Skip to content

Commit

Permalink
feat: world placeholder when logging (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexlManu authored Jan 9, 2024
1 parent 243f083 commit e0f6a78
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class NoIllegalsPlugin extends JavaPlugin {
private static final String ITEM_PLACEHOLDER = "[item]";
private static final String AMOUNT_PLACEHOLDER = "[amount]";
private static final String ENCHANTMENTS_PLACEHOLDER = "[enchantments]";
private static final String WORLD_PLACEHOLDER = "[world]";

private boolean checkOPPlayers;
private String infoLogText = "";
Expand Down Expand Up @@ -164,6 +165,7 @@ public void logInventoryOpen(Player player, String inventoryTitle, int x, int y,
inventoryOpenLogText
.replace("[block_type]", inventoryTitle)
.replace(PLAYER_NAME_PLACEHOLDER, player.getName())
.replace(WORLD_PLACEHOLDER, player.getLocation().getWorld().getName())
.replace("[x]", String.valueOf(x))
.replace("[y]", String.valueOf(y))
.replace("[z]", String.valueOf(z)));
Expand All @@ -187,6 +189,7 @@ public void logPlayerItemReceive(Player player, ItemStack itemStack) {
.replace("[x]", String.valueOf(player.getLocation().getBlockX()))
.replace("[y]", String.valueOf(player.getLocation().getBlockY()))
.replace("[z]", String.valueOf(player.getLocation().getBlockZ()))
.replace(WORLD_PLACEHOLDER, player.getLocation().getWorld().getName())
.replace(ENCHANTMENTS_PLACEHOLDER,
itemStack.getEnchantments().entrySet().stream()
.map(entry -> entry.getKey().getKey() + "=" + entry.getValue())
Expand Down Expand Up @@ -215,6 +218,7 @@ public void logPlayerItemSent(Player player, ItemStack itemStack,
.replace("[x]", String.valueOf(player.getLocation().getBlockX()))
.replace("[y]", String.valueOf(player.getLocation().getBlockY()))
.replace("[z]", String.valueOf(player.getLocation().getBlockZ()))
.replace(WORLD_PLACEHOLDER, player.getLocation().getWorld().getName())
.replace(ENCHANTMENTS_PLACEHOLDER,
itemStack.getEnchantments().entrySet().stream()
.map(entry -> entry.getKey().getKey() + "=" + entry.getValue())
Expand All @@ -233,6 +237,7 @@ public void logInventoryCreation(Player player, String inventoryType,
inventoryCreationLogText
.replace("[inventory_type]", inventoryType)
.replace(PLAYER_NAME_PLACEHOLDER, player.getName())
.replace(WORLD_PLACEHOLDER, player.getLocation().getWorld().getName())
.replace("[x]", String.valueOf(location.getBlockX()))
.replace("[y]", String.valueOf(location.getBlockY()))
.replace("[z]", String.valueOf(location.getBlockZ())));
Expand All @@ -256,6 +261,7 @@ public void logPlayerDroppedItem(Player player, ItemStack itemStack) {
.replace("[x]", String.valueOf(player.getLocation().getBlockX()))
.replace("[y]", String.valueOf(player.getLocation().getBlockY()))
.replace("[z]", String.valueOf(player.getLocation().getBlockZ()))
.replace(WORLD_PLACEHOLDER, player.getLocation().getWorld().getName())
.replace(ENCHANTMENTS_PLACEHOLDER,
itemStack.getEnchantments().entrySet().stream()
.map(entry -> entry.getKey().getKey() + "=" + entry.getValue())
Expand Down

0 comments on commit e0f6a78

Please sign in to comment.