Null check command charged

This commit is contained in:
fullwall 2022-07-25 00:23:44 +08:00
parent d5db707d58
commit ac92bafa71
6 changed files with 8 additions and 5 deletions

View File

@ -530,7 +530,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
}
private class CitizensLoadTask implements Runnable {
@Override
public void run() {
saves.loadInto(npcRegistry);

View File

@ -2082,6 +2082,8 @@ public class NPCCommands {
};
NPCRegistry registry = args.hasValueFlag("registry") ? CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"))
: CitizensAPI.getNPCRegistry();
if (registry == null)
throw new CommandException(Messages.UNKNOWN_NPC_REGISTRY, args.getFlag("registry"));
if (args.argsLength() <= 1) {
if (!(sender instanceof Player))
throw new ServerCommandException();

View File

@ -243,7 +243,7 @@ public class CommandTrait extends Trait {
}
}
runCommand(player, command);
if (executionMode == ExecutionMode.SEQUENTIAL || charged == false) {
if (executionMode == ExecutionMode.SEQUENTIAL || (charged != null && charged == false)) {
break;
}
}

View File

@ -222,7 +222,7 @@ public class ShopTrait extends Trait {
@Menu(title = "NPC Shop Item Editor", type = InventoryType.CHEST, dimensions = { 5, 9 })
@MenuSlot(slot = { 0, 4 }, material = Material.DISPENSER, amount = 1, title = "Place display item below")
public static class NPCShopItemEditor extends InventoryMenuPage {
private final Consumer<NPCShopItem> consumer;
private final Consumer<NPCShopItem> callback;
private MenuContext ctx;
private final NPCShopItem modified;
private NPCShopItem original;
@ -230,7 +230,7 @@ public class ShopTrait extends Trait {
public NPCShopItemEditor(NPCShopItem item, Consumer<NPCShopItem> consumer) {
this.original = item;
this.modified = original.clone();
this.consumer = consumer;
this.callback = consumer;
}
@Override
@ -252,7 +252,7 @@ public class ShopTrait extends Trait {
if (original != null && original.display == null) {
original = null;
}
consumer.accept(original);
callback.accept(original);
}
@MenuSlot(slot = { 1, 5 }, material = Material.BOOK, amount = 1, title = "Set description")

View File

@ -375,6 +375,7 @@ public class Messages {
public static final String UNDO_UNSUCCESSFUL = "citizens.commands.npc.undo.unsuccessful";
public static final String UNKNOWN_COMMAND = "citizens.commands.unknown-command";
public static final String UNKNOWN_MATERIAL = "citizens.commands.npc.item.unknown-material";
public static final String UNKNOWN_NPC_REGISTRY = "citizens.commands.errors.unknown-registry";
public static final String UNKNOWN_PLAYER_ANIMATION = "citizens.commands.npc.panimate.unknown-animation";
public static final String USING_MINECRAFT_AI = "citizens.commands.npc.ai.started";
public static final String VILLAGER_LEVEL_SET = "citizens.commands.npc.villager.level-set";

View File

@ -2,6 +2,7 @@ citizens.changed-implementation=Citizens implementation changed, disabling plugi
citizens.commands.citizens.save.help=Use the -a flag to save async (off the main server thread).
citizens.commands.console-error=Please report this error: [See console]
citizens.commands.errors.missing-world=World not found.
citizens.commands.errors.unknown-registry=Unknown NPC registry [[{0}]].
citizens.commands.help.command-missing=Command /{0} not found.
citizens.commands.help.header=Help
citizens.commands.id-not-found=Couldn''t find any NPC with ID [[{0}]].