Skip to content

Commit

Permalink
Version 2.3 with option to not consume compasses
Browse files Browse the repository at this point in the history
  • Loading branch information
percyqaz committed Jan 1, 2023
1 parent 6b62448 commit f0636ba
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 167 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions .idea/artifacts/Lodestone_jar.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

110 changes: 0 additions & 110 deletions .idea/workspace.xml

This file was deleted.

34 changes: 18 additions & 16 deletions src/me/Percyqaz/Lodestone/CompassListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CompassListener implements Listener
long warmupTimeTicks;
boolean enableRecoveryCompass;
boolean enableDimensionalTravel;
boolean teleportationConsumesCompass;
Map<String, Long> cooldowns = new HashMap<>();

public CompassListener(Lodestone plugin, FileConfiguration config)
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/me/Percyqaz/Lodestone/Lodestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Lodestone
version: 2.2
version: 2.3
author: Percyqaz
main: me.Percyqaz.Lodestone.Lodestone
api-version: 1.19

0 comments on commit f0636ba

Please sign in to comment.