mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-27 09:42:37 +01:00
Add stuck action setting
This commit is contained in:
parent
19b917e905
commit
7db27a3eee
@ -241,6 +241,9 @@ public class Settings {
|
||||
STORAGE_FILE("storage.file", "saves.yml"),
|
||||
STORAGE_TYPE("Although technically Citizens can use NBT storage, it is not well tested and YAML is recommended",
|
||||
"storage.type", "yaml"),
|
||||
STUCK_ACTION(
|
||||
"The default action to perform when NPCs are unable to find a path or are stuck in the same block for too long. Supported options are: 'teleport to destination' or 'none'",
|
||||
"npc.pathfinding.default-stuck-action", "teleport to destination"),
|
||||
TABLIST_REMOVE_PACKET_DELAY("How long to wait before sending the tablist remove packet",
|
||||
"npc.tablist.remove-packet-delay", "1t"),
|
||||
TALK_CLOSE_TO_NPCS("Whether to talk to NPCs (and therefore bystanders) as well as players",
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.ai.TeleportStuckAction;
|
||||
import net.citizensnpcs.api.astar.pathfinder.ChunkBlockSource;
|
||||
import net.citizensnpcs.api.command.Command;
|
||||
@ -64,9 +65,10 @@ public class WaypointCommands {
|
||||
max = 1,
|
||||
permission = "citizens.waypoints.disableteleport")
|
||||
public void disableTeleporting(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
npc.data().setPersistent(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION,
|
||||
!npc.data().get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION, false));
|
||||
if (npc.data().get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION, false)) {
|
||||
npc.data().setPersistent(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION, !npc.data()
|
||||
.get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION, !Setting.STUCK_ACTION.asString().contains("teleport")));
|
||||
if (npc.data().get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION,
|
||||
!Setting.STUCK_ACTION.asString().contains("teleport"))) {
|
||||
npc.getNavigator().getDefaultParameters().stuckAction(null);
|
||||
Messaging.sendTr(sender, Messages.WAYPOINT_TELEPORTING_DISABLED, npc.getName());
|
||||
} else {
|
||||
|
@ -67,7 +67,8 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
|
||||
public CitizensNavigator(NPC npc) {
|
||||
this.npc = npc;
|
||||
if (npc.data().get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION, false)) {
|
||||
if (npc.data().get(NPC.Metadata.DISABLE_DEFAULT_STUCK_ACTION,
|
||||
!Setting.STUCK_ACTION.asString().contains("teleport"))) {
|
||||
defaultParams.stuckAction(null);
|
||||
}
|
||||
defaultParams.examiner(new SwimmingExaminer(npc));
|
||||
|
Loading…
Reference in New Issue
Block a user