added logging

This commit is contained in:
Elias Müller 2024-10-05 19:24:36 +02:00
parent 39af3589e3
commit 156b7e6b61

View File

@ -92,6 +92,8 @@ public class PixelBlock {
player.sendMessage(Component.text("Dieser Pixelblock gehört nicht dir!", NamedTextColor.RED));
return;
}
Main.plugin.getLogger().info(String.format("'%s' entered PixelBlock '%s' at %s", player.getName(), this.blockUUID, this.pixelBlockLocation.toString()));
getBlockTaskChain()
.async(() -> {
this.lastEntryLocation = player.getLocation();
@ -103,6 +105,7 @@ public class PixelBlock {
}
public void exitBlock(@NotNull Player player) {
Main.plugin.getLogger().info(String.format("%s exited PixelBlock", player.getName()));
player.teleport(this.lastEntryLocation);
}
@ -212,6 +215,8 @@ public class PixelBlock {
} else {
spawnInteraction(false);
}
Main.plugin.getLogger().info(String.format("Placed %d entities for PixelBlock '%s'", this.pixels.size(), this.blockUUID));
})
.execute();
}
@ -224,6 +229,7 @@ public class PixelBlock {
@Nullable PixelBlock blockAtLocation = PixelBlock.getPixelBlockFromPlacedLocation(newLocation);
if(blockAtLocation != null && blockAtLocation != this) throw new IllegalArgumentException("Es können nicht mehrere Pixelblöcke ineinander platziert werden.");
Main.plugin.getLogger().info(String.format("Placing PixelBlock '%s' at %s", this.blockUUID, placeLocation));
this.pixelBlockLocation = newLocation;
this.facingDirection = direction;
updateEntities();
@ -241,6 +247,8 @@ public class PixelBlock {
p.teleport(this.lastEntryLocation);
});
Main.plugin.getLogger().info(String.format("Destroying PixelBlock '%s' at %s", this.blockUUID, pixelBlockLocation));
this.pixelWorld.getEntitiesInWorld().stream()
.filter(entity -> entity instanceof Item)
.forEach(entity -> entity.teleport(this.lastEntryLocation));
@ -259,6 +267,7 @@ public class PixelBlock {
chunk.getEntities();
}
Main.plugin.getLogger().info(String.format("Removing %d entities for PixelBlock '%s'", this.pixels.size(), this.blockUUID));
this.pixels.forEach(Pixel::destroy);
this.pixels.clear();
@ -273,7 +282,7 @@ public class PixelBlock {
}
this.pixelBlockLocation.getWorld().getEntities().stream()
.filter(this::isRelevantEntity)
.filter(this::isPixelBlockComponent)
.filter(entity -> entity.getLocation()
.add(0, hitboxOffset, 0)
.toBlockLocation()
@ -281,7 +290,7 @@ public class PixelBlock {
.forEach(Entity::remove);
}
private boolean isRelevantEntity(Entity entity) {
private boolean isPixelBlockComponent(Entity entity) {
return entity.getType().equals(EntityType.BLOCK_DISPLAY)
|| entity.getType().equals(EntityType.INTERACTION)
|| entity.getType().equals(EntityType.ITEM_DISPLAY);