Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hu.bendi.rndtp;
- import java.util.Random;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin {
- @Override
- public void onEnable() {
- getLogger().info("[RandomTP] Sikeresen elindult a plugin!");
- }
- @Override
- public void onDisable() {
- getLogger().info("[RandomTP] Sikeresen leált a plugin!");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- Player p = (Player)sender;
- System.out.println(command.getName()+ " " + command.getLabel() + " " + label);
- if (command.getName().equalsIgnoreCase("rndtp") && args.length > 0) {
- System.out.println("adsaf");
- switch (args[0]) {
- case "help":
- p.sendMessage("RandomTP Plugin By Bendi.");
- return true;
- case "tp":
- if (args.length > 1) {
- Location loc = getRandomLoc();
- getServer().getPlayer(args[1]).getLocation().setX(loc.getX());
- getServer().getPlayer(args[1]).getLocation().setY(loc.getY());
- getServer().getPlayer(args[1]).getLocation().setZ(loc.getZ());
- }else {
- Location loc = getRandomLoc();
- p.getLocation().setX(loc.getX());
- p.getLocation().setY(loc.getY());
- p.getLocation().setZ(loc.getZ());
- }
- return true;
- }
- }
- return false;
- }
- public Location getRandomLoc() {
- Random rnd = new Random();
- int x = rnd.nextInt() / 100;
- int z = rnd.nextInt() / 100;
- boolean plx = rnd.nextBoolean();
- boolean plz = rnd.nextBoolean();
- if (plx) {
- while (x < 2047) {
- x = rnd.nextInt()/ 100;
- System.out.println(x);
- }
- }else {
- while (x > -1536) {
- x = rnd.nextInt()/100;
- System.out.println(x);
- }
- }
- if (plz) {
- while (z < 2943) {
- z = rnd.nextInt()/100;
- System.out.println(z);
- }
- }else {
- while (z > -1536) {
- z = rnd.nextInt()/100;
- System.out.println(z);
- }
- }
- for (int i =255;i>0;i--) {
- Location lc = new Location(getServer().getWorld("world"), x, i, z);
- if (lc.getBlock().getType() != Material.AIR || lc.getBlock().getType() != Material.WATER) {
- return lc;
- }
- }
- return new Location(getServer().getWorld("world"), 0, 100, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement