add coomand: clear
This commit is contained in:
parent
81613186e5
commit
141c1b1f5c
2 changed files with 42 additions and 0 deletions
|
@ -16,6 +16,7 @@ import common.log.Log;
|
|||
import server.Server;
|
||||
import server.command.commands.CommandAdmin;
|
||||
import server.command.commands.CommandBlock;
|
||||
import server.command.commands.CommandClear;
|
||||
import server.command.commands.CommandFind;
|
||||
import server.command.commands.CommandHelp;
|
||||
import server.command.commands.CommandKick;
|
||||
|
@ -291,6 +292,7 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandBlock());
|
||||
this.registerExecutable(new CommandSeed());
|
||||
this.registerExecutable(new CommandSv());
|
||||
this.registerExecutable(new CommandClear());
|
||||
|
||||
this.registerExecutable(new CommandHelp(this));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.UserPolicy;
|
||||
|
||||
public class CommandClear extends Command {
|
||||
public CommandClear() {
|
||||
super("clear");
|
||||
|
||||
this.addLivingEntityList("entities", true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities) {
|
||||
int done = 0;
|
||||
for(EntityLiving entity : entities) {
|
||||
if(entity instanceof EntityNPC) {
|
||||
if(entity.isPlayer()) {
|
||||
((EntityNPC)entity).inventory.clearItems();
|
||||
}
|
||||
else {
|
||||
((EntityNPC)entity).getExtendedInventory().clear();
|
||||
for(int z = 0; z < 5; z++) {
|
||||
((EntityNPC)entity).setItem(z, null);
|
||||
}
|
||||
}
|
||||
exec.logConsole("Inventar von %s gelöscht", entity.getCommandName());
|
||||
done++;
|
||||
}
|
||||
}
|
||||
if(done > 1)
|
||||
exec.logConsole("Inventar von %d Objekten gelöscht", done);
|
||||
return done;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue