Fix NPEs in bB(), add more .* permissions

This commit is contained in:
fullwall 2013-02-23 12:27:00 +08:00
parent 8023034a8c
commit 6e0fe92c51
34 changed files with 55 additions and 38 deletions

View File

@ -36,7 +36,7 @@ public class HelpCommands {
modifiers = { "help" },
min = 1,
max = 2,
permission = "citizens.help")
permission = "citizens.citizens.help")
@Requirements
public void citizensHelp(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
int page = 1;

View File

@ -230,8 +230,9 @@ public class NPCCommands {
+ npc.getBukkitEntity().getType().toString().toLowerCase()))
|| !sender.hasPermission("citizens.npc.controllable"))
throw new NoPermissionsException();
if (!npc.hasTrait(Controllable.class))
if (!npc.hasTrait(Controllable.class)) {
npc.addTrait(new Controllable(false));
}
Controllable trait = npc.getTrait(Controllable.class);
boolean enabled = trait.toggle();
String key = enabled ? Messages.CONTROLLABLE_SET : Messages.CONTROLLABLE_REMOVED;

View File

@ -24,7 +24,7 @@ import com.google.common.collect.Lists;
@Requirements(selected = true, ownership = true)
public class TraitCommands {
@Command(aliases = { "trait", "tr" }, usage = "add [trait name]...", desc = "Adds traits to the NPC", modifiers = {
"add", "a" }, min = 1, permission = "npc.trait")
"add", "a" }, min = 1, permission = "citizens.npc.trait")
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
List<String> added = Lists.newArrayList();
List<String> failed = Lists.newArrayList();
@ -59,7 +59,7 @@ public class TraitCommands {
modifiers = { "*" },
min = 1,
flags = "*",
permission = "npc.trait-configure")
permission = "citizens.npc.trait-configure")
public void configure(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String traitName = args.getString(0);
if (!sender.hasPermission("citizens.npc.trait-configure." + traitName))
@ -81,7 +81,7 @@ public class TraitCommands {
desc = "Removes traits on the NPC",
modifiers = { "remove", "rem", "r" },
min = 1,
permission = "npc.trait")
permission = "citizens.npc.trait")
public void remove(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
List<String> removed = Lists.newArrayList();
List<String> failed = Lists.newArrayList();
@ -116,7 +116,7 @@ public class TraitCommands {
desc = "Toggles traits on the NPC",
modifiers = { "*" },
min = 1,
permission = "npc.trait")
permission = "citizens.npc.trait")
public void toggle(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
List<String> added = Lists.newArrayList();
List<String> removed = Lists.newArrayList();

View File

@ -59,7 +59,7 @@ public class BatController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -59,7 +59,7 @@ public class BlazeController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -59,7 +59,7 @@ public class CaveSpiderController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -59,7 +59,7 @@ public class ChickenController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -59,7 +59,7 @@ public class CowController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -66,7 +66,7 @@ public class CreeperController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -58,7 +58,7 @@ public class EnderDragonController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -59,7 +59,7 @@ public class EndermanController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -52,7 +52,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -44,7 +44,7 @@ public class GhastController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class GiantController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -44,7 +44,7 @@ public class IronGolemController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -46,7 +46,7 @@ public class MagmaCubeController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -46,7 +46,7 @@ public class MushroomCowController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class OcelotController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -52,7 +52,7 @@ public class PigController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -46,7 +46,7 @@ public class PigZombieController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SheepController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SilverfishController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SkeletonController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -47,7 +47,7 @@ public class SlimeController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SnowmanController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SpiderController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class SquidController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -53,7 +53,7 @@ public class VillagerController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class WitchController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class WitherController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class WolfController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -45,7 +45,7 @@ public class ZombieController extends MobEntityController {
@Override
public float bB() {
return super.bB() * npc.getNavigator().getLocalParameters().speed();
return npc == null ? super.bB() : super.bB() * npc.getNavigator().getLocalParameters().speed();
}
@Override

View File

@ -161,9 +161,9 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
@Override
public void save(DataKey key) {
if (explicitType == null)
if (explicitType == null) {
key.removeKey("explicittype");
else
} else
key.setString("explicittype", explicitType.name());
}

View File

@ -35,11 +35,27 @@ permissions:
citizens.admin: true
citizens.admin.avoid-limits: true
citizens.admin.remove.all: true
citizens.help: true
citizens.help.*:
children:
citizens.npc.help: true
citizens.trait.help: true
citizens.help: true
citizens.waypoints.help: true
citizens.templates.help: true
citizens.citizens.help: true
citizens.script.help: true
citizens.script.*:
children:
citizens.script.compile: true
citizens.script.help: true
citizens.templates.*:
children:
citizens.templates.apply: true
citizens.templates.create: true
citizens.waypoints.*:
children:
citizens.waypoints.disableteleport: true
citizens.waypoints.provider: true
citizens.npc.*:
children:
citizens.npc.age: true