From c042c8d4cccce49c97c6c7eae729cc51ce8af623 Mon Sep 17 00:00:00 2001 From: JustBru00 Date: Thu, 29 Sep 2022 21:01:41 -0400 Subject: [PATCH] Release 3.11-snapshot+2022.sept.29 --- .../epic/rename/commands/v3/RemoveLore.java | 84 +++++++++++++++++++ .../rename/configuration/ConfigUpdater.java | 11 +++ .../rename/enums/v3/EpicRenameCommands.java | 5 +- .../justbru00/epic/rename/main/v3/Main.java | 6 +- src/messages.yml | 11 +++ src/plugin.yml | 20 ++++- 6 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 src/com/gmail/justbru00/epic/rename/commands/v3/RemoveLore.java diff --git a/src/com/gmail/justbru00/epic/rename/commands/v3/RemoveLore.java b/src/com/gmail/justbru00/epic/rename/commands/v3/RemoveLore.java new file mode 100644 index 0000000..98bd28a --- /dev/null +++ b/src/com/gmail/justbru00/epic/rename/commands/v3/RemoveLore.java @@ -0,0 +1,84 @@ +/** + * @author Justin "JustBru00" Brubaker + * + * This is licensed under the MPL Version 2.0. See license info in LICENSE.txt + */ +package com.gmail.justbru00.epic.rename.commands.v3; + +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; + +import com.gmail.justbru00.epic.rename.enums.v3.EpicRenameCommands; +import com.gmail.justbru00.epic.rename.main.v3.Main; +import com.gmail.justbru00.epic.rename.utils.v3.Blacklists; +import com.gmail.justbru00.epic.rename.utils.v3.MaterialPermManager; +import com.gmail.justbru00.epic.rename.utils.v3.Messager; +import com.gmail.justbru00.epic.rename.utils.v3.RenameUtil; +import com.gmail.justbru00.epic.rename.utils.v3.WorldChecker; + +public class RemoveLore implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if (command.getName().equalsIgnoreCase("removelore")) { + if (sender.hasPermission("epicrename.removelore")) { + if (sender instanceof Player) { + Player player = (Player) sender; + if (WorldChecker.checkWorld(player)) { + + // Check Material Permissions + if (!MaterialPermManager.checkPerms(EpicRenameCommands.REMOVELORE, RenameUtil.getInHand(player), player)) { + Messager.msgPlayer(Main.getMsgFromConfig("removelore.no_permission_for_material"), player); + return true; + } + + // Check Blacklist + if (!Blacklists.checkMaterialBlacklist(RenameUtil.getInHand(player).getType(), player)) { + Messager.msgPlayer(Main.getMsgFromConfig("removelore.blacklisted_material_found"), player); + return true; + } + + // Check Existing Name Blacklist + if (!Blacklists.checkExistingName(player)) { + Messager.msgPlayer(Main.getMsgFromConfig("removelore.blacklisted_existing_name_found"), player); + return true; + } + + // Check Existing Lore Blacklist + if (!Blacklists.checkExistingLore(player)) { + Messager.msgPlayer(Main.getMsgFromConfig("removelore.blacklisted_existing_lore_found"), player); + return true; + } + + if (RenameUtil.getInHand(player).getType() == Material.AIR) { + Messager.msgPlayer(Main.getMsgFromConfig("removelore.cannot_edit_air"), player); + return true; + } + ItemMeta im = RenameUtil.getInHand(player).getItemMeta(); + im.setLore(null); + RenameUtil.getInHand(player).setItemMeta(im); + Messager.msgPlayer(Main.getMsgFromConfig("removelore.success"), player); + return true; + + } else { + Messager.msgSender(Main.getMsgFromConfig("removelore.disabled_world"), sender); + return true; + } + } else { + Messager.msgSender(Main.getMsgFromConfig("removelore.wrong_sender"), sender); + return true; + } + } else { + Messager.msgSender(Main.getMsgFromConfig("removelore.no_permission"), sender); + return true; + } + } + return false; + } + +} diff --git a/src/com/gmail/justbru00/epic/rename/configuration/ConfigUpdater.java b/src/com/gmail/justbru00/epic/rename/configuration/ConfigUpdater.java index 324adbe..1433a20 100644 --- a/src/com/gmail/justbru00/epic/rename/configuration/ConfigUpdater.java +++ b/src/com/gmail/justbru00/epic/rename/configuration/ConfigUpdater.java @@ -302,6 +302,17 @@ public static void updateMessagesYml() { updateMessagesYmlString("removename.no_permission_for_material", "&cSorry you don''t have permission for that material."); updateMessagesYmlString("removename.success", "&aRemoved the display name from the item successfully."); + // /removelore + updateMessagesYmlString("removelore.no_permission", "&cSorry you don''t have permission to perform that command."); + updateMessagesYmlString("removelore.wrong_sender", "&cSorry only a player can use that command."); + updateMessagesYmlString("removelore.disabled_world", "&cYou are in a disabled world."); + updateMessagesYmlString("removelore.blacklisted_material_found", "&cSorry that material is blacklisted."); + updateMessagesYmlString("removelore.blacklisted_existing_name_found", "&cSorry that item has an existing name that is blacklisted."); + updateMessagesYmlString("removelore.blacklisted_existing_lore_found", "&cSorry that item has an existing line of lore that is blacklisted."); + updateMessagesYmlString("removelore.cannot_edit_air", "&cSorry you can''t edit nothing."); + updateMessagesYmlString("removelore.no_permission_for_material", "&cSorry you don''t have permission for that material."); + updateMessagesYmlString("removelore.success", "&aRemoved the lore from the item successfully."); + // rename_character_limit updateMessagesYmlString("rename_character_limit.name_too_long", "&cSorry that name is too long. The character limit is {char}."); diff --git a/src/com/gmail/justbru00/epic/rename/enums/v3/EpicRenameCommands.java b/src/com/gmail/justbru00/epic/rename/enums/v3/EpicRenameCommands.java index e1fd5e0..0187485 100644 --- a/src/com/gmail/justbru00/epic/rename/enums/v3/EpicRenameCommands.java +++ b/src/com/gmail/justbru00/epic/rename/enums/v3/EpicRenameCommands.java @@ -7,8 +7,8 @@ public enum EpicRenameCommands { - RENAME, LORE, EPICRENAME, SETLORELINE, - REMOVELORELINE, INSERTLORELINE, GLOW, REMOVEGLOW, ALIGN, EXPORT, IMPORT, REMOVENAME; + RENAME, LORE, EPICRENAME, SETLORELINE, REMOVELORELINE, INSERTLORELINE, GLOW, REMOVEGLOW, ALIGN, EXPORT, IMPORT, + REMOVENAME, REMOVELORE; public static String getStringName(EpicRenameCommands e) { @@ -25,6 +25,7 @@ public static String getStringName(EpicRenameCommands e) { case EXPORT: {return "export";} case IMPORT: {return "import";} case REMOVENAME: {return "removename";} + case REMOVELORE: {return "returnlore";} default: break; } diff --git a/src/com/gmail/justbru00/epic/rename/main/v3/Main.java b/src/com/gmail/justbru00/epic/rename/main/v3/Main.java index f917510..a0ccb7a 100644 --- a/src/com/gmail/justbru00/epic/rename/main/v3/Main.java +++ b/src/com/gmail/justbru00/epic/rename/main/v3/Main.java @@ -24,6 +24,7 @@ import com.gmail.justbru00.epic.rename.commands.v3.InsertLoreLine; import com.gmail.justbru00.epic.rename.commands.v3.Lore; import com.gmail.justbru00.epic.rename.commands.v3.RemoveGlow; +import com.gmail.justbru00.epic.rename.commands.v3.RemoveLore; import com.gmail.justbru00.epic.rename.commands.v3.RemoveLoreLine; import com.gmail.justbru00.epic.rename.commands.v3.RemoveName; import com.gmail.justbru00.epic.rename.commands.v3.Rename; @@ -90,8 +91,8 @@ public void onEnable() { checkServerVerison(); Messager.msgConsole("&bVersion: &c" + PLUGIN_VERISON + " &bMC Version: &c" + MC_VERSION.toString()); - Messager.msgConsole("&cThis plugin is Copyright (c) 2021 Justin \"JustBru00\" Brubaker. This plugin is licensed under the MPL v2.0. " - + "You can view a copy of it at: http://bit.ly/2eMknxx"); + Messager.msgConsole("&cThis plugin is Copyright (c) 2022 Justin \"JustBru00\" Brubaker. This plugin is licensed under the MPL v2.0. " + + "You can view a copy of the MPL v2.0 license at: http://bit.ly/2eMknxx"); Messager.msgConsole("&aStarting to enable plugin..."); @@ -144,6 +145,7 @@ public void onEnable() { getCommand("import").setExecutor(new Import());; getCommand("export").setExecutor(new Export()); getCommand("removename").setExecutor(new RemoveName()); + getCommand("removelore").setExecutor(new RemoveLore()); // Start bstats BStats bstats = new BStats(this, BSTATS_PLUGIN_ID); diff --git a/src/messages.yml b/src/messages.yml index 256cd1f..4b7c9e1 100644 --- a/src/messages.yml +++ b/src/messages.yml @@ -158,6 +158,17 @@ removename: cannot_edit_air: '&cSorry you can''t edit nothing.' no_permission_for_material: '&cSorry you don''t have permission for that material.' success: '&aRemoved the display name from the item successfully.' + +removelore: + no_permission: '&cSorry you don''t have permission to perform that command.' + wrong_sender: '&cSorry only a player can use that command.' + disabled_world: '&cYou are in a disabled world.' + blacklisted_material_found: '&cSorry that material is blacklisted.' + blacklisted_existing_name_found: '&cSorry that item has an existing name that is blacklisted.' + blacklisted_existing_lore_found: '&cSorry that item has an existing line of lore that is blacklisted.' + cannot_edit_air: '&cSorry you can''t edit nothing.' + no_permission_for_material: '&cSorry you don''t have permission for that material.' + success: '&aRemoved the lore from the item successfully.' rename_character_limit: name_too_long: '&cSorry that name is too long. The character limit is {char}.' diff --git a/src/plugin.yml b/src/plugin.yml index 88a7210..6598543 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: EpicRename main: com.gmail.justbru00.epic.rename.main.v3.Main -version: '3.11-INDEV' +version: '3.11-snapshot+2022.sept.29' description: Performs different item modifications with easy to use commands. authors: [Justin Brubaker,JustBru00,jayoevans] softdepend: [Vault] @@ -40,6 +40,9 @@ commands: removename: description: Removes the display name from an item. aliases: [epremovename] + removelore: + description: Removes the lore from and item. + aliases: [epremovelore] permissions: epicrename.epicrename: @@ -286,6 +289,13 @@ permissions: description: Placeholder permission. Use an actual bukkit material for this permission to work. Ex. epicrename.removename.material.STONE epicrename.removename.material.*: description: Allows all materials for the /removename command. + + epicrename.removelore: + description: Basic permission for the /removelore command. + epicrename.removelore.material.MATERIAL_HERE: + description: Placeholder permission. Use an actual bukkit material for this permission to work. Ex. epicrename.removelore.material.STONE + epicrename.removelore.material.*: + description: Allows all materials for the /removelore command. epicrename.bypass.charlimit: description: Allows the user to bypass the character limit set for /rename. @@ -432,6 +442,7 @@ permissions: epicrename.import: true epicrename.export: true epicrename.removename.*: true + epicrename.removelore.*: true epicrename.poweruser: description: Provides the user permission for all materials and all formatting codes for all commands except for /import, /epicrename reload, or /epicrename debug. Does not provide bypass permissions. Use epicrename.bypass.* for that. @@ -446,6 +457,7 @@ permissions: epicrename.removeglow.*: true epicrename.export: true epicrename.removename.*: true + epicrename.removelore.*: true epicrename.rename.*: description: Provides the user permission for all materials and all formatting codes for /rename. Also provides basic permission epicrename.rename. @@ -480,6 +492,12 @@ permissions: epicrename.removename: true epicrename.removename.material.*: true + epicrename.removelore.*: + description: Provides the user permission for all materials for /removelore. Also provides basic permission epicrename.removelore. + children: + epicrename.removelore: true + epicrename.removelore.material.*: true + epicrename.insertloreline.*: description: Provides the user permission for all materials and all formatting codes for /insertloreline. Also provides basic permission epicrename.insertloreline. children: