Merge pull request #273 from CoolJWB/development

Updated my own code
This commit is contained in:
CoolJWB 2020-08-18 09:40:56 +02:00 committed by GitHub
commit ebc07f6259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View File

@ -22,8 +22,8 @@ import org.bukkit.potion.PotionEffectType;
public class Monitors extends FreedomService public class Monitors extends FreedomService
{ {
@Getter @Getter
private List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>(); private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
private Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>(); private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS, private final List<PotionEffectType> 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". PotionEffectType.LEVITATION, PotionEffectType.CONFUSION, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.HUNGER)); // A list of all effects that count as "troll".
@ -33,26 +33,23 @@ public class Monitors extends FreedomService
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
{ {
for (Player player : recentlyThrownPotions.keySet()) for (Player player : recentlyThrownPotions.keySet())
{
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getPotionSpy())
{ {
List<ThrownPotion> playerThrownPotions = recentlyThrownPotions.get(player); List<ThrownPotion> playerThrownPotions = recentlyThrownPotions.get(player);
ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position. ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position.
int potionsThrown = playerThrownPotions.size(); int potionsThrown = playerThrownPotions.size();
boolean trollPotions = false; int trollPotions = 0;
for (ThrownPotion potion : playerThrownPotions) for (ThrownPotion potion : playerThrownPotions)
{ {
if (isTrollPotion(potion)) 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.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(), 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(); recentlyThrownPotions.clear();
}, 0L, 40L); }, 0L, 40L);

View File

@ -134,7 +134,10 @@ public class FAWEBridge extends FreedomService
public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern) public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern)
{ {
// Add the broken blocks to CoreProtect. // 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<Block> blocks = new ArrayList<>(); List<Block> blocks = new ArrayList<>();
for (BlockVector3 blockVector3 : region) for (BlockVector3 blockVector3 : region)