menu supports placeholder

This commit is contained in:
SuperRonanCraft 2023-04-02 10:48:02 -04:00
parent 9c56ec17ea
commit a94b7d3ce8
2 changed files with 8 additions and 7 deletions

View File

@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTPAddons</artifactId> <artifactId>BetterRTPAddons</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.8.4</version> <version>1.8.5</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
@ -109,7 +109,7 @@
<dependency> <dependency>
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<version>3.6.0</version> <version>3.6.3</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- ProtocolLib --> <!-- ProtocolLib -->

View File

@ -9,6 +9,7 @@ import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -34,7 +35,7 @@ public class RTPMenu_SelectWorld {
} }
int size = Math.floorDiv(actual_worlds.size(), 9) * 9; int size = Math.floorDiv(actual_worlds.size(), 9) * 9;
if (size < actual_worlds.size()) size += 9; if (size < actual_worlds.size()) size += 9;
Inventory inv = createInventory(color(Files.FILETYPE.CONFIG.getString(AddonRTPMenu.name + ".Title")), size); Inventory inv = createInventory(color(p, Files.FILETYPE.CONFIG.getString(AddonRTPMenu.name + ".Title")), size);
HashMap<Integer, World> world_slots = centerWorlds(new ArrayList<>(actual_worlds)); HashMap<Integer, World> world_slots = centerWorlds(new ArrayList<>(actual_worlds));
@ -45,9 +46,9 @@ public class RTPMenu_SelectWorld {
ItemStack item = new ItemStack(worldInfo.item, 1); ItemStack item = new ItemStack(worldInfo.item, 1);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName(color(worldInfo.name)); meta.setDisplayName(color(p, worldInfo.name));
List<String> lore = new ArrayList<>(worldInfo.lore); List<String> lore = new ArrayList<>(worldInfo.lore);
lore.forEach(s -> lore.set(lore.indexOf(s), color(s).replace("%world%", world.getValue().getName()))); lore.forEach(s -> lore.set(lore.indexOf(s), color(p, s).replace("%world%", world.getValue().getName())));
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);
inv.setItem(slot, item); inv.setItem(slot, item);
@ -117,8 +118,8 @@ public class RTPMenu_SelectWorld {
return 0; return 0;
} }
private static String color(String str) { private static String color(CommandSender sendi, String str) {
return ChatColor.translateAlternateColorCodes('&', str); return ChatColor.translateAlternateColorCodes('&', Message.placeholder(sendi, str));
} }
private static Inventory createInventory(String title, int size) { private static Inventory createInventory(String title, int size) {