Make /npc chunkload persistent by default

This commit is contained in:
fullwall 2021-10-10 23:19:43 +08:00
parent fd3833deba
commit 780899cbad

View File

@ -307,16 +307,21 @@ public class NPCCommands {
@Command(
aliases = { "npc" },
usage = "chunkload",
usage = "chunkload (-t(emporary))",
desc = "Toggle the NPC forcing chunks to stay loaded",
modifiers = { "chunkload", "cload" },
min = 1,
max = 1,
flags = "t",
permission = "citizens.npc.chunkload")
@Requirements(selected = true, ownership = true)
public void chunkload(CommandContext args, CommandSender sender, NPC npc) {
boolean enabled = !npc.data().get(NPC.KEEP_CHUNK_LOADED_METADATA, Setting.KEEP_CHUNKS_LOADED.asBoolean());
npc.data().set(NPC.KEEP_CHUNK_LOADED_METADATA, enabled);
if (args.hasFlag('t')) {
npc.data().set(NPC.KEEP_CHUNK_LOADED_METADATA, enabled);
} else {
npc.data().setPersistent(NPC.KEEP_CHUNK_LOADED_METADATA, enabled);
}
Messaging.sendTr(sender, enabled ? Messages.CHUNKLOAD_SET : Messages.CHUNKLOAD_UNSET, npc.getName());
}