Added groups, info menus, worked on conditions.

This commit is contained in:
GB6 2019-01-27 16:22:05 +01:00
parent a857e5d407
commit 015a8d6ce2
35 changed files with 694 additions and 177 deletions

View File

@ -9,7 +9,8 @@ import com.songoda.epicenchants.listeners.EntityListener;
import com.songoda.epicenchants.listeners.PlayerListener;
import com.songoda.epicenchants.managers.EnchantManager;
import com.songoda.epicenchants.managers.FileManager;
import com.songoda.epicenchants.menus.BookMenu;
import com.songoda.epicenchants.managers.GroupManager;
import com.songoda.epicenchants.managers.InfoManager;
import com.songoda.epicenchants.objects.Enchant;
import com.songoda.epicenchants.utils.EnchantUtils;
import com.songoda.epicenchants.utils.FastInv;
@ -25,16 +26,17 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.utils.Chat.color;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
import static org.bukkit.Bukkit.getConsoleSender;
@Getter
public class EpicEnchants extends JavaPlugin {
private FastInv bookInventory;
private BukkitCommandManager commandManager;
private Economy economy;
private EnchantManager enchantManager;
private InfoManager infoManager;
private GroupManager groupManager;
private EnchantUtils enchantUtils;
private FileManager fileManager;
private Locale locale;
@ -50,23 +52,25 @@ public class EpicEnchants extends JavaPlugin {
this.locale = Locale.getLocale(getConfig().getString("language"));
this.fileManager = new FileManager(this);
this.enchantManager = new EnchantManager();
this.economy = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
this.groupManager = new GroupManager(this);
this.enchantManager = new EnchantManager(this);
this.enchantUtils = new EnchantUtils(this);
this.infoManager = new InfoManager(this);
this.economy = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
fileManager.createFiles();
fileManager.loadEnchants();
groupManager.loadGroups();
enchantManager.loadEnchants();
infoManager.loadMenus();
setupCommands();
setupListeners();
setupVersion();
if (!enchantManager.getEnchants().isEmpty()) {
getLogger().info("Successfully loaded enchants: " + enchantManager.getEnchants().stream().map(Enchant::getIdentifier).collect(Collectors.joining(",")));
getLogger().info("Successfully loaded enchants: " + enchantManager.getEnchants().stream().map(Enchant::getIdentifier).collect(Collectors.joining(", ")));
}
this.bookInventory = new BookMenu(this, fileManager.getConfiguration("bookMenu"));
getConsoleSender().sendMessage(color("&a============================="));
}
@ -84,10 +88,10 @@ public class EpicEnchants extends JavaPlugin {
commandManager.registerDependency(EpicEnchants.class, "instance", this);
commandManager.getCommandCompletions().registerCompletion("enchants", c -> enchantManager.getEnchants().stream().map(Enchant::getIdentifier).collect(Collectors.toList()));
commandManager.getCommandCompletions().registerCompletion("enchantFiles", c -> fileManager.getEnchantFiles().orElse(Collections.emptyList()).stream().map(File::getName).collect(Collectors.toList()));
commandManager.getCommandCompletions().registerCompletion("enchantFiles", c -> fileManager.getYmlFiles("enchants").orElse(Collections.emptyList()).stream().map(File::getName).collect(Collectors.toList()));
commandManager.getCommandContexts().registerContext(Enchant.class, c -> enchantManager.getEnchant(c.popFirstArg()).orElseThrow(() -> new InvalidCommandArgument("No enchant exists by that name")));
commandManager.getCommandContexts().registerContext(File.class, c -> fileManager.getEnchantFile(c.popFirstArg()).orElseThrow(() -> new InvalidCommandArgument("No EnchantFile exists by that name")));
commandManager.getCommandContexts().registerContext(File.class, c -> enchantManager.getEnchantFile(c.popFirstArg()).orElseThrow(() -> new InvalidCommandArgument("No EnchantFile exists by that name")));
commandManager.registerCommand(new EnchantCommand());
}
@ -115,6 +119,9 @@ public class EpicEnchants extends JavaPlugin {
public void reload() {
reloadConfig();
locale.reloadMessages();
fileManager.loadEnchants();
enchantManager.loadEnchants();
groupManager.loadGroups();
infoManager.loadMenus();
}
}

View File

@ -3,6 +3,7 @@ package com.songoda.epicenchants;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.songoda.epicenchants.objects.Placeholder;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
@ -276,8 +277,8 @@ public class Locale {
* @param node the node to get
* @return the message for the specified node
*/
public String getMessageWithPrefix(String node, Object... args) {
return ChatColor.translateAlternateColorCodes('&', getPrefix() + getMessage(node, args));
public String getMessageWithPrefix(String node, Placeholder... placeholders) {
return ChatColor.translateAlternateColorCodes('&', getPrefix() + getMessage(node, placeholders));
}
/**
@ -287,10 +288,10 @@ public class Locale {
* @param args the replacement arguments
* @return the message for the specified node
*/
public String getMessage(String node, Object... args) {
public String getMessage(String node, Placeholder... placeholders) {
String message = getMessage(node);
for (Object arg : args) {
message = message.replaceFirst("\\{.*?}", arg.toString());
for (Placeholder placeholder : placeholders) {
message = message.replaceAll(placeholder.getPlaceholder(), placeholder.getToReplace().toString());
}
return message;
}

View File

@ -4,14 +4,17 @@ import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.enums.EnchantResult;
import com.songoda.epicenchants.menus.EnchanterMenu;
import com.songoda.epicenchants.objects.Enchant;
import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.objects.Placeholder.of;
@CommandAlias("epicenchants|ee")
public class EnchantCommand extends BaseCommand {
@ -20,24 +23,24 @@ public class EnchantCommand extends BaseCommand {
private EpicEnchants instance;
@Default
@Subcommand("gui")
@Description("Opens the GUI for getting enchants")
@Subcommand("enchanter")
@Description("Opens the Enchanter")
public void onGui(Player player) {
instance.getBookInventory().open(player);
new EnchanterMenu(instance, instance.getFileManager().getConfiguration("menus/enchanter-menu"), player).open(player);
}
//ee give {player} {enchant} {tier}
//ee give {player} {enchant} {group}
@Subcommand("give")
@CommandCompletion("@players @enchants @nothing @nothing @nothing")
@Description("Give enchant books to players")
@CommandPermission("epicenchants.give")
public void onGiveBook(CommandSender sender, @Flags("other") Player target, Enchant enchant, @Optional Integer level, @Optional Integer successRate, @Optional Integer destroyRate) {
target.getInventory().addItem(enchant.getBookItem().get(enchant, level, successRate, destroyRate));
target.sendMessage(instance.getLocale().getMessageWithPrefix("command.book.given", enchant.getIdentifier()));
sender.sendMessage(instance.getLocale().getMessageWithPrefix("command.book.gave", target.getName(), enchant.getIdentifier()));
target.sendMessage(instance.getLocale().getMessageWithPrefix("command.book.given", of("enchant", enchant.getIdentifier())));
sender.sendMessage(instance.getLocale().getMessageWithPrefix("command.book.gave", of("player", target.getName()), of("enchant", enchant.getIdentifier())));
}
//ee apply {enchant} {tier}
//ee apply {enchant} {group}
@Subcommand("apply")
@CommandCompletion("@enchants @nothing")
@Description("Apply enchant to item in hand")
@ -64,18 +67,16 @@ public class EnchantCommand extends BaseCommand {
messageKey = "enchant.conflict";
}
player.sendMessage(instance.getLocale().getMessageWithPrefix(messageKey, enchant.getIdentifier()));
player.sendMessage(instance.getLocale().getMessageWithPrefix(messageKey, of("enchant", enchant.getIdentifier())));
player.getInventory().setItem(slot, result.getLeft());
}
//ee list
@Subcommand("list")
@CommandPermission("epicenchants.list")
@Description("List all enchants with their effects")
@Subcommand("info")
@CommandPermission("epicenchants.info")
@Description("List all enchants with their description")
public void onList(Player player) {
instance.getEnchantManager().getEnchants().forEach(enchant ->
player.sendMessage(instance.getLocale().getMessageWithPrefix("command.list", enchant.getIdentifier(),
enchant.getEffectExecutors().stream().map(s -> s.getClass().getSimpleName()).collect(Collectors.joining(", ")))));
instance.getInfoManager().getMainInfoMenu().open(player);
}
//ee reload [enchantFileName]
@ -83,15 +84,23 @@ public class EnchantCommand extends BaseCommand {
@CommandAlias("load")
@Description("Reload all config files, or reload/load specific enchant files")
@CommandCompletion("@enchantFiles")
public void onReload(Player player, @Optional File fileName) {
public void onReload(CommandSender sender, @Optional File fileName) {
if (fileName == null) {
instance.reload();
player.sendMessage(instance.getLocale().getMessageWithPrefix("command.reload"));
sender.sendMessage(instance.getLocale().getMessageWithPrefix("command.reload"));
return;
}
instance.getFileManager().loadEnchant(fileName);
player.sendMessage(instance.getLocale().getMessageWithPrefix("command.filereload", fileName.getName()));
try {
instance.getEnchantManager().loadEnchant(fileName);
} catch (Exception e) {
sender.sendMessage(instance.getLocale().getMessageWithPrefix("command.filereload.failed", of("file-name", fileName.getName())));
Bukkit.getConsoleSender().sendMessage("Something went wrong loading the enchant from file " + fileName.getName());
Bukkit.getConsoleSender().sendMessage("Please check to make sure there are no errors in the file.");
e.printStackTrace();
return;
}
sender.sendMessage(instance.getLocale().getMessageWithPrefix("command.filereload.success", of("file-name", fileName.getName())));
}
}

View File

@ -5,7 +5,7 @@ import com.songoda.epicenchants.enums.EventType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import static com.songoda.epicenchants.utils.Chat.color;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
public class Message extends EffectExecutor {
public Message(ConfigurationSection section) {

View File

@ -30,7 +30,8 @@ public class Potion extends EffectExecutor {
if (this.getEffectType() == EffectType.STATIC_EFFECT || this.getEffectType() == EffectType.HELD_ITEM) {
if (eventType == EventType.ON) {
consume(player -> player.addPotionEffect(new PotionEffect(effectType, Integer.MAX_VALUE, ((int) amplifier.get(level, 0)))), wearer, opponent);
consume(player -> player.addPotionEffect(new PotionEffect(effectType, Integer.MAX_VALUE, ((int) amplifier.get(level, 0)),
false, false)), wearer, opponent);
} else if (eventType == EventType.OFF) {
consume(player -> player.removePotionEffect(effectType), wearer, opponent);
}
@ -44,7 +45,8 @@ public class Potion extends EffectExecutor {
return;
}
consume(player -> player.addPotionEffect(new PotionEffect(effectType, ((int) duration.get(level, Integer.MAX_VALUE)), ((int) amplifier.get(level, 0)))), wearer, opponent);
consume(player -> player.addPotionEffect(new PotionEffect(effectType, ((int) duration.get(level, Integer.MAX_VALUE)),
((int) amplifier.get(level, 0)), false, false)), wearer, opponent);
}
}

View File

@ -16,6 +16,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import static com.songoda.epicenchants.objects.Placeholder.of;
public class BookListener implements Listener {
private final EpicEnchants instance;
@ -39,7 +41,7 @@ public class BookListener implements Listener {
Enchant enchant = instance.getEnchantManager().getEnchant(nbtItem.getString("enchant")).orElseThrow(() -> new IllegalStateException("Book without enchant!"));
if (!enchant.getItemWhitelist().contains(toApplyTo.getType())) {
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.invalidmaterial", enchant.getIdentifier()));
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.invalidmaterial", of("enchant", enchant.getIdentifier())));
return;
}
@ -58,14 +60,14 @@ public class BookListener implements Listener {
switch (result.getRight()) {
case FAILURE:
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.failure", enchant.getIdentifier()));
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.failure", of("enchant", enchant.getIdentifier())));
break;
case BROKEN_FAILURE:
event.getCurrentItem().setType(Material.AIR);
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.brokenfailure", enchant.getIdentifier()));
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.brokenfailure", of("enchant", enchant.getIdentifier())));
break;
case SUCCESS:
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.success", enchant.getIdentifier()));
event.getWhoClicked().sendMessage(instance.getLocale().getMessageWithPrefix("enchant.success", of("enchant", enchant.getIdentifier())));
}
event.getWhoClicked().setItemOnCursor(null);

View File

@ -3,7 +3,7 @@ package com.songoda.epicenchants.listeners;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.enums.EffectType;
import org.bukkit.entity.Explosive;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
@ -12,9 +12,11 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.projectiles.ProjectileSource;
import static com.songoda.epicenchants.enums.EffectType.*;
import static com.songoda.epicenchants.utils.Constants.MONSTER_MAP;
import static org.bukkit.entity.EntityType.PLAYER;
import static org.bukkit.event.entity.EntityDamageEvent.DamageCause.*;
@ -27,7 +29,7 @@ public class EntityListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Mob && event.getEntity().getKiller() != null) {
if (event.getEntity() instanceof Monster && event.getEntity().getKiller() != null) {
instance.getEnchantUtils().handlePlayer(event.getEntity().getKiller(), event, KILLED_MOB);
}
}
@ -55,7 +57,7 @@ public class EntityListener implements Listener {
if (event.getDamager() instanceof Player) {
effectType = DEFENSE_PLAYER_MELEE;
} else if (event.getDamager() instanceof Mob) {
} else if (event.getDamager() instanceof Monster) {
effectType = DEFENSE_MOB_MELEE;
} else if (event.getDamager() instanceof Explosive) {
effectType = EXPLOSION_DAMAGE;
@ -72,7 +74,7 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof Player) {
effectType = ATTACK_PLAYER_MELEE;
} else if (event.getEntity() instanceof Mob) {
} else if (event.getEntity() instanceof Monster) {
effectType = ATTACK_MOB_MELEE;
}
@ -99,5 +101,11 @@ public class EntityListener implements Listener {
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) {
if (MONSTER_MAP.containsValue(event.getEntity().getUniqueId())) {
//TODO: Add team support.
event.setCancelled(true);
}
}
}

View File

@ -1,14 +1,24 @@
package com.songoda.epicenchants.managers;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.objects.Enchant;
import com.songoda.epicenchants.objects.Group;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.utils.ConfigParser.parseEnchant;
import static java.io.File.separator;
public class EnchantManager {
private final Map<String, Enchant> enchantMap;
private final EpicEnchants instance;
public EnchantManager() {
public EnchantManager(EpicEnchants instance) {
this.instance = instance;
this.enchantMap = new HashMap<>();
}
@ -20,12 +30,12 @@ public class EnchantManager {
enchantMap.put(enchant.getIdentifier(), enchant);
}
public Collection<Enchant> getEnchants(int tier) {
return Collections.unmodifiableCollection(enchantMap.values().stream().filter(s -> s.getTier() == tier).collect(Collectors.toList()));
public Collection<Enchant> getEnchants(Group group) {
return Collections.unmodifiableCollection(enchantMap.values().stream().filter(s -> s.getGroup().equals(group)).collect(Collectors.toList()));
}
public Optional<Enchant> getRandomEnchant(int tier) {
Collection<Enchant> tierList = getEnchants(tier);
public Optional<Enchant> getRandomEnchant(Group group) {
Collection<Enchant> tierList = getEnchants(group);
return tierList.stream().skip((int) (tierList.size() * Math.random())).findFirst();
}
@ -37,4 +47,26 @@ public class EnchantManager {
public Enchant getEnchantUnsafe(String identifier) {
return getEnchant(identifier).orElse(null);
}
public void loadEnchants() {
instance.getFileManager().getYmlFiles("enchants").ifPresent(list -> list.forEach(file -> {
try {
loadEnchant(file);
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("Something went wrong loading the enchant from file " + file.getName());
Bukkit.getConsoleSender().sendMessage("Please check to make sure there are no errors in the file.");
e.printStackTrace();
}
}));
}
public void loadEnchant(File file) throws Exception {
addEnchant(parseEnchant(instance, YamlConfiguration.loadConfiguration(file)));
}
public Optional<File> getEnchantFile(String path) {
File file = new File(instance.getDataFolder() + separator + "enchants" + separator + path);
return file.exists() ? Optional.of(file) : Optional.empty();
}
}

View File

@ -11,9 +11,9 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static com.songoda.epicenchants.utils.parser.ConfigParser.parseEnchant;
import static java.io.File.separator;
import static java.util.Arrays.asList;
import static org.apache.commons.lang3.tuple.Pair.of;
public class FileManager {
private final EpicEnchants instance;
@ -25,58 +25,49 @@ public class FileManager {
}
public void createFiles() {
File dir = new File(instance.getDataFolder() + separator + "enchants" + separator);
Set<String> recentDirs = new HashSet<>();
asList(of("menus/main-info-menu.yml", true),
of("menus/enchanter-menu.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/example-enchant.yml", false),
of("config.yml", true),
of("groups.yml", true)).forEach(pair -> {
File file = new File(instance.getDataFolder() + separator + pair.getLeft());
if (!dir.exists()) {
File def = new File(instance.getDataFolder() + separator + "enchants" + separator + "StrengthEnchant.yml");
try {
FileUtils.copyInputStreamToFile(instance.getResource("ExampleEnchant.yml"), def);
} catch (IOException e) {
e.printStackTrace();
}
}
for (String name : asList("config", "bookMenu")) {
File file = new File(instance.getDataFolder(), name + ".yml");
if (!file.exists()) {
if (!file.exists() && (pair.getRight() || (!file.getParent().equals(instance.getDataFolder().getPath())
&& (!file.getParentFile().exists() || recentDirs.contains(file.getParent()))))) {
file.getParentFile().mkdirs();
instance.saveResource(file.getName(), false);
recentDirs.add(file.getParent());
Bukkit.getConsoleSender().sendMessage("Creating file: " + pair.getLeft());
try {
FileUtils.copyInputStreamToFile(instance.getResource(pair.getLeft()), file);
} catch (IOException e) {
e.printStackTrace();
}
}
FileConfiguration configuration = new YamlConfiguration();
try {
configuration.load(file);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
configurationMap.put(name, configuration);
}
}
public void loadEnchants() {
getEnchantFiles().ifPresent(list -> list.forEach(this::loadEnchant));
if (pair.getRight()) {
FileConfiguration configuration = new YamlConfiguration();
try {
configuration.load(file);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
configurationMap.put(pair.getLeft().replace(".yml", ""), configuration);
}
});
}
public FileConfiguration getConfiguration(String key) {
return configurationMap.get(key);
}
public void loadEnchant(File file) {
try {
instance.getEnchantManager().addEnchant(parseEnchant(YamlConfiguration.loadConfiguration(file)));
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("Something went wrong loading the enchant from file " + file.getName());
Bukkit.getConsoleSender().sendMessage("Please check to make sure there are no errors in the file.");
e.printStackTrace();
}
}
public Optional<File> getEnchantFile(String path) {
File file = new File(instance.getDataFolder() + separator + "enchants" + separator + path);
return file.exists() ? Optional.of(file) : Optional.empty();
}
public Optional<List<File>> getEnchantFiles() {
File dir = new File(instance.getDataFolder() + separator + "enchants" + separator);
public Optional<List<File>> getYmlFiles(String directory) {
File dir = new File(instance.getDataFolder() + separator + directory + separator);
File[] files = dir.listFiles((dir1, filename) -> filename.endsWith(".yml"));
if (files != null)

View File

@ -0,0 +1,35 @@
package com.songoda.epicenchants.managers;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.objects.Group;
import com.songoda.epicenchants.utils.ConfigParser;
import org.bukkit.configuration.ConfigurationSection;
import java.util.*;
public class GroupManager {
private final Map<String, Group> groupMap;
private final EpicEnchants instance;
public GroupManager(EpicEnchants instance) {
this.instance = instance;
this.groupMap = new HashMap<>();
}
public Optional<Group> getGroup(String identifier) {
return Optional.ofNullable(groupMap.get(identifier));
}
public void addGroup(Group group) {
groupMap.put(group.getIdentifier(), group);
}
public void loadGroups() {
ConfigurationSection config = instance.getFileManager().getConfiguration("groups").getConfigurationSection("groups");
config.getKeys(false).forEach(key -> addGroup(ConfigParser.parseGroup(config.getConfigurationSection(key))));
}
public Collection<Group> getGroups() {
return Collections.unmodifiableCollection(groupMap.values());
}
}

View File

@ -0,0 +1,44 @@
package com.songoda.epicenchants.managers;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.menus.InfoMenu;
import com.songoda.epicenchants.menus.MainInfoMenu;
import com.songoda.epicenchants.objects.Group;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class InfoManager {
private final Map<Group, InfoMenu> infoMenus;
private final EpicEnchants instance;
@Getter private MainInfoMenu mainInfoMenu;
public InfoManager(EpicEnchants instance) {
this.instance = instance;
this.infoMenus = new HashMap<>();
}
public Optional<InfoMenu> getMenu(Group group) {
return Optional.ofNullable(infoMenus.get(group));
}
public void loadMenus() {
mainInfoMenu = new MainInfoMenu(instance, instance.getFileManager().getConfiguration("menus/main-info-menu"));
instance.getFileManager().getYmlFiles("menus/groups").ifPresent(list -> list.forEach(file -> {
try {
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
infoMenus.put(instance.getGroupManager().getGroup(config.getString("group"))
.orElseThrow(() -> new IllegalArgumentException("Invalid group: " + config.getString("group"))), new InfoMenu(instance, config));
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("Something went wrong loading the menu from file " + file.getName());
Bukkit.getConsoleSender().sendMessage("Please check to make sure there are no errors in the file.");
e.printStackTrace();
}
}));
}
}

View File

@ -2,17 +2,22 @@ package com.songoda.epicenchants.menus;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.objects.Enchant;
import com.songoda.epicenchants.objects.Group;
import com.songoda.epicenchants.utils.FastInv;
import com.songoda.epicenchants.utils.ItemBuilder;
import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
public class BookMenu extends FastInv {
public BookMenu(EpicEnchants instance, FileConfiguration config) {
super(config.getInt("rows") * 9);
import static com.songoda.epicenchants.objects.Placeholder.of;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
import static com.songoda.epicenchants.utils.GeneralUtils.getSlot;
public class EnchanterMenu extends FastInv {
public EnchanterMenu(EpicEnchants instance, FileConfiguration config, Player player) {
super(config.getInt("rows") * 9, color(config.getString("title")));
if (config.isConfigurationSection("fill")) {
fill(new ItemBuilder(config.getConfigurationSection("fill")).build());
@ -20,22 +25,28 @@ public class BookMenu extends FastInv {
config.getConfigurationSection("contents").getKeys(false)
.stream()
.filter(StringUtils::isNumeric)
.map(s -> "contents." + s)
.map(config::getConfigurationSection)
.forEach(section -> {
double expCost = section.getDouble("exp-cost");
double ecoCost = section.getDouble("eco-cost");
int tier = section.getInt("tier");
addItem(getSlot(section.getInt("row"), section.getInt("column")), new ItemBuilder(section).build(), event -> {
Player player = event.getPlayer();
double xpLeft = expCost - player.getLevel();
double ecoLeft = ecoCost - instance.getEconomy().getBalance(player);
Group group = instance.getGroupManager().getGroup(section.getString("group").toUpperCase())
.orElseThrow(() -> new IllegalArgumentException("Invalid group set in enchanter: " + section.getString("group")));
ItemStack itemStack = new ItemBuilder(section,
of("exp_cost", expCost),
of("eco_cost", ecoCost),
of("xp_left", xpLeft),
of("eco_left", ecoLeft)).build();
addItem(getSlot(section.getInt("row"), section.getInt("column")), itemStack, event -> {
if (!instance.getEconomy().has((player), ecoCost) || (player).getLevel() < expCost) {
player.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.purchase.cannotafford"));
return;
}
Optional<Enchant> enchant = instance.getEnchantManager().getRandomEnchant(tier);
Optional<Enchant> enchant = instance.getEnchantManager().getRandomEnchant(group);
if (!enchant.isPresent()) {
player.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.purchase.noenchant"));
@ -45,15 +56,9 @@ public class BookMenu extends FastInv {
instance.getEconomy().withdrawPlayer(player, ecoCost);
player.setLevel((int) (player.getLevel() - expCost));
player.getInventory().addItem(enchant.get().getBookItem().get(enchant.get()));
player.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.purchase.success", "" + tier));
player.sendMessage(instance.getLocale().getMessageWithPrefix("event.purchase.success", of("group_name", group.getName())));
});
});
}
private int getSlot(int row, int column) {
if (column > 9 || row < 1) {
return 0;
}
return (row - 1) * 9 + column - 1;
}
}

View File

@ -0,0 +1,48 @@
package com.songoda.epicenchants.menus;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.objects.Enchant;
import com.songoda.epicenchants.objects.Group;
import com.songoda.epicenchants.utils.FastInv;
import com.songoda.epicenchants.utils.ItemBuilder;
import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.Iterator;
import java.util.Set;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.objects.Placeholder.of;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
import static com.songoda.epicenchants.utils.GeneralUtils.getSlot;
import static java.util.Arrays.stream;
public class InfoMenu extends FastInv {
public InfoMenu(EpicEnchants instance, FileConfiguration config) {
super(config.getInt("size"), color(config.getString("title")));
Group group = instance.getGroupManager().getGroup(config.getString("group")).orElseThrow(() -> new IllegalArgumentException("Invalid group: " + config.getString("group")));
String[] split = config.getString("slots").split(",");
Set<Integer> slots = stream(split, 0, split.length)
.filter(StringUtils::isNumeric)
.map(Integer::parseInt)
.collect(Collectors.toSet());
Iterator<Enchant> enchantIterator = instance.getEnchantManager().getEnchants(group).iterator();
slots.stream().filter(slot -> enchantIterator.hasNext()).forEach(slot -> {
Enchant enchant = enchantIterator.next();
addItem(slot, new ItemBuilder(config.getConfigurationSection("enchant-item"),
of("group_color", enchant.getGroup().getColor()),
of("enchant", enchant.getIdentifier()),
of("description", enchant.getDescription())).build());
});
if (config.isConfigurationSection("contents"))
config.getConfigurationSection("contents").getKeys(false)
.stream()
.map(s -> "contents." + s)
.map(config::getConfigurationSection)
.forEach(section -> addItem(getSlot(section.getInt("row"), section.getInt("column")), new ItemBuilder(section).build()));
}
}

View File

@ -0,0 +1,29 @@
package com.songoda.epicenchants.menus;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.objects.Group;
import com.songoda.epicenchants.utils.FastInv;
import com.songoda.epicenchants.utils.GeneralUtils;
import com.songoda.epicenchants.utils.ItemBuilder;
import org.bukkit.configuration.file.FileConfiguration;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
public class MainInfoMenu extends FastInv {
public MainInfoMenu(EpicEnchants instance, FileConfiguration config) {
super(config.getInt("size"), color(config.getString("title")));
config.getConfigurationSection("contents").getKeys(false)
.stream()
.map(s -> "contents." + s)
.map(config::getConfigurationSection)
.forEach(section -> {
addItem(GeneralUtils.getSlot(section.getInt("row"), section.getInt("column")), new ItemBuilder(section).build(), event -> {
Group group = instance.getGroupManager().getGroup(section.getString("group"))
.orElseThrow(() -> new IllegalArgumentException("Invalid group: " + section.getString("group")));
instance.getInfoManager().getMenu(group).ifPresent(menu -> menu.open(event.getPlayer()));
});
});
}
}

View File

@ -0,0 +1,35 @@
package com.songoda.epicenchants.objects;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Condition {
private final String string;
private Condition(String string) {
this.string = string;
}
public static Condition of(String string) {
return new Condition(string);
}
public boolean get(Player player, int level, boolean def) {
if (string == null || string.isEmpty()) {
return true;
}
ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
try {
return Boolean.parseBoolean(scriptEngine.eval(string.replace("{level}", "" + level)).toString());
} catch (ScriptException | NumberFormatException e) {
Bukkit.getLogger().warning("[EpicEnchants] One of your condition expressions is not properly formatted.");
return def;
}
}
}

View File

@ -6,10 +6,10 @@ import com.songoda.epicenchants.enums.EventType;
import com.songoda.epicenchants.wrappers.MobWrapper;
import lombok.Builder;
import lombok.Getter;
import lombok.Singular;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@ -17,18 +17,27 @@ import java.util.Set;
@Getter
public class Enchant {
private String identifier;
private int tier;
private Group group;
private int maxLevel;
@Singular("conflict") private Set<String> conflict;
@Singular("whiteItem") private Set<Material> itemWhitelist;
@Singular("effect") private Set<EffectExecutor> effectExecutors;
@Singular("mob") private Set<MobWrapper> mobs;
private String format;
private BookItem bookItem;
private Set<String> conflict;
private Set<Material> itemWhitelist;
private Set<EffectExecutor> effectExecutors;
private Set<MobWrapper> mobs;
private Set<String> description;
@Nullable private String format;
@Nullable private BookItem bookItem;
private LeveledModifier modifyDamage;
public void onAction(Player wearer, Player attacker, Event event, int level, EffectType effectType, EventType eventType) {
effectExecutors.forEach(effect -> effect.testAndRun(wearer, attacker, level, effectType, event, eventType));
mobs.forEach(mobWrapper -> mobWrapper.trySpawn(wearer, attacker, level, effectType));
}
public BookItem getBookItem() {
return bookItem != null ? bookItem : group.getBookItem();
}
public String getFormat() {
return format != null ? format : group.getFormat();
}
}

View File

@ -0,0 +1,15 @@
package com.songoda.epicenchants.objects;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder
public class Group {
private String identifier;
private String name;
private String format;
private String color;
private int slotsUsed;
private BookItem bookItem;
}

View File

@ -0,0 +1,18 @@
package com.songoda.epicenchants.objects;
import lombok.Getter;
@Getter
public class Placeholder {
private String placeholder;
private Object toReplace;
private Placeholder(String placeholder, Object toReplace) {
this.placeholder = "\\{" + placeholder + "\\}";
this.toReplace = toReplace;
}
public static Placeholder of(String placeholder, Object toReplace) {
return new Placeholder(placeholder, toReplace);
}
}

View File

@ -1,13 +0,0 @@
package com.songoda.epicenchants.utils;
import org.bukkit.ChatColor;
public class Chat {
public static String color(String input) {
return format(input, "", null);
}
public static String format(String input, String placeholder, Object toReplace) {
return ChatColor.translateAlternateColorCodes('&', input).replaceAll(placeholder, toReplace == null ? "" : toReplace.toString());
}
}

View File

@ -1,12 +1,12 @@
package com.songoda.epicenchants.utils.parser;
package com.songoda.epicenchants.utils;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.effect.EffectManager;
import com.songoda.epicenchants.enums.EffectType;
import com.songoda.epicenchants.objects.BookItem;
import com.songoda.epicenchants.objects.Enchant;
import com.songoda.epicenchants.objects.Group;
import com.songoda.epicenchants.objects.LeveledModifier;
import com.songoda.epicenchants.utils.Chat;
import com.songoda.epicenchants.utils.ItemBuilder;
import com.songoda.epicenchants.wrappers.EnchantmentWrapper;
import com.songoda.epicenchants.wrappers.MobWrapper;
import org.bukkit.Material;
@ -20,18 +20,18 @@ import java.util.HashSet;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.utils.Chat.color;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
public class ConfigParser {
public static Enchant parseEnchant(FileConfiguration config) {
public static Enchant parseEnchant(EpicEnchants instance, FileConfiguration config) {
return Enchant.builder()
.identifier(config.getString("identifier"))
.tier(config.getInt("tier"))
.group(instance.getGroupManager().getGroup(config.getString("group").toUpperCase()).orElseThrow(() -> new IllegalArgumentException("Invalid group: " + config.getString("group"))))
.maxLevel(config.getInt("max-level"))
.format(color(config.getString("applied-format")))
.bookItem(parseBookItem(config.getConfigurationSection("book-item")))
.itemWhitelist(config.getStringList("item-whitelist").stream().map(Material::valueOf).collect(Collectors.toSet()))
.conflict(new HashSet<>(config.getStringList("conflicting-enchants")))
.itemWhitelist((config.isList("item-whitelist") ? config.getStringList("item-whitelist").stream().map(Material::valueOf).collect(Collectors.toSet()) : Collections.emptySet()))
.conflict(config.isList("conflicting-enchants") ? new HashSet<>(config.getStringList("conflicting-enchants")) : Collections.emptySet())
.mobs(config.isConfigurationSection("mobs") ? config.getConfigurationSection("mobs").getKeys(false).stream()
.map(s -> "mobs." + s)
.map(config::getConfigurationSection)
@ -43,6 +43,7 @@ public class ConfigParser {
.map(o -> o.orElse(null))
.filter(Objects::nonNull)
.collect(Collectors.toSet()) : Collections.emptySet())
.description(config.isList("description") ? new HashSet<>(config.getStringList("description")) : Collections.emptySet())
.build();
}
@ -72,11 +73,22 @@ public class ConfigParser {
.build();
}
public static BookItem parseBookItem(ConfigurationSection section) {
private static BookItem parseBookItem(ConfigurationSection section) {
return section != null ? BookItem.builder()
.material(Material.valueOf(section.getString("material")))
.displayName(color(section.getString("display-name")))
.lore(section.getStringList("lore").stream().map(Chat::color).collect(Collectors.toList()))
.lore(section.getStringList("lore").stream().map(GeneralUtils::color).collect(Collectors.toList()))
.build() : null;
}
public static Group parseGroup(ConfigurationSection section) {
return section != null ? Group.builder()
.identifier(section.getName())
.name(color(section.getString("group-name")))
.format(section.getString("group-format"))
.color(section.getString("group-color"))
.bookItem(parseBookItem(section.getConfigurationSection("book-item")))
.slotsUsed(section.getInt("slots-used"))
.build() : null;
}
}

View File

@ -0,0 +1,10 @@
package com.songoda.epicenchants.utils;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import java.util.UUID;
public interface Constants {
Multimap<UUID, UUID> MONSTER_MAP = HashMultimap.create();
}

View File

@ -1,5 +1,7 @@
package com.songoda.epicenchants.utils;
import org.bukkit.ChatColor;
import java.util.concurrent.ThreadLocalRandom;
public class GeneralUtils {
@ -10,4 +12,19 @@ public class GeneralUtils {
public static boolean chance(double chance) {
return ThreadLocalRandom.current().nextDouble(101) < chance;
}
public static String color(String input) {
return format(input, "", null);
}
public static String format(String input, String placeholder, Object toReplace) {
return ChatColor.translateAlternateColorCodes('&', input).replaceAll(placeholder, toReplace == null ? "" : toReplace.toString());
}
public static int getSlot(int row, int column) {
if (column > 9 || row < 1) {
return 0;
}
return (row - 1) * 9 + column - 1;
}
}

View File

@ -1,6 +1,6 @@
package com.songoda.epicenchants.utils;
import com.songoda.epicenchants.utils.parser.ConfigParser;
import com.songoda.epicenchants.objects.Placeholder;
import com.songoda.epicenchants.wrappers.EnchantmentWrapper;
import de.tr7zw.itemnbtapi.NBTItem;
import org.bukkit.Material;
@ -14,6 +14,8 @@ import org.bukkit.inventory.meta.SkullMeta;
import java.util.*;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.utils.GeneralUtils.color;
public class ItemBuilder {
private final ItemStack item;
@ -39,7 +41,7 @@ public class ItemBuilder {
this(new ItemStack(material, amount, data));
}
public ItemBuilder(ConfigurationSection section) {
public ItemBuilder(ConfigurationSection section, Placeholder... placeholders) {
this(Material.valueOf(section.getString("material")), (byte) (section.contains("data") ? section.getInt("data") : 0));
if (section.contains("enchants")) {
@ -49,11 +51,31 @@ public class ItemBuilder {
}
if (section.contains("display-name")) {
name(Chat.color(section.getString("display-name")));
String displayName = section.getString("display-name");
for (Placeholder placeholder : placeholders) {
displayName = displayName.replaceAll(placeholder.getPlaceholder(), placeholder.getToReplace().toString());
}
name(color(displayName));
}
if (section.contains("lore")) {
lore(section.getStringList("lore").stream().map(Chat::color).collect(Collectors.toList()));
List<String> lore = section.getStringList("lore");
for (int i = 0; i < lore.size(); i++) {
String string = lore.get(i);
for (Placeholder placeholder : placeholders) {
if (placeholder.getToReplace() instanceof HashSet && string.contains(placeholder.getPlaceholder())) {
lore.remove(i);
Set<String> stringSet = (Set<String>) placeholder.getToReplace();
stringSet.forEach(System.out::println);
lore.addAll(i, stringSet);
} else {
lore.set(i, string.replaceAll(placeholder.getPlaceholder(), placeholder.getToReplace().toString()));
}
}
}
lore(lore.stream().map(GeneralUtils::color).collect(Collectors.toList()));
}
}
@ -116,7 +138,7 @@ public class ItemBuilder {
}
public ItemBuilder removeLore(String string) {
if(!meta.hasLore()) {
if (!meta.hasLore()) {
return this;
}

View File

@ -13,6 +13,7 @@ import org.bukkit.Location;
import org.bukkit.entity.*;
import org.jetbrains.annotations.NotNull;
import static com.songoda.epicenchants.utils.Constants.MONSTER_MAP;
import static java.util.concurrent.ThreadLocalRandom.current;
@Builder
@ -87,6 +88,8 @@ public class MobWrapper {
lc.setDouble("Base", health.get(level, (int) lc.getDouble("Base")));
}
}
MONSTER_MAP.put(player.getUniqueId(), entity.getUniqueId());
}
}
}

View File

@ -1,19 +0,0 @@
title: "Books"
rows: 1
#You can choose to fill the entire inventory witht this material
#fill:
# material: "MATERIAL_HERE"
# display-name: "&r"
# data: 7
contents:
1:
material: "PAPER"
display-name: "&cClick to purchase random book"
data: 7
tier: 1
exp-cost: 20
eco-cost: 2000
row: 1
column: 5

View File

@ -4,18 +4,18 @@ general.nametag.prefix= "&8[&6EpicEnchants&8]"
#Command Messages
command.book.give= "&7You have been given a &6tier {tier} &7Book."
command.book.gave= "&7You gave {player} a &6tier {tier} &7Book."
command.list= "&6{enchant} &7- {effects}"
command.book.give= "&7You have been given a &6{group-name} &7book."
command.book.gave= "&7You gave {player} a &6{group-name} &7book."
command.reload= "&6Configuration files reload"
command.filereload= "&6{file} has been reloaded&7, please check console for potential errors."
command.filereload.success= "&6{file-name} has been successfully reloaded."
command.filereload.failed= "&c{file-name} failed to be reloaded. &7Please check console for errors."
#Event Messages
event.general.nopermission= "&cYou do not have permission to do that."
event.purchase.noenchant= "&cThere is no enchant available for &6tier {tier}&7."
event.purchase.noenchant= "&cThere is no enchant available for &6{group-name}&7."
event.purchase.cannotafford= "&cYou cannot afford this purchase."
event.purchase.success= "&7You successfully purchased a &6tier {tier} &7Book."
event.purchase.success= "&7You successfully purchased a &6{group-name} &7Book."
#Enchant Messages
enchant.invalidmaterial= "&cYou can not apply &6{enchant} to that item."

View File

@ -1,11 +1,11 @@
#The enchant identifier must be unique
identifier: ExampleEnchant
#The max tier for this enchant
#The max group for this enchant
max-level: 4
#The tier of this enchant
tier: 1
#The group of this enchant
group: SIMPLE
#The book item
book-item:

View File

@ -0,0 +1,61 @@
groups:
SIMPLE:
group-color: "&7"
group-name: "Simple"
group-format: "{group_color} {enchant} {level}"
slots-used: 1
book-item:
material: BOOK
display-name: "&7{enchant} {level}"
lore:
- "&7Drag on to item to enchant"
- "&7Destroy Rate &c{destroy_rate}"
- "&7Success Rate &a{success_rate}"
UNIQUE:
group-color: "&a"
group-name: "Unique"
group-format: "{group_color} {enchant} {level}"
slots-used: 1
book-item:
material: BOOK
display-name: "{group_color}{enchant} {level}"
lore:
- "&7Drag on to item to enchant"
- "&7Destroy Rate &c{destroy_rate}"
- "&7Success Rate &a{success_rate}"
ELITE:
group-color: "&b"
group-name: "Elite"
group-format: "{group_color} {enchant} {level}"
slots-used: 1
book-item:
material: BOOK
display-name: "{group_color} {enchant} {level}"
lore:
- "&7Drag on to item to enchant"
- "&7Destroy Rate &c{destroy_rate}"
- "&7Success Rate &a{success_rate}"
ULTIMATE:
group-color: "&e"
group-name: "Ultimate"
group-format: "{group_color} {enchant} {level}"
slots-used: 2
book-item:
material: BOOK
display-name: "{group_color} {enchant} {level}"
lore:
- "&7Drag on to item to enchant"
- "&cDestroy Rate {destroy_rate}"
- "&aSuccess Rate {success_rate}"
LEGENDARY:
group-color: "&6"
group-name: "Legendary"
group-format: "{group_color} {enchant} {level}"
slots-used: 1
book-item:
material: BOOK
display-name: "{group_color} {enchant} {level}"
lore:
- "&7Drag on to item to enchant"
- "&cDestroy Rate {destroy_rate}"
- "&aSuccess Rate {success_rate}"

View File

@ -0,0 +1,25 @@
title: "Enchanter"
rows: 1
#You can choose to fill the entire inventory witht this material
#fill:
# material: "MATERIAL_HERE"
# display-name: "&r"
# data: 7
contents:
1:
material: "PAPER"
display-name: "&f&lSimple Enchantment &7(Right Click)"
lore:
- "&7Examine to receive a random"
- "&fSimple &7enchantment book."
- ""
- "&b&lCOST&8:"
- "&f{exp_cost} EXP &7(You need {exp_left} more EXP)"
- "&f{eco_cost} $ &7(You need {eco_left} more $)"
group: SIMPLE
exp-cost: 20
eco-cost: 2000
row: 1
column: 5

View File

@ -0,0 +1,15 @@
title: "Elite enchants"
size: 9
#Slots that you want enchants to be displayed on
slots: "4,5,6"
#The group of the enchants to be displayed
group: ELITE
enchant-item:
material: "PAPER"
display-name: "{group_color} {enchant}"
lore:
- "&7Description:"
- "{description}"

View File

@ -0,0 +1,15 @@
title: "Legendary enchants"
size: 9
#Slots that you want enchants to be displayed on
slots: "4,5,6"
#The group of the enchants to be displayed
group: LEGENDARY
enchant-item:
material: "PAPER"
display-name: "{group_color} {enchant}"
lore:
- "&7Description:"
- "{description}"

View File

@ -0,0 +1,15 @@
title: "Simple enchants"
size: 9
#Slots that you want enchants to be displayed on
slots: "4,5,6"
#The group of the enchants to be displayed
group: SIMPLE
enchant-item:
material: "PAPER"
display-name: "{group_color} {enchant}"
lore:
- "&7Description:"
- "{description}"

View File

@ -0,0 +1,15 @@
title: "Ultimate enchants"
size: 9
#Slots that you want enchants to be displayed on
slots: "4,5,6"
#The group of the enchants to be displayed
group: ULTIMATE
enchant-item:
material: "PAPER"
display-name: "{group_color} {enchant}"
lore:
- "&7Description:"
- "{description}"

View File

@ -0,0 +1,15 @@
title: "Unique enchants"
size: 9
#Slots that you want enchants to be displayed on
slots: "4,5,6"
#The group of the enchants to be displayed
group: UNIQUE
enchant-item:
material: "PAPER"
display-name: "{group_color} {enchant}"
lore:
- "&7Description:"
- "{description}"

View File

@ -0,0 +1,34 @@
title: "Main info menu"
size: 9
contents:
1:
material: "PAPER"
display-name: "&f&lSimple Enchantments"
group: SIMPLE
row: 1
column: 1
2:
material: "PAPER"
display-name: "&a&lUnique Enchantments"
group: UNIQUE
row: 1
column: 2
3:
material: "PAPER"
display-name: "&b&lElite Enchantments"
group: ELITE
row: 1
column: 3
4:
material: "PAPER"
display-name: "&e&lUltimate Enchantments"
group: ULTIMATE
row: 1
column: 4
5:
material: "PAPER"
display-name: "&6&lLegendary Enchantments"
group: LEGENDARY
row: 1
column: 5