mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 10:35:22 +01:00
Attempt at carrying over lowest health feature.
This commit is contained in:
parent
38787e0c1e
commit
0efcd158f8
@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class SpawnerListeners implements Listener {
|
||||
|
||||
@ -45,7 +46,6 @@ public class SpawnerListeners implements Listener {
|
||||
|
||||
if (instance.getStackingTask().attemptAddToStack((LivingEntity) event.getEntity(), null)) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity.getType() == EntityType.FIREWORK) return;
|
||||
if (entity.getVehicle() != null) {
|
||||
entity.getVehicle().remove();
|
||||
entity.remove();
|
||||
@ -60,6 +60,7 @@ public class SpawnerListeners implements Listener {
|
||||
}
|
||||
}
|
||||
entity.remove();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,9 @@ public class StackingTask extends BukkitRunnable {
|
||||
stack.addAmount(amtToStack);
|
||||
stack.updateStack();
|
||||
removed.add(initialEntity.getUniqueId());
|
||||
|
||||
fixHealth(entity, initialEntity);
|
||||
|
||||
initialEntity.remove();
|
||||
|
||||
return true;
|
||||
@ -128,6 +131,9 @@ public class StackingTask extends BukkitRunnable {
|
||||
&& initialEntity.getLocation().getY() > entity.getLocation().getY()) {
|
||||
stackManager.addStack(entity, initialStack.getAmount() + 1);
|
||||
removed.add(initialEntity.getUniqueId());
|
||||
|
||||
fixHealth(initialEntity, entity);
|
||||
|
||||
initialEntity.remove();
|
||||
|
||||
return true;
|
||||
@ -148,6 +154,9 @@ public class StackingTask extends BukkitRunnable {
|
||||
|
||||
entityList.stream().filter(entity -> !stackManager.isStacked(entity)
|
||||
&& !removed.contains(entity.getUniqueId())).limit(maxEntityStackSize).forEach(entity -> {
|
||||
|
||||
fixHealth(initialEntity, entity);
|
||||
|
||||
removed.add(entity.getUniqueId());
|
||||
entity.remove();
|
||||
});
|
||||
@ -156,4 +165,9 @@ public class StackingTask extends BukkitRunnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void fixHealth(LivingEntity entity, LivingEntity initialEntity) {
|
||||
if (Setting.CARRY_OVER_LOWEST_HEALTH.getBoolean() && initialEntity.getHealth() < entity.getHealth())
|
||||
entity.setHealth(initialEntity.getHealth());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -179,10 +179,10 @@ public class Methods {
|
||||
|
||||
if (Setting.KEEP_FIRE.getBoolean())
|
||||
newEntity.setFireTicks(toClone.getFireTicks());
|
||||
if (Setting.KEEP_POTION.getBoolean())
|
||||
if (Setting.KEEP_POTION.getBoolean())
|
||||
newEntity.addPotionEffects(toClone.getActivePotionEffects());
|
||||
|
||||
return newEntity;
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public static List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initalEntity) {
|
||||
@ -368,7 +368,7 @@ public class Methods {
|
||||
}
|
||||
case PARROT_TYPE: {
|
||||
if (!UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)
|
||||
||!(initalEntity instanceof Parrot)) break;
|
||||
|| !(initalEntity instanceof Parrot)) break;
|
||||
Parrot parrot = (Parrot) initalEntity;
|
||||
entityList.removeIf(entity -> ((Parrot) entity).getVariant() != parrot.getVariant());
|
||||
break;
|
||||
@ -502,10 +502,10 @@ public class Methods {
|
||||
ItemStack glass;
|
||||
if (rainbow) {
|
||||
glass = new ItemStack(UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) randomNum);
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) randomNum);
|
||||
} else {
|
||||
glass = new ItemStack(UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ?
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) type);
|
||||
Material.LEGACY_STAINED_GLASS_PANE : Material.valueOf("STAINED_GLASS_PANE"), 1, (short) type);
|
||||
}
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName("§l");
|
||||
@ -624,5 +624,4 @@ public class Methods {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -85,6 +85,9 @@ public enum Setting {
|
||||
KEEP_POTION("Entities.Keep Potion Effects", true,
|
||||
"Should potion effects persist to the next entity when an entity dies?"),
|
||||
|
||||
CARRY_OVER_LOWEST_HEALTH("Entities.Carry Over Lowest Health", true,
|
||||
"Should the lowest health be carried over when stacked?"),
|
||||
|
||||
ONLY_STACK_FROM_SPAWNERS("Entities.Only Stack From Spawners", false,
|
||||
"Should entities only be stacked if they originate from a spawner?",
|
||||
"It should be noted that the identifier that tells the plugin",
|
||||
|
Loading…
Reference in New Issue
Block a user