From 073a618035e223b9d77eef2d0f776738e7c395c4 Mon Sep 17 00:00:00 2001 From: William Bergh Date: Tue, 4 Aug 2020 00:07:50 +0200 Subject: [PATCH 1/3] Hotfix to potion spy Note to self: don't do crack cocain when you code, this will actually announce the potion splashes to admins (also fixed a spell issue). --- .../me/totalfreedom/totalfreedommod/Monitors.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java index a74ee0aa..84ac8518 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java @@ -22,8 +22,8 @@ import org.bukkit.potion.PotionEffectType; public class Monitors extends FreedomService { @Getter - private List> allThrownPotions = new ArrayList<>(); - private Map> recentlyThrownPotions = new HashMap<>(); + private final List> allThrownPotions = new ArrayList<>(); + private final Map> recentlyThrownPotions = new HashMap<>(); private final List badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.LEVITATION, PotionEffectType.CONFUSION, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.HUNGER)); // A list of all effects that count as "troll". @@ -39,19 +39,19 @@ public class Monitors extends FreedomService List playerThrownPotions = recentlyThrownPotions.get(player); ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position. int potionsThrown = playerThrownPotions.size(); - boolean trollPotions = false; + int trollPotions = 0; for (ThrownPotion potion : playerThrownPotions) { if (isTrollPotion(potion)) { - trollPotions = true; + trollPotions++; } } - FUtil.playerMsg(player, ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", + plugin.al.messageAllAdmins(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(), - latestThrownPotion.getWorld().getName(), trollPotions ? " &c(most likely troll potion/potions)" : ""))); + latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : ""))); } } recentlyThrownPotions.clear(); From d74846cde627fc0627eda89c16e3cac6674f0991 Mon Sep 17 00:00:00 2001 From: William Bergh Date: Sat, 15 Aug 2020 15:33:29 +0200 Subject: [PATCH 2/3] Fixed my bad code --- .../totalfreedommod/Monitors.java | 27 +++++++++---------- .../totalfreedommod/bridge/FAWEBridge.java | 5 +++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java index 84ac8518..f9d4d130 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java @@ -34,25 +34,22 @@ public class Monitors extends FreedomService { for (Player player : recentlyThrownPotions.keySet()) { - if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getPotionSpy()) + List playerThrownPotions = recentlyThrownPotions.get(player); + ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position. + int potionsThrown = playerThrownPotions.size(); + int trollPotions = 0; + + for (ThrownPotion potion : playerThrownPotions) { - List playerThrownPotions = recentlyThrownPotions.get(player); - ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position. - int potionsThrown = playerThrownPotions.size(); - int trollPotions = 0; - - for (ThrownPotion potion : playerThrownPotions) + if (isTrollPotion(potion)) { - if (isTrollPotion(potion)) - { - trollPotions++; - } + trollPotions++; } - - plugin.al.messageAllAdmins(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", - player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(), - latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : ""))); } + + plugin.al.messageAllAdmins(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", + player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(), + latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : ""))); } recentlyThrownPotions.clear(); }, 0L, 40L); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/FAWEBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/FAWEBridge.java index 5a7e4143..d7182949 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/FAWEBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/FAWEBridge.java @@ -134,7 +134,10 @@ public class FAWEBridge extends FreedomService public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern) { // Add the broken blocks to CoreProtect. - World world = server.getWorld(region.getWorld().getName()); + if (world == null || !world.getName().equals(editSession.getWorld().getName())) + { + world = server.getWorld(editSession.getWorld().getName()); + } List blocks = new ArrayList<>(); for (BlockVector3 blockVector3 : region) From 6a7a6e74e3f86e1830bd8f28298f9ddf3bc3f554 Mon Sep 17 00:00:00 2001 From: William Bergh Date: Tue, 18 Aug 2020 09:37:19 +0200 Subject: [PATCH 3/3] Update code --- src/main/java/me/totalfreedom/totalfreedommod/Monitors.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java index f9d4d130..eef73c7e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java @@ -47,7 +47,7 @@ public class Monitors extends FreedomService } } - plugin.al.messageAllAdmins(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", + plugin.sl.messageAllStaff(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.", player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(), latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : ""))); }