diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index ac7af0053..3d46273be 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -2300,7 +2300,7 @@ public class NPCCommands { output += " " + Messaging.tr(Messages.PATHFINDING_OPTIONS_USE_NEW_FINDER, npc.getName(), useNewFinder); } if (fallingDistance != null) { - npc.data().set(NPC.Metadata.PATHFINDER_FALL_DISTANCE, fallingDistance); + npc.getNavigator().getDefaultParameters().fallDistance(fallingDistance); output += " " + Messaging.tr(Messages.PATHFINDING_OPTIONS_FALLING_DISTANCE_SET, npc.getName(), fallingDistance); } 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 042ecdb32..d54edbb01 100644 --- a/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java +++ b/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java @@ -60,7 +60,8 @@ public class CitizensNavigator implements Navigator, Runnable { .stationaryTicks(Setting.DEFAULT_STATIONARY_DURATION.asTicks()).stuckAction(TeleportStuckAction.INSTANCE) .examiner(new MinecraftBlockExaminer()).useNewPathfinder(Setting.USE_NEW_PATHFINDER.asBoolean()) .straightLineTargetingDistance(Setting.DEFAULT_STRAIGHT_LINE_TARGETING_DISTANCE.asFloat()) - .destinationTeleportMargin(Setting.DEFAULT_DESTINATION_TELEPORT_MARGIN.asDouble()); + .destinationTeleportMargin(Setting.DEFAULT_DESTINATION_TELEPORT_MARGIN.asDouble()) + .fallDistance(Setting.PATHFINDER_FALL_DISTANCE.asInt()); private PathStrategy executing; private int lastX, lastY, lastZ; private NavigatorParameters localParams = defaultParams; @@ -174,6 +175,9 @@ public class CitizensNavigator implements Navigator, Runnable { if (root.keyExists("updatepathrate")) { defaultParams.updatePathRate(root.getInt("updatepathrate")); } + if (root.keyExists("falldistance")) { + defaultParams.fallDistance(root.getInt("falldistance")); + } defaultParams.speedModifier((float) root.getDouble("speedmodifier", 1F)); defaultParams.avoidWater(root.getBoolean("avoidwater")); if (!root.getBoolean("usedefaultstuckaction") && defaultParams.stuckAction() == TeleportStuckAction.INSTANCE) { @@ -268,6 +272,11 @@ public class CitizensNavigator implements Navigator, Runnable { } else { root.removeKey("updatepathrate"); } + if (defaultParams.fallDistance() != Setting.PATHFINDER_FALL_DISTANCE.asTicks()) { + root.setInt("falldistance", defaultParams.fallDistance()); + } else { + root.removeKey("falldistance"); + } if (defaultParams.useNewPathfinder() != Setting.USE_NEW_PATHFINDER.asBoolean()) { root.setBoolean("usenewpathfinder", defaultParams.useNewPathfinder()); } else { @@ -334,8 +343,7 @@ public class CitizensNavigator implements Navigator, Runnable { stopNavigating(CancelReason.REPLACE); } localParams = defaultParams.clone(); - int fallDistance = npc.data().get(NPC.Metadata.PATHFINDER_FALL_DISTANCE, - Setting.PATHFINDER_FALL_DISTANCE.asInt()); + int fallDistance = localParams.fallDistance(); if (fallDistance != -1) { localParams.examiner(new FallingExaminer(fallDistance)); } diff --git a/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java b/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java index 7b2b280dc..1f48f9e0f 100644 --- a/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java @@ -7,6 +7,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -686,8 +687,8 @@ public class ShopTrait extends Trait { if (description.isEmpty()) { meta.setLore(Lists.newArrayList()); } else { - meta.setLore(Lists - .newArrayList(Splitter.on('\n').split(Messaging.parseComponents(description)))); + meta.setLore(Splitter.on("
").splitToStream(description) + .map(s -> Messaging.parseComponents(s)).collect(Collectors.toList())); } modified.display.setItemMeta(meta); }); diff --git a/main/src/main/java/net/citizensnpcs/util/NMS.java b/main/src/main/java/net/citizensnpcs/util/NMS.java index 38c4b8de3..6fc7382b8 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMS.java +++ b/main/src/main/java/net/citizensnpcs/util/NMS.java @@ -48,7 +48,6 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.ProfileLookupCallback; -import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.ai.NavigatorParameters; import net.citizensnpcs.api.astar.pathfinder.SwimmingExaminer; @@ -256,10 +255,8 @@ public class NMS { } public static int getFallDistance(NPC npc, int def) { - return npc == null ? def - : npc.data().get(NPC.Metadata.PATHFINDER_FALL_DISTANCE, - Setting.PATHFINDER_FALL_DISTANCE.asInt() != -1 ? Setting.PATHFINDER_FALL_DISTANCE.asInt() - : def); + return npc == null || npc.getNavigator().getLocalParameters().fallDistance() == -1 ? def + : npc.getNavigator().getLocalParameters().fallDistance(); } public static Field getField(Class clazz, String field) {