package me.km.commands; import me.km.api.GlobalText; import me.km.api.Location; import me.km.api.Module; import me.km.api.ModuleCommand; import me.km.api.SimpleConfig; import me.km.api.Utils; import me.km.permissions.Permissions; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; public class CommandSetHome extends ModuleCommand { public CommandSetHome(Module m) { super("sethome", m); super.setDescription("Erstellt einen neuen Home"); super.setUsage("/sethome "); super.setPermission(Permissions.SET_HOME); } public boolean addHome(String name, String uuid, Location l) { SimpleConfig sc = new SimpleConfig(this.getModule(), "home/" + uuid, name, false); if(sc.exists()) { return false; } sc.setLocation("home", l); sc.save(); return true; } @Override public boolean execute(ICommandSender cs, String[] arg) { if(!(cs instanceof EntityPlayer)) { this.getModule().send(cs, GlobalText.onlyPlayer()); return true; } if(arg.length < 1) { return false; } EntityPlayer p = ((EntityPlayer) cs); if(addHome(arg[0], p.getUniqueID().toString(), new Location(p))) { this.getModule().send(cs, "Der Home " + arg[0] + " wurde erstellt."); return true; } this.getModule().send(cs, "Der Home " + arg[0] + " existiert bereits."); return true; } }