mirror of
https://github.com/songoda/EpicEnchants.git
synced 2025-01-03 06:57:39 +01:00
Migrate from SongodaCore to CraftaroCore v3.0.0-SNAPSHOT
This commit is contained in:
parent
8e27640956
commit
489bff3620
21
pom.xml
21
pom.xml
@ -33,7 +33,7 @@
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
|
||||
<release>${java.release}</release>
|
||||
<release>${java.release}</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -94,6 +94,11 @@
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>craftaro-minecraft-plugins</id>
|
||||
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
@ -106,6 +111,13 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
@ -113,13 +125,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.19</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateBottles</artifactId>
|
||||
|
@ -1,12 +1,13 @@
|
||||
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.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.epicenchants.commands.CommandAlchemist;
|
||||
import com.songoda.epicenchants.commands.CommandApply;
|
||||
import com.songoda.epicenchants.commands.CommandEnchanter;
|
||||
@ -71,10 +72,10 @@ public class EpicEnchants extends SongodaPlugin {
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 67, CompatibleMaterial.DIAMOND_SWORD);
|
||||
SongodaCore.registerPlugin(this, 67, XMaterial.DIAMOND_SWORD);
|
||||
|
||||
// setup commands
|
||||
this.commandManager = new com.songoda.core.commands.CommandManager(this);
|
||||
this.commandManager = new com.craftaro.core.commands.CommandManager(this);
|
||||
this.commandManager.addMainCommand("ee")
|
||||
.addSubCommand(new CommandReload(this))
|
||||
.addSubCommand(new CommandAlchemist(this))
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.menus.AlchemistMenu;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
@ -62,7 +62,7 @@ public class CommandApply extends AbstractCommand {
|
||||
int level = Integer.parseInt(args[1]);
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(player.getItemInHand()))) {
|
||||
if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(player.getItemInHand().getType()).get())) {
|
||||
System.out.println("List = " + enchant.getItemWhitelist());
|
||||
plugin.getLocale().getMessage("command.apply.invaliditem")
|
||||
.processPlaceholder("enchant", enchant.getIdentifier())
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.menus.EnchanterMenu;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.configuration.editor.PluginConfigGui;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.configuration.editor.PluginConfigGui;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.menus.TinkererMenu;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import com.songoda.epicenchants.enums.EventType;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -24,7 +24,7 @@ public class DropHead extends EffectExecutor {
|
||||
}
|
||||
|
||||
private Optional<ItemStack> getHead(Entity entity) {
|
||||
ItemStack out = CompatibleMaterial.PLAYER_HEAD.getItem();
|
||||
ItemStack out = XMaterial.PLAYER_HEAD.parseItem();
|
||||
String skin = null;
|
||||
|
||||
switch (entity.getType()) {
|
||||
@ -47,10 +47,10 @@ public class DropHead extends EffectExecutor {
|
||||
skin = "MHF_Spider";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
out = CompatibleMaterial.ZOMBIE_HEAD.getItem();
|
||||
out = XMaterial.ZOMBIE_HEAD.parseItem();
|
||||
break;
|
||||
case SKELETON:
|
||||
out = CompatibleMaterial.SKELETON_SKULL.getItem();
|
||||
out = XMaterial.SKELETON_SKULL.parseItem();
|
||||
break;
|
||||
case VILLAGER:
|
||||
skin = "MHF_Villager";
|
||||
@ -62,7 +62,7 @@ public class DropHead extends EffectExecutor {
|
||||
skin = "MHF_Blaze";
|
||||
break;
|
||||
case CREEPER:
|
||||
out = CompatibleMaterial.CREEPER_HEAD.getItem();
|
||||
out = XMaterial.CREEPER_HEAD.parseItem();
|
||||
case ENDERMAN:
|
||||
skin = "MHF_Enderman";
|
||||
break;
|
||||
@ -72,8 +72,6 @@ public class DropHead extends EffectExecutor {
|
||||
case IRON_GOLEM:
|
||||
skin = "MHF_Golem";
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
out = CompatibleMaterial.WITHER_SKELETON_SKULL.getItem();
|
||||
case PLAYER:
|
||||
break;
|
||||
default:
|
||||
@ -82,9 +80,9 @@ public class DropHead extends EffectExecutor {
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) out.getItemMeta();
|
||||
|
||||
if (skin != null && CompatibleMaterial.getMaterial(out) == CompatibleMaterial.PLAYER_HEAD
|
||||
|| entity instanceof Player)
|
||||
if ((skin != null && XMaterial.PLAYER_HEAD.isSimilar(out)) || entity instanceof Player) {
|
||||
skullMeta.setOwner(entity instanceof Player ? entity.getName() : skin);
|
||||
}
|
||||
out.setItemMeta(skullMeta);
|
||||
|
||||
return Optional.of(out);
|
||||
|
@ -5,8 +5,6 @@ import com.songoda.epicenchants.enums.EventType;
|
||||
import com.songoda.epicenchants.objects.LeveledModifier;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -91,11 +89,13 @@ public class SpawnMob extends EffectExecutor {
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
AttributeInstance attack = ((LivingEntity) entity).getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
|
||||
attack.setBaseValue(attackDamage.get(level, (int) Math.round(attack.getBaseValue()), user, opponent));
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
AttributeInstance heal = ((LivingEntity) entity).getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||
heal.setBaseValue(health.get(level, (int) Math.round(heal.getBaseValue()), user, opponent));
|
||||
// AttributeInstance attack = ((LivingEntity) entity).getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
|
||||
// attack.setBaseValue(attackDamage.get(level, (int) Math.round(attack.getBaseValue()), user, opponent));
|
||||
|
||||
double maxHealth = livingEntity.getMaxHealth();
|
||||
livingEntity.setMaxHealth(health.get(level, (int) Math.round(maxHealth), user, opponent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.listeners;
|
||||
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.craftaro.core.nms.NmsManager;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.enums.TriggerType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.listeners.item;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.utils.single.RomanNumber;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.listeners.item;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
import com.songoda.epicenchants.events.EnchantApplyEvent;
|
||||
@ -39,7 +39,7 @@ public class BookListener extends ItemListener {
|
||||
ItemStack toApply = event.getCurrentItem();
|
||||
Enchant enchant = instance.getEnchantManager().getValue(cursor.getString("enchant")).orElseThrow(() -> new IllegalStateException("Book without enchant!"));
|
||||
|
||||
if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(current.getItem()))) {
|
||||
if (!enchant.getItemWhitelist().contains(CompatibleMaterial.getMaterial(current.getItem().getType()).get())) {
|
||||
return;
|
||||
}
|
||||
// get total amount of enchantments on item
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.listeners.item;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicenchants.listeners.item;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.compatibility.CompatibleHand;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -10,7 +11,6 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class ItemListener implements Listener {
|
||||
@ -61,9 +61,8 @@ public abstract class ItemListener implements Listener {
|
||||
void useItem(PlayerInteractEvent event) {
|
||||
int slot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
|
||||
try {
|
||||
if (event.getHand() == EquipmentSlot.OFF_HAND) slot = 40;
|
||||
} catch (Exception | Error ignore) {
|
||||
if (CompatibleHand.getHand(event) == CompatibleHand.OFF_HAND) {
|
||||
slot = 40;
|
||||
}
|
||||
|
||||
if (event.getItem().getAmount() > 1) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.listeners.item;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -27,7 +27,7 @@ public class WhiteScrollListener extends ItemListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!instance.getItemGroup().isValid(CompatibleMaterial.getMaterial(event.getCurrentItem())))
|
||||
if (!instance.getItemGroup().isValid(CompatibleMaterial.getMaterial(event.getCurrentItem().getType()).get()))
|
||||
return;
|
||||
|
||||
current.setBoolean("protected", true);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.managers;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.utils.objects.FileLocation;
|
||||
import com.songoda.epicenchants.utils.settings.Settings;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.menus;
|
||||
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.menus;
|
||||
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
import com.songoda.epicenchants.utils.objects.FastInv;
|
||||
@ -84,4 +84,3 @@ public class EnchanterMenu extends FastInv {
|
||||
.forEach(section -> addItem(getSlots(section.getString("slot")), new ItemBuilder(section).build()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicenchants.menus;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.enums.ItemType;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.objects;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
import com.songoda.epicenchants.utils.settings.Settings;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicenchants.objects;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import com.songoda.epicenchants.enums.EventType;
|
||||
import com.songoda.epicenchants.enums.TriggerType;
|
||||
@ -23,14 +24,14 @@ public class Enchant {
|
||||
private Group group;
|
||||
private int maxLevel;
|
||||
private Set<String> conflict;
|
||||
private Set<CompatibleMaterial> itemWhitelist;
|
||||
private Set<XMaterial> itemWhitelist;
|
||||
private Set<EffectExecutor> effectExecutors;
|
||||
private List<String> description;
|
||||
private String format;
|
||||
@Nullable
|
||||
private BookItem bookItem;
|
||||
|
||||
Enchant(String author, String identifier, Group group, int maxLevel, Set<String> conflict, Set<CompatibleMaterial> itemWhitelist, Set<EffectExecutor> effectExecutors, List<String> description, String format, BookItem bookItem) {
|
||||
Enchant(String author, String identifier, Group group, int maxLevel, Set<String> conflict, Set<XMaterial> itemWhitelist, Set<EffectExecutor> effectExecutors, List<String> description, String format, BookItem bookItem) {
|
||||
this.author = author;
|
||||
this.identifier = identifier;
|
||||
this.group = group;
|
||||
@ -96,7 +97,7 @@ public class Enchant {
|
||||
return this.conflict;
|
||||
}
|
||||
|
||||
public Set<CompatibleMaterial> getItemWhitelist() {
|
||||
public Set<XMaterial> getItemWhitelist() {
|
||||
return new HashSet<>(this.itemWhitelist);
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ public class Enchant {
|
||||
private Group group;
|
||||
private int maxLevel;
|
||||
private Set<String> conflict;
|
||||
private Set<CompatibleMaterial> itemWhitelist;
|
||||
private Set<XMaterial> itemWhitelist;
|
||||
private Set<EffectExecutor> effectExecutors;
|
||||
private List<String> description;
|
||||
private String format;
|
||||
@ -157,7 +158,7 @@ public class Enchant {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Enchant.EnchantBuilder itemWhitelist(Set<CompatibleMaterial> itemWhitelist) {
|
||||
public Enchant.EnchantBuilder itemWhitelist(Set<XMaterial> itemWhitelist) {
|
||||
this.itemWhitelist = itemWhitelist;
|
||||
return this;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicenchants.utils;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTCompound;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
import com.songoda.epicenchants.enums.EventType;
|
||||
@ -18,8 +18,8 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -1,43 +1,8 @@
|
||||
package com.songoda.epicenchants.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class Methods {
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
EpicEnchants instance = EpicEnchants.getInstance();
|
||||
return Methods.getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
EpicEnchants instance = EpicEnchants.getInstance();
|
||||
if (type)
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
}
|
||||
|
||||
private static ItemStack getGlass(Boolean rainbow, int type) {
|
||||
int randomNum = 1 + (int) (Math.random() * 6);
|
||||
ItemStack glass;
|
||||
if (rainbow) {
|
||||
glass = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) randomNum);
|
||||
} else {
|
||||
glass = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) type);
|
||||
}
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName("§l");
|
||||
glass.setItemMeta(glassmeta);
|
||||
return glass;
|
||||
}
|
||||
|
||||
public static boolean isInt(String number) {
|
||||
if (number == null || number.equals(""))
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicenchants.utils;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.objects.Group;
|
||||
import com.songoda.epicenchants.utils.objects.ItemBuilder;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicenchants.utils.objects;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicenchants.objects.Placeholder;
|
||||
import com.songoda.epicenchants.utils.single.ConfigParser;
|
||||
import com.songoda.epicenchants.utils.single.GeneralUtils;
|
||||
@ -53,8 +54,8 @@ public class ItemBuilder {
|
||||
public ItemBuilder(ConfigurationSection section, Player player, Placeholder... placeholders) {
|
||||
this(section, placeholders);
|
||||
|
||||
if (item.getType() == Material.LEGACY_SKULL_ITEM) {
|
||||
((SkullMeta) item.getItemMeta()).setOwningPlayer(player);
|
||||
if (XMaterial.PLAYER_HEAD.isSimilar(item)) {
|
||||
((SkullMeta) item.getItemMeta()).setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,15 +255,6 @@ public class ItemBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable() {
|
||||
return unbreakable(true);
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable(boolean unbreakable) {
|
||||
meta.setUnbreakable(unbreakable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTItem nbt() {
|
||||
return new NBTItem(build());
|
||||
}
|
||||
@ -304,11 +296,4 @@ public class ItemBuilder {
|
||||
public String getName() {
|
||||
return meta.getDisplayName();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unbreakability:
|
||||
*/
|
||||
public boolean isUnbreakable() {
|
||||
return meta.isUnbreakable();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicenchants.utils.settings;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.configuration.ConfigSetting;
|
||||
import com.craftaro.core.hooks.EconomyManager;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicenchants.utils.single;
|
||||
|
||||
import com.songoda.core.math.MathUtils;
|
||||
import com.craftaro.core.compatibility.CompatibleHand;
|
||||
import com.craftaro.core.math.MathUtils;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
import com.songoda.epicenchants.enums.TriggerType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -10,8 +11,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -74,11 +73,8 @@ public class GeneralUtils {
|
||||
} else if (entity.getEquipment() != null) {
|
||||
ItemStack item = entity.getEquipment().getItemInHand();
|
||||
|
||||
try {
|
||||
if (item.getType() == Material.AIR) {
|
||||
return entity.getEquipment().getItemInOffHand();
|
||||
}
|
||||
} catch (NoSuchMethodError ignore) {
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
return CompatibleHand.OFF_HAND.getItem(entity);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@ -86,16 +82,10 @@ public class GeneralUtils {
|
||||
}
|
||||
|
||||
public static int getHeldItemSlot(Player player, Event event) {
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
|
||||
try {
|
||||
if (event instanceof PlayerInteractEvent && ((PlayerInteractEvent) event).getHand() == EquipmentSlot.OFF_HAND) {
|
||||
slot = 40;
|
||||
}
|
||||
} catch (NoSuchMethodError ignore) {
|
||||
if (CompatibleHand.getHand(event) == CompatibleHand.OFF_HAND) {
|
||||
return 40;
|
||||
}
|
||||
|
||||
return slot;
|
||||
return player.getInventory().getHeldItemSlot();
|
||||
}
|
||||
|
||||
public static Object parseJS(String toParse, String type, Object def) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.epicenchants.utils.single;
|
||||
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -13,12 +14,12 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.core.compatibility.CompatibleMaterial.*;
|
||||
import static com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial.*;
|
||||
import static com.songoda.epicenchants.utils.single.ItemGroup.Group.*;
|
||||
|
||||
public class ItemGroup {
|
||||
|
||||
private final Multimap<Group, CompatibleMaterial> groupMap;
|
||||
private final Multimap<Group, XMaterial> groupMap;
|
||||
|
||||
public ItemGroup() {
|
||||
groupMap = HashMultimap.create();
|
||||
@ -46,27 +47,26 @@ public class ItemGroup {
|
||||
groupMap.put(TRIDENTS, TRIDENT);
|
||||
}
|
||||
|
||||
public Set<CompatibleMaterial> get(String key) {
|
||||
public Set<XMaterial> get(String key) {
|
||||
Optional<Group> optionalGroup = Group.from(key);
|
||||
Set<CompatibleMaterial> output = new HashSet<>();
|
||||
Set<XMaterial> output = new HashSet<>();
|
||||
|
||||
optionalGroup.ifPresent(group -> output.addAll(getMaterials(group)));
|
||||
|
||||
if (CompatibleMaterial.getMaterial(key) != null) {
|
||||
output.add(CompatibleMaterial.getMaterial(key));
|
||||
}
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(key);
|
||||
material.ifPresent(output::add);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public boolean isValid(CompatibleMaterial material) {
|
||||
public boolean isValid(XMaterial material) {
|
||||
for (Group group : groupMap.keys())
|
||||
if (getMaterials(group).contains(material))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<String> getGroups(Set<CompatibleMaterial> materials) {
|
||||
public Set<String> getGroups(Set<XMaterial> materials) {
|
||||
Set<String> groups = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -76,11 +76,11 @@ public class ItemGroup {
|
||||
});
|
||||
}
|
||||
|
||||
groups.addAll(materials.stream().map(CompatibleMaterial::toString).collect(Collectors.toSet()));
|
||||
groups.addAll(materials.stream().map(XMaterial::toString).collect(Collectors.toSet()));
|
||||
return groups;
|
||||
}
|
||||
|
||||
public Optional<Group> getGroup(Set<CompatibleMaterial> materials) {
|
||||
public Optional<Group> getGroup(Set<XMaterial> materials) {
|
||||
Optional<Group> group = Arrays.stream(Group.values())
|
||||
.filter(s -> !s.getChildren().isEmpty() && s.getChildren().stream().allMatch(child -> materials.containsAll(groupMap.get(child))))
|
||||
.findFirst();
|
||||
@ -92,8 +92,8 @@ public class ItemGroup {
|
||||
return groupMap.asMap().entrySet().stream().filter(s -> materials.containsAll(s.getValue())).map(Map.Entry::getKey).findFirst();
|
||||
}
|
||||
|
||||
public Set<CompatibleMaterial> getMaterials(Group group) {
|
||||
Set<CompatibleMaterial> out = new HashSet<>();
|
||||
public Set<XMaterial> getMaterials(Group group) {
|
||||
Set<XMaterial> out = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (group.getChildren().isEmpty())
|
||||
|
@ -10,9 +10,10 @@ softdepend:
|
||||
- UltimateBottles
|
||||
- Vault
|
||||
|
||||
author: Songoda
|
||||
author: Craftaro
|
||||
website: ${project.url}
|
||||
|
||||
# TODO: Fix the stuff below (ussage?, why ee and not epicenchants?, etc.)
|
||||
commands:
|
||||
ee:
|
||||
aliases:
|
||||
|
Loading…
Reference in New Issue
Block a user