From 4f60103dc931f00de01808b35f9d446c6f685291 Mon Sep 17 00:00:00 2001 From: Brianna Date: Sun, 4 Aug 2019 22:24:48 -0400 Subject: [PATCH] Converted commands. --- .../utils/objects/FileLocation.java | 30 ---- pom.xml | 11 -- .../songoda/epicenchants/CommandCommons.java | 15 ++ .../songoda/epicenchants/EpicEnchants.java | 12 +- .../epicenchants/command/AbstractCommand.java | 71 +++++++++ .../epicenchants/command/CommandManager.java | 92 +++++++++++ .../epicenchants/command/TabManager.java | 52 +++++++ .../command/commands/CommandAlchemist.java | 44 ++++++ .../command/commands/CommandApply.java | 104 +++++++++++++ .../command/commands/CommandEnchanter.java | 43 ++++++ .../command/commands/CommandEpicEnchants.java | 51 ++++++ .../command/commands/CommandGiveBook.java | 108 +++++++++++++ .../command/commands/CommandGiveItemDust.java | 88 +++++++++++ .../command/commands/CommandGiveScroll.java | 92 +++++++++++ .../command/commands/CommandInfo.java | 51 ++++++ .../command/commands/CommandReload.java | 41 +++++ .../command/commands/CommandSettings.java | 41 +++++ .../command/commands/CommandTinkerer.java | 44 ++++++ .../epicenchants/commands/CustomCommand.java | 40 ----- .../epicenchants/commands/EnchantCommand.java | 146 ------------------ .../listeners/item/BlackScrollListener.java | 2 +- .../epicenchants/managers/CommandManager.java | 76 --------- .../epicenchants/managers/EnchantManager.java | 2 +- .../epicenchants/managers/FileManager.java | 85 +++++++--- .../epicenchants/managers/InfoManager.java | 2 +- .../epicenchants/menus/TinkererMenu.java | 6 +- .../epicenchants/objects/BookItem.java | 8 +- .../epicenchants/utils/EnchantUtils.java | 12 +- .../songoda/epicenchants/utils/Methods.java | 11 ++ .../epicenchants/utils/SpecialItems.java | 20 +-- .../utils/single/GeneralUtils.java | 2 +- src/main/resources/en_US.lang | 4 +- .../resources/enchants/elite/AntiGravity.yml | 27 ++++ src/main/resources/enchants/elite/Frozen.yml | 34 ++++ src/main/resources/enchants/elite/Poison.yml | 31 ++++ .../resources/enchants/elite/RocketEscape.yml | 31 ++++ .../resources/enchants/elite/Shockwave.yml | 29 ++++ src/main/resources/enchants/elite/Wither.yml | 34 ++++ .../resources/enchants/example-enchant.yml | 95 ------------ .../enchants/legendary/DeathBringer.yml | 28 ++++ .../resources/enchants/legendary/DeathGod.yml | 29 ++++ .../enchants/legendary/Enlightened.yml | 26 ++++ .../resources/enchants/legendary/Gears.yml | 26 ++++ .../enchants/legendary/LifeSteal.yml | 26 ++++ .../resources/enchants/legendary/Overload.yml | 26 ++++ .../enchants/legendary/SkillSwipe.yml | 26 ++++ .../resources/enchants/simple/Aquatic.yml | 24 +++ .../resources/enchants/simple/Confusion.yml | 33 ++++ .../resources/enchants/simple/Experience.yml | 29 ++++ .../resources/enchants/simple/Glowing.yml | 24 +++ src/main/resources/enchants/simple/Haste.yml | 28 ++++ .../resources/enchants/simple/Insomnia.yml | 59 +++++++ .../resources/enchants/simple/Lightning.yml | 27 ++++ .../resources/enchants/simple/Obliterate.yml | 32 ++++ .../resources/enchants/simple/Oxygenate.yml | 29 ++++ .../resources/enchants/ultimate/Blind.yml | 33 ++++ .../resources/enchants/ultimate/Dodge.yml | 26 ++++ .../resources/enchants/ultimate/IceAspect.yml | 27 ++++ .../resources/enchants/ultimate/StormFall.yml | 45 ++++++ .../resources/enchants/unique/Berserk.yml | 28 ++++ .../resources/enchants/unique/Explosive.yml | 29 ++++ .../enchants/unique/FeatherWeight.yml | 28 ++++ .../enchants/unique/ObsidianDestroyer.yml | 29 ++++ .../enchants/unique/PlagueCarrier.yml | 33 ++++ .../resources/enchants/unique/Ragdoll.yml | 33 ++++ .../enchants/unique/SelfDestruct.yml | 30 ++++ src/main/resources/plugin.yml | 8 +- 67 files changed, 2056 insertions(+), 452 deletions(-) delete mode 100644 core/src/main/java/com/songoda/epicenchants/utils/objects/FileLocation.java create mode 100644 src/main/java/com/songoda/epicenchants/CommandCommons.java create mode 100644 src/main/java/com/songoda/epicenchants/command/AbstractCommand.java create mode 100644 src/main/java/com/songoda/epicenchants/command/CommandManager.java create mode 100644 src/main/java/com/songoda/epicenchants/command/TabManager.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandAlchemist.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandApply.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandEnchanter.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandEpicEnchants.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandGiveBook.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandGiveItemDust.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandGiveScroll.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandInfo.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandReload.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandSettings.java create mode 100644 src/main/java/com/songoda/epicenchants/command/commands/CommandTinkerer.java delete mode 100644 src/main/java/com/songoda/epicenchants/commands/CustomCommand.java delete mode 100644 src/main/java/com/songoda/epicenchants/commands/EnchantCommand.java delete mode 100644 src/main/java/com/songoda/epicenchants/managers/CommandManager.java create mode 100644 src/main/resources/enchants/elite/AntiGravity.yml create mode 100644 src/main/resources/enchants/elite/Frozen.yml create mode 100644 src/main/resources/enchants/elite/Poison.yml create mode 100644 src/main/resources/enchants/elite/RocketEscape.yml create mode 100644 src/main/resources/enchants/elite/Shockwave.yml create mode 100644 src/main/resources/enchants/elite/Wither.yml delete mode 100644 src/main/resources/enchants/example-enchant.yml create mode 100644 src/main/resources/enchants/legendary/DeathBringer.yml create mode 100644 src/main/resources/enchants/legendary/DeathGod.yml create mode 100644 src/main/resources/enchants/legendary/Enlightened.yml create mode 100644 src/main/resources/enchants/legendary/Gears.yml create mode 100644 src/main/resources/enchants/legendary/LifeSteal.yml create mode 100644 src/main/resources/enchants/legendary/Overload.yml create mode 100644 src/main/resources/enchants/legendary/SkillSwipe.yml create mode 100644 src/main/resources/enchants/simple/Aquatic.yml create mode 100644 src/main/resources/enchants/simple/Confusion.yml create mode 100644 src/main/resources/enchants/simple/Experience.yml create mode 100644 src/main/resources/enchants/simple/Glowing.yml create mode 100644 src/main/resources/enchants/simple/Haste.yml create mode 100644 src/main/resources/enchants/simple/Insomnia.yml create mode 100644 src/main/resources/enchants/simple/Lightning.yml create mode 100644 src/main/resources/enchants/simple/Obliterate.yml create mode 100644 src/main/resources/enchants/simple/Oxygenate.yml create mode 100644 src/main/resources/enchants/ultimate/Blind.yml create mode 100644 src/main/resources/enchants/ultimate/Dodge.yml create mode 100644 src/main/resources/enchants/ultimate/IceAspect.yml create mode 100644 src/main/resources/enchants/ultimate/StormFall.yml create mode 100644 src/main/resources/enchants/unique/Berserk.yml create mode 100644 src/main/resources/enchants/unique/Explosive.yml create mode 100644 src/main/resources/enchants/unique/FeatherWeight.yml create mode 100644 src/main/resources/enchants/unique/ObsidianDestroyer.yml create mode 100644 src/main/resources/enchants/unique/PlagueCarrier.yml create mode 100644 src/main/resources/enchants/unique/Ragdoll.yml create mode 100644 src/main/resources/enchants/unique/SelfDestruct.yml diff --git a/core/src/main/java/com/songoda/epicenchants/utils/objects/FileLocation.java b/core/src/main/java/com/songoda/epicenchants/utils/objects/FileLocation.java deleted file mode 100644 index a6eb289..0000000 --- a/core/src/main/java/com/songoda/epicenchants/utils/objects/FileLocation.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.songoda.epicenchants.utils.objects; - -import lombok.Getter; - -public class FileLocation { - @Getter private final boolean required, versionDependent; - @Getter private final String path; - - private FileLocation(String path, boolean required, boolean versionDependent) { - this.required = required; - this.versionDependent = versionDependent; - this.path = path; - } - - public static FileLocation of(String path, boolean required) { - return new FileLocation(path, required, false); - } - - public static FileLocation of(String path, boolean required, boolean versionDependent) { - return new FileLocation(path, required, versionDependent); - } - - public String getResourcePath(String dir) { - return (versionDependent ? "version-dependent/" + dir + "/" : "") + path; - } - - public boolean isDirectory() { - return path.endsWith("/"); - } -} diff --git a/pom.xml b/pom.xml index 8b0d3ad..958e285 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ com.songoda:songodaupdater fr.mymicky:FastInv - co.aikar:acf-bukkit @@ -67,10 +66,6 @@ jitpack.io https://jitpack.io - - aikar - https://repo.aikar.co/content/groups/aikar/ - @@ -79,12 +74,6 @@ spigot 1.14.4 - - co.aikar - acf-bukkit - 0.5.0-SNAPSHOT - compile - fr.mrmicky FastInv diff --git a/src/main/java/com/songoda/epicenchants/CommandCommons.java b/src/main/java/com/songoda/epicenchants/CommandCommons.java new file mode 100644 index 0000000..ba21399 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/CommandCommons.java @@ -0,0 +1,15 @@ +package com.songoda.epicenchants; + +import com.songoda.epicenchants.utils.Methods; +import org.bukkit.command.CommandSender; + +public class CommandCommons { + + public static boolean isInt(String number, CommandSender sender) { + if (!Methods.isInt(number)) { + EpicEnchants.getInstance().getLocale().newMessage("Not a number.").sendPrefixedMessage(sender); + return false; + } + return true; + } +} diff --git a/src/main/java/com/songoda/epicenchants/EpicEnchants.java b/src/main/java/com/songoda/epicenchants/EpicEnchants.java index f04c951..1cdef32 100644 --- a/src/main/java/com/songoda/epicenchants/EpicEnchants.java +++ b/src/main/java/com/songoda/epicenchants/EpicEnchants.java @@ -1,6 +1,6 @@ package com.songoda.epicenchants; -import co.aikar.commands.BukkitCommandManager; +import com.songoda.epicenchants.command.CommandManager; import com.songoda.epicenchants.economy.Economy; import com.songoda.epicenchants.economy.PlayerPointsEconomy; import com.songoda.epicenchants.economy.ReserveEconomy; @@ -46,7 +46,7 @@ public class EpicEnchants extends JavaPlugin { private FileManager fileManager; private HookManager hookManager; private SettingsManager settingsManager; - private BukkitCommandManager commandManager; + private CommandManager commandManager; private Locale locale; @@ -221,4 +221,12 @@ public class EpicEnchants extends JavaPlugin { public Locale getLocale() { return locale; } + + public CommandManager getCommandManager() { + return commandManager; + } + + public SettingsManager getSettingsManager() { + return settingsManager; + } } diff --git a/src/main/java/com/songoda/epicenchants/command/AbstractCommand.java b/src/main/java/com/songoda/epicenchants/command/AbstractCommand.java new file mode 100644 index 0000000..7bdd9a3 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/AbstractCommand.java @@ -0,0 +1,71 @@ +package com.songoda.epicenchants.command; + +import com.songoda.epicenchants.EpicEnchants; +import org.bukkit.command.CommandSender; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public abstract class AbstractCommand { + + private final boolean noConsole; + private AbstractCommand parent = null; + private boolean hasArgs = false; + private String command; + + private List subCommand = new ArrayList<>(); + + protected AbstractCommand(AbstractCommand parent, boolean noConsole, String... command) { + if (parent != null) { + this.subCommand = Arrays.asList(command); + } else { + this.command = Arrays.asList(command).get(0); + } + this.parent = parent; + this.noConsole = noConsole; + } + + protected AbstractCommand(boolean noConsole, boolean hasArgs, String... command) { + this.command = Arrays.asList(command).get(0); + + this.hasArgs = hasArgs; + this.noConsole = noConsole; + } + + public AbstractCommand getParent() { + return parent; + } + + public String getCommand() { + return command; + } + + public List getSubCommand() { + return subCommand; + } + + public void addSubCommand(String command) { + subCommand.add(command); + } + + protected abstract ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args); + + protected abstract List onTab(EpicEnchants instance, CommandSender sender, String... args); + + public abstract String getPermissionNode(); + + public abstract String getSyntax(); + + public abstract String getDescription(); + + public boolean hasArgs() { + return hasArgs; + } + + public boolean isNoConsole() { + return noConsole; + } + + public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR} +} diff --git a/src/main/java/com/songoda/epicenchants/command/CommandManager.java b/src/main/java/com/songoda/epicenchants/command/CommandManager.java new file mode 100644 index 0000000..e355327 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/CommandManager.java @@ -0,0 +1,92 @@ +package com.songoda.epicenchants.command; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.commands.*; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class CommandManager implements CommandExecutor { + + private static final List commands = new ArrayList<>(); + private EpicEnchants plugin; + private TabManager tabManager; + + public CommandManager(EpicEnchants plugin) { + this.plugin = plugin; + this.tabManager = new TabManager(this); + + plugin.getCommand("EpicEnchants").setExecutor(this); + + AbstractCommand commandEpicEnchants = addCommand(new CommandEpicEnchants()); + + addCommand(new CommandSettings(commandEpicEnchants)); + addCommand(new CommandReload(commandEpicEnchants)); + addCommand(new CommandApply(commandEpicEnchants)); + addCommand(new CommandInfo(commandEpicEnchants)); + addCommand(new CommandGiveBook(commandEpicEnchants)); + addCommand(new CommandGiveItemDust(commandEpicEnchants)); + addCommand(new CommandGiveScroll(commandEpicEnchants)); + addCommand(new CommandAlchemist(commandEpicEnchants)); + addCommand(new CommandEnchanter(commandEpicEnchants)); + addCommand(new CommandTinkerer(commandEpicEnchants)); + + for (AbstractCommand abstractCommand : commands) { + if (abstractCommand.getParent() != null) continue; + plugin.getCommand(abstractCommand.getCommand()).setTabCompleter(tabManager); + } + } + + private AbstractCommand addCommand(AbstractCommand abstractCommand) { + commands.add(abstractCommand); + return abstractCommand; + } + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { + for (AbstractCommand abstractCommand : commands) { + if (abstractCommand.getCommand() != null && abstractCommand.getCommand().equalsIgnoreCase(command.getName().toLowerCase())) { + if (strings.length == 0 || abstractCommand.hasArgs()) { + processRequirements(abstractCommand, commandSender, strings); + return true; + } + } else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) { + String cmd = strings[0]; + String cmd2 = strings.length >= 2 ? String.join(" ", strings[0], strings[1]) : null; + for (String cmds : abstractCommand.getSubCommand()) { + if (cmd.equalsIgnoreCase(cmds) || (cmd2 != null && cmd2.equalsIgnoreCase(cmds))) { + processRequirements(abstractCommand, commandSender, strings); + return true; + } + } + } + } + plugin.getLocale().newMessage("&7The command you entered does not exist or is spelt incorrectly.").sendPrefixedMessage(commandSender); + return true; + } + + private void processRequirements(AbstractCommand command, CommandSender sender, String[] strings) { + if (!(sender instanceof Player) && command.isNoConsole()) { + sender.sendMessage("You must be a player to use this commands."); + return; + } + if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { + AbstractCommand.ReturnType returnType = command.runCommand(plugin, sender, strings); + if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) { + plugin.getLocale().newMessage("&cInvalid Syntax!").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&7The valid syntax is: &6" + command.getSyntax() + "&7.").sendPrefixedMessage(sender); + } + return; + } + plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender); + } + + public List getCommands() { + return Collections.unmodifiableList(commands); + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/TabManager.java b/src/main/java/com/songoda/epicenchants/command/TabManager.java new file mode 100644 index 0000000..1fe6cab --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/TabManager.java @@ -0,0 +1,52 @@ +package com.songoda.epicenchants.command; + +import com.songoda.epicenchants.EpicEnchants; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCompleter; + +import java.util.ArrayList; +import java.util.List; + +public class TabManager implements TabCompleter { + + private final CommandManager commandManager; + + TabManager(CommandManager commandManager) { + this.commandManager = commandManager; + } + + @Override + public List onTabComplete(CommandSender sender, Command command, String alias, String[] strings) { + for (AbstractCommand abstractCommand : commandManager.getCommands()) { + if (abstractCommand.getCommand() != null && abstractCommand.getCommand().equalsIgnoreCase(command.getName().toLowerCase())) { + if (strings.length == 1) { + List subs = new ArrayList<>(); + for (AbstractCommand ac : commandManager.getCommands()) { + if (ac.getSubCommand() == null) continue; + subs.addAll(ac.getSubCommand()); + } + subs.removeIf(s -> !s.toLowerCase().startsWith(strings[0].toLowerCase())); + return subs; + } + } else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName().toLowerCase())) { + String cmd = strings[0]; + String cmd2 = strings.length >= 2 ? String.join(" ", strings[0], strings[1]) : null; + for (String cmds : abstractCommand.getSubCommand()) { + if (cmd.equalsIgnoreCase(cmds) || (cmd2 != null && cmd2.equalsIgnoreCase(cmds))) { + List list = abstractCommand.onTab(EpicEnchants.getInstance(), sender, strings); + String str = strings[strings.length - 1]; + if (list != null && str != null && str.length() >= 1) { + try { + list.removeIf(s -> !s.toLowerCase().startsWith(str.toLowerCase())); + } catch (UnsupportedOperationException ignored) { + } + } + return list; + } + } + } + } + return null; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandAlchemist.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandAlchemist.java new file mode 100644 index 0000000..c11b6c2 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandAlchemist.java @@ -0,0 +1,44 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.menus.AlchemistMenu; +import com.songoda.epicenchants.menus.TinkererMenu; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class CommandAlchemist extends AbstractCommand { + + public CommandAlchemist(AbstractCommand parent) { + super(parent, true, "alchemist"); + } + + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + Player player = (Player)sender; + new AlchemistMenu(instance, instance.getFileManager().getConfiguration("menus/alchemist-menu")).open(player); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.alchemist"; + } + + @Override + public String getSyntax() { + return "/ee alchemist"; + } + + @Override + public String getDescription() { + return "Opens the Alchemist."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandApply.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandApply.java new file mode 100644 index 0000000..d7a2b88 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandApply.java @@ -0,0 +1,104 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.CommandCommons; +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.enums.EnchantResult; +import com.songoda.epicenchants.objects.Enchant; +import com.songoda.epicenchants.utils.Tuple; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.List; +import java.util.Optional; + +import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE; +import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult; + +public class CommandApply extends AbstractCommand { + + public CommandApply(AbstractCommand parent) { + super(parent, true, "apply"); + } + + //ee apply [enchant] [level] + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + if (args.length < 3 || args.length > 5) + return ReturnType.SYNTAX_ERROR; + + Optional optionalEnchant = instance.getEnchantManager().getValue(args[1].replaceAll("_", " ")); + + if (!optionalEnchant.isPresent()) { + instance.getLocale().newMessage("&cNo enchants exist with that name...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + if (!CommandCommons.isInt(args[2], sender)) + return ReturnType.FAILURE; + + int successRate = 100; + int destroyRate = 0; + + if (args.length > 3) { + if (!CommandCommons.isInt(args[3], sender)) + return ReturnType.FAILURE; + successRate = Integer.parseInt(args[3]); + } + + if (args.length > 4) { + if (!CommandCommons.isInt(args[4], sender)) + return ReturnType.FAILURE; + destroyRate = Integer.parseInt(args[4]); + } + Enchant enchant = optionalEnchant.get(); + int level = Integer.parseInt(args[2]); + Player player = (Player) sender; + + if (!enchant.getItemWhitelist().contains(player.getItemInHand().getType())) { + System.out.println("List = " + enchant.getItemWhitelist()); + instance.getLocale().getMessage("command.apply.invaliditem") + .processPlaceholder("enchant", enchant.getIdentifier()) + .sendPrefixedMessage(player); + return ReturnType.FAILURE; + } + + int slot = player.getInventory().getHeldItemSlot(); + ItemStack before = player.getItemInHand(); + Tuple result = instance.getEnchantUtils().apply(before, enchant, level, + successRate, destroyRate); + + instance.getLocale().getMessage(getMessageFromResult(result.getRight())) + .processPlaceholder("enchant", enchant.getIdentifier()) + .sendPrefixedMessage(player); + + if (result.getRight() == BROKEN_FAILURE) { + player.getInventory().clear(slot); + return ReturnType.FAILURE; + } + + player.getInventory().setItem(slot, result.getLeft()); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.apply"; + } + + @Override + public String getSyntax() { + return "/ee apply [success-rate] [destroy-rate]"; + } + + @Override + public String getDescription() { + return "Apply an enchant to the item in hand."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandEnchanter.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandEnchanter.java new file mode 100644 index 0000000..14dce8a --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandEnchanter.java @@ -0,0 +1,43 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.menus.EnchanterMenu; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class CommandEnchanter extends AbstractCommand { + + public CommandEnchanter(AbstractCommand parent) { + super(parent, true, "enchanter"); + } + + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + Player player = (Player)sender; + new EnchanterMenu(instance, instance.getFileManager().getConfiguration("menus/enchanter-menu"), player).open(player); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.enchanter"; + } + + @Override + public String getSyntax() { + return "/ee enchanter"; + } + + @Override + public String getDescription() { + return "Opens the Enchanter."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandEpicEnchants.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandEpicEnchants.java new file mode 100644 index 0000000..9f045b4 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandEpicEnchants.java @@ -0,0 +1,51 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.utils.Methods; +import org.bukkit.command.CommandSender; + +import java.util.List; + +public class CommandEpicEnchants extends AbstractCommand { + + public CommandEpicEnchants() { + super(null, false, "EpicEnchants"); + } + + @Override + protected AbstractCommand.ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + sender.sendMessage(""); + instance.getLocale().newMessage("&7Version " + instance.getDescription().getVersion() + + " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(sender); + + for (AbstractCommand command : instance.getCommandManager().getCommands()) { + if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { + sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription())); + } + } + sender.sendMessage(""); + + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return null; + } + + @Override + public String getSyntax() { + return "/EpicEnchants"; + } + + @Override + public String getDescription() { + return "Displays this page."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveBook.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveBook.java new file mode 100644 index 0000000..c15b04b --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveBook.java @@ -0,0 +1,108 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.CommandCommons; +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.enums.EnchantResult; +import com.songoda.epicenchants.objects.Enchant; +import com.songoda.epicenchants.utils.Tuple; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.List; +import java.util.Optional; + +import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE; +import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult; + +public class CommandGiveBook extends AbstractCommand { + + public CommandGiveBook(AbstractCommand parent) { + super(parent, false, "givebook"); + } + + //ee givebook [level] [success-rate] [destroy-rate] + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + if (args.length < 3 || args.length > 6) + return ReturnType.SYNTAX_ERROR; + + OfflinePlayer target = Bukkit.getPlayer(args[1]); + + if (target == null) { + instance.getLocale().newMessage("&cThis player does not exist...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + Optional optionalEnchant = instance.getEnchantManager().getValue(args[2].replaceAll("_", " ")); + + if (!optionalEnchant.isPresent()) { + instance.getLocale().newMessage("&cNo enchants exist with that name...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + Enchant enchant = optionalEnchant.get(); + int level = -1; + int successRate = -1; + int destroyRate = -1; + + if (args.length > 3) { + if (!CommandCommons.isInt(args[3], sender)) + return ReturnType.FAILURE; + level = Integer.parseInt(args[3]); + } + + if (args.length > 4) { + if (!CommandCommons.isInt(args[4], sender)) + return ReturnType.FAILURE; + successRate = Integer.parseInt(args[4]); + } + + if (args.length > 5) { + if (!CommandCommons.isInt(args[5], sender)) + return ReturnType.FAILURE; + destroyRate = Integer.parseInt(args[5]); + } + + if (level != -1 && (level > enchant.getMaxLevel() || level < 1)) { + instance.getLocale().getMessage("command.book." + (level > enchant.getMaxLevel() ? "maxlevel" : "minlevel")) + .processPlaceholder("enchant", enchant.getIdentifier()) + .processPlaceholder("maxlevel", enchant.getMaxLevel()) + .sendPrefixedMessage(sender); + return ReturnType.SUCCESS; + } + + target.getPlayer().getInventory().addItem(enchant.getBook().get(enchant, level, successRate, destroyRate)); + instance.getLocale().getMessage("command.book.received") + .processPlaceholder("enchant", enchant.getIdentifier()) + .sendPrefixedMessage(target.getPlayer()); + instance.getLocale().getMessage("command.book.gave") + .processPlaceholder("player", target.getPlayer().getName()) + .processPlaceholder("enchant", enchant.getIdentifier()) + .sendPrefixedMessage(sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.givebook"; + } + + @Override + public String getSyntax() { + return "/ee givebook [level] [success-rate] [destroy-rate]"; + } + + @Override + public String getDescription() { + return "Give enchant books to players."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveItemDust.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveItemDust.java new file mode 100644 index 0000000..6c6fee7 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveItemDust.java @@ -0,0 +1,88 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.CommandCommons; +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.objects.Enchant; +import com.songoda.epicenchants.objects.Group; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class CommandGiveItemDust extends AbstractCommand { + + public CommandGiveItemDust(AbstractCommand parent) { + super(parent, false, "giveitemdust"); + } + + //ee giveitemdust [type] [percentage] + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + if (args.length < 3 || args.length > 6) + return ReturnType.SYNTAX_ERROR; + + OfflinePlayer target = Bukkit.getPlayer(args[1]); + + if (target == null) { + instance.getLocale().newMessage("&cThis player does not exist...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + List groups = instance.getGroupManager().getValues().stream() + .filter(group -> group.getIdentifier().equalsIgnoreCase(args[2])).collect(Collectors.toList()); + + if (groups.isEmpty()) { + instance.getLocale().newMessage("&cThe group you entered was no found...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + Group group = groups.get(0); + + String dustType = null; + int percentage = -1; + + if (args.length > 3) { + dustType = args[3]; + } + + if (args.length > 4) { + if (!CommandCommons.isInt(args[4], sender)) + return ReturnType.FAILURE; + percentage = Integer.parseInt(args[4]); + } + + target.getPlayer().getInventory().addItem(instance.getSpecialItems().getDust(group, dustType, percentage, true)); + instance.getLocale().getMessage("command.dust.received") + .processPlaceholder("group", group.getIdentifier()) + .sendPrefixedMessage(target.getPlayer()); + instance.getLocale().getMessage("command.dust.gave") + .processPlaceholder("player", target.getPlayer().getName()) + .processPlaceholder("group", group.getIdentifier()) + .sendPrefixedMessage(sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.giveitemdust"; + } + + @Override + public String getSyntax() { + return "/ee giveitemdust [type] [percentage]"; + } + + @Override + public String getDescription() { + return "Give item dust."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveScroll.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveScroll.java new file mode 100644 index 0000000..14975df --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandGiveScroll.java @@ -0,0 +1,92 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.CommandCommons; +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; + +import java.util.List; + +public class CommandGiveScroll extends AbstractCommand { + + public CommandGiveScroll(AbstractCommand parent) { + super(parent, false, "givescroll"); + } + + //ee givescroll [amount] [success-rate] + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + if (args.length < 3 || args.length > 6) + return ReturnType.SYNTAX_ERROR; + + String giveType = args[1]; + OfflinePlayer target = Bukkit.getPlayer(args[2]); + + if (target == null) { + instance.getLocale().newMessage("&cThis player does not exist...").sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + int amount = 1; + int successRate = -1; + + + if (args.length > 3) { + if (!CommandCommons.isInt(args[3], sender)) + return ReturnType.FAILURE; + amount = Integer.parseInt(args[3]); + } + + if (args.length > 4) { + if (!CommandCommons.isInt(args[4], sender)) + return ReturnType.FAILURE; + successRate = Integer.parseInt(args[4]); + } + + String messageKey; + switch (giveType.toLowerCase()) { + case "whitescroll": + target.getPlayer().getInventory().addItem(instance.getSpecialItems().getWhiteScroll(amount)); + messageKey = "whitescroll"; + break; + case "blackscroll": + messageKey = "blackscroll"; + target.getPlayer().getInventory().addItem(instance.getSpecialItems().getBlackScroll(amount, successRate)); + break; + default: + instance.getLocale().getMessage("command.giveunknown") + .processPlaceholder("unknown", giveType) + .sendPrefixedMessage(sender); + return ReturnType.FAILURE; + } + + instance.getLocale().getMessage("command." + messageKey + ".received") + .sendPrefixedMessage(target.getPlayer()); + instance.getLocale().getMessage("command." + messageKey + ".gave") + .processPlaceholder("player", target.getName()) + .sendPrefixedMessage(sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.givescroll"; + } + + @Override + public String getSyntax() { + return "/ee givescroll [amount] [success-rate]"; + } + + @Override + public String getDescription() { + return "Give enchant scrolls to players."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandInfo.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandInfo.java new file mode 100644 index 0000000..a2060b4 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandInfo.java @@ -0,0 +1,51 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.CommandCommons; +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.enums.EnchantResult; +import com.songoda.epicenchants.objects.Enchant; +import com.songoda.epicenchants.utils.Tuple; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.List; +import java.util.Optional; + +import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE; +import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult; + +public class CommandInfo extends AbstractCommand { + + public CommandInfo(AbstractCommand parent) { + super(parent, true, "info"); + } + + //ee apply [enchant] [level] + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + instance.getInfoManager().getMainInfoMenu().open((Player)sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.info"; + } + + @Override + public String getSyntax() { + return "/ee info"; + } + + @Override + public String getDescription() { + return "List all enchants with their description."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandReload.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandReload.java new file mode 100644 index 0000000..4b7e1f8 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandReload.java @@ -0,0 +1,41 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import org.bukkit.command.CommandSender; + +import java.util.List; + +public class CommandReload extends AbstractCommand { + + public CommandReload(AbstractCommand parent) { + super(parent, false, "reload"); + } + + @Override + protected AbstractCommand.ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + instance.reload(); + instance.getLocale().getMessage("command.reload").sendPrefixedMessage(sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.reload"; + } + + @Override + public String getSyntax() { + return "/ee reload"; + } + + @Override + public String getDescription() { + return "Reload the Configuration files."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandSettings.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandSettings.java new file mode 100644 index 0000000..b09664b --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandSettings.java @@ -0,0 +1,41 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class CommandSettings extends AbstractCommand { + + public CommandSettings(AbstractCommand parent) { + super(parent, true, "Settings"); + } + + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + instance.getSettingsManager().openSettingsManager((Player) sender); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.admin"; + } + + @Override + public String getSyntax() { + return "/ee settings"; + } + + @Override + public String getDescription() { + return "Edit the EpicEnchants Settings."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/command/commands/CommandTinkerer.java b/src/main/java/com/songoda/epicenchants/command/commands/CommandTinkerer.java new file mode 100644 index 0000000..9e13f38 --- /dev/null +++ b/src/main/java/com/songoda/epicenchants/command/commands/CommandTinkerer.java @@ -0,0 +1,44 @@ +package com.songoda.epicenchants.command.commands; + +import com.songoda.epicenchants.EpicEnchants; +import com.songoda.epicenchants.command.AbstractCommand; +import com.songoda.epicenchants.menus.EnchanterMenu; +import com.songoda.epicenchants.menus.TinkererMenu; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class CommandTinkerer extends AbstractCommand { + + public CommandTinkerer(AbstractCommand parent) { + super(parent, true, "tinkerer"); + } + + @Override + protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { + Player player = (Player)sender; + new TinkererMenu(instance, instance.getFileManager().getConfiguration("menus/tinkerer-menu")).open(player); + return ReturnType.SUCCESS; + } + + @Override + protected List onTab(EpicEnchants instance, CommandSender sender, String... args) { + return null; + } + + @Override + public String getPermissionNode() { + return "epicenchants.tinkerer"; + } + + @Override + public String getSyntax() { + return "/ee tinkerer"; + } + + @Override + public String getDescription() { + return "Opens the Tinkerer."; + } +} diff --git a/src/main/java/com/songoda/epicenchants/commands/CustomCommand.java b/src/main/java/com/songoda/epicenchants/commands/CustomCommand.java deleted file mode 100644 index ebb2d3d..0000000 --- a/src/main/java/com/songoda/epicenchants/commands/CustomCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.songoda.epicenchants.commands; - -import co.aikar.commands.BaseCommand; -import co.aikar.commands.annotation.CommandAlias; -import co.aikar.commands.annotation.CommandPermission; -import co.aikar.commands.annotation.Dependency; -import co.aikar.commands.annotation.Description; -import com.songoda.epicenchants.EpicEnchants; -import com.songoda.epicenchants.menus.AlchemistMenu; -import com.songoda.epicenchants.menus.EnchanterMenu; -import com.songoda.epicenchants.menus.TinkererMenu; -import org.bukkit.entity.Player; - -public class CustomCommand extends BaseCommand { - - @Dependency("instance") - private EpicEnchants instance; - - @CommandAlias("%enchanter") - @Description("Opens the Enchanter") - @CommandPermission("epicenchants.enchanter") - public void onEnchanter(Player player) { - new EnchanterMenu(instance, instance.getFileManager().getConfiguration("menus/enchanter-menu"), player).open(player); - } - - @CommandAlias("%tinkerer") - @Description("Opens the Tinkerer") - @CommandPermission("epicenchants.tinkerer") - public void onTinkerer(Player player) { - new TinkererMenu(instance, instance.getFileManager().getConfiguration("menus/tinkerer-menu")).open(player); - } - - @CommandAlias("%alchemist") - @Description("Opens the Alchemist") - @CommandPermission("epicenchants.alchemist") - public void onAlchemist(Player player) { - new AlchemistMenu(instance, instance.getFileManager().getConfiguration("menus/alchemist-menu")).open(player); - } - -} diff --git a/src/main/java/com/songoda/epicenchants/commands/EnchantCommand.java b/src/main/java/com/songoda/epicenchants/commands/EnchantCommand.java deleted file mode 100644 index d6d5f03..0000000 --- a/src/main/java/com/songoda/epicenchants/commands/EnchantCommand.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.songoda.epicenchants.commands; - -import co.aikar.commands.BaseCommand; -import co.aikar.commands.CommandHelp; -import co.aikar.commands.annotation.*; -import com.songoda.epicenchants.EpicEnchants; -import com.songoda.epicenchants.enums.EnchantResult; -import com.songoda.epicenchants.objects.Enchant; -import com.songoda.epicenchants.objects.Group; -import com.songoda.epicenchants.utils.Tuple; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE; -import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult; - -@CommandAlias("epicenchants|ee") -public class EnchantCommand extends BaseCommand { - - @Dependency("instance") - private EpicEnchants instance; - - //ee give book [player] [enchant] - @Subcommand("give book") - @CommandCompletion("@players @enchants @levels @increment @increment") - @Description("Give enchant books to players") - @CommandPermission("epicenchants.give.book") - public void onGiveBook(CommandSender sender, @Flags("other") Player target, Enchant enchant, @Optional Integer level, @Optional Integer successRate, @Optional Integer destroyRate) { - if (level != null && (level > enchant.getMaxLevel() || level < 1)) { - instance.getLocale().getMessage("command.book." + (level > enchant.getMaxLevel() ? "maxlevel" : "minlevel")) - .processPlaceholder("enchant", enchant.getIdentifier()) - .processPlaceholder("maxlevel", enchant.getMaxLevel()) - .sendPrefixedMessage(sender); - return; - } - - target.getInventory().addItem(enchant.getBook().get(enchant, level, successRate, destroyRate)); - instance.getLocale().getMessage("command.book.received") - .processPlaceholder("enchant", enchant.getIdentifier()) - .sendPrefixedMessage(target); - instance.getLocale().getMessage("command.book.gave") - .processPlaceholder("player", target.getName()) - .processPlaceholder("enchant", enchant.getIdentifier()) - .sendPrefixedMessage(sender); - } - - //ee give item dust [player] [group] - @Subcommand("give item dust") - @CommandCompletion("@players @groups @dustTypes @nothing") - @CommandPermission("epicenchants.give.item.dust") - public void onGiveDust(CommandSender sender, @Flags("other") Player target, Group group, @Optional String dustType, @Optional Integer percentage) { - target.getInventory().addItem(instance.getSpecialItems().getDust(group, dustType, percentage, true)); - instance.getLocale().getMessage("command.dust.received") - .processPlaceholder("group", group.getIdentifier()) - .sendPrefixedMessage(target); - instance.getLocale().getMessage("command.dust.gave") - .processPlaceholder("player", target.getName()) - .processPlaceholder("group", group.getIdentifier()) - .sendPrefixedMessage(sender); - } - - //ee give item [giveType] [player] - @Subcommand("give item") - @CommandCompletion("@giveType @players @nothing @nothing") - @Description("Give enchant books to players") - @CommandPermission("epicenchants.give.item") - public void onGiveItem(CommandSender sender, String giveType, @Flags("other") Player target, @Optional Integer amount, @Optional Integer successRate) { - String messageKey; - switch (giveType.toLowerCase()) { - case "whitescroll": - target.getInventory().addItem(instance.getSpecialItems().getWhiteScroll(amount)); - messageKey = "whitescroll"; - break; - case "blackscroll": - messageKey = "blackscroll"; - target.getInventory().addItem(instance.getSpecialItems().getBlackScroll(amount, successRate)); - break; - default: - instance.getLocale().getMessage("command.giveunknown") - .processPlaceholder("unknown", giveType) - .sendPrefixedMessage(target); - return; - } - - instance.getLocale().getMessage("command." + messageKey + ".received") - .sendPrefixedMessage(target); - instance.getLocale().getMessage("command." + messageKey + ".gave") - .processPlaceholder("player", target.getName()) - .sendPrefixedMessage(target); - } - - - //ee apply [enchant] [level] - @Subcommand("apply") - @CommandCompletion("@enchants @nothing") - @Description("Apply enchant to item in hand") - @CommandPermission("epicenchants.apply") - public void onApply(Player player, Enchant enchant, int level, @Optional Integer successRate, @Optional Integer destroyRate) { - if (!enchant.getItemWhitelist().contains(player.getItemInHand().getType())) { - System.out.println("List = " + enchant.getItemWhitelist()); - instance.getLocale().getMessage("command.apply.invaliditem") - .processPlaceholder("enchant", enchant.getIdentifier()) - .sendPrefixedMessage(player); - return; - } - - int slot = player.getInventory().getHeldItemSlot(); - ItemStack before = player.getItemInHand(); - Tuple result = instance.getEnchantUtils().apply(before, enchant, level, - successRate == null ? 100 : successRate, destroyRate == null ? 0 : destroyRate); - - instance.getLocale().getMessage(getMessageFromResult(result.getRight())) - .processPlaceholder("enchant", enchant.getIdentifier()) - .sendPrefixedMessage(player); - - if (result.getRight() == BROKEN_FAILURE) { - player.getInventory().clear(slot); - return; - } - - player.getInventory().setItem(slot, result.getLeft()); - } - - //ee list - @Subcommand("info") - @CommandPermission("epicenchants.info") - @Description("List all enchants with their description") - public void onList(Player player) { - instance.getInfoManager().getMainInfoMenu().open(player); - } - - //ee reload [enchantFileName] - @Subcommand("reload") - @Description("Reload all config files.") - @CommandPermission("epicenchants.reload") - public void onReload(CommandSender sender) { - instance.reload(); - instance.getLocale().getMessage("command.reload").sendPrefixedMessage(sender); - } - - @HelpCommand - public void doHelp(CommandSender sender, CommandHelp help) { - help.showHelp(); - } -} diff --git a/src/main/java/com/songoda/epicenchants/listeners/item/BlackScrollListener.java b/src/main/java/com/songoda/epicenchants/listeners/item/BlackScrollListener.java index aee9bf5..e82d260 100644 --- a/src/main/java/com/songoda/epicenchants/listeners/item/BlackScrollListener.java +++ b/src/main/java/com/songoda/epicenchants/listeners/item/BlackScrollListener.java @@ -22,7 +22,7 @@ public class BlackScrollListener extends ItemListener { } event.setCancelled(true); - NBTCompound compound = current.getCompound("src/main/resources/enchants"); + NBTCompound compound = current.getCompound("enchants"); if (compound == null || compound.getKeys().isEmpty()) { instance.getLocale().getMessage("blackscroll.noenchants") diff --git a/src/main/java/com/songoda/epicenchants/managers/CommandManager.java b/src/main/java/com/songoda/epicenchants/managers/CommandManager.java deleted file mode 100644 index 4c72d9b..0000000 --- a/src/main/java/com/songoda/epicenchants/managers/CommandManager.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.songoda.epicenchants.managers; - -import co.aikar.commands.BukkitCommandManager; -import co.aikar.commands.InvalidCommandArgument; -import com.songoda.epicenchants.EpicEnchants; -import com.songoda.epicenchants.commands.CustomCommand; -import com.songoda.epicenchants.commands.EnchantCommand; -import com.songoda.epicenchants.enums.GiveType; -import com.songoda.epicenchants.objects.Enchant; -import com.songoda.epicenchants.objects.Group; - -import java.util.Arrays; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class CommandManager extends BukkitCommandManager { - public CommandManager(EpicEnchants instance) { - super(instance); - - // DEPENDENCIES - - registerDependency(EpicEnchants.class, "instance", instance); - - // COMPLETIONS - - getCommandCompletions().registerCompletion("src/main/resources/enchants", c -> - instance.getEnchantManager().getKeys().stream().map(s -> s.replaceAll("\\s", "_")).collect(Collectors.toList())); - - getCommandCompletions().registerCompletion("giveType", c -> - Arrays.stream(GiveType.values()).map(s -> s.toString().replace("_", "-").toLowerCase()).collect(Collectors.toList())); - - getCommandCompletions().registerCompletion("levels", c -> - IntStream.rangeClosed(1, c.getContextValue(Enchant.class).getMaxLevel()).boxed().map(Objects::toString).collect(Collectors.toList())); - - getCommandCompletions().registerCompletion("increment", c -> - IntStream.rangeClosed(0, 100).filter(i -> i % 10 == 0).boxed().map(Objects::toString).collect(Collectors.toList())); - - getCommandCompletions().registerCompletion("groups", c -> - instance.getGroupManager().getValues().stream().map(Group::getIdentifier).collect(Collectors.toList())); - - getCommandCompletions().registerCompletion("dustTypes", c -> - instance.getFileManager().getConfiguration("items/dusts").getConfigurationSection("dusts").getKeys(false)); - - // CONTEXTS - - getCommandContexts().registerContext(Enchant.class, c -> - instance.getEnchantManager().getValue(c.popFirstArg().replaceAll("_", " ")).orElseThrow(() -> - new InvalidCommandArgument("No enchant exists by that name", false))); - - getCommandContexts().registerContext(GiveType.class, c -> Arrays.stream(GiveType.values()) - .filter(s -> s.toString().toLowerCase().replace("_", "-").equalsIgnoreCase(c.popFirstArg())) - .findFirst() - .orElseThrow(() -> new InvalidCommandArgument("No item by that type.", false))); - - getCommandContexts().registerContext(Group.class, c -> instance.getGroupManager().getValue(c.popFirstArg().toUpperCase()).orElseThrow(() -> - new InvalidCommandArgument("No group exists by that name", false))); - - // REPLACEMENTS - - getCommandReplacements().addReplacements( - "enchanter", instance.getFileManager().getConfiguration("config").getString("commands.enchanter"), - "alchemist", instance.getFileManager().getConfiguration("config").getString("commands.alchemist"), - "tinkerer", instance.getFileManager().getConfiguration("config").getString("commands.tinkerer") - ); - - // API - - enableUnstableAPI("help"); - - // COMMANDS - - registerCommand(new EnchantCommand()); - registerCommand(new CustomCommand()); - } -} diff --git a/src/main/java/com/songoda/epicenchants/managers/EnchantManager.java b/src/main/java/com/songoda/epicenchants/managers/EnchantManager.java index 708a764..bfd5aeb 100644 --- a/src/main/java/com/songoda/epicenchants/managers/EnchantManager.java +++ b/src/main/java/com/songoda/epicenchants/managers/EnchantManager.java @@ -30,7 +30,7 @@ public class EnchantManager extends Manager { } public void loadEnchants() { - instance.getFileManager().getYmlFiles("src/main/resources/enchants").forEach(file -> { + instance.getFileManager().getYmlFiles("enchants").forEach(file -> { try { loadEnchant(file); } catch (Exception e) { diff --git a/src/main/java/com/songoda/epicenchants/managers/FileManager.java b/src/main/java/com/songoda/epicenchants/managers/FileManager.java index 916c741..0d8603c 100644 --- a/src/main/java/com/songoda/epicenchants/managers/FileManager.java +++ b/src/main/java/com/songoda/epicenchants/managers/FileManager.java @@ -2,6 +2,7 @@ package com.songoda.epicenchants.managers; import com.songoda.epicenchants.EpicEnchants; import com.songoda.epicenchants.utils.objects.FileLocation; +import com.songoda.epicenchants.utils.settings.Setting; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -10,6 +11,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.nio.file.Files; import java.util.*; @@ -21,18 +23,55 @@ public class FileManager extends Manager { private final String directory; private final LinkedHashSet files = new LinkedHashSet<>(asList( - of("config.yml", true), - of("src/main/resources/menus/main-info-menu.yml", true), + of("menus/main-info-menu.yml", true), of("menus/enchanter-menu.yml", true, true), of("menus/tinkerer-menu.yml", true, true), of("menus/alchemist-menu.yml", true, true), - of("src/main/resources/menus/groups/simple-menu.yml", false), - of("src/main/resources/menus/groups/unique-menu.yml", false), - of("src/main/resources/menus/groups/elite-menu.yml", false), - of("src/main/resources/menus/groups/ultimate-menu.yml", false), - of("src/main/resources/menus/groups/legendary-menu.yml", false), - of("src/main/resources/enchants/example-enchant.yml", false), - of("src/main/resources/groups.yml", true), + of("menus/groups/simple-menu.yml", false), + of("menus/groups/unique-menu.yml", false), + of("menus/groups/elite-menu.yml", false), + of("menus/groups/ultimate-menu.yml", false), + of("menus/groups/legendary-menu.yml", false), + + of("enchants/elite/AntiGravity.yml", false), + of("enchants/elite/Frozen.yml", false), + of("enchants/elite/Poison.yml", false), + of("enchants/elite/RocketEscape.yml", false), + of("enchants/elite/Shockwave.yml", false), + of("enchants/elite/Wither.yml", false), + + of("enchants/legendary/DeathBringer.yml", false), + of("enchants/legendary/DeathGod.yml", false), + of("enchants/legendary/Enlightened.yml", false), + of("enchants/legendary/Gears.yml", false), + of("enchants/legendary/LifeSteal.yml", false), + of("enchants/legendary/Overload.yml", false), + of("enchants/legendary/SkillSwipe.yml", false), + + of("enchants/simple/Aquatic.yml", false), + of("enchants/simple/Confusion.yml", false), + of("enchants/simple/Experience.yml", false), + of("enchants/simple/Glowing.yml", false), + of("enchants/simple/Haste.yml", false), + of("enchants/simple/Insomnia.yml", false), + of("enchants/simple/Lightning.yml", false), + of("enchants/simple/Obliterate.yml", false), + of("enchants/simple/Oxygenate.yml", false), + + of("enchants/ultimate/Blind.yml", false), + of("enchants/ultimate/Dodge.yml", false), + of("enchants/ultimate/IceAspect.yml", false), + of("enchants/ultimate/StormFall.yml", false), + + of("enchants/unique/Berserk.yml", false), + of("enchants/unique/Explosive.yml", false), + of("enchants/unique/FeatherWeight.yml", false), + of("enchants/unique/ObsidianDestroyer.yml", false), + of("enchants/unique/PlagueCarrier.yml", false), + of("enchants/unique/Ragdoll.yml", false), + of("enchants/unique/SelfDestruct.yml", false), + + of("groups.yml", true), of("items/special-items.yml", true, true), of("items/dusts.yml", true, true) )); @@ -47,14 +86,13 @@ public class FileManager extends Manager { files.forEach(fileLocation -> { File file = new File(instance.getDataFolder() + separator + fileLocation.getPath()); - if (!file.exists() && (fileLocation.isRequired() || getConfiguration("config").getBoolean("System.First Load"))) { + if (!file.exists() && (fileLocation.isRequired() || Setting.FIRST_LOAD.getBoolean())) { file.getParentFile().mkdirs(); Bukkit.getConsoleSender().sendMessage("Creating file: " + fileLocation.getPath()); try { - InputStream in = instance.getResource(fileLocation.getResourcePath(directory)); - if (in != null) - Files.copy(in, file.toPath()); + System.out.println(fileLocation.getResourcePath(directory) + " : " + file.toPath()); + copy(instance.getResource(fileLocation.getResourcePath(directory)), Files.newOutputStream(file.toPath())); } catch (IOException e) { e.printStackTrace(); } @@ -71,12 +109,8 @@ public class FileManager extends Manager { } }); - getConfiguration("config").set("System.First Load", false); - try { - getConfiguration("config").save(new File(instance.getDataFolder() + separator + "config.yml")); - } catch (IOException e) { - e.printStackTrace(); - } + instance.getConfig().set("System.First Load", false); + instance.getSettingsManager().reloadConfig(); } public FileConfiguration getConfiguration(String key) { @@ -103,4 +137,17 @@ public class FileManager extends Manager { return output; } + + private static void copy(InputStream input, OutputStream output) { + int n; + byte[] buffer = new byte[1024 * 4]; + + try { + while ((n = input.read(buffer)) != -1) { + output.write(buffer, 0, n); + } + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/songoda/epicenchants/managers/InfoManager.java b/src/main/java/com/songoda/epicenchants/managers/InfoManager.java index a881e43..09a67c1 100644 --- a/src/main/java/com/songoda/epicenchants/managers/InfoManager.java +++ b/src/main/java/com/songoda/epicenchants/managers/InfoManager.java @@ -24,7 +24,7 @@ public class InfoManager extends Manager { public void loadMenus() { mainInfoMenu = new MainInfoMenu(instance, instance.getFileManager().getConfiguration("menus/main-info-menu")); - instance.getFileManager().getYmlFiles("src/main/resources/menus/groups").forEach(file -> { + instance.getFileManager().getYmlFiles("menus/groups").forEach(file -> { try { YamlConfiguration config = YamlConfiguration.loadConfiguration(file); add(instance.getGroupManager().getValue(config.getString("group")) diff --git a/src/main/java/com/songoda/epicenchants/menus/TinkererMenu.java b/src/main/java/com/songoda/epicenchants/menus/TinkererMenu.java index ec2cf80..37b39c3 100644 --- a/src/main/java/com/songoda/epicenchants/menus/TinkererMenu.java +++ b/src/main/java/com/songoda/epicenchants/menus/TinkererMenu.java @@ -178,7 +178,7 @@ public class TinkererMenu extends FastInv { return NONE; } - if (!itemStack.getEnchantments().isEmpty() || (nbtItem.getCompound("src/main/resources/enchants") != null && !nbtItem.getCompound("src/main/resources/enchants").getKeys().isEmpty())) { + if (!itemStack.getEnchantments().isEmpty() || (nbtItem.getCompound("enchants") != null && !nbtItem.getCompound("enchants").getKeys().isEmpty())) { if (getExpAmount(itemStack) == 0) { return NONE; } @@ -237,11 +237,11 @@ public class TinkererMenu extends FastInv { NBTItem nbtItem = new NBTItem(itemStack); - if (!nbtItem.hasKey("src/main/resources/enchants")) { + if (!nbtItem.hasKey("enchants")) { return total.get(); } - NBTCompound enchantments = nbtItem.getCompound("src/main/resources/enchants"); + NBTCompound enchantments = nbtItem.getCompound("enchants"); if (enchantments == null) { return total.get(); diff --git a/src/main/java/com/songoda/epicenchants/objects/BookItem.java b/src/main/java/com/songoda/epicenchants/objects/BookItem.java index 19c1515..f5d2001 100644 --- a/src/main/java/com/songoda/epicenchants/objects/BookItem.java +++ b/src/main/java/com/songoda/epicenchants/objects/BookItem.java @@ -45,10 +45,10 @@ public class BookItem { current().nextInt(enchant.getGroup().getDestroyRateMin(), enchant.getGroup().getDestroyRateMax())); } - public ItemStack get(Enchant enchant, @Nullable Integer level, @Nullable Integer successRate, @Nullable Integer destroyRate) { - successRate = successRate == null ? current().nextInt(101) : successRate; - destroyRate = destroyRate == null ? current().nextInt(101) : destroyRate; - level = level == null ? current().nextInt(1, enchant.getMaxLevel() + 1) : level; + public ItemStack get(Enchant enchant, int level, int successRate, int destroyRate) { + successRate = successRate == -1 ? current().nextInt(101) : successRate; + destroyRate = destroyRate == -1 ? current().nextInt(101) : destroyRate; + level = level == -1 ? current().nextInt(1, enchant.getMaxLevel() + 1) : level; int finalSuccessRate = successRate; int finalDestroyRate = destroyRate; diff --git a/src/main/java/com/songoda/epicenchants/utils/EnchantUtils.java b/src/main/java/com/songoda/epicenchants/utils/EnchantUtils.java index 18aa465..b93a97b 100644 --- a/src/main/java/com/songoda/epicenchants/utils/EnchantUtils.java +++ b/src/main/java/com/songoda/epicenchants/utils/EnchantUtils.java @@ -78,9 +78,9 @@ public class EnchantUtils { NBTItem nbtItem = itemBuilder.nbt(); - nbtItem.addCompound("src/main/resources/enchants"); + nbtItem.addCompound("enchants"); - NBTCompound compound = nbtItem.getCompound("src/main/resources/enchants"); + NBTCompound compound = nbtItem.getCompound("enchants"); compound.setInteger(enchant.getIdentifier(), level); return Tuple.of(nbtItem.getItem(), SUCCESS); @@ -93,11 +93,11 @@ public class EnchantUtils { NBTItem nbtItem = new NBTItem(itemStack); - if (!nbtItem.hasNBTData() || !nbtItem.hasKey("src/main/resources/enchants")) { + if (!nbtItem.hasNBTData() || !nbtItem.hasKey("enchants")) { return Collections.emptyMap(); } - NBTCompound compound = nbtItem.getCompound("src/main/resources/enchants"); + NBTCompound compound = nbtItem.getCompound("enchants"); if (compound == null) { return Collections.emptyMap(); @@ -128,11 +128,11 @@ public class EnchantUtils { NBTItem nbtItem = new NBTItem(itemStack); - if (nbtItem.getCompound("src/main/resources/enchants") == null || nbtItem.getCompound("src/main/resources/enchants").getInteger(enchant.getIdentifier()) == null) { + if (nbtItem.getCompound("enchants") == null || nbtItem.getCompound("enchants").getInteger(enchant.getIdentifier()) == null) { return itemStack; } - nbtItem.getCompound("src/main/resources/enchants").removeKey(enchant.getIdentifier()); + nbtItem.getCompound("enchants").removeKey(enchant.getIdentifier()); ItemBuilder output = new ItemBuilder(nbtItem.getItem()); output.removeLore(enchant.getFormat().replace("{level}", "").trim()); return output.build(); diff --git a/src/main/java/com/songoda/epicenchants/utils/Methods.java b/src/main/java/com/songoda/epicenchants/utils/Methods.java index 7ac7bad..b9ed78e 100644 --- a/src/main/java/com/songoda/epicenchants/utils/Methods.java +++ b/src/main/java/com/songoda/epicenchants/utils/Methods.java @@ -37,6 +37,17 @@ public class Methods { return glass; } + public static boolean isInt(String number) { + if (number == null || number.equals("")) + return false; + try { + Integer.parseInt(number); + } catch (NumberFormatException e) { + return false; + } + return true; + } + public static String formatText(String text) { if (text == null || text.equals("")) return ""; diff --git a/src/main/java/com/songoda/epicenchants/utils/SpecialItems.java b/src/main/java/com/songoda/epicenchants/utils/SpecialItems.java index 6b68548..e5f165c 100644 --- a/src/main/java/com/songoda/epicenchants/utils/SpecialItems.java +++ b/src/main/java/com/songoda/epicenchants/utils/SpecialItems.java @@ -22,30 +22,26 @@ public class SpecialItems { this.instance = instance; } - public ItemStack getWhiteScroll(Integer amount) { + public ItemStack getWhiteScroll(int amount) { NBTItem nbtItem = new ItemBuilder(instance.getFileManager().getConfiguration("items/special-items").getConfigurationSection("white-scroll")).nbt(); nbtItem.setBoolean("white-scroll", true); ItemStack itemStack = nbtItem.getItem(); - if (amount != null) { - itemStack.setAmount(amount); - } + itemStack.setAmount(amount); return itemStack; } - public ItemStack getBlackScroll(Integer amount, Integer chance) { - int successRate = chance == null ? ThreadLocalRandom.current().nextInt(Setting.BLACK_MIN.getInt(), Setting.BLACK_MAX.getInt() + 1) : chance; - NBTItem nbtItem = new ItemBuilder(instance.getFileManager().getConfiguration("items/special-items").getConfigurationSection("black-scroll"), of("success-rate", successRate)).nbt (); + public ItemStack getBlackScroll(int amount, int chance) { + int successRate = chance == -1 ? ThreadLocalRandom.current().nextInt(Setting.BLACK_MIN.getInt(), Setting.BLACK_MAX.getInt() + 1) : chance; + NBTItem nbtItem = new ItemBuilder(instance.getFileManager().getConfiguration("items/special-items").getConfigurationSection("black-scroll"), of("success-rate", successRate)).nbt(); nbtItem.setBoolean("black-scroll", true); nbtItem.setInteger("success-rate", successRate); ItemStack itemStack = nbtItem.getItem(); - if (amount != null) { - itemStack.setAmount(amount); - } + itemStack.setAmount(amount); return itemStack; } @@ -80,7 +76,7 @@ public class SpecialItems { return nbtItem.getItem(); } - public ItemStack getDust(Group group, @Nullable String type, @Nullable Integer percentage, boolean command) { + public ItemStack getDust(Group group, @Nullable String type, int percentage, boolean command) { FileConfiguration dustConfig = instance.getFileManager().getConfiguration("items/dusts"); int random = ThreadLocalRandom.current().nextInt(101); int counter = 0; @@ -103,7 +99,7 @@ public class SpecialItems { int minRate = config.getInt("min-rate"); int maxRate = config.getInt("max-rate"); percentage = ThreadLocalRandom.current().nextInt(minRate, maxRate + 1); - } else if (percentage == null) { + } else if (percentage == -1) { percentage = ThreadLocalRandom.current().nextInt(0, 10); } diff --git a/src/main/java/com/songoda/epicenchants/utils/single/GeneralUtils.java b/src/main/java/com/songoda/epicenchants/utils/single/GeneralUtils.java index 740b01e..12f312e 100644 --- a/src/main/java/com/songoda/epicenchants/utils/single/GeneralUtils.java +++ b/src/main/java/com/songoda/epicenchants/utils/single/GeneralUtils.java @@ -46,7 +46,7 @@ public class GeneralUtils { } public static String getMessageFromResult(EnchantResult result) { - return "enchants." + result.toString().toLowerCase().replace("_", "-"); + return "enchants." + result.toString().toLowerCase().replace("_", ""); } public static X getRandomElement(Set set) { diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang index c409c2b..50e32e7 100644 --- a/src/main/resources/en_US.lang +++ b/src/main/resources/en_US.lang @@ -6,7 +6,7 @@ general.nametag.prefix = "&8[&6EpicEnchants&8]" command.book.received = "&7You have been given a &6%enchant% &7book." command.book.gave = "&7You gave &6%player% &7an &6%enchant% &7book." command.book.maxlevel = "&cThe max level for &4%enchant% &cis &4%maxlevel%&c." -command.book.minlevel = "&cThe min level for &4$enchant% &cis &41&c." +command.book.minlevel = "&cThe min level for &4%enchant% &cis &41&c." command.whitescroll.received = "&7You have been given a whitescroll." command.whitescroll.gave = "&7You gave &6%player% &7a whitescroll." @@ -46,7 +46,7 @@ alchemist.cannotafford = "&cYou cannot afford this exchange..." alchemist.success = "&7Exchanged for &6%expcost% &7experience." enchants.invalidmaterial = "&cYou can not apply &4%enchant% &cto that item..." -enchants.failure = "&4%enchant% %cfailed to apply..." +enchants.failure = "&4%enchant% &cfailed to apply..." enchants.brokenfailure = "&4%enchant% &cfailed to apply and broke your item..." enchants.conflict = "&cYou cannot apply this enchant as it conflicts with another enchant..." enchants.maxedout = "&cYou already have that enchant maxed out on this item..." diff --git a/src/main/resources/enchants/elite/AntiGravity.yml b/src/main/resources/enchants/elite/AntiGravity.yml new file mode 100644 index 0000000..cd05770 --- /dev/null +++ b/src/main/resources/enchants/elite/AntiGravity.yml @@ -0,0 +1,27 @@ +# The enchant identifier must be unique. +identifier: Anti Gravity + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +#Description +description: + - "Permanent jump boost." + +# What items this enchant can be applied to. +item-whitelist: + - "BOOTS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: STATIC_EFFECT + # The potion type. + potion-type: JUMP_BOOST + # The amplifier of the potion effect. + amplifier: "{level}" + \ No newline at end of file diff --git a/src/main/resources/enchants/elite/Frozen.yml b/src/main/resources/enchants/elite/Frozen.yml new file mode 100644 index 0000000..0a93e24 --- /dev/null +++ b/src/main/resources/enchants/elite/Frozen.yml @@ -0,0 +1,34 @@ +# The enchant identifier must be unique. +identifier: Frozen + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +#Description +description: + - "Slow your enemies down when" + - "you are attacked." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_PLAYER_RANGE" + # The potion type. + potion-type: SLOW + # The amplifier of the potion effect. + amplifier: "{level}" + # Duration of the potion effect. + duration: "{level} * 2" + # Chance of the effect firing. + chance: "5 * {level}" + # Who should this effect be ran on. + who: OPPONENT + \ No newline at end of file diff --git a/src/main/resources/enchants/elite/Poison.yml b/src/main/resources/enchants/elite/Poison.yml new file mode 100644 index 0000000..86dce11 --- /dev/null +++ b/src/main/resources/enchants/elite/Poison.yml @@ -0,0 +1,31 @@ +# The enchant identifier must be unique. +identifier: Poison + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +# Description +description: + - "A chance of giving the poison effect." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: ATTACK_PLAYER_MELEE + # The potion type. + potion-type: POISON + # The amplifier of the potion effect. + amplifier: "{level}" + # Duration of the potion effect. + duration: "{level} * 2" + # Chance of the effect firing. + chance: "3 * {level}" + \ No newline at end of file diff --git a/src/main/resources/enchants/elite/RocketEscape.yml b/src/main/resources/enchants/elite/RocketEscape.yml new file mode 100644 index 0000000..02e3d17 --- /dev/null +++ b/src/main/resources/enchants/elite/RocketEscape.yml @@ -0,0 +1,31 @@ +# The enchant identifier must be unique. +identifier: Rocket Escape + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +#Description +description: + - "Blast off into the air at low HP." + +# What items this enchant can be applied to. +item-whitelist: + - "BOOTS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + THROW: + # The trigger that will fire this effect. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_PLAYER_RANGE" + # The direction of the throw. + direction: UP + # Magnitude of the throw. + magnitude: 3 + # Chance of the effect firing. + chance: "{level} * 10" + # Only fire at low HP + condition: "{user_health} < 5" + \ No newline at end of file diff --git a/src/main/resources/enchants/elite/Shockwave.yml b/src/main/resources/enchants/elite/Shockwave.yml new file mode 100644 index 0000000..3f92dfe --- /dev/null +++ b/src/main/resources/enchants/elite/Shockwave.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: Shockwave + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +#Description +description: + - "Push your attackers backwards" + - "when you are attacked." + +# What items this enchant can be applied to. +item-whitelist: + - "CHESTPLATES" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + THROW: + # The trigger that will fire this effect. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_PLAYER_RANGE" + # The direction of the throw. + direction: BACKWARD + # Magnitude of the throw. + magnitude: "{level} * 0.2" + # Chance of the effect firing. + chance: "{level} * 3" \ No newline at end of file diff --git a/src/main/resources/enchants/elite/Wither.yml b/src/main/resources/enchants/elite/Wither.yml new file mode 100644 index 0000000..0e712c4 --- /dev/null +++ b/src/main/resources/enchants/elite/Wither.yml @@ -0,0 +1,34 @@ +# The enchant identifier must be unique. +identifier: Wither + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ELITE + +#Description +description: + - "Infect your enemies with a wither" + - "effect when you are attacked." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_PLAYER_RANGE" + # The potion type. + potion-type: WITHER + # The amplifier of the potion effect. + amplifier: "{level}" + # Duration of the potion effect. + duration: "{level} * 2" + # Chance of the effect firing. + chance: "5 * {level}" + # Who should this effect be ran on. + who: OPPONENT + \ No newline at end of file diff --git a/src/main/resources/enchants/example-enchant.yml b/src/main/resources/enchants/example-enchant.yml deleted file mode 100644 index e7033db..0000000 --- a/src/main/resources/enchants/example-enchant.yml +++ /dev/null @@ -1,95 +0,0 @@ -# The enchant identifier must be unique. -identifier: ExampleEnchant - -# The max level for this enchant. -max-level: 3 - -# The group of this enchant. Configure the groups in the groups.yml file. -group: SIMPLE - -# The item that the enchantment book is. This will override it's group setting. -book-item: - material: BOOK - display-name: "&b&lExampleEnchant {level}" - # The lore on the enchantments books. - lore: - - "&7Drag on to enchant" - - "&a{success_rate}% Success Rate" - - "&c{destroy_rate}% Destroy Rate" - -# How the enchant should be formatted on the enchanted item. This will override it's group setting. -applied-format: "&cExampleEnchant {level}" - -# What items this enchant can be applied too. -# For a full list of item groups, please visit: https://wiki.songoda.com/display/SON/EpicEnchants -item-whitelist: - - "HELMETS" - -# This enchantment can not be applied if then enchantment below is already on the item. -conflicting-enchants: - - "someEnchant" - -# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants -effects: - # The "-1" is added because every effect key has to be unique. - POTION-1: - # The trigger that will fire this effect - trigger: DEFENSE_PLAYER_MELEE - # What player should the effect be ran on: USER/OPPONENT. - who: USER - # Potion Effect that should be applied. - potion-type: SPEED - # Duration of the Potion Effect in seconds. - duration: "10 * {level}" - # Chance that the effect gets activated. - chance: "20 * {level}" - # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. - amplifier: "{level} - 1" - POTION-2: - trigger: STATIC_EFFECT - who: WEARER - potion-type: INCREASE_DAMAGE - amplifier: "{level} - 1" - SPAWN_MOB: - # The mob type - mob-type: CREEPER - # Trigger event that spawns the mob. - trigger: DEFENSE_PLAYER_MELEE - # Max amount mobs that will be spawned. - amount: "{random(low=0, up={level})}" - # Chance that the effect gets activated. - chance: "20 * {level}" - # Drop chance of the mob its equipment upon death. - equipment-drop-chance: "10 * {level}" - # Health of the mob. - health: "3 * {level}" - # Amount of damage the mob deals. - attack-damage: "{level}" - # Display name of the spawned mob - display-name: "&cAngry guy level {level}" - # The equiment that the mob wears - equipment: - helmet: - material: DIAMOND_HELMET - enchants: - - "DURABILITY:{level}" - - "THORNS:{level} - 1" - chestplate: - material: DIAMOND_CHESTPLATE - enchants: - - "DURABILITY:{level}" - - "THORNS:{level} - 1" - leggings: - material: DIAMOND_LEGGINGS - enchants: - - "DURABILITY:{level}" - - "THORNS:{level} - 1" - boots: - material: DIAMOND_BOOTS - enchants: - - "DURABILITY:{level}" - - "THORNS:{level} - 1" - hand-item: - material: DIAMOND_SWORD - enchant: - - "SHARPNESS:{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/DeathBringer.yml b/src/main/resources/enchants/legendary/DeathBringer.yml new file mode 100644 index 0000000..c1ee5e2 --- /dev/null +++ b/src/main/resources/enchants/legendary/DeathBringer.yml @@ -0,0 +1,28 @@ +# The enchant identifier must be unique. +identifier: DeathBringer + +# The max level for this enchant. +max-level: 1 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Chance to gain Strengh for a short time." + +# What items this enchant can be applied to. +item-whitelist: + - "AXES" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # The potion type. + potion-type: INCREASE_DAMAGE + # The duration of the effect. + duration: "{level} * 2" + # Chance that this effect will fire. + chance: "{level} * 5" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/DeathGod.yml b/src/main/resources/enchants/legendary/DeathGod.yml new file mode 100644 index 0000000..0e71ad8 --- /dev/null +++ b/src/main/resources/enchants/legendary/DeathGod.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: DeathGod + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Chance of regain a lot of hearts" + - "when under 2 hearts." + +# What items this enchant can be applied to. +item-whitelist: + - "HELMETS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + MODIFY_HEALTH: + # The trigger that will fire this effect + trigger: "DEFENSE_PLAYER_MELEE,DEFENSE_PLAYER_RANGE" + # Amount of half hearts to give to the user when fired. + amount: 10 + # Only trigger this effect when the user has less than 2 hearts. + condition: "{user_health} < 4" + # Chance that this effect wil fire. + chance: "100*{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/Enlightened.yml b/src/main/resources/enchants/legendary/Enlightened.yml new file mode 100644 index 0000000..baf7da8 --- /dev/null +++ b/src/main/resources/enchants/legendary/Enlightened.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: Enlightened + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Chance to heal while damaged." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + MODIFY_HEALTH: + # The trigger that will fire this effect + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_MOB_MELEE" + # How much life does it should add + amount: "+1" + # Chances for the event to proceed + chance: "10*{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/Gears.yml b/src/main/resources/enchants/legendary/Gears.yml new file mode 100644 index 0000000..1359990 --- /dev/null +++ b/src/main/resources/enchants/legendary/Gears.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: Gears + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Gain speed when equipped." + +# What items this enchant can be applied to. +item-whitelist: + - "BOOTS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: STATIC_EFFECT + # The potion type. + potion-type: SPEED + # The amplifier of the potion effect. + amplifier: "{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/LifeSteal.yml b/src/main/resources/enchants/legendary/LifeSteal.yml new file mode 100644 index 0000000..8cb72c4 --- /dev/null +++ b/src/main/resources/enchants/legendary/LifeSteal.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: LifeSteal + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Chance to steal life from your opponent." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + STEAL_HEALTH: + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # How much life does it should steal + amount: 1 + # Chance that this effect wil fire. + chance: "5*{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/Overload.yml b/src/main/resources/enchants/legendary/Overload.yml new file mode 100644 index 0000000..675ed6f --- /dev/null +++ b/src/main/resources/enchants/legendary/Overload.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: Overload + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Grants permanent extra health." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: STATIC_EFFECT + # The potion type. + potion-type: HEALTH_BOOST + # The amplifier of the potion effect. + amplifier: "{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/legendary/SkillSwipe.yml b/src/main/resources/enchants/legendary/SkillSwipe.yml new file mode 100644 index 0000000..a30dbaf --- /dev/null +++ b/src/main/resources/enchants/legendary/SkillSwipe.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: Skill Swipe + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: LEGENDARY + +#Description +description: + - "Chance to steal EXP from your opponent." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + STEAL_EXP: + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # Chance that this effect wil fire. + chance: "5 * {level}" + # Amount of EXP to be stolen. + amount: 100 \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Aquatic.yml b/src/main/resources/enchants/simple/Aquatic.yml new file mode 100644 index 0000000..8ef81d7 --- /dev/null +++ b/src/main/resources/enchants/simple/Aquatic.yml @@ -0,0 +1,24 @@ +# The enchant identifier must be unique. +identifier: Aquatic + +# The max level for this enchant. +max-level: 1 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "Gives permanent water breathing." + +# What items this enchant can be applied to. +item-whitelist: + - "HELMETS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect + trigger: STATIC_EFFECT + # Potion Effect that should be applied. + potion-type: WATER_BREATHING \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Confusion.yml b/src/main/resources/enchants/simple/Confusion.yml new file mode 100644 index 0000000..79805e2 --- /dev/null +++ b/src/main/resources/enchants/simple/Confusion.yml @@ -0,0 +1,33 @@ +# The enchant identifier must be unique. +identifier: Confusion + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to deal" + - "nauseau to your victim." + +# What items this enchant can be applied to. +item-whitelist: + - "HELMETS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # What player should the effect be ran on: WEARER/OPPONENT. + who: OPPONENT + # Potion Effect that should be applied. + potion-type: CONFUSION + # Duration of the Potion Effect in seconds. + duration: "3 * {level}" + # Chance that the Effect gets activated. + chance: "5 * {level}" + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Experience.yml b/src/main/resources/enchants/simple/Experience.yml new file mode 100644 index 0000000..e1f5ae4 --- /dev/null +++ b/src/main/resources/enchants/simple/Experience.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: Experience + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to receive" + - "more EXP when mining blocks." + +# What items this enchant can be applied to. +item-whitelist: + - "TOOLS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + MODIFY_EXP: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: BLOCK_BREAK + # What player should the effect be ran on: USER/OPPONENT. + who: USER + # Amount of EXP to add + amount: "10 * {level}" \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Glowing.yml b/src/main/resources/enchants/simple/Glowing.yml new file mode 100644 index 0000000..ac3ac84 --- /dev/null +++ b/src/main/resources/enchants/simple/Glowing.yml @@ -0,0 +1,24 @@ +# The enchant identifier must be unique. +identifier: Glowing + +# The max level for this enchant. +max-level: 1 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "Gives you permanent night vision" + +# What items this enchant can be applied too. +item-whitelist: + - "HELMETS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION-1: + # The trigger that will fire this effect + trigger: STATIC_EFFECT + # Potion effect type + potion-type: NIGHT_VISION \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Haste.yml b/src/main/resources/enchants/simple/Haste.yml new file mode 100644 index 0000000..fc9c434 --- /dev/null +++ b/src/main/resources/enchants/simple/Haste.yml @@ -0,0 +1,28 @@ +# The enchant identifier must be unique. +identifier: Haste + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "Permanent haste effect when" + - "holding a tool with this enchant." + +# What items this enchant can be applied to. +item-whitelist: + - "TOOLS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect + trigger: HELD_ITEM + # Potion Effect that should be applied. + potion-type: FAST_DIGGING + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" + \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Insomnia.yml b/src/main/resources/enchants/simple/Insomnia.yml new file mode 100644 index 0000000..da616dd --- /dev/null +++ b/src/main/resources/enchants/simple/Insomnia.yml @@ -0,0 +1,59 @@ +# The enchant identifier must be unique. +identifier: Insomnia + +# The max level for this enchant. +max-level: 7 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to give your opponent" + - "slowness, slow swinging and confusion." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION-1: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT + # Amount of EXP to add + potion-type: CONFUSION + # Duration of the Potion Effect in seconds. + duration: "3 * {level}" + # Chance that the Effect gets activated. + chance: "5 * {level}" + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" + # Simultaneous + simultaneous: + POTION: + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT + # Amount of EXP to add + potion-type: SLOW_DIGGING + # Duration of the Potion Effect in seconds. + duration: "3 * {level}" + # Chance that the Effect gets activated. + chance: "5 * {level}" + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" + POTION-1: + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT + # Amount of EXP to add + potion-type: SLOW + # Duration of the Potion Effect in seconds. + duration: "3 * {level}" + # Chance that the Effect gets activated. + chance: "5 * {level}" + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Lightning.yml b/src/main/resources/enchants/simple/Lightning.yml new file mode 100644 index 0000000..ec61fa1 --- /dev/null +++ b/src/main/resources/enchants/simple/Lightning.yml @@ -0,0 +1,27 @@ +# The enchant identifier must be unique. +identifier: Lightning + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to strike lightning" + - "at your opponents location." + +# What items this enchant can be applied to. +item-whitelist: + - "BOWS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + LIGHTNING: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Obliterate.yml b/src/main/resources/enchants/simple/Obliterate.yml new file mode 100644 index 0000000..1934b20 --- /dev/null +++ b/src/main/resources/enchants/simple/Obliterate.yml @@ -0,0 +1,32 @@ +# The enchant identifier must be unique. +identifier: Obliterate + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to deal extreme knockback" + +# What items this enchant can be applied to. +item-whitelist: + - "WEAPONS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + THROW: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT + # What direction the player should be moved in: UP/DOWN/BACKWARD/FORWARD + direction: FORWARD + # Magnitude of the throw + magnitude: "0.2 * {level}" + # What the direction should relative to + relative-to: USER \ No newline at end of file diff --git a/src/main/resources/enchants/simple/Oxygenate.yml b/src/main/resources/enchants/simple/Oxygenate.yml new file mode 100644 index 0000000..fe44621 --- /dev/null +++ b/src/main/resources/enchants/simple/Oxygenate.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: Oxygenate + +# The max level for this enchant. +max-level: 1 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to refill your oxygen" + - "levels when breaking blocks." + +# What items this enchant can be applied to. +item-whitelist: + - "TOOLS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + MODIFY_OXYGEN: + # The trigger that will fire this effect + trigger: BLOCK_BREAK + # Potion Effect that should be applied. + potion-type: WATER_BREATHING + # Chance that this will happen + chance: "10 * {level}" + # Amount of oxygen to refill + amount: "{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/ultimate/Blind.yml b/src/main/resources/enchants/ultimate/Blind.yml new file mode 100644 index 0000000..aff7907 --- /dev/null +++ b/src/main/resources/enchants/ultimate/Blind.yml @@ -0,0 +1,33 @@ +# The enchant identifier must be unique. +identifier: Blind + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ULTIMATE + +#Description +description: + - "Chance to give the blindness on" + - "effect to your opponent on attack." + +# What items this enchant can be applied to. +item-whitelist: + - "WEAPONS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect. + trigger: ATTACK_PLAYER_MELEE + # The potion type. + potion-type: BLINDNESS + # The duration of the potion effect. + duration: "10*{level}" + # The amplifier of the potion effect. + amplifier: "2*{level}" + # Who this effect should be ran on. + who: OPPONENT + # Chance that this effect wil fire. + chance: "10*{level}" \ No newline at end of file diff --git a/src/main/resources/enchants/ultimate/Dodge.yml b/src/main/resources/enchants/ultimate/Dodge.yml new file mode 100644 index 0000000..bef0f33 --- /dev/null +++ b/src/main/resources/enchants/ultimate/Dodge.yml @@ -0,0 +1,26 @@ +# The enchant identifier must be unique. +identifier: Dodge + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ULTIMATE + +#Description +description: + - "Chance to dodge melee attacks," + - "increased chance when sneaking." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + CANCEL_EVENT: + # The trigger that will fire this effect + trigger: "DEFENSE_PLAYER_MELEE,DEFENSE_MOB_MELEE" + # Chance that this effect wil fire. + chance: "user_is_sneaking ? (8 * {level)) : (4 * {level})" + \ No newline at end of file diff --git a/src/main/resources/enchants/ultimate/IceAspect.yml b/src/main/resources/enchants/ultimate/IceAspect.yml new file mode 100644 index 0000000..2ff83f7 --- /dev/null +++ b/src/main/resources/enchants/ultimate/IceAspect.yml @@ -0,0 +1,27 @@ +# The enchant identifier must be unique. +identifier: IceAspect + +# The max level for this enchant. +max-level: 2 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ULTIMATE + +#Description +description: + - "Chance to slow your opponent." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + - "AXES" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + trigger: 'ATTACK_PLAYER_MELEE,ATTACK_PLAYER_RANGE,ATTACK_MOB_MELEE,ATTACK_MOB_RANGE' + potion-type: SLOWNESS + duration: '10*{level}' + amplifier: '{level}' + who: OPPONENT + chance: '15*{level}' diff --git a/src/main/resources/enchants/ultimate/StormFall.yml b/src/main/resources/enchants/ultimate/StormFall.yml new file mode 100644 index 0000000..7e54a79 --- /dev/null +++ b/src/main/resources/enchants/ultimate/StormFall.yml @@ -0,0 +1,45 @@ +# The enchant identifier must be unique. +identifier: StormFall + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: ULTIMATE + +#Description +description: + - "Summon Lightnings at your Opponnent." + +# What items this enchant can be applied to. +item-whitelist: + - "BOWS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + effects: + LIGHTNING-1: + trigger: ATTACK_PLAYER_RANGE + who: OPPONENT + chance: '100*{level}' + LIGHTNING-2: + trigger: ATTACK_PLAYER_RANGE + who: OPPONENT + chance: '100*{level}-100' + LIGHTNING-3: + trigger: ATTACK_PLAYER_RANGE + who: OPPONENT + chance: '100*{level}-200' +#--------------------------------------- + LIGHTNING-4: + trigger: ATTACK_MOB_RANGE + who: OPPONENT + chance: '100*{level}' + LIGHTNING-5: + trigger: ATTACK_MOB_RANGE + who: OPPONENT + chance: '100*{level}-100' + LIGHTNING-6: + trigger: ATTACK_MOB_RANGE + who: OPPONENT + chance: '100*{level}-200' \ No newline at end of file diff --git a/src/main/resources/enchants/unique/Berserk.yml b/src/main/resources/enchants/unique/Berserk.yml new file mode 100644 index 0000000..5bb67b1 --- /dev/null +++ b/src/main/resources/enchants/unique/Berserk.yml @@ -0,0 +1,28 @@ +# The enchant identifier must be unique. +identifier: Berserk + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "A chance to receive strength." + - "and mining fatique." + +# What items this enchant can be applied to. +item-whitelist: + - "AXES" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: ATTACK_PLAYER_MELEE + # What player should the effect be ran on: USER/OPPONENT. + who: USER + \ No newline at end of file diff --git a/src/main/resources/enchants/unique/Explosive.yml b/src/main/resources/enchants/unique/Explosive.yml new file mode 100644 index 0000000..a3459da --- /dev/null +++ b/src/main/resources/enchants/unique/Explosive.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: Explosive + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "A chance for your arrows to" + - "blow up on impact." + +# What items this enchant can be applied to. +item-whitelist: + - "BOWS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + EXPLODE: + # Chance that this will happen + chance: "10 * {level}" + # The trigger that will fire this effect + trigger: "ATTACK_PLAYER_RANGE, ATTACK_MOB_RANGE" + # What player should the effect be ran on: USER/OPPONENT. + who: OPPONENT + # Magnitude of the throw + magnitude: "1 * {level}" \ No newline at end of file diff --git a/src/main/resources/enchants/unique/FeatherWeight.yml b/src/main/resources/enchants/unique/FeatherWeight.yml new file mode 100644 index 0000000..5ae0391 --- /dev/null +++ b/src/main/resources/enchants/unique/FeatherWeight.yml @@ -0,0 +1,28 @@ +# The enchant identifier must be unique. +identifier: Featherweight + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "A chance to give a burst of haste." + +# What items this enchant can be applied to. +item-whitelist: + - "SWORDS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + POTION: + # The trigger that will fire this effect + trigger: "ATTACK_PLAYER_MELEE, ATTACK_MOB_MELEE" + # Potion Effect that should be applied. + potion-type: FAST_DIGGING + # Amplifier of 0 = SPEED 1 a Amplifier of 1 = SPEED 2, etc. + amplifier: "{level}" + # Chance that this will happen + chance: "10 * {level}" \ No newline at end of file diff --git a/src/main/resources/enchants/unique/ObsidianDestroyer.yml b/src/main/resources/enchants/unique/ObsidianDestroyer.yml new file mode 100644 index 0000000..6c8476a --- /dev/null +++ b/src/main/resources/enchants/unique/ObsidianDestroyer.yml @@ -0,0 +1,29 @@ +# The enchant identifier must be unique. +identifier: ObsidianDestroyer + +# The max level for this enchant. +max-level: 5 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: SIMPLE + +#Description +description: + - "A chance to instantly break obsidian." + +# What items this enchant can be applied to. +item-whitelist: + - "PICKAXES" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + MODIFY_BLOCK: + # The trigger that will fire this effect + trigger: LEFT_CLICK + # Chance that this will happen + chance: "10 * {level}" + # Check if clicked block is obsidian + condition: "{clicked_block} === 'OBSIDIAN'" + # Set the block to air + material: AIR + \ No newline at end of file diff --git a/src/main/resources/enchants/unique/PlagueCarrier.yml b/src/main/resources/enchants/unique/PlagueCarrier.yml new file mode 100644 index 0000000..d2f6a42 --- /dev/null +++ b/src/main/resources/enchants/unique/PlagueCarrier.yml @@ -0,0 +1,33 @@ +# The enchant identifier must be unique. +identifier: "Plague Carrier" + +# The max level for this enchant. +max-level: 8 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "When near death summon creepers" + - "to avenge you." + +# What items this enchant can be applied to. +item-whitelist: + - "LEGGINGS" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + SPAWN_MOB: + # The mob type. + mob-type: CREEPER + # Trigger event that spawns the mob. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_MOB_MELEE" + # Max amount mobs that will be spawned. + amount: "{random(low=0, up={level})}" + # Chance of the mob spawning. + chance: "5 * {level}" + # Condition + condition: "{user_health} < 4" + # Display name of the spawned mob + display-name: "&cPlague carrier" \ No newline at end of file diff --git a/src/main/resources/enchants/unique/Ragdoll.yml b/src/main/resources/enchants/unique/Ragdoll.yml new file mode 100644 index 0000000..2fda8a8 --- /dev/null +++ b/src/main/resources/enchants/unique/Ragdoll.yml @@ -0,0 +1,33 @@ +# The enchant identifier must be unique. +identifier: Ragdoll + +# The max level for this enchant. +max-level: 4 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "A chance to be pushed back when." + - "you take damage." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + THROW: + # Chance that this will happen + chance: "5 * {level}" + # The trigger that will fire this effect + trigger: DEFENSE_PLAYER_MELEE + # What player should the effect be ran on: USER/OPPONENT. + who: USER + # What direction the player should be moved in: UP/DOWN/BACKWARD/FORWARD + direction: BACKWARD + # Magnitude of the throw + magnitude: "0.1 * {level}" + # What the direction should relative to + relative-to: USER \ No newline at end of file diff --git a/src/main/resources/enchants/unique/SelfDestruct.yml b/src/main/resources/enchants/unique/SelfDestruct.yml new file mode 100644 index 0000000..8d6d5d1 --- /dev/null +++ b/src/main/resources/enchants/unique/SelfDestruct.yml @@ -0,0 +1,30 @@ +# The enchant identifier must be unique. +identifier: "Self Destruct" + +# The max level for this enchant. +max-level: 3 + +# The group of this enchant. Configure the groups in the groups.yml file. +group: UNIQUE + +#Description +description: + - "When near death spawns tnt around you." + +# What items this enchant can be applied to. +item-whitelist: + - "ARMOR" + +# For a full list of effects, please visit: https://wiki.songoda.com/display/SON/EpicEnchants +effects: + SPAWN_TNT: + # Trigger event that spawns the mob. + trigger: "DEFENSE_PLAYER_MELEE, DEFENSE_MOB_MELEE" + # Max amount mobs that will be spawned. + amount: "{random(low=0, up={level})}" + # Chance of the mob spawning. + chance: "5 * {level}" + # Condition + condition: "{user_health} < 4" + # The fuse of the TNT + fuse: 60 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b3957c0..966779d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,12 @@ name: EpicEnchants -version: ${project.version} +version: maven-version-number main: com.songoda.epicenchants.EpicEnchants authors: [GB6] website: https://songoda.com/ depend: [Vault] softdepend: [UltimateBottles, PlaceholderAPI] -api-version: 1.13 \ No newline at end of file +api-version: 1.13 +commands: + epicenchants: + aliases: [ee] + ussage: /ee reload \ No newline at end of file