From 14cd243d6a1e97f8d87d33fa009d8e66fd2b9363 Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 9 Sep 2016 01:32:10 +0800 Subject: [PATCH] Don't add waypoint markers to the main registry --- .../net/citizensnpcs/npc/ai/CitizensNavigator.java | 14 ++++++++++++++ .../trait/waypoint/WaypointMarkers.java | 11 ++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java b/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java index d3ed35f87..969c25f2b 100644 --- a/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java +++ b/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java @@ -125,6 +125,9 @@ public class CitizensNavigator implements Navigator, Runnable { if (root.keyExists("distancemargin")) { defaultParams.distanceMargin(root.getDouble("distancemargin")); } + if (root.keyExists("updatepathrate")) { + defaultParams.updatePathRate(root.getInt("updatepathrate")); + } defaultParams.speedModifier((float) root.getDouble("speedmodifier", 1F)); defaultParams.avoidWater(root.getBoolean("avoidwater")); if (!root.getBoolean("usedefaultstuckaction") && defaultParams.stuckAction() == TeleportStuckAction.INSTANCE) { @@ -178,12 +181,23 @@ public class CitizensNavigator implements Navigator, Runnable { public void save(DataKey root) { if (defaultParams.range() != Setting.DEFAULT_PATHFINDING_RANGE.asFloat()) { root.setDouble("pathfindingrange", defaultParams.range()); + } else { + root.removeKey("pathfindingrange"); } if (defaultParams.stationaryTicks() != Setting.DEFAULT_STATIONARY_TICKS.asInt()) { root.setInt("stationaryticks", defaultParams.stationaryTicks()); + } else { + root.removeKey("stationaryticks"); } if (defaultParams.distanceMargin() != Setting.DEFAULT_DISTANCE_MARGIN.asDouble()) { root.setDouble("distancemargin", defaultParams.distanceMargin()); + } else { + root.removeKey("distancemargin"); + } + if (defaultParams.updatePathRate() != Setting.DEFAULT_PATHFINDER_UPDATE_PATH_RATE.asInt()) { + root.setInt("updatepathrate", defaultParams.updatePathRate()); + } else { + root.removeKey("updatepathrate"); } root.setDouble("speedmodifier", defaultParams.speedModifier()); root.setBoolean("avoidwater", defaultParams.avoidWater()); diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/WaypointMarkers.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/WaypointMarkers.java index eb7aba5a8..b23bc8417 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/WaypointMarkers.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/WaypointMarkers.java @@ -2,10 +2,6 @@ package net.citizensnpcs.trait.waypoint; import java.util.Map; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.util.NMS; - import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; @@ -13,6 +9,10 @@ import org.bukkit.entity.EntityType; import com.google.common.collect.Maps; +import net.citizensnpcs.api.CitizensAPI; +import net.citizensnpcs.api.npc.MemoryNPCDataStore; +import net.citizensnpcs.api.npc.NPC; + public class WaypointMarkers { private final Map waypointMarkers = Maps.newHashMap(); private final World world; @@ -44,7 +44,8 @@ public class WaypointMarkers { } public Entity spawnMarker(World world, Location at) { - NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.ENDER_SIGNAL, ""); + NPC npc = CitizensAPI.createAnonymousNPCRegistry(new MemoryNPCDataStore()).createNPC(EntityType.ENDER_SIGNAL, + ""); npc.spawn(at); return npc.getEntity(); }