From 6863487ad607b487f3f8838d00a9c296e4bb9929 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Tue, 23 May 2017 18:24:19 -0400 Subject: [PATCH] Adjustments to hardcoded values --- .../java/buttondevteam/presents/rtp/Rtp.java | 31 ++++++++++--------- target/classes/plugin.yml | 4 ++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/buttondevteam/presents/rtp/Rtp.java b/src/main/java/buttondevteam/presents/rtp/Rtp.java index 1580c88..f74b9ea 100644 --- a/src/main/java/buttondevteam/presents/rtp/Rtp.java +++ b/src/main/java/buttondevteam/presents/rtp/Rtp.java @@ -7,9 +7,9 @@ import buttondevteam.presents.architecture.commands.PlayerCommand; @CommandClass(path = "rtp") public class Rtp extends PlayerCommand { - final coordinate[] places = { + private int currentplace = 0; + private final coordinate[] teleportLocations = { new coordinate(-582,72), - new coordinate(-772, 140), new coordinate(-838,226), new coordinate(-282, 444), //star island new coordinate(-654, 202), @@ -19,24 +19,27 @@ public class Rtp extends PlayerCommand { new coordinate(-273, 556), new coordinate(-737, 217) }; - int currentplace = 0; - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - coordinate currentCoordinate = places[currentplace]; - - player.teleport(player.getWorld().getHighestBlockAt(currentCoordinate.x, currentCoordinate.z).getLocation()); - - currentplace = (int) (currentplace + Math.floor(Math.random()*4 - 1)) % places.length; - return false; - } - + private class coordinate{ final int x; final int z; - public coordinate(int x, int z){ + coordinate(int x, int z){ this.x = x; this.z = z; } } + + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + player.sendMessage("Teleporting..."); + coordinate currentCoordinate = teleportLocations[currentplace]; + + player.teleport(player.getWorld().getHighestBlockAt(currentCoordinate.x, currentCoordinate.z).getLocation()); + + currentplace = (int) (currentplace + Math.floor(Math.random()*5 - 1)) % teleportLocations.length; + return true; + } + + } diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index 5c4bd50..d37604d 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -4,4 +4,6 @@ version: 0.0.1 commands: hello: - description: A set of Hello World commands and listeners, type in /hello to see subcommands \ No newline at end of file + description: A set of Hello World commands and listeners, type in /hello to see subcommands + rtp: + description: A command that allows players to randomly teleport across the map \ No newline at end of file