mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 19:16:34 +01:00
Fix bug with /npc playerlist, add some mob-specific methods
This commit is contained in:
parent
c9f51bca26
commit
8d7d8a7261
@ -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")) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user