mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-06 16:37:37 +01:00
Update
This commit is contained in:
parent
996dd07f2c
commit
c9f054b615
@ -9,6 +9,7 @@ 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.CommandConfigurable;
|
||||||
import net.citizensnpcs.command.CommandContext;
|
import net.citizensnpcs.command.CommandContext;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.EntityLiving;
|
import net.minecraft.server.EntityLiving;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ import com.google.common.collect.Maps;
|
|||||||
public class Controllable extends Trait implements Toggleable, CommandConfigurable {
|
public class Controllable extends Trait implements Toggleable, CommandConfigurable {
|
||||||
private Controller controller = new GroundController();
|
private Controller controller = new GroundController();
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
private EntityType explicitType;
|
||||||
|
|
||||||
public Controllable() {
|
public Controllable() {
|
||||||
super("controllable");
|
super("controllable");
|
||||||
@ -53,6 +55,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
|||||||
@Override
|
@Override
|
||||||
public void load(DataKey key) throws NPCLoadException {
|
public void load(DataKey key) throws NPCLoadException {
|
||||||
enabled = key.getBoolean("enabled");
|
enabled = key.getBoolean("enabled");
|
||||||
|
explicitType = Util.matchEntityType(key.getString("explicittype"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mount(Player toMount) {
|
public boolean mount(Player toMount) {
|
||||||
@ -93,7 +96,13 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSpawn() {
|
public void onSpawn() {
|
||||||
|
loadController();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadController() {
|
||||||
EntityType type = npc.getBukkitEntity().getType();
|
EntityType type = npc.getBukkitEntity().getType();
|
||||||
|
if (explicitType != null)
|
||||||
|
type = explicitType;
|
||||||
Class<? extends Controller> clazz = controllerTypes.get(type);
|
Class<? extends Controller> clazz = controllerTypes.get(type);
|
||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
controller = new GroundController();
|
controller = new GroundController();
|
||||||
@ -128,6 +137,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
|||||||
@Override
|
@Override
|
||||||
public void save(DataKey key) {
|
public void save(DataKey key) {
|
||||||
key.setBoolean("enabled", enabled);
|
key.setBoolean("enabled", enabled);
|
||||||
|
key.setString("explicittype", explicitType.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -230,6 +240,12 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
|||||||
@Override
|
@Override
|
||||||
public void configure(CommandContext args) {
|
public void configure(CommandContext args) {
|
||||||
if (args.hasFlag('f'))
|
if (args.hasFlag('f'))
|
||||||
controller = new AirController();
|
explicitType = EntityType.BLAZE;
|
||||||
|
else if (args.hasFlag('n'))
|
||||||
|
explicitType = null;
|
||||||
|
else if (args.hasValueFlag("explicittype"))
|
||||||
|
explicitType = Util.matchEntityType(args.getFlag("explicittype"));
|
||||||
|
if (npc.isSpawned())
|
||||||
|
loadController();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user