Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package us.riotnetwork.teleport;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- import java.util.Random;
- /**
- * Created by Anthony on 12/19/2014.
- */
- public class Teleport extends JavaPlugin {
- @Override
- public void onEnable() {
- getLogger().info("onEnable has been invoked!");
- }
- @Override
- public void onDisable() {
- getLogger().info("onDisable has been invoked!");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You need to be a player to do this!");
- return true;
- }
- final Player p = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("location")) {
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- p.sendMessage(ChatColor.RED + "Your location is" + "" + x + "" + y + "" + z);
- return true;
- }
- return false;
- if (args.length == 3 && cmd.getName().equalsIgnoreCase("teleport")) {
- Location loc = p.getLocation();
- int x = Integer.parseInt(args[0]);
- int y = Integer.parseInt(args[1]);
- int z = Integer.parseInt(args[2]);
- loc.setX(x);
- loc.setY(y);
- loc.setZ(z);
- p.teleport(loc);
- p.sendMessage(ChatColor.RED + "You have been teleported to" + "" + x + "" + y + "" + z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement