From 72db71b3cf3847e55928dcc0881bf05ca484f72e Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Sat, 29 Dec 2018 12:41:48 -0700 Subject: [PATCH] yay done --- TotalFreedomMod.iml | 16 ++--- pom.xml | 6 +- .../totalfreedommod/LoginProcess.java | 2 +- .../totalfreedommod/TotalFreedomMod.java | 4 +- .../blocking/BlockBlocker.java | 25 +++++++ .../blocking/EventBlocker.java | 69 +++++++++++++++++++ .../bridge/LibsDisguisesBridge.java | 14 +--- .../bridge/WorldEditBridge.java | 30 +++++++- .../totalfreedommod/caging/CageData.java | 14 ++-- .../command/Command_disguisetoggle.java | 7 +- .../command/Command_setlimit.java | 4 +- .../totalfreedommod/command/Command_tag.java | 18 ++--- .../command/Command_tagnyan.java | 18 ++--- .../command/Command_undisguiseall.java | 17 +++-- .../command/Command_vanish.java | 2 +- .../totalfreedommod/util/FUtil.java | 2 +- 16 files changed, 187 insertions(+), 61 deletions(-) diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml index 272d131b..e2f46a38 100644 --- a/TotalFreedomMod.iml +++ b/TotalFreedomMod.iml @@ -27,25 +27,24 @@ - + - - + + - + + + - - - - + @@ -63,7 +62,6 @@ - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 60b20ebd..8764960d 100644 --- a/pom.xml +++ b/pom.xml @@ -123,14 +123,14 @@ com.github.TFPatches TF-LibsDisguises - c213295f95 + 89efd2c93e provided com.github.TFPatches TF-WorldEdit - 2e79570525 + c0f82ebeff provided @@ -144,7 +144,7 @@ org.bukkit craftbukkit - 1.13.1-R0.1-SNAPSHOT + 1.13.2-R0.1-SNAPSHOT provided diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index a1c2e839..2530bbb6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -223,7 +223,7 @@ public class LoginProcess extends FreedomService { if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) { - player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins."); + player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins."); } if (lockdownEnabled) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 5a77a565..b8c10eb3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -246,8 +246,8 @@ public class TotalFreedomMod extends AeroPlugin cpb = bridges.registerService(CoreProtectBridge.class); esb = bridges.registerService(EssentialsBridge.class); // Disabled so I can at least load TFM as these plugins aren't updated - //ldb = bridges.registerService(LibsDisguisesBridge.class); - //web = bridges.registerService(WorldEditBridge.class); + ldb = bridges.registerService(LibsDisguisesBridge.class); + web = bridges.registerService(WorldEditBridge.class); //wgb = bridges.registerService(WorldGuardBridge.class); amp = bridges.registerService(AMP.class); bridges.start(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index b5703b43..d86bb27b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -9,6 +9,7 @@ import me.totalfreedom.totalfreedommod.util.MaterialGroup; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.Dispenser; import org.bukkit.block.ShulkerBox; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -126,4 +127,28 @@ public class BlockBlocker extends FreedomService } } + @EventHandler(priority = EventPriority.HIGH) + public void onDispenserPlace(BlockPlaceEvent event) + { + Block block = event.getBlock(); + if (block.getType().equals(Material.DISPENSER)) + { + Dispenser dispenser = (Dispenser)block.getState(); + boolean empty = true; + for (ItemStack itemStack : dispenser.getInventory().getContents()) + { + if (itemStack != null) + { + empty = false; + break; + } + } + if (!empty) + { + dispenser.getInventory().clear(); + event.getPlayer().sendMessage(ChatColor.RED + "For security reasons, dispenser has been emptied."); + } + } + } + } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java index 1fdf0586..e4374584 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java @@ -3,6 +3,15 @@ package me.totalfreedom.totalfreedommod.blocking; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.util.FLog; +import me.totalfreedom.totalfreedommod.util.MaterialGroup; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.block.Dispenser; +import org.bukkit.block.ShulkerBox; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.entity.Entity; import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; @@ -21,6 +30,8 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.FireworkExplodeEvent; import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.inventory.ItemStack; public class EventBlocker extends FreedomService { @@ -194,4 +205,62 @@ public class EventBlocker extends FreedomService } } + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerRespawn(PlayerRespawnEvent event) + { + double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + if (maxHealth < 1) + { + for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers()) + { + event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier); + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockDispense(BlockDispenseEvent event) + { + if (event.getBlock() instanceof ShulkerBox) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onEntityBlockForm(EntityBlockFormEvent event) + { + FLog.info("block form by entity fired"); + if (event.getBlock() instanceof Dispenser) + { + Dispenser dispenser = (Dispenser)event.getBlock(); + ItemStack[] items = dispenser.getInventory().getContents(); + for (ItemStack item : items) + { + if (item != null && MaterialGroup.SHULKER_BOXES.contains(item.getType())) + { + dispenser.getInventory().clear(); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockForm(BlockFormEvent event) + { + FLog.info("block form fired"); + if (event.getBlock() instanceof Dispenser) + { + Dispenser dispenser = (Dispenser)event.getBlock(); + ItemStack[] items = dispenser.getInventory().getContents(); + for (ItemStack item : items) + { + if (item != null && MaterialGroup.SHULKER_BOXES.contains(item.getType())) + { + dispenser.getInventory().clear(); + } + } + } + } + } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java index ec292cc0..771d67b0 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java @@ -2,8 +2,7 @@ package me.totalfreedom.totalfreedommod.bridge; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; -import me.totalfreedom.libsdisguise.DisallowedDisguises; -import me.totalfreedom.libsdisguise.TF_DisguiseAPI; +import me.totalfreedom.disguise.DisguiseBlocker; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.util.FLog; @@ -109,19 +108,12 @@ public class LibsDisguisesBridge extends FreedomService return; } - if (state) - { - TF_DisguiseAPI.enableDisguises(); - } - else - { - TF_DisguiseAPI.disableDisguises(); - } + libsDisguises.toggleUsability(state); } public boolean isDisguisesEnabled() { - return !DisallowedDisguises.disabled; + return DisguiseBlocker.enabled; } public boolean isEnabled() diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java index 024c198d..689964eb 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java @@ -70,7 +70,8 @@ public class WorldEditBridge extends FreedomService { for (int i = 0; i < count; i++) { - session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer); + com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer; + session.undo(session.getBlockBag(fuckyou), fuckyou); } } } @@ -93,7 +94,8 @@ public class WorldEditBridge extends FreedomService { for (int i = 0; i < count; i++) { - session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer); + com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer; + session.redo(session.getBlockBag(fuckyou), fuckyou); } } } @@ -121,6 +123,30 @@ public class WorldEditBridge extends FreedomService } + public int getDefaultLimit() + { + final WorldEditPlugin wep = getWorldEditPlugin(); + if (wep == null) + { + return 0; + } + + return wep.getLocalConfiguration().defaultChangeLimit; + + } + + public int getMaxLimit() + { + final WorldEditPlugin wep = getWorldEditPlugin(); + if (wep == null) + { + return 0; + } + + return wep.getLocalConfiguration().maxChangeLimit; + + } + private LocalSession getPlayerSession(Player player) { final WorldEditPlugin wep = getWorldEditPlugin(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java b/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java index 31e7f75c..bac9127e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java @@ -206,10 +206,16 @@ public class CageData block.setType(Material.PLAYER_HEAD); if (input != null) { - Skull skull = (Skull)block.getState(); - // This may or may not work in future versions of spigot - skull.setOwner(input); - skull.update(); + try + { + Skull skull = (Skull)block.getState(); + // This may or may not work in future versions of spigot + skull.setOwner(input); + skull.update(); + } + catch (ClassCastException e) + { + } } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java index 2bdf85c1..5b19cf72 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java @@ -1,6 +1,6 @@ package me.totalfreedom.totalfreedommod.command; -import me.totalfreedom.libsdisguise.DisallowedDisguises; +import me.totalfreedom.disguise.DisguiseBlocker; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.command.Command; @@ -21,8 +21,7 @@ public class Command_disguisetoggle extends FreedomCommand return true; } - FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") - + " disguises", false); + FUtil.adminAction(sender.getName(), (DisguiseBlocker.enabled ? "Disabling" : "Enabling") + " disguises", false); if (plugin.ldb.isDisguisesEnabled()) { @@ -34,7 +33,7 @@ public class Command_disguisetoggle extends FreedomCommand plugin.ldb.setDisguisesEnabled(true); } - msg("Disguises are now " + (!DisallowedDisguises.disabled ? "enabled." : "disabled.")); + msg("Disguises are now " + (DisguiseBlocker.enabled ? "enabled." : "disabled.")); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java index 05b11f53..80f52c7c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java @@ -14,12 +14,12 @@ public class Command_setlimit extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - int amount = 100000; + int amount = plugin.web.getDefaultLimit(); if (args.length > 0) { try { - amount = Math.max(1, Math.min(200000, Integer.parseInt(args[0]))); + amount = Math.max(1, Math.min(plugin.web.getMaxLimit(), Integer.parseInt(args[0]))); } catch (NumberFormatException ex) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java index 5e2ba9bc..28022b1e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java @@ -151,16 +151,18 @@ public class Command_tag extends FreedomCommand }); final String outputTag = FUtil.colorize(strippedTag); + int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20); + + final String rawTag = ChatColor.stripColor(strippedTag).toLowerCase(); + + if (rawTag.length() > tagLimit) + { + msg("That tag is too long (Max is " + String.valueOf(tagLimit) + " characters)."); + return true; + } + if (!plugin.al.isAdmin(sender)) { - final String rawTag = ChatColor.stripColor(outputTag).toLowerCase(); - - if (rawTag.length() > 20) - { - msg("That tag is too long (Max is 20 characters)."); - return true; - } - for (String word : FORBIDDEN_WORDS) { if (rawTag.contains(word)) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java index 92252506..dd536709 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java @@ -31,16 +31,18 @@ public class Command_tagnyan extends FreedomCommand String tagStr = tag.toString(); + int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20); + + final String rawTag = ChatColor.stripColor(tagStr).toLowerCase(); + + if (rawTag.length() > tagLimit) + { + msg("That tag is too long (Max is " + String.valueOf(tagLimit) + " characters)."); + return true; + } + if (!plugin.al.isAdmin(sender)) { - final String rawTag = ChatColor.stripColor(tagStr).toLowerCase(); - - if (rawTag.length() > 20) - { - msg("That tag is too long (Max is 20 characters)."); - return true; - } - for (String word : Command_tag.FORBIDDEN_WORDS) { if (rawTag.contains(word)) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java index 32006848..804517f7 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java @@ -1,6 +1,6 @@ package me.totalfreedom.totalfreedommod.command; -import me.totalfreedom.libsdisguise.DisallowedDisguises; +import me.totalfreedom.disguise.DisguiseBlocker; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.command.Command; @@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Undisguise all players on the server", usage = "/", aliases = "uall") +@CommandParameters(description = "Undisguise all players on the server", usage = "/ [-a]", aliases = "uall") public class Command_undisguiseall extends FreedomCommand { @@ -21,15 +21,22 @@ public class Command_undisguiseall extends FreedomCommand return true; } - if (DisallowedDisguises.disabled) + if (!DisguiseBlocker.enabled) { msg("Disguises are not enabled."); return true; } - FUtil.adminAction(sender.getName(), "Undisguising all non-admins", true); + boolean admins = false; - plugin.ldb.undisguiseAll(false); + if (args.length > 0 && args[0].equalsIgnoreCase("-a")) + { + admins = true; + } + + FUtil.adminAction(sender.getName(), "Undisguising all " + (admins ? "players" : "non-admins"), true); + + plugin.ldb.undisguiseAll(admins); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java index 38c438b9..3a47aff6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java @@ -44,7 +44,7 @@ public class Command_vanish extends FreedomCommand } if (!silent) { - FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg); + FUtil.bcastMsg(ChatColor.AQUA + (loginMsg.contains("%name%") ? "" : playerSender.getName() + " is ") + FUtil.colorize(loginMsg).replace("%name%", playerSender.getName())); FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW); } if (admin.getTag() != null) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index b0c50aa7..2f3544b5 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -37,7 +37,7 @@ public class FUtil // public static final String SAVED_FLAGS_FILENAME = "savedflags.dat"; // See https://github.com/TotalFreedom/License - None of the listed names may be removed. - public static final List DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Wild1145", "ZeroEpoch1969", "Mafrans"); + public static final List DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Wild1145", "Catholic_Mario"); public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static final Map CHAT_COLOR_NAMES = new HashMap<>(); public static final List CHAT_COLOR_POOL = Arrays.asList(