mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 03:57:35 +01:00
Fix entity armor stand right click events
This commit is contained in:
parent
fb2ebc0a31
commit
14081192c3
@ -2,11 +2,6 @@ package net.citizensnpcs.editor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
@ -17,6 +12,11 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
|
||||
public class EquipmentEditor extends Editor {
|
||||
private final NPC npc;
|
||||
private final Player player;
|
||||
@ -50,8 +50,9 @@ public class EquipmentEditor extends Editor {
|
||||
return;
|
||||
|
||||
Equipper equipper = EQUIPPERS.get(npc.getEntity().getType());
|
||||
if (equipper == null)
|
||||
if (equipper == null) {
|
||||
equipper = new GenericEquipper();
|
||||
}
|
||||
equipper.equip(event.getPlayer(), npc);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.citizensnpcs.editor;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.trait.Equipment;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GenericEquipper implements Equipper {
|
||||
@Override
|
||||
public void equip(Player equipper, NPC toEquip) {
|
||||
@ -67,8 +67,9 @@ public class GenericEquipper implements Equipper {
|
||||
}
|
||||
// Drop any previous equipment on the ground
|
||||
ItemStack equippedItem = trait.get(slot);
|
||||
if (equippedItem != null && equippedItem.getType() != Material.AIR)
|
||||
if (equippedItem != null && equippedItem.getType() != Material.AIR) {
|
||||
equipper.getWorld().dropItemNaturally(toEquip.getEntity().getLocation(), equippedItem);
|
||||
}
|
||||
|
||||
// Now edit the equipment based on the slot
|
||||
if (type != Material.AIR) {
|
||||
|
@ -1,5 +1,14 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
@ -12,13 +21,6 @@ import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.Vec3D;
|
||||
import net.minecraft.server.v1_8_R3.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArmorStandController extends MobEntityController {
|
||||
public ArmorStandController() {
|
||||
super(EntityArmorStandNPC.class);
|
||||
@ -56,8 +58,14 @@ public class ArmorStandController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman paramEntityHuman, Vec3D paramVec3D) {
|
||||
return true;
|
||||
public boolean a(EntityHuman entityhuman, Vec3D vec3d) {
|
||||
if (npc == null) {
|
||||
return super.a(entityhuman, vec3d);
|
||||
}
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) entityhuman.getBukkitEntity(),
|
||||
getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user