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 CommandSetWarp extends ModuleCommand { public CommandSetWarp(Module m) { super("setwarp", m); super.setDescription("Erstellt einen neuen Warp"); super.setUsage("/setwarp "); super.setPermission(Permissions.SET_WARP); } public boolean addWarp(String name, Location l) { SimpleConfig sc = new SimpleConfig(this.getModule(), "warp/" + name, false); if(sc.exists()) { return false; } sc.setLocation("warp", 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; } if(addWarp(arg[0], Utils.getEntityLocation((EntityPlayer) cs))) { this.getModule().send(cs, "Der Warp " + arg[0] + " wurde erstellt."); return true; } this.getModule().send(cs, "Der Warp " + arg[0] + " existiert bereits."); return true; } }