package me.km.datatools; import me.km.api.GlobalText; import me.km.api.Module; import me.km.api.ModuleCommand; import me.km.api.Utils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import me.km.entities.EntityHuman; import me.km.permissions.Permissions; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class CommandHuman extends ModuleCommand { private final ArrayList first; public CommandHuman(Module m) { super("human", m); super.setDescription("Spezielle Commands für Humans"); super.setUsage("/human für die Hilfe"); super.setPermission(Permissions.HUMAN); super.addAlias("h"); first = new ArrayList<>(Arrays.asList(new String[] {"spawn", "set", "kill", "size", "slim"})); } @Override public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos) { List names = new ArrayList<>(); switch (args.length) { case 1: first.stream().filter(e -> e.toLowerCase().startsWith(args[0].toLowerCase())).forEach(e -> { names.add(e); }); break; } return names; } @Override public boolean execute(ICommandSender cs, String[] arg) { if(!(cs instanceof EntityPlayerMP)) { this.getModule().send(cs, GlobalText.onlyPlayer()); return true; } EntityPlayerMP p = (EntityPlayerMP) cs; Module m = this.getModule(); if(arg.length >= 1) { switch (arg[0]) { case "spawn": { World w = p.getEntityWorld(); EntityHuman h = new EntityHuman(w); h.setPosition(p.posX, p.posY, p.posZ); w.spawnEntity(h); return true; } case "set": { if(arg.length < 2) { break; } EntityHuman h = Utils.getTargetedEntity(p, 3, EntityHuman.class); if(h == null) { m.send(cs, "Du musst auf einen Human gerichtet sein."); return true; } h.setName(arg[1]); m.send(cs, "Die Daten wurden geändert."); return true; } case "kill": { EntityHuman h = Utils.getTargetedEntity(p, 3, EntityHuman.class); if(h == null) { m.send(cs, "Du musst auf einen Human gerichtet sein."); return true; } h.setDead(); m.send(cs, "Der Human wurde getötet."); return true; } case "size": { if(arg.length < 2) { break; } EntityHuman h = Utils.getTargetedEntity(p, 3, EntityHuman.class); if(h == null) { m.send(cs, "Du musst auf einen Human gerichtet sein."); return true; } float scale; try { scale = Float.parseFloat(arg[1]); } catch(NumberFormatException ex) { m.send(cs, "Du musst einen gültigen Float eingeben."); return true; } h.setScale(scale); m.send(cs, "Der Human wurde skaliert."); return true; } case "slim": { EntityHuman h = Utils.getTargetedEntity(p, 3, EntityHuman.class); if(h == null) { m.send(cs, "Du musst auf einen Human gerichtet sein."); return true; } h.setSlim(!h.isSlim()); m.send(cs, "Der Skin wurde geändert."); return true; } } } m.send(cs, "/human ..."); m.sendHelpListElement(cs, "spawn", "Spawnt einen Human"); m.sendHelpListElement(cs, "set ", "Setzt den Namen"); m.sendHelpListElement(cs, "kill", "Tötet einen Human"); m.sendHelpListElement(cs, "size ", "Setzt die Größenskalierung"); m.sendHelpListElement(cs, "slim", "Schaltet Alex/Steve Skin"); return true; } }