1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Now you can use ender crystal as killed entity

Closes #572
This commit is contained in:
montlikadani 2020-07-07 13:18:22 +02:00
parent 071b70609d
commit 439665039b
5 changed files with 44 additions and 33 deletions

View File

@ -1365,7 +1365,7 @@ public enum CMIMaterial {
Integer data = null;
Integer ids = null;
id = id.replaceAll("_| |minecraft:", "").toLowerCase();
if (id.contains(":")) {

View File

@ -14,9 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class RawMessage {
final static String colorReplacerPlaceholder = "\uFF06";
List<String> parts = new ArrayList<>();
List<String> cleanParts = new ArrayList<>();

View File

@ -32,7 +32,7 @@ public class EntityActionInfo extends BaseActionInfo {
}
@Override
public String getName() {
public String getName() {
return Jobs.getNms().getRealType(entity);
}

View File

@ -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

View File

@ -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;