parent
2b2c732850
commit
19dcc4c482
|
@ -10,4 +10,5 @@ Changelogs
|
||||||
|
|
||||||
v1.3 <v1.3>
|
v1.3 <v1.3>
|
||||||
v1.4 <v1.4>
|
v1.4 <v1.4>
|
||||||
v1.5 <v1.5>
|
v1.5 <v1.5>
|
||||||
|
v1.6 <v1.6>
|
|
@ -0,0 +1,16 @@
|
||||||
|
.. include:: ../common.rst
|
||||||
|
|
||||||
|
.. _qol_v1.6:
|
||||||
|
|
||||||
|
QoL v1.6
|
||||||
|
========
|
||||||
|
|
||||||
|
Additions
|
||||||
|
---------
|
||||||
|
* `Grief Alert`_ - Monitors for actions (starting a fire, dumping lava, or placing TnT) and alerts when encountered
|
||||||
|
|
||||||
|
.. _Grief Alert: https://git.etztech.xyz/Etzelia/QoL/issues/22
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
None
|
|
@ -48,3 +48,8 @@ Auto Dynmap Hide
|
||||||
|
|
||||||
If Dynmap is detected on the server, QoL will hide a user on the dynmap when they spec. When they come out of spec, their previous visibility state will be restored.
|
If Dynmap is detected on the server, QoL will hide a user on the dynmap when they spec. When they come out of spec, their previous visibility state will be restored.
|
||||||
|
|
||||||
|
|
||||||
|
Grief Alert
|
||||||
|
-----------
|
||||||
|
|
||||||
|
If a player places TnT, starts a fire, or dumps lava, everyone with the ``qol.griefalert`` permission is notified as well as an optional Discord ping.
|
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<groupId>xyz.etztech</groupId>
|
<groupId>xyz.etztech</groupId>
|
||||||
<artifactId>QoL</artifactId>
|
<artifactId>QoL</artifactId>
|
||||||
<!-- Version is used in plugin.yml -->
|
<!-- Version is used in plugin.yml -->
|
||||||
<version>1.5</version>
|
<version>1.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<!-- Plugin Information -->
|
<!-- Plugin Information -->
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.dynmap.DynmapAPI;
|
import org.dynmap.DynmapAPI;
|
||||||
import xyz.etztech.qol.commands.*;
|
import xyz.etztech.qol.commands.*;
|
||||||
import xyz.etztech.qol.listeners.*;
|
import xyz.etztech.qol.listeners.*;
|
||||||
|
import xyz.etztech.qol.other.GriefAlert;
|
||||||
import xyz.etztech.qol.other.LinkCommand;
|
import xyz.etztech.qol.other.LinkCommand;
|
||||||
import xyz.etztech.qol.other.TPSRunnable;
|
import xyz.etztech.qol.other.TPSRunnable;
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ public class QoL extends JavaPlugin {
|
||||||
private static boolean timeout = false;
|
private static boolean timeout = false;
|
||||||
private static List<String> audits = new ArrayList<>();
|
private static List<String> audits = new ArrayList<>();
|
||||||
private static List<LinkCommand> links = new ArrayList<>();
|
private static List<LinkCommand> links = new ArrayList<>();
|
||||||
|
private GriefAlert griefAlert;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -68,6 +70,10 @@ public class QoL extends JavaPlugin {
|
||||||
getServer().getPluginManager().registerEvents(commandPreprocessListener, this);
|
getServer().getPluginManager().registerEvents(commandPreprocessListener, this);
|
||||||
DeathListener deathListener = new DeathListener(this);
|
DeathListener deathListener = new DeathListener(this);
|
||||||
getServer().getPluginManager().registerEvents(deathListener, this);
|
getServer().getPluginManager().registerEvents(deathListener, this);
|
||||||
|
PlayerBucketEmptyListener playerBucketEmptyListener = new PlayerBucketEmptyListener(this);
|
||||||
|
getServer().getPluginManager().registerEvents(playerBucketEmptyListener, this);
|
||||||
|
BlockPlaceListener blockPlaceListener = new BlockPlaceListener(this);
|
||||||
|
getServer().getPluginManager().registerEvents(blockPlaceListener, this);
|
||||||
|
|
||||||
// Add commands
|
// Add commands
|
||||||
MainCommand mainCommand = new MainCommand(this);
|
MainCommand mainCommand = new MainCommand(this);
|
||||||
|
@ -143,6 +149,9 @@ public class QoL extends JavaPlugin {
|
||||||
// TPS Check
|
// TPS Check
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), new TPSRunnable(this), 0, EtzTechUtil.minutesToTicks(1));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +275,10 @@ public class QoL extends JavaPlugin {
|
||||||
|
|
||||||
public DynmapAPI getDynmap() { return dynmap; }
|
public DynmapAPI getDynmap() { return dynmap; }
|
||||||
|
|
||||||
|
public GriefAlert getGriefAlert() {
|
||||||
|
return griefAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void runTask(final String command) {
|
private void runTask(final String command) {
|
||||||
Bukkit.getScheduler().runTask(QoL.instance, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
|
Bukkit.getScheduler().runTask(QoL.instance, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
|
||||||
|
|
|
@ -19,5 +19,9 @@ public class BlockIgniteListener implements Listener {
|
||||||
if (plugin.getConfig().getBoolean("disable-fire." + cause.name().toLowerCase())) {
|
if (plugin.getConfig().getBoolean("disable-fire." + cause.name().toLowerCase())) {
|
||||||
event.setCancelled(true);
|
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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if( event.getBlockPlaced().getType() == Material.TNT) {
|
||||||
|
plugin.getGriefAlert().addAlert(player.getName() + " placed TnT.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if( event.getBucket() == Material.LAVA_BUCKET) {
|
||||||
|
plugin.getGriefAlert().addAlert(player.getName() + " poured lava.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
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);
|
||||||
|
if (num == 1) {
|
||||||
|
String webhook = plugin.getConfig().getString("grief-alert.webhook", "");
|
||||||
|
String message = "@here " + alert;
|
||||||
|
if (StringUtils.isNotEmpty(webhook)) {
|
||||||
|
Map<String, String> data = new HashMap<>();
|
||||||
|
data.put("username", "Grief Alert");
|
||||||
|
data.put("content", message);
|
||||||
|
CoreWeb.asyncPost(plugin, webhook, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (num == lines) {
|
||||||
|
alert(alert + " Suppressing more alerts for a while...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void alert(String alert) {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player.hasPermission("qol.griefalert")) {
|
||||||
|
EtzTechUtil.sms(player, ChatColor.RED + alert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,10 @@ tps:
|
||||||
threshold: 12
|
threshold: 12
|
||||||
webhook: ''
|
webhook: ''
|
||||||
|
|
||||||
|
grief-alert:
|
||||||
|
lines: 5
|
||||||
|
webhook: ''
|
||||||
|
|
||||||
# The range after which a player will be marked as "outside the border"
|
# The range after which a player will be marked as "outside the border"
|
||||||
worldinfo:
|
worldinfo:
|
||||||
world: 5000
|
world: 5000
|
||||||
|
|
|
@ -86,6 +86,9 @@ permissions:
|
||||||
qol.tpconfirm:
|
qol.tpconfirm:
|
||||||
description: Makes the user confirm they want to TP out of spec
|
description: Makes the user confirm they want to TP out of spec
|
||||||
default: op
|
default: op
|
||||||
|
qol.griefalert:
|
||||||
|
description: Alerts the user when monitored actions are encountered
|
||||||
|
default: op
|
||||||
qol.whitelist.bypass:
|
qol.whitelist.bypass:
|
||||||
description: Allows someone into the server when Whitelist is enabled
|
description: Allows someone into the server when Whitelist is enabled
|
||||||
default: op
|
default: op
|
||||||
|
|
Loading…
Reference in New Issue