mirror of
https://github.com/songoda/EpicEnchants.git
synced 2025-03-12 06:43:07 +01:00
Added 1.16 Support.
This commit is contained in:
parent
99928f434b
commit
f64ed4f913
2
pom.xml
2
pom.xml
@ -94,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<version>1.16.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.mrmicky</groupId>
|
||||
|
BIN
src/main/java/com/songoda/epicenchants/.DS_Store
vendored
Normal file
BIN
src/main/java/com/songoda/epicenchants/.DS_Store
vendored
Normal file
Binary file not shown.
@ -2,11 +2,12 @@ package com.songoda.epicenchants;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.epicenchants.command.CommandManager;
|
||||
import com.songoda.epicenchants.command.commands.*;
|
||||
import com.songoda.epicenchants.listeners.ArmorListener;
|
||||
import com.songoda.epicenchants.listeners.EntityListener;
|
||||
import com.songoda.epicenchants.listeners.PlayerListener;
|
||||
@ -90,7 +91,7 @@ public class EpicEnchants extends SongodaPlugin {
|
||||
this.specialItems = new SpecialItems(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.hookManager = new HookManager();
|
||||
this.itemGroup = new ItemGroup(this);
|
||||
this.itemGroup = new ItemGroup();
|
||||
|
||||
groupManager.loadGroups();
|
||||
enchantManager.loadEnchants();
|
||||
|
@ -31,9 +31,6 @@ public class DropHead extends EffectExecutor {
|
||||
case CHICKEN:
|
||||
skin = "MHF_Chicken";
|
||||
break;
|
||||
case PIG_ZOMBIE:
|
||||
skin = "MHF_PigZombie";
|
||||
break;
|
||||
case PIG:
|
||||
skin = "MHF_Pig";
|
||||
break;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicenchants.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
@ -48,7 +49,7 @@ public class InfoMenu extends FastInv {
|
||||
slots.stream().filter(slot -> enchantIterator.hasNext()).forEach(slot -> {
|
||||
Enchant enchant = enchantIterator.next();
|
||||
|
||||
String whitelist = instance.getItemGroup().getGroups(enchant.getItemWhitelist())
|
||||
String whitelist = instance.getItemGroup().getGroups(enchant.getItemWhitelist().stream().map(CompatibleMaterial::getMaterial).collect(Collectors.toSet()))
|
||||
.stream()
|
||||
.map(s -> StringUtils.capitalize(s.toLowerCase()))
|
||||
.collect(Collectors.joining(", "));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicenchants.objects;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.utils.itemnbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
@ -64,7 +65,8 @@ public class BookItem {
|
||||
}
|
||||
|
||||
string = string
|
||||
.replace("{item_group}", "" + instance.getItemGroup().getGroup(enchant.getItemWhitelist()).map(ItemGroup.Group::getName).orElse("N/A"))
|
||||
.replace("{item_group}", "" + instance.getItemGroup().getGroup(enchant.getItemWhitelist()
|
||||
.stream().map(CompatibleMaterial::getMaterial).collect(Collectors.toSet())).map(ItemGroup.Group::getName).orElse("N/A"))
|
||||
.replace("{success_rate}", "" + finalSuccessRate)
|
||||
.replace("{destroy_rate}", "" + finalDestroyRate);
|
||||
|
||||
|
@ -11,7 +11,6 @@ import com.songoda.epicenchants.utils.itemnbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import com.songoda.epicenchants.utils.settings.Settings;
|
||||
import com.songoda.epicenchants.utils.single.GeneralUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -2,87 +2,60 @@ package com.songoda.epicenchants.utils.single;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.core.compatibility.CompatibleMaterial.*;
|
||||
import static com.songoda.epicenchants.utils.single.ItemGroup.Group.*;
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
public class ItemGroup {
|
||||
|
||||
private Multimap<Group, Material> groupMap;
|
||||
private final Multimap<Group, CompatibleMaterial> groupMap;
|
||||
|
||||
public ItemGroup(EpicEnchants instance) {
|
||||
public ItemGroup() {
|
||||
groupMap = HashMultimap.create();
|
||||
if (com.songoda.core.compatibility.ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) setupMaster();
|
||||
else setupLegacy();
|
||||
}
|
||||
|
||||
private void setupMaster() {
|
||||
groupMap.putAll(AXES, Arrays.asList(DIAMOND_AXE, GOLDEN_AXE, IRON_AXE, STONE_AXE, WOODEN_AXE));
|
||||
groupMap.putAll(AXES, Arrays.asList(NETHERITE_AXE, DIAMOND_AXE, GOLDEN_AXE, IRON_AXE, STONE_AXE, WOODEN_AXE));
|
||||
|
||||
groupMap.putAll(PICKAXES, Arrays.asList(DIAMOND_PICKAXE, GOLDEN_PICKAXE, IRON_PICKAXE, STONE_PICKAXE, WOODEN_PICKAXE));
|
||||
groupMap.putAll(PICKAXES, Arrays.asList(NETHERITE_PICKAXE, DIAMOND_PICKAXE, GOLDEN_PICKAXE, IRON_PICKAXE, STONE_PICKAXE, WOODEN_PICKAXE));
|
||||
|
||||
groupMap.putAll(HOES, Arrays.asList(DIAMOND_HOE, GOLDEN_HOE, IRON_HOE, STONE_HOE, WOODEN_HOE));
|
||||
groupMap.putAll(HOES, Arrays.asList(NETHERITE_HOE, DIAMOND_HOE, GOLDEN_HOE, IRON_HOE, STONE_HOE, WOODEN_HOE));
|
||||
|
||||
groupMap.putAll(SHOVELS, Arrays.asList(DIAMOND_SHOVEL, GOLDEN_SHOVEL, IRON_SHOVEL, STONE_SHOVEL, WOODEN_SHOVEL));
|
||||
groupMap.putAll(SHOVELS, Arrays.asList(NETHERITE_SHOVEL, DIAMOND_SHOVEL, GOLDEN_SHOVEL, IRON_SHOVEL, STONE_SHOVEL, WOODEN_SHOVEL));
|
||||
|
||||
groupMap.putAll(SWORDS, Arrays.asList(DIAMOND_SWORD, GOLDEN_SWORD, IRON_SWORD, STONE_SWORD, WOODEN_SWORD));
|
||||
groupMap.putAll(SWORDS, Arrays.asList(NETHERITE_SWORD, DIAMOND_SWORD, GOLDEN_SWORD, IRON_SWORD, STONE_SWORD, WOODEN_SWORD));
|
||||
|
||||
groupMap.put(BOWS, BOW);
|
||||
|
||||
groupMap.putAll(BOOTS, Arrays.asList(DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, LEATHER_BOOTS));
|
||||
groupMap.putAll(BOOTS, Arrays.asList(NETHERITE_BOOTS, DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, LEATHER_BOOTS));
|
||||
|
||||
groupMap.putAll(LEGGINGS, Arrays.asList(DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, LEATHER_LEGGINGS));
|
||||
groupMap.putAll(LEGGINGS, Arrays.asList(NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, LEATHER_LEGGINGS));
|
||||
|
||||
groupMap.putAll(CHESTPLATES, Arrays.asList(DIAMOND_CHESTPLATE, GOLDEN_CHESTPLATE, IRON_CHESTPLATE, LEATHER_CHESTPLATE));
|
||||
groupMap.putAll(CHESTPLATES, Arrays.asList(NETHERITE_CHESTPLATE, DIAMOND_CHESTPLATE, GOLDEN_CHESTPLATE, IRON_CHESTPLATE, LEATHER_CHESTPLATE));
|
||||
|
||||
groupMap.putAll(HELMETS, Arrays.asList(DIAMOND_HELMET, GOLDEN_HELMET, IRON_HELMET, LEATHER_HELMET));
|
||||
groupMap.putAll(HELMETS, Arrays.asList(NETHERITE_HELMET, DIAMOND_HELMET, GOLDEN_HELMET, IRON_HELMET, LEATHER_HELMET));
|
||||
|
||||
groupMap.put(TRIDENTS, TRIDENT);
|
||||
}
|
||||
|
||||
private void setupLegacy() {
|
||||
groupMap.putAll(AXES, Arrays.asList(DIAMOND_AXE, Material.valueOf("GOLD_AXE"), IRON_AXE, STONE_AXE, Material.valueOf("WOOD_AXE")));
|
||||
|
||||
groupMap.putAll(PICKAXES, Arrays.asList(DIAMOND_PICKAXE, Material.valueOf("GOLD_PICKAXE"), IRON_PICKAXE, STONE_PICKAXE, Material.valueOf("WOOD_PICKAXE")));
|
||||
|
||||
groupMap.putAll(HOES, Arrays.asList(DIAMOND_HOE, Material.valueOf("GOLD_HOE"), IRON_HOE, STONE_HOE, Material.valueOf("WOOD_HOE")));
|
||||
|
||||
groupMap.putAll(SHOVELS, Arrays.asList(Material.valueOf("DIAMOND_SPADE"), Material.valueOf("GOLD_SPADE"), Material.valueOf("IRON_SPADE"), Material.valueOf("STONE_SPADE"), Material.valueOf("WOOD_SPADE")));
|
||||
|
||||
groupMap.putAll(SWORDS, Arrays.asList(DIAMOND_SWORD, Material.valueOf("GOLD_SWORD"), IRON_SWORD, STONE_SWORD, Material.valueOf("WOOD_SWORD")));
|
||||
|
||||
groupMap.put(BOWS, BOW);
|
||||
|
||||
groupMap.putAll(BOOTS, Arrays.asList(DIAMOND_BOOTS, Material.valueOf("GOLD_BOOTS"), IRON_BOOTS, LEATHER_BOOTS));
|
||||
|
||||
groupMap.putAll(LEGGINGS, Arrays.asList(DIAMOND_LEGGINGS, Material.valueOf("GOLD_LEGGINGS"), IRON_LEGGINGS, LEATHER_LEGGINGS));
|
||||
|
||||
groupMap.putAll(CHESTPLATES, Arrays.asList(DIAMOND_CHESTPLATE, Material.valueOf("GOLD_CHESTPLATE"), IRON_CHESTPLATE, LEATHER_CHESTPLATE));
|
||||
|
||||
groupMap.putAll(HELMETS, Arrays.asList(DIAMOND_HELMET, Material.valueOf("GOLD_HELMET"), IRON_HELMET, LEATHER_HELMET));
|
||||
}
|
||||
|
||||
public Set<Material> get(String key) {
|
||||
Optional<Group> optionalGroup = Group.from(key);
|
||||
Set<Material> output = new HashSet<>();
|
||||
|
||||
optionalGroup.ifPresent(group -> output.addAll(getMaterials(group)));
|
||||
|
||||
if (Material.matchMaterial(key) != null) {
|
||||
output.add(Material.matchMaterial(key));
|
||||
if (CompatibleMaterial.getMaterial(key) != null) {
|
||||
output.add(CompatibleMaterial.getMaterial(key).getMaterial());
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public Set<String> getGroups(Set<Material> materials) {
|
||||
public Set<String> getGroups(Set<CompatibleMaterial> materials) {
|
||||
Set<String> groups = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -92,11 +65,11 @@ public class ItemGroup {
|
||||
});
|
||||
}
|
||||
|
||||
groups.addAll(materials.stream().map(Material::toString).collect(Collectors.toSet()));
|
||||
groups.addAll(materials.stream().map(CompatibleMaterial::toString).collect(Collectors.toSet()));
|
||||
return groups;
|
||||
}
|
||||
|
||||
public Optional<Group> getGroup(Set<Material> materials) {
|
||||
public Optional<Group> getGroup(Set<CompatibleMaterial> materials) {
|
||||
Optional<Group> group = Arrays.stream(Group.values())
|
||||
.filter(s -> !s.getChildren().isEmpty() && s.getChildren().stream().allMatch(child -> materials.containsAll(groupMap.get(child))))
|
||||
.findFirst();
|
||||
@ -113,7 +86,7 @@ public class ItemGroup {
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (group.getChildren().isEmpty())
|
||||
out.addAll(groupMap.get(group));
|
||||
out.addAll(groupMap.get(group).stream().map(CompatibleMaterial::getMaterial).collect(Collectors.toList()));
|
||||
else
|
||||
out.addAll(group.getChildren().stream().map(this::getMaterials).flatMap(Collection::stream).collect(Collectors.toSet()));
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ website: https://songoda.com/
|
||||
softdepend: [Vault, PlayerPoints, UltimateBottles, PlaceholderAPI]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
epicenchants:
|
||||
aliases: [ee]
|
||||
ussage: /ee reload
|
||||
ee:
|
||||
aliases: [epicenchants]
|
||||
ussage: reload
|
@ -15,7 +15,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&fsimple &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &f/ee list simple &7to view a list"
|
||||
- "&fUse &flist simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -31,7 +31,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&aunique &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &a/ee list unique &7to view a list"
|
||||
- "&fUse &alist unique &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -47,7 +47,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&belite &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &b/ee list elite &7to view a list"
|
||||
- "&fUse &blist elite &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -63,7 +63,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&eultimate &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &e/ee list simple &7to view a list"
|
||||
- "&fUse &elist simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -79,7 +79,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&6legendary &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &6/ee list simple &7to view a list"
|
||||
- "&fUse &6list simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
|
@ -14,7 +14,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&fsimple &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &f/ee list simple &7to view a list"
|
||||
- "&fUse &flist simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -29,7 +29,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&aunique &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &a/ee list unique &7to view a list"
|
||||
- "&fUse &alist unique &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -44,7 +44,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&belite &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &b/ee list elite &7to view a list"
|
||||
- "&fUse &blist elite &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -59,7 +59,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&eultimate &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &e/ee list simple &7to view a list"
|
||||
- "&fUse &elist simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
@ -74,7 +74,7 @@ contents:
|
||||
- "&7Examine to receive a random"
|
||||
- "&6legendary &7enchantment book."
|
||||
- ""
|
||||
- "&fUse &6/ee list simple &7to view a list"
|
||||
- "&fUse &6list simple &7to view a list"
|
||||
- "&fof possible enchants you could unlock!"
|
||||
- ""
|
||||
- "&b&lCOST &r&f{exp_cost} EXP"
|
||||
|
Loading…
Reference in New Issue
Block a user