diff --git a/TestServer/plugins/TF_PrisonEscape/languages/english.yml b/TestServer/plugins/TF_PrisonEscape/languages/english.yml index b780fe8b..b81bc52a 100644 --- a/TestServer/plugins/TF_PrisonEscape/languages/english.yml +++ b/TestServer/plugins/TF_PrisonEscape/languages/english.yml @@ -1,3 +1,8 @@ +Kits: + Prisoner: + ArmorName: "&6Prisoner uniform" + Guard: + ArmorName: "&9Guard uniform" BossBar: DayTitle: "&eDay {DAY}" NightTitle: "&9Night {DAY}" diff --git a/TestServer/server.properties b/TestServer/server.properties index 7c822a3a..264e857b 100644 --- a/TestServer/server.properties +++ b/TestServer/server.properties @@ -1,5 +1,5 @@ #Minecraft server properties -#Wed May 22 23:30:13 WEST 2024 +#Mon Jun 17 15:38:43 WEST 2024 enable-jmx-monitoring=false rcon.port=25575 level-seed= diff --git a/src/main/java/net/tiagofar78/prisonescape/kits/Kit.java b/src/main/java/net/tiagofar78/prisonescape/kits/Kit.java index 0c38477b..8c2c4546 100644 --- a/src/main/java/net/tiagofar78/prisonescape/kits/Kit.java +++ b/src/main/java/net/tiagofar78/prisonescape/kits/Kit.java @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; import java.util.Hashtable; import java.util.Map.Entry; @@ -16,6 +17,10 @@ public abstract class Kit { protected abstract Hashtable getContents(); + protected Hashtable getVisualContents(MessageLanguageManager messages) { + return new Hashtable(); + } + public void give(String playerName) { Player bukkitPlayer = Bukkit.getPlayer(playerName); if (bukkitPlayer == null || !bukkitPlayer.isOnline()) { @@ -30,6 +35,10 @@ public void give(String playerName) { for (Entry entry : getContents().entrySet()) { inv.setItem(entry.getKey(), entry.getValue().toItemStack(messages)); } + + for (Entry entry : getVisualContents(messages).entrySet()) { + inv.setItem(entry.getKey(), entry.getValue()); + } } public void update(String playerName) { diff --git a/src/main/java/net/tiagofar78/prisonescape/kits/PoliceKit.java b/src/main/java/net/tiagofar78/prisonescape/kits/PoliceKit.java index cfb5e45d..1d91eecd 100644 --- a/src/main/java/net/tiagofar78/prisonescape/kits/PoliceKit.java +++ b/src/main/java/net/tiagofar78/prisonescape/kits/PoliceKit.java @@ -10,8 +10,12 @@ import net.tiagofar78.prisonescape.managers.MessageLanguageManager; import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; import java.util.Hashtable; @@ -26,6 +30,10 @@ public class PoliceKit extends Kit { private static final int MISSIONS_ITEM_INDEX = 7; private static final int SHOP_ITEM_INDEX = 8; + private static final int CHESTPLATE_INDEX = 38; + private static final int LEGGINGS_INDEX = 37; + private static final int BOOTS_INDEX = 36; + @Override protected Hashtable getContents() { Hashtable items = new Hashtable<>(); @@ -44,6 +52,29 @@ protected Hashtable getContents() { return items; } + @Override + public Hashtable getVisualContents(MessageLanguageManager messages) { + Hashtable items = new Hashtable<>(); + + String uniformName = messages.getPrisonerUniformName(); + + items.put(CHESTPLATE_INDEX, createColoredArmor(Material.LEATHER_CHESTPLATE, uniformName)); + items.put(LEGGINGS_INDEX, createColoredArmor(Material.LEATHER_LEGGINGS, uniformName)); + items.put(BOOTS_INDEX, createColoredArmor(Material.LEATHER_BOOTS, uniformName)); + + return items; + } + + private ItemStack createColoredArmor(Material type, String name) { + ItemStack item = new ItemStack(type); + LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); + meta.setColor(Color.BLUE); + meta.setDisplayName(name); + item.setItemMeta(meta); + + return item; + } + @Override public void update(String playerName) { Player bukkitPlayer = Bukkit.getPlayer(playerName); diff --git a/src/main/java/net/tiagofar78/prisonescape/kits/PrisonerKit.java b/src/main/java/net/tiagofar78/prisonescape/kits/PrisonerKit.java index 8ffac508..f6072499 100644 --- a/src/main/java/net/tiagofar78/prisonescape/kits/PrisonerKit.java +++ b/src/main/java/net/tiagofar78/prisonescape/kits/PrisonerKit.java @@ -3,6 +3,12 @@ import net.tiagofar78.prisonescape.items.CraftingMenuItem; import net.tiagofar78.prisonescape.items.GlassItem; import net.tiagofar78.prisonescape.items.Item; +import net.tiagofar78.prisonescape.managers.MessageLanguageManager; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; import java.util.Hashtable; @@ -12,6 +18,10 @@ public class PrisonerKit extends Kit { private static final int LAST_GLASS_ITEM_INDEX = 35; private static final int CRAFTING_MENU_INDEX = 8; + private static final int CHESTPLATE_INDEX = 38; + private static final int LEGGINGS_INDEX = 37; + private static final int BOOTS_INDEX = 36; + @Override public Hashtable getContents() { Hashtable items = new Hashtable<>(); @@ -25,4 +35,27 @@ public Hashtable getContents() { return items; } + + @Override + public Hashtable getVisualContents(MessageLanguageManager messages) { + Hashtable items = new Hashtable<>(); + + String uniformName = messages.getPrisonerUniformName(); + + items.put(CHESTPLATE_INDEX, createColoredArmor(Material.LEATHER_CHESTPLATE, uniformName)); + items.put(LEGGINGS_INDEX, createColoredArmor(Material.LEATHER_LEGGINGS, uniformName)); + items.put(BOOTS_INDEX, createColoredArmor(Material.LEATHER_BOOTS, uniformName)); + + return items; + } + + private ItemStack createColoredArmor(Material type, String name) { + ItemStack item = new ItemStack(type); + LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); + meta.setColor(Color.ORANGE); + meta.setDisplayName(name); + item.setItemMeta(meta); + + return item; + } } diff --git a/src/main/java/net/tiagofar78/prisonescape/managers/MessageLanguageManager.java b/src/main/java/net/tiagofar78/prisonescape/managers/MessageLanguageManager.java index faf1280f..b1ee64cf 100644 --- a/src/main/java/net/tiagofar78/prisonescape/managers/MessageLanguageManager.java +++ b/src/main/java/net/tiagofar78/prisonescape/managers/MessageLanguageManager.java @@ -57,6 +57,13 @@ private static String getPlayerLanguage(String playerName) { return ConfigManager.getInstance().getDefaultLanguage(); } +// ####################################### +// # Kit # +// ####################################### + + private String _prisonerUniformName; + private String _guardUniformName; + // ####################################### // # BossBar # // ####################################### @@ -219,6 +226,10 @@ private static String getPlayerLanguage(String playerName) { private MessageLanguageManager(String language) { YamlConfiguration messages = PEResources.getYamlLanguage(language); + String kitsPath = "Kits."; + _prisonerUniformName = createMessage(messages.getString(kitsPath + "Prisoner.ArmorName")); + _guardUniformName = createMessage(messages.getString(kitsPath + "Guard.ArmorName")); + String bossBarPath = "BossBar."; _bossBarDayTitle = createMessage(messages.getString(bossBarPath + "DayTitle")); _bossBarNightTitle = createMessage(messages.getString(bossBarPath + "NightTitle")); @@ -389,6 +400,18 @@ private List createMessage(List rawMessage) { return message; } +// ####################################### +// # Kit # +// ####################################### + + public String getPrisonerUniformName() { + return _prisonerUniformName; + } + + public String getGuardUniformName() { + return _guardUniformName; + } + // ####################################### // # BossBar # // ####################################### diff --git a/src/main/resources/languages/english.yml b/src/main/resources/languages/english.yml index b780fe8b..b81bc52a 100644 --- a/src/main/resources/languages/english.yml +++ b/src/main/resources/languages/english.yml @@ -1,3 +1,8 @@ +Kits: + Prisoner: + ArmorName: "&6Prisoner uniform" + Guard: + ArmorName: "&9Guard uniform" BossBar: DayTitle: "&eDay {DAY}" NightTitle: "&9Night {DAY}"