Remove GriefAlert

Signed-off-by: Etzelia <etzelia@hotmail.com>
grief
Etzelia 2020-08-02 14:01:05 -05:00
parent cc11677a18
commit d9a1a0fbe9
No known key found for this signature in database
GPG Key ID: 708511AE7ABC5314
7 changed files with 3 additions and 138 deletions

View File

@ -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<String> audits = new ArrayList<>();
private static List<LinkCommand> 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));
}

View File

@ -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.");
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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<String, Integer> 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<String, String> 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);
}
}
}
}

View File

@ -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'

View File

@ -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