From f0636ba3be86582bfabb3e43dd4fb5558e5a616d Mon Sep 17 00:00:00 2001 From: percyqaz <21290233+percyqaz@users.noreply.github.com> Date: Sun, 1 Jan 2023 14:19:19 +0000 Subject: [PATCH] Version 2.3 with option to not consume compasses --- .gitignore | 9 +- .idea/artifacts/Lodestone_jar.xml | 8 -- .idea/compiler.xml | 6 - .idea/misc.xml | 6 - .idea/modules.xml | 8 -- .idea/vcs.xml | 6 - .idea/workspace.xml | 110 ------------------ .../Percyqaz/Lodestone/CompassListener.java | 34 +++--- src/me/Percyqaz/Lodestone/Lodestone.java | 1 + src/plugin.yml | 2 +- 10 files changed, 23 insertions(+), 167 deletions(-) delete mode 100644 .idea/artifacts/Lodestone_jar.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.gitignore b/.gitignore index 7b23659..c481f8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -out/artifacts/Lodestone_jar/Lodestone.jar -out/production/Lodestone/plugin.yml -out/production/Lodestone/me/Percyqaz/Lodestone/CompassListener.class -out/production/Lodestone/me/Percyqaz/Lodestone/Lodestone.class -.idea/ -.vs/ +out +.vs +.idea \ No newline at end of file diff --git a/.idea/artifacts/Lodestone_jar.xml b/.idea/artifacts/Lodestone_jar.xml deleted file mode 100644 index 0205312..0000000 --- a/.idea/artifacts/Lodestone_jar.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/Lodestone_jar - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 38d573b..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 15cec4b..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index ec57e2f..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 6a53167..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1593367818276 - - - 1626271207819 - - - 1639964456629 - - - 1672353007815 - - - - - - - - - - - - \ No newline at end of file diff --git a/src/me/Percyqaz/Lodestone/CompassListener.java b/src/me/Percyqaz/Lodestone/CompassListener.java index a7db819..b5d7fbf 100644 --- a/src/me/Percyqaz/Lodestone/CompassListener.java +++ b/src/me/Percyqaz/Lodestone/CompassListener.java @@ -23,6 +23,7 @@ public class CompassListener implements Listener long warmupTimeTicks; boolean enableRecoveryCompass; boolean enableDimensionalTravel; + boolean teleportationConsumesCompass; Map cooldowns = new HashMap<>(); public CompassListener(Lodestone plugin, FileConfiguration config) @@ -35,6 +36,7 @@ public CompassListener(Lodestone plugin, FileConfiguration config) enableRecoveryCompass = config.getBoolean("enableRecoveryCompass", true); enableDimensionalTravel = config.getBoolean("enableDimensionalTravel", true); + teleportationConsumesCompass = config.getBoolean("teleportationConsumesCompass", true); // Cooldown must always be at least as long as warmup cooldownTimeMillis = Math.max(cooldownTimeMillis, warmupTimeTicks * 50L); @@ -101,7 +103,7 @@ void PerformTeleport(Player player, Location oldLoc) Location pos = itemMeta.getLodestone(); player.teleport(pos.add(0.5, 1.5, 0.5)); - item.setAmount(item.getAmount() - 1); + if (teleportationConsumesCompass) item.setAmount(item.getAmount() - 1); player.spawnParticle(Particle.CLOUD, player.getLocation().add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f); player.playSound(player.getLocation(), Sound.BLOCK_CONDUIT_ACTIVATE, 1.0f, 0.5f); @@ -126,25 +128,25 @@ void PerformRecoveryTeleport(Player player, Location oldLoc) } ItemStack item = player.getInventory().getItemInMainHand(); + if (item.getType() != Material.RECOVERY_COMPASS) + { + player.sendMessage(config.getString("teleportFailedCompassNotInHand")); + player.playSound(oldLoc, Sound.ITEM_LODESTONE_COMPASS_LOCK, 1.0f, 0.3f); + ResetPlayerCooldown(player.getName()); + return; + } - if (item.getType() == Material.RECOVERY_COMPASS) { - Location lastDeath = player.getLastDeathLocation(); - - String teleportMessage = config.getString("teleportSucceeded"); - player.sendMessage(teleportMessage); - player.spawnParticle(Particle.CLOUD, oldLoc.add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f); + Location lastDeath = player.getLastDeathLocation(); - player.teleport(lastDeath); - item.setAmount(item.getAmount() - 1); + String teleportMessage = config.getString("teleportSucceeded"); + player.sendMessage(teleportMessage); + player.spawnParticle(Particle.CLOUD, oldLoc.add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f); - player.spawnParticle(Particle.CLOUD, player.getLocation().add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f); - player.playSound(player.getLocation(), Sound.BLOCK_CONDUIT_ACTIVATE, 1.0f, 0.3f); - return; - } + player.teleport(lastDeath.add(0.5, 0.0, 0.5)); + if (teleportationConsumesCompass) item.setAmount(item.getAmount() - 1); - player.sendMessage(config.getString("teleportFailedCompassNotInHand")); - player.playSound(oldLoc, Sound.ITEM_LODESTONE_COMPASS_LOCK, 1.0f, 0.3f); - ResetPlayerCooldown(player.getName()); + player.spawnParticle(Particle.CLOUD, player.getLocation().add(0.0f, 1.0f, 0.0f), 50, 0.5f, 1.0f, 0.5f, 0.01f); + player.playSound(player.getLocation(), Sound.BLOCK_CONDUIT_ACTIVATE, 1.0f, 0.3f); } /// Returns true if a teleport went through and false otherwise diff --git a/src/me/Percyqaz/Lodestone/Lodestone.java b/src/me/Percyqaz/Lodestone/Lodestone.java index 1c14fee..ac60481 100644 --- a/src/me/Percyqaz/Lodestone/Lodestone.java +++ b/src/me/Percyqaz/Lodestone/Lodestone.java @@ -18,6 +18,7 @@ public void onEnable() { config.addDefault("teleportSucceededNamedLocation", "§9Whoosh! Teleported to §a%location%"); config.addDefault("enableRecoveryCompass", true); config.addDefault("enableDimensionalTravel", true); + config.addDefault("teleportationConsumesCompass", true); config.options().copyDefaults(true); saveConfig(); diff --git a/src/plugin.yml b/src/plugin.yml index 6d6379a..73543d7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: Lodestone -version: 2.2 +version: 2.3 author: Percyqaz main: me.Percyqaz.Lodestone.Lodestone api-version: 1.19 \ No newline at end of file