Friday, May 2, 2014

Help on my minecraft plugin!!




So, im making a minecraft plugin for my server. And im having a bit of trouble, I want it so that when you do the command (map1) it will create a new world/Just copy the map so its the same always through multiverse and then teleport you to it. But ive only made it so it teleports you to coordinates. Any help? :/




package me.simmmatt;




import org.bukkit.ChatColor;



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 Maps extends JavaPlugin {




@Override



public void onEnable() {




}




@Override



public void onDisable() {




}




public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {




if (cmd.getName().equalsIgnoreCase("map1") && sender instanceof Player) {




Player player = (Player) sender;




Location teleportLocation = null;




int x = 0;



int y = 150;



int z = 0;




boolean isOnLand = false;




while (isOnLand == false) {




teleportLocation = new Location(player.getWorld(), x, y, z);




if (teleportLocation.getBlock().getType() != Material.AIR) {



isOnLand = true;



} else y--;




}




player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));




player.sendMessage(ChatColor.GREEN + "You have been teleported to map 1!");




return true;




} else if



(cmd.getName().equalsIgnoreCase("map2") && sender instanceof Player) {




Player player = (Player) sender;




Location teleportLocation = null;




int x = 100;



int y = 150;



int z = 100;




boolean isOnLand = false;




while (isOnLand == false) {




teleportLocation = new Location(player.getWorld(), x, y, z);




if (teleportLocation.getBlock().getType() != Material.AIR) {



isOnLand = true;



} else y--;




}




player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));




player.sendMessage(ChatColor.GREEN + "You have been teleported to map 2!");




return true;




} else if



(cmd.getName().equalsIgnoreCase("map3") && sender instanceof Player) {




Player player = (Player) sender;




Location teleportLocation = null;




int x = 300;



int y = 150;



int z = 300;




boolean isOnLand = false;




while (isOnLand == false) {




teleportLocation = new Location(player.getWorld(), x, y, z);




if (teleportLocation.getBlock().getType() != Material.AIR) {



isOnLand = true;



} else y--;




}




player.teleport(new Location(player.getWorld(), teleportLocation.getX(), teleportLocation.getY() + 1, teleportLocation.getZ()));




player.sendMessage(ChatColor.GREEN + "You have been teleported to map 3!");




return true;




}



return false;



}



}







No comments:

Post a Comment