mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-10-02 09:08:02 +02:00
Allow any entity type to be controlled as a flyable npc
This commit is contained in:
parent
ea190794da
commit
996dd07f2c
@ -202,14 +202,16 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "controllable|control",
|
||||
usage = "controllable|control -f",
|
||||
desc = "Toggles whether the NPC can be ridden and controlled",
|
||||
modifiers = { "controllable", "control" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "f",
|
||||
permission = "npc.controllable")
|
||||
public void controllable(CommandContext args, CommandSender sender, NPC npc) {
|
||||
boolean enabled = npc.getTrait(Controllable.class).toggle();
|
||||
Controllable trait = npc.getTrait(Controllable.class);
|
||||
boolean enabled = trait.toggle();
|
||||
String key = enabled ? Messages.CONTROLLABLE_SET : Messages.CONTROLLABLE_REMOVED;
|
||||
Messaging.sendTr(sender, key);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class TraitCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "traitc", "trc", "tc" },
|
||||
aliases = { "traitc", "trc" },
|
||||
usage = "[trait name] [flags]",
|
||||
desc = "Configures a trait",
|
||||
modifiers = { "*" },
|
||||
|
@ -7,6 +7,8 @@ import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
import net.citizensnpcs.command.CommandConfigurable;
|
||||
import net.citizensnpcs.command.CommandContext;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
|
||||
@ -22,7 +24,7 @@ import org.bukkit.util.Vector;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
//TODO: reduce reliance on CitizensNPC
|
||||
public class Controllable extends Trait implements Toggleable {
|
||||
public class Controllable extends Trait implements Toggleable, CommandConfigurable {
|
||||
private Controller controller = new GroundController();
|
||||
private boolean enabled;
|
||||
|
||||
@ -224,4 +226,10 @@ public class Controllable extends Trait implements Toggleable {
|
||||
controllerTypes.put(EntityType.ENDER_DRAGON, AirController.class);
|
||||
controllerTypes.put(EntityType.GHAST, AirController.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(CommandContext args) {
|
||||
if (args.hasFlag('f'))
|
||||
controller = new AirController();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user