Fix bug with /npc playerlist, add some mob-specific methods

This commit is contained in:
fullwall 2013-06-08 18:43:19 +08:00
parent c9f51bca26
commit 8d7d8a7261
5 changed files with 24 additions and 6 deletions

View File

@ -675,7 +675,7 @@ public class NPCCommands {
max = 1,
flags = "ar",
permission = "citizens.npc.playerlist")
@Requirements(types = EntityType.PLAYER)
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
public void playerlist(CommandContext args, CommandSender sender, NPC npc) {
boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
if (args.hasFlag('a'))
@ -698,7 +698,6 @@ public class NPCCommands {
min = 1,
max = 2,
permission = "citizens.npc.pose")
@Requirements(selected = true, ownership = true)
public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Poses trait = npc.getTrait(Poses.class);
if (args.hasValueFlag("save")) {

View File

@ -53,7 +53,7 @@ public class BatController extends MobEntityController {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
a(false);
setFlying(false);
}
}
@ -121,5 +121,9 @@ public class BatController extends MobEntityController {
if (npc != null)
npc.update();
}
public void setFlying(boolean flying) {
a(flying);
}
}
}

View File

@ -43,6 +43,7 @@ public class CreeperController extends MobEntityController {
}
public static class EntityCreeperNPC extends EntityCreeper implements NPCHolder {
private boolean allowPowered;
private final CitizensNPC npc;
public EntityCreeperNPC(World world) {
@ -59,7 +60,7 @@ public class CreeperController extends MobEntityController {
@Override
public void a(EntityLightning entitylightning) {
if (npc == null)
if (npc == null || allowPowered)
super.a(entitylightning);
}
@ -117,5 +118,9 @@ public class CreeperController extends MobEntityController {
public NPC getNPC() {
return npc;
}
public void setAllowPowered(boolean allowPowered) {
this.allowPowered = allowPowered;
}
}
}

View File

@ -29,6 +29,7 @@ public class VillagerController extends MobEntityController {
}
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
private boolean blockTrades = true;
private final CitizensNPC npc;
public EntityVillagerNPC(World world) {
@ -45,7 +46,8 @@ public class VillagerController extends MobEntityController {
@Override
public boolean a_(EntityHuman entityhuman) {
return npc == null ? super.a_(entityhuman) : false; // block trades
return npc == null || !blockTrades ? super.a_(entityhuman) : false; // block
// trades
}
@Override
@ -102,6 +104,14 @@ public class VillagerController extends MobEntityController {
public NPC getNPC() {
return npc;
}
public boolean isBlockingTrades() {
return blockTrades;
}
public void setBlockTrades(boolean blocked) {
this.blockTrades = blocked;
}
}
public static class VillagerNPC extends CraftVillager implements NPCHolder {

View File

@ -22,7 +22,7 @@ public class Gravity extends Trait implements Toggleable {
if (!npc.isSpawned() || !enabled)
return;
Vector vector = npc.getBukkitEntity().getVelocity();
vector.setY(0);
vector.setY(Math.max(0, vector.getY()));
npc.getBukkitEntity().setVelocity(vector);
}