123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package me.km.commands;
- import me.km.permissions.Permissions;
- import me.km.api.Utils;
- import me.km.api.GlobalText;
- import me.km.api.Location;
- import me.km.api.Module;
- import me.km.api.ModuleCommand;
- import me.km.dimensions.ModDimensions;
- import me.km.exception.PlayerNotFoundException;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.math.Vec3d;
- import net.minecraft.world.World;
- public class CommandTpPos extends ModuleCommand
- {
- public CommandTpPos(Module m)
- {
- super("tppos", m);
- super.setDescription("Teleportiert einen Spieler zu Koordinaten");
- super.setUsage("/tppos <x> <y> <z> [world] [player]");
- super.setPermission(Permissions.TP_POS);
- }
- @Override
- public boolean execute(ICommandSender cs, String[] arg)
- {
- if(arg.length < 3)
- {
- return false;
- }
- EntityPlayer 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 EntityPlayer))
- {
- this.getModule().send(cs, GlobalText.missingParameter());
- return true;
- }
- affectedPlayer = (EntityPlayer) cs;
- }
-
- try
- {
- World w;
- if(arg.length >= 4)
- {
- w = ModDimensions.getWorldFromName(arg[3]);
- if(w == null)
- {
- this.getModule().send(cs, "Die Welt '" + arg[3] + "' wurde nicht gefunden.");
- }
- }
- else
- {
- w = affectedPlayer.getEntityWorld();
- }
- Vec3d v = new Vec3d(Double.parseDouble(arg[0]), Double.parseDouble(arg[1]), Double.parseDouble(arg[2]));
- Utils.teleportEntity(affectedPlayer, new Location(w, v));
- String s = " zu " + v.x + ", " + v.y + ", " + v.z + " 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;
- }
- }
- }
|