mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 10:35:22 +01:00
Added ability to stack by spawn reason.
This commit is contained in:
parent
4dfe48bc16
commit
7fdf7bbe3d
@ -2,7 +2,7 @@ package com.songoda.ultimatestacker.entity;
|
||||
|
||||
public enum Check {
|
||||
|
||||
SPAWN_REASON(false), // ToDo: This
|
||||
SPAWN_REASON(false),
|
||||
NERFED(true),
|
||||
AGE(true),
|
||||
TICK_AGE(false),
|
||||
|
@ -15,9 +15,12 @@ import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -31,6 +34,11 @@ public class EntityListeners implements Listener {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(CreatureSpawnEvent event) {
|
||||
event.getEntity().setMetadata("US_REASON", new FixedMetadataValue(instance, event.getSpawnReason().name()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEgg(ItemSpawnEvent event) {
|
||||
if (event.getEntity().getItemStack().getType() != Material.EGG) return;
|
||||
|
@ -188,6 +188,10 @@ public class Methods {
|
||||
for (String checkStr : checks) {
|
||||
Check check = Check.valueOf(checkStr);
|
||||
switch (check) {
|
||||
case SPAWN_REASON: {
|
||||
if (initalEntity.hasMetadata("US_REASON"))
|
||||
entityList.removeIf(entity -> entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").get(0).asString().equals("US_REASON"));
|
||||
}
|
||||
case AGE: {
|
||||
if (!(initalEntity instanceof Ageable)) break;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public enum Setting {
|
||||
"These are checks that are processed before an entity is stacked.",
|
||||
"You can add and remove from the list at will.",
|
||||
"The acceptable check options are:",
|
||||
"NERFED, AGE, TICK_AGE, PHANTOM_SIZE",
|
||||
"SPAWN_REASON, NERFED, AGE, TICK_AGE, PHANTOM_SIZE",
|
||||
"CAN_BREED, IS_TAMED, ANIMAL_OWNER, SKELETON_TYPE",
|
||||
"ZOMBIE_BABY, SLIME_SIZE, PIG_SADDLE, SHEEP_SHEERED",
|
||||
"SHEEP_COLOR, WOLF_COLLAR_COLOR, OCELOT_TYPE, HORSE_COLOR",
|
||||
|
Loading…
Reference in New Issue
Block a user