Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.randomHashTags.RandomPackage.api;
- import me.randomHashTags.RandomPackage.*;
- import org.bukkit.inventory.*;
- import org.bukkit.plugin.*;
- import java.io.*;
- import org.bukkit.event.server.*;
- import org.bukkit.command.*;
- import org.bukkit.configuration.file.*;
- import org.bukkit.enchantments.*;
- import org.bukkit.event.inventory.*;
- import java.math.*;
- import org.bukkit.potion.*;
- import java.util.*;
- import me.randomHashTags.RandomPackage.other.*;
- import me.randomHashTags.RandomPackage.versions.*;
- import org.bukkit.event.block.*;
- import org.bukkit.*;
- import org.bukkit.event.*;
- import org.bukkit.inventory.meta.*;
- import org.bukkit.util.*;
- import org.bukkit.event.player.*;
- import org.bukkit.event.entity.*;
- import org.bukkit.entity.*;
- public class CustomEnchantments implements Listener
- {
- public boolean enabled;
- private static CustomEnchantments instance;
- private RandomPackage rp;
- private RandomPackageAPI api;
- private final String prefix;
- private Random random;
- private ItemStack item;
- private ItemMeta itemMeta;
- private String guardiansname;
- private String spiritsname;
- private String undeadrusename;
- private String configPrefix;
- private String SUCCESS;
- private String DESTROY;
- private String APPLY_TO_ITEM;
- private String WHITE_SCROLL_PROTECTED;
- private String ARMOR;
- private String HELMET;
- private String CHESTPLATE;
- private String LEGGINGS;
- private String BOOTS;
- private String TOOL;
- private String PICKAXE;
- private String AXE;
- private String SWORD;
- private String WEAPON;
- private String BOW;
- private String TRANSMOG;
- private String mcmmo;
- private boolean shootfireworks;
- private boolean alchemistAccept;
- private boolean tinkererAccept;
- private ItemStack[] items;
- private Inventory[] inventories;
- private String[] particlelist;
- private String[] particleloc;
- private FileConfiguration enchantments;
- private FileConfiguration enchantmentsInfo;
- private FileConfiguration messages;
- private FileConfiguration sounds;
- private FileConfiguration itemsConfig;
- private FileConfiguration particles;
- private FileConfiguration cemessages;
- private FactionsAPI fapi;
- private Plugin randompackage;
- private final String folder;
- private String[] enchantstrings;
- private Double[] doubles;
- private HashMap<String, String> enchants;
- private HashMap<Player, Double> marksman;
- private HashMap<Player, List<Player>> aegis;
- private HashMap<Player, ItemStack> commander;
- private HashMap<Player, ItemStack> protection;
- private HashMap<Player, ItemStack> implants;
- private HashMap<Player, ItemStack> teleblock;
- private ArrayList<ItemStack> bows;
- private ArrayList<UUID> soulmode;
- private ArrayList<UUID> dominate;
- private ArrayList<UUID> repairguard;
- private ArrayList<UUID> bowsp;
- private ArrayList<UUID> Teleblock;
- private ArrayList<UUID> phoenix;
- private ArrayList<UUID> divineimmolation;
- private ArrayList<Integer> dominatee;
- private List<String> addpotioneffect;
- private List<String> removepotioneffect;
- private List<String> applyinfo;
- private List<String> alchemistexchange;
- private List<String> alchemistclose;
- private List<String> tinkereraccept;
- private List<String> tinkerercancelled;
- private List<String> soulmodedeactivatedMoved;
- private List<String> soulmodedeactivatedDropped;
- private List<String> soulmodedeactivatedInteract;
- private List<String> soulmodedeactivatedRanOut;
- private List<String> soulmodeactivate;
- private List[] enchantmessages;
- public ArrayList<String> disabledenchantments;
- public ArrayList<String> detonate;
- public ArrayList<String> arrowdeflect;
- public ArrayList<String> unfocus;
- public ArrayList<String> lore;
- public HashMap<String, ArrayList<String>> customenchantments;
- public HashMap<String, ItemStack> revealitems;
- public HashMap<String, ItemStack> revealeditems;
- public HashMap<String, ItemStack> regulardust;
- public HashMap<String, ItemStack> primaldust;
- public HashMap<String, ItemStack> fireballs;
- private HashMap<String, String> revealeditemsfirework;
- private HashMap<String, String> applyformat;
- private HashMap<String, String> randomizationscrollappliesto;
- private HashMap<String, List<String>> revealitemsmessages;
- public HashMap<String, Integer> regulardustchance;
- public HashMap<String, Integer> primaldustchance;
- public ArrayList<String> allcustomenchantments;
- private ArrayList<ItemStack> soultrackers;
- private ArrayList<ItemStack> randomizationscrolls;
- private ArrayList<String> soultrackers_apply;
- private ArrayList<String> randomizationscrollrarities;
- public HashMap<String, Integer> enchantmaxlevel;
- private ArrayList<String> potioneffectEnchants;
- private ArrayList<List<String>> armorlore;
- private boolean doublestrike;
- private ArrayList<String> playerRage;
- private ArrayList<String> mobRage;
- public CustomEnchantments() {
- this.enabled = false;
- this.rp = RandomPackage.getInstance();
- this.prefix = this.rp.prefix;
- this.random = new Random();
- this.item = new ItemStack(Material.APPLE);
- this.itemMeta = this.item.getItemMeta();
- this.mcmmo = null;
- this.shootfireworks = false;
- this.alchemistAccept = false;
- this.tinkererAccept = false;
- this.items = this.rp.items;
- this.inventories = this.rp.inventories;
- this.particlelist = this.rp.particles;
- this.particleloc = this.rp.particlesloc;
- this.fapi = FactionsAPI.getInstance();
- this.randompackage = RandomPackage.getPlugin;
- this.folder = "plugins" + File.separator + "RandomPackage" + File.separator + "Custom Enchantments" + File.separator;
- this.enchantstrings = new String[10000];
- this.doubles = new Double[10000];
- this.enchants = new HashMap<String, String>();
- this.marksman = new HashMap<Player, Double>();
- this.aegis = new HashMap<Player, List<Player>>();
- this.commander = new HashMap<Player, ItemStack>();
- this.protection = new HashMap<Player, ItemStack>();
- this.implants = new HashMap<Player, ItemStack>();
- this.teleblock = new HashMap<Player, ItemStack>();
- this.bows = new ArrayList<ItemStack>();
- this.soulmode = new ArrayList<UUID>();
- this.dominate = new ArrayList<UUID>();
- this.repairguard = new ArrayList<UUID>();
- this.bowsp = new ArrayList<UUID>();
- this.Teleblock = new ArrayList<UUID>();
- this.phoenix = new ArrayList<UUID>();
- this.divineimmolation = new ArrayList<UUID>();
- this.dominatee = new ArrayList<Integer>();
- this.enchantmessages = new List[1000];
- this.disabledenchantments = new ArrayList<String>();
- this.detonate = new ArrayList<String>();
- this.arrowdeflect = new ArrayList<String>();
- this.unfocus = new ArrayList<String>();
- this.lore = new ArrayList<String>();
- this.customenchantments = new HashMap<String, ArrayList<String>>();
- this.revealitems = new HashMap<String, ItemStack>();
- this.revealeditems = new HashMap<String, ItemStack>();
- this.regulardust = new HashMap<String, ItemStack>();
- this.primaldust = new HashMap<String, ItemStack>();
- this.fireballs = new HashMap<String, ItemStack>();
- this.revealeditemsfirework = new HashMap<String, String>();
- this.applyformat = new HashMap<String, String>();
- this.randomizationscrollappliesto = this.rp.randomizationscrollappliesto;
- this.revealitemsmessages = new HashMap<String, List<String>>();
- this.regulardustchance = new HashMap<String, Integer>();
- this.primaldustchance = new HashMap<String, Integer>();
- this.allcustomenchantments = new ArrayList<String>();
- this.soultrackers = this.rp.soultrackers;
- this.randomizationscrolls = this.rp.randomizationscrolls;
- this.soultrackers_apply = this.rp.soultrackers_apply;
- this.randomizationscrollrarities = this.rp.randomizationscrollrarities;
- this.enchantmaxlevel = new HashMap<String, Integer>();
- this.potioneffectEnchants = new ArrayList<String>();
- this.doublestrike = false;
- this.playerRage = new ArrayList<String>();
- this.mobRage = new ArrayList<String>();
- }
- public static CustomEnchantments getInstance() {
- if (CustomEnchantments.instance == null) {
- CustomEnchantments.instance = new CustomEnchantments();
- }
- return CustomEnchantments.instance;
- }
- private ItemStack setupItem(final FileConfiguration config, final String path) {
- String iitem = config.getString(String.valueOf(path) + ".item");
- if (iitem == null) {
- return null;
- }
- iitem = iitem.toLowerCase();
- if (Material.getMaterial(iitem.toUpperCase().split(":")[0]) == null) {
- return new ItemStack(Material.AIR);
- }
- int amount = 1;
- if (config.get(String.valueOf(path) + ".amount") != null) {
- amount = Integer.parseInt(config.getString(String.valueOf(path) + ".amount"));
- }
- int data = 0;
- if (config.getString(String.valueOf(path) + ".item").contains(":")) {
- data = Integer.parseInt(config.getString(String.valueOf(path) + ".item").split("\\:")[1]);
- }
- this.item = new ItemStack(Material.getMaterial(config.getString(String.valueOf(path) + ".item").toUpperCase().split(":")[0]), amount, (short)(byte)data);
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (config.get(String.valueOf(path) + ".name") != null) {
- this.itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(String.valueOf(path) + ".name")));
- }
- for (final String string : config.getStringList(String.valueOf(path) + ".lore")) {
- this.lore.add(ChatColor.translateAlternateColorCodes('&', string));
- }
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- return this.item;
- }
- @EventHandler
- private void pluginEnableEvent(final PluginEnableEvent event) {
- if (event.getPlugin().getName().equalsIgnoreCase("mcmmmo")) {
- this.mcmmo = "MCMMO";
- }
- else if (event.getPlugin() == RandomPackage.getPlugin) {
- this.api = RandomPackageAPI.getInstance();
- this.enabled = true;
- this.armorlore = CustomArmor.getInstance().armorlores;
- for (final World world : Bukkit.getServer().getWorlds()) {
- if (!world.getGameRuleValue("commandBlockOutput").equals("false")) {
- world.setGameRuleValue("commandBlockOutput", "false");
- }
- if (!world.getGameRuleValue("sendCommandFeedback").equals("false")) {
- world.setGameRuleValue("sendCommandFeedback", "false");
- }
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "rg flag -w " + world.getName() + " __global__ pvp allow");
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "rg flag -w " + world.getName() + " __global__ blockbreak allow");
- }
- this.cemessages = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(String.valueOf(this.folder) + "messages.yml"));
- this.enchantmentsInfo = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(String.valueOf(this.folder) + "info.yml"));
- this.enchantments = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(String.valueOf(this.folder) + "enchantments.yml"));
- this.itemsConfig = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(this.randompackage.getDataFolder() + File.separator + "items.yml"));
- this.messages = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(this.randompackage.getDataFolder() + File.separator + "messages.yml"));
- this.particles = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(this.randompackage.getDataFolder() + File.separator + "particles.yml"));
- this.sounds = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(this.randompackage.getDataFolder() + File.separator + "sounds.yml"));
- String path = null;
- for (int i = 0; i <= 14; ++i) {
- if (i == 0) {
- path = "PlanetaryDeathbringer.multiplied-by";
- }
- else if (i == 1) {
- path = "Rage.multiplied-by";
- }
- else if (i == 2) {
- path = "Aegis.multiplied-by";
- }
- else if (i == 3) {
- path = "Assassin.close";
- }
- else if (i == 4) {
- path = "Assassin.close-damage";
- }
- else if (i == 5) {
- path = "Assassin.far-damage";
- }
- else if (i == 6) {
- path = "Dominate.multiplied-by";
- }
- else if (i == 7) {
- path = "Dominate.duration";
- }
- else if (i == 8) {
- path = "EagleEye.max";
- }
- else if (i == 9) {
- path = "IceFreeze.duration";
- }
- else if (i == 10) {
- path = "Curse.hp";
- }
- else if (i == 11) {
- path = "Leadership.radius";
- }
- else if (i == 12) {
- path = "Leadership.increased-damage";
- }
- else if (i == 13) {
- path = "DimensionRift.cobweb-chance";
- }
- else if (i == 14) {
- path = "DimensionRift.duration";
- }
- if (path != null && this.enchantments.get(path) != null) {
- this.doubles[i] = this.enchantments.getDouble(path);
- }
- }
- path = null;
- for (int i = 0; i <= 3; ++i) {
- if (i == 0) {
- path = "Inquisitive.level-one";
- }
- else if (i == 1) {
- path = "Inquisitive.levels";
- }
- else if (i == 2) {
- path = "MasterInquisitive.level-one";
- }
- else if (i == 3) {
- path = "MasterInquisitive.levels";
- }
- if (path != null && this.enchantments.get(path) != null) {
- this.enchantstrings[i] = this.enchantments.getString(path).toLowerCase();
- }
- }
- path = null;
- this.addpotioneffect = (List<String>)this.messages.getStringList("CustomEnchantments.apply-potion-effect");
- this.removepotioneffect = (List<String>)this.messages.getStringList("CustomEnchantments.remove-potion-effect");
- this.applyinfo = (List<String>)this.messages.getStringList("CustomEnchantments.books.apply-info");
- for (int i = 1; i < this.enchantmessages.length; ++i) {
- if (i == 1) {
- path = "ArrowBreak";
- }
- else if (i == 2) {
- path = "Blacksmith";
- }
- else if (i == 3) {
- path = "Blessed";
- }
- else if (i == 4) {
- path = "BloodLink";
- }
- else if (i == 5) {
- path = "Disarmor";
- }
- else if (i == 6) {
- path = "DivineImmolation";
- }
- else if (i == 7) {
- path = "DoubleStrike";
- }
- else if (i == 8) {
- path = "Dodge";
- }
- else if (i == 9) {
- path = "Enlighted";
- }
- else if (i == 10) {
- path = "Inversion";
- }
- else if (i == 11) {
- path = "KillAura";
- }
- else if (i == 12) {
- path = "NaturesWrath";
- }
- else if (i == 13) {
- path = "Sniper";
- }
- else if (i == 50) {
- path = "Unfocus";
- }
- else if (i == 51) {
- path = "Refocus";
- }
- else {
- path = null;
- }
- if (path != null) {
- this.enchantmessages[i] = this.cemessages.getStringList("enchants." + path);
- }
- }
- this.soulmodeactivate = (List<String>)this.messages.getStringList("Givedp.soul-mode.activate");
- this.soulmodedeactivatedMoved = (List<String>)this.messages.getStringList("Givedp.soul-mode.deactivate.moved");
- this.soulmodedeactivatedDropped = (List<String>)this.messages.getStringList("Givedp.soul-mode.deactivate.dropped");
- this.soulmodedeactivatedInteract = (List<String>)this.messages.getStringList("Givedp.soul-mode.deactivate.interact");
- this.soulmodedeactivatedRanOut = (List<String>)this.messages.getStringList("Givedp.soul-mode.deactivate.ran-out");
- this.alchemistexchange = (List<String>)this.messages.getStringList("Inventories.alchemist.exchange");
- this.alchemistclose = (List<String>)this.messages.getStringList("Inventories.alchemist.close");
- this.tinkereraccept = (List<String>)this.messages.getStringList("Inventories.tinkerer.accept-trade");
- this.tinkerercancelled = (List<String>)this.messages.getStringList("Inventories.tinkerer.cancel-trade");
- this.shootfireworks = this.itemsConfig.getBoolean("shoot-fireworks");
- this.SUCCESS = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("success"));
- this.DESTROY = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("destroy"));
- this.APPLY_TO_ITEM = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("apply"));
- this.WHITE_SCROLL_PROTECTED = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("white-scroll.apply"));
- this.TRANSMOG = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("transmog-scroll.apply"));
- this.ARMOR = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.armor"));
- this.HELMET = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.helmet"));
- this.CHESTPLATE = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.chestplate"));
- this.LEGGINGS = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.leggings"));
- this.BOOTS = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.boots"));
- this.WEAPON = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.weapon"));
- this.SWORD = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.sword"));
- this.AXE = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.axe"));
- this.BOW = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.bow"));
- this.PICKAXE = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.pickaxe"));
- this.TOOL = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("enchant-types.tool"));
- this.configPrefix = ChatColor.translateAlternateColorCodes('&', this.messages.getString("prefix"));
- this.guardiansname = ChatColor.translateAlternateColorCodes('&', this.enchantments.getString("Guardians.name"));
- this.spiritsname = ChatColor.translateAlternateColorCodes('&', this.enchantments.getString("Spirits.name"));
- this.undeadrusename = ChatColor.translateAlternateColorCodes('&', this.enchantments.getString("UndeadRuse.name"));
- for (final String string : this.enchantments.getStringList("Detonate.blacklisted-blocks")) {
- this.detonate.add(string.toUpperCase());
- }
- for (int i = 0; i <= 100; ++i) {
- if (this.itemsConfig.get("rarities." + i + ".name") != null) {
- final String rarity = this.itemsConfig.getString("rarities." + i + ".name").toLowerCase();
- this.customenchantments.put(rarity, new ArrayList<String>());
- this.revealitemsmessages.put(rarity, this.messages.getStringList("CustomEnchantments.books." + rarity));
- this.revealeditemsfirework.put(rarity, this.itemsConfig.getString("rarities." + i + ".revealed-item.firework"));
- this.item = new ItemStack(Material.APPLE, 1);
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (this.itemsConfig.get("rarities." + i + ".reveal-item.lore") != null) {
- this.revealitems.put(rarity, this.setupItem(this.itemsConfig, "rarities." + i + ".reveal-item"));
- }
- if (this.itemsConfig.get("rarities." + i + ".revealed-item.lore") != null) {
- this.revealeditems.put(rarity, this.setupItem(this.itemsConfig, "rarities." + i + ".revealed-item"));
- }
- if (this.itemsConfig.get("rarities." + i + ".revealed-item.apply-format") != null) {
- this.applyformat.put(rarity, ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("rarities." + i + ".revealed-item.apply-format")));
- }
- if (this.itemsConfig.get("rarities." + i + ".regular") != null) {
- this.regulardust.put(rarity, this.setupItem(this.itemsConfig, "rarities." + i + ".regular"));
- this.regulardustchance.put(rarity, this.itemsConfig.getInt("rarities." + i + ".regular.chance"));
- }
- if (this.itemsConfig.get("rarities." + i + ".primal") != null) {
- this.primaldust.put(rarity, this.setupItem(this.itemsConfig, "rarities." + i + ".primal"));
- this.primaldustchance.put(rarity, this.itemsConfig.getInt("rarities." + i + ".primal.chance"));
- }
- if (this.itemsConfig.get("rarities." + i + ".fireball") != null) {
- this.fireballs.put(rarity, this.setupItem(this.itemsConfig, "rarities." + i + ".fireball"));
- }
- }
- }
- RandomPackageEnchants[] values;
- for (int length = (values = RandomPackageEnchants.values()).length, k = 0; k < length; ++k) {
- final RandomPackageEnchants enchant = values[k];
- if (this.enchantments.get("chances." + enchant.name()) != null) {
- this.enchants.put(this.enchantmentsInfo.getString(String.valueOf(enchant.name()) + ".enchant-name"), this.enchantments.getString("chances." + enchant.name()).replace(" ", ""));
- }
- else {
- Bukkit.broadcastMessage(String.valueOf(this.prefix) + ChatColor.RED + "Missing proc chance for enchant " + ChatColor.GRAY + enchant.name());
- }
- String enchantname = null;
- String rarity2 = null;
- if (this.enchantmentsInfo.get(String.valueOf(enchant.name()) + ".enchant-name") != null) {
- enchantname = this.enchantmentsInfo.getString(String.valueOf(enchant.name()) + ".enchant-name");
- }
- else {
- Bukkit.broadcastMessage(String.valueOf(this.prefix) + ChatColor.RED + "Missing enchant-name for enchant " + ChatColor.GRAY + enchant.name());
- }
- if (this.enchantmentsInfo.get(String.valueOf(enchant.name()) + ".rarity") != null) {
- rarity2 = this.enchantmentsInfo.getString(String.valueOf(enchant.name()) + ".rarity").toLowerCase();
- }
- else {
- Bukkit.broadcastMessage(String.valueOf(this.prefix) + ChatColor.RED + "Missing rarity for enchant " + ChatColor.GRAY + enchant.name());
- }
- boolean enabled = false;
- if (this.enchantmentsInfo.get(String.valueOf(enchant.name()) + ".enabled") != null) {
- enabled = this.enchantmentsInfo.getBoolean(String.valueOf(enchant.name()) + ".enabled");
- }
- else {
- Bukkit.broadcastMessage(String.valueOf(this.prefix) + ChatColor.RED + "Missing enabled status for enchant " + ChatColor.GRAY + enchant.name());
- }
- final int maxlevel = this.enchantmentsInfo.getInt(String.valueOf(enchant.name()) + ".max-level");
- ArrayList<String> raritytype = null;
- if (!enabled) {
- raritytype = this.disabledenchantments;
- }
- else {
- raritytype = this.customenchantments.get(rarity2.toLowerCase());
- }
- this.enchantmaxlevel.put(enchantname, maxlevel);
- if (enchant.name().equals("AntiGravity") || enchant.name().equals("Aquatic") || enchant.name().equals("Drunk") || enchant.name().equals("Gears") || enchant.name().equals("Glowing") || enchant.name().equals("Obsidianshield") || enchant.name().equals("Overload") || enchant.name().equals("Springs") || enchant.name().equals("GodlyOverload")) {
- this.potioneffectEnchants.add(enchant.name());
- }
- if (raritytype != null) {
- final int rarityint = this.api.convertStringRarityToIntRarity(rarity2);
- if (!enabled) {
- raritytype.add(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("rarities." + rarityint + ".revealed-item.apply-format").replace("{ENCHANT}", enchantname)));
- }
- else {
- for (int j = 1; j <= maxlevel; ++j) {
- raritytype.add(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("rarities." + rarityint + ".revealed-item.name").replace("{ENCHANT}", String.valueOf(enchantname) + " " + this.replaceIntWithRomanNumerals(j))));
- }
- }
- for (int j = 1; j <= maxlevel; ++j) {
- this.allcustomenchantments.add(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("rarities." + rarityint + ".revealed-item.name").replace("{ENCHANT}", String.valueOf(enchantname) + " " + this.replaceIntWithRomanNumerals(j))));
- }
- }
- }
- if (this.randompackage.getConfig().getBoolean("features.Items.soul-gem")) {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (!CustomEnchantments.this.soulmode.isEmpty()) {
- for (final UUID uuid : CustomEnchantments.this.soulmode) {
- final Player player = Bukkit.getPlayer(uuid);
- if (Bukkit.getVersion().contains("1.8")) {
- player.getWorld().spigot().playEffect(new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY() + 0.5, player.getLocation().getZ()), Effect.FLYING_GLYPH, 0, 0, 0.0f, 1.0f, 1.0f, 1.0f, 100, 0);
- }
- }
- }
- }
- }, 0L, 7L);
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (!CustomEnchantments.this.soulmode.isEmpty()) {
- for (final UUID uuid : CustomEnchantments.this.divineimmolation) {
- final Player player = Bukkit.getPlayer(uuid);
- CustomEnchantments.access$3(CustomEnchantments.this, CustomEnchantments.this.getSoulGemInPlayerInventory(player, false));
- CustomEnchantments.this.depleteSouls(player, CustomEnchantments.this.item, CustomEnchantments.this.getRemainingIntFromString(CustomEnchantments.this.item.getItemMeta().getDisplayName()), 16);
- }
- }
- }
- }, 0L, 20L);
- }
- if (this.enchantmentsInfo.getBoolean("Commander.enabled")) {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- for (final Player player : CustomEnchantments.this.commander.keySet()) {
- for (final String enchant : CustomEnchantments.this.getEnchantmentsOnItem(CustomEnchantments.this.commander.get(player))) {
- if (enchant.split(" ")[0].equals("Commander") && CustomEnchantments.this.random.nextInt(100) <= CustomEnchantments.this.getProckChance("Commander", Integer.parseInt(enchant.split(" ")[1]), player)) {
- CustomEnchantments.this.Commander(player, Integer.parseInt(enchant.split(" ")[1]));
- }
- }
- }
- }
- }, 0L, 200L);
- }
- if (this.enchantmentsInfo.getBoolean("Protection.enabled")) {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- for (final Player player : CustomEnchantments.this.protection.keySet()) {
- for (final String enchant : CustomEnchantments.this.getEnchantmentsOnItem(CustomEnchantments.this.protection.get(player))) {
- if (enchant.split(" ")[0].equals("Protection") && CustomEnchantments.this.random.nextInt(100) <= CustomEnchantments.this.getProckChance("Protection", Integer.parseInt(enchant.split(" ")[1]), player)) {
- CustomEnchantments.this.Protection(player, Integer.parseInt(enchant.split(" ")[1]));
- }
- }
- }
- }
- }, 0L, 200L);
- }
- if (this.enchantmentsInfo.getBoolean("Implants.enabled")) {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- for (final Player player : CustomEnchantments.this.implants.keySet()) {
- for (final String enchant : CustomEnchantments.this.getEnchantmentsOnItem(CustomEnchantments.this.implants.get(player))) {
- if (enchant.split(" ")[0].equals("Implants") && CustomEnchantments.this.random.nextInt(100) <= CustomEnchantments.this.getProckChance("Implants", Integer.parseInt(enchant.split(" ")[1]), player)) {
- CustomEnchantments.this.Implants(player);
- }
- }
- }
- }
- }, 0L, 120L);
- }
- }
- }
- @EventHandler
- private void playerQuitEvent(final PlayerQuitEvent event) {
- if (this.soulmode.contains(event.getPlayer().getUniqueId())) {
- this.soulmode.remove(event.getPlayer().getUniqueId());
- }
- }
- public ItemStack getBook(String rarityOrOEN, int level, final int success, final int destroy) {
- this.item = new ItemStack(Material.APPLE, 1);
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (rarityOrOEN == null) {
- return null;
- }
- String enchant = null;
- String OEN = this.getOriginalEnchantmentName(rarityOrOEN);
- if (OEN != null) {
- enchant = this.enchantmentsInfo.getString(String.valueOf(OEN) + ".enchant-name");
- rarityOrOEN = this.enchantmentsInfo.getString(String.valueOf(OEN) + ".rarity").toLowerCase();
- }
- rarityOrOEN = rarityOrOEN.toLowerCase();
- this.item = this.revealeditems.get(rarityOrOEN).clone();
- List<String> enchantlist = null;
- for (int i = 0; i < this.customenchantments.keySet().size(); ++i) {
- if (this.customenchantments.keySet().toArray()[i].equals(rarityOrOEN)) {
- enchantlist = this.customenchantments.get(rarityOrOEN);
- }
- }
- if (level < 0) {
- level = this.random.nextInt(enchantlist.size());
- }
- if (enchant == null) {
- enchant = enchantlist.get(level);
- OEN = this.getOriginalEnchantmentName(enchant);
- }
- else {
- enchant = this.item.getItemMeta().getDisplayName().replace("{ENCHANT}", String.valueOf(enchant) + " " + this.replaceIntWithRomanNumerals(level));
- }
- final String type = this.enchantmentsInfo.getString(String.valueOf(OEN) + ".enchant-type").toLowerCase();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- for (final String string : this.itemMeta.getLore()) {
- if (string.equals("{SUCCESS}")) {
- this.lore.add(this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(success).toString()));
- }
- else if (string.equals("{DESTROY}")) {
- this.lore.add(this.DESTROY.replace("{PERCENT}", new StringBuilder().append(destroy).toString()));
- }
- else if (string.equals("{BOOK_LORE}")) {
- for (final String STRING : this.enchantmentsInfo.getStringList(String.valueOf(OEN) + ".lore")) {
- this.lore.add(ChatColor.translateAlternateColorCodes('&', STRING));
- }
- }
- else if (string.equals("{ENCHANT_TYPE}")) {
- if (type.equals("armor")) {
- this.lore.add(this.ARMOR);
- }
- else if (type.equals("axe")) {
- this.lore.add(this.AXE);
- }
- else if (type.equals("boots")) {
- this.lore.add(this.BOOTS);
- }
- else if (type.equals("bow")) {
- this.lore.add(this.BOW);
- }
- else if (type.equals("chestplate")) {
- this.lore.add(this.CHESTPLATE);
- }
- else if (type.equals("helmet")) {
- this.lore.add(this.HELMET);
- }
- else if (type.equals("leggings")) {
- this.lore.add(this.LEGGINGS);
- }
- else if (type.equals("pickaxe")) {
- this.lore.add(this.PICKAXE);
- }
- else if (type.equals("sword")) {
- this.lore.add(this.SWORD);
- }
- else if (type.equals("tool")) {
- this.lore.add(this.TOOL);
- }
- else {
- if (!type.equals("weapon")) {
- continue;
- }
- this.lore.add(this.WEAPON);
- }
- }
- else {
- if (!string.equals("{APPLY}")) {
- continue;
- }
- this.lore.add(this.APPLY_TO_ITEM);
- }
- }
- this.itemMeta.setDisplayName(enchant);
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- return this.item;
- }
- private String formatIntUsingCommas(final int integer) {
- return String.format("%,d", integer);
- }
- @EventHandler
- private void inventoryClickEvents(final InventoryClickEvent event) {
- final Player player = (Player)event.getWhoClicked();
- final String title = event.getWhoClicked().getOpenInventory().getTopInventory().getTitle();
- if (title.equals(this.inventories[168].getTitle()) && event.getClick().equals((Object)ClickType.NUMBER_KEY)) {
- event.setCancelled(true);
- player.updateInventory();
- return;
- }
- if (!event.isCancelled() && event.getCurrentItem() != null && !event.getCurrentItem().getType().equals((Object)Material.AIR) && event.getWhoClicked().getOpenInventory() != null && event.getWhoClicked().getOpenInventory().getTopInventory() != null && event.getWhoClicked().getOpenInventory().getTopInventory().getTitle() != null && title.equals(this.inventories[168].getTitle())) {
- event.setCancelled(true);
- player.updateInventory();
- if (event.getClick().equals((Object)ClickType.NUMBER_KEY)) {
- return;
- }
- if (title.equals(this.inventories[168].getTitle())) {
- this.item = new ItemStack(Material.AIR);
- int SLOT = player.getOpenInventory().getTopInventory().firstEmpty();
- if ((player.getOpenInventory().getTopInventory().firstEmpty() == -1 && event.getRawSlot() > player.getOpenInventory().getTopInventory().getMaxStackSize()) || !event.getCurrentItem().hasItemMeta() || (event.getRawSlot() >= 4 && event.getRawSlot() <= 8) || (event.getRawSlot() >= 13 && event.getRawSlot() <= 17) || (event.getRawSlot() >= 22 && event.getRawSlot() <= 26) || (event.getRawSlot() >= 31 && event.getRawSlot() <= 35) || (event.getRawSlot() >= 40 && event.getRawSlot() <= 44) || (event.getRawSlot() >= 49 && event.getRawSlot() <= 53)) {
- return;
- }
- if (event.getCurrentItem().equals((Object)this.items[600])) {
- this.tinkererAccept = true;
- player.closeInventory();
- return;
- }
- if (event.getRawSlot() < player.getOpenInventory().getTopInventory().getSize()) {
- this.giveItem(player, event.getCurrentItem());
- event.setCurrentItem(new ItemStack(Material.AIR));
- SLOT = event.getRawSlot();
- }
- else if (event.getCurrentItem().getType().name().endsWith("HELMET") || event.getCurrentItem().getType().name().endsWith("CHESTPLATE") || event.getCurrentItem().getType().name().endsWith("LEGGINGS") || event.getCurrentItem().getType().name().endsWith("BOOTS") || event.getCurrentItem().getType().name().endsWith("SWORD") || event.getCurrentItem().getType().name().endsWith("AXE") || event.getCurrentItem().getType().name().endsWith("SPADE") || event.getCurrentItem().getType().name().endsWith("HOE") || event.getCurrentItem().getType().name().endsWith("BOW")) {
- int xp = 0;
- for (final Enchantment enchant : event.getCurrentItem().getEnchantments().keySet()) {
- xp += Integer.parseInt(this.enchantmentsInfo.getString("vanilla." + enchant.getName().toLowerCase()));
- }
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- for (final String string : this.getEnchantmentsOnItem(event.getCurrentItem())) {
- xp += Integer.parseInt(this.enchantmentsInfo.getString(String.valueOf(string.split(" ")[0]) + ".tinkerer").split(":")[Integer.parseInt(string.split(" ")[1]) - 1]);
- }
- }
- if (xp != 0) {
- this.item = this.items[10].clone();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (this.item.hasItemMeta() && this.item.getItemMeta().hasLore()) {
- for (String string : this.itemMeta.getLore()) {
- if (string.contains("{AMOUNT}")) {
- string = string.replace("{AMOUNT}", this.formatIntUsingCommas(xp));
- }
- else if (string.contains("{BOTTLER_NAME}")) {
- string = string.replace("{BOTTLER_NAME}", "Tinkerer");
- }
- this.lore.add(string);
- }
- }
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- }
- }
- else {
- if (this.getOriginalEnchantmentName(event.getCurrentItem().getItemMeta().getDisplayName()) == null) {
- return;
- }
- final ItemStack itemstack = this.fireballs.get(this.enchantmentsInfo.getString(String.valueOf(this.getOriginalEnchantmentName(event.getCurrentItem().getItemMeta().getDisplayName())) + ".rarity").toLowerCase());
- if (itemstack == null) {
- return;
- }
- this.item = itemstack.clone();
- }
- int slot = 0;
- if (player.getOpenInventory().getTopInventory().firstEmpty() <= 8) {
- slot = 4;
- }
- else {
- slot = 5;
- }
- player.getOpenInventory().getTopInventory().setItem(SLOT + slot, this.item);
- if (event.getRawSlot() > player.getOpenInventory().getTopInventory().getSize()) {
- player.getOpenInventory().getTopInventory().setItem(player.getOpenInventory().getTopInventory().firstEmpty(), event.getCurrentItem());
- }
- event.setCurrentItem(new ItemStack(Material.AIR));
- }
- player.updateInventory();
- }
- }
- @EventHandler
- private void inventoryCloseEvent(final InventoryCloseEvent event) {
- final Player player = (Player)event.getPlayer();
- if (event.getInventory() != null && event.getInventory().getTitle() != null && event.getInventory().getType().equals((Object)InventoryType.CHEST) && event.getInventory().getHolder() != null && event.getInventory().getHolder().toString().contains(event.getPlayer().getName())) {
- final String title = event.getInventory().getTitle();
- if (title.equals(this.inventories[0].getTitle()) || title.equals(this.inventories[1].getTitle()) || title.equals(this.inventories[168].getTitle())) {
- if (title.equals(this.inventories[0].getTitle())) {
- if (this.alchemistAccept) {
- this.sendStringListMessage(player.getUniqueId(), this.alchemistexchange, 0.0);
- this.alchemistAccept = false;
- }
- else {
- this.sendStringListMessage(player.getUniqueId(), this.alchemistclose, 0.0);
- }
- }
- else if (title.equals(this.inventories[168].getTitle())) {
- if (this.tinkererAccept) {
- this.sendStringListMessage(player.getUniqueId(), this.tinkereraccept, 0.0);
- this.tinkererAccept = false;
- for (int i = 0; i < event.getInventory().getSize(); ++i) {
- if (event.getInventory().getItem(i) != null && ((i >= 5 && i <= 7) || (i >= 14 && i <= 17) || (i >= 23 && i <= 26) || (i >= 32 && i <= 35) || (i >= 41 && i <= 44) || (i >= 50 && i <= 53))) {
- this.giveItem(player, event.getInventory().getItem(i));
- }
- }
- }
- else {
- this.sendStringListMessage(player.getUniqueId(), this.tinkerercancelled, 0.0);
- for (int i = 0; i < event.getInventory().getSize(); ++i) {
- if (event.getInventory().getItem(i) != null && ((i >= 1 && i <= 3) || (i >= 9 && i <= 12) || (i >= 18 && i <= 21) || (i >= 27 && i <= 30) || (i >= 36 && i <= 39) || (i >= 45 && i <= 48))) {
- this.giveItem(player, event.getInventory().getItem(i));
- }
- }
- }
- }
- if (player.isOnline()) {
- player.updateInventory();
- }
- }
- }
- }
- private ItemStack getItemInHand(final Player player) {
- if (Bukkit.getVersion().contains("1.7") || Bukkit.getVersion().contains("1.8")) {
- return player.getInventory().getItemInHand();
- }
- return player.getInventory().getItemInMainHand();
- }
- private void giveItem(final Player player, final ItemStack is) {
- if (player.getInventory().firstEmpty() < 0 && !is.hasItemMeta() && player.getInventory().getItem(player.getInventory().first(new ItemStack(is.getType(), player.getInventory().getItem(player.getInventory().first(is.getType())).getAmount(), (short)is.getData().getData()))).getAmount() > is.getMaxStackSize()) {
- player.getWorld().dropItem(player.getLocation(), is);
- }
- else if (player.getInventory().firstEmpty() == -1) {
- player.getWorld().dropItem(player.getLocation(), is);
- }
- else {
- player.getInventory().addItem(new ItemStack[] { is });
- player.updateInventory();
- }
- }
- private void removeItem(final Player player, final ItemStack is, final int removeAmount) {
- for (int i = 0; i < player.getInventory().getSize(); ++i) {
- if (player.getInventory().getItem(i) != null && player.getInventory().getItem(i).getData().getData() == is.getData().getData() && player.getInventory().getItem(i).getType().equals((Object)is.getType()) && (!is.hasItemMeta() || (is.hasItemMeta() && is.getItemMeta().equals(player.getInventory().getItem(i).getItemMeta())))) {
- for (int z = 1; z <= removeAmount; ++z) {
- if (player.getInventory().getItem(i).getAmount() == 1) {
- player.getInventory().setItem(i, new ItemStack(Material.AIR));
- }
- else {
- player.getInventory().getItem(i).setAmount(player.getInventory().getItem(i).getAmount() - 1);
- }
- }
- return;
- }
- }
- player.updateInventory();
- }
- private void sendStringListMessage(final UUID uuid, final List<String> message, final double d) {
- final Player player = Bukkit.getPlayer(uuid);
- if (message.size() > 0 && !message.get(0).equals("")) {
- for (String string : message) {
- if (string.contains("{PREFIX}")) {
- string = string.replace("{PREFIX}", this.configPrefix);
- }
- if (string.contains("{AMOUNT}")) {
- string = string.replace("{AMOUNT}", Double.toString(d));
- }
- string = ChatColor.translateAlternateColorCodes('&', string);
- if (player == null) {
- Bukkit.getConsoleSender().sendMessage(string);
- }
- else {
- player.sendMessage(string);
- }
- }
- }
- }
- private int getRemainingIntFromString(String string) {
- string = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', string)).replaceAll("\\p{L}", "").replaceAll("\\s", "").replaceAll("\\p{P}", "").replaceAll("\\p{S}", "");
- if (string == null || string.equals("")) {
- return -1;
- }
- return Integer.parseInt(string);
- }
- private String getSoulGemColors(final int soulgemAmount) {
- if (soulgemAmount < 100) {
- return ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("soul-gem.colors.less-than-100"));
- }
- int last = 0;
- for (int i = 100; i <= 60000000; i += 100) {
- if (this.itemsConfig.get("soul-gem.colors." + i + "s") != null) {
- last = i;
- }
- if (soulgemAmount >= last && soulgemAmount <= i + 100) {
- return ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("soul-gem.colors." + last + "s"));
- }
- }
- return ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("soul-gem.colors.else"));
- }
- public ArrayList<String> getEnchantmentsOnItem(final ItemStack is) {
- final ArrayList<String> enchants = new ArrayList<String>();
- if (is != null && !is.getType().equals((Object)Material.AIR) && is.hasItemMeta() && is.getItemMeta().hasLore()) {
- for (final String string : is.getItemMeta().getLore()) {
- if (string.split(" ").length - 1 != -1) {
- for (final String enchant : this.enchants.keySet()) {
- if (ChatColor.stripColor(string).startsWith(enchant)) {
- final String level = string.split(" ")[string.split(" ").length - 1].replace("IX", "9").replace("X", "10").replace("VIII", "8").replace("VII", "7").replace("VI", "6").replace("IV", "4").replace("V", "5").replace("III", "3").replace("II", "2").replace("I", "1").replace("\\p{L}", "").replace("\\p{M}", "").replace("\\p{Sc}", "").replace("\\p{Sk}", "").replace("\\p{So}", "").replace("\\p{Nl}", "").replace("\\p{No}", "");
- if (this.parseInt(level) == null) {
- continue;
- }
- enchants.add(String.valueOf(this.getOriginalEnchantmentName(enchant.replace(" ", ""))) + " " + level);
- }
- }
- }
- }
- }
- return enchants;
- }
- private Integer parseInt(final String input) {
- try {
- return Integer.parseInt(input);
- }
- catch (NumberFormatException e) {
- return null;
- }
- }
- public String getEnchantmentRarity(final String string) {
- final String OEN = this.getOriginalEnchantmentName(string);
- if (OEN != null) {
- return this.enchantmentsInfo.getString(String.valueOf(OEN) + ".rarity").toLowerCase();
- }
- return null;
- }
- public String getOriginalEnchantmentName(String string) {
- string = ChatColor.stripColor(string);
- if (this.enchantmentsInfo.get(String.valueOf(string) + ".enchant-name") != null) {
- return string;
- }
- RandomPackageEnchants[] values;
- for (int length = (values = RandomPackageEnchants.values()).length, i = 0; i < length; ++i) {
- final RandomPackageEnchants enchant = values[i];
- if (string.toLowerCase().replace(" ", "").startsWith(enchant.name().toLowerCase()) || string.toLowerCase().replace(" ", "").startsWith(this.enchantmentsInfo.getString(String.valueOf(enchant.name()) + ".enchant-name").toLowerCase().replace(" ", ""))) {
- return enchant.name();
- }
- }
- return null;
- }
- private int getTotalExperience(final Player player) {
- int experience = 0;
- final int level = player.getLevel();
- if (level >= 0 && level <= 15) {
- experience = (int)Math.ceil(Math.pow(level, 2.0) + 6 * level);
- final int requiredExperience = 2 * level + 7;
- final double currentExp = Double.parseDouble(Float.toString(player.getExp()));
- experience += (int)Math.ceil(currentExp * requiredExperience);
- return experience;
- }
- if (level > 15 && level <= 30) {
- experience = (int)Math.ceil(2.5 * Math.pow(level, 2.0) - 40.5 * level + 360.0);
- final int requiredExperience = 5 * level - 38;
- final double currentExp = Double.parseDouble(Float.toString(player.getExp()));
- experience += (int)Math.ceil(currentExp * requiredExperience);
- return experience;
- }
- experience = (int)Math.ceil(4.5 * Math.pow(level, 2.0) - 162.5 * level + 2220.0);
- final int requiredExperience = 9 * level - 158;
- final double currentExp = Double.parseDouble(Float.toString(player.getExp()));
- experience += (int)Math.ceil(currentExp * requiredExperience);
- return experience;
- }
- private void setTotalExperience(final Player player, final int xp) {
- if (xp >= 0 && xp < 351) {
- final int a = 1;
- final int b = 6;
- final int c = -xp;
- final int level = (int)(-b + Math.sqrt(Math.pow(b, 2.0) - 4 * a * c)) / (2 * a);
- final int xpForLevel = (int)(Math.pow(level, 2.0) + 6 * level);
- final int remainder = xp - xpForLevel;
- final int experienceNeeded = 2 * level + 7;
- float experience = remainder / experienceNeeded;
- experience = this.round(experience, 2);
- player.setLevel(level);
- player.setExp(experience);
- }
- else if (xp >= 352 && xp < 1507) {
- final double a2 = 2.5;
- final double b2 = -40.5;
- final int c2 = -xp + 360;
- final double dLevel = (-b2 + Math.sqrt(Math.pow(b2, 2.0) - 4.0 * a2 * c2)) / (2.0 * a2);
- final int level2 = (int)Math.floor(dLevel);
- final int xpForLevel2 = (int)(2.5 * Math.pow(level2, 2.0) - 40.5 * level2 + 360.0);
- final int remainder2 = xp - xpForLevel2;
- final int experienceNeeded2 = 5 * level2 - 38;
- float experience2 = remainder2 / experienceNeeded2;
- experience2 = this.round(experience2, 2);
- player.setLevel(level2);
- player.setExp(experience2);
- }
- else {
- final double a2 = 4.5;
- final double b2 = -162.5;
- final int c2 = -xp + 2220;
- final double dLevel = (-b2 + Math.sqrt(Math.pow(b2, 2.0) - 4.0 * a2 * c2)) / (2.0 * a2);
- final int level2 = (int)Math.floor(dLevel);
- final int xpForLevel2 = (int)(4.5 * Math.pow(level2, 2.0) - 162.5 * level2 + 2220.0);
- final int remainder2 = xp - xpForLevel2;
- final int experienceNeeded2 = 9 * level2 - 158;
- float experience2 = remainder2 / experienceNeeded2;
- experience2 = this.round(experience2, 2);
- player.setLevel(level2);
- player.setExp(experience2);
- }
- }
- private float round(final float d, final int decimalPlace) {
- BigDecimal bd = new BigDecimal(Float.toString(d));
- bd = bd.setScale(decimalPlace, 5);
- return bd.floatValue();
- }
- private int getEnchantmentLevel(String string) {
- string = string.split(" ")[string.split(" ").length - 1].toLowerCase().replace("i", "1").replace("v", "2").replace("x", "3").replaceAll("\\p{L}", "").replace("1", "i").replace("2", "v").replace("3", "x").replaceAll("\\p{N}", "").replaceAll("\\p{P}", "").replaceAll("\\p{S}", "").replaceAll("\\p{M}", "").replaceAll("\\p{Z}", "");
- if (string.equals("i")) {
- return 1;
- }
- if (string.equals("ii")) {
- return 2;
- }
- if (string.equals("iii")) {
- return 3;
- }
- if (string.equals("iv")) {
- return 4;
- }
- if (string.equals("v")) {
- return 5;
- }
- if (string.equals("vi")) {
- return 6;
- }
- if (string.equals("vii")) {
- return 7;
- }
- if (string.equals("viii")) {
- return 8;
- }
- if (string.equals("ix")) {
- return 9;
- }
- if (string.equals("x")) {
- return 10;
- }
- if (string.equals("xi")) {
- return 11;
- }
- if (string.equals("xii")) {
- return 12;
- }
- if (string.equals("xiii")) {
- return 13;
- }
- if (string.equals("xiv")) {
- return 14;
- }
- if (string.equals("xv")) {
- return 15;
- }
- if (string.equals("xvi")) {
- return 16;
- }
- if (string.equals("xvii")) {
- return 17;
- }
- if (string.equals("xviii")) {
- return 18;
- }
- if (string.equals("xix")) {
- return 19;
- }
- if (string.equals("xx")) {
- return 20;
- }
- return -1;
- }
- private String replaceIntWithRomanNumerals(final int integer) {
- if (integer == 1) {
- return "I";
- }
- if (integer == 2) {
- return "II";
- }
- if (integer == 3) {
- return "III";
- }
- if (integer == 4) {
- return "IV";
- }
- if (integer == 5) {
- return "V";
- }
- if (integer == 6) {
- return "VI";
- }
- if (integer == 7) {
- return "VII";
- }
- if (integer == 8) {
- return "VIII";
- }
- if (integer == 9) {
- return "IX";
- }
- if (integer == 10) {
- return "X";
- }
- if (integer == 11) {
- return "XI";
- }
- if (integer == 12) {
- return "XII";
- }
- if (integer == 13) {
- return "XIII";
- }
- if (integer == 14) {
- return "XIV";
- }
- if (integer == 15) {
- return "XV";
- }
- if (integer == 16) {
- return "XVI";
- }
- if (integer == 17) {
- return "XVII";
- }
- if (integer == 18) {
- return "XVIII";
- }
- if (integer == 19) {
- return "XIX";
- }
- if (integer == 20) {
- return "XX";
- }
- return null;
- }
- private Color getColor(final String path) {
- if (path == null) {
- return null;
- }
- if (path.equalsIgnoreCase("aqua")) {
- return Color.AQUA;
- }
- if (path.equalsIgnoreCase("black")) {
- return Color.BLACK;
- }
- if (path.equalsIgnoreCase("blue")) {
- return Color.BLUE;
- }
- if (path.equalsIgnoreCase("fuchsia")) {
- return Color.FUCHSIA;
- }
- if (path.equalsIgnoreCase("gray")) {
- return Color.GRAY;
- }
- if (path.equalsIgnoreCase("green")) {
- return Color.GREEN;
- }
- if (path.equalsIgnoreCase("lime")) {
- return Color.LIME;
- }
- if (path.equalsIgnoreCase("maroon")) {
- return Color.MAROON;
- }
- if (path.equalsIgnoreCase("navy")) {
- return Color.NAVY;
- }
- if (path.equalsIgnoreCase("olive")) {
- return Color.OLIVE;
- }
- if (path.equalsIgnoreCase("orange")) {
- return Color.ORANGE;
- }
- if (path.equalsIgnoreCase("purple")) {
- return Color.PURPLE;
- }
- if (path.equalsIgnoreCase("red")) {
- return Color.RED;
- }
- if (path.equalsIgnoreCase("silver")) {
- return Color.SILVER;
- }
- if (path.equalsIgnoreCase("teal")) {
- return Color.TEAL;
- }
- if (path.equalsIgnoreCase("white")) {
- return Color.WHITE;
- }
- if (path.equalsIgnoreCase("yellow")) {
- return Color.YELLOW;
- }
- return null;
- }
- public int getProckChance(final String OEN, final int level, final Player player) {
- String chancestring = null;
- if (this.enchantments.get("chances." + OEN) != null) {
- chancestring = this.enchantments.getString("chances." + OEN).replace(" ", "").toLowerCase().replace("level", new StringBuilder().append(level).toString());
- }
- else {
- chancestring = OEN.replace(" ", "").replace("level", new StringBuilder().append(level).toString());
- }
- int lucky = 0;
- if (chancestring.contains("lucky") && player != null) {
- boolean did = false;
- ItemStack[] armorContents;
- for (int length = (armorContents = player.getInventory().getArmorContents()).length, j = 0; j < length; ++j) {
- final ItemStack is = armorContents[j];
- if (!did && is != null && is.hasItemMeta() && is.getItemMeta().hasLore()) {
- for (final String string : is.getItemMeta().getLore()) {
- if (ChatColor.stripColor(string).startsWith(this.enchantmentsInfo.getString("Lucky.enchant-name"))) {
- did = true;
- lucky = Integer.parseInt(this.enchantments.getString("chances.Lucky").toLowerCase().replace("level", new StringBuilder().append(this.getEnchantmentLevel(string)).toString()));
- }
- }
- }
- }
- }
- chancestring = chancestring.replace("lucky", new StringBuilder().append(lucky).toString()).replace("\\p{L}", "");
- String parentheses = null;
- int prockchance = 0;
- if (chancestring.contains("(") && chancestring.contains(")")) {
- for (int z = 1; z <= 5; ++z) {
- int startp = -1;
- int endp = -1;
- for (int i = 0; i < chancestring.length(); ++i) {
- if (chancestring.substring(i, i + 1).equals("(")) {
- startp = i;
- }
- else if (chancestring.substring(i, i + 1).equals(")")) {
- endp = i + 1;
- }
- if (startp != -1 && endp != -1) {
- parentheses = chancestring.substring(startp, endp);
- prockchance = this.evaluate(parentheses.substring(1, parentheses.length() - 1));
- chancestring = chancestring.replace(parentheses, new StringBuilder().append(prockchance).toString());
- if (chancestring.endsWith("+") || chancestring.endsWith("-") || chancestring.endsWith("*") || chancestring.endsWith("/")) {
- chancestring = chancestring.substring(0, chancestring.length() - 1);
- }
- if (chancestring.startsWith("+") || chancestring.startsWith("-") || chancestring.startsWith("*") || chancestring.startsWith("/")) {
- chancestring = chancestring.substring(1);
- }
- startp = -1;
- endp = -1;
- }
- }
- }
- }
- return this.evaluate(chancestring);
- }
- private int evaluate(String input) {
- int chance = 0;
- for (int i = 1; i <= 5; ++i) {
- String sign = null;
- if (input.contains("*")) {
- sign = String.valueOf(input.split("\\*")[0]) + "*" + input.split("\\*")[1];
- chance = Math.multiplyExact(Integer.parseInt(input.split("\\*")[0]), Integer.parseInt(input.split("\\*")[1]));
- }
- else if (input.contains("/")) {
- sign = String.valueOf(input.split("\\/")[0]) + "/" + input.split("\\/")[1];
- chance = Math.floorDiv(Integer.parseInt(input.split("\\/")[0]), Integer.parseInt(input.split("\\/")[1]));
- }
- else if (input.contains("+")) {
- sign = String.valueOf(input.split("\\+")[0]) + "+" + input.split("\\+")[1];
- chance = Math.addExact(Integer.parseInt(input.split("\\+")[0]), Integer.parseInt(input.split("\\+")[1]));
- }
- else if (input.contains("-")) {
- sign = String.valueOf(input.split("\\-")[0]) + "-" + input.split("\\-")[1];
- chance = Math.subtractExact(Integer.parseInt(input.split("\\-")[0]), Integer.parseInt(input.split("\\-")[1]));
- }
- else if (Integer.valueOf(input) != null) {
- return Integer.valueOf(input);
- }
- if (sign != null) {
- input = input.replace(sign, new StringBuilder().append(chance).toString());
- }
- }
- return chance;
- }
- private void givePotionEffects(final LivingEntity damager, final Player victim, final String OEN, final int level) {
- int clarity = -1;
- int metaphysical = -1;
- if (victim != null) {
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, j = 0; j < length; ++j) {
- final ItemStack is = armorContents[j];
- if (is != null && is.hasItemMeta() && is.getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(is)) {
- final String OEn = enchant.split(" ")[0];
- if (OEn.equals("Clarity")) {
- if (Integer.parseInt(enchant.split(" ")[1]) <= clarity) {
- continue;
- }
- clarity = Integer.parseInt(enchant.split(" ")[1]);
- }
- else {
- if (!OEn.equals("Metaphysical")) {
- continue;
- }
- metaphysical = this.getProckChance("Metaphysical", Integer.parseInt(enchant.split(" ")[1]), victim);
- }
- }
- }
- }
- }
- for (int i = 0; i <= 10; ++i) {
- if (this.enchantments.get(String.valueOf(OEN) + ".potion-effects." + i) != null) {
- final String[] string = this.enchantments.getString(String.valueOf(OEN) + ".potion-effects." + i).toLowerCase().split("\\:");
- PotionEffect effect = new PotionEffect(this.getPotionEffectType(string[0]), this.getProckChance(string[2].replace(" ", "").replace("level", new StringBuilder().append(level).toString()), -1, null), this.getProckChance(string[1].replace(" ", "").replace("level", new StringBuilder().append(level).toString()), -1, null));
- if (damager != null) {
- damager.addPotionEffect(effect);
- }
- if (victim != null) {
- if (effect.getType().equals((Object)PotionEffectType.BLINDNESS) && clarity >= effect.getAmplifier() + 1) {
- effect = null;
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + victim.getName() + " ~ ~ ~ particle cloud " + victim.getEyeLocation().getX() + " " + (victim.getEyeLocation().getY() + 0.65) + " " + victim.getEyeLocation().getZ() + " 0.3 0.2 0.3 0 10");
- }
- if (effect.getType().equals((Object)PotionEffectType.SLOW) && metaphysical != -1 && this.random.nextInt(100) <= metaphysical) {
- effect = null;
- for (int o = 1; o <= 5; ++o) {
- victim.getWorld().playEffect(victim.getEyeLocation(), Effect.BOW_FIRE, 1);
- }
- }
- if (effect != null) {
- victim.addPotionEffect(effect);
- }
- }
- }
- }
- }
- private PotionEffectType getPotionEffectType(String string) {
- string = string.toLowerCase();
- if (string.startsWith("f")) {
- return PotionEffectType.FIRE_RESISTANCE;
- }
- if (string.startsWith("i")) {
- return PotionEffectType.INVISIBILITY;
- }
- if (string.startsWith("st") || string.equalsIgnoreCase("increase_damage")) {
- return PotionEffectType.INCREASE_DAMAGE;
- }
- if (string.startsWith("wa")) {
- return PotionEffectType.WATER_BREATHING;
- }
- if (string.startsWith("reg")) {
- return PotionEffectType.REGENERATION;
- }
- if (string.startsWith("sp")) {
- return PotionEffectType.SPEED;
- }
- if (string.startsWith("po")) {
- return PotionEffectType.POISON;
- }
- if (string.startsWith("instanth") || string.equals("heal")) {
- return PotionEffectType.HEAL;
- }
- if (string.startsWith("n")) {
- return PotionEffectType.NIGHT_VISION;
- }
- if (string.startsWith("we")) {
- return PotionEffectType.WEAKNESS;
- }
- if (string.startsWith("sl")) {
- return PotionEffectType.SLOW;
- }
- if (string.startsWith("m") || string.equals("mining_fatigue")) {
- return PotionEffectType.SLOW_DIGGING;
- }
- if (string.startsWith("j")) {
- return PotionEffectType.JUMP;
- }
- if (string.startsWith("healt")) {
- return PotionEffectType.HEALTH_BOOST;
- }
- if (string.startsWith("dam") || string.startsWith("dmg")) {
- return PotionEffectType.DAMAGE_RESISTANCE;
- }
- if (string.startsWith("wi")) {
- return PotionEffectType.WITHER;
- }
- if (string.startsWith("bl")) {
- return PotionEffectType.BLINDNESS;
- }
- if (string.startsWith("ab")) {
- return PotionEffectType.ABSORPTION;
- }
- if (string.startsWith("co")) {
- return PotionEffectType.CONFUSION;
- }
- if (string.startsWith("has")) {
- return PotionEffectType.FAST_DIGGING;
- }
- if (string.startsWith("har")) {
- return PotionEffectType.HARM;
- }
- if (string.startsWith("hu")) {
- return PotionEffectType.HUNGER;
- }
- if (string.startsWith("sa")) {
- return PotionEffectType.SATURATION;
- }
- Bukkit.broadcastMessage(string);
- return null;
- }
- public int convertStringRarityToIntRarity(final String rarity) {
- for (int i = 0; i < this.revealitems.size(); ++i) {
- if (this.revealitems.keySet().toArray()[i].equals(rarity)) {
- return i;
- }
- }
- return -1;
- }
- public String getRevealItemRarity(final ItemStack is) {
- if (is != null && is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
- for (int i = 0; i < this.revealitems.size(); ++i) {
- if (is.getItemMeta().equals(this.revealitems.get(this.revealitems.keySet().toArray()[i]).getItemMeta())) {
- return this.revealitems.keySet().toArray()[i].toString();
- }
- }
- }
- return null;
- }
- public ItemStack getFireballRarity(final ItemStack is) {
- if (is != null && is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
- int i = 0;
- while (i < this.fireballs.size()) {
- if (this.fireballs.values().toArray()[i] != null && is.getItemMeta().equals(((ItemStack)this.fireballs.values().toArray()[i]).getItemMeta())) {
- if (this.random.nextInt(100) <= (int)this.primaldustchance.values().toArray()[i]) {
- return ((ItemStack)this.primaldust.values().toArray()[i]).clone();
- }
- if (this.random.nextInt(100) <= (int)this.regulardustchance.values().toArray()[i]) {
- return ((ItemStack)this.regulardust.values().toArray()[i]).clone();
- }
- return this.items[20].clone();
- }
- else {
- ++i;
- }
- }
- }
- return null;
- }
- private void getAndPlaySound(final Player player, final Location location, final String path, final boolean globalSound) {
- if (Bukkit.getVersion().contains("1.8") && this.sounds.get("1.8.8." + path + ".sound") != null) {
- player.playSound(player.getLocation(), Sound.valueOf(this.sounds.getString("1.8.8." + path + ".sound").toUpperCase()), (float)this.sounds.getInt("1.8.8." + path + ".volume"), (float)this.sounds.getInt("1.8.8." + path + ".pitch"));
- }
- else if (this.sounds.get("1.9+." + path + ".sound") != null) {
- player.playSound(player.getLocation(), Sound.valueOf(this.sounds.getString("1.9+." + path + ".sound").toUpperCase()), (float)this.sounds.getInt("1.9+." + path + ".volume"), (float)this.sounds.getInt("1.9+." + path + ".pitch"));
- }
- }
- private void playSuccess(final Player player) {
- this.getAndPlaySound(player, player.getLocation(), "success-and-destroy.success", false);
- for (int i = 1; i <= 15; ++i) {
- player.getWorld().playEffect(player.getEyeLocation(), Effect.SPELL, 1);
- }
- }
- private void playDestroy(final Player player) {
- this.getAndPlaySound(player, player.getLocation(), "success-and-destroy.destroy", false);
- for (int i = 1; i <= 15; ++i) {
- player.getWorld().playEffect(player.getEyeLocation(), Effect.LAVA_POP, 1);
- }
- }
- private RandomPackage.RPItem checkItemStackForRPItem(final ItemStack is) {
- if (is == null || is.getType().equals((Object)Material.AIR) || !is.hasItemMeta() || !is.getItemMeta().hasLore()) {
- return null;
- }
- if (this.items[0] != null && is.getItemMeta().equals(this.items[0].getItemMeta())) {
- return RandomPackage.RPItem.ARMOR_ENCHANTMENT_ORB;
- }
- if (is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[1].getItemMeta().getDisplayName())) {
- return RandomPackage.RPItem.BLACK_SCROLL;
- }
- if (is.getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore())) {
- return RandomPackage.RPItem.SOUL_GEM;
- }
- if (is.getItemMeta().equals(this.items[25].getItemMeta())) {
- return RandomPackage.RPItem.TRANSMOG_SCROLL;
- }
- if ((this.items[39] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[39].getItemMeta().getDisplayName())) || (this.items[40] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[40].getItemMeta().getDisplayName())) || (this.items[41] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[41].getItemMeta().getDisplayName())) || (this.items[42] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[42].getItemMeta().getDisplayName())) || (this.items[43] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[43].getItemMeta().getDisplayName()))) {
- return RandomPackage.RPItem.WEAPON_ENCHANTMENT_ORB;
- }
- if ((this.items[140] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[140].getItemMeta().getDisplayName())) || (this.items[141] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[141].getItemMeta().getDisplayName())) || (this.items[142] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[142].getItemMeta().getDisplayName())) || (this.items[143] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[143].getItemMeta().getDisplayName())) || (this.items[144] != null && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equals(this.items[144].getItemMeta().getDisplayName()))) {
- return RandomPackage.RPItem.ARMOR_ENCHANTMENT_ORB;
- }
- if (is.getItemMeta().equals(this.items[27].getItemMeta())) {
- return RandomPackage.RPItem.WHITE_SCROLL;
- }
- return null;
- }
- private int getSoulTrackerItemStackRarity(final ItemMeta itemmeta) {
- for (int i = 0; i < this.soultrackers.size(); ++i) {
- if (this.soultrackers.get(i).hasItemMeta() && this.soultrackers.get(i).getItemMeta().equals(itemmeta)) {
- return i;
- }
- }
- return -1;
- }
- private String getRandomizationScrollRarity(final ItemMeta itemmeta) {
- for (int i = 0; i < this.randomizationscrolls.size(); ++i) {
- if (this.randomizationscrolls.get(i) != null && itemmeta.equals(this.randomizationscrolls.get(i).getItemMeta())) {
- return this.randomizationscrollrarities.get(i);
- }
- }
- return null;
- }
- private String getDustRarity(final ItemStack itemstack) {
- if (itemstack != null && itemstack.hasItemMeta() && itemstack.getItemMeta().hasDisplayName() && itemstack.getItemMeta().hasLore()) {
- for (int i = 0; i < this.primaldust.size(); ++i) {
- if (((ItemStack)this.primaldust.values().toArray()[i]).getItemMeta().getDisplayName().equals(itemstack.getItemMeta().getDisplayName())) {
- return this.primaldust.keySet().toArray()[i] + "-primal";
- }
- }
- for (int i = 0; i < this.regulardust.size(); ++i) {
- if (((ItemStack)this.regulardust.values().toArray()[i]).getItemMeta().getDisplayName().equals(itemstack.getItemMeta().getDisplayName())) {
- return this.regulardust.keySet().toArray()[i] + "-regular";
- }
- }
- return null;
- }
- return null;
- }
- private void applyEnchantmentOrb(final InventoryClickEvent event, final String type) {
- int previous = -1;
- int j = 38;
- if (type.equals("armor-enchantment-orb")) {
- j = 139;
- }
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- for (int i = 1; i <= 5; ++i) {
- if (this.itemsConfig.get(String.valueOf(type) + "." + i) != null && this.items[j + i] != null && ((this.itemsConfig.get(String.valueOf(type) + "." + (i - 1)) == null && i == 1) || (this.itemsConfig.get(String.valueOf(type) + "." + (i - 1)) != null && event.getCurrentItem().getItemMeta().getLore().contains(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString(String.valueOf(type) + ".apply").replace("{SLOTS}", new StringBuilder().append(this.itemsConfig.getInt(String.valueOf(type) + "." + (i - 1) + ".slots")).toString()).replace("{ADD_SLOTS}", new StringBuilder().append(i - 1).toString())))))) {
- previous = i - 1;
- }
- }
- }
- else {
- previous = 0;
- }
- for (int i = 0; i <= 4; ++i) {
- if (previous == i && !event.getCursor().getItemMeta().getDisplayName().equals(this.items[j + 1 + i].getItemMeta().getDisplayName())) {
- return;
- }
- }
- this.item = event.getCurrentItem();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (this.itemMeta.hasLore()) {
- this.lore.addAll(this.itemMeta.getLore());
- }
- int percent = -1;
- ++previous;
- for (int k = 0; k < this.itemsConfig.getStringList(String.valueOf(type) + "." + previous + ".lore").size(); ++k) {
- if (this.itemsConfig.getStringList(String.valueOf(type) + "." + previous + ".lore").get(k).contains("{PERCENT}")) {
- percent = this.getRemainingIntFromString(event.getCursor().getItemMeta().getLore().get(k));
- }
- }
- --previous;
- if (this.random.nextInt(100) <= percent) {
- if (previous == 0) {
- this.lore.add(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString(String.valueOf(type) + ".apply").replace("{SLOTS}", new StringBuilder().append(this.itemsConfig.getInt(String.valueOf(type) + ".1.slots")).toString()).replace("{ADD_SLOTS}", new StringBuilder().append(previous + 1).toString())));
- }
- else {
- boolean did = false;
- for (int l = 0; l < this.lore.size(); ++l) {
- if (!did && this.lore.get(l).equals(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString(String.valueOf(type) + ".apply").replace("{SLOTS}", new StringBuilder().append(this.itemsConfig.getInt(String.valueOf(type) + "." + previous + ".slots")).toString()).replace("{ADD_SLOTS}", new StringBuilder().append(previous).toString())))) {
- did = true;
- this.lore.set(l, ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString(String.valueOf(type) + ".apply").replace("{SLOTS}", new StringBuilder().append(this.itemsConfig.getInt(String.valueOf(type) + "." + (previous + 1) + ".slots")).toString()).replace("{ADD_SLOTS}", new StringBuilder().append(previous + 1).toString())));
- }
- }
- if (!did) {
- return;
- }
- }
- this.playSuccess((Player)event.getWhoClicked());
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- event.setCancelled(true);
- event.setCurrentItem(this.item);
- if (event.getCursor().getAmount() == 1) {
- event.setCursor(new ItemStack(Material.AIR));
- }
- else {
- event.getCursor().setAmount(event.getCursor().getAmount() - 1);
- }
- ((Player)event.getWhoClicked()).updateInventory();
- return;
- }
- this.playDestroy((Player)event.getWhoClicked());
- event.getWhoClicked().sendMessage("[CustomEnchantments] previous=" + previous + "; percent=" + percent + " - Report how you got this to RandomHashTags!");
- }
- @EventHandler
- private void inventoryClickEvent(final InventoryClickEvent event) {
- if (event.isCancelled()) {
- return;
- }
- if (event.getWhoClicked().getOpenInventory().getTopInventory().getType().equals((Object)InventoryType.ANVIL)) {
- if ((event.getCurrentItem() != null && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().hasLore()) || event.getClick().equals((Object)ClickType.NUMBER_KEY)) {
- String OEN = null;
- if (event.getClick().equals((Object)ClickType.NUMBER_KEY) && event.getWhoClicked().getInventory().getItem(event.getHotbarButton()) != null) {
- this.item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton());
- if (this.item.hasItemMeta() && this.item.getItemMeta().hasDisplayName()) {
- OEN = this.getOriginalEnchantmentName(this.item.getItemMeta().getDisplayName());
- }
- }
- else {
- this.item = event.getCurrentItem();
- OEN = this.getOriginalEnchantmentName(event.getCurrentItem().getItemMeta().getDisplayName());
- }
- if (OEN != null && (this.allcustomenchantments.contains(this.item.getItemMeta().getDisplayName()) || this.getEnchantmentLevel(this.item.getItemMeta().getDisplayName()) > this.enchantmentsInfo.getInt(String.valueOf(OEN) + ".max-level"))) {
- event.setCancelled(true);
- ((Player)event.getWhoClicked()).updateInventory();
- event.getWhoClicked().closeInventory();
- }
- }
- return;
- }
- if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals((Object)Material.AIR)) {
- return;
- }
- if (event.getInventory().getType().equals((Object)InventoryType.CRAFTING) || event.getInventory().getType().equals((Object)InventoryType.PLAYER)) {
- boolean success = false;
- int enchantcount = -1;
- if (this.checkItemStackForRPItem(event.getCursor()) != null || (event.getCursor().hasItemMeta() && this.getRandomizationScrollRarity(event.getCursor().getItemMeta()) != null) || (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore() && event.getCurrentItem().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore()) && this.soulmode.contains(event.getWhoClicked().getUniqueId()))) {
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore() && event.getCurrentItem().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore()) && this.soulmode.contains(event.getWhoClicked().getUniqueId())) {
- this.soulmode.remove(event.getWhoClicked().getUniqueId());
- this.sendStringListMessage(event.getWhoClicked().getUniqueId(), this.soulmodedeactivatedMoved, 0.0);
- return;
- }
- final String rsr = this.getRandomizationScrollRarity(event.getCursor().getItemMeta());
- ArrayList<String> enchantmentsonitem = null;
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- enchantmentsonitem = this.getEnchantmentsOnItem(event.getCurrentItem());
- }
- if (event.getCursor().getItemMeta().equals(this.items[27].getItemMeta())) {
- if ((event.getCurrentItem().getType().name().endsWith("AXE") || event.getCurrentItem().getType().name().endsWith("SWORD") || event.getCurrentItem().getType().name().endsWith("SPADE") || event.getCurrentItem().getType().equals((Object)Material.BOW) || event.getCurrentItem().getType().equals((Object)Material.FISHING_ROD) || event.getCurrentItem().getType().name().endsWith("HELMET") || event.getCurrentItem().getType().name().endsWith("CHESTPLATE") || event.getCurrentItem().getType().name().endsWith("LEGGINGS") || event.getCurrentItem().getType().name().endsWith("BOOTS")) && (!event.getCurrentItem().hasItemMeta() || (event.getCurrentItem().hasItemMeta() && !event.getCurrentItem().getItemMeta().hasLore()) || (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore() && !event.getCurrentItem().getItemMeta().getLore().contains(this.WHITE_SCROLL_PROTECTED)))) {
- this.item = event.getCurrentItem();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (this.item.hasItemMeta() && this.item.getItemMeta().hasLore()) {
- this.lore.addAll(this.itemMeta.getLore());
- }
- this.lore.add(this.WHITE_SCROLL_PROTECTED);
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- success = true;
- }
- }
- else if (event.getCursor().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore()) && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore() && event.getCurrentItem().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore())) {
- this.item = this.items[22].clone();
- this.itemMeta = this.item.getItemMeta();
- final int gems = this.getRemainingIntFromString(event.getCurrentItem().getItemMeta().getDisplayName()) + this.getRemainingIntFromString(event.getCursor().getItemMeta().getDisplayName());
- this.itemMeta.setDisplayName(this.item.getItemMeta().getDisplayName().replace("{SOULS}", String.valueOf(this.getSoulGemColors(gems)) + gems));
- success = true;
- }
- else if (event.getCursor().getItemMeta().equals(this.items[25].getItemMeta())) {
- if (event.getCurrentItem().getType().name().endsWith("AXE") || event.getCurrentItem().getType().name().endsWith("SWORD") || event.getCurrentItem().getType().name().endsWith("SPADE") || event.getCurrentItem().getType().equals((Object)Material.BOW) || event.getCurrentItem().getType().name().endsWith("HELMET") || event.getCurrentItem().getType().name().endsWith("CHESTPLATE") || event.getCurrentItem().getType().name().endsWith("LEGGINGS") || event.getCurrentItem().getType().name().endsWith("BOOTS")) {
- this.api.applyTransmogScroll(event.getCurrentItem(), 0);
- this.playSuccess((Player)event.getWhoClicked());
- event.setCancelled(true);
- event.setCurrentItem(event.getCurrentItem());
- if (event.getCursor().getAmount() == 1) {
- event.setCursor(new ItemStack(Material.AIR));
- }
- else {
- event.getCursor().setAmount(event.getCursor().getAmount() - 1);
- }
- ((Player)event.getWhoClicked()).updateInventory();
- return;
- }
- }
- else {
- if ((event.getCursor().getItemMeta().hasDisplayName() && this.items[39] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[39].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[40] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[40].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[41] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[41].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[42] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[42].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[43] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[43].getItemMeta().getDisplayName()))) {
- if (event.getCurrentItem().getType().name().endsWith("SWORD") || event.getCurrentItem().getType().name().endsWith("_AXE")) {
- this.applyEnchantmentOrb(event, "weapon-enchantment-orb");
- }
- return;
- }
- if ((event.getCursor().getItemMeta().hasDisplayName() && this.items[140] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[140].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[141] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[141].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[142] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[142].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[143] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[143].getItemMeta().getDisplayName())) || (event.getCursor().getItemMeta().hasDisplayName() && this.items[144] != null && event.getCursor().getItemMeta().getDisplayName().equals(this.items[144].getItemMeta().getDisplayName()))) {
- if (event.getCurrentItem().getType().name().endsWith("HELMET") || event.getCurrentItem().getType().name().endsWith("CHESTPLATE") || event.getCurrentItem().getType().name().contains("LEGGINGS") || event.getCurrentItem().getType().name().contains("BOOTS")) {
- this.applyEnchantmentOrb(event, "armor-enchantment-orb");
- }
- return;
- }
- if (event.getCursor().getItemMeta().hasDisplayName() && event.getCursor().getItemMeta().hasLore() && event.getCursor().getItemMeta().getDisplayName().equals(this.items[1].getItemMeta().getDisplayName()) && enchantmentsonitem != null) {
- this.lore.clear();
- this.lore.addAll(enchantmentsonitem);
- if (this.lore.size() < 1) {
- return;
- }
- enchantcount = enchantmentsonitem.size();
- final String randomenchant = this.lore.get(this.random.nextInt(this.lore.size()));
- int successPercent = -1;
- int rarityint = -1;
- final int enchantlevel = Integer.parseInt(randomenchant.split(" ")[randomenchant.split(" ").length - 1]);
- final String OEN2 = this.getOriginalEnchantmentName(randomenchant);
- final String enchantname = this.enchantmentsInfo.getString(String.valueOf(OEN2) + ".enchant-name");
- rarityint = this.api.convertStringRarityToIntRarity(this.enchantmentsInfo.getString(String.valueOf(OEN2) + ".rarity").toLowerCase());
- final String enchant = ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("rarities." + rarityint + ".revealed-item.apply-format").replace("{ENCHANT}", String.valueOf(enchantname) + " " + this.replaceIntWithRomanNumerals(enchantlevel)));
- for (final String string : event.getCursor().getItemMeta().getLore()) {
- if (this.getRemainingIntFromString(string) != -1) {
- successPercent = this.getRemainingIntFromString(string);
- }
- }
- this.giveItem((Player)event.getWhoClicked(), this.getBook(OEN2, enchantlevel, successPercent, 100).clone());
- this.item = event.getCurrentItem();
- this.itemMeta = event.getCurrentItem().getItemMeta();
- this.lore.clear();
- this.lore.addAll(event.getCurrentItem().getItemMeta().getLore());
- int enchantslot = -1;
- for (int i = 0; i < this.lore.size(); ++i) {
- if (this.lore.get(i).equals(enchant)) {
- enchantslot = i;
- }
- }
- if (enchantslot == -1) {
- return;
- }
- this.lore.remove(enchantslot);
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- success = true;
- }
- else if ((rsr != null && this.randomizationscrollappliesto.get(rsr).equals("all")) || (rsr != null && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().hasLore() && this.getEnchantmentRarity(event.getCurrentItem().getItemMeta().getDisplayName()) != null && rsr.equals(this.getEnchantmentRarity(event.getCurrentItem().getItemMeta().getDisplayName())))) {
- this.item = event.getCurrentItem();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- for (String string2 : this.itemMeta.getLore()) {
- if (string2.equals(this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(this.getRemainingIntFromString(string2)).toString()))) {
- string2 = this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(this.random.nextInt(101)).toString());
- }
- else if (string2.equals(this.DESTROY.replace("{PERCENT}", new StringBuilder().append(this.getRemainingIntFromString(string2)).toString()))) {
- string2 = this.DESTROY.replace("{PERCENT}", new StringBuilder().append(this.random.nextInt(101)).toString());
- }
- this.lore.add(ChatColor.translateAlternateColorCodes('&', string2));
- }
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- success = true;
- }
- }
- if (success) {
- this.playSuccess((Player)event.getWhoClicked());
- this.item.setItemMeta(this.itemMeta);
- if (this.item.getItemMeta().hasDisplayName() && this.item.getItemMeta().getDisplayName().contains(this.TRANSMOG.replace("{LORE_COUNT}", new StringBuilder().append(enchantcount).toString()))) {
- this.api.applyTransmogScroll(this.item, enchantcount);
- }
- event.setCancelled(true);
- event.setCurrentItem(this.item);
- if (event.getCursor().getAmount() == 1) {
- event.setCursor(new ItemStack(Material.AIR));
- }
- else {
- event.getCursor().setAmount(event.getCursor().getAmount() - 1);
- }
- ((Player)event.getWhoClicked()).updateInventory();
- }
- }
- else if (event.getCursor() != null && event.getCursor().hasItemMeta() && event.getCursor().getItemMeta().hasDisplayName() && event.getCursor().getItemMeta().hasLore() && this.getOriginalEnchantmentName(event.getCursor().getItemMeta().getDisplayName()) != null) {
- final List<String> cursorLore = (List<String>)event.getCursor().getItemMeta().getLore();
- if ((cursorLore.contains(this.ARMOR) && event.getCurrentItem().getType().name().endsWith("HELMET")) || (cursorLore.contains(this.ARMOR) && event.getCurrentItem().getType().name().endsWith("CHESTPLATE")) || (cursorLore.contains(this.ARMOR) && event.getCurrentItem().getType().name().endsWith("LEGGINGS")) || (cursorLore.contains(this.ARMOR) && event.getCurrentItem().getType().name().endsWith("BOOTS")) || (cursorLore.contains(this.HELMET) && event.getCurrentItem().getType().name().endsWith("HELMET")) || (cursorLore.contains(this.CHESTPLATE) && event.getCurrentItem().getType().name().endsWith("CHESTPLATE")) || (cursorLore.contains(this.LEGGINGS) && event.getCurrentItem().getType().name().endsWith("LEGGINGS")) || (cursorLore.contains(this.BOOTS) && event.getCurrentItem().getType().name().endsWith("BOOTS")) || (cursorLore.contains(this.AXE) && event.getCurrentItem().getType().name().endsWith("_AXE")) || (cursorLore.contains(this.BOW) && event.getCurrentItem().getType().name().endsWith("BOW")) || (this.getOriginalEnchantmentName(event.getCursor().getItemMeta().getDisplayName()).equals("Rage") && event.getCurrentItem().getType().name().endsWith("BOW")) || (cursorLore.contains(this.PICKAXE) && event.getCurrentItem().getType().name().endsWith("PICKAXE")) || (cursorLore.contains(this.SWORD) && event.getCurrentItem().getType().name().endsWith("SWORD")) || (cursorLore.contains(this.TOOL) && event.getCurrentItem().getType().name().endsWith("AXE")) || (cursorLore.contains(this.TOOL) && event.getCurrentItem().getType().name().endsWith("SPADE")) || (cursorLore.contains(this.WEAPON) && event.getCurrentItem().getType().name().endsWith("_AXE")) || (cursorLore.contains(this.WEAPON) && event.getCurrentItem().getType().name().endsWith("SWORD"))) {
- this.item = event.getCurrentItem();
- this.itemMeta = event.getCurrentItem().getItemMeta();
- this.lore.clear();
- int playerlevelcap = 0;
- final int enchantsize = this.getEnchantmentsOnItem(this.item).size();
- int succeSS = 0;
- int destroy = 0;
- final int bookEnchantLevel = this.getEnchantmentLevel(event.getCursor().getItemMeta().getDisplayName());
- int currentEnchantLevel = 0;
- final String OEN3 = this.getOriginalEnchantmentName(event.getCursor().getItemMeta().getDisplayName());
- final String enchantName = this.enchantmentsInfo.getString(String.valueOf(OEN3) + ".enchant-name");
- final String rarity = this.enchantmentsInfo.getString(String.valueOf(OEN3) + ".rarity").toLowerCase();
- int level = -1;
- int replace = -1;
- boolean addnumber = false;
- final ArrayList<String> enchantsonitem = this.getEnchantmentsOnItem(event.getCurrentItem());
- boolean did = false;
- if (OEN3.equals("DivineEnlighted") || OEN3.equals("GodlyOverload") || OEN3.equals("MasterInquisitive") || OEN3.equals("PlanetaryDeathbringer")) {
- if (!event.getCurrentItem().hasItemMeta() || !event.getCurrentItem().getItemMeta().hasLore()) {
- return;
- }
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- for (int j = 0; j < enchantsonitem.size(); ++j) {
- if ((OEN3.equals("DivineEnlighted") && enchantsonitem.get(j).split(" ")[0].equals("Enlighted")) || (OEN3.equals("GodlyOverload") && enchantsonitem.get(j).split(" ")[0].equals("Overload")) || (OEN3.equals("MasterInquisitive") && enchantsonitem.get(j).split(" ")[0].equals("Inquisitive")) || (OEN3.equals("PlanetaryDeathbringer") && enchantsonitem.get(j).split(" ")[0].equals("Deathbringer"))) {
- did = true;
- }
- }
- }
- if (!did) {
- return;
- }
- }
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- this.lore.addAll(event.getCurrentItem().getItemMeta().getLore());
- for (int j = 0; j < enchantsonitem.size(); ++j) {
- if ((OEN3.equals("DivineEnlighted") && enchantsonitem.get(j).split(" ")[0].equals("Enlighted")) || (OEN3.equals("GodlyOverload") && enchantsonitem.get(j).split(" ")[0].equals("Overload")) || (OEN3.equals("MasterInquisitive") && enchantsonitem.get(j).split(" ")[0].equals("Inquisitive")) || (OEN3.equals("PlanetaryDeathbringer") && enchantsonitem.get(j).split(" ")[0].equals("Deathbringer"))) {
- if (Integer.parseInt(enchantsonitem.get(j).split(" ")[1]) != this.enchantmaxlevel.get(enchantName)) {
- this.lore.clear();
- return;
- }
- replace = j;
- }
- else if ((OEN3.equals("Enlighted") && enchantsonitem.get(j).split(" ")[0].equals("DivineEnlighted")) || (OEN3.equals("Deathbringer") && enchantsonitem.get(j).split(" ")[0].equals("PlanetaryDeathbringer")) || (OEN3.equals("Inquisitive") && enchantsonitem.get(j).split(" ")[0].equals("MasterInquisitive")) || (OEN3.equals("Overload") && enchantsonitem.get(j).split(" ")[0].equals("GodlyOverload"))) {
- this.lore.clear();
- return;
- }
- }
- if (replace == -1) {
- for (final String string3 : enchantsonitem) {
- if (level == -1 && string3.split(" ")[0].equals(OEN3)) {
- currentEnchantLevel = Integer.parseInt(string3.split(" ")[1]);
- if (currentEnchantLevel + 1 > this.enchantmaxlevel.get(enchantName)) {
- return;
- }
- if (bookEnchantLevel > currentEnchantLevel) {
- level = bookEnchantLevel;
- }
- else {
- level = currentEnchantLevel + 1;
- }
- }
- }
- }
- }
- for (int j = 0; j <= 100; ++j) {
- if (event.getCursor().getItemMeta().getLore().contains(this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(j).toString()))) {
- succeSS = j;
- }
- if (event.getCursor().getItemMeta().getLore().contains(this.DESTROY.replace("{PERCENT}", new StringBuilder().append(j).toString()))) {
- destroy = j;
- }
- }
- for (int j = 1; j <= 100; ++j) {
- if (event.getWhoClicked().hasPermission("RandomPackage.levelcap." + j)) {
- playerlevelcap = j;
- }
- }
- for (int j = 1; j <= 5; ++j) {
- if ((this.item.getType().name().contains("SWORD") || this.item.getType().name().contains("_AXE")) && this.itemMeta.hasLore() && this.itemsConfig.get("weapon-enchantment-orb." + j) != null && this.itemMeta.getLore().contains(ChatColor.translateAlternateColorCodes('&', this.itemsConfig.getString("weapon-enchantment-orb.apply").replace("{SLOTS}", new StringBuilder().append(this.itemsConfig.getInt("weapon-enchantment-orb." + j + ".slots")).toString()).replace("{ADD_SLOTS}", new StringBuilder().append(j).toString())))) {
- playerlevelcap = this.itemsConfig.getInt("weapon-enchantment-orb." + j + ".slots");
- }
- }
- if (enchantsize + 1 > playerlevelcap && level == -1) {
- return;
- }
- if (this.random.nextInt(100) <= succeSS) {
- final String applyf = this.applyformat.get(rarity);
- final String preve = applyf.replace("{ENCHANT}", String.valueOf(enchantName) + " " + this.replaceIntWithRomanNumerals(currentEnchantLevel));
- if (level != -1) {
- this.lore.remove(preve);
- this.lore.add(applyf.replace("{ENCHANT}", String.valueOf(enchantName) + " " + this.replaceIntWithRomanNumerals(level)));
- }
- else if (replace != -1) {
- this.lore.set(replace, applyf.replace("{ENCHANT}", String.valueOf(enchantName) + " " + this.replaceIntWithRomanNumerals(bookEnchantLevel)));
- }
- else {
- this.lore.add(applyf.replace("{ENCHANT}", String.valueOf(enchantName) + " " + this.replaceIntWithRomanNumerals(bookEnchantLevel)));
- addnumber = true;
- }
- if (this.itemMeta.hasLore()) {
- for (int k = 0; k < this.armorlore.size(); ++k) {
- if (this.itemMeta.getLore().toString().substring(0, this.itemMeta.getLore().toString().length() - 1).contains(this.armorlore.get(k).toString().substring(0, this.armorlore.get(k).toString().length() - 1))) {
- for (final String s : this.armorlore.get(k)) {
- this.lore.remove(s);
- this.lore.add(s);
- }
- }
- }
- for (final String string4 : this.itemMeta.getLore()) {
- if (!this.lore.contains(string4) && !string4.equals(preve)) {
- this.lore.add(string4);
- }
- }
- if (this.itemMeta.getLore().contains(this.WHITE_SCROLL_PROTECTED)) {
- this.lore.remove(this.WHITE_SCROLL_PROTECTED);
- this.lore.add(this.WHITE_SCROLL_PROTECTED);
- }
- for (final String string4 : this.soultrackers_apply) {
- if (this.itemMeta.getLore().get(this.itemMeta.getLore().size() - 1).startsWith(string4.replace("{SOULS}", ""))) {
- final String s2 = this.itemMeta.getLore().get(this.itemMeta.getLore().size() - 1);
- this.lore.remove(s2);
- this.lore.add(s2);
- }
- }
- }
- this.playSuccess((Player)event.getWhoClicked());
- }
- else if (this.random.nextInt(101) <= destroy) {
- this.playDestroy((Player)event.getWhoClicked());
- if (!this.lore.contains(this.WHITE_SCROLL_PROTECTED)) {
- this.item = new ItemStack(Material.AIR);
- }
- else {
- this.lore.remove(this.WHITE_SCROLL_PROTECTED);
- addnumber = false;
- }
- }
- else {
- this.playDestroy((Player)event.getWhoClicked());
- }
- if (!this.item.getType().equals((Object)Material.AIR)) {
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- if (addnumber && this.itemMeta.hasDisplayName() && this.itemMeta.getDisplayName().contains(this.itemMeta.getDisplayName().replace(this.TRANSMOG.replace("{LORE_COUNT}", new StringBuilder().append(enchantsize).toString()), ""))) {
- this.api.applyTransmogScroll(this.item, enchantsize);
- }
- }
- event.setCancelled(true);
- event.setCurrentItem(this.item);
- if (event.getCursor().getAmount() == 1) {
- event.setCursor(new ItemStack(Material.AIR));
- }
- else {
- event.getCursor().setAmount(event.getCursor().getAmount() - 1);
- }
- ((Player)event.getWhoClicked()).updateInventory();
- }
- }
- else if (event.getCursor() != null && event.getCursor().hasItemMeta() && event.getCursor().getItemMeta().hasLore() && event.getCursor().getItemMeta().hasDisplayName() && event.getCurrentItem() != null) {
- final String dustrarity = this.getDustRarity(event.getCursor());
- this.item = event.getCurrentItem();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName()) {
- final String OEN4 = this.getOriginalEnchantmentName(event.getCurrentItem().getItemMeta().getDisplayName());
- String enchantrarity = null;
- final String randomizationscrollrarity = this.getRandomizationScrollRarity(event.getCursor().getItemMeta());
- if (OEN4 != null) {
- enchantrarity = this.enchantmentsInfo.getString(String.valueOf(OEN4) + ".rarity").toLowerCase();
- }
- if (randomizationscrollrarity != null) {
- if (enchantrarity.equals(randomizationscrollrarity)) {
- for (String string5 : this.itemMeta.getLore()) {
- if (string5.equals(this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(this.getRemainingIntFromString(string5)).toString()))) {
- string5 = this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(this.random.nextInt(101)).toString());
- }
- else if (string5.equals(this.DESTROY.replace("{PERCENT}", new StringBuilder().append(this.getRemainingIntFromString(string5)).toString()))) {
- string5 = this.DESTROY.replace("{PERCENT}", new StringBuilder().append(this.random.nextInt(101)).toString());
- }
- this.lore.add(ChatColor.translateAlternateColorCodes('&', string5));
- success = true;
- }
- }
- }
- else if (OEN4 != null && dustrarity != null) {
- HashMap<String, ItemStack> type = null;
- if (dustrarity.contains("primal")) {
- type = this.primaldust;
- }
- else {
- type = this.regulardust;
- }
- this.item = type.get(dustrarity.split("-")[0]).clone();
- if (!dustrarity.startsWith(enchantrarity)) {
- return;
- }
- int percent = -1;
- for (int z = 0; z < this.item.getItemMeta().getLore().size(); ++z) {
- if (this.item.getItemMeta().getLore().get(z).contains("{PERCENT}")) {
- percent = this.getRemainingIntFromString(event.getCursor().getItemMeta().getLore().get(z));
- }
- }
- if (percent == -1) {
- return;
- }
- for (String string6 : this.itemMeta.getLore()) {
- if (string6.equals(this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(this.getRemainingIntFromString(string6)).toString()))) {
- int bookpercent = this.getRemainingIntFromString(string6);
- if (bookpercent == 100) {
- return;
- }
- if (bookpercent + percent > 100) {
- bookpercent = 50;
- percent = 50;
- }
- string6 = this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(bookpercent + percent).toString());
- }
- this.lore.add(ChatColor.translateAlternateColorCodes('&', string6));
- }
- this.item = event.getCurrentItem();
- this.itemMeta = this.item.getItemMeta();
- success = true;
- }
- }
- final int soultrackerrarity = this.getSoulTrackerItemStackRarity(event.getCursor().getItemMeta());
- if (soultrackerrarity != -1 && (event.getCurrentItem().getType().name().contains("SWORD") || event.getCurrentItem().getType().name().contains("_AXE"))) {
- final String soultracker = this.soultrackers_apply.get(soultrackerrarity);
- boolean did2 = false;
- if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- this.lore.addAll(event.getCurrentItem().getItemMeta().getLore());
- for (final String string5 : this.soultrackers_apply) {
- if (!did2 && string5 != null && event.getCurrentItem().getItemMeta().getLore().get(event.getCurrentItem().getItemMeta().getLore().size() - 1).startsWith(string5.replace("{SOULS}", ""))) {
- did2 = true;
- this.lore.set(this.lore.size() - 1, soultracker.replace("{SOULS}", "0"));
- }
- }
- if (!did2) {
- this.lore.add(soultracker.replace("{SOULS}", "0"));
- }
- }
- else {
- this.lore.add(soultracker.replace("{SOULS}", "0"));
- }
- for (String string5 : this.messages.getStringList("Givedp.soul-trackers.apply." + soultracker.toLowerCase())) {
- if (string5.contains("{ITEM}")) {
- string5 = string5.replace("{ITEM}", event.getCurrentItem().getType().name());
- }
- event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', string5));
- }
- success = true;
- }
- if (success) {
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- event.setCancelled(true);
- event.setCurrentItem(this.item);
- if (event.getCursor().getAmount() == 1) {
- event.setCursor(new ItemStack(Material.AIR));
- }
- else {
- event.getCursor().setAmount(event.getCursor().getAmount() - 1);
- }
- ((Player)event.getWhoClicked()).updateInventory();
- this.playSuccess((Player)event.getWhoClicked());
- }
- }
- }
- }
- public void potionEffects(final Player player, final String enchant, final boolean removePotionEffects) {
- final String OEN = enchant.split(" ")[0];
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- for (int i = 1; i <= 10; ++i) {
- if (this.enchantments.get(String.valueOf(OEN) + ".potion-effects." + i) != null) {
- final String[] string = this.enchantments.getString(String.valueOf(OEN) + ".potion-effects." + i).toLowerCase().replace(" ", "").replace("level", new StringBuilder().append(level).toString()).split(":");
- List<String> action = null;
- final PotionEffectType potioneffecttype = this.getPotionEffectType(string[0]);
- final int potioneffectlevel = this.evaluate(string[1]);
- if (removePotionEffects) {
- player.removePotionEffect(potioneffecttype);
- action = this.removepotioneffect;
- }
- else {
- player.addPotionEffect(new PotionEffect(potioneffecttype, this.evaluate(string[2]), potioneffectlevel));
- action = this.addpotioneffect;
- }
- for (String String : action) {
- if (String.contains("{ENCHANT}")) {
- String = String.replace("{ENCHANT}", String.valueOf(this.enchantmentsInfo.getString(new StringBuilder(String.valueOf(OEN)).append(".enchant-name").toString())) + " " + this.replaceIntWithRomanNumerals(level));
- }
- if (String.contains("{POTION_EFFECT}")) {
- String = String.replace("{POTION_EFFECT}", String.valueOf(potioneffecttype.getName()) + " " + this.replaceIntWithRomanNumerals(1 + potioneffectlevel));
- }
- player.sendMessage(ChatColor.translateAlternateColorCodes('&', String));
- }
- }
- }
- }
- @EventHandler
- private void removePotionEffect(final InventoryClickEvent event) {
- if (event.isCancelled() || event.getClick().equals((Object)ClickType.DOUBLE_CLICK) || event.getClick().equals((Object)ClickType.CONTROL_DROP)) {
- return;
- }
- if (event.getCurrentItem() != null && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore() && event.getClickedInventory().getType().equals((Object)InventoryType.PLAYER) && event.getWhoClicked().getOpenInventory().getTopInventory().getType().equals((Object)InventoryType.CRAFTING) && event.isShiftClick() && !event.getSlotType().equals((Object)InventoryType.SlotType.ARMOR)) {
- if ((event.getCurrentItem().getType().name().endsWith("HELMET") && event.getWhoClicked().getInventory().getHelmet() == null) || (event.getCurrentItem().getType().name().endsWith("CHESTPLATE") && event.getWhoClicked().getInventory().getChestplate() == null) || (event.getCurrentItem().getType().name().endsWith("LEGGINGS") && event.getWhoClicked().getInventory().getLeggings() == null) || (event.getCurrentItem().getType().name().endsWith("BOOTS") && event.getWhoClicked().getInventory().getBoots() == null)) {
- for (final String enchant : this.getEnchantmentsOnItem(event.getCurrentItem())) {
- final String OEN = enchant.split(" ")[0];
- if (this.potioneffectEnchants.contains(OEN)) {
- this.potionEffects((Player)event.getWhoClicked(), enchant, false);
- }
- else if (OEN.equals("EnderWalker")) {
- this.getAndPlaySound((Player)event.getWhoClicked(), event.getWhoClicked().getLocation(), "enchants.EnderWalker", false);
- }
- else if (OEN.equals("Commander")) {
- this.commander.put((Player)event.getWhoClicked(), event.getCurrentItem());
- }
- else {
- if (!OEN.equals("Protection")) {
- continue;
- }
- this.protection.put((Player)event.getWhoClicked(), event.getCurrentItem());
- }
- }
- }
- return;
- }
- if (event.getSlotType().equals((Object)InventoryType.SlotType.ARMOR)) {
- if (event.getCurrentItem() != null && event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasLore()) {
- if ((event.getRawSlot() == 5 && !event.getCurrentItem().getType().name().endsWith("HELMET")) || (event.getRawSlot() == 6 && !event.getCurrentItem().getType().name().endsWith("CHESTPLATE")) || (event.getRawSlot() == 7 && !event.getCurrentItem().getType().name().endsWith("LEGGINGS")) || (event.getRawSlot() == 8 && !event.getCurrentItem().getType().name().endsWith("BOOTS"))) {
- return;
- }
- for (final String enchant : this.getEnchantmentsOnItem(event.getCurrentItem())) {
- final String OEN = enchant.split(" ")[0];
- if (this.potioneffectEnchants.contains(OEN)) {
- this.potionEffects((Player)event.getWhoClicked(), enchant, true);
- }
- else if (OEN.equals("Commander")) {
- this.commander.remove(event.getWhoClicked());
- }
- else if (OEN.equals("Protection")) {
- this.protection.remove(event.getWhoClicked());
- }
- else {
- if (!OEN.equals("RepairGuard")) {
- continue;
- }
- this.repairguard.add(event.getWhoClicked().getUniqueId());
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.repairguard.remove(event.getWhoClicked().getUniqueId());
- }
- }, (long)(20 * Integer.parseInt(enchant.split(" ")[1])));
- }
- }
- }
- if (event.getCursor() != null && event.getCursor().hasItemMeta() && event.getCursor().getItemMeta().hasLore()) {
- if ((event.getRawSlot() == 5 && !event.getCursor().getType().name().endsWith("HELMET")) || (event.getRawSlot() == 6 && !event.getCursor().getType().name().endsWith("CHESTPLATE")) || (event.getRawSlot() == 7 && !event.getCursor().getType().name().endsWith("LEGGINGS")) || (event.getRawSlot() == 8 && !event.getCursor().getType().name().endsWith("BOOTS"))) {
- return;
- }
- for (final String enchant : this.getEnchantmentsOnItem(event.getCursor())) {
- final String OEN = enchant.split(" ")[0];
- if (this.potioneffectEnchants.contains(OEN)) {
- this.potionEffects((Player)event.getWhoClicked(), enchant, false);
- }
- else if (OEN.equals("EnderWalker")) {
- this.getAndPlaySound((Player)event.getWhoClicked(), event.getWhoClicked().getLocation(), "enchants.EnderWalker", false);
- }
- else if (OEN.equals("Commander")) {
- this.commander.put((Player)event.getWhoClicked(), event.getCursor());
- }
- else {
- if (!OEN.equals("Protection")) {
- continue;
- }
- this.protection.put((Player)event.getWhoClicked(), event.getCursor());
- }
- }
- }
- }
- }
- @EventHandler
- private void entityDamageByEntityEvent(final EntityDamageByEntityEvent event) {
- if (event.isCancelled()) {
- if (event.getEntity() instanceof Player && event.getDamager().getType().name().contains("ARROW") && ((Projectile)event.getDamager()).getShooter() instanceof Player) {
- final Player shooter = (Player)((Projectile)event.getDamager()).getShooter();
- final Player victim = (Player)event.getEntity();
- for (int i = 0; i < this.bowsp.size(); ++i) {
- if (this.bowsp.get(i).equals(shooter.getUniqueId())) {
- final ArrayList<String> damagerenchants = this.getEnchantmentsOnItem(this.bows.get(i));
- for (final String string : damagerenchants) {
- final String OEN = string.split(" ")[0];
- if (OEN.equals("Teleportation") && (this.fapi.relationIsAlly(shooter, victim) || this.fapi.relationIsMember(shooter, victim))) {
- this.Teleportation((Projectile)event.getDamager(), shooter, victim);
- }
- }
- }
- }
- }
- return;
- }
- this.procEnchants(event);
- }
- public void procEnchants(final EntityDamageByEntityEvent event) {
- if ((Bukkit.getPluginManager().getPlugin("WorldEdit") != null && Bukkit.getPluginManager().getPlugin("WorldGuard") != null && event.getEntity() instanceof Player && !RP_WorldEditWorldGuard.getInstance().locationHasPvPAllowed(event.getEntity().getWorld(), event.getEntity().getLocation())) || (event.getEntity() instanceof Player && event.getDamager() instanceof Player && !this.fapi.relationIsEnemyOrNull((Player)event.getEntity(), (Player)event.getDamager()) && !this.fapi.relationIsNeutral((Player)event.getEntity(), (Player)event.getDamager()))) {
- event.setCancelled(true);
- return;
- }
- if (event.getEntity() instanceof IronGolem && event.getEntity().getCustomName() != null && event.getDamager() instanceof Player) {
- final String playername = ChatColor.stripColor(event.getEntity().getCustomName().replace(ChatColor.stripColor(this.guardiansname.replace("{PLAYER}", "")), ""));
- if (Bukkit.getPlayer(playername) != null && Bukkit.getPlayer(playername).isOnline() && !Bukkit.getPlayer(playername).getName().equalsIgnoreCase(playername)) {
- ItemStack[] armorContents;
- for (int length = (armorContents = Bukkit.getPlayer(playername).getInventory().getArmorContents()).length, k = 0; k < length; ++k) {
- final ItemStack is = armorContents[k];
- if (is != null && !is.getType().equals((Object)Material.AIR) && is.hasItemMeta() && is.getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(is)) {
- if (enchant.split(" ")[0].equals("BloodLink") && this.random.nextInt(100) <= this.getProckChance("BloodLink", Integer.parseInt(enchant.split(" ")[1]), Bukkit.getPlayer(playername))) {
- this.BloodLink(Bukkit.getPlayer(playername));
- }
- }
- }
- }
- }
- return;
- }
- if (event.getEntity() instanceof LivingEntity && event.getDamager() instanceof Player && this.getItemInHand((Player)event.getDamager()) != null && this.getItemInHand((Player)event.getDamager()).hasItemMeta() && this.getItemInHand((Player)event.getDamager()).getItemMeta().hasLore()) {
- final Player damager = (Player)event.getDamager();
- final LivingEntity victim = (LivingEntity)event.getEntity();
- if (this.dominate.contains(damager.getUniqueId())) {
- int d = 0;
- for (int z = 0; z < this.dominate.size(); ++z) {
- if (this.dominate.get(z).equals(damager.getUniqueId()) && d == 0) {
- d = z;
- }
- }
- event.setDamage(event.getDamage() * (event.getDamage() * this.dominatee.get(d) * this.doubles[7]));
- }
- final int shackle = 0;
- for (final String enchant2 : this.getEnchantmentsOnItem(this.getItemInHand(damager))) {
- final String OEN = enchant2.split(" ")[0];
- final int level = Integer.parseInt(enchant2.split(" ")[1]);
- int chance = 0;
- if (!OEN.equals("Dodge")) {
- chance = this.getProckChance(OEN, level, damager);
- }
- if (this.random.nextInt(100) <= chance || OEN.equals("Silence") || OEN.equals("Disarmor") || OEN.equals("DivineImmolation")) {
- if (OEN.equals("Assassin")) {
- this.Assassin(event, level);
- }
- else if (OEN.equals("Barbarian")) {
- this.Barbarian(event, level, damager);
- }
- else if (OEN.equals("Demonforged") && victim instanceof Player) {
- this.Demonforged((Player)victim, level, chance);
- }
- else if (OEN.equals("DivineImmolation") && this.soulmode.contains(event.getDamager().getUniqueId())) {
- this.DivineImmolation(event, level);
- }
- else if (OEN.equals("Berserk")) {
- this.Berserk(damager, level);
- }
- else if (OEN.equals("Blacksmith")) {
- this.Blacksmith(event, damager, level);
- }
- else if (OEN.equals("Blessed")) {
- this.Blessed(damager);
- }
- else if (OEN.equals("Blind")) {
- this.Blind(event, level);
- }
- else if (OEN.equals("Cleave")) {
- this.Cleave(damager, victim, level, event);
- }
- else if (OEN.equals("Confusion") && victim instanceof Player) {
- this.Confusion((Player)victim, level);
- }
- else if (OEN.equals("DeepWounds") && victim instanceof Player) {
- this.DeepWounds(event, (Player)victim, level);
- }
- else if (OEN.equals("Disarmor") && victim instanceof Player && ((Player)victim).getHealth() <= 8.0) {
- boolean did = false;
- ItemStack[] armorContents2;
- for (int length2 = (armorContents2 = ((Player)victim).getInventory().getArmorContents()).length, l = 0; l < length2; ++l) {
- final ItemStack is2 = armorContents2[l];
- for (final String enchants : this.getEnchantmentsOnItem(is2)) {
- if (enchants.split(" ")[0].equals("Sticky") && !did) {
- chance -= this.getProckChance(enchants, level, damager);
- did = true;
- }
- }
- }
- if (this.random.nextInt(100) > chance) {
- continue;
- }
- this.Disarmor((Player)victim);
- }
- else if (OEN.equals("Dominate") && victim instanceof Player) {
- this.Dominate(event, level);
- }
- else if (OEN.equals("DoubleStrike") && !this.doublestrike) {
- this.procEnchants(event);
- this.doublestrike = true;
- this.sendStringListMessage(damager.getUniqueId(), this.enchantmessages[7], 0.0);
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.DoubleStrike", false);
- }
- else if (OEN.equals("Epicness") && victim instanceof Player) {
- this.Epicness((Player)victim, level);
- }
- else if (OEN.equals("Enrage")) {
- this.Enrage(event, damager, level);
- }
- else if (OEN.equals("Execute")) {
- this.Execute(damager, level);
- }
- else if (OEN.equals("Featherweight")) {
- this.Featherweight(damager, level);
- }
- else if (OEN.equals("Frozen") && victim instanceof Player) {
- this.Frozen((Player)victim, level);
- }
- else if (OEN.equals("Greatsword") && victim instanceof Player) {
- this.Greatsword(event, (Player)victim, level);
- }
- else if (OEN.equals("IceAspect") && victim instanceof Player) {
- this.IceAspect((Player)victim, level);
- }
- else if (OEN.equals("IceFreeze") && victim instanceof Player) {
- this.IceFreeze((Player)victim, level);
- }
- else if (OEN.equals("Insanity") && victim instanceof Player) {
- this.Insanity(damager, level, (Player)victim, event);
- }
- else if (OEN.equals("Insomnia") && victim instanceof Player) {
- this.Insomnia((Player)victim, level, event);
- }
- else if (OEN.equals("Lifesteal")) {
- this.Lifesteal(event, damager);
- }
- else if (OEN.equals("Obliterate")) {
- this.Obliterate(event, level);
- }
- else if (OEN.equals("Paralyze") && victim instanceof Player) {
- this.Paralyze((Player)victim, level);
- }
- else if (OEN.equals("Poison")) {
- this.Poison(victim, level);
- }
- else if (OEN.equals("Pummel") && victim instanceof Player) {
- this.Pummel(damager, (Player)victim, level);
- }
- else if (OEN.equals("Rage")) {
- this.Rage(event, damager, level);
- }
- else if (OEN.equals("Ravenous")) {
- this.Ravenous(damager, level);
- }
- else if (OEN.equals("Shackle") && !(victim instanceof Player)) {
- this.Shackle(event, level);
- }
- else if (OEN.equals("Silence") && victim instanceof Player) {
- int solitude = 0;
- for (final String str : this.getEnchantmentsOnItem(this.getItemInHand(damager))) {
- if (str.equals("Solitude")) {
- solitude = this.getProckChance(str, level, damager);
- }
- }
- chance += solitude;
- if (this.random.nextInt(100) > chance) {
- continue;
- }
- this.Silence((Player)victim, level);
- }
- else if (OEN.equals("SkillSwipe") && victim instanceof Player) {
- this.SkillSwipe((Player)victim, damager, level);
- }
- else if (OEN.equals("ThunderingBlow")) {
- this.ThunderingBlow(event, level);
- }
- else if (OEN.equals("Trap") && victim instanceof Player) {
- this.Trap((Player)victim, level);
- }
- else if (OEN.equals("Trickster") && victim instanceof Player) {
- this.Trickster((Player)victim);
- }
- else {
- if (!OEN.equals("Vampire")) {
- continue;
- }
- this.Vampire(event, damager);
- }
- }
- }
- this.doublestrike = false;
- final int lucky = 0;
- ItemStack[] armorContents3;
- for (int length3 = (armorContents3 = damager.getInventory().getArmorContents()).length, n = 0; n < length3; ++n) {
- final ItemStack is3 = armorContents3[n];
- if (is3 != null && is3.hasItemMeta() && is3.getItemMeta().hasLore()) {
- for (final String enchant3 : this.getEnchantmentsOnItem(is3)) {
- final String OEN2 = enchant3.split(" ")[0];
- final int level2 = Integer.parseInt(enchant3.split(" ")[1]);
- int chance2 = 0;
- if (!OEN2.equals("Dodge")) {
- chance2 = this.getProckChance(OEN2, level2, damager);
- }
- if (this.random.nextInt(100) <= chance2) {
- if (OEN2.equals("PlanetaryDeathbringer")) {
- this.PlanetaryDeathbringer(event);
- }
- else {
- if (!OEN2.equals("Leadership")) {
- continue;
- }
- this.Leadership(event, level2);
- }
- }
- }
- }
- }
- }
- if ((event.getEntity() instanceof Player && event.getDamager() instanceof Player) || (event.getEntity() instanceof Player && event.getDamager() instanceof LivingEntity)) {
- final Player victim2 = (Player)event.getEntity();
- LivingEntity damager2 = (LivingEntity)event.getDamager();
- if (damager2 instanceof Projectile && damager2.getType().name().contains("ARROW")) {
- if (!(((Projectile)damager2).getShooter() instanceof Player)) {
- return;
- }
- damager2 = (LivingEntity)((Projectile)damager2).getShooter();
- }
- boolean phoeniX = false;
- final int phoenix = 1000 + this.random.nextInt(101);
- this.item = this.getSoulGemInPlayerInventory(victim2, true);
- ItemStack[] armorContents4;
- for (int length4 = (armorContents4 = victim2.getInventory().getArmorContents()).length, n2 = 0; n2 < length4; ++n2) {
- final ItemStack ap = armorContents4[n2];
- if (ap != null && ap.hasItemMeta() && ap.getItemMeta().hasLore()) {
- for (final String enchant3 : this.getEnchantmentsOnItem(ap)) {
- int souls = 0;
- if (this.item != null) {
- souls = this.getRemainingIntFromString(this.item.getItemMeta().getDisplayName());
- }
- final String OEN3 = enchant3.split(" ")[0];
- final int level3 = Integer.parseInt(enchant3.split(" ")[enchant3.split(" ").length - 1]);
- int chance3 = 0;
- if (!OEN3.equals("Dodge")) {
- chance3 = this.getProckChance(OEN3, level3, victim2);
- }
- if (this.random.nextInt(100) <= chance3 || OEN3.equals("Dodge") || OEN3.equals("Immortal") || OEN3.equals("Phoenix")) {
- if (OEN3.equals("Aegis") && damager2 instanceof Player) {
- this.Aegis(event, (Player)damager2, level3);
- }
- else if (OEN3.equals("Angelic")) {
- this.Angelic(victim2, level3);
- }
- else if (OEN3.equals("Armored") && damager2 instanceof Player) {
- this.Armored(victim2, (Player)damager2, level3, event);
- }
- else if (OEN3.equals("ArrowDeflect") && damager2.getType().name().contains("ARROW")) {
- this.ArrowDeflect(event, victim2, level3);
- }
- else if (OEN3.equals("Cactus")) {
- this.Cactus(damager2, level3);
- }
- else if ((OEN3.equals("CreeperArmor") && event.getDamager().getType().equals((Object)EntityType.CREEPER)) || (OEN3.equals("CreeperArmor") && event.getDamager().getType().equals((Object)EntityType.PRIMED_TNT))) {
- this.CreeperArmor(event, victim2, level3);
- }
- else if (OEN3.equals("Curse") && victim2.getHealth() <= this.doubles[10]) {
- this.Curse(victim2, level3);
- }
- else if (OEN3.equals("Deathbringer")) {
- this.Deathbringer(victim2, level3);
- }
- else if (OEN3.equals("DeathGod")) {
- this.DeathGod(event, level3);
- }
- else if (OEN3.equals("Dodge")) {
- if (victim2.isSneaking()) {
- chance3 = this.getProckChance(this.enchantments.getString("chances." + OEN3 + ".if-sneaking"), level3, victim2);
- }
- else {
- chance3 = this.getProckChance(this.enchantments.getString("chances." + OEN3 + ".not-sneaking"), level3, victim2);
- }
- if (this.random.nextInt(100) > chance3) {
- continue;
- }
- this.Dodge(victim2, event);
- }
- else if (OEN3.equals("EnderShift")) {
- this.EnderShift(victim2, level3);
- }
- else if (OEN3.equals("Enlighted")) {
- this.Enlighted(victim2);
- }
- else if (OEN3.equals("Guardians")) {
- this.Guardians(event, victim2, level3);
- }
- else if (OEN3.equals("Immortal") && this.item != null && souls - 5 - level3 >= 0) {
- this.Immortal(victim2, ap);
- this.depleteSouls(victim2, this.item, souls, 5 + this.random.nextInt(level3 * 4));
- victim2.updateInventory();
- }
- else if (OEN3.equals("Inversion")) {
- this.Inversion(event, victim2, level3);
- }
- else if (OEN3.equals("Molten")) {
- this.Molten(damager2, level3);
- }
- else if (OEN3.equals("NaturesWrath") && this.item != null && souls - 75 >= 0) {
- this.NaturesWrath(event, victim2, level3);
- this.depleteSouls(victim2, this.item, souls, 75);
- }
- else if (OEN3.equals("Phoenix") && this.item != null && victim2.getHealth() - event.getFinalDamage() <= 0.0 && souls - phoenix >= 0 && !phoeniX) {
- phoeniX = true;
- this.Phoenix(event, victim2, level3);
- this.depleteSouls(victim2, this.item, souls, phoenix);
- }
- else if (OEN3.equals("Poisoned")) {
- this.Poisoned(damager2, level3);
- }
- else if (OEN3.equals("Ragdoll")) {
- this.Ragdoll(victim2);
- }
- else if (OEN3.equals("Shockwave") && event.getDamager() instanceof Player) {
- this.Shockwave((Player)event.getDamager(), level3);
- }
- else if (OEN3.equals("SmokeBomb")) {
- this.SmokeBomb(damager2, level3);
- }
- else if (OEN3.equals("SpiritLink")) {
- this.SpiritLink(victim2, level3);
- }
- else if (OEN3.equals("Spirits")) {
- this.Spirits(victim2, level3);
- }
- else if (OEN3.equals("Stormcaller")) {
- this.Stormcaller(damager2);
- }
- else if (OEN3.equals("RocketEscape")) {
- this.RocketEscape(victim2, level3);
- }
- else if (OEN3.equals("Tank") && event.getDamager() instanceof Player) {
- this.Tank(victim2, (Player)event.getDamager(), level3, event);
- }
- else if (OEN3.equals("Valor") && event.getDamager() instanceof Player && ((Player)event.getDamager()).getInventory().getItemInHand().getType().name().contains("SWORD")) {
- this.Valor(event, level3);
- }
- else if (OEN3.equals("Voodoo")) {
- this.Voodoo(damager2, level3);
- }
- else if (OEN3.equals("Wither")) {
- this.Wither(damager2, level3);
- }
- else {
- if (!OEN3.equals("UndeadRuse")) {
- continue;
- }
- this.UndeadRuse(victim2, level3, damager2);
- }
- }
- }
- }
- }
- if (this.repairguard.contains(victim2.getUniqueId())) {
- event.setDamage(event.getFinalDamage() / 2.0);
- }
- if (this.getItemInHand(victim2) != null && this.getItemInHand(victim2).getType().equals((Object)Material.BOW) && this.getItemInHand(victim2).hasItemMeta() && this.getItemInHand(victim2).getItemMeta().hasLore()) {
- for (final String enchant4 : this.getEnchantmentsOnItem(this.getItemInHand(victim2))) {
- final String OEN4 = enchant4.split(" ")[0];
- final int level4 = Integer.parseInt(enchant4.split(" ")[1]);
- final int chance4 = this.getProckChance(enchant4, level4, victim2);
- if (this.random.nextInt(100) <= chance4 && OEN4.equals("Farcast")) {
- this.Farcast(damager2, level4);
- }
- }
- }
- }
- if (event.getEntity() instanceof Player && event.getDamager().getType().name().contains("ARROW") && ((Projectile)event.getDamager()).getShooter() instanceof Player) {
- final Player damager = (Player)((Projectile)event.getDamager()).getShooter();
- final Player victim3 = (Player)event.getEntity();
- boolean heavy = false;
- if (this.getItemInHand(victim3) != null && this.getItemInHand(victim3).hasItemMeta() && this.getItemInHand(victim3).getItemMeta().hasLore()) {
- this.item = this.getItemInHand(victim3);
- for (final String enchant2 : this.getEnchantmentsOnItem(this.item)) {
- final String OEN = this.getOriginalEnchantmentName(enchant2);
- final int level = Integer.parseInt(enchant2.split(" ")[1]);
- final int chance = this.getProckChance(OEN, level, victim3);
- if (this.random.nextInt(100) <= chance && OEN.equals("ArrowBreak") && this.item.getType().name().endsWith("_AXE")) {
- this.ArrowBreak(event, victim3);
- }
- }
- }
- ItemStack[] armorContents5;
- for (int length5 = (armorContents5 = victim3.getInventory().getArmorContents()).length, n3 = 0; n3 < length5; ++n3) {
- final ItemStack is4 = armorContents5[n3];
- if (is4 != null) {
- for (final String enchant5 : this.getEnchantmentsOnItem(is4)) {
- final String OEN5 = enchant5.split(" ")[0];
- if (OEN5.equals("Heavy") || OEN5.equals("Marksman")) {
- final int chance5 = this.getProckChance(OEN5, Integer.parseInt(enchant5.split(" ")[1]), victim3);
- if (this.random.nextInt(100) > chance5) {
- continue;
- }
- if (OEN5.equals("Heavy") && !heavy) {
- heavy = true;
- this.Heavy(event, victim3);
- }
- else {
- if (!OEN5.equals("Marksman") || this.marksman.get(damager) == null) {
- continue;
- }
- this.Marksman(event, this.marksman.get(damager));
- this.marksman.remove(damager);
- }
- }
- }
- }
- }
- heavy = false;
- if (this.unfocus.contains(victim3.getName())) {
- event.setDamage(event.getDamage() * 0.5);
- }
- if (this.bowsp.contains(damager)) {
- for (int i = 0; i < this.bowsp.size(); ++i) {
- if (this.bowsp.get(i) == damager.getUniqueId()) {
- for (final String enchant4 : this.getEnchantmentsOnItem(this.bows.get(i))) {
- final String OEN4 = enchant4.split(" ")[0];
- final int level4 = Integer.parseInt(enchant4.split(" ")[1]);
- final int chance4 = this.getProckChance(OEN4, level4, damager);
- if (this.random.nextInt(100) <= chance4) {
- if (OEN4.equals("ArrowLifesteal")) {
- this.ArrowLifesteal(victim3, damager);
- }
- else if (OEN4.equals("Longbow") && this.getItemInHand(victim3) != null && this.getItemInHand(victim3).getType().equals((Object)Material.BOW)) {
- event.setDamage(event.getDamage() + level4);
- }
- else if (OEN4.equals("Piercing")) {
- this.Piercing(event, level4);
- }
- else if (OEN4.equals("Snare")) {
- this.Snare(victim3, level4);
- }
- else if (OEN4.equals("Sniper")) {
- this.Sniper(event, damager, victim3, level4);
- }
- else {
- if (!OEN4.equals("Unfocus") || this.unfocus.contains(victim3.getName())) {
- continue;
- }
- this.unfocus.add(victim3.getName());
- this.sendStringListMessage(victim3.getUniqueId(), this.enchantmessages[50], 0.0);
- this.getAndPlaySound(victim3, victim3.getLocation(), "enchants.Unfocus", false);
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.Unfocus", false);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (victim3.isOnline()) {
- CustomEnchantments.this.unfocus.remove(victim3.getName());
- CustomEnchantments.this.sendStringListMessage(victim3.getUniqueId(), CustomEnchantments.this.enchantmessages[51], 0.0);
- }
- }
- }, (long)(20 * level4 * 2));
- }
- }
- }
- }
- }
- }
- return;
- }
- if (event.getEntity() instanceof LivingEntity && event.getEntity().getCustomName() != null && event.getEntity().getType().equals((Object)EntityType.IRON_GOLEM) && event.getDamager().getType().name().endsWith("ARROW") && ((Projectile)event.getDamager()).getShooter() instanceof Player && this.bowsp.contains(((Projectile)event.getDamager()).getShooter())) {
- for (int j = 0; j < this.bowsp.size(); ++j) {
- if (this.bowsp.get(j) == ((Player)((Projectile)event.getDamager()).getShooter()).getUniqueId()) {
- for (final String enchant6 : this.getEnchantmentsOnItem(this.bows.get(j))) {
- final String OEN6 = enchant6.split(" ")[0];
- if (OEN6.equals("Hijack") && this.random.nextInt(100) <= this.getProckChance(OEN6, Integer.parseInt(enchant6.split(" ")[1]), (Player)((Projectile)event.getDamager()).getShooter())) {
- for (final Player players : Bukkit.getWorld(event.getEntity().getWorld().getName()).getPlayers()) {
- if (ChatColor.stripColor(event.getEntity().getCustomName()).contains(players.getName())) {
- this.Hijack((IronGolem)event.getEntity(), (Player)((Projectile)event.getDamager()).getShooter(), players);
- return;
- }
- }
- }
- }
- }
- }
- }
- }
- public List<String> getBookLore(final String OEN) {
- return (List<String>)this.enchantmentsInfo.getStringList(String.valueOf(OEN) + ".lore");
- }
- public String getEnchantmentType(final String OEN) {
- return this.enchantmentsInfo.getString(String.valueOf(OEN) + ".enchant-type").toLowerCase();
- }
- public ItemStack formatBookLore(final ItemStack is, final String enchant, final int successPercent, final int destroyPercent) {
- if (this.enchantmentsInfo == null) {
- this.enchantmentsInfo = (FileConfiguration)YamlConfiguration.loadConfiguration(new File(this.randompackage.getDataFolder() + File.separator + "Custom Enchantments" + File.separator, "info.yml"));
- }
- if (is != null && is.hasItemMeta() && is.getItemMeta().hasLore() && is.getItemMeta().hasDisplayName() && enchant != null) {
- this.itemMeta = is.getItemMeta();
- this.lore.clear();
- this.itemMeta.setDisplayName(enchant);
- final String OEN = this.getOriginalEnchantmentName(enchant);
- for (String string : this.itemMeta.getLore()) {
- if (string.equals("{SUCCESS}")) {
- string = this.SUCCESS.replace("{PERCENT}", new StringBuilder().append(successPercent).toString());
- }
- else if (string.equals("{DESTROY}")) {
- string = this.DESTROY.replace("{PERCENT}", new StringBuilder().append(destroyPercent).toString());
- }
- else if (string.equals("{APPLY}")) {
- string = this.APPLY_TO_ITEM;
- }
- else if (string.equals("{BOOK_LORE}")) {
- for (final String booklore : this.enchantmentsInfo.getStringList(String.valueOf(OEN) + ".lore")) {
- this.lore.add(ChatColor.translateAlternateColorCodes('&', booklore));
- }
- }
- else if (string.equals("{ENCHANT_TYPE}")) {
- string = this.itemsConfig.getString("enchant-types." + this.getEnchantmentType(OEN));
- }
- if (!string.equals("{BOOK_LORE}")) {
- this.lore.add(ChatColor.translateAlternateColorCodes('&', string));
- }
- }
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- is.setItemMeta(this.itemMeta);
- return is;
- }
- return null;
- }
- private void setItemInHand(final Player player, final ItemStack is) {
- if (Bukkit.getVersion().contains("1.8")) {
- v1_8.getInstance().setItemInHand(player, is);
- }
- else {
- v1_9.getInstance().setItemInHand(player, is);
- }
- }
- private void removeItem(final PlayerInteractEvent event, final int amount) {
- if (this.getItemInHand(event.getPlayer()) != null) {
- final ItemStack iih = this.getItemInHand(event.getPlayer());
- if (iih.getAmount() - amount <= 0) {
- this.setItemInHand(event.getPlayer(), new ItemStack(Material.AIR));
- }
- else {
- iih.setAmount(iih.getAmount() - amount);
- }
- event.getPlayer().updateInventory();
- }
- }
- @EventHandler
- private void interactArmorEvent(final PlayerInteractEvent event) {
- if (event.getItem() == null || event.getItem().getType().equals((Object)Material.AIR) || !event.getItem().hasItemMeta() || !event.getItem().getItemMeta().hasLore() || (!event.getItem().getType().name().endsWith("HELMET") && !event.getItem().getType().name().endsWith("CHESTPLATE") && !event.getItem().getType().name().endsWith("LEGGINGS") && !event.getItem().getType().name().endsWith("BOOTS"))) {
- return;
- }
- if ((event.getItem().getType().name().endsWith("HELMET") && event.getPlayer().getInventory().getHelmet() == null) || (event.getItem().getType().name().endsWith("CHESTPLATE") && event.getPlayer().getInventory().getChestplate() == null) || (event.getItem().getType().name().endsWith("LEGGINGS") && event.getPlayer().getInventory().getLeggings() == null) || (event.getItem().getType().name().endsWith("BOOTS") && event.getPlayer().getInventory().getBoots() == null)) {
- if (event.getAction().equals((Object)Action.RIGHT_CLICK_AIR) || event.getAction().equals((Object)Action.RIGHT_CLICK_BLOCK)) {
- if (event.getAction().equals((Object)Action.RIGHT_CLICK_BLOCK) && this.mcmmo != null && (event.getClickedBlock().getType().equals((Object)Material.GOLD_BLOCK) || event.getClickedBlock().getType().equals((Object)Material.IRON_BLOCK))) {
- return;
- }
- final ItemStack item = event.getItem();
- Bukkit.getScheduler().scheduleSyncDelayedTask(RandomPackage.getPlugin, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (CustomEnchantments.this.getItemInHand(event.getPlayer()).equals((Object)item)) {
- return;
- }
- for (final String enchant : CustomEnchantments.this.getEnchantmentsOnItem(item)) {
- final String OEN = enchant.split(" ")[0];
- if (CustomEnchantments.this.potioneffectEnchants.contains(OEN)) {
- CustomEnchantments.this.potionEffects(event.getPlayer(), enchant, false);
- }
- }
- }
- }, 1L);
- }
- }
- else if (event.isCancelled() && event.getItem() != null && event.getAction().name().contains("RIGHT_CLICK") && ((event.getItem().getType().name().endsWith("HELMET") && event.getPlayer().getInventory().getHelmet() != null) || (event.getItem().getType().name().endsWith("CHESTPLATE") && event.getPlayer().getInventory().getChestplate() != null) || (event.getItem().getType().name().endsWith("LEGGINGS") && event.getPlayer().getInventory().getLeggings() != null) || (event.getItem().getType().name().endsWith("BOOTS") && event.getPlayer().getInventory().getBoots() != null))) {
- final List<String> enchantsonitem = this.getEnchantmentsOnItem(event.getItem());
- List<String> enchantsonarmor = null;
- if (event.getItem().getType().name().endsWith("HELMET")) {
- this.item = event.getPlayer().getInventory().getHelmet();
- }
- else if (event.getItem().getType().name().endsWith("CHESTPLATE")) {
- this.item = event.getPlayer().getInventory().getChestplate();
- }
- else if (event.getItem().getType().name().endsWith("LEGGINGS")) {
- this.item = event.getPlayer().getInventory().getLeggings();
- }
- else if (event.getItem().getType().name().endsWith("BOOTS")) {
- this.item = event.getPlayer().getInventory().getBoots();
- }
- enchantsonarmor = this.getEnchantmentsOnItem(this.item);
- for (final String enchant : enchantsonarmor) {
- if (this.potioneffectEnchants.contains(enchant.split(" ")[0])) {
- this.potionEffects(event.getPlayer(), enchant, true);
- }
- }
- for (final String enchant : enchantsonitem) {
- if (this.potioneffectEnchants.contains(enchant.split(" ")[0])) {
- this.potionEffects(event.getPlayer(), enchant, false);
- }
- }
- if (event.getItem().getType().name().endsWith("HELMET")) {
- event.getPlayer().getInventory().setHelmet(event.getItem());
- }
- else if (event.getItem().getType().name().endsWith("CHESTPLATE")) {
- event.getPlayer().getInventory().setChestplate(event.getItem());
- }
- else if (event.getItem().getType().name().endsWith("LEGGINGS")) {
- event.getPlayer().getInventory().setLeggings(event.getItem());
- }
- else if (event.getItem().getType().name().endsWith("BOOTS")) {
- event.getPlayer().getInventory().setBoots(event.getItem());
- }
- this.setItemInHand(event.getPlayer(), this.item);
- event.getPlayer().updateInventory();
- }
- }
- @EventHandler
- private void playerInteractEvent(final PlayerInteractEvent event) {
- if (event.getItem() != null && event.getItem().hasItemMeta() && event.getItem().getItemMeta().hasLore()) {
- final ItemStack fireball = this.getFireballRarity(event.getItem());
- final String revealitemrarity = this.getRevealItemRarity(event.getItem());
- if (event.getItem().getItemMeta().hasDisplayName() && this.allcustomenchantments.contains(event.getItem().getItemMeta().getDisplayName())) {
- this.sendStringListMessage(event.getPlayer().getUniqueId(), this.applyinfo, 0.0);
- event.setCancelled(true);
- }
- else if (fireball != null) {
- event.setCancelled(true);
- this.removeItem(event, 1);
- this.item = fireball.clone();
- this.itemMeta = this.item.getItemMeta();
- this.lore.clear();
- if (!this.item.equals((Object)this.items[20])) {
- this.getAndPlaySound(event.getPlayer(), event.getPlayer().getLocation(), "dust.reveal-dust", false);
- for (int i = 1; i <= 15; ++i) {
- event.getPlayer().getWorld().playEffect(event.getPlayer().getEyeLocation(), Effect.SPELL, 1);
- }
- }
- else {
- this.getAndPlaySound(event.getPlayer(), event.getPlayer().getLocation(), "dust.reveal-mystery-dust", false);
- for (int i = 1; i <= 15; ++i) {
- event.getPlayer().getWorld().playEffect(event.getPlayer().getEyeLocation(), Effect.LAVA_POP, 1);
- }
- }
- final int randomprimal = this.getRandomPrimalPercent();
- final int randomregular = this.getRandomDustPercent();
- for (String string : this.itemMeta.getLore()) {
- if (string.contains("{PERCENT}")) {
- if (this.regulardust.values().contains(this.item)) {
- string = string.replace("{PERCENT}", new StringBuilder().append(randomregular).toString());
- }
- else {
- string = string.replace("{PERCENT}", new StringBuilder().append(randomprimal).toString());
- }
- }
- this.lore.add(string);
- }
- this.itemMeta.setLore((List)this.lore);
- this.lore.clear();
- this.item.setItemMeta(this.itemMeta);
- this.giveItem(event.getPlayer(), this.item);
- }
- else if (revealitemrarity != null) {
- event.setCancelled(true);
- ArrayList<String> enchantments = null;
- String enchant = null;
- if (revealitemrarity.equals("random")) {
- enchantments = this.customenchantments.get(this.customenchantments.keySet().toArray()[this.random.nextInt(this.customenchantments.size())]);
- }
- else {
- enchantments = this.customenchantments.get(revealitemrarity);
- }
- if (enchantments.size() == 0) {
- return;
- }
- enchant = enchantments.get(this.random.nextInt(enchantments.size()));
- this.item = this.getBook(enchant, this.getEnchantmentLevel(enchant), this.random.nextInt(101), this.random.nextInt(101));
- this.removeItem(event.getPlayer(), event.getItem(), 1);
- this.giveItem(event.getPlayer(), this.item);
- for (String string : this.revealitemsmessages.get(revealitemrarity)) {
- if (string.contains("{BOOK_NAME}")) {
- string = string.replace("{BOOK_NAME}", enchant);
- }
- event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
- }
- if (this.shootfireworks) {
- final Firework fw = (Firework)event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), (Class)Firework.class);
- final FireworkMeta fwm = fw.getFireworkMeta();
- String[] string2 = null;
- string2 = this.revealeditemsfirework.get(revealitemrarity).toLowerCase().replace(" ", "").split("\\:");
- fwm.addEffects(new FireworkEffect[] { FireworkEffect.builder().trail(true).flicker(true).with(FireworkEffect.Type.valueOf(string2[0].toUpperCase())).withColor(this.getColor(string2[1])).withFade(this.getColor(string2[2])).withFlicker().withTrail().build() });
- fwm.setPower(Integer.parseInt(string2[3]));
- fw.setFireworkMeta(fwm);
- }
- }
- else if (event.getItem().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore())) {
- event.setCancelled(true);
- if (this.soulmode.contains(event.getPlayer().getUniqueId())) {
- this.soulmode.remove(event.getPlayer().getUniqueId());
- this.sendStringListMessage(event.getPlayer().getUniqueId(), this.soulmodedeactivatedInteract, 0.0);
- }
- else if (this.getRemainingIntFromString(event.getItem().getItemMeta().getDisplayName()) <= 0) {
- this.sendStringListMessage(event.getPlayer().getUniqueId(), this.soulmodedeactivatedRanOut, 0.0);
- }
- else {
- this.soulmode.add(event.getPlayer().getUniqueId());
- this.getAndPlaySound(event.getPlayer(), event.getPlayer().getLocation(), "soul-mode.enter", false);
- this.sendStringListMessage(event.getPlayer().getUniqueId(), this.soulmodeactivate, 0.0);
- }
- }
- else {
- if (!event.getItem().getType().name().endsWith("AXE") && !event.getItem().getType().name().endsWith("SPADE")) {
- return;
- }
- for (final String enchant2 : this.getEnchantmentsOnItem(event.getItem())) {
- final String OEN = enchant2.split(" ")[0];
- if (OEN.equals("Haste") || OEN.equals("ObsidianDestroyer")) {
- final int level = Integer.parseInt(enchant2.split(" ")[1]);
- final int chance = this.getProckChance(OEN, level, event.getPlayer());
- if (this.random.nextInt(100) > chance) {
- continue;
- }
- if (OEN.equals("Haste")) {
- this.Haste(event, level);
- }
- else {
- if (!OEN.equals("ObsidianDestroyer") || this.fapi.blockIsProtected(event.getPlayer(), event.getClickedBlock())) {
- continue;
- }
- this.ObsidianDestroyer(event, level);
- }
- }
- }
- }
- event.getPlayer().updateInventory();
- }
- }
- private int getRandomPrimalPercent() {
- return 10 + this.random.nextInt(21);
- }
- private int getRandomDustPercent() {
- return 1 + this.random.nextInt(9);
- }
- @EventHandler
- private void playerDropItemEvent(final PlayerDropItemEvent event) {
- if (!event.isCancelled() && this.soulmode.contains(event.getPlayer().getUniqueId()) && event.getItemDrop().getItemStack().hasItemMeta() && event.getItemDrop().getItemStack().getItemMeta().hasLore() && event.getItemDrop().getItemStack().getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore())) {
- this.soulmode.remove(event.getPlayer().getUniqueId());
- this.sendStringListMessage(event.getPlayer().getUniqueId(), this.soulmodedeactivatedDropped, 0.0);
- }
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- private void blockBreakEvent(final BlockBreakEvent event) {
- if (event.isCancelled() || this.getItemInHand(event.getPlayer()) == null || !this.getItemInHand(event.getPlayer()).hasItemMeta() || !this.getItemInHand(event.getPlayer()).getItemMeta().hasLore() || event.getPlayer().getGameMode().equals((Object)GameMode.CREATIVE)) {
- return;
- }
- final Player player = event.getPlayer();
- for (final String enchant : this.getEnchantmentsOnItem(this.getItemInHand(event.getPlayer()))) {
- final String OEN = enchant.split(" ")[0];
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- final int chance = this.getProckChance(OEN, level, player);
- if (this.random.nextInt(100) <= chance) {
- if (OEN.equals("AutoSmelt")) {
- this.AutoSmelt(event, event.getPlayer(), event.getBlock().getType(), level);
- }
- else if (OEN.equals("Detonate")) {
- this.Detonate(event, player, event.getBlock().getType());
- }
- else if (OEN.equals("Experience")) {
- this.Experience(event, player, level);
- }
- else if (OEN.equals("Oxygenate")) {
- this.Oxygenate(player);
- }
- else {
- if (!OEN.equals("Telepathy") || event.getBlock().getType().equals((Object)Material.MOB_SPAWNER)) {
- continue;
- }
- for (final ItemStack is : event.getBlock().getDrops()) {
- this.giveItem(player, is);
- }
- event.setCancelled(true);
- event.getBlock().setType(Material.AIR);
- }
- }
- }
- }
- @EventHandler
- private void playerItemHeldEvent(final PlayerItemHeldEvent event) {
- if (this.divineimmolation.contains(event.getPlayer().getUniqueId())) {
- this.divineimmolation.remove(event.getPlayer().getUniqueId());
- }
- if (this.soulmode.contains(event.getPlayer().getUniqueId()) && event.getPlayer().getInventory().getItem(event.getNewSlot()) != null && event.getPlayer().getInventory().getItem(event.getNewSlot()).getType().name().endsWith("SWORD")) {
- for (final String enchant : this.getEnchantmentsOnItem(event.getPlayer().getInventory().getItem(event.getNewSlot()))) {
- if (enchant.split(" ")[0].equals("DivineImmolation")) {
- this.divineimmolation.add(event.getPlayer().getUniqueId());
- }
- }
- }
- }
- private void DivineImmolation(final EntityDamageByEntityEvent event, final int level) {
- event.getEntity().setFireTicks(level * 20 + 40);
- if (event.getEntity() instanceof Player) {
- ((Damageable)event.getEntity()).damage(level * 1.5);
- }
- else {
- ((Damageable)event.getEntity()).damage(level * 3.5);
- }
- for (final Entity entity : event.getEntity().getNearbyEntities(level * 1.5, level * 1.5, level * 1.5)) {
- if (!(entity instanceof Player) || (entity instanceof Player && entity != event.getDamager() && this.fapi.relationIsEnemyOrNull((Player)event.getDamager(), (Player)entity))) {
- entity.setFireTicks(level * 20 + 40);
- if (entity instanceof Player) {
- ((Damageable)entity).damage(level * 1.5);
- }
- else {
- if (!(entity instanceof Damageable)) {
- continue;
- }
- ((Damageable)entity).damage(level * 3.5);
- }
- }
- }
- }
- private void Immortal(final Player victim, final ItemStack is) {
- is.setDurability((short)(is.getDurability() - 1));
- }
- private void NaturesWrath(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- for (final Entity entity : victim.getNearbyEntities(45.0, 45.0, 45.0)) {
- if ((entity instanceof Player && this.fapi.relationIsEnemyOrNull(victim, (Player)entity)) || (!(entity instanceof Player) && entity instanceof Damageable)) {
- for (int i = 0; i <= 11; ++i) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (!entity.isDead()) {
- victim.getWorld().strikeLightning(entity.getLocation());
- }
- }
- }, (long)(20 * i));
- }
- if (!(entity instanceof Player)) {
- continue;
- }
- final Player Player = (Player)entity;
- Player.setWalkSpeed(0.0f);
- this.sendStringListMessage(Player.getUniqueId(), this.enchantmessages[13], 0.0);
- Bukkit.getScheduler().scheduleSyncDelayedTask(RandomPackage.getPlugin, (Runnable)new Runnable() {
- @Override
- public void run() {
- Player.setWalkSpeed(0.2f);
- }
- }, 220L);
- }
- }
- }
- private void Phoenix(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- if (!this.phoenix.contains(victim)) {
- this.phoenix.add(victim.getUniqueId());
- event.setCancelled(true);
- victim.setHealth(victim.getMaxHealth());
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Phoenix", true);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.phoenix.remove(victim);
- }
- }, (long)(12000 - 1200 * level));
- }
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- private void projectileLaunchEvent(final ProjectileLaunchEvent event) {
- if (event.getEntityType().equals((Object)EntityType.ENDER_PEARL) && event.getEntity().getShooter() instanceof Player && this.Teleblock.contains(event.getEntity().getShooter())) {
- event.setCancelled(true);
- this.giveItem((Player)event.getEntity().getShooter(), new ItemStack(Material.ARROW, 1));
- ((Player)event.getEntity().getShooter()).updateInventory();
- }
- }
- private void Teleblock(final Player victim, final int level) {
- if (!this.Teleblock.contains(victim)) {
- this.Teleblock.add(victim.getUniqueId());
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.Teleblock.remove(victim);
- }
- }, (long)(20 * level + 100));
- }
- if (victim.getInventory().first(Material.ENDER_PEARL) != -1) {
- this.removeItem(victim, victim.getInventory().getItem(victim.getInventory().first(Material.ENDER_PEARL)), this.random.nextInt(12) + level);
- }
- }
- private void depleteSouls(final Player player, final ItemStack is, final int currentSouls, int depleteBy) {
- if (currentSouls - depleteBy <= 0) {
- this.sendStringListMessage(player.getUniqueId(), this.soulmodedeactivatedRanOut, 0.0);
- depleteBy = currentSouls;
- this.soulmode.remove(player.getUniqueId());
- }
- (this.itemMeta = is.getItemMeta()).setDisplayName(this.itemMeta.getDisplayName().replace(new StringBuilder().append(currentSouls).toString(), new StringBuilder().append(currentSouls - depleteBy).toString()));
- is.setItemMeta(this.itemMeta);
- }
- private ItemStack getSoulGemInPlayerInventory(final Player player, final boolean checkWholeInv) {
- int size = 0;
- if (checkWholeInv) {
- size = player.getInventory().getSize();
- }
- else {
- size = 9;
- }
- for (int i = 0; i < size; ++i) {
- this.item = player.getInventory().getItem(i);
- if (this.item != null && !this.item.getType().equals((Object)Material.AIR) && this.item.hasItemMeta() && this.item.getItemMeta().hasDisplayName() && this.item.getItemMeta().hasLore() && this.item.getItemMeta().getLore().equals(this.items[22].getItemMeta().getLore())) {
- return this.item;
- }
- }
- return null;
- }
- @EventHandler
- private void entityShootBowEvent(final EntityShootBowEvent event) {
- if (event.isCancelled() || !(event.getEntity() instanceof Player) || (Bukkit.getPluginManager().getPlugin("WorldEdit") != null && Bukkit.getPluginManager().getPlugin("WorldGuard") != null && !RP_WorldEditWorldGuard.getInstance().locationHasPvPAllowed(event.getEntity().getWorld(), event.getProjectile().getLocation()))) {
- return;
- }
- final Player player = (Player)event.getEntity();
- if (event.getBow().hasItemMeta() && event.getBow().getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(event.getBow())) {
- final String OEN = enchant.split(" ")[0];
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- final int chance = this.getProckChance(OEN, Integer.parseInt(enchant.split(" ")[1]), player);
- if ((this.random.nextInt(100) <= chance || OEN.equals("Teleblock")) && !OEN.equals("Cowification") && OEN.equals("Teleblock") && this.soulmode.contains(player.getUniqueId())) {
- this.depleteSouls(player, this.item = this.getSoulGemInPlayerInventory(player, false), this.getRemainingIntFromString(this.item.getItemMeta().getDisplayName()), level * 6);
- this.teleblock.put(player, event.getBow());
- }
- }
- }
- double marksmanDamage = 0.0;
- ItemStack[] armorContents;
- for (int length = (armorContents = player.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack is = armorContents[i];
- if (is != null && is.hasItemMeta() && is.getItemMeta().hasLore()) {
- for (final String enchant2 : this.getEnchantmentsOnItem(is)) {
- final String OEN2 = enchant2.split(" ")[0];
- final int level2 = Integer.parseInt(enchant2.split(" ")[1]);
- if (OEN2.equals("Marksman")) {
- marksmanDamage += level2 * 0.25;
- }
- }
- }
- }
- if (marksmanDamage != 0.0) {
- this.marksman.put(player, marksmanDamage);
- }
- this.bows.add(event.getBow());
- this.bowsp.add(event.getEntity().getUniqueId());
- }
- @EventHandler
- private void projectileHitEvent(final ProjectileHitEvent event) {
- if (event.getEntity().getShooter() instanceof Player && event.getEntity().getType().name().contains("ARROW")) {
- final Player shooter = (Player)event.getEntity().getShooter();
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- Entity h = null;
- if (event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).size() != 0) {
- h = event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).get(0);
- }
- if (shooter != null && CustomEnchantments.this.bowsp.contains(shooter.getUniqueId())) {
- for (int i = 0; i < CustomEnchantments.this.bowsp.size(); ++i) {
- if (CustomEnchantments.this.bowsp.get(i) == shooter.getUniqueId()) {
- for (final String enchant : CustomEnchantments.this.getEnchantmentsOnItem(CustomEnchantments.this.bows.get(i))) {
- final String OEN = enchant.split(" ")[0];
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- final int chance = CustomEnchantments.this.getProckChance(OEN, level, shooter);
- if (CustomEnchantments.this.random.nextInt(100) <= chance || (OEN.equals("Teleblock") && CustomEnchantments.this.soulmode.contains(shooter.getUniqueId()) && CustomEnchantments.this.teleblock.get(shooter) != null && event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).size() >= 1 && event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).get(0) instanceof Player)) {
- if (OEN.equals("EagleEye") && h != null && h instanceof Player) {
- CustomEnchantments.this.EagleEye((Player)h);
- }
- else if (OEN.equals("DimensionRift")) {
- CustomEnchantments.this.DimensionRift(h, level);
- }
- else if (OEN.equals("Explosive")) {
- CustomEnchantments.this.Explosive(event.getEntity().getLocation(), event.getEntity());
- }
- else if (OEN.equals("Hellfire")) {
- CustomEnchantments.this.Hellfire(event.getEntity(), shooter, level);
- }
- else if (OEN.equals("Lightning")) {
- CustomEnchantments.this.Lightning(event.getEntity().getLocation(), event.getEntity());
- }
- else {
- if (!OEN.equals("Teleblock")) {
- continue;
- }
- CustomEnchantments.this.Teleblock(event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).get(0), level);
- }
- }
- }
- CustomEnchantments.this.marksman.remove(shooter);
- CustomEnchantments.this.teleblock.remove(shooter);
- CustomEnchantments.this.bowsp.remove(i);
- CustomEnchantments.this.bows.remove(i);
- return;
- }
- }
- }
- }
- }, 1L);
- }
- }
- @EventHandler
- private void entityTargetLivingEntityEvent(final EntityTargetLivingEntityEvent event) {
- if (event.getEntity().getCustomName() != null && event.getTarget() instanceof Player && ((event.getEntityType().equals((Object)EntityType.IRON_GOLEM) && event.getEntity().getCustomName().equals(this.guardiansname.replace("{PLAYER}", event.getTarget().getName()))) || (event.getEntityType().equals((Object)EntityType.ZOMBIE) && event.getEntity().getCustomName().equals(this.undeadrusename.replace("{PLAYER}", event.getTarget().getName()))) || (event.getEntityType().equals((Object)EntityType.BLAZE) && event.getEntity().getCustomName().equals(this.spiritsname.replace("{PLAYER}", event.getTarget().getName()))))) {
- event.setCancelled(true);
- }
- }
- private void Aegis(final EntityDamageByEntityEvent event, final Player damager, final int level) {
- if (!this.aegis.keySet().contains(event.getEntity())) {
- this.aegis.put((Player)event.getEntity(), new ArrayList<Player>());
- }
- if (!this.aegis.get(event.getEntity()).isEmpty() && this.aegis.get(event.getEntity()).contains(damager) && 8 - level >= this.aegis.get(event.getEntity()).size()) {
- event.setDamage(event.getDamage() * this.doubles[2]);
- }
- else {
- this.aegis.get(event.getEntity()).add(damager);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.aegis.get(event.getEntity()).remove(damager);
- }
- }, 200L);
- }
- }
- private void Angelic(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Angelic", level);
- }
- private void ArrowBreak(final EntityDamageByEntityEvent event, final Player victim) {
- event.setCancelled(true);
- event.getDamager().remove();
- this.sendStringListMessage(victim.getUniqueId(), this.enchantmessages[1], 0.0);
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.ArrowBreak", true);
- }
- private void ArrowDeflect(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- if (this.arrowdeflect.contains(String.valueOf(victim.getName()) + level)) {
- event.setCancelled(true);
- }
- else {
- this.arrowdeflect.add(String.valueOf(victim.getName()) + level);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.arrowdeflect.remove(String.valueOf(victim.getName()) + level);
- }
- }, (long)(40 - (int)(0.4 * level)));
- }
- }
- private void ArrowLifesteal(final Player victim, final Player damager) {
- if (victim.getHealth() - 1.0 <= 0.0) {
- victim.setHealth(0.0);
- }
- else {
- victim.setHealth(victim.getHealth() - 1.0);
- }
- damager.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20, 2));
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.ArrowLifesteal", false);
- }
- private void Armored(final Player victim, final Player damager, final int level, final EntityDamageByEntityEvent event) {
- if (this.getItemInHand(damager) == null || !this.getItemInHand(damager).getType().name().endsWith("_SWORD")) {
- return;
- }
- double dividedDamage = 0.0;
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack item = armorContents[i];
- for (final String enchant : this.getEnchantmentsOnItem(item)) {
- if (enchant.split(" ")[0].equals("Armored")) {
- dividedDamage += 1.85 * level;
- }
- }
- }
- event.setDamage(event.getDamage() / dividedDamage);
- }
- private void Assassin(final EntityDamageByEntityEvent event, final int level) {
- if (event.getEntity().getLocation().distance(event.getDamager().getLocation()) <= this.doubles[3]) {
- event.setDamage(event.getDamage() * (1.0 + level * this.doubles[4]));
- }
- else {
- event.setDamage(event.getDamage() * this.doubles[5]);
- }
- }
- private void AutoSmelt(final BlockBreakEvent event, final Player player, final Material material, int level) {
- if (material.equals((Object)Material.GOLD_ORE) || material.equals((Object)Material.IRON_ORE)) {
- event.setCancelled(true);
- event.getBlock().setType(Material.AIR);
- for (final Enchantment enchant : this.getItemInHand(player).getEnchantments().keySet()) {
- if (enchant.equals((Object)Enchantment.LOOT_BONUS_BLOCKS)) {
- int fortune = this.random.nextInt(this.getItemInHand(player).getEnchantmentLevel(enchant) + 1);
- if (fortune == 0) {
- fortune = 1;
- }
- level *= fortune;
- }
- }
- this.giveItem(player, new ItemStack(Material.getMaterial(material.name().replace("ORE", "INGOT")), level, (short)0));
- this.getAndPlaySound(player, event.getBlock().getLocation(), "enchants.AutoSmelt", true);
- }
- }
- private void Barbarian(final EntityDamageByEntityEvent event, final int level, final Player player) {
- if (event.getEntity() instanceof Player && this.getItemInHand((Player)event.getEntity()) != null && this.getItemInHand((Player)event.getEntity()).getType().name().endsWith("_AXE")) {
- event.setDamage(event.getDamage() * (1.1 + level * 0.05));
- this.getAndPlaySound(player, player.getLocation(), "enchants.Barbarian", true);
- }
- }
- private void Berserk(final Player player, final int level) {
- this.givePotionEffects(null, player, "Berserk", level);
- }
- private void Blacksmith(final EntityDamageByEntityEvent event, final Player damager, final int level) {
- event.setDamage(event.getDamage() * 0.5);
- final int amount = this.random.nextInt(2) + 1;
- ItemStack piece = new ItemStack(Material.LEATHER_BOOTS, 1);
- ItemStack[] armorContents;
- for (int length = (armorContents = damager.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack is = armorContents[i];
- if (is != null && is.getDurability() > piece.getDurability()) {
- piece = is;
- }
- }
- if (piece.getDurability() - amount < 0) {
- piece.setDurability((short)0);
- }
- else {
- piece.setDurability((short)(piece.getDurability() - amount));
- }
- this.sendStringListMessage(damager.getUniqueId(), this.enchantmessages[2], 0.0);
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.Blacksmith", true);
- damager.updateInventory();
- }
- public void Blessed(final Player player) {
- for (final PotionEffect pe : player.getActivePotionEffects()) {
- final PotionEffectType type = pe.getType();
- if (type.equals((Object)PotionEffectType.BLINDNESS) || type.equals((Object)PotionEffectType.CONFUSION) || type.equals((Object)PotionEffectType.HARM) || type.equals((Object)PotionEffectType.HUNGER) || type.equals((Object)PotionEffectType.POISON) || type.equals((Object)PotionEffectType.SLOW) || type.equals((Object)PotionEffectType.SLOW_DIGGING) || type.equals((Object)PotionEffectType.WEAKNESS) || type.equals((Object)PotionEffectType.WITHER) || (!Bukkit.getVersion().contains("1.8") && type.equals((Object)PotionEffectType.getByName("UNLUCK"))) || (!Bukkit.getVersion().contains("1.8") && type.equals((Object)PotionEffectType.getByName("LEVITATION"))) || (!Bukkit.getVersion().contains("1.8") && type.equals((Object)PotionEffectType.getByName("GLOWING")))) {
- player.removePotionEffect(type);
- }
- }
- this.sendStringListMessage(player.getUniqueId(), this.enchantmessages[3], 0.0);
- }
- private void Blind(final EntityDamageByEntityEvent event, final int level) {
- ((LivingEntity)event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * level + 40, level - 1));
- }
- private void BloodLink(final Player player) {
- final int randomhealth = this.random.nextInt(2) + 1;
- if (player.getHealth() + randomhealth <= player.getMaxHealth()) {
- player.setHealth(player.getHealth() + randomhealth);
- }
- this.sendStringListMessage(player.getUniqueId(), this.enchantmessages[4], randomhealth);
- }
- private void Cactus(final LivingEntity damager, final int level) {
- damager.damage((double)level);
- }
- private void Cleave(final Player damager, final LivingEntity victim, final int level, final EntityDamageByEntityEvent event) {
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.Cleave", true);
- final String[] area = this.enchantments.getString("Cleave.area").replace("level", new StringBuilder().append(level).toString()).replace("\\s", "").replace(" ", "").split("\\:");
- for (final Entity entity : victim.getNearbyEntities((double)this.evaluate(area[0]), (double)this.evaluate(area[1]), (double)this.evaluate(area[2]))) {
- if ((!(entity instanceof Player) && entity instanceof Damageable) || (entity instanceof Player && this.fapi.relationIsEnemyOrNull(damager, (Player)entity))) {
- ((Damageable)entity).damage(event.getFinalDamage() * 0.25);
- if (!this.getItemInHand(damager).getItemMeta().hasEnchant(Enchantment.FIRE_ASPECT) || this.random.nextInt(100) > this.enchantments.getInt("Cleave.fire-aspect")) {
- continue;
- }
- entity.setFireTicks(10 * level);
- }
- }
- }
- private void Commander(final Player player, final int level) {
- player.getWorld().playEffect(new Location(player.getWorld(), player.getEyeLocation().getX(), player.getEyeLocation().getY() + 0.5, player.getEyeLocation().getZ()), Effect.STEP_SOUND, (Object)Material.DIAMOND_BLOCK);
- final String[] string = this.enchantments.getString("Commander.area").toLowerCase().replace("level", new StringBuilder().append(level).toString()).replace(" ", "").split("\\:");
- for (final Entity entity : player.getNearbyEntities((double)this.evaluate(string[0]), (double)this.evaluate(string[1]), (double)this.evaluate(string[2]))) {
- if (entity instanceof Player && this.fapi.relationIsAlly(player, (Player)entity)) {
- this.givePotionEffects(null, (Player)entity, "Commander", level);
- }
- }
- }
- private void Confusion(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Confusion", level);
- }
- private void Cowification(final EntityShootBowEvent event) {
- if (event.getForce() == 1.0f && event.getEntity() instanceof Player) {
- event.getProjectile().setCustomName("CowificationArrow");
- event.getProjectile().setCustomNameVisible(false);
- final Cow cow = (Cow)event.getProjectile().getWorld().spawn(event.getProjectile().getLocation().add(0.0, 1.25, 0.0), (Class)Cow.class);
- cow.setAgeLock(true);
- cow.setVelocity(event.getProjectile().getVelocity());
- cow.setCustomName("CowificationCow");
- cow.setCustomNameVisible(false);
- }
- }
- private void CreeperArmor(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- event.setDamage(event.getDamage() / level);
- event.setCancelled(true);
- }
- private void Curse(final Player victim, final int level) {
- this.givePotionEffects((LivingEntity)victim, null, "Curse", level);
- }
- private void Deathbringer(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Deathbringer", level);
- }
- private void DeathGod(final EntityDamageByEntityEvent event, final int level) {
- final Player victim = (Player)event.getEntity();
- if (victim.getHealth() <= level + 4) {
- event.setDamage(0.0);
- victim.setHealth(victim.getHealth() + 5.0);
- }
- }
- @EventHandler
- private void playerDeathEvent(final PlayerDeathEvent event) {
- if (this.bowsp.contains(event.getEntity())) {
- for (int i = 0; i < this.bowsp.size(); ++i) {
- if (this.bowsp.get(i).equals(event.getEntity())) {
- this.bowsp.remove(i);
- }
- this.bows.remove(i);
- }
- }
- if (this.soulmode.contains(event.getEntity().getUniqueId())) {
- this.soulmode.remove(event.getEntity().getUniqueId());
- }
- if (this.divineimmolation.contains(event.getEntity().getUniqueId())) {
- this.divineimmolation.remove(event.getEntity().getUniqueId());
- }
- if (event.getEntity().getKiller() instanceof Player && this.getItemInHand(event.getEntity().getKiller()) != null && this.getItemInHand(event.getEntity().getKiller()).hasItemMeta() && this.getItemInHand(event.getEntity().getKiller()).getItemMeta().hasLore()) {
- this.item = this.getItemInHand(event.getEntity().getKiller());
- for (final String enchant : this.getEnchantmentsOnItem(this.item)) {
- final String OEN = enchant.split(" ")[0];
- if (OEN.equals("Decapitation") || OEN.equals("Lifebloom")) {
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- final int chance = this.getProckChance(OEN, level, event.getEntity());
- if (this.random.nextInt(100) > chance) {
- continue;
- }
- if (OEN.equals("Decapitation") || OEN.equals("Headless")) {
- this.DecapitationHeadless(event.getEntity());
- }
- else {
- if (!OEN.equals("Lifebloom")) {
- continue;
- }
- this.Lifebloom(event.getEntity(), level);
- }
- }
- }
- }
- }
- private void DecapitationHeadless(final Player victim) {
- this.item = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
- final SkullMeta skullMeta = (SkullMeta)this.item.getItemMeta();
- skullMeta.setOwner(victim.getName());
- this.item.setItemMeta((ItemMeta)skullMeta);
- victim.getWorld().dropItem(victim.getLocation(), this.item);
- }
- private void DeepWounds(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- this.givePotionEffects(null, victim, "DeepWounds", level);
- }
- private void Demonforged(final Player victim, final int level, final int chance) {
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack item = armorContents[i];
- if (item != null) {
- item.setDurability((short)(item.getDurability() - Math.subtractExact(chance, 9)));
- }
- }
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Demonforged", false);
- }
- private void Detonate(final BlockBreakEvent event, final Player player, Material material) {
- for (int i = 1; i <= 7; ++i) {
- Location loc = new Location(event.getPlayer().getWorld(), 0.0, 0.0, 0.0);
- if (i == 1) {
- material = event.getBlock().getType();
- loc = event.getBlock().getLocation();
- }
- else if (i == 2) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY() + 1, event.getBlock().getLocation().getBlockZ()).getType();
- loc = new Location(event.getBlock().getWorld(), (double)event.getBlock().getLocation().getBlockX(), (double)(event.getBlock().getLocation().getBlockY() + 1), (double)event.getBlock().getLocation().getBlockZ());
- }
- else if (i == 3) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY() - 1, event.getBlock().getLocation().getBlockZ()).getType();
- loc = new Location(event.getBlock().getWorld(), (double)event.getBlock().getLocation().getBlockX(), (double)(event.getBlock().getLocation().getBlockY() - 1), (double)event.getBlock().getLocation().getBlockZ());
- }
- else if (i == 4) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX() + 1, event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ()).getType();
- loc = new Location(event.getBlock().getWorld(), (double)(event.getBlock().getLocation().getBlockX() + 1), (double)event.getBlock().getLocation().getBlockY(), (double)event.getBlock().getLocation().getBlockZ());
- }
- else if (i == 5) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX() - 1, event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ()).getType();
- loc = new Location(event.getBlock().getWorld(), (double)(event.getBlock().getLocation().getBlockX() - 1), (double)event.getBlock().getLocation().getBlockY(), (double)event.getBlock().getLocation().getBlockZ());
- }
- else if (i == 6) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ() + 1).getType();
- loc = new Location(event.getBlock().getWorld(), (double)event.getBlock().getLocation().getBlockX(), (double)event.getBlock().getLocation().getBlockY(), (double)(event.getBlock().getLocation().getBlockZ() + 1));
- }
- else if (i == 7) {
- material = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ() - 1).getType();
- loc = new Location(event.getBlock().getWorld(), (double)event.getBlock().getLocation().getBlockX(), (double)event.getBlock().getLocation().getBlockY(), (double)(event.getBlock().getLocation().getBlockZ() - 1));
- }
- if (this.detonate.contains(material.name())) {
- return;
- }
- loc.getWorld().getBlockAt(loc).breakNaturally();
- loc.getWorld().playEffect(event.getBlock().getLocation(), Effect.EXPLOSION_LARGE, 1);
- this.getAndPlaySound(player, event.getBlock().getLocation(), "enchants.Detonate", true);
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + event.getPlayer().getName() + " ~ ~ ~ particle flame " + loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ() + " 0.25 0.5 0.25 0 25");
- }
- }
- private void DimensionRift(final Entity entity, final int level) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- final Location loc = new Location(entity.getWorld(), (double)entity.getLocation().getBlockX(), (double)(entity.getLocation().getBlockY() - 1), (double)entity.getLocation().getBlockZ());
- final Location loc2 = new Location(entity.getWorld(), (double)entity.getLocation().getBlockX(), (double)entity.getLocation().getBlockY(), (double)entity.getLocation().getBlockZ());
- final Material prev = entity.getWorld().getBlockAt(loc).getType();
- final Material prev2 = entity.getWorld().getBlockAt(loc2).getType();
- boolean did = false;
- if (CustomEnchantments.this.random.nextInt(100) <= CustomEnchantments.this.doubles[13]) {
- did = true;
- }
- entity.getWorld().getBlockAt(loc).setType(Material.SOUL_SAND);
- if (did) {
- entity.getWorld().getBlockAt(loc2).setType(Material.WEB);
- }
- final boolean o = did;
- Bukkit.getScheduler().scheduleSyncDelayedTask(CustomEnchantments.this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- entity.getWorld().getBlockAt(loc).setType(Material.AIR);
- entity.getWorld().getBlockAt(loc).setType(prev);
- if (o) {
- entity.getWorld().getBlockAt(loc2).setType(Material.AIR);
- entity.getWorld().getBlockAt(loc2).setType(prev2);
- }
- }
- }, (long)(int)(20.0 * CustomEnchantments.this.doubles[14]));
- }
- }, 20L);
- }
- private void Diminish(final EntityDamageByEntityEvent event) {
- }
- private void Disarmor(final Player victim) {
- final int randomarmor = this.random.nextInt(4);
- if (randomarmor == 0 && victim.getInventory().getHelmet() != null && !victim.getInventory().getHelmet().getType().equals((Object)Material.AIR)) {
- this.item = victim.getInventory().getHelmet();
- victim.getInventory().setHelmet(new ItemStack(Material.AIR));
- }
- else if (randomarmor == 1 && victim.getInventory().getChestplate() != null && !victim.getInventory().getChestplate().getType().equals((Object)Material.AIR)) {
- this.item = victim.getInventory().getChestplate();
- victim.getInventory().setChestplate(new ItemStack(Material.AIR));
- }
- else if (randomarmor == 2 && victim.getInventory().getLeggings() != null && !victim.getInventory().getLeggings().getType().equals((Object)Material.AIR)) {
- this.item = victim.getInventory().getLeggings();
- victim.getInventory().setLeggings(new ItemStack(Material.AIR));
- }
- else {
- if (randomarmor != 3 || victim.getInventory().getBoots() == null || victim.getInventory().getBoots().getType().equals((Object)Material.AIR)) {
- return;
- }
- this.item = victim.getInventory().getBoots();
- victim.getInventory().setBoots(new ItemStack(Material.AIR));
- }
- if (this.item.hasItemMeta() && this.item.getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(this.item)) {
- final String OEN = enchant.split(" ")[0];
- if (this.potioneffectEnchants.contains(OEN)) {
- this.potionEffects(victim, OEN, true);
- }
- }
- }
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Disarmor", false);
- this.sendStringListMessage(victim.getUniqueId(), this.enchantmessages[5], 0.0);
- this.giveItem(victim, this.item);
- }
- private void Dodge(final Player victim, final EntityDamageByEntityEvent event) {
- event.setCancelled(true);
- this.sendStringListMessage(victim.getUniqueId(), this.enchantmessages[6], 0.0);
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Dodge", true);
- }
- private void Dominate(final EntityDamageByEntityEvent event, final int level) {
- this.dominate.add(event.getEntity().getUniqueId());
- final int j = this.dominatee.size();
- this.dominatee.add(level);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.dominate.remove(event.getEntity().getUniqueId());
- CustomEnchantments.this.dominatee.remove(j);
- }
- }, (long)(20 * level * this.doubles[7]));
- }
- private void EagleEye(final Player victim) {
- final short r = (short)(1 + this.random.nextInt((int)(Object)this.doubles[8] - 1));
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack is = armorContents[i];
- if (is != null) {
- is.setDurability((short)(is.getDurability() + r));
- }
- }
- }
- private void EnderShift(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "EnderShift", level);
- }
- private void Enlighted(final Player victim) {
- if (victim.getHealth() + 2.0 <= victim.getMaxHealth()) {
- victim.setHealth(victim.getHealth() + 2.0);
- }
- }
- @EventHandler
- private void EnderWalker(final EntityDamageEvent event) {
- if (event.isCancelled() || !(event.getEntity() instanceof Player) || (!event.getCause().equals((Object)EntityDamageEvent.DamageCause.POISON) && !event.getCause().equals((Object)EntityDamageEvent.DamageCause.WITHER))) {
- return;
- }
- final Player player = (Player)event.getEntity();
- if (player.getInventory().getBoots() != null) {
- for (final String enchant : this.getEnchantmentsOnItem(player.getInventory().getBoots())) {
- if (enchant.split(" ")[0].equals("EnderWalker")) {
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- event.setCancelled(true);
- if (this.random.nextInt(100) > this.getProckChance("EnderWalker", level, player) || player.getHealth() + level > player.getMaxHealth()) {
- continue;
- }
- player.setHealth(player.getHealth() + level);
- }
- }
- }
- }
- private void Enrage(final EntityDamageByEntityEvent event, final Player damager, final int level) {
- final double multiplier = (damager.getMaxHealth() - damager.getHealth()) / 3.0;
- if (multiplier == 0.0) {
- return;
- }
- if (multiplier < 1.0) {
- event.setDamage(event.getDamage() * (1.0 + multiplier));
- }
- else {
- event.setDamage(event.getDamage() * multiplier / 2.0);
- }
- }
- private void Epicness(final Player victim, final int level) {
- if (level == 1) {
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + victim.getName() + " ~ ~ ~ particle largesmoke " + victim.getLocation().getX() + " " + victim.getLocation().getY() + " " + victim.getLocation().getZ() + " 0.5 1 0.5 1 25 1");
- }
- else if (level == 2) {
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + victim.getName() + " ~ ~ ~ particle magicCrit " + victim.getLocation().getX() + " " + victim.getLocation().getY() + " " + victim.getLocation().getZ() + " 0.5 1 0.5 1 25 1");
- }
- else if (level == 3) {
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + victim.getName() + " ~ ~ ~ particle cloud " + victim.getLocation().getX() + " " + victim.getLocation().getY() + " " + victim.getLocation().getZ() + " 0.5 1 0.5 1 25 1");
- }
- }
- private void Execute(final Player player, final int level) {
- this.givePotionEffects((LivingEntity)player, null, "Execute", level);
- }
- private void Experience(final BlockBreakEvent event, final Player player, final int level) {
- int mulitplier = this.random.nextInt(level + 1);
- if (mulitplier == 0) {
- mulitplier = 1;
- }
- event.setExpToDrop(event.getExpToDrop() * mulitplier);
- }
- private void Explosive(final Location location, final Projectile proj) {
- location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 2.0f, false, false);
- proj.remove();
- }
- private void Farcast(final LivingEntity damager, final int level) {
- final double knockback = level * 0.25;
- damager.setVelocity(new Vector(-damager.getEyeLocation().getDirection().getX() + knockback, 0.0, -damager.getEyeLocation().getDirection().getZ() + knockback));
- }
- private void Featherweight(final Player player, final int level) {
- this.givePotionEffects((LivingEntity)player, null, "Featherweight", level);
- }
- private void Frozen(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Frozen", level);
- }
- private void Greatsword(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- final double damage = event.getDamage() * (1.0 + level * 0.15);
- if (this.getItemInHand(victim) != null && this.getItemInHand(victim).getType().equals((Object)Material.BOW)) {
- if (victim.getHealth() - damage > 0.0) {
- event.setDamage(damage);
- }
- else {
- victim.setHealth(0.0);
- }
- }
- }
- private void Guardians(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- final IronGolem ig = (IronGolem)victim.getWorld().spawnEntity(victim.getLocation(), EntityType.IRON_GOLEM);
- ig.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 99999, 4, false));
- ig.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 99999, 4, false));
- ig.setCustomName(this.guardiansname.replace("{PLAYER}", victim.getName()));
- if (event.getDamager() instanceof LivingEntity) {
- ig.setTarget((LivingEntity)event.getDamager());
- }
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (!ig.isDead()) {
- ig.remove();
- }
- }
- }, 320L);
- }
- @EventHandler
- private void HardenedReforged(final PlayerItemDamageEvent event) {
- if (!event.isCancelled() && event.getItem() != null && event.getItem().hasItemMeta() && event.getItem().getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(event.getItem())) {
- final String OEN = enchant.split(" ")[0];
- if ((OEN.equals("Hardened") || OEN.equals("Reforged")) && this.random.nextInt(100) <= this.getProckChance(OEN, Integer.parseInt(enchant.split(" ")[1]), event.getPlayer())) {
- event.setCancelled(true);
- }
- }
- }
- }
- private void Haste(final PlayerInteractEvent event, final int level) {
- this.givePotionEffects((LivingEntity)event.getPlayer(), null, "Haste", level);
- }
- private void Heavy(final EntityDamageByEntityEvent event, final Player victim) {
- double percent = 0.02;
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack item = armorContents[i];
- for (final String enchant : this.getEnchantmentsOnItem(item)) {
- if (enchant.split(" ")[0].equals("Heavy")) {
- percent += 0.02 * Integer.parseInt(enchant.split(" ")[1]);
- }
- }
- }
- event.setDamage(event.getDamage() * (1.0 - percent));
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Heavy", true);
- }
- private void Hijack(final IronGolem g, final Player player, final Player gOwner) {
- if (player.getName().equalsIgnoreCase(gOwner.getName())) {
- return;
- }
- final IronGolem ig = (IronGolem)g.getWorld().spawn(g.getLocation(), (Class)IronGolem.class);
- g.remove();
- ig.setTarget((LivingEntity)gOwner);
- ig.setCustomName(this.guardiansname.replace("{PLAYER}", player.getName()));
- ig.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 99999, 1, false));
- ig.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 99999, 1, false));
- }
- private void Hellfire(final Projectile proj, final Player player, final int level) {
- Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "execute " + player.getName() + " " + proj.getLocation().getX() + " " + proj.getLocation().getY() + " " + proj.getLocation().getZ() + " particle flame " + proj.getLocation().getX() + " " + (proj.getLocation().getY() + 1.0) + " " + proj.getLocation().getZ() + " 2.5 1 2.5 0 400 0");
- proj.remove();
- for (final Entity entity : player.getNearbyEntities(5.0, 4.0, 5.0)) {
- if (!(entity instanceof Player) || (entity instanceof Player && this.fapi.relationIsEnemyOrNull(player, (Player)entity))) {
- entity.setFireTicks(level * 40);
- }
- }
- }
- private void IceAspect(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "IceAspect", level);
- victim.getWorld().playEffect(victim.getEyeLocation(), Effect.STEP_SOUND, (Object)Material.ICE);
- }
- private void IceFreeze(final Player victim, final int level) {
- final float walkspeed = victim.getWalkSpeed();
- victim.setWalkSpeed(0.0f);
- Bukkit.getScheduler().scheduleSyncDelayedTask(RandomPackage.getPlugin, (Runnable)new Runnable() {
- @Override
- public void run() {
- victim.setWalkSpeed(walkspeed);
- }
- }, (long)(int)(20.0 * this.doubles[9]));
- }
- private void Implants(final Player player) {
- if (player.getFoodLevel() != 20) {
- player.setFoodLevel(player.getFoodLevel() + 1);
- }
- if (this.random.nextInt(100) <= 2 && player.getHealth() + 1.0 <= player.getMaxHealth()) {
- player.setHealth(player.getHealth() + 1.0);
- }
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- private void Inquisitive(final EntityDeathEvent event) {
- if (event.getEntity() instanceof LivingEntity && !(event.getEntity() instanceof Player)) {
- if (event.getEntity().getKiller() instanceof Player && this.getItemInHand(event.getEntity().getKiller()) != null) {
- this.item = this.getItemInHand(event.getEntity().getKiller());
- if (event.getEntity().getCustomName() != null && ((event.getEntityType().equals((Object)EntityType.IRON_GOLEM) && ChatColor.stripColor(event.getEntity().getCustomName()).endsWith(ChatColor.stripColor(this.guardiansname.replace("{PLAYER}", "")))) || (event.getEntityType().equals((Object)EntityType.ZOMBIE) && ChatColor.stripColor(event.getEntity().getCustomName()).endsWith(ChatColor.stripColor(this.undeadrusename.replace("{PLAYER}", "")))) || (event.getEntityType().equals((Object)EntityType.BLAZE) && ChatColor.stripColor(event.getEntity().getCustomName()).endsWith(ChatColor.stripColor(this.spiritsname.replace("{PLAYER}", "")))))) {
- event.setDroppedExp(0);
- event.getDrops().clear();
- return;
- }
- if (event.getEntity().getKiller() instanceof Player && this.item != null && this.mobRage.contains(event.getEntity().getKiller().getName())) {
- event.getEntity().setVelocity(new Vector(event.getEntity().getKiller().getLocation().getDirection().getX() * 0.45, 0.25, event.getEntity().getKiller().getLocation().getDirection().getZ() * 0.45));
- if (event.getEntity().getNearbyEntities(0.0, 0.0, 0.0).size() >= 1) {
- for (final Entity entity : event.getEntity().getNearbyEntities(0.0, 0.0, 0.0)) {
- if (entity.getType().equals((Object)event.getEntity().getType())) {
- entity.setVelocity(new Vector(-event.getEntity().getKiller().getLocation().getDirection().getX() * 0.25, 0.0, -event.getEntity().getKiller().getLocation().getDirection().getZ() * 0.25));
- }
- }
- }
- }
- if (this.item.hasItemMeta() && this.item.getItemMeta().hasLore()) {
- for (final String enchant : this.getEnchantmentsOnItem(this.item)) {
- final String OEN = enchant.split(" ")[0];
- final int level = Integer.parseInt(enchant.split(" ")[1]);
- final int chance = this.getProckChance(OEN, level, event.getEntity().getKiller());
- if (this.random.nextInt(100) <= chance) {
- if (OEN.equals("Inquisitive")) {
- String equ = null;
- if (level == 1) {
- equ = this.enchantstrings[0];
- }
- else {
- equ = this.enchantstrings[1];
- }
- equ = equ.replace(" ", "").replace("xp", new StringBuilder().append(event.getDroppedExp()).toString()).replace("level", new StringBuilder().append(level).toString());
- event.setDroppedExp(this.getProckChance(equ, level, event.getEntity().getKiller()));
- }
- else {
- if (!OEN.equals("MasterInquisitive")) {
- continue;
- }
- String equ = null;
- if (level == 1) {
- equ = this.enchantstrings[2];
- }
- else {
- equ = this.enchantstrings[3];
- }
- equ = equ.replace(" ", "").replace("xp", new StringBuilder().append(event.getDroppedExp()).toString()).replace("level", new StringBuilder().append(level).toString());
- event.setDroppedExp(this.getProckChance(equ, level, event.getEntity().getKiller()));
- }
- }
- }
- }
- }
- }
- }
- private void Insanity(final Player damager, final int level, final Player victim, final EntityDamageByEntityEvent event) {
- if (this.getItemInHand(victim) != null && this.getItemInHand(victim).getType().name().endsWith("_SWORD")) {
- final String damage = this.enchantments.getString("Insanity.damage").replace("damage", new StringBuilder().append(event.getDamage()).toString()).replace("level", new StringBuilder().append(level).toString());
- event.setDamage((double)this.evaluate(damage));
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.Insanity", false);
- }
- }
- private void Insomnia(final Player player, final int level, final EntityDamageByEntityEvent event) {
- this.givePotionEffects((LivingEntity)player, null, "Insomnia", level);
- if (this.random.nextInt(101) <= 25) {
- event.setDamage(event.getDamage() * 2.0);
- }
- }
- private void Inversion(final EntityDamageByEntityEvent event, final Player victim, final int level) {
- event.setDamage(0.0);
- final int amount = this.random.nextInt(3) + 1;
- if (victim.getHealth() + amount <= victim.getMaxHealth()) {
- victim.setHealth(victim.getHealth() + amount);
- }
- for (final String string : this.messages.getStringList("enchants.inversion")) {
- victim.sendMessage(ChatColor.translateAlternateColorCodes('&', string.replace("{AMOUNT}", new StringBuilder().append(amount).toString())));
- }
- }
- private void Leadership(final EntityDamageByEntityEvent event, final int level) {
- int nearbyallies = 0;
- for (final Entity entity : event.getDamager().getNearbyEntities((double)this.doubles[11], (double)this.doubles[11], (double)this.doubles[11])) {
- if (entity instanceof Player && this.fapi.relationIsAlly((Player)event.getDamager(), (Player)entity)) {
- ++nearbyallies;
- }
- }
- event.setDamage(event.getDamage() * (1.0 + this.doubles[12] * nearbyallies));
- }
- private void Lifebloom(final Player victim, final int level) {
- victim.playEffect(victim.getLocation(), Effect.STEP_SOUND, (Object)Material.EMERALD_BLOCK);
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Lifebloom", true);
- final int area = this.evaluate(this.enchantments.getString("Lifebloom.area").replace("level", new StringBuilder().append(level).toString()));
- for (final Entity entity : victim.getNearbyEntities((double)area, (double)area, (double)area)) {
- if ((entity instanceof Player && this.fapi.relationIsAlly(victim, (Player)entity)) || (entity instanceof Player && this.fapi.relationIsMember(victim, (Player)entity))) {
- ((Player)entity).setHealth(((Player)entity).getMaxHealth());
- }
- }
- }
- private void Lifesteal(final EntityDamageByEntityEvent event, final Player player) {
- if (player.getHealth() + 1.0 <= 20.0) {
- player.setHealth(player.getHealth() + 1.0);
- }
- if (((LivingEntity)event.getEntity()).getHealth() - 1.0 > 0.0) {
- ((LivingEntity)event.getEntity()).setHealth(((LivingEntity)event.getEntity()).getHealth() - 1.0);
- }
- this.getAndPlaySound(player, player.getLocation(), "enchants.Lifesteal", true);
- }
- private void Lightning(final Location location, final Projectile proj) {
- proj.getWorld().strikeLightning(location);
- proj.remove();
- }
- private void Marksman(final EntityDamageByEntityEvent event, final double damage) {
- event.setDamage(event.getDamage() + damage);
- }
- private void Molten(final LivingEntity damager, final int level) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- damager.setFireTicks(40 * level + 60);
- }
- }, 1L);
- }
- private void Obliterate(final EntityDamageByEntityEvent event, final int level) {
- final double multiplier = level + 0.25;
- event.getEntity().setVelocity(new Vector(-event.getEntity().getLocation().getDirection().getX() * multiplier, event.getEntity().getVelocity().getY(), -event.getEntity().getLocation().getDirection().getZ() * multiplier));
- }
- private void ObsidianDestroyer(final PlayerInteractEvent event, final int level) {
- if (event.getClickedBlock().getType().equals((Object)Material.OBSIDIAN)) {
- event.getClickedBlock().breakNaturally();
- event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, (Object)Material.OBSIDIAN);
- }
- }
- private void Oxygenate(final Player player) {
- if (player.getRemainingAir() + 40 <= 300) {
- player.setRemainingAir(player.getRemainingAir() + 40);
- }
- }
- private void Paralyze(final Player victim, final int level) {
- victim.getWorld().strikeLightning(victim.getLocation());
- if (this.random.nextInt(100) <= level * 15) {
- this.givePotionEffects(null, victim, "Paralyze", level);
- }
- }
- private void Piercing(final EntityDamageByEntityEvent event, final int level) {
- event.setDamage(event.getFinalDamage() * (1.0 + level * 0.25));
- }
- private void PlanetaryDeathbringer(final EntityDamageByEntityEvent event) {
- event.setDamage(event.getDamage() * this.doubles[0]);
- }
- private void Poison(final LivingEntity victim, final int level) {
- victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 40 * level + 40, level - 1));
- }
- private void Poisoned(final LivingEntity damager, final int level) {
- damager.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 40 * level + 40, level - 1));
- }
- private void Protection(final Player player, final int level) {
- final String[] string = this.enchantments.getString("Protection.area").toLowerCase().replace(" ", "").replace("level", new StringBuilder().append(level).toString()).split("\\:");
- for (final Entity entity : player.getNearbyEntities((double)this.evaluate(string[0]), (double)this.evaluate(string[1]), (double)this.evaluate(string[2]))) {
- if (entity instanceof Player && this.fapi.relationIsAlly(player, (Player)entity)) {
- ((Player)entity).addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 40 * level, level / 2));
- ((Player)entity).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * level, 1));
- }
- }
- }
- private void Pummel(final Player damager, final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Pummel", level);
- final String[] string = this.enchantments.getString("Pummel.area").replace(" ", "").toLowerCase().replace("level", new StringBuilder().append(level).toString()).split("\\:");
- for (final Entity entity : victim.getNearbyEntities((double)this.evaluate(string[0]), (double)this.evaluate(string[1]), (double)this.evaluate(string[2]))) {
- if (entity instanceof Player && this.fapi.relationIsEnemyOrNull(damager, victim)) {
- this.givePotionEffects(null, (Player)entity, "Pummel", level);
- }
- }
- }
- private void Ragdoll(final Player victim) {
- victim.setVelocity(victim.getLocation().getDirection().multiply(-this.random.nextDouble() - 0.5));
- }
- private void Rage(final EntityDamageByEntityEvent event, final Player damager, final int level) {
- final LivingEntity entity = (LivingEntity)event.getEntity();
- double multiplier = 1.0;
- if ((entity instanceof Player && this.enchantments.getBoolean("Rage.player-particles")) || (!(entity instanceof Player) && this.enchantments.getBoolean("Rage.mob-particles"))) {
- entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, (Object)Material.REDSTONE_BLOCK);
- entity.getWorld().playEffect(entity.getEyeLocation(), Effect.STEP_SOUND, (Object)Material.REDSTONE_BLOCK);
- }
- ArrayList<String> type = null;
- if (entity instanceof Player) {
- type = this.playerRage;
- }
- else {
- type = this.mobRage;
- }
- type.add(damager.getName());
- for (final String string : type) {
- if (string.equals(damager.getName()) && multiplier + 0.111 <= 1.0 + level * 0.111) {
- multiplier += 0.111;
- }
- }
- entity.setVelocity(new Vector(-event.getDamager().getLocation().getDirection().getX() * 0.35, 0.0, -event.getDamager().getLocation().getDirection().getZ() * 0.35));
- event.setDamage(event.getDamage() * multiplier);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- CustomEnchantments.this.playerRage.remove(damager.getName());
- CustomEnchantments.this.mobRage.remove(damager.getName());
- }
- }, 80L);
- }
- private void Ravenous(final Player player, final int level) {
- this.givePotionEffects(null, player, "Ravenous", level);
- }
- private void RocketEscape(final Player victim, final int level) {
- if (victim.getHealth() <= level * 2 + 4) {
- this.givePotionEffects(null, victim, "RocketEscape", level);
- }
- }
- private void Shackle(final EntityDamageByEntityEvent event, final int level) {
- if (level <= 3 || (level == 2 && !event.getEntity().getType().equals((Object)EntityType.MAGMA_CUBE)) || (level == 1 && !event.getEntity().getType().equals((Object)EntityType.BLAZE) && !event.getEntity().getType().equals((Object)EntityType.MAGMA_CUBE))) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- event.getEntity().setVelocity(new Vector(-(event.getDamager().getLocation().getDirection().getX() * 0.25), 0.0, -(event.getDamager().getLocation().getDirection().getZ() * 0.25)));
- }
- }, 1L);
- }
- }
- private void Shockwave(final Player damager, final int level) {
- damager.setVelocity(new Vector(-damager.getLocation().getDirection().getX() * 3.0, damager.getVelocity().getY(), -damager.getLocation().getDirection().getZ() * 3.0));
- }
- private void Silence(final Player victim, final int level) {
- final Collection<PotionEffect> pes = (Collection<PotionEffect>)victim.getActivePotionEffects();
- final Collection<PotionEffect> potioneffects = (Collection<PotionEffect>)victim.getActivePotionEffects();
- for (final PotionEffect pe : pes) {
- victim.removePotionEffect(pe.getType());
- }
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- for (final PotionEffect pe : potioneffects) {
- victim.addPotionEffect(pe);
- }
- }
- }, (long)(20 * level));
- }
- private void SkillSwipe(final Player victim, final Player damager, final int level) {
- final int taken_xp = (this.random.nextInt(10) + 1) * level;
- if (victim.getTotalExperience() >= taken_xp) {
- final int remaining_xp = this.getTotalExperience(victim) - taken_xp;
- this.setTotalExperience(victim, remaining_xp);
- this.setTotalExperience(damager, this.getTotalExperience(damager) + taken_xp);
- }
- }
- private void SmokeBomb(final LivingEntity damager, final int level) {
- damager.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * level + 100, level - 1));
- }
- private void Snare(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Snare", level);
- }
- private void Sniper(final EntityDamageByEntityEvent event, final Player damager, final Player victim, final int level) {
- if (event.getDamager().getLocation().getY() > victim.getLocation().getY()) {
- double multiplier = 1.0;
- for (int i = 1; i <= level; ++i) {
- multiplier += 0.5;
- }
- final double damage = event.getFinalDamage() * multiplier;
- event.setDamage(0.0);
- if (victim.getHealth() - damage <= 0.0) {
- victim.setHealth(0.0);
- }
- else {
- victim.setHealth(victim.getHealth() - damage);
- }
- this.getAndPlaySound(damager, damager.getLocation(), "enchants.Sniper", false);
- this.sendStringListMessage(damager.getUniqueId(), this.enchantmessages[13], 0.0);
- }
- }
- private void SpiritLink(final Player victim, final int level) {
- final String[] string = this.enchantments.getString("SpiritLink.area").toLowerCase().replace(" ", "").replace("level", new StringBuilder().append(level).toString()).split("\\:");
- for (final Entity entity : victim.getNearbyEntities((double)this.evaluate(string[0]), (double)this.evaluate(string[1]), (double)this.evaluate(string[2]))) {
- if ((entity instanceof Player && this.fapi.relationIsAlly(victim, (Player)entity)) || (entity instanceof Player && this.fapi.relationIsMember(victim, (Player)entity))) {
- final Player nearbyplayer = (Player)entity;
- if (nearbyplayer.getHealth() + 1.0 > nearbyplayer.getMaxHealth()) {
- continue;
- }
- nearbyplayer.setHealth(nearbyplayer.getHealth() + 1.0);
- }
- }
- }
- private void Spirits(final Player victim, final int level) {
- this.getAndPlaySound(victim, victim.getLocation(), "enchants.Spirits", true);
- for (final Entity entity : victim.getNearbyEntities((double)(level + level / 2), (double)(level + level / 2), (double)(level + level / 2))) {
- if (entity instanceof Player && this.fapi.relationIsAlly(victim, (Player)entity)) {
- this.givePotionEffects(null, (Player)entity, "Spirits", level);
- }
- }
- for (int i = 1; i <= level; ++i) {
- final Blaze blaze = (Blaze)victim.getWorld().spawnEntity(victim.getLocation(), EntityType.BLAZE);
- blaze.setCustomName(this.spiritsname.replace("{PLAYER}", victim.getName()));
- blaze.setCanPickupItems(false);
- blaze.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 99999, level));
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- blaze.remove();
- }
- }, 300L);
- }
- }
- private void Stormcaller(final LivingEntity damager) {
- damager.getWorld().strikeLightning(damager.getLocation());
- }
- private void Tank(final Player victim, final Player damager, final int level, final EntityDamageByEntityEvent event) {
- if (this.getItemInHand(damager) == null || !this.getItemInHand(damager).getType().name().endsWith("_AXE")) {
- return;
- }
- double dividedDamage = 0.0;
- ItemStack[] armorContents;
- for (int length = (armorContents = victim.getInventory().getArmorContents()).length, i = 0; i < length; ++i) {
- final ItemStack item = armorContents[i];
- for (final String enchant : this.getEnchantmentsOnItem(item)) {
- if (enchant.split(" ")[0].equals("Tank")) {
- dividedDamage += 1.85 * level;
- }
- }
- }
- event.setDamage(event.getDamage() / dividedDamage);
- }
- private void Teleportation(final Projectile proj, final Player player1, final Player player2) {
- player1.teleport(player2.getLocation());
- proj.remove();
- }
- private void ThunderingBlow(final EntityDamageByEntityEvent event, final int level) {
- for (int i = 1; i <= 3; ++i) {
- event.getEntity().getWorld().strikeLightning(event.getEntity().getLocation());
- }
- }
- private void Trap(final Player victim, final int level) {
- this.givePotionEffects(null, victim, "Trap", level);
- }
- private void Trickster(final Player victim) {
- final Location location = victim.getLocation();
- if (victim.getLocation().getYaw() >= 0.0f) {
- location.setYaw(victim.getLocation().getYaw() - 180.0f);
- }
- else {
- location.setYaw(victim.getLocation().getYaw() + 180.0f);
- }
- victim.teleport(location);
- }
- private void UndeadRuse(final Player victim, final int level, final LivingEntity damager) {
- for (int i = 1; i <= level; ++i) {
- final Zombie zombie = (Zombie)victim.getWorld().spawnEntity(victim.getLocation(), EntityType.ZOMBIE);
- zombie.setCustomName(this.undeadrusename.replace("{PLAYER}", victim.getName()));
- zombie.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 99999, 3));
- zombie.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 99999, 1));
- zombie.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 99999, 1));
- zombie.setCanPickupItems(false);
- zombie.setTarget(damager);
- Bukkit.getScheduler().scheduleSyncDelayedTask(this.randompackage, (Runnable)new Runnable() {
- @Override
- public void run() {
- if (!zombie.isDead()) {
- zombie.remove();
- }
- }
- }, 400L);
- }
- }
- private void Valor(final EntityDamageByEntityEvent event, final int level) {
- event.setDamage(0.045 * level);
- }
- private void Vampire(final EntityDamageByEntityEvent event, final Player damager) {
- if (damager.getHealth() + event.getDamage() / 2.0 > damager.getMaxHealth()) {
- damager.setHealth(damager.getMaxHealth());
- return;
- }
- damager.setHealth(damager.getHealth() + event.getDamage() / 2.0);
- }
- private void Voodoo(final LivingEntity damager, final int level) {
- damager.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 40 * level + 40, level - 1));
- }
- private void Wither(final LivingEntity damager, final int level) {
- damager.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 40 * level + 40, level - 1));
- }
- private void playParticle(final Player player, final int PARTICLE) {
- final String particle = this.particlelist[PARTICLE];
- final String particlelocation = this.particleloc[PARTICLE];
- Location loc = null;
- if (particlelocation.equals("EYE_LOCATION")) {
- loc = player.getEyeLocation();
- }
- else if (particlelocation.equals("LOCATION")) {
- loc = player.getLocation();
- }
- int count = 1;
- if (particle.contains("count=")) {
- count = Integer.parseInt(particle.split("\\=")[1]);
- }
- for (int i = 1; i <= count; ++i) {
- player.playEffect(loc, Effect.valueOf(particle), 1);
- }
- }
- static /* synthetic */ void access$3(final CustomEnchantments customEnchantments, final ItemStack item) {
- customEnchantments.item = item;
- }
- public enum RandomPackageEnchants
- {
- Aegis("Aegis", 0),
- Angelic("Angelic", 1),
- AntiGank("AntiGank", 2),
- AntiGravity("AntiGravity", 3),
- Aquatic("Aquatic", 4),
- Armored("Armored", 5),
- ArrowBreak("ArrowBreak", 6),
- ArrowDeflect("ArrowDeflect", 7),
- ArrowLifesteal("ArrowLifesteal", 8),
- Assassin("Assassin", 9),
- AutoSmelt("AutoSmelt", 10),
- Barbarian("Barbarian", 11),
- Berserk("Berserk", 12),
- Blacksmith("Blacksmith", 13),
- Bleed("Bleed", 14),
- Blessed("Blessed", 15),
- Blind("Blind", 16),
- Block("Block", 17),
- BloodLink("BloodLink", 18),
- BloodLust("BloodLust", 19),
- Cactus("Cactus", 20),
- Clarity("Clarity", 21),
- Cleave("Cleave", 22),
- Commander("Commander", 23),
- Confusion("Confusion", 24),
- Cowification("Cowification", 25),
- CreeperArmor("CreeperArmor", 26),
- Curse("Curse", 27),
- Deathbringer("Deathbringer", 28),
- DeathGod("DeathGod", 29),
- Decapitation("Decapitation", 30),
- DeepWounds("DeepWounds", 31),
- Demonforged("Demonforged", 32),
- Destruction("Destruction", 33),
- Detonate("Detonate", 34),
- Devour("Devour", 35),
- DimensionRift("DimensionRift", 36),
- Diminish("Diminish", 37),
- Disarmor("Disarmor", 38),
- Disintegrate("Disintegrate", 39),
- DivineEnlighted("DivineEnlighted", 40),
- DivineImmolation("DivineImmolation", 41),
- Dodge("Dodge", 42),
- Dominate("Dominate", 43),
- DoubleStrike("DoubleStrike", 44),
- Drunk("Drunk", 45),
- EagleEye("EagleEye", 46),
- EnderShift("EnderShift", 47),
- EnderWalker("EnderWalker", 48),
- Enlighted("Enlighted", 49),
- Enrage("Enrage", 50),
- Epicness("Epicness", 51),
- Execute("Execute", 52),
- Experience("Experience", 53),
- Explosive("Explosive", 54),
- Farcast("Farcast", 55),
- Featherweight("Featherweight", 56),
- Frozen("Frozen", 57),
- Fuse("Fuse", 58),
- Gears("Gears", 59),
- Ghost("Ghost", 60),
- Glowing("Glowing", 61),
- GodlyOverload("GodlyOverload", 62),
- Greatsword("Greatsword", 63),
- Guardians("Guardians", 64),
- Hardened("Hardened", 65),
- Haste("Haste", 66),
- Headless("Headless", 67),
- Healing("Healing", 68),
- Heavy("Heavy", 69),
- Hellfire("Hellfire", 70),
- Hijack("Hijack", 71),
- IceAspect("IceAspect", 72),
- IceFreeze("IceFreeze", 73),
- Immortal("Immortal", 74),
- Implants("Implants", 75),
- Infernal("Infernal", 76),
- Inquisitive("Inquisitive", 77),
- Insanity("Insanity", 78),
- Insomnia("Insomnia", 79),
- Inversion("Inversion", 80),
- KillAura("KillAura", 81),
- Leadership("Leadership", 82),
- Lifebloom("Lifebloom", 83),
- Lifesteal("Lifesteal", 84),
- Lightning("Lightning", 85),
- Longbow("Longbow", 86),
- Lucky("Lucky", 87),
- Marksman("Marksman", 88),
- MasterInquisitive("MasterInquisitive", 89),
- Metaphysical("Metaphysical", 90),
- Molten("Molten", 91),
- NaturesWrath("NaturesWrath", 92),
- Nimble("Nimble", 93),
- Nutrition("Nutrition", 94),
- Obliterate("Obliterate", 95),
- ObsidianDestroyer("ObsidianDestroyer", 96),
- Obsidianshield("Obsidianshield", 97),
- Overload("Overload", 98),
- Oxygenate("Oxygenate", 99),
- Pacify("Pacify", 100),
- Paradox("Paradox", 101),
- Paralyze("Paralyze", 102),
- Phoenix("Phoenix", 103),
- Piercing("Piercing", 104),
- PlagueCarrier("PlagueCarrier", 105),
- PlanetaryDeathbringer("PlanetaryDeathbringer", 106),
- Poison("Poison", 107),
- Poisoned("Poisoned", 108),
- Protection("Protection", 109),
- Pummel("Pummel", 110),
- Ragdoll("Ragdoll", 111),
- Rage("Rage", 112),
- Ravenous("Ravenous", 113),
- Reforged("Reforged", 114),
- RepairGuard("RepairGuard", 115),
- Resilience("Resilience", 116),
- RocketEscape("RocketEscape", 117),
- SelfDestruct("SelfDestruct", 118),
- Shackle("Shackle", 119),
- Shockwave("Shockwave", 120),
- Silence("Silence", 121),
- SkillSwipe("SkillSwipe", 122),
- Skilling("Skilling", 123),
- SmokeBomb("SmokeBomb", 124),
- Snare("Snare", 125),
- Sniper("Sniper", 126),
- Solitude("Solitude", 127),
- SoulTrap("SoulTrap", 128),
- SpiritLink("SpiritLink", 129),
- Spirits("Spirits", 130),
- Springs("Springs", 131),
- Sticky("Sticky", 132),
- Stormcaller("Stormcaller", 133),
- Tank("Tank", 134),
- TargetTracking("TargetTracking", 135),
- Teleblock("Teleblock", 136),
- Telepathy("Telepathy", 137),
- Teleportation("Teleportation", 138),
- ThunderingBlow("ThunderingBlow", 139),
- Training("Training", 140),
- Trap("Trap", 141),
- Trickster("Trickster", 142),
- UndeadRuse("UndeadRuse", 143),
- Unfocus("Unfocus", 144),
- Valor("Valor", 145),
- Vampire("Vampire", 146),
- Venom("Venom", 147),
- Virus("Virus", 148),
- Voodoo("Voodoo", 149),
- Wither("Wither", 150);
- private RandomPackageEnchants(final String s, final int n) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment