Finished prototype Random Teleports

This commit is contained in:
alisolarflare 2017-05-23 18:07:57 -04:00
parent 05463da034
commit 06076a750f
4 changed files with 62 additions and 4 deletions

View file

@ -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()+ ").");
}

View file

@ -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!");

View file

@ -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());
}
}

View file

@ -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;
}
}
}