diff --git a/assets/button-community.png b/assets/button-community.png
new file mode 100644
index 0000000..6ca03cb
Binary files /dev/null and b/assets/button-community.png differ
diff --git a/assets/button-discord.png b/assets/button-discord.png
new file mode 100644
index 0000000..b1745ba
Binary files /dev/null and b/assets/button-discord.png differ
diff --git a/assets/button-source.png b/assets/button-source.png
new file mode 100644
index 0000000..68fbb80
Binary files /dev/null and b/assets/button-source.png differ
diff --git a/assets/button-wiki.png b/assets/button-wiki.png
new file mode 100644
index 0000000..29ed8cc
Binary files /dev/null and b/assets/button-wiki.png differ
diff --git a/pom.xml b/pom.xml
index 0023df8..1814202 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.NVus
NVus_Prison
- 1.1.6
+ 1.1.8
jar
NVus_PrisonSetup
diff --git a/src/main/java/me/nvus/nvus_prison_setup/Kit/KitManager.java b/src/main/java/me/nvus/nvus_prison_setup/Kit/KitManager.java
index 745487b..92e654b 100644
--- a/src/main/java/me/nvus/nvus_prison_setup/Kit/KitManager.java
+++ b/src/main/java/me/nvus/nvus_prison_setup/Kit/KitManager.java
@@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -65,44 +66,125 @@ public class KitManager {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
-
- // Set the display name if available
+ // Configure item meta (name, lore, enchantments)...
if (itemSpec.containsKey("name")) {
- String name = ChatColor.translateAlternateColorCodes('&', (String) itemSpec.get("name"));
- meta.setDisplayName(name);
+ meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', (String) itemSpec.get("name")));
}
-
- // Set lore if available
if (itemSpec.containsKey("lore")) {
List lore = new ArrayList<>();
- for (String line : (List) itemSpec.get("lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', line));
- }
+ ((List) itemSpec.get("lore")).forEach(line -> lore.add(ChatColor.translateAlternateColorCodes('&', line)));
meta.setLore(lore);
}
-
- // Set enchantments if available
if (itemSpec.containsKey("enchantments")) {
- Map enchantments = (Map) itemSpec.get("enchantments");
- for (Map.Entry enchantmentEntry : enchantments.entrySet()) {
- Enchantment enchantment = Enchantment.getByName(enchantmentEntry.getKey());
- if (enchantment != null) {
- meta.addEnchant(enchantment, enchantmentEntry.getValue(), true);
- }
- }
+ ((Map) itemSpec.get("enchantments")).forEach((enchant, level) -> meta.addEnchant(Enchantment.getByName(enchant.toUpperCase()), level, true));
}
-
item.setItemMeta(meta);
- // Set item in specified quickbar slot, if available
if (itemSpec.containsKey("slot")) {
- player.getInventory().setItem((Integer) itemSpec.get("slot"), item);
+ int slot = (Integer) itemSpec.get("slot");
+ ItemStack existingItem = player.getInventory().getItem(slot);
+
+ if (existingItem != null && existingItem.getType() != Material.AIR && !isPrisonerKitItem(existingItem)) {
+ moveItemToAvailableSlot(player, existingItem);
+ }
+
+ player.getInventory().setItem(slot, item);
} else {
player.getInventory().addItem(item);
}
}
}
+ private void moveItemToAvailableSlot(Player player, ItemStack item) {
+ // Attempt to move the existing item to an available slot
+ HashMap overflow = player.getInventory().addItem(item);
+ if (!overflow.isEmpty()) {
+ // Check Ender Chest
+ if (player.getEnderChest().firstEmpty() != -1) {
+ player.getEnderChest().addItem(overflow.get(0));
+ player.sendMessage(ChatColor.YELLOW + "Your inventory was full, so an item was moved to your Ender Chest.");
+ } else {
+ // Drop the item at the player's location
+ player.getWorld().dropItemNaturally(player.getLocation(), overflow.get(0));
+ player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest were full, so an item was dropped on the ground.");
+ }
+ }
+ }
+
+
+
+
+
+
+// public void givePrisonerKit(Player player) {
+// if (!configManager.getBoolean("config.yml", "PrisonerKit", false)) {
+// return;
+// }
+//
+// FileConfiguration config = configManager.getConfig("config.yml");
+// List