mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 01:27:33 +01:00
Move PlayerShearEntityEvent handling to EventListen to cover for snowman
This commit is contained in:
parent
4e4112d531
commit
d005c228ff
@ -46,6 +46,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@ -631,6 +632,16 @@ public class EventListen implements Listener {
|
||||
skinUpdateTracker.updatePlayer(event.getPlayer(), 15, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShearEntityEvent(PlayerShearEntityEvent event) {
|
||||
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getEntity());
|
||||
if (npc == null)
|
||||
return;
|
||||
if (npc.isProtected()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getPlayer());
|
||||
|
@ -2,10 +2,7 @@ package net.citizensnpcs.trait;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
@ -32,13 +29,6 @@ public class SheepTrait extends Trait {
|
||||
return sheared;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onPlayerShearEntityEvent(PlayerShearEntityEvent event) {
|
||||
if (npc != null && npc.isProtected() && npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getEntity()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (npc.getEntity() instanceof Sheep) {
|
||||
|
Loading…
Reference in New Issue
Block a user