diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java index 7d4d32be..d023cc83 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java @@ -1365,7 +1365,7 @@ public enum CMIMaterial { Integer data = null; Integer ids = null; - + id = id.replaceAll("_| |minecraft:", "").toLowerCase(); if (id.contains(":")) { diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/RawMessage.java b/src/main/java/com/gamingmesh/jobs/CMILib/RawMessage.java index 916132ea..09a36ff0 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/RawMessage.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/RawMessage.java @@ -14,9 +14,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class RawMessage { - - final static String colorReplacerPlaceholder = "\uFF06"; - + List parts = new ArrayList<>(); List cleanParts = new ArrayList<>(); diff --git a/src/main/java/com/gamingmesh/jobs/actions/EntityActionInfo.java b/src/main/java/com/gamingmesh/jobs/actions/EntityActionInfo.java index d8510fe3..e56db4d6 100644 --- a/src/main/java/com/gamingmesh/jobs/actions/EntityActionInfo.java +++ b/src/main/java/com/gamingmesh/jobs/actions/EntityActionInfo.java @@ -32,7 +32,7 @@ public class EntityActionInfo extends BaseActionInfo { } @Override - public String getName() { + public String getName() { return Jobs.getNms().getRealType(entity); } diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index c888aec8..bb91b9a0 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -32,7 +32,6 @@ import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.Util; import org.apache.commons.lang.StringEscapeUtils; -import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; @@ -1328,13 +1327,18 @@ public class ConfigManager { // check entities CMIEntityType entity = CMIEntityType.getByName(key); - if (entity != null && entity.isAlive()) { + if (entity != null) { + if (entity.isAlive()) { + type = entity.toString(); + id = entity.getId(); + + // using breeder finder + if (actionType == ActionType.BREED) + Jobs.getGCManager().useBreederFinder = true; + } else if (entity == CMIEntityType.ENDER_CRYSTAL) { type = entity.toString(); id = entity.getId(); - - // using breeder finder - if (actionType == ActionType.BREED) - Jobs.getGCManager().useBreederFinder = true; + } } // Pre 1.13 checks for custom names diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 78fcb7a5..47d84f06 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -20,6 +20,7 @@ package com.gamingmesh.jobs.listeners; import com.gamingmesh.jobs.CMILib.ActionBarManager; import com.gamingmesh.jobs.CMILib.CMIEnchantment; +import com.gamingmesh.jobs.CMILib.CMIEntityType; import com.gamingmesh.jobs.CMILib.CMIMaterial; import com.gamingmesh.jobs.CMILib.ItemManager; import com.gamingmesh.jobs.CMILib.Version; @@ -1149,11 +1150,20 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) return; + Entity ent = event.getEntity(); Entity damager = event.getDamager(); + if (ent instanceof org.bukkit.entity.EnderCrystal && damager instanceof Player) { + String meta = "enderCrystalDamage"; + if (ent.hasMetadata(meta)) + ent.removeMetadata(meta, plugin); + + ent.setMetadata(meta, new FixedMetadataValue(plugin, ent)); + return; + } + if (!(damager instanceof Projectile)) return; - Entity ent = event.getEntity(); if (!(ent instanceof Damageable)) return; @@ -1541,13 +1551,8 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) return; - if (!(event.getEntity() instanceof Player)) - return; - - if (event.getEntity().hasMetadata("NPC")) - return; - - if (event.getFoodLevel() <= ((Player) event.getEntity()).getFoodLevel()) + if (!(event.getEntity() instanceof Player) || event.getEntity().hasMetadata("NPC") + || event.getFoodLevel() <= ((Player) event.getEntity()).getFoodLevel()) return; Player player = (Player) event.getEntity(); @@ -1576,23 +1581,23 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTntExplode(EntityExplodeEvent event) { - // make sure plugin is enabled if (!plugin.isEnabled()) return; - //disabling plugin in world - if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity())) + Entity e = event.getEntity(); + if (!Jobs.getGCManager().canPerformActionInWorld(e)) return; - if (!Jobs.getGCManager().isUseTntFinder()) + EntityType type = event.getEntityType(); + if (type != EntityType.PRIMED_TNT && type != EntityType.MINECART_TNT && type != CMIEntityType.ENDER_CRYSTAL.getType()) return; - if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT) + if (!Jobs.getGCManager().isUseTntFinder() || type != CMIEntityType.ENDER_CRYSTAL.getType()) return; double closest = 60.0; Player player = null; - Location loc = event.getEntity().getLocation(); + Location loc = e.getLocation(); for (Player i : Bukkit.getOnlinePlayers()) { if (loc.getWorld() != i.getWorld()) continue; @@ -1604,17 +1609,11 @@ public class JobsPaymentListener implements Listener { } } - if (player == null || closest == 60.0) - return; - - if (!player.isOnline()) + if (player == null || closest == 60.0 || !player.isOnline()) return; // check if in creative - if (!payIfCreative(player)) - return; - - if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) + if (!payIfCreative(player) || !Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; // check if player is riding @@ -1625,6 +1624,16 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; + String meta = "enderCrystalDamage"; + if (type == CMIEntityType.ENDER_CRYSTAL.getType() && e.hasMetadata(meta) && !e.getMetadata(meta).isEmpty()) { + Entity killed = (Entity) e.getMetadata(meta).get(0).value(); + if (killed != null) { + Jobs.action(jPlayer, new EntityActionInfo(killed, ActionType.KILL)); + killed.removeMetadata(meta, plugin); + return; + } + } + for (Block block : event.blockList()) { if (block == null) continue;