From 0a012a395b8e23d4cf798317ee59ebef021bab30 Mon Sep 17 00:00:00 2001 From: destro174 <40720638+destro174@users.noreply.github.com> Date: Sun, 20 Feb 2022 20:41:27 +0100 Subject: [PATCH] remove junk --- .../GriefPrevention/GriefPrevention.java | 270 +----------------- .../GriefPrevention/PlayerEventHandler.java | 65 ----- src/main/resources/plugin.yml | 43 --- 3 files changed, 1 insertion(+), 377 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 8eece41..c760404 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -2401,39 +2401,6 @@ public class GriefPrevention extends JavaPlugin return true; } - else if (cmd.getName().equalsIgnoreCase("softmute")) - { - //requires one parameter - if (args.length != 1) return false; - - //find the specified player - OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); - if (targetPlayer == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - //toggle mute for player - boolean isMuted = this.dataStore.toggleSoftMute(targetPlayer.getUniqueId()); - if (isMuted) - { - GriefPrevention.sendMessage(player, TextMode.Success, Messages.SoftMuted, targetPlayer.getName()); - String executorName = "console"; - if (player != null) - { - executorName = player.getName(); - } - - GriefPrevention.AddLogEntry(executorName + " muted " + targetPlayer.getName() + ".", CustomLogEntryTypes.AdminActivity, true); - } - else - { - GriefPrevention.sendMessage(player, TextMode.Success, Messages.UnSoftMuted, targetPlayer.getName()); - } - - return true; - } else if (cmd.getName().equalsIgnoreCase("gpreload")) { this.loadConfig(); @@ -2494,144 +2461,6 @@ public class GriefPrevention extends JavaPlugin return true; } - - //ignoreplayer - else if (cmd.getName().equalsIgnoreCase("ignoreplayer") && player != null) - { - //requires target player name - if (args.length < 1) return false; - - //validate target player - OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); - if (targetPlayer == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - this.setIgnoreStatus(player, targetPlayer, IgnoreMode.StandardIgnore); - - GriefPrevention.sendMessage(player, TextMode.Success, Messages.IgnoreConfirmation); - - return true; - } - - //unignoreplayer - else if (cmd.getName().equalsIgnoreCase("unignoreplayer") && player != null) - { - //requires target player name - if (args.length < 1) return false; - - //validate target player - OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); - if (targetPlayer == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); - Boolean ignoreStatus = playerData.ignoredPlayers.get(targetPlayer.getUniqueId()); - if (ignoreStatus == null || ignoreStatus == true) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.NotIgnoringPlayer); - return true; - } - - this.setIgnoreStatus(player, targetPlayer, IgnoreMode.None); - - GriefPrevention.sendMessage(player, TextMode.Success, Messages.UnIgnoreConfirmation); - - return true; - } - - //ignoredplayerlist - else if (cmd.getName().equalsIgnoreCase("ignoredplayerlist") && player != null) - { - PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); - StringBuilder builder = new StringBuilder(); - for (Entry entry : playerData.ignoredPlayers.entrySet()) - { - if (entry.getValue() != null) - { - //if not an admin ignore, add it to the list - if (!entry.getValue()) - { - builder.append(GriefPrevention.lookupPlayerName(entry.getKey())); - builder.append(" "); - } - } - } - - String list = builder.toString().trim(); - if (list.isEmpty()) - { - GriefPrevention.sendMessage(player, TextMode.Info, Messages.NotIgnoringAnyone); - } - else - { - GriefPrevention.sendMessage(player, TextMode.Info, list); - } - - return true; - } - - //separateplayers - else if (cmd.getName().equalsIgnoreCase("separate")) - { - //requires two player names - if (args.length < 2) return false; - - //validate target players - OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); - if (targetPlayer == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - OfflinePlayer targetPlayer2 = this.resolvePlayerByName(args[1]); - if (targetPlayer2 == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - this.setIgnoreStatus(targetPlayer, targetPlayer2, IgnoreMode.AdminIgnore); - - GriefPrevention.sendMessage(player, TextMode.Success, Messages.SeparateConfirmation); - - return true; - } - - //unseparateplayers - else if (cmd.getName().equalsIgnoreCase("unseparate")) - { - //requires two player names - if (args.length < 2) return false; - - //validate target players - OfflinePlayer targetPlayer = this.resolvePlayerByName(args[0]); - if (targetPlayer == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - OfflinePlayer targetPlayer2 = this.resolvePlayerByName(args[1]); - if (targetPlayer2 == null) - { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); - return true; - } - - this.setIgnoreStatus(targetPlayer, targetPlayer2, IgnoreMode.None); - this.setIgnoreStatus(targetPlayer2, targetPlayer, IgnoreMode.None); - - GriefPrevention.sendMessage(player, TextMode.Success, Messages.UnSeparateConfirmation); - - return true; - } return false; } @@ -2909,10 +2738,8 @@ public class GriefPrevention extends JavaPlugin Player targetPlayer = this.getServer().getPlayerExact(name); if (targetPlayer != null) return targetPlayer; - UUID bestMatchID = null; - //try exact match first - bestMatchID = this.playerNameToIDMap.get(name); + UUID bestMatchID = this.playerNameToIDMap.get(name); //if failed, try ignore case if (bestMatchID == null) @@ -3253,45 +3080,6 @@ public class GriefPrevention extends JavaPlugin GriefPrevention.instance.getServer().getScheduler().runTaskLaterAsynchronously(GriefPrevention.instance, task, delayInTicks); } - private Set parseMaterialListFromConfig(List stringsToParse) - { - Set materials = EnumSet.noneOf(Material.class); - - //for each string in the list - for (int i = 0; i < stringsToParse.size(); i++) - { - String string = stringsToParse.get(i); - - //defensive coding - if (string == null) continue; - - //try to parse the string value into a material - Material material = Material.getMaterial(string.toUpperCase()); - - //null value returned indicates an error parsing the string from the config file - if (material == null) - { - //check if string has failed validity before - if (!string.contains("can't")) - { - //update string, which will go out to config file to help user find the error entry - stringsToParse.set(i, string + " <-- can't understand this entry, see BukkitDev documentation"); - - //warn about invalid material in log - GriefPrevention.AddLogEntry(String.format("ERROR: Invalid material %s. Please update your config.yml.", string)); - } - } - - //otherwise material is valid, add it - else - { - materials.add(material); - } - } - - return materials; - } - public int getSeaLevel(World world) { Integer overrideValue = this.config_seaLevelOverride.get(world.getName()); @@ -3401,62 +3189,6 @@ public class GriefPrevention extends JavaPlugin !claim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims; } - /* - protected boolean isPlayerTrappedInPortal(Block block) - { - Material playerBlock = block.getType(); - if (playerBlock == Material.PORTAL) - return true; - //Most blocks you can "stand" inside but cannot pass through (isSolid) usually can be seen through (!isOccluding) - //This can cause players to technically be considered not in a portal block, yet in reality is still stuck in the portal animation. - if ((!playerBlock.isSolid() || playerBlock.isOccluding())) //If it is _not_ such a block, - { - //Check the block above - playerBlock = block.getRelative(BlockFace.UP).getType(); - if ((!playerBlock.isSolid() || playerBlock.isOccluding())) - return false; //player is not stuck - } - //Check if this block is also adjacent to a portal - return block.getRelative(BlockFace.EAST).getType() == Material.PORTAL - || block.getRelative(BlockFace.WEST).getType() == Material.PORTAL - || block.getRelative(BlockFace.NORTH).getType() == Material.PORTAL - || block.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL; - } - - public void rescuePlayerTrappedInPortal(final Player player) - { - final Location oldLocation = player.getLocation(); - if (!isPlayerTrappedInPortal(oldLocation.getBlock())) - { - //Note that he 'escaped' the portal frame - instance.portalReturnMap.remove(player.getUniqueId()); - instance.portalReturnTaskMap.remove(player.getUniqueId()); - return; - } - - Location rescueLocation = portalReturnMap.get(player.getUniqueId()); - - if (rescueLocation == null) - return; - - //Temporarily store the old location, in case the player wishes to undo the rescue - dataStore.getPlayerData(player.getUniqueId()).portalTrappedLocation = oldLocation; - - player.teleport(rescueLocation); - sendMessage(player, TextMode.Info, Messages.RescuedFromPortalTrap); - portalReturnMap.remove(player.getUniqueId()); - - new BukkitRunnable() - { - public void run() - { - if (oldLocation == dataStore.getPlayerData(player.getUniqueId()).portalTrappedLocation) - dataStore.getPlayerData(player.getUniqueId()).portalTrappedLocation = null; - } - }.runTaskLater(this, 600L); - } - */ - //Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it. ConcurrentHashMap portalReturnTaskMap = new ConcurrentHashMap<>(); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 59f6640..c19e7d3 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -131,71 +131,6 @@ class PlayerEventHandler implements Listener bannedWordFinder = new WordFinder(instance.dataStore.loadBannedWords()); } - private final ConcurrentHashMap commandCategoryMap = new ConcurrentHashMap<>(); - - private CommandCategory getCommandCategory(String commandName) - { - if (commandName.startsWith("/")) commandName = commandName.substring(1); - - //if we've seen this command or alias before, return the category determined previously - CommandCategory category = this.commandCategoryMap.get(commandName); - if (category != null) return category; - - //otherwise build a list of all the aliases of this command across all installed plugins - HashSet aliases = new HashSet<>(); - aliases.add(commandName); - aliases.add("minecraft:" + commandName); - for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) - { - if (!(plugin instanceof JavaPlugin)) - continue; - JavaPlugin javaPlugin = (JavaPlugin) plugin; - Command command = javaPlugin.getCommand(commandName); - if (command != null) - { - aliases.add(command.getName().toLowerCase()); - aliases.add(plugin.getName().toLowerCase() + ":" + command.getName().toLowerCase()); - for (String alias : command.getAliases()) - { - aliases.add(alias.toLowerCase()); - aliases.add(plugin.getName().toLowerCase() + ":" + alias.toLowerCase()); - } - } - } - - //also consider vanilla commands - Command command = Bukkit.getServer().getPluginCommand(commandName); - if (command != null) - { - aliases.add(command.getName().toLowerCase()); - aliases.add("minecraft:" + command.getName().toLowerCase()); - for (String alias : command.getAliases()) - { - aliases.add(alias.toLowerCase()); - aliases.add("minecraft:" + alias.toLowerCase()); - } - } - - //if any of those aliases are in the chat list or whisper list, then we know the category for that command - category = CommandCategory.None; - for (String alias : aliases) - { - if (instance.config_eavesdrop_whisperCommands.contains("/" + alias)) - { - category = CommandCategory.Whisper; - } - else if (instance.config_spam_monitorSlashCommands.contains("/" + alias)) - { - category = CommandCategory.Chat; - } - - //remember the categories for later - this.commandCategoryMap.put(alias.toLowerCase(), category); - } - - return category; - } - static int longestNameLength = 10; static void makeSocialLogEntry(String name, String message) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f6d5d00..b3c6204 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -181,10 +181,6 @@ commands: usage: /ClaimExplosions permission: griefprevention.claims aliases: claimexplosion - softmute: - description: Toggles whether a player's messages will only reach other soft-muted players. - usage: /SoftMute - permission: griefprevention.softmute gpreload: description: Reloads Grief Prevention's configuration settings. Does NOT totally reload the entire plugin. usage: /gpreload @@ -197,29 +193,6 @@ commands: description: Allows an administrator to get technical information about blocks in the world and items in hand. usage: /GPBlockInfo permission: griefprevention.gpblockinfo - ignoreplayer: - description: Ignores another player's chat messages. - usage: /IgnorePlayer - aliases: [ignore] - permission: griefprevention.ignore - unignoreplayer: - description: Unignores another player's chat messages. - usage: /UnIgnorePlayer - aliases: [unignore] - permission: griefprevention.ignore - ignoredplayerlist: - description: Lists the players you're ignoring in chat. - usage: /IgnoredPlayerList - aliases: [ignores, ignored, ignorelist, ignoredlist, listignores, listignored, ignoring] - permission: griefprevention.ignore - separate: - description: Forces two players to ignore each other in chat. - usage: /Separate - permission: griefprevention.separate - unseparate: - description: Reverses /separate. - usage: /UnSeparate - permission: griefprevention.separate claimbook: description: Gives a player a manual about claiming land. usage: /ClaimBook @@ -241,7 +214,6 @@ permissions: griefprevention.lava: true griefprevention.eavesdrop: true griefprevention.deathblow: true - griefprevention.softmute: true griefprevention.reload: true griefprevention.visualizenearbyclaims: true griefprevention.overrideclaimcountlimit: true @@ -303,9 +275,6 @@ permissions: griefprevention.lava: description: Grants permission to place lava near the surface and outside of claims. default: op - griefprevention.eavesdrop: - description: Allows a player to see whispered chat messages (/tell) and softmuted messages. - default: op griefprevention.eavesdropsigns: description: Allows a player to see sign placements as chat messages. default: op @@ -318,9 +287,6 @@ permissions: griefprevention.reload: description: Grants access to /gpreload. default: op - griefprevention.softmute: - description: Grants access to /SoftMute. - default: op griefprevention.claims: description: Grants access to claim-related slash commands. default: true @@ -339,18 +305,9 @@ permissions: griefprevention.overrideclaimcountlimit: description: Allows players to create more claims than the limit specified by the config. default: op - griefprevention.separate: - description: Grants access to /Separate and /UnSeparate. - default: op - griefprevention.ignore: - description: Grants access to /Ignore, /Unignore, and /IgnoreList - default: true griefprevention.claimbook: description: Grants access to /ClaimBook. default: op - griefprevention.notignorable: - description: Players with this permission can't be ignored. - default: op griefprevention.seeinactivity: description: Players with this permission can see how long a claim owner has been offline. default: op