TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/anticheat/AntiNuke.java
spacerocket62 3c22de71de A lot of re-organization included in this. This is a combination of Video's 1.17 update with my structural changes and NMS removals. This technically isn't a Jira issue so I wasn't aware what to call it, so I'll call it 1.17.
- NMS has been removed for now. SignBlocker.java has to be finished and moved to kyori's component system instead of NMS, but at this moment it is commented out.
- The main class uses proper variable naming conventions, as do the command classes.
- I've also incorporated manual verification into /verify, and commented out /manuallyverify. The new usage for /verify is /verify [-m] <code | player>, -m being a manual verification.
2021-12-04 23:01:02 -08:00

72 lines
2.3 KiB
Java

package me.totalfreedom.totalfreedommod.anticheat;
import me.totalfreedom.totalfreedommod.services.AbstractService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class AntiNuke extends AbstractService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
return;
}
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.playerList.getPlayer(player);
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
{
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
fPlayer.resetBlockDestroyCount();
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
return;
}
Player player = event.getPlayer();
FPlayer fPlayer = plugin.playerList.getPlayer(player);
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
{
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
fPlayer.resetBlockPlaceCount();
event.setCancelled(true);
}
}
}