Converted commands.

This commit is contained in:
Brianna 2019-08-04 22:24:48 -04:00
parent 4db8c49fa4
commit 4f60103dc9
67 changed files with 2056 additions and 452 deletions

View File

@ -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("/");
}
}

11
pom.xml
View File

@ -34,7 +34,6 @@
<includes>
<include>com.songoda:songodaupdater</include>
<include>fr.mymicky:FastInv</include>
<include>co.aikar:acf-bukkit</include>
</includes>
</artifactSet>
<filters>
@ -67,10 +66,6 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
</repositories>
<dependencies>
@ -79,12 +74,6 @@
<artifactId>spigot</artifactId>
<version>1.14.4</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bukkit</artifactId>
<version>0.5.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.mrmicky</groupId>
<artifactId>FastInv</artifactId>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<String> 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<String> getSubCommand() {
return subCommand;
}
public void addSubCommand(String command) {
subCommand.add(command);
}
protected abstract ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args);
protected abstract List<String> 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}
}

View File

@ -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<AbstractCommand> 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<AbstractCommand> getCommands() {
return Collections.unmodifiableList(commands);
}
}

View File

@ -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<String> 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<String> 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<String> 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;
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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] <success-rate> <destroy-rate>
@Override
protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) {
if (args.length < 3 || args.length > 5)
return ReturnType.SYNTAX_ERROR;
Optional<Enchant> 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<ItemStack, EnchantResult> 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<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
return null;
}
@Override
public String getPermissionNode() {
return "epicenchants.apply";
}
@Override
public String getSyntax() {
return "/ee apply <enchant> <level> [success-rate] [destroy-rate]";
}
@Override
public String getDescription() {
return "Apply an enchant to the item in hand.";
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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 <player> <enchant> [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<Enchant> 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<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
return null;
}
@Override
public String getPermissionNode() {
return "epicenchants.givebook";
}
@Override
public String getSyntax() {
return "/ee givebook <player> <enchant> [level] [success-rate] [destroy-rate]";
}
@Override
public String getDescription() {
return "Give enchant books to players.";
}
}

View File

@ -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 <player> <group> [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<Group> 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<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
return null;
}
@Override
public String getPermissionNode() {
return "epicenchants.giveitemdust";
}
@Override
public String getSyntax() {
return "/ee giveitemdust <player> <group> [type] [percentage]";
}
@Override
public String getDescription() {
return "Give item dust.";
}
}

View File

@ -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 <giveType> <player> [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<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
return null;
}
@Override
public String getPermissionNode() {
return "epicenchants.givescroll";
}
@Override
public String getSyntax() {
return "/ee givescroll <whitescroll/blackscroll> <player> [amount] [success-rate]";
}
@Override
public String getDescription() {
return "Give enchant scrolls to players.";
}
}

View File

@ -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] <success-rate> <destroy-rate>
@Override
protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) {
instance.getInfoManager().getMainInfoMenu().open((Player)sender);
return ReturnType.SUCCESS;
}
@Override
protected List<String> 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.";
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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<String> 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.";
}
}

View File

@ -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);
}
}

View File

@ -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] <level> <success-rate> <destroy-rate>
@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] <type> <percentage>
@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] <amount> <success-rate>
@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] <success-rate> <destroy-rate>
@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<ItemStack, EnchantResult> 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();
}
}

View File

@ -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")

View File

@ -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());
}
}

View File

@ -30,7 +30,7 @@ public class EnchantManager extends Manager<String, Enchant> {
}
public void loadEnchants() {
instance.getFileManager().getYmlFiles("src/main/resources/enchants").forEach(file -> {
instance.getFileManager().getYmlFiles("enchants").forEach(file -> {
try {
loadEnchant(file);
} catch (Exception e) {

View File

@ -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<String, FileConfiguration> {
private final String directory;
private final LinkedHashSet<FileLocation> 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<String, FileConfiguration> {
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<String, FileConfiguration> {
}
});
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<String, FileConfiguration> {
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();
}
}
}

View File

@ -24,7 +24,7 @@ public class InfoManager extends Manager<Group, InfoMenu> {
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"))

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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 "";

View File

@ -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);
}

View File

@ -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> X getRandomElement(Set<X> set) {

View File

@ -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..."

View File

@ -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}"

View File

@ -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

View File

@ -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}"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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}"

View File

@ -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"

View File

@ -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}"

View File

@ -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}"

View File

@ -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}"

View File

@ -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}"

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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}"

View File

@ -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}"

View File

@ -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

View File

@ -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}"

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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}"

View File

@ -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}"

View File

@ -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})"

View File

@ -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}'

View File

@ -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'

View File

@ -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

View File

@ -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}"

View File

@ -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}"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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
api-version: 1.13
commands:
epicenchants:
aliases: [ee]
ussage: /ee reload