From 2bc9733955bc2ecca15656a35797fb823a1c2f37 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sun, 2 Aug 2020 23:11:42 +0200 Subject: [PATCH] Remove GriefAlert (#58) Remove GriefAlert Signed-off-by: Etzelia Reviewed-on: https://git.etztech.xyz/Minecraft/QoL/pulls/58 Reviewed-by: ZeroHD --- src/main/java/xyz/etztech/qol/QoL.java | 18 +----- .../qol/listeners/BlockIgniteListener.java | 4 -- .../qol/listeners/BlockPlaceListener.java | 27 --------- .../listeners/PlayerBucketEmptyListener.java | 27 --------- .../xyz/etztech/qol/other/GriefAlert.java | 58 ------------------- src/main/resources/config.yml | 4 -- src/main/resources/plugin.yml | 3 - 7 files changed, 3 insertions(+), 138 deletions(-) delete mode 100644 src/main/java/xyz/etztech/qol/listeners/BlockPlaceListener.java delete mode 100644 src/main/java/xyz/etztech/qol/listeners/PlayerBucketEmptyListener.java delete mode 100644 src/main/java/xyz/etztech/qol/other/GriefAlert.java diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 9fa8900..d2ec1ac 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -4,7 +4,6 @@ import net.ess3.api.IEssentials; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -15,11 +14,12 @@ import org.dynmap.markers.MarkerIcon; import org.dynmap.markers.MarkerSet; import xyz.etztech.qol.commands.*; import xyz.etztech.qol.listeners.*; -import xyz.etztech.qol.other.GriefAlert; import xyz.etztech.qol.other.LinkCommand; import xyz.etztech.qol.other.TPSRunnable; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; import java.util.logging.Logger; public class QoL extends JavaPlugin { @@ -44,8 +44,6 @@ public class QoL extends JavaPlugin { private static boolean timeout = false; private static List audits = new ArrayList<>(); private static List links = new ArrayList<>(); - - private GriefAlert griefAlert; public void onEnable() { instance = this; @@ -96,8 +94,6 @@ public class QoL extends JavaPlugin { new BlockIgniteListener(this); new CommandPreprocessListener(this); new DeathListener(this); - new PlayerBucketEmptyListener(this); - new BlockPlaceListener(this); // Add commands new MainCommand(this); @@ -159,10 +155,6 @@ public class QoL extends JavaPlugin { // TPS Check Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), new TPSRunnable(this), 0, EtzTechUtil.minutesToTicks(1)); - - // Grief Alert - griefAlert = new GriefAlert(this); - Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), griefAlert, 0, EtzTechUtil.minutesToTicks(10)); } } @@ -290,10 +282,6 @@ public class QoL extends JavaPlugin { public DynmapAPI getDynmap() { return dynmap; } - public GriefAlert getGriefAlert() { - return griefAlert; - } - public void runTask(final String command) { Bukkit.getScheduler().runTask(QoL.instance, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)); } diff --git a/src/main/java/xyz/etztech/qol/listeners/BlockIgniteListener.java b/src/main/java/xyz/etztech/qol/listeners/BlockIgniteListener.java index be9da71..c94b138 100644 --- a/src/main/java/xyz/etztech/qol/listeners/BlockIgniteListener.java +++ b/src/main/java/xyz/etztech/qol/listeners/BlockIgniteListener.java @@ -20,9 +20,5 @@ public class BlockIgniteListener implements Listener { if (plugin.getConfig().getBoolean("disable-fire." + cause.name().toLowerCase())) { event.setCancelled(true); } - - if (event.getPlayer() != null && (cause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL || cause == BlockIgniteEvent.IgniteCause.FIREBALL)) { - plugin.getGriefAlert().addAlert(event.getPlayer().getName() + " started a fire."); - } } } diff --git a/src/main/java/xyz/etztech/qol/listeners/BlockPlaceListener.java b/src/main/java/xyz/etztech/qol/listeners/BlockPlaceListener.java deleted file mode 100644 index aeec12d..0000000 --- a/src/main/java/xyz/etztech/qol/listeners/BlockPlaceListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package xyz.etztech.qol.listeners; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import xyz.etztech.qol.QoL; - -public class BlockPlaceListener implements Listener { - - QoL plugin; - - public BlockPlaceListener(QoL plugin) { - this.plugin = plugin; - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) { - Player player = event.getPlayer(); - if( event.getBlockPlaced().getType() == Material.TNT) { - plugin.getGriefAlert().addAlert(player.getName() + " placed TnT."); - } - } -} diff --git a/src/main/java/xyz/etztech/qol/listeners/PlayerBucketEmptyListener.java b/src/main/java/xyz/etztech/qol/listeners/PlayerBucketEmptyListener.java deleted file mode 100644 index 9cef25a..0000000 --- a/src/main/java/xyz/etztech/qol/listeners/PlayerBucketEmptyListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package xyz.etztech.qol.listeners; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import xyz.etztech.qol.QoL; - -public class PlayerBucketEmptyListener implements Listener { - - QoL plugin; - - public PlayerBucketEmptyListener(QoL plugin) { - this.plugin = plugin; - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler - public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { - Player player = event.getPlayer(); - if( event.getBucket() == Material.LAVA_BUCKET) { - plugin.getGriefAlert().addAlert(player.getName() + " poured lava."); - } - } -} diff --git a/src/main/java/xyz/etztech/qol/other/GriefAlert.java b/src/main/java/xyz/etztech/qol/other/GriefAlert.java deleted file mode 100644 index 7f1a4c7..0000000 --- a/src/main/java/xyz/etztech/qol/other/GriefAlert.java +++ /dev/null @@ -1,58 +0,0 @@ -package xyz.etztech.qol.other; - -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import xyz.etztech.core.web.CoreWeb; -import xyz.etztech.qol.EtzTechUtil; -import xyz.etztech.qol.QoL; - -import java.util.HashMap; -import java.util.Map; - -public class GriefAlert implements Runnable { - private Map alerts; - - private QoL plugin; - - public GriefAlert(QoL plugin) { - this.plugin = plugin; - } - - - @Override - public void run() { - alerts = new HashMap<>(); - } - - public void addAlert(String alert) { - int num = alerts.getOrDefault(alert, 0); - alerts.put(alert, ++num); - int lines = plugin.getConfig().getInt("grief-alert.lines", 5); - if (num < lines) { - alert(alert); - } else if (num == lines) { - String extra = " Suppressing more alerts for a while"; - String webhook = plugin.getConfig().getString("grief-alert.webhook", ""); - String message = "@here " + alert; - if (StringUtils.isNotEmpty(webhook)) { - extra += " and pinging Discord"; - Map data = new HashMap<>(); - data.put("username", "Grief Alert"); - data.put("content", message); - CoreWeb.asyncPost(plugin, webhook, data); - } - extra += "..."; - alert(alert + extra); - } - } - - private void alert(String alert) { - for (Player player : Bukkit.getOnlinePlayers()) { - if (player.hasPermission("qol.griefalert")) { - EtzTechUtil.sms(player, ChatColor.RED + alert); - } - } - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index aa1ea83..17b14b4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -43,10 +43,6 @@ tps: threshold: 12 webhook: '' -grief-alert: - lines: 5 - webhook: '' - # The link to open for portal setup instructions portal-link: 'https://i.imgur.com/tQCbI0C.png' diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 23f7b4a..98041e7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -95,9 +95,6 @@ permissions: qol.specconfirm: description: Makes the user confirm they want to run (configurable) command(s) out of spec default: op - qol.griefalert: - description: Alerts the user when monitored actions are encountered - default: op qol.whitelist.bypass: description: Allows someone into the server when Whitelist is enabled default: op