mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-06-26 14:35:03 +02:00
Add unmount flag to /npc mount
This commit is contained in:
parent
8ed08f0b2e
commit
3feaf43f48
|
@ -79,6 +79,7 @@ import net.citizensnpcs.trait.GameModeTrait;
|
|||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.HorseModifiers;
|
||||
import net.citizensnpcs.trait.LookClose;
|
||||
import net.citizensnpcs.trait.MountTrait;
|
||||
import net.citizensnpcs.trait.OcelotModifiers;
|
||||
import net.citizensnpcs.trait.Poses;
|
||||
import net.citizensnpcs.trait.Powered;
|
||||
|
@ -484,7 +485,8 @@ public class NPCCommands {
|
|||
if (args.argsLength() < 2) {
|
||||
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||
}
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args, args.getString(1));
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args,
|
||||
args.getString(1));
|
||||
} else {
|
||||
callback.run(npc);
|
||||
}
|
||||
|
@ -891,11 +893,12 @@ public class NPCCommands {
|
|||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "mount (--onnpc <npc id>)",
|
||||
usage = "mount (--onnpc <npc id>) (-c (ancel))",
|
||||
desc = "Mounts a controllable NPC",
|
||||
modifiers = { "mount" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "c",
|
||||
permission = "citizens.npc.controllable")
|
||||
public void mount(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.hasValueFlag("onnpc")) {
|
||||
|
@ -914,6 +917,9 @@ public class NPCCommands {
|
|||
}
|
||||
NMS.mount(mount.getEntity(), npc.getEntity());
|
||||
return;
|
||||
} else if (args.hasFlag('c')) {
|
||||
npc.getTrait(MountTrait.class).unmount();
|
||||
return;
|
||||
}
|
||||
boolean enabled = npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled();
|
||||
if (!enabled) {
|
||||
|
@ -1325,7 +1331,8 @@ public class NPCCommands {
|
|||
Messaging.sendTr(sender, Messages.NPC_REMOVED, npc.getName());
|
||||
}
|
||||
};
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args, args.getString(1));
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args,
|
||||
args.getString(1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1452,7 +1459,8 @@ public class NPCCommands {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args, args.getString(1));
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args,
|
||||
args.getString(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1696,7 +1704,8 @@ public class NPCCommands {
|
|||
}
|
||||
};
|
||||
if (args.argsLength() > 1) {
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args, args.getString(1));
|
||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args,
|
||||
args.getString(1));
|
||||
} else {
|
||||
callback.run(npc);
|
||||
}
|
||||
|
|
|
@ -67,4 +67,15 @@ public class MountTrait extends Trait {
|
|||
}
|
||||
checkMount(e);
|
||||
}
|
||||
|
||||
public void unmount() {
|
||||
if (mountedOn != null) {
|
||||
Entity e = NMS.getVehicle(npc.getEntity());
|
||||
if (e != null) {
|
||||
npc.getEntity().leaveVehicle();
|
||||
}
|
||||
uuid = null;
|
||||
mountedOn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user