mirror of
https://github.com/songoda/EpicEnchants.git
synced 2024-11-14 22:56:20 +01:00
Bug fixes
This commit is contained in:
parent
926b572c8c
commit
79ed22a755
@ -47,11 +47,9 @@ public class EpicEnchants extends JavaPlugin {
|
||||
getConsoleSender().sendMessage(color("&7" + getDescription().getName() + " " + getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
getConsoleSender().sendMessage(color("&7Action: &aEnabling&7..."));
|
||||
|
||||
FastInv.init(this);
|
||||
preload();
|
||||
|
||||
this.version = Integer.parseInt(Bukkit.getServer().getBukkitVersion().split("\\.")[1]);
|
||||
this.action = new Action();
|
||||
this.fileManager = new FileManager(this);
|
||||
this.groupManager = new GroupManager(this);
|
||||
this.enchantManager = new EnchantManager(this);
|
||||
this.enchantUtils = new EnchantUtils(this);
|
||||
@ -62,7 +60,6 @@ public class EpicEnchants extends JavaPlugin {
|
||||
this.hookManager = new HookManager();
|
||||
this.itemGroup = new ItemGroup(this);
|
||||
|
||||
fileManager.loadFiles();
|
||||
groupManager.loadGroups();
|
||||
enchantManager.loadEnchants();
|
||||
infoManager.loadMenus();
|
||||
@ -78,6 +75,13 @@ public class EpicEnchants extends JavaPlugin {
|
||||
getConsoleSender().sendMessage(color("&a============================="));
|
||||
}
|
||||
|
||||
private void preload() {
|
||||
FastInv.init(this);
|
||||
this.version = Integer.parseInt(Bukkit.getServer().getBukkitVersion().split("\\.")[1]);
|
||||
this.fileManager = new FileManager(this);
|
||||
fileManager.loadFiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getConsoleSender().sendMessage(color("&a============================="));
|
||||
@ -101,10 +105,19 @@ public class EpicEnchants extends JavaPlugin {
|
||||
|
||||
public void reload() {
|
||||
reloadConfig();
|
||||
|
||||
fileManager.clear();
|
||||
fileManager.loadFiles();
|
||||
enchantManager.loadEnchants();
|
||||
|
||||
groupManager.clear();
|
||||
groupManager.loadGroups();
|
||||
|
||||
enchantManager.clear();
|
||||
enchantManager.loadEnchants();
|
||||
|
||||
infoManager.clear();
|
||||
infoManager.loadMenus();
|
||||
|
||||
action.load(fileManager.getConfiguration("actions"));
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class EnchantCommand extends BaseCommand {
|
||||
@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));
|
||||
target.getInventory().addItem(instance.getSpecialItems().getDust(group, dustType, percentage, true));
|
||||
instance.getAction().perform(target, "command.dust.received", of("group", group.getIdentifier()));
|
||||
instance.getAction().perform(sender, "command.dust.gave", of("player", target.getName()), of("group", group.getIdentifier()));
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.CaseFormat.*;
|
||||
|
||||
public class EffectManager {
|
||||
|
||||
|
@ -78,6 +78,7 @@ public class BookListener extends ItemListener {
|
||||
}
|
||||
|
||||
Group group = instance.getGroupManager().getValueUnsafe(clicked.getString("group"));
|
||||
|
||||
Optional<Enchant> enchant = instance.getEnchantManager().getRandomEnchant(group);
|
||||
|
||||
if (!enchant.isPresent()) {
|
||||
|
@ -60,6 +60,6 @@ public class DustListener extends ItemListener {
|
||||
int rate = ThreadLocalRandom.current().nextInt(clicked.getInteger("min-rate"), clicked.getInteger("max-rate"));
|
||||
|
||||
useItem(event);
|
||||
event.getPlayer().getInventory().addItem(instance.getSpecialItems().getDust(group, null, rate));
|
||||
event.getPlayer().getInventory().addItem(instance.getSpecialItems().getDust(group, null, rate, false));
|
||||
}
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ public class CommandManager extends BukkitCommandManager {
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new InvalidCommandArgument("No item by that type.", false)));
|
||||
|
||||
getCommandContexts().registerContext(Group.class, c -> instance.getGroupManager().getValue(c.popFirstArg()).orElseThrow(() ->
|
||||
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.getConfig().getString("commands.enchanter"),
|
||||
"alchemist", instance.getConfig().getString("commands.alchemist"),
|
||||
"tinkerer", instance.getConfig().getString("commands.tinkerer")
|
||||
"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
|
||||
|
@ -20,6 +20,7 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
|
||||
private final String directory;
|
||||
private final LinkedHashSet<Pair<String, Boolean>> files = new LinkedHashSet<>(asList(
|
||||
of("config.yml", true),
|
||||
of("menus/main-info-menu.yml", true),
|
||||
of("menus/enchanter-menu.yml", true),
|
||||
of("menus/tinkerer-menu.yml", true),
|
||||
@ -29,7 +30,6 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
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),
|
||||
of("actions.yml", true),
|
||||
of("items/special-items.yml", true),
|
||||
@ -45,15 +45,13 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
}
|
||||
|
||||
public void loadFiles() {
|
||||
Set<String> recentDirs = new HashSet<>();
|
||||
files.forEach(pair -> {
|
||||
File file = new File(instance.getDataFolder() + separator + pair.getLeft());
|
||||
|
||||
if (!file.exists() && (pair.getRight() || (!file.getParent().equals(instance.getDataFolder().getPath())
|
||||
&& (!file.getParentFile().exists() || recentDirs.contains(file.getParent()))))) {
|
||||
if (!file.exists() && (pair.getRight() || getConfiguration("config").getBoolean("first-load"))) {
|
||||
file.getParentFile().mkdirs();
|
||||
recentDirs.add(file.getParent());
|
||||
Bukkit.getConsoleSender().sendMessage("Creating file: " + pair.getLeft());
|
||||
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(instance.getResource(directory + "/" + pair.getLeft()), file);
|
||||
} catch (IOException e) {
|
||||
@ -71,6 +69,13 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
add(pair.getLeft().replace(".yml", ""), configuration);
|
||||
}
|
||||
});
|
||||
|
||||
getConfiguration("config").set("first-load", false);
|
||||
try {
|
||||
getConfiguration("config").save(new File(instance.getDataFolder() + separator + "config.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getConfiguration(String key) {
|
||||
@ -94,6 +99,7 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
.filter(File::isDirectory)
|
||||
.filter(s -> !s.getName().equalsIgnoreCase("old"))
|
||||
.forEach(f -> output.addAll(getYmlFiles(directory + separator + f.getName())));
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public class GroupManager extends Manager<String, Group> {
|
||||
public void loadGroups() {
|
||||
ConfigurationSection config = instance.getFileManager().getConfiguration("groups").getConfigurationSection("groups");
|
||||
config.getKeys(false).forEach(key -> {
|
||||
Group group = ConfigParser.parseGroup(config.getConfigurationSection(key));
|
||||
add(group.getIdentifier(), group);
|
||||
Group group = ConfigParser.parseGroup(instance, config.getConfigurationSection(key));
|
||||
add(group.getIdentifier().toUpperCase(), group);
|
||||
});
|
||||
}
|
||||
}
|
@ -8,22 +8,19 @@ 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;
|
||||
public class InfoManager extends Manager<Group, InfoMenu> {
|
||||
private final EpicEnchants instance;
|
||||
@Getter private MainInfoMenu mainInfoMenu;
|
||||
|
||||
public InfoManager(EpicEnchants instance) {
|
||||
super(instance);
|
||||
this.instance = instance;
|
||||
this.infoMenus = new HashMap<>();
|
||||
}
|
||||
|
||||
public Optional<InfoMenu> getMenu(Group group) {
|
||||
return Optional.ofNullable(infoMenus.get(group));
|
||||
return getValue(group);
|
||||
}
|
||||
|
||||
public void loadMenus() {
|
||||
@ -31,7 +28,7 @@ public class InfoManager {
|
||||
instance.getFileManager().getYmlFiles("menus/groups").forEach(file -> {
|
||||
try {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
infoMenus.put(instance.getGroupManager().getValue(config.getString("group"))
|
||||
add(instance.getGroupManager().getValue(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());
|
||||
|
@ -30,4 +30,8 @@ public abstract class Manager<K, V> {
|
||||
return Collections.unmodifiableCollection(map.values());
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -35,6 +36,8 @@ public class TinkererMenu extends FastInv {
|
||||
this.instance = instance;
|
||||
this.config = config;
|
||||
|
||||
AtomicBoolean accepted = new AtomicBoolean(false);
|
||||
|
||||
if (config.isConfigurationSection("fill")) {
|
||||
fill(new ItemBuilder(config.getConfigurationSection("fill")).build());
|
||||
}
|
||||
@ -50,6 +53,7 @@ public class TinkererMenu extends FastInv {
|
||||
slotMap.keySet().forEach(slot -> getInventory().clear(slot));
|
||||
event.getPlayer().closeInventory();
|
||||
instance.getAction().perform(event.getPlayer(), "tinkerer.accepted");
|
||||
accepted.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -141,12 +145,15 @@ public class TinkererMenu extends FastInv {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Player closed inventory
|
||||
onClose(event -> {
|
||||
slotMap.keySet().stream().filter(s -> getInventory().getItem(s) != null).forEach(s -> {
|
||||
event.getPlayer().getInventory().addItem(getInventory().getItem(s));
|
||||
});
|
||||
|
||||
instance.getAction().perform(event.getPlayer(), "tinkerer.cancelled");
|
||||
if (!accepted.get())
|
||||
instance.getAction().perform(event.getPlayer(), "tinkerer.cancelled");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
package com.songoda.epicenchants.objects;
|
||||
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import com.songoda.epicenchants.utils.single.GeneralUtils;
|
||||
import com.songoda.epicenchants.utils.single.ItemGroup;
|
||||
import com.songoda.epicenchants.utils.single.RomanNumber;
|
||||
import de.tr7zw.itemnbtapi.NBTItem;
|
||||
import lombok.Builder;
|
||||
import org.bukkit.Material;
|
||||
@ -10,10 +14,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.epicenchants.utils.single.GeneralUtils.color;
|
||||
import static java.util.concurrent.ThreadLocalRandom.current;
|
||||
|
||||
@Builder
|
||||
public class BookItem {
|
||||
private EpicEnchants instance;
|
||||
private Material material;
|
||||
private String displayName;
|
||||
private List<String> lore;
|
||||
@ -35,14 +41,34 @@ public class BookItem {
|
||||
|
||||
int finalSuccessRate = successRate;
|
||||
int finalDestroyRate = destroyRate;
|
||||
int finalLevel = level;
|
||||
|
||||
List<String> toSet = lore;
|
||||
|
||||
for (int i = lore.size() - 1; i >= 0; i--) {
|
||||
String string = toSet.get(i);
|
||||
|
||||
if (string.contains("{description}")) {
|
||||
lore.remove(i);
|
||||
lore.addAll(i, enchant.getDescription().stream().map(GeneralUtils::color).collect(Collectors.toList()));
|
||||
continue;
|
||||
}
|
||||
|
||||
string = string
|
||||
.replace("{item_group}", "" + instance.getItemGroup().getGroup(enchant.getItemWhitelist()).map(ItemGroup.Group::getName).orElse("N/A"))
|
||||
.replace("{success_rate}", "" + finalSuccessRate)
|
||||
.replace("{destroy_rate}", "" + finalDestroyRate);
|
||||
|
||||
lore.set(i, string);
|
||||
}
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder(material)
|
||||
.name(displayName.replace("{level}", "" + level))
|
||||
.lore(lore.stream()
|
||||
.map(s -> s.replace("{level}", "" + finalLevel)
|
||||
.replace("{success_rate}", "" + finalSuccessRate)
|
||||
.replace("{destroy_rate}", "" + finalDestroyRate))
|
||||
.collect(Collectors.toList()));
|
||||
.name(color(displayName
|
||||
.replace("{level}", "" + (instance.getFileManager().getConfiguration("config").getBoolean("roman-numbers") ? RomanNumber.toRoman(level) : level))
|
||||
.replace("{enchant}", "" + enchant.getIdentifier())
|
||||
.replace("{group_color}", enchant.getGroup().getColor())
|
||||
.replace("{group_name}", enchant.getGroup().getName())
|
||||
))
|
||||
.lore(toSet);
|
||||
|
||||
NBTItem nbtItem = itemBuilder.nbt();
|
||||
nbtItem.setBoolean("book-item", true);
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epicenchants.objects;
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import com.songoda.epicenchants.enums.EventType;
|
||||
import com.songoda.epicenchants.enums.TriggerType;
|
||||
import com.songoda.epicenchants.utils.single.RomanNumber;
|
||||
import com.songoda.epicenchants.wrappers.MobWrapper;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@ -13,8 +14,11 @@ import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.songoda.epicenchants.utils.single.GeneralUtils.color;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class Enchant {
|
||||
@ -25,8 +29,8 @@ public class Enchant {
|
||||
private Set<Material> itemWhitelist;
|
||||
private Set<EffectExecutor> effectExecutors;
|
||||
private Set<MobWrapper> mobs;
|
||||
private Set<String> description;
|
||||
@Nullable private String format;
|
||||
private List<String> description;
|
||||
private String format;
|
||||
@Nullable private BookItem bookItem;
|
||||
private Condition condition;
|
||||
|
||||
@ -43,7 +47,14 @@ public class Enchant {
|
||||
return bookItem != null ? bookItem : group.getBookItem();
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format != null ? format : group.getFormat();
|
||||
public String getFormat(int level, boolean roman) {
|
||||
String output = format.isEmpty() ? group.getFormat() : format;
|
||||
|
||||
output = output
|
||||
.replace("{level}", "" + (roman ? RomanNumber.toRoman(level) : level))
|
||||
.replace("{enchant}", "" + identifier)
|
||||
.replace("{group_color}", "" + group.getColor());
|
||||
|
||||
return color(output);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.epicenchants.enums.TriggerType;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import com.songoda.epicenchants.utils.single.GeneralUtils;
|
||||
import com.songoda.epicenchants.utils.single.RomanNumber;
|
||||
import de.tr7zw.itemnbtapi.NBTCompound;
|
||||
import de.tr7zw.itemnbtapi.NBTItem;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@ -72,7 +71,7 @@ public class EnchantUtils {
|
||||
}
|
||||
|
||||
itemBuilder.removeLore(enchant.getFormat().replace("{level}", "").trim());
|
||||
itemBuilder.addLore(enchant.getFormat().replace("{level}", "" + (instance.getConfig().getBoolean("roman-numbers") ? RomanNumber.toRoman(level) : level)));
|
||||
itemBuilder.addLore(enchant.getFormat(level, instance.getFileManager().getConfiguration("config").getBoolean("roman-numbers")));
|
||||
|
||||
if (hasProtection) {
|
||||
itemBuilder.addLore(instance.getSpecialItems().getWhiteScrollLore());
|
||||
|
@ -34,7 +34,7 @@ public class SpecialItems {
|
||||
}
|
||||
|
||||
public ItemStack getBlackScroll(Integer amount, Integer chance) {
|
||||
int successRate = chance == null ? ThreadLocalRandom.current().nextInt(instance.getConfig().getInt("rates.black-scroll-min"), instance.getConfig().getInt("rates.black-scroll-max") + 1) : chance;
|
||||
int successRate = chance == null ? ThreadLocalRandom.current().nextInt(instance.getFileManager().getConfiguration("config").getInt("rates.black-scroll-min"), instance.getFileManager().getConfiguration("config").getInt("rates.black-scroll-max") + 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);
|
||||
@ -74,12 +74,12 @@ public class SpecialItems {
|
||||
|
||||
nbtItem.setBoolean("secret-dust", true);
|
||||
nbtItem.setString("group", group.getIdentifier());
|
||||
nbtItem.setInteger("max-rate", max);
|
||||
nbtItem.setInteger("max-rate", max + 1);
|
||||
nbtItem.setInteger("min-rate", 1);
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public ItemStack getDust(Group group, @Nullable String type, @Nullable Integer percentage) {
|
||||
public ItemStack getDust(Group group, @Nullable String type, @Nullable Integer percentage, boolean command) {
|
||||
FileConfiguration dustConfig = instance.getFileManager().getConfiguration("items/dusts");
|
||||
int random = ThreadLocalRandom.current().nextInt(101);
|
||||
int counter = 0;
|
||||
@ -94,9 +94,11 @@ public class SpecialItems {
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationSection config = dustConfig.getConfigurationSection("dusts." + (type == null ? "mystery" : type));
|
||||
type = type == null ? "mystery" : type;
|
||||
|
||||
if (config.isInt("min-rate") && config.isInt("max-rate") && percentage == null) {
|
||||
ConfigurationSection config = dustConfig.getConfigurationSection("dusts." + type);
|
||||
|
||||
if (!command && config.isInt("min-rate") && config.isInt("max-rate")) {
|
||||
int minRate = config.getInt("min-rate");
|
||||
int maxRate = config.getInt("max-rate");
|
||||
percentage = ThreadLocalRandom.current().nextInt(minRate, maxRate + 1);
|
||||
@ -109,7 +111,7 @@ public class SpecialItems {
|
||||
of("group-name", group.getName()),
|
||||
of("percentage", percentage)).nbt();
|
||||
|
||||
if (type != null && type.equalsIgnoreCase("mystery")) {
|
||||
if (type.equalsIgnoreCase("mystery")) {
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ import java.util.stream.Collectors;
|
||||
import static com.songoda.epicenchants.utils.single.GeneralUtils.color;
|
||||
|
||||
public class ConfigParser {
|
||||
public static Enchant parseEnchant(EpicEnchants instance, FileConfiguration config) {
|
||||
public static Enchant parseEnchant(EpicEnchants instance, FileConfiguration config) throws Exception {
|
||||
return Enchant.builder()
|
||||
.identifier(config.getString("identifier"))
|
||||
.group(instance.getGroupManager().getValue(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")))
|
||||
.format(config.isSet("appliead-format") ? color(config.getString("applied-format")) : "")
|
||||
.bookItem(parseBookItem(instance, config.getConfigurationSection("book-item")))
|
||||
.itemWhitelist((config.isList("item-whitelist") ? config.getStringList("item-whitelist").stream().map(instance.getItemGroup()::get).flatMap(Collection::stream).collect(Collectors.toSet()) : Collections.emptySet()))
|
||||
.conflict(config.isList("conflicting-enchants") ? new HashSet<>(config.getStringList("conflicting-enchants")) : Collections.emptySet())
|
||||
.condition(Condition.of(config.getString("condition")))
|
||||
@ -37,10 +37,10 @@ public class ConfigParser {
|
||||
.map(s -> "effects." + s)
|
||||
.map(config::getConfigurationSection)
|
||||
.map(EffectManager::getEffect)
|
||||
.map(o -> o.orElse(null))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toSet()) : Collections.emptySet())
|
||||
.description(config.isList("description") ? new HashSet<>(config.getStringList("description")) : Collections.emptySet())
|
||||
.description(config.isList("description") ? config.getStringList("description") : Collections.emptyList())
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -70,21 +70,22 @@ public class ConfigParser {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static BookItem parseBookItem(ConfigurationSection section) {
|
||||
private static BookItem parseBookItem(EpicEnchants instance, ConfigurationSection section) {
|
||||
return section != null ? BookItem.builder()
|
||||
.instance(instance)
|
||||
.material(Material.valueOf(section.getString("material")))
|
||||
.displayName(color(section.getString("display-name")))
|
||||
.lore(section.getStringList("lore").stream().map(GeneralUtils::color).collect(Collectors.toList()))
|
||||
.build() : null;
|
||||
}
|
||||
|
||||
public static Group parseGroup(ConfigurationSection section) {
|
||||
public static Group parseGroup(EpicEnchants instance, ConfigurationSection section) {
|
||||
return section != null ? Group.builder()
|
||||
.identifier(section.getName())
|
||||
.name(color(section.getString("group-name")))
|
||||
.format(section.getString("group-lore-format"))
|
||||
.color(section.getString("group-color"))
|
||||
.bookItem(parseBookItem(section.getConfigurationSection("book-item")))
|
||||
.bookItem(parseBookItem(instance, section.getConfigurationSection("book-item")))
|
||||
.slotsUsed(section.getInt("slots-used"))
|
||||
.tinkererExp(section.getInt("tinkerer-exp-per-level"))
|
||||
.destroyRateMin(section.getInt("rates.destroy-min"))
|
||||
|
@ -28,7 +28,7 @@ public class GeneralUtils {
|
||||
}
|
||||
|
||||
public static String getMessageFromResult(EnchantResult result) {
|
||||
return "enchant." + result.toString().toLowerCase().replace("_", "");
|
||||
return "enchants." + result.toString().toLowerCase().replace("_", "-");
|
||||
}
|
||||
|
||||
public static <X> X getRandomElement(Set<X> set) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicenchants.utils.single;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import lombok.Getter;
|
||||
@ -17,7 +18,8 @@ public class ItemGroup {
|
||||
private Multimap<Group, Material> groupMap;
|
||||
|
||||
public ItemGroup(EpicEnchants instance) {
|
||||
if (instance.getVersion() > 1.12) setupMaster();
|
||||
groupMap = HashMultimap.create();
|
||||
if (instance.getVersion() > 12) setupMaster();
|
||||
else setupLegacy();
|
||||
}
|
||||
|
||||
@ -73,6 +75,10 @@ public class ItemGroup {
|
||||
return output;
|
||||
}
|
||||
|
||||
public Optional<Group> getGroup(Set<Material> materials) {
|
||||
return groupMap.asMap().entrySet().stream().filter(s -> s.getValue().equals(materials)).map(Map.Entry::getKey).findFirst();
|
||||
}
|
||||
|
||||
|
||||
public enum Group {
|
||||
AXES,
|
||||
|
@ -1,5 +1,7 @@
|
||||
#LEGACY CONFIG
|
||||
|
||||
first-load: true
|
||||
|
||||
language: "en_US"
|
||||
|
||||
roman-numbers: true
|
||||
@ -8,7 +10,6 @@ rates:
|
||||
black-scroll-min: 20
|
||||
black-scroll-max: 100
|
||||
|
||||
|
||||
commands:
|
||||
enchanter: "enchanter"
|
||||
alchemist: "alchemist"
|
||||
|
@ -22,9 +22,7 @@ applied-format: "&cExampleEnchant {level}"
|
||||
|
||||
# What items this enchant can be applied too.
|
||||
item-whitelist:
|
||||
- "DIAMOND_HELMET"
|
||||
- "IRON_HELMET"
|
||||
- "LEATHER_HELMET"
|
||||
- "HELMETS"
|
||||
|
||||
# This enchantment can not be applied if then enchantment below is already on the item.
|
||||
conflicting-enchants:
|
||||
|
@ -2,7 +2,7 @@ groups:
|
||||
SIMPLE:
|
||||
group-color: "&f"
|
||||
group-name: "Simple"
|
||||
group-lore-format: "{group_color} {enchant} {level}"
|
||||
group-lore-format: "{group_color}{enchant} {level}"
|
||||
rates:
|
||||
destroy-min: 10
|
||||
destroy-max: 100
|
||||
@ -15,6 +15,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
UNIQUE:
|
||||
group-color: "&a"
|
||||
@ -32,6 +33,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
ELITE:
|
||||
group-color: "&b"
|
||||
@ -49,6 +51,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
ULTIMATE:
|
||||
group-color: "&e"
|
||||
@ -66,6 +69,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
LEGENDARY:
|
||||
group-color: "&6"
|
||||
@ -83,4 +87,5 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
@ -8,7 +8,8 @@ rows: 1
|
||||
|
||||
contents:
|
||||
1:
|
||||
material: "WHITE_STAINED_GLASS_PANE"
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 0
|
||||
display-name: "&f&lSimple Enchantment &7(Right Click)"
|
||||
lore:
|
||||
- "&7Examine to receive a random"
|
||||
@ -23,7 +24,8 @@ contents:
|
||||
eco-cost: 0
|
||||
slot: 2
|
||||
2:
|
||||
material: "LIME_STAINED_GLASS_PANE"
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 5
|
||||
display-name: "&a&lUnique Enchantment &7(Right Click)"
|
||||
lore:
|
||||
- "&7Examine to receive a random"
|
||||
@ -38,7 +40,8 @@ contents:
|
||||
eco-cost: 0
|
||||
slot: 3
|
||||
3:
|
||||
material: "CYAN_STAINED_GLASS_PANE"
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 9
|
||||
display-name: "&b&lElite Enchantment &7(Right Click)"
|
||||
lore:
|
||||
- "&7Examine to receive a random"
|
||||
@ -53,7 +56,8 @@ contents:
|
||||
eco-cost: 0
|
||||
slot: 4
|
||||
4:
|
||||
material: "YELLOW_STAINED_GLASS_PANE"
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 4
|
||||
display-name: "&e&lUltimate Enchantment &7(Right Click)"
|
||||
lore:
|
||||
- "&7Examine to receive a random"
|
||||
@ -68,7 +72,8 @@ contents:
|
||||
eco-cost: 0
|
||||
slot: 5
|
||||
5:
|
||||
material: "ORANGE_STAINED_GLASS_PANE"
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 1
|
||||
display-name: "&6&lLegendary Enchantment &7(Right Click)"
|
||||
lore:
|
||||
- "&7Examine to receive a random"
|
||||
|
@ -1,8 +0,0 @@
|
||||
name: EpicEnchants
|
||||
version: ${project.version}
|
||||
main: com.songoda.epicenchants.EpicEnchants
|
||||
authors: [GB6]
|
||||
website: https://songoda.com/
|
||||
depend: [Vault]
|
||||
softdepend: [UltimateBottles]
|
||||
api-version: 1.13
|
@ -1,5 +1,7 @@
|
||||
#MASTER CONFIG
|
||||
|
||||
first-load: true
|
||||
|
||||
language: "en_US"
|
||||
|
||||
roman-numbers: true
|
||||
|
@ -2,7 +2,7 @@ groups:
|
||||
SIMPLE:
|
||||
group-color: "&f"
|
||||
group-name: "Simple"
|
||||
group-lore-format: "{group_color} {enchant} {level}"
|
||||
group-lore-format: "{group_color}{enchant} {level}"
|
||||
rates:
|
||||
destroy-min: 10
|
||||
destroy-max: 100
|
||||
@ -15,6 +15,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
UNIQUE:
|
||||
group-color: "&a"
|
||||
@ -32,6 +33,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
ELITE:
|
||||
group-color: "&b"
|
||||
@ -49,6 +51,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
ULTIMATE:
|
||||
group-color: "&e"
|
||||
@ -66,6 +69,7 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
||||
LEGENDARY:
|
||||
group-color: "&6"
|
||||
@ -83,4 +87,5 @@ groups:
|
||||
- "&a{success_rate}% Success Rate"
|
||||
- "&c{destroy_rate}% Destroy Rate"
|
||||
- "{description}"
|
||||
- "&7{item_group} Enchantment"
|
||||
- "&7Drag and drop to enchant."
|
@ -1,5 +1,5 @@
|
||||
secret-dust:
|
||||
material: FIREBALL
|
||||
material: FIRE_CHARGE
|
||||
display-name: "{group-color}{group-name} Secret Dust &7(Right click)"
|
||||
lore:
|
||||
- "&aSuccess: +{min-rate}-{max-rate}%"
|
||||
@ -9,7 +9,7 @@ secret-dust:
|
||||
dusts:
|
||||
mystery:
|
||||
chance: 50
|
||||
material: SULPHUR
|
||||
material: GUNPOWDER
|
||||
display-name: "&fMystery Dust"
|
||||
lore:
|
||||
- "&7The failed bi-product of"
|
||||
|
@ -14,22 +14,19 @@ slots: "(1,5) (2,6) (3,7) (9,14)
|
||||
|
||||
contents:
|
||||
1:
|
||||
material: "STAINED_GLASS_PANE"
|
||||
material: "WHITE_STAINED_GLASS_PANE"
|
||||
display-name: " "
|
||||
slot: "4,13,22,31,40"
|
||||
accept-left:
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 4
|
||||
material: "LIME_STAINED_GLASS_PANE"
|
||||
display-name: "&eClick to accept trade"
|
||||
slot: 0
|
||||
accept-right:
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 4
|
||||
material: "LIME_STAINED_GLASS_PANE"
|
||||
display-name: "&eClick to accept trade"
|
||||
slot: 8
|
||||
deposit-all:
|
||||
material: "STAINED_GLASS_PANE"
|
||||
data: 4
|
||||
material: "LIME_STAINED_GLASS_PANE"
|
||||
display-name: "&l&eDeposit All"
|
||||
lore:
|
||||
- "&7Click to deposit all tinkerable items."
|
||||
|
Loading…
Reference in New Issue
Block a user