From 06076a750ff904396a23566d347dfca774324de4 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Tue, 23 May 2017 18:07:57 -0400 Subject: [PATCH] Finished prototype Random Teleports --- .../java/buttondevteam/presents/Main.java | 2 + .../hello/effects/HelloBedsplode.java | 8 ++-- .../presents/rtp/RandomTeleportComponent.java | 14 +++++++ .../java/buttondevteam/presents/rtp/Rtp.java | 42 +++++++++++++++++++ 4 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 src/main/java/buttondevteam/presents/rtp/RandomTeleportComponent.java create mode 100644 src/main/java/buttondevteam/presents/rtp/Rtp.java diff --git a/src/main/java/buttondevteam/presents/Main.java b/src/main/java/buttondevteam/presents/Main.java index 66e0e21..d27ecfc 100644 --- a/src/main/java/buttondevteam/presents/Main.java +++ b/src/main/java/buttondevteam/presents/Main.java @@ -6,6 +6,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.presents.hello.HelloComponent; +import buttondevteam.presents.rtp.RandomTeleportComponent; public class Main extends JavaPlugin{ public void onEnable(){ @@ -15,6 +16,7 @@ PluginDescriptionFile pdfFile = getDescription(); logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); new HelloComponent().register(this); + new RandomTeleportComponent().register(this); logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); } diff --git a/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java b/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java index 90a5aa3..6ca4c8b 100644 --- a/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java +++ b/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java @@ -9,15 +9,15 @@ public class HelloBedsplode implements Listener { @EventHandler public void onSleep(PlayerBedEnterEvent event){ Player player = event.getPlayer(); - if (player.getName() != "alisolarflare") return; + if (player.getName().toLowerCase() != "alisolarflare") return; player.getWorld().createExplosion( player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ(), - 4, - false, - false); + 4, //power + false, //setfire + false); //breakblocks player.sendMessage("HELLO MOTHERFUCKER!"); player.sendMessage("WAKEY WAKEY!"); diff --git a/src/main/java/buttondevteam/presents/rtp/RandomTeleportComponent.java b/src/main/java/buttondevteam/presents/rtp/RandomTeleportComponent.java new file mode 100644 index 0000000..5c83043 --- /dev/null +++ b/src/main/java/buttondevteam/presents/rtp/RandomTeleportComponent.java @@ -0,0 +1,14 @@ +package buttondevteam.presents.rtp; + +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.Component; + +public class RandomTeleportComponent extends Component { + + @Override + public void register(JavaPlugin plugin) { + this.registerCommand(plugin, new Rtp()); + } + +} diff --git a/src/main/java/buttondevteam/presents/rtp/Rtp.java b/src/main/java/buttondevteam/presents/rtp/Rtp.java new file mode 100644 index 0000000..1580c88 --- /dev/null +++ b/src/main/java/buttondevteam/presents/rtp/Rtp.java @@ -0,0 +1,42 @@ +package buttondevteam.presents.rtp; + +import org.bukkit.entity.Player; + +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.presents.architecture.commands.PlayerCommand; + +@CommandClass(path = "rtp") +public class Rtp extends PlayerCommand { + final coordinate[] places = { + new coordinate(-582,72), + new coordinate(-772, 140), + new coordinate(-838,226), + new coordinate(-282, 444), //star island + new coordinate(-654, 202), + new coordinate(250, 542), + new coordinate(370, 514), + new coordinate(-317, 431), + 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){ + this.x = x; + this.z = z; + } + } +}