Add leashable command

This commit is contained in:
fullwall 2013-07-09 22:01:00 +08:00
parent 9b8bef597d
commit c7057656a3
32 changed files with 314 additions and 1 deletions

View File

@ -458,6 +458,26 @@ public class NPCCommands {
Messaging.send(sender, npc.getId());
}
@Command(
aliases = { "npc" },
usage = "leashable",
desc = "Toggles leashability",
modifiers = { "leashable" },
min = 1,
max = 1,
flags = "t",
permission = "citizens.npc.leashable")
public void leashable(CommandContext args, CommandSender sender, NPC npc) {
boolean vulnerable = !npc.data().get(NPC.LEASH_PROTECTED_METADATA, true);
if (args.hasFlag('t')) {
npc.data().set(NPC.LEASH_PROTECTED_METADATA, vulnerable);
} else {
npc.data().setPersistent(NPC.LEASH_PROTECTED_METADATA, vulnerable);
}
String key = vulnerable ? Messages.LEASHABLE_STOPPED : Messages.LEASHABLE_SET;
Messaging.sendTr(sender, key, npc.getName());
}
@Command(
aliases = { "npc" },
usage = "list (page) ((-a) --owner (owner) --type (type) --char (char))",

View File

@ -67,6 +67,16 @@ public class BatController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -56,6 +56,16 @@ public class BlazeController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc != null) {

View File

@ -64,6 +64,16 @@ public class CaveSpiderController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null)

View File

@ -63,6 +63,16 @@ public class ChickenController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -64,6 +64,16 @@ public class CowController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -71,6 +71,16 @@ public class CreeperController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -56,6 +56,16 @@ public class EnderDragonController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null) {

View File

@ -63,6 +63,16 @@ public class EndermanController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null)

View File

@ -42,6 +42,16 @@ public class GhastController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc != null) {

View File

@ -42,6 +42,16 @@ public class GiantController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null) {

View File

@ -42,6 +42,16 @@ public class HorseController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void c() {
if (npc == null) {

View File

@ -49,6 +49,16 @@ public class IronGolemController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -50,6 +50,16 @@ public class MagmaCubeController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null)

View File

@ -50,6 +50,16 @@ public class MushroomCowController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -50,6 +50,16 @@ public class OcelotController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -56,6 +56,16 @@ public class PigController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -50,6 +50,16 @@ public class PigZombieController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null) {

View File

@ -50,6 +50,16 @@ public class SheepController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -39,7 +39,6 @@ public class SilverfishController extends MobEntityController {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}
@ -50,6 +49,16 @@ public class SilverfishController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null) {

View File

@ -49,6 +49,16 @@ public class SkeletonController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -51,6 +51,16 @@ public class SlimeController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null) {

View File

@ -49,6 +49,16 @@ public class SnowmanController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -49,6 +49,16 @@ public class SpiderController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc == null)

View File

@ -42,6 +42,16 @@ public class SquidController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void bk() {
if (npc != null) {

View File

@ -57,6 +57,16 @@ public class VillagerController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -49,6 +49,16 @@ public class WitchController extends MobEntityController {
npc.update();
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -50,6 +50,16 @@ public class WitherController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void c() {
if (npc == null) {

View File

@ -50,6 +50,16 @@ public class WolfController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -50,6 +50,16 @@ public class ZombieController extends MobEntityController {
}
}
@Override
public boolean bH() {
if (npc == null)
return super.bH();
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH();
return false; // shouldLeash
}
@Override
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -86,6 +86,8 @@ public class Messages {
public static final String INVALID_SKELETON_TYPE = "citizens.commands.npc.skeletontype.invalid-type";
public static final String INVALID_SPAWN_LOCATION = "citizens.commands.npc.create.invalid-location";
public static final String INVALID_TRIGGER_TELEPORT_FORMAT = "citizens.editors.waypoints.triggers.teleport.invalid-format";
public static final String LEASHABLE_SET = "citizens.commands.npc.leashable.set";
public static final String LEASHABLE_STOPPED = "citizens.commands.npc.leashable.stopped";
public static final String LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT = "citizens.editors.waypoints.linear.added-waypoint";
public static final String LINEAR_WAYPOINT_EDITOR_BEGIN = "citizens.editors.waypoints.linear.begin";
public static final String LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET = "citizens.editors.waypoints.linear.edit-slot-set";

View File

@ -40,6 +40,8 @@ citizens.commands.npc.gamemode.invalid={0} is not a valid gamemode.
citizens.commands.npc.gamemode.set=Gamemode set to [[{0}]].
citizens.commands.npc.gravity.disabled=Gravity [[disabled]].
citizens.commands.npc.gravity.enabled=Gravity [[enabled]].
citizens.commands.npc.leashable.set=[[{0}]] is now leashable.
citizens.commands.npc.leashable.stopped=[[{0}]] is no longer leashable.
citizens.commands.npc.lookclose.set=[[{0}]] will now rotate when players are nearby.
citizens.commands.npc.lookclose.stopped=[[{0}]] will no longer rotate when players are nearby.
citizens.commands.npc.mount.failed=Couldn''t mount [[{0}]].