diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 98ab659..e78132d 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.bin and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 37901ce..a6cd383 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index 143e81c..1832238 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.bin and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index 5bf3e4c..00b3746 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin index c3e402e..efee609 100644 Binary files a/.gradle/8.8/fileHashes/resourceHashesCache.bin and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index baf212c..921a713 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index d15ee3f..9746776 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/build/classes/java/main/CoswayUtil/BlockShop.class b/build/classes/java/main/CoswayUtil/BlockShop.class index daf8ccb..f8c91e1 100644 Binary files a/build/classes/java/main/CoswayUtil/BlockShop.class and b/build/classes/java/main/CoswayUtil/BlockShop.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$1.class index 371af4c..17690f8 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$1.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$1.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class index aee7c6b..332218b 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$1.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class index f38429d..e7877e6 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$2.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class index 30408e1..5fef7f8 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$3.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class index ed4b3e7..d713e4e 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield$4.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class index 3f4018d..474ba6f 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$AnchorShield.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil.class b/build/classes/java/main/CoswayUtil/CoswayUtil.class index a5dc176..e8d0716 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil.class and b/build/classes/java/main/CoswayUtil/CoswayUtil.class differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml index 9906b40..d1079ce 100644 --- a/build/resources/main/plugin.yml +++ b/build/resources/main/plugin.yml @@ -1,5 +1,5 @@ name: CoswayUtil -version: '1.11-RELEASE' +version: '1.12-RELEASE' main: CoswayUtil.CoswayUtil description: "utility plugin for Cosway servers, a yescraft network server" api-version: '1.21' diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BlockShop.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/BlockShop.class.uniqueId3 deleted file mode 100644 index 2691484..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/BlockShop.class.uniqueId3 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId8 similarity index 93% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId8 index 371af4c..17690f8 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId0 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId8 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 deleted file mode 100644 index aee7c6b..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId7 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId10 similarity index 93% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId10 index f38429d..e7877e6 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId2 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId10 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 index 30408e1..5fef7f8 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$3.class.uniqueId5 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId3 similarity index 92% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId3 index ed4b3e7..d713e4e 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId4 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId3 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 deleted file mode 100644 index 3f4018d..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId6 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 deleted file mode 100644 index a5dc176..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId1 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId9 new file mode 100644 index 0000000..00cc108 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId9 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 new file mode 100644 index 0000000..d11403e Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId7 new file mode 100644 index 0000000..446d49a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/LaunchStick.class.uniqueId7 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId2 new file mode 100644 index 0000000..b7b9dbf Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId11 b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId11 new file mode 100644 index 0000000..af0dcbb Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId11 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId6 new file mode 100644 index 0000000..7d55222 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId6 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId13 new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId13 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId1 new file mode 100644 index 0000000..1d9a4fa Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId4 new file mode 100644 index 0000000..ef78745 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId4 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 0d349f4..f6f07f5 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/CoswayUtil/BlockShop.java b/src/main/java/CoswayUtil/BlockShop.java index 7ccc2c6..7b707fc 100644 --- a/src/main/java/CoswayUtil/BlockShop.java +++ b/src/main/java/CoswayUtil/BlockShop.java @@ -128,15 +128,7 @@ public class BlockShop implements Listener { config = plugin.getConfig(); // Reassign the updated config } - // Helper method to add items to the shop - private void addItemToShop(Inventory shop, Material material, String displayName, double price) { - ItemStack item = new ItemStack(material); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(displayName); - meta.setLore(Collections.singletonList(ChatColor.GOLD + "Price: " + price + " currency")); - item.setItemMeta(meta); - shop.addItem(item); - } + // Handle item right-click to open the shop @EventHandler @@ -152,14 +144,21 @@ public class BlockShop implements Listener { } } - // Handle purchases from the shop @EventHandler public void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); InventoryView clickedInventory = event.getWhoClicked().getOpenInventory(); + Inventory topInventory = clickedInventory.getTopInventory(); // The shop inventory + Inventory clickedSlotInventory = event.getClickedInventory(); // Where the click happened + // Ensure the clicked inventory is the Block Shop (not player's inventory) if (clickedInventory.getTitle().equals(ChatColor.GREEN + "Block Shop")) { - event.setCancelled(true); // Prevent item from being moved + event.setCancelled(true); // Prevent item movement + + // Ignore clicks outside the shop inventory + if (clickedSlotInventory == null || !clickedSlotInventory.equals(topInventory)) { + return; + } ItemStack clickedItem = event.getCurrentItem(); if (clickedItem != null && clickedItem.getType() != Material.AIR) { @@ -170,25 +169,26 @@ public class BlockShop implements Listener { } // Create a new ItemStack with the default meta - ItemStack sold = new ItemStack(clickedItem.getType(), clickedItem.getAmount()); + ItemStack sold = clickedItem.clone(); - // Reset item meta (default name, no lore) - ItemMeta defaultMeta = sold.getItemMeta(); - if (clickedItem.getType() != Material.KNOWLEDGE_BOOK && defaultMeta != null) { - defaultMeta.setDisplayName(null); // Reset to default name - defaultMeta.setLore(null); // Remove lore - sold.setItemMeta(defaultMeta); + // Only reset the meta if the item is NOT a Knowledge Book + if (clickedItem.getType() != Material.KNOWLEDGE_BOOK) { + ItemMeta defaultMeta = sold.getItemMeta(); + if (defaultMeta != null) { + defaultMeta.setDisplayName(null); + defaultMeta.setLore(null); + sold.setItemMeta(defaultMeta); + } } // Check if player's inventory has space before proceeding HashMap leftover = player.getInventory().addItem(sold); if (!leftover.isEmpty()) { - // If there are leftover items, inventory is full player.sendMessage(ChatColor.RED + getConfigLine("inventory_full", "Your inventory is full! Purchase failed.")); return; } - // If inventory had space, finalize the purchase + // Finalize the purchase economy.withdrawPlayer(player, price); player.sendMessage(ColorKey("&aYou bought &b" + clickedItem.getAmount() + " &7" + String.valueOf(sold.getType()).toLowerCase().replace("_", " ") + @@ -197,6 +197,7 @@ public class BlockShop implements Listener { } } + public String ColorKey(String t) { char searchChar = '&'; // Character to search for char replacementChar = 'ยง'; // Character to replace with diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 2b596c6..298aefa 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -20,7 +20,9 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -33,6 +35,7 @@ import org.bukkit.block.data.type.RespawnAnchor; import CoswayUtil.GravityGauntletCommand; import net.milkbowl.vault.economy.Economy; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -99,6 +102,36 @@ public final class CoswayUtil extends JavaPlugin implements Listener { this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand()); this.getCommand("getwand").setExecutor(new GiveWandCommand()); getServer().getPluginManager().registerEvents(new LaunchStick(this), this); + new BukkitRunnable() { + + @Override + public void run() { + for (Player player : Bukkit.getOnlinePlayers()) { + if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Gravity Gauntlet")) { + ItemStack gauntlet = new ItemStack(Material.NETHERITE_HOE); // You can change this to any item you prefer + ItemMeta meta = gauntlet.getItemMeta(); + + if (meta != null) { + meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Gravity Gauntlet"); + meta.setLore(Collections.singletonList(ChatColor.GOLD + "Right Click to pull, Shift+Right Click to throw")); + meta.setUnbreakable(true); + gauntlet.setItemMeta(meta); + } + + player.getInventory().addItem(gauntlet); + } + if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Launch Stick")) { + player.getInventory().addItem(LaunchStick.createLaunchStick()); + } + if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Levitation Wand")) { + player.getInventory().addItem(MobLevitationWand.createWand()); + } + if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Rapid Fire Bow")) { + player.getInventory().addItem(RapidFireBow.createRapidFireBow()); + } + } + } + }.runTaskTimer(this,0,2); } @@ -196,6 +229,21 @@ public final class CoswayUtil extends JavaPlugin implements Listener { } return sb.toString(); } + public boolean removeCustomKnowledgeBook(Player player, String customName) { + for (ItemStack item : player.getInventory().getContents()) { + if (item != null && item.getType() == Material.KNOWLEDGE_BOOK) { + ItemMeta meta = item.getItemMeta(); + //player.sendMessage("you have a knowledge book with name: \n"+ meta.getDisplayName() + "\n"+customName+"\n do they match?"); + if (meta != null && meta.hasDisplayName() && meta.getDisplayName().equals(customName)) { + player.getInventory().remove(item); // Remove the book + return true; // Found and removed + } + } + } + return false; // No matching book found + } + + public void serverMessage(String msg) { getServer().broadcastMessage(prefix()+ColorKey(msg)); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cd4315d..2a8bf5b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,6 +12,28 @@ shop: material: OAK_PLANKS price: 15 display_name: "Oak Planks" + utilities: + items: + grav: + material: KNOWLEDGE_BOOK + price: 1000000 + quantity: 1 + display_name: "Gravity Gauntlet" + wand: + material: KNOWLEDGE_BOOK + price: 1000000 + quantity: 1 + display_name: "Levitation Wand" + launch: + material: KNOWLEDGE_BOOK + price: 1000000 + quantity: 1 + display_name: "Launch Stick" + bow: + material: KNOWLEDGE_BOOK + price: 1000000 + quantity: 1 + display_name: "Rapid Fire Bow" poor: "you're poor..." inventory_full: "you got too much clutter, cant fit your purchase into that mess..." pagination: