1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package me.km.commands;
- import me.km.api.GlobalText;
- import me.km.api.Module;
- import me.km.api.ModuleCommand;
- import me.km.api.Location;
- import me.km.api.Utils;
- import me.km.exception.PlayerNotFoundException;
- import me.km.permissions.Permission;
- import me.km.permissions.Permissions;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.math.BlockPos;
- public class CommandBed extends ModuleCommand
- {
- public CommandBed(Module m)
- {
- super("bed", m);
- super.setDescription("Teleportiert einen Spieler zu einem Bett");
- super.setUsage("/bed [player]");
- super.setPermission(Permissions.BED);
- }
- @Override
- public boolean execute(ICommandSender cs, String[] arg)
- {
- if(!(cs instanceof EntityPlayer))
- {
- this.getModule().send(cs, GlobalText.onlyPlayer());
- return true;
- }
- EntityPlayer p = (EntityPlayer) cs;
-
- if(arg.length == 0 || !Permission.hasPermission(cs, Permissions.BED_OTHER))
- {
- BlockPos pos = p.getBedLocation(p.dimension);
- if(pos == null)
- {
- this.getModule().send(cs, "Du hast keinen Bettspawn gesetzt.");
- return true;
- }
- Utils.teleportEntity(p, new Location(p.getEntityWorld(), pos));
- this.getModule().send(cs, "Du wurdest zu deinem Bett teleportiert.");
- return true;
- }
- EntityPlayer affectedPlayer;
- try
- {
- affectedPlayer = Utils.getPlayerByName(arg[0]);
- }
- catch(PlayerNotFoundException ex)
- {
- this.getModule().send(cs, GlobalText.cantFindPlayer(arg[0]));
- return true;
- }
- BlockPos pos = p.getBedLocation(p.dimension);
- if(pos == null)
- {
- this.getModule().send(cs, affectedPlayer.getName() + " hat keinen Bettspawn gesetzt.");
- return true;
- }
- Utils.teleportEntity(p, new Location(p.getEntityWorld(), pos));
- this.getModule().send(cs, "Du wurdest zum Bett von " + affectedPlayer.getName() + " teleportiert.");
- return true;
- }
- }
|