mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-27 04:25:21 +01:00
Sheep color
This commit is contained in:
parent
f4ce12ff8e
commit
9458e5bdf7
@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityBreedEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.SheepDyeWoolEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
@ -29,6 +30,25 @@ public class InteractListeners implements Listener {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSheepDye(SheepDyeWoolEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!instance.getEntityStackManager().isStacked(entity) || event.getColor() == ((Sheep) entity).getColor()) return;
|
||||
EntityStack stack = instance.getEntityStackManager().getStack(entity);
|
||||
|
||||
Entity newEntity = entity.getWorld().spawnEntity(entity.getLocation(), entity.getType());
|
||||
entity.setVelocity(getRandomVector());
|
||||
|
||||
Sheep sheep = ((Sheep) newEntity);
|
||||
sheep.setSheared(sheep.isSheared());
|
||||
sheep.setColor(sheep.getColor());
|
||||
|
||||
instance.getEntityStackManager().addStack(new EntityStack(newEntity, stack.getAmount() - 1));
|
||||
stack.setAmount(1);
|
||||
instance.getEntityStackManager().removeStack(entity);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user