Fix issues with editors not respecting editing player

This commit is contained in:
fullwall 2018-10-13 11:11:09 +08:00
parent 0ecd480790
commit 1276365a11
2 changed files with 9 additions and 8 deletions

View File

@ -1,16 +1,16 @@
package net.citizensnpcs.editor;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.util.Messages;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.util.Messages;
public class CopierEditor extends Editor {
private final String name;
private final NPC npc;
@ -34,7 +34,7 @@ public class CopierEditor extends Editor {
@EventHandler
public void onBlockClick(PlayerInteractEvent event) {
if (event.getClickedBlock() == null) {
if (event.getClickedBlock() == null || !event.getPlayer().equals(player)) {
return;
}
NPC copy = npc.clone();

View File

@ -45,6 +45,8 @@ public class EquipmentEditor extends Editor {
@EventHandler(ignoreCancelled = true)
public void onPlayerChat(final AsyncPlayerChatEvent event) {
if (!event.getPlayer().equals(player))
return;
EquipmentSlot slot = null;
if (event.getMessage().contains("helmet")
&& event.getPlayer().hasPermission("citizens.npc.edit.equip.any-helmet")) {
@ -83,7 +85,7 @@ public class EquipmentEditor extends Editor {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR && Editor.hasEditor(event.getPlayer())) {
if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().equals(player)) {
event.setUseItemInHand(Result.DENY);
}
}
@ -93,7 +95,6 @@ public class EquipmentEditor extends Editor {
if (!npc.isSpawned() || !event.getPlayer().equals(player) || Util.isOffHand(event)
|| !npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())))
return;
Equipper equipper = EQUIPPERS.get(npc.getEntity().getType());
if (equipper == null) {
equipper = new GenericEquipper();