mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-24 18:18:58 +01:00
Add /npc chunkload
This commit is contained in:
parent
c24ce1e1ed
commit
3d85ad4ea8
@ -302,6 +302,21 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "chunkload",
|
||||
desc = "Toggle the NPC forcing chunks to stay loaded",
|
||||
modifiers = { "chunkload", "cload" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
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);
|
||||
Messaging.sendTr(sender, enabled ? Messages.CHUNKLOAD_SET : Messages.CHUNKLOAD_UNSET, npc.getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "collidable",
|
||||
|
@ -74,7 +74,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
NPCDespawnEvent event = new NPCDespawnEvent(this, reason);
|
||||
if (reason == DespawnReason.CHUNK_UNLOAD) {
|
||||
event.setCancelled(Setting.KEEP_CHUNKS_LOADED.asBoolean());
|
||||
event.setCancelled(data().get(NPC.KEEP_CHUNK_LOADED_METADATA, Setting.KEEP_CHUNKS_LOADED.asBoolean()));
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled() && reason != DespawnReason.DEATH) {
|
||||
|
@ -36,6 +36,8 @@ public class Messages {
|
||||
public static final String CHAT_TRIGGER_MESSAGE_ADDED = "citizens.editors.waypoints.triggers.chat.message-added";
|
||||
public static final String CHAT_TRIGGER_PROMPT = "citizens.editors.waypoints.triggers.chat.prompt";
|
||||
public static final String CHAT_TRIGGER_RADIUS_SET = "citizens.editors.waypoints.triggers.chat.radius-set";
|
||||
public static final String CHUNKLOAD_SET = "citizens.commands.npc.chunkload.set";
|
||||
public static final String CHUNKLOAD_UNSET = "citizens.commands.npc.chunkload.unset";
|
||||
public static final String CITIZENS_IMPLEMENTATION_DISABLED = "citizens.changed-implementation";
|
||||
public static final String CITIZENS_INCOMPATIBLE = "citizens.notifications.incompatible-version";
|
||||
public static final String CITIZENS_INVALID_COMMAND_CLASS = "citizens.commands.invalid.class";
|
||||
|
@ -41,6 +41,8 @@ citizens.commands.npc.cat.sitting-stop=[[{0}]] stopped sitting.
|
||||
citizens.commands.npc.cat.lying-start=[[{0}]] started lying down.
|
||||
citizens.commands.npc.cat.lying-stop=[[{0}]] stopped lying down.
|
||||
citizens.commands.npc.cat.type-set=Type set to [[{0}]].
|
||||
citizens.commands.npc.chunkload.set=[[{0}]] will now force chunks to be loaded.
|
||||
citizens.commands.npc.chunkload.unset=[[{0}]] will no longer force chunks to be loaded.
|
||||
citizens.commands.npc.collidable.set=[[{0}]] will now collide with entities.
|
||||
citizens.commands.npc.collidable.unset=[[{0}]] will no longer collide with entities.
|
||||
citizens.commands.npc.command.none-added=No commands have been added.
|
||||
|
Loading…
Reference in New Issue
Block a user