merge master, fix conflicts

This commit is contained in:
JCThePants 2015-08-25 14:29:51 -07:00
commit 8d3ab22212
13 changed files with 170 additions and 96 deletions

View File

@ -72,6 +72,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
@ -217,8 +218,8 @@ public class EventListen implements Listener {
if (npc == null) { if (npc == null) {
return; return;
} }
Bukkit.getPluginManager().callEvent(new NPCDeathEvent(npc, event));
final Location location = npc.getEntity().getLocation(); final Location location = npc.getEntity().getLocation();
Bukkit.getPluginManager().callEvent(new NPCDeathEvent(npc, event));
npc.despawn(DespawnReason.DEATH); npc.despawn(DespawnReason.DEATH);
if (npc.data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) { if (npc.data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
@ -236,7 +237,7 @@ public class EventListen implements Listener {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (!npc.isSpawned()) { if (!npc.isSpawned() && npc.getOwningRegistry().getByUniqueId(npc.getUniqueId()) == npc) {
npc.spawn(location); npc.spawn(location);
} }
} }
@ -387,6 +388,15 @@ public class EventListen implements Listener {
recalculatePlayer(event.getPlayer(), 15, true); recalculatePlayer(event.getPlayer(), 15, true);
} }
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
NPC npc = npcRegistry.getNPC(event.getVehicle());
if (npc == null) {
return;
}
event.setCancelled(npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
}
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) { public void onVehicleEnter(VehicleEnterEvent event) {
if (!npcRegistry.isNPC(event.getEntered())) if (!npcRegistry.isNPC(event.getEntered()))

View File

@ -852,11 +852,6 @@ public class NPCCommands {
public void name(CommandContext args, CommandSender sender, NPC npc) { public void name(CommandContext args, CommandSender sender, NPC npc) {
LivingEntity entity = (LivingEntity) npc.getEntity(); LivingEntity entity = (LivingEntity) npc.getEntity();
entity.setCustomNameVisible(!entity.isCustomNameVisible()); entity.setCustomNameVisible(!entity.isCustomNameVisible());
if (!entity.isCustomNameVisible()) {
entity.setCustomName("");
} else {
entity.setCustomName(npc.getFullName());
}
npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, entity.isCustomNameVisible()); npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, entity.isCustomNameVisible());
Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED); Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED);
} }

View File

