Skip to content

Commit

Permalink
utilize util more generically
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 2, 2024
1 parent a07769f commit 24fe119
Show file tree
Hide file tree
Showing 40 changed files with 261 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.ItemUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -76,7 +76,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
|| burrowMaterial.equals(Material.DIRT) // Fixes false positives when trampling farmland
|| burrowMaterial.equals(Material.SAND)
|| burrowMaterial.equals(Material.GRAVEL)
|| ItemUtil.isShulkerBox(burrowMaterial)
|| MaterialUtil.isShulkerBox(burrowMaterial)
) return;

if (preventIfBlockAboveBurrow || burrowBlock.getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
Expand Down Expand Up @@ -120,7 +120,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
}

// Beacon and Indestructibles
if (burrowMaterial.equals(Material.BEACON) || ItemUtil.isIndestructible(burrowMaterial)) {
if (burrowMaterial.equals(Material.BEACON) || MaterialUtil.isIndestructible(burrowMaterial)) {
player.damage(damageWhenMovingInBurrow);
if (shouldTeleportUp) teleportUpAndCenter(player, burrowBlock.getLocation());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -105,7 +105,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (spawn_AlsoRemoveElytraOnLowTPS) {
player.getScheduler().run(plugin, removeElytra -> {
PlayerInventory playerInv = player.getInventory();
if (playerInv.getChestplate() != null && playerInv.getChestplate().getType().equals(Material.ELYTRA)) {
if (MaterialUtil.isElytra(playerInv.getChestplate())) {
final ItemStack elytra = playerInv.getChestplate();
playerInv.setChestplate(null);
player.getWorld().dropItemNaturally(playerLoc, elytra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -114,7 +114,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (global_AlsoRemoveOnLowTPS) {
player.getScheduler().run(plugin, removeElytra -> {
PlayerInventory playerInv = player.getInventory();
if (playerInv.getChestplate() != null && playerInv.getChestplate().getType().equals(Material.ELYTRA)) {
if (MaterialUtil.isElytra(playerInv.getChestplate())) {
final ItemStack elytra = playerInv.getChestplate();
playerInv.setChestplate(null);
player.getWorld().dropItemNaturally(playerLoc, elytra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -111,7 +111,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (ceiling_AlsoRemoveOnLowTPS) {
player.getScheduler().run(plugin, removeElytra -> {
PlayerInventory playerInv = player.getInventory();
if (playerInv.getChestplate() != null && playerInv.getChestplate().getType().equals(Material.ELYTRA)) {
if (MaterialUtil.isElytra(playerInv.getChestplate())) {
final ItemStack elytra = playerInv.getChestplate();
playerInv.setChestplate(null);
player.getWorld().dropItemNaturally(playerLoc, elytra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import org.bukkit.Material;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;

import java.util.HashMap;
import java.util.UUID;
Expand Down Expand Up @@ -82,10 +83,12 @@ private void onElytraOpen(EntityToggleGlideEvent event) {
player.getScheduler().run(plugin, kick -> player.kick(AnarchyExploitFixes.getLang(player.locale()).elytra_disablePacketElytraFly), null);
} else {
player.getScheduler().run(plugin, removeElytra -> {
final ItemStack chestItem = player.getInventory().getChestplate();
if (chestItem == null || !chestItem.getType().equals(Material.ELYTRA)) return;
player.getInventory().setChestplate(null);
player.getWorld().dropItemNaturally(player.getEyeLocation(), chestItem).setPickupDelay(1);
PlayerInventory playerInv = player.getInventory();
if (MaterialUtil.isElytra(playerInv.getChestplate())) {
ItemStack elytra = playerInv.getChestplate();
playerInv.setChestplate(null);
player.getWorld().dropItemNaturally(player.getLocation(), elytra);
}
if (notify) player.sendMessage(AnarchyExploitFixes.getLang(player.locale()).elytra_disablePacketElytraFly);
}, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class RevertOverstacked implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class RevertUnbreakables implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class BanSpecificBlocks implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Map;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class HigherEnchants implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Map;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class InapplicableEnchants implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.*;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.*;

public class IncompatibleEnchants implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Map;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class SpecificHigherEnchants implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.LogUtil.moduleLog;

public class DamageModifierTags implements AnarchyExploitFixesModule, Listener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.LogUtil.materialNotRecognized;
import static me.moomoo.anarchyexploitfixes.utils.LogUtil.moduleLog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;

public class BanPlayerHeads implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.ItemUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
Expand All @@ -11,7 +11,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.PlayerInventory;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isSpawnEgg;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isSpawnEgg;

public class PreventUsingSpawnEggs implements AnarchyExploitFixesModule, Listener {

Expand Down Expand Up @@ -50,7 +50,7 @@ public void disable() {
private void onInteract(PlayerInteractEvent event) {
if (event.getAction().isLeftClick()) return;
PlayerInventory inventory = event.getPlayer().getInventory();
if (ItemUtil.isSpawnEgg(inventory.getItemInMainHand()) || ItemUtil.isSpawnEgg(inventory.getItemInOffHand())) {
if (MaterialUtil.isSpawnEgg(inventory.getItemInMainHand()) || MaterialUtil.isSpawnEgg(inventory.getItemInOffHand())) {
event.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isSpawnEgg;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isShulkerBox;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isSpawnEgg;

public class RemoveSpawnEggs implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.HashSet;
import java.util.List;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isIndestructible;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isIndestructible;

public class PistonExplodePermBlockRemoval implements AnarchyExploitFixesModule, Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.HashSet;
import java.util.List;

import static me.moomoo.anarchyexploitfixes.utils.ItemUtil.isIndestructible;
import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.isIndestructible;

public class PistonPlaceWhileRetractPermBlockRemoval implements AnarchyExploitFixesModule, Listener {

Expand Down
Loading

0 comments on commit 24fe119

Please sign in to comment.