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