Skip to content

Commit

Permalink
Fix bug with /npc playerlist, add some mob-specific methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 8, 2013
1 parent da26f45 commit 4b45fc6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -675,7 +675,7 @@ public void pathfindingRange(CommandContext args, CommandSender sender, NPC npc)
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'))
Expand All @@ -698,7 +698,6 @@ else if (args.hasFlag('r'))
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")) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/citizensnpcs/npc/entity/BatController.java
Expand Up @@ -53,7 +53,7 @@ public EntityBatNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
a(false);
setFlying(false);
}
}

Expand Down Expand Up @@ -121,5 +121,9 @@ public void l_() {
if (npc != null)
npc.update();
}

public void setFlying(boolean flying) {
a(flying);
}
}
}
Expand Up @@ -43,6 +43,7 @@ public NPC getNPC() {
}

public static class EntityCreeperNPC extends EntityCreeper implements NPCHolder {
private boolean allowPowered;
private final CitizensNPC npc;

public EntityCreeperNPC(World world) {
Expand All @@ -59,7 +60,7 @@ public EntityCreeperNPC(World world, NPC npc) {

@Override
public void a(EntityLightning entitylightning) {
if (npc == null)
if (npc == null || allowPowered)
super.a(entitylightning);
}

Expand Down Expand Up @@ -117,5 +118,9 @@ public CraftEntity getBukkitEntity() {
public NPC getNPC() {
return npc;
}

public void setAllowPowered(boolean allowPowered) {
this.allowPowered = allowPowered;
}
}
}
Expand Up @@ -29,6 +29,7 @@ public Villager getBukkitEntity() {
}

public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
private boolean blockTrades = true;
private final CitizensNPC npc;

public EntityVillagerNPC(World world) {
Expand All @@ -45,7 +46,8 @@ public EntityVillagerNPC(World world, NPC npc) {

@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
Expand Down Expand Up @@ -102,6 +104,14 @@ public CraftEntity getBukkitEntity() {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/citizensnpcs/trait/Gravity.java
Expand Up @@ -22,7 +22,7 @@ public void run() {
if (!npc.isSpawned() || !enabled)
return;
Vector vector = npc.getBukkitEntity().getVelocity();
vector.setY(0);
vector.setY(Math.max(0, vector.getY()));
npc.getBukkitEntity().setVelocity(vector);
}

Expand Down

0 comments on commit 4b45fc6

Please sign in to comment.