123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package me.km.commands;
- import me.kt.api.Utils;
- import me.kt.api.GlobalText;
- import me.kt.api.Module;
- import me.kt.api.ModuleCommand;
- import me.kt.exceptions.PlayerNotFoundException;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class CommandTpPos extends ModuleCommand
- {
- public CommandTpPos(Module m)
- {
- super("tppos", m);
- this.setDescription("Teleportiert einen Spieler zu Koordinaten");
- this.setUsage("/tppos <x> <y> <z> [world] [player]");
- this.setPermission("kt.tppos");
- }
- @Override
- public boolean execute(CommandSender cs, String string, String[] arg)
- {
- if(arg.length < 3)
- {
- return false;
- }
- Player affectedPlayer;
- try
- {
- affectedPlayer = Utils.getPlayerByName(arg[4]);
- }
- catch(PlayerNotFoundException ex)
- {
- this.getModule().send(cs, GlobalText.cantFindPlayer(arg[4]));
- return true;
- }
- catch(IndexOutOfBoundsException ex)
- {
- if(!(cs instanceof Player))
- {
- this.getModule().send(cs, GlobalText.missingParameter());
- return true;
- }
- affectedPlayer = (Player) cs;
- }
-
- try
- {
- World w;
- if(arg.length >= 4 && Bukkit.getWorld(arg[3]) != null)
- {
- w = Bukkit.getWorld(arg[3]);
- }
- else
- {
- w = affectedPlayer.getWorld();
- }
- Location l = new Location(w, Double.parseDouble(arg[0]), Double.parseDouble(arg[1]), Double.parseDouble(arg[2]));
- affectedPlayer.teleport(l);
- String s = " zu " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + " teleportiert.";
- this.getModule().send(affectedPlayer, "Du wurdest" + s);
- if(!cs.equals(affectedPlayer))
- {
- this.getModule().send(cs, affectedPlayer.getName() + " wurde" + s);
- }
- return true;
- }
- catch(Exception ex)
- {
- this.getModule().send(cs, GlobalText.noIntegerNumber());
- return true;
- }
- }
- }
|