diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock index 32d87bb..b98f7ff 100644 Binary files a/.gradle/8.8/checksums/checksums.lock and b/.gradle/8.8/checksums/checksums.lock differ diff --git a/.gradle/8.8/checksums/md5-checksums.bin b/.gradle/8.8/checksums/md5-checksums.bin index a21048a..eeffb37 100644 Binary files a/.gradle/8.8/checksums/md5-checksums.bin and b/.gradle/8.8/checksums/md5-checksums.bin differ diff --git a/.gradle/8.8/checksums/sha1-checksums.bin b/.gradle/8.8/checksums/sha1-checksums.bin index a080e94..d3e352e 100644 Binary files a/.gradle/8.8/checksums/sha1-checksums.bin and b/.gradle/8.8/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index d5e23fc..2c28973 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 e5761d3..26b8a20 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 1b02f86..043bfae 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 155cb20..4142dd6 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 7d065b4..1bdc586 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 7fa8795..3a4e6f1 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 9be656d..a2f14f8 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index afadb01..11cf80d 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/.idea/modules.xml b/.idea/modules.xml index 8bf3721..2d8eacf 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/.idea/modules/CoswayUtil.main.iml b/.idea/modules/CoswayUtil.main.iml index bbeeb3e..746f1fd 100644 --- a/.idea/modules/CoswayUtil.main.iml +++ b/.idea/modules/CoswayUtil.main.iml @@ -11,4 +11,8 @@ + + + + \ No newline at end of file diff --git a/.idea/modules/com.newt-tech.CoswayUtil.main.iml b/.idea/modules/com.newt-tech.CoswayUtil.main.iml new file mode 100644 index 0000000..bbeeb3e --- /dev/null +++ b/.idea/modules/com.newt-tech.CoswayUtil.main.iml @@ -0,0 +1,14 @@ + + + + + + + PAPER + ADVENTURE + + 1 + + + + \ No newline at end of file diff --git a/build/classes/java/main/CoswayUtil/BlackholeEffect$1.class b/build/classes/java/main/CoswayUtil/BlackholeEffect$1.class new file mode 100644 index 0000000..a495b1f Binary files /dev/null and b/build/classes/java/main/CoswayUtil/BlackholeEffect$1.class differ diff --git a/build/classes/java/main/CoswayUtil/BlackholeEffect.class b/build/classes/java/main/CoswayUtil/BlackholeEffect.class new file mode 100644 index 0000000..43cc5e7 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/BlackholeEffect.class differ diff --git a/build/classes/java/main/CoswayUtil/CoswayUtil$1.class b/build/classes/java/main/CoswayUtil/CoswayUtil$1.class index 341d5f6..2e2d776 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$2.class b/build/classes/java/main/CoswayUtil/CoswayUtil$2.class index 47fe399..f2d540e 100644 Binary files a/build/classes/java/main/CoswayUtil/CoswayUtil$2.class and b/build/classes/java/main/CoswayUtil/CoswayUtil$2.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 b812d25..b6b0904 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 fa87804..0fd550f 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 81bf3aa..5c0a116 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 5891ef5..e52a22c 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 a3116c9..84d3cb7 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 6f06b34..8d2fc78 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/classes/java/main/CoswayUtil/RepairCommand.class b/build/classes/java/main/CoswayUtil/RepairCommand.class new file mode 100644 index 0000000..205fa16 Binary files /dev/null and b/build/classes/java/main/CoswayUtil/RepairCommand.class differ diff --git a/build/classes/java/main/CoswayUtil/UnbreakableCommand.class b/build/classes/java/main/CoswayUtil/UnbreakableCommand.class new file mode 100644 index 0000000..ee4d34f Binary files /dev/null and b/build/classes/java/main/CoswayUtil/UnbreakableCommand.class differ diff --git a/build/libs/CoswayUtil-1.12-RELEASE.jar b/build/libs/CoswayUtil-1.12-RELEASE.jar index 3b5e67e..0124dc8 100644 Binary files a/build/libs/CoswayUtil-1.12-RELEASE.jar and b/build/libs/CoswayUtil-1.12-RELEASE.jar differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml index d1079ce..7b81ff2 100644 --- a/build/resources/main/plugin.yml +++ b/build/resources/main/plugin.yml @@ -37,4 +37,12 @@ commands: blockshop: description: "opens block shop" usage: "/blockshop" - permission: CoswayUtil.shop \ No newline at end of file + permission: CoswayUtil.shop + unbreakable: + description: Makes the held tool unbreakable. + usage: /unbreakable + permission: coswayutil.unbreakable + repair: + description: Repairs the held tool to full durability. + usage: /repair + permission: coswayutil.repair \ No newline at end of file diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect$1.class.uniqueId16 b/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect$1.class.uniqueId16 new file mode 100644 index 0000000..a495b1f Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect$1.class.uniqueId16 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect.class.uniqueId23 b/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect.class.uniqueId23 new file mode 100644 index 0000000..43cc5e7 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/BlackholeEffect.class.uniqueId23 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId9 new file mode 100644 index 0000000..341d5f6 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$1.class.uniqueId9 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId0 new file mode 100644 index 0000000..47fe399 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$2.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId18 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId13 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$1.class.uniqueId18 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId8 new file mode 100644 index 0000000..fa87804 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$2.class.uniqueId8 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId12 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId12 new file mode 100644 index 0000000..5891ef5 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield$4.class.uniqueId12 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId21 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId21 new file mode 100644 index 0000000..a3116c9 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil$AnchorShield.class.uniqueId21 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId11 similarity index 99% rename from build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 rename to build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId11 index 158deb8..6f06b34 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId6 and b/build/tmp/compileJava/compileTransaction/stash-dir/CoswayUtil.class.uniqueId11 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId10 b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId10 new file mode 100644 index 0000000..62d16c2 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$1.class.uniqueId10 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$2.class.uniqueId22 b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$2.class.uniqueId22 new file mode 100644 index 0000000..b307551 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator$2.class.uniqueId22 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator.class.uniqueId26 b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator.class.uniqueId26 new file mode 100644 index 0000000..7eac3d8 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/FireflySimulator.class.uniqueId26 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GiveWandCommand.class.uniqueId15 b/build/tmp/compileJava/compileTransaction/stash-dir/GiveWandCommand.class.uniqueId15 new file mode 100644 index 0000000..5746ceb Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/GiveWandCommand.class.uniqueId15 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId2 new file mode 100644 index 0000000..d11403e Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/GravityGauntlet.class.uniqueId2 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/IlluminationWand.class.uniqueId17 b/build/tmp/compileJava/compileTransaction/stash-dir/IlluminationWand.class.uniqueId17 new file mode 100644 index 0000000..3eb5705 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/IlluminationWand.class.uniqueId17 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId19 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId0 rename to build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand$1.class.uniqueId19 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId13 new file mode 100644 index 0000000..af0dcbb Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/MobLevitationWand.class.uniqueId13 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId25 b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId25 new file mode 100644 index 0000000..b8ab886 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge$1.class.uniqueId25 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId20 b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId20 new file mode 100644 index 0000000..eff2eda Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/PhantomDodge.class.uniqueId20 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow$1.class.uniqueId24 b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow$1.class.uniqueId24 new file mode 100644 index 0000000..fef5727 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow$1.class.uniqueId24 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId5 b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId5 new file mode 100644 index 0000000..7d55222 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/RapidFireBow.class.uniqueId5 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId1 new file mode 100644 index 0000000..b63243a Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/ShadowStep.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId14 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId14 new file mode 100644 index 0000000..1d9a4fa Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$1.class.uniqueId14 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId6 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId2 rename to build/tmp/compileJava/compileTransaction/stash-dir/WitherContract$2.class.uniqueId6 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId12 b/build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId7 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId12 rename to build/tmp/compileJava/compileTransaction/stash-dir/WitherContract.class.uniqueId7 diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index df27f69..447a106 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/BlackholeEffect.java b/src/main/java/CoswayUtil/BlackholeEffect.java index 11f2d37..27eaa6c 100644 --- a/src/main/java/CoswayUtil/BlackholeEffect.java +++ b/src/main/java/CoswayUtil/BlackholeEffect.java @@ -38,11 +38,11 @@ public class BlackholeEffect extends BukkitRunnable { for (Entity nearbyEntity : nearbyEntities) { if (nearbyEntity instanceof Monster && nearbyEntity != entity) { pullEntityTowards(nearbyEntity, blackholeLocation); - pullTimer.putIfAbsent(nearbyEntity, 0); + pullTimer.putIfAbsent(nearbyEntity, Integer.valueOf(0)); } } - pullTimer.replaceAll((mob, time) -> time + 1); + pullTimer.replaceAll((mob, time) -> (Integer) (time + 1)); Iterator> iterator = pullTimer.entrySet().iterator(); while (iterator.hasNext()) { @@ -68,6 +68,7 @@ public class BlackholeEffect extends BukkitRunnable { } }.runTaskTimer(plugin, 0, 1); iterator.remove(); + removeEntityFromAllReferences(entity); } } } @@ -75,7 +76,10 @@ public class BlackholeEffect extends BukkitRunnable { } } - + private void removeEntityFromAllReferences(Entity entity) { + pullTimer.remove(entity); + entity.remove(); + } private void pullEntityTowards(Entity entity, Location targetLocation) { Vector direction = targetLocation.toVector().subtract(entity.getLocation().toVector()).normalize(); entity.setVelocity(direction.multiply(0.3)); diff --git a/src/main/java/CoswayUtil/CoswayUtil.java b/src/main/java/CoswayUtil/CoswayUtil.java index 937d6e5..c64e035 100644 --- a/src/main/java/CoswayUtil/CoswayUtil.java +++ b/src/main/java/CoswayUtil/CoswayUtil.java @@ -1,5 +1,6 @@ package CoswayUtil; +import io.papermc.paper.datacomponent.item.Unbreakable; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -114,6 +115,10 @@ public final class CoswayUtil extends JavaPlugin implements Listener { getServer().getPluginManager().registerEvents(new LaunchStick(this), this); new FireflySimulator(this); registration("FireFlies"); + getCommand("unbreakable").setExecutor(new UnbreakableCommand()); + registration("Unbreakable Command"); + getCommand("repair").setExecutor(new RepairCommand()); + registration("Repair Command"); //getServer().getPluginManager().registerEvents(new FireflySimulator(this), this); new BukkitRunnable() { diff --git a/src/main/java/CoswayUtil/RepairCommand.java b/src/main/java/CoswayUtil/RepairCommand.java new file mode 100644 index 0000000..360571e --- /dev/null +++ b/src/main/java/CoswayUtil/RepairCommand.java @@ -0,0 +1,64 @@ +package CoswayUtil; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class RepairCommand implements CommandExecutor { + + private static final Set REPAIRABLE_TOOLS = new HashSet<>(Arrays.asList( + Material.WOODEN_PICKAXE, Material.STONE_PICKAXE, Material.IRON_PICKAXE, Material.GOLDEN_PICKAXE, Material.DIAMOND_PICKAXE, Material.NETHERITE_PICKAXE, + Material.WOODEN_AXE, Material.STONE_AXE, Material.IRON_AXE, Material.GOLDEN_AXE, Material.DIAMOND_AXE, Material.NETHERITE_AXE, + Material.WOODEN_SHOVEL, Material.STONE_SHOVEL, Material.IRON_SHOVEL, Material.GOLDEN_SHOVEL, Material.DIAMOND_SHOVEL, Material.NETHERITE_SHOVEL, + Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD, Material.NETHERITE_SWORD, + Material.WOODEN_HOE, Material.STONE_HOE, Material.IRON_HOE, Material.GOLDEN_HOE, Material.DIAMOND_HOE, Material.NETHERITE_HOE, + Material.FISHING_ROD, Material.SHEARS + )); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED + "Only players can use this command!"); + return true; + } + + Player player = (Player) sender; + ItemStack item = player.getInventory().getItemInMainHand(); + + if (item.getType() == Material.AIR) { + player.sendMessage(ChatColor.RED + "You must be holding a tool to repair it!"); + return true; + } + + if (!REPAIRABLE_TOOLS.contains(item.getType())) { + player.sendMessage(ChatColor.RED + "That item is not a valid tool!"); + return true; + } + + ItemMeta meta = item.getItemMeta(); + if (meta instanceof Damageable) { + Damageable damageable = (Damageable) meta; + + if (damageable.getDamage() == 0) { + player.sendMessage(ChatColor.YELLOW + "This tool is already at full durability!"); + return true; + } + + damageable.setDamage(0); + item.setItemMeta((ItemMeta) damageable); + player.sendMessage(ChatColor.GREEN + "Your tool has been fully repaired!"); + } + + return true; + } +} diff --git a/src/main/java/CoswayUtil/UnbreakableCommand.java b/src/main/java/CoswayUtil/UnbreakableCommand.java new file mode 100644 index 0000000..de06fb6 --- /dev/null +++ b/src/main/java/CoswayUtil/UnbreakableCommand.java @@ -0,0 +1,61 @@ +package CoswayUtil; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class UnbreakableCommand implements CommandExecutor { + + private static final Set VALID_TOOLS = new HashSet<>(Arrays.asList( + Material.WOODEN_PICKAXE, Material.STONE_PICKAXE, Material.IRON_PICKAXE, Material.GOLDEN_PICKAXE, Material.DIAMOND_PICKAXE, Material.NETHERITE_PICKAXE, + Material.WOODEN_AXE, Material.STONE_AXE, Material.IRON_AXE, Material.GOLDEN_AXE, Material.DIAMOND_AXE, Material.NETHERITE_AXE, + Material.WOODEN_SHOVEL, Material.STONE_SHOVEL, Material.IRON_SHOVEL, Material.GOLDEN_SHOVEL, Material.DIAMOND_SHOVEL, Material.NETHERITE_SHOVEL, + Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD, Material.NETHERITE_SWORD, + Material.WOODEN_HOE, Material.STONE_HOE, Material.IRON_HOE, Material.GOLDEN_HOE, Material.DIAMOND_HOE, Material.NETHERITE_HOE, + Material.FISHING_ROD, Material.SHEARS + )); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED + "Only players can use this command!"); + return true; + } + + Player player = (Player) sender; + ItemStack item = player.getInventory().getItemInMainHand(); + + if (item.getType() == Material.AIR) { + player.sendMessage(ChatColor.RED + "You must be holding a tool to make it unbreakable!"); + return true; + } + + if (!VALID_TOOLS.contains(item.getType())) { + player.sendMessage(ChatColor.RED + "That item is not a valid tool!"); + return true; + } + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return true; + + if (meta.isUnbreakable()) { + player.sendMessage(ChatColor.YELLOW + "This tool is already unbreakable!"); + return true; + } + + meta.setUnbreakable(true); + item.setItemMeta(meta); + player.sendMessage(ChatColor.GREEN + "Your tool has been made unbreakable!"); + + return true; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 093b757..a187189 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -37,4 +37,12 @@ commands: blockshop: description: "opens block shop" usage: "/blockshop" - permission: CoswayUtil.shop \ No newline at end of file + permission: CoswayUtil.shop + unbreakable: + description: Makes the held tool unbreakable. + usage: /unbreakable + permission: coswayutil.unbreakable + repair: + description: Repairs the held tool to full durability. + usage: /repair + permission: coswayutil.repair \ No newline at end of file