@ -2,6 +2,13 @@ package net.citizensnpcs.commands;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.command.Command; import net.citizensnpcs.api.command.Command;
import net.citizensnpcs.api.command.CommandConfigurable; import net.citizensnpcs.api.command.CommandConfigurable;
@ -16,13 +23,6 @@ import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Messages; import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.StringHelper; import net.citizensnpcs.util.StringHelper;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
@Requirements(selected = true, ownership = true) @Requirements(selected = true, ownership = true)
public class TraitCommands { public class TraitCommands {
@Command( @Command(
@ -30,12 +30,12 @@ public class TraitCommands {
usage = "add [trait name]...", usage = "add [trait name]...",
desc = "Adds traits to the NPC", desc = "Adds traits to the NPC",
modifiers = { "add", "a" }, modifiers = { "add", "a" },
min = 1, min = 2,
permission = "citizens.npc.trait") permission = "citizens.npc.trait")
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException { public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
List<String> added = Lists.newArrayList(); List<String> added = Lists.newArrayList();
List<String> failed = Lists.newArrayList(); List<String> failed = Lists.newArrayList();
for (String traitName : Splitter.on(',').split(args.getJoinedStrings(0))) { for (String traitName : Splitter.on(',').split(args.getJoinedStrings(1))) {
if (!sender.hasPermission("citizens.npc.trait." + traitName) if (!sender.hasPermission("citizens.npc.trait." + traitName)
&& !sender.hasPermission("citizens.npc.trait.*")) { && !sender.hasPermission("citizens.npc.trait.*")) {
failed.add(String.format("%s: No permission", traitName)); failed.add(String.format("%s: No permission", traitName));

View File

@ -43,8 +43,9 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scoreboard.NameTagVisibility;
public class CitizensNPC extends AbstractNPC { public class CitizensNPC extends AbstractNPC {
private EntityController entityController; private EntityController entityController;
@ -65,7 +66,6 @@ public class CitizensNPC extends AbstractNPC {
} }
return false; return false;
} }
NPCDespawnEvent event = new NPCDespawnEvent(this, reason); NPCDespawnEvent event = new NPCDespawnEvent(this, reason);
if (reason == DespawnReason.CHUNK_UNLOAD) { if (reason == DespawnReason.CHUNK_UNLOAD) {
event.setCancelled(Setting.KEEP_CHUNKS_LOADED.asBoolean()); event.setCancelled(Setting.KEEP_CHUNKS_LOADED.asBoolean());
@ -186,7 +186,7 @@ public class CitizensNPC extends AbstractNPC {
entityController.spawn(at, this); entityController.spawn(at, this);
net.minecraft.server.v1_8_R3.Entity mcEntity = ((CraftEntity) getEntity()).getHandle(); net.minecraft.server.v1_8_R3.Entity mcEntity = ((CraftEntity) getEntity()).getHandle();
boolean couldSpawn = !Util.isLoaded(at) ? false : mcEntity.world.addEntity(mcEntity, CreatureSpawnEvent.SpawnReason.CUSTOM); boolean couldSpawn = !Util.isLoaded(at) ? false : mcEntity.world.addEntity(mcEntity, SpawnReason.CUSTOM);
// send skin packets, if applicable, before other NMS packets are sent // send skin packets, if applicable, before other NMS packets are sent
SkinnableEntity skinnable = NMS.getSkinnableNPC(getEntity()); SkinnableEntity skinnable = NMS.getSkinnableNPC(getEntity());
@ -255,7 +255,6 @@ public class CitizensNPC extends AbstractNPC {
if (getEntity() instanceof LivingEntity) { if (getEntity() instanceof LivingEntity) {
LivingEntity entity = (LivingEntity) getEntity(); LivingEntity entity = (LivingEntity) getEntity();
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);
entity.setCustomName(getFullName());
if (NMS.getStepHeight(entity) < 1) { if (NMS.getStepHeight(entity) < 1) {
NMS.setStepHeight(NMS.getHandle(entity), 1); NMS.setStepHeight(NMS.getHandle(entity), 1);
@ -284,7 +283,21 @@ public class CitizensNPC extends AbstractNPC {
if (!getNavigator().isNavigating() if (!getNavigator().isNavigating()
&& getEntity().getWorld().getFullTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) { && getEntity().getWorld().getFullTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
if (getEntity() instanceof LivingEntity) { if (getEntity() instanceof LivingEntity) {
((LivingEntity) getEntity()).setCustomName(getFullName()); if (!getEntity().isCustomNameVisible()) {
if (getEntity() instanceof Player && data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName)
.setNameTagVisibility(NameTagVisibility.NEVER);
}
getEntity().setCustomName("");
} else {
if (getEntity() instanceof Player && data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName)
.setNameTagVisibility(NameTagVisibility.ALWAYS);
}
getEntity().setCustomName(getFullName());
}
} }
Player player = getEntity() instanceof Player ? (Player) getEntity() : null; Player player = getEntity() instanceof Player ? (Player) getEntity() : null;
NMS.sendPacketNearby(player, getStoredLocation(), NMS.sendPacketNearby(player, getStoredLocation(),

View File

@ -1,5 +1,9 @@
package net.citizensnpcs.npc.ai; package net.citizensnpcs.npc.ai;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.LivingEntity;
import net.citizensnpcs.api.ai.AttackStrategy; import net.citizensnpcs.api.ai.AttackStrategy;
import net.citizensnpcs.api.ai.EntityTarget; import net.citizensnpcs.api.ai.EntityTarget;
import net.citizensnpcs.api.ai.NavigatorParameters; import net.citizensnpcs.api.ai.NavigatorParameters;
@ -13,10 +17,6 @@ import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.NavigationAbstract; import net.minecraft.server.v1_8_R3.NavigationAbstract;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.LivingEntity;
public class MCTargetStrategy implements PathStrategy, EntityTarget { public class MCTargetStrategy implements PathStrategy, EntityTarget {
private final boolean aggro; private final boolean aggro;
private int attackTicks; private int attackTicks;
@ -117,9 +117,10 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
} }
if (!aggro && distanceSquared() < parameters.distanceMargin()) { if (!aggro && distanceSquared() < parameters.distanceMargin()) {
stop(); stop();
} else if (target.world.getWorld().getFullTime() % 10 == 0) { } else if (target.world.getWorld().getFullTime() % 60 == 0) {
setPath(); setPath();
} }
NMS.look(handle, target); NMS.look(handle, target);
if (aggro && canAttack()) { if (aggro && canAttack()) {
AttackStrategy strategy = parameters.attackStrategy(); AttackStrategy strategy = parameters.attackStrategy();

View File

@ -25,7 +25,6 @@ import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
public class HumanController extends AbstractEntityController { public class HumanController extends AbstractEntityController {
public HumanController() { public HumanController() {
super(); super();
} }
@ -77,7 +76,7 @@ public class HumanController extends AbstractEntityController {
uuid = new UUID(msb, uuid.getLeastSignificantBits()); uuid = new UUID(msb, uuid.getLeastSignificantBits());
} }
final GameProfile profile = new GameProfile(uuid, coloredName); GameProfile profile = new GameProfile(uuid, coloredName);
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile, final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
new PlayerInteractManager(nmsWorld), npc); new PlayerInteractManager(nmsWorld), npc);

View File

@ -1,5 +1,12 @@
package net.citizensnpcs.npc.entity.nonliving; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartChest;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,17 +14,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartChest; import net.minecraft.server.v1_8_R3.EntityMinecartChest;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartChest;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartChestController extends MobEntityController { public class MinecartChestController extends MobEntityController {
public MinecartChestController() { public MinecartChestController() {
super(EntityMinecartChestNPC.class); super(EntityMinecartChestNPC.class);
@ -55,6 +56,13 @@ public class MinecartChestController extends MobEntityController {
return npc == null ? super.d(save) : false; return npc == null ? super.d(save) : false;
} }
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,12 @@
package net.citizensnpcs.npc.entity.nonliving; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartCommand;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,17 +14,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartCommandBlock; import net.minecraft.server.v1_8_R3.EntityMinecartCommandBlock;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartCommand;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartCommandController extends MobEntityController { public class MinecartCommandController extends MobEntityController {
public MinecartCommandController() { public MinecartCommandController() {
super(EntityMinecartCommandNPC.class); super(EntityMinecartCommandNPC.class);
@ -40,11 +41,6 @@ public class MinecartCommandController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -55,6 +51,18 @@ public class MinecartCommandController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,12 @@
package net.citizensnpcs.npc.entity.nonliving; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartFurnace;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,17 +14,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartFurnace; import net.minecraft.server.v1_8_R3.EntityMinecartFurnace;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartFurnace;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartFurnaceController extends MobEntityController { public class MinecartFurnaceController extends MobEntityController {
public MinecartFurnaceController() { public MinecartFurnaceController() {
super(EntityMinecartFurnaceNPC.class); super(EntityMinecartFurnaceNPC.class);
@ -40,11 +41,6 @@ public class MinecartFurnaceController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -55,6 +51,18 @@ public class MinecartFurnaceController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,8 @@
package net.citizensnpcs.npc.entity.nonliving; package net.citizensnpcs.npc.entity.nonliving;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,13 +10,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartHopper; import net.minecraft.server.v1_8_R3.EntityMinecartHopper;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; import net.minecraft.server.v1_8_R3.World;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartHopperController extends MobEntityController { public class MinecartHopperController extends MobEntityController {
public MinecartHopperController() { public MinecartHopperController() {
super(EntityMinecartHopperNPC.class); super(EntityMinecartHopperNPC.class);
@ -36,11 +37,6 @@ public class MinecartHopperController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -51,6 +47,18 @@ public class MinecartHopperController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,12 @@
package net.citizensnpcs.npc.entity.nonliving; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartRideable;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,17 +14,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartRideable; import net.minecraft.server.v1_8_R3.EntityMinecartRideable;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecartRideable;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartRideableController extends MobEntityController { public class MinecartRideableController extends MobEntityController {
public MinecartRideableController() { public MinecartRideableController() {
super(EntityMinecartRideableNPC.class); super(EntityMinecartRideableNPC.class);
@ -40,11 +41,6 @@ public class MinecartRideableController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -55,6 +51,18 @@ public class MinecartRideableController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,8 @@
package net.citizensnpcs.npc.entity.nonliving; package net.citizensnpcs.npc.entity.nonliving;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,13 +10,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartMobSpawner; import net.minecraft.server.v1_8_R3.EntityMinecartMobSpawner;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; import net.minecraft.server.v1_8_R3.World;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartSpawnerController extends MobEntityController { public class MinecartSpawnerController extends MobEntityController {
public MinecartSpawnerController() { public MinecartSpawnerController() {
super(EntityMinecartSpawnerNPC.class); super(EntityMinecartSpawnerNPC.class);
@ -36,11 +37,6 @@ public class MinecartSpawnerController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -51,6 +47,18 @@ public class MinecartSpawnerController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {

View File

@ -1,5 +1,8 @@
package net.citizensnpcs.npc.entity.nonliving; package net.citizensnpcs.npc.entity.nonliving;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.CitizensNPC;
@ -7,13 +10,11 @@ import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityMinecartTNT; import net.minecraft.server.v1_8_R3.EntityMinecartTNT;
import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World; import net.minecraft.server.v1_8_R3.World;
import org.bukkit.entity.Minecart;
import org.bukkit.util.Vector;
public class MinecartTNTController extends MobEntityController { public class MinecartTNTController extends MobEntityController {
public MinecartTNTController() { public MinecartTNTController() {
super(EntityMinecartTNTNPC.class); super(EntityMinecartTNTNPC.class);
@ -36,11 +37,6 @@ public class MinecartTNTController extends MobEntityController {
this.npc = (CitizensNPC) npc; this.npc = (CitizensNPC) npc;
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override @Override
public void collide(net.minecraft.server.v1_8_R3.Entity entity) { public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
// this method is called by both the entities involved - cancelling // this method is called by both the entities involved - cancelling
@ -51,6 +47,18 @@ public class MinecartTNTController extends MobEntityController {
} }
} }
@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
return super.damageEntity(damagesource, f);
return false;
}
@Override @Override
public void g(double x, double y, double z) { public void g(double x, double y, double z) {
if (npc == null) { if (npc == null) {