Fixed issue #931 related to waypoints lore being inverted in the UI. Now you can use the placeholder {lore} in the UI config to display the waypoint specific lore.

This commit is contained in:
Ka0rX 2023-09-05 19:32:08 +01:00
parent 7b45b54793
commit 55953d41ce
2 changed files with 18 additions and 16 deletions

View File

@ -1,18 +1,17 @@
package net.Indyuce.mmocore.gui;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.api.player.PlayerActivity;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.EditableInventory;
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.waypoint.WaypointPath;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
@ -142,16 +141,14 @@ public class WaypointViewer extends EditableInventory {
// If a player can teleport to another waypoint given his location
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n);
ItemMeta meta = disp.getItemMeta();
// Add waypoint lore if not empty
if (!waypoint.getLore().isEmpty()) {
List<String> lore = meta.getLore();
Placeholders placeholders = new Placeholders();
for (String str : waypoint.getLore())
lore.add(0, ChatColor.GRAY + placeholders.apply(inv.getPlayer(), str));
meta.setLore(lore);
}
List<String> lore = new ArrayList<>();
meta.getLore().forEach(string -> {
if (string.contains("{lore}"))
lore.addAll(waypoint.getLore());
else
lore.add(string);
});
meta.setLore(lore);
PersistentDataContainer container = meta.getPersistentDataContainer();
container.set(new NamespacedKey(MMOCore.plugin, "waypointId"), PersistentDataType.STRING, waypoint.getId());
disp.setItemMeta(meta);
@ -164,6 +161,7 @@ public class WaypointViewer extends EditableInventory {
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
holders.register("name", waypoint.getName());
if (!onlyName) {
holders.register("current_cost", inv.paths.get(waypoint).getCost());
holders.register("normal_cost", decimal.format(inv.paths.containsKey(waypoint) ? inv.paths.get(waypoint).getCost() : Double.POSITIVE_INFINITY));

View File

@ -33,6 +33,7 @@ items:
not-ready: ENDER_PEARL
lore:
- '{lore}'
- '&7You cannot teleport as the two waypoints are not linked.'
@ -42,6 +43,7 @@ items:
item: ENDER_PEARL
lore:
- '{lore}'
- '&7You cannot teleport as you are not standing on a waypoint.'
@ -50,6 +52,7 @@ items:
item: ENDER_PEARL
lore:
- '{lore}'
- '&7The waypoint you are standing at.'
# When you don't have enough stellium
@ -58,6 +61,7 @@ items:
item: ENDER_PEARL
lore:
- '{lore}'
- '&7You cannot teleport as you do not have enough Stellium.'
- '&7Teleporting costs &b{normal_cost}&7/&b{dynamic_cost} &7Stellium.'
@ -65,8 +69,8 @@ items:
display:
name: '&a{name}'
item: ENDER_EYE
lore:
- '{lore}'
- '&7You can teleport to this waypoint.'
- '&7Intermediary waypoints: {intermediary_waypoints}'
- '&7Click to teleport for &b{current_cost} &7Stellium.'