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