mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-14 12:11:30 +01:00
Set the default controllable behaviour to not require an owner (use the -o flag to require an owner)
This commit is contained in:
parent
36b9a0c4c8
commit
8ae49480ae
@ -216,12 +216,12 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "controllable|control (-m,-y,-n)",
|
||||
usage = "controllable|control (-m(ount),-y,-n,-o)",
|
||||
desc = "Toggles whether the NPC can be ridden and controlled",
|
||||
modifiers = { "controllable", "control" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "myn")
|
||||
flags = "myno")
|
||||
public void controllable(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if ((npc.isSpawned() && !sender.hasPermission("citizens.npc.controllable."
|
||||
+ npc.getEntity().getType().name().toLowerCase().replace("_", "")))
|
||||
@ -237,6 +237,7 @@ public class NPCCommands {
|
||||
} else if (args.hasFlag('n')) {
|
||||
enabled = trait.setEnabled(false);
|
||||
}
|
||||
trait.setOwnerRequired(args.hasFlag('o'));
|
||||
String key = enabled ? Messages.CONTROLLABLE_SET : Messages.CONTROLLABLE_REMOVED;
|
||||
Messaging.sendTr(sender, key, npc.getName());
|
||||
if (enabled && args.hasFlag('m') && sender instanceof Player) {
|
||||
|
@ -36,6 +36,8 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
@Persist
|
||||
private boolean enabled = true;
|
||||
private EntityType explicitType;
|
||||
@Persist("owner_required")
|
||||
private boolean ownerRequired;
|
||||
|
||||
public Controllable() {
|
||||
super("controllable");
|
||||
@ -58,9 +60,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
explicitType = null;
|
||||
} else if (args.hasValueFlag("explicittype"))
|
||||
explicitType = Util.matchEntityType(args.getFlag("explicittype"));
|
||||
if (npc.isSpawned())
|
||||
if (npc.isSpawned()) {
|
||||
loadController();
|
||||
}
|
||||
}
|
||||
|
||||
private void enterOrLeaveVehicle(Player player) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
@ -70,9 +73,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (npc.getTrait(Owner.class).isOwnedBy(handle.getBukkitEntity())) {
|
||||
handle.setPassengerOf(getHandle());
|
||||
if (ownerRequired && !npc.getTrait(Owner.class).isOwnedBy(handle.getBukkitEntity())) {
|
||||
return;
|
||||
}
|
||||
handle.setPassengerOf(getHandle());
|
||||
}
|
||||
|
||||
private net.minecraft.server.v1_7_R4.Entity getHandle() {
|
||||
@ -195,6 +199,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
NMS.setHeadYaw(handle, handle.yaw);
|
||||
}
|
||||
|
||||
public void setOwnerRequired(boolean ownerRequired) {
|
||||
this.ownerRequired = ownerRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
enabled = !enabled;
|
||||
@ -360,7 +368,6 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
|
||||
private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
|
||||
.newEnumMap(EntityType.class);
|
||||
|
||||
static {
|
||||
controllerTypes.put(EntityType.BAT, PlayerInputAirController.class);
|
||||
controllerTypes.put(EntityType.BLAZE, PlayerInputAirController.class);
|
||||
|
Loading…
Reference in New Issue
Block a user