mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-02-18 20:31:41 +01:00
Fix for respawn on full stack kill.
Fix for held items dropping more than once.
This commit is contained in:
parent
1b40bcb3a5
commit
8ab098e02f
@ -20,8 +20,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Methods {
|
public class Methods {
|
||||||
|
|
||||||
private static void handleWholeStackDeath(Location killedLocation, EntityStack stack, List<ItemStack> items, int droppedExp) {
|
private static void handleWholeStackDeath(LivingEntity killed, EntityStack stack, List<ItemStack> items, int droppedExp) {
|
||||||
|
Location killedLocation = killed.getLocation();
|
||||||
for (int i = 1; i < stack.getAmount(); i++) {
|
for (int i = 1; i < stack.getAmount(); i++) {
|
||||||
|
if (i == 1) {
|
||||||
|
if (killed.getType() != EntityType.PIG_ZOMBIE)
|
||||||
|
items.removeIf(it -> it.isSimilar(killed.getEquipment().getItemInHand()));
|
||||||
|
}
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
killedLocation.getWorld().dropItemNaturally(killedLocation, item);
|
killedLocation.getWorld().dropItemNaturally(killedLocation, item);
|
||||||
}
|
}
|
||||||
@ -34,6 +39,8 @@ public class Methods {
|
|||||||
UltimateStacker instance = UltimateStacker.getInstance();
|
UltimateStacker instance = UltimateStacker.getInstance();
|
||||||
EntityStackManager stackManager = instance.getEntityStackManager();
|
EntityStackManager stackManager = instance.getEntityStackManager();
|
||||||
Entity newEntity = newEntity(killed);
|
Entity newEntity = newEntity(killed);
|
||||||
|
|
||||||
|
if (killed.getType() != EntityType.PIG_ZOMBIE)
|
||||||
((LivingEntity) newEntity).getEquipment().clear();
|
((LivingEntity) newEntity).getEquipment().clear();
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners"))
|
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners"))
|
||||||
@ -64,31 +71,24 @@ public class Methods {
|
|||||||
EntityStack stack = stackManager.getStack(killed);
|
EntityStack stack = stackManager.getStack(killed);
|
||||||
|
|
||||||
if (instance.getConfig().getBoolean("Entity.Kill Whole Stack On Death") && stack.getAmount() != 1) {
|
if (instance.getConfig().getBoolean("Entity.Kill Whole Stack On Death") && stack.getAmount() != 1) {
|
||||||
handleWholeStackDeath(killed.getLocation(), stack, items, droppedExp);
|
handleWholeStackDeath(killed, stack, items, droppedExp);
|
||||||
} else if(instance.getConfig().getBoolean("Entity.Kill Whole Stack On Special Death Cause") && stack.getAmount() != 1) {
|
} else if(instance.getConfig().getBoolean("Entity.Kill Whole Stack On Special Death Cause") && stack.getAmount() != 1) {
|
||||||
List<String> reasons = instance.getConfig().getStringList("Entity.Special Death Cause");
|
List<String> reasons = instance.getConfig().getStringList("Entity.Special Death Cause");
|
||||||
EntityDamageEvent lastDamageCause = killed.getLastDamageCause();
|
EntityDamageEvent lastDamageCause = killed.getLastDamageCause();
|
||||||
|
|
||||||
if(lastDamageCause != null) {
|
if(lastDamageCause != null) {
|
||||||
EntityDamageEvent.DamageCause cause = lastDamageCause.getCause();
|
EntityDamageEvent.DamageCause cause = lastDamageCause.getCause();
|
||||||
boolean killWholeStack = false;
|
|
||||||
|
|
||||||
for(String s : reasons) {
|
for(String s : reasons) {
|
||||||
if(cause.name().equalsIgnoreCase(s)) {
|
if(cause.name().equalsIgnoreCase(s)) {
|
||||||
killWholeStack = true;
|
handleWholeStackDeath(killed, stack, items, droppedExp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(killWholeStack) {
|
|
||||||
handleWholeStackDeath(killed.getLocation(), stack, items, droppedExp);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSingleStackDeath(killed);
|
handleSingleStackDeath(killed);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static LivingEntity newEntity(LivingEntity killed) {
|
private static LivingEntity newEntity(LivingEntity killed) {
|
||||||
LivingEntity newEntity = (LivingEntity) killed.getWorld().spawnEntity(killed.getLocation(), killed.getType());
|
LivingEntity newEntity = (LivingEntity) killed.getWorld().spawnEntity(killed.getLocation(), killed.getType());
|
||||||
|
Loading…
Reference in New Issue
Block a user