fix fonts
This commit is contained in:
parent
cd7a739c5d
commit
6114da126a
14 changed files with 124 additions and 81 deletions
|
@ -14,35 +14,7 @@ import common.collect.Sets;
|
|||
import common.color.TextColor;
|
||||
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;
|
||||
import server.command.commands.CommandMessage;
|
||||
import server.command.commands.CommandMilk;
|
||||
import server.command.commands.CommandOfflinetp;
|
||||
import server.command.commands.CommandPasswd;
|
||||
import server.command.commands.CommandPlayers;
|
||||
import server.command.commands.CommandPotion;
|
||||
import server.command.commands.CommandPubkey;
|
||||
import server.command.commands.CommandRegister;
|
||||
import server.command.commands.CommandRegkey;
|
||||
import server.command.commands.CommandRemove;
|
||||
import server.command.commands.CommandRevoke;
|
||||
import server.command.commands.CommandSave;
|
||||
import server.command.commands.CommandSeed;
|
||||
import server.command.commands.CommandShutdown;
|
||||
import server.command.commands.CommandSpawn;
|
||||
import server.command.commands.CommandSv;
|
||||
import server.command.commands.CommandTele;
|
||||
import server.command.commands.CommandTime;
|
||||
import server.command.commands.CommandTp;
|
||||
import server.command.commands.CommandUsers;
|
||||
import server.command.commands.CommandWarp;
|
||||
import server.command.commands.CommandWeather;
|
||||
import server.command.commands.CommandWorld;
|
||||
import server.command.commands.*;
|
||||
|
||||
public class CommandEnvironment {
|
||||
private final Server server;
|
||||
|
@ -293,6 +265,7 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandSeed());
|
||||
this.registerExecutable(new CommandSv());
|
||||
this.registerExecutable(new CommandClear());
|
||||
this.registerExecutable(new CommandEntity());
|
||||
|
||||
this.registerExecutable(new CommandHelp(this));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ public enum UserPolicy {
|
|||
return true;
|
||||
}
|
||||
},
|
||||
NO_PLAYERS("Objekt ist ein Spieler") {
|
||||
public boolean applies(CommandEnvironment env, Executor exec, User user) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
NON_ADMINS("Spieler ist ein Admin") {
|
||||
public boolean applies(CommandEnvironment env, Executor exec, User user) {
|
||||
return !user.isAdmin() || exec.isConsole();
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.tags.TagObject;
|
||||
import common.util.BlockPos;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.UserPolicy;
|
||||
|
||||
public class CommandEntity extends Command {
|
||||
public CommandEntity() {
|
||||
super("entity");
|
||||
|
||||
this.addEntityList("entities", false, UserPolicy.NO_PLAYERS);
|
||||
this.setParamsOptional();
|
||||
this.addTag("tag");
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<Entity> entities, TagObject tag) {
|
||||
int done = 0;
|
||||
for(Entity entity : entities) {
|
||||
if(entity.isEntityAlive()) {
|
||||
BlockPos pos = entity.getPosition();
|
||||
TagObject etag = new TagObject();
|
||||
entity.writeTags(etag);
|
||||
if(tag == null) {
|
||||
exec.logConsole("************************************************************");
|
||||
exec.logConsole("Daten von %s bei %d, %d, %d in %s:", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getFormattedName(false));
|
||||
exec.logConsole(etag.format(4));
|
||||
}
|
||||
else {
|
||||
etag.merge(tag);
|
||||
entity.readTags(etag);
|
||||
exec.logConsole("Daten von %s bei %d, %d, %d in %s geändert", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getFormattedName(false));
|
||||
}
|
||||
done++;
|
||||
}
|
||||
}
|
||||
if(tag != null && done > 1)
|
||||
exec.logConsole("Daten von %d Objekten geändert", done);
|
||||
return done;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
@ -12,24 +13,24 @@ import server.command.Command;
|
|||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.Parameter;
|
||||
import server.command.RunException;
|
||||
import server.command.StringCompleter;
|
||||
|
||||
public class CommandHelp extends Command {
|
||||
public CommandHelp(CommandEnvironment env) {
|
||||
super("help");
|
||||
|
||||
this.setParamsOptional();
|
||||
this.addEnum("command", CachedExecutable.class, env.getExecutables().values());
|
||||
this.addString("command", false, new StringCompleter() {
|
||||
public Collection<String> complete(CommandEnvironment env) {
|
||||
return env.getExecutables().keySet();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, CachedExecutable command) {
|
||||
if(command == null) {
|
||||
for(CachedExecutable cmd : env.getExecutables().values()) {
|
||||
this.exec(env, exec, cmd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
private void formatCommand(CommandEnvironment env, Executor exec, CachedExecutable cmd) {
|
||||
List<String> list = Lists.newArrayList();
|
||||
for(Entry<String, Parameter> entry : command.parameters().entrySet()) {
|
||||
for(Entry<String, Parameter> entry : cmd.parameters().entrySet()) {
|
||||
Parameter param = entry.getValue();
|
||||
boolean required = param.neededIn(env);
|
||||
if(entry.getKey().length() == 1 && !param.positional() && param.shorthand()) {
|
||||
|
@ -42,7 +43,7 @@ public class CommandHelp extends Command {
|
|||
}, param.parsers()))) + (required ? ">" : "]"));
|
||||
}
|
||||
}
|
||||
for(Parameter param : command.positionals()) {
|
||||
for(Parameter param : cmd.positionals()) {
|
||||
boolean required = param.neededIn(env);
|
||||
list.add((required ? "<" : "[") + (param.parsers().size() == 1 &&
|
||||
param.parsers().get(0).getName().equals(param.name()) ? param.name() :
|
||||
|
@ -52,6 +53,19 @@ public class CommandHelp extends Command {
|
|||
}
|
||||
}, param.parsers())) + (required ? ">" : "]"));
|
||||
}
|
||||
exec.logConsole("%s %s", command.name(), Util.buildLines(" ", list));
|
||||
exec.logConsole("%s %s", cmd.name(), Util.buildLines(" ", list));
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, String command) {
|
||||
if(command == null) {
|
||||
for(CachedExecutable cmd : env.getExecutables().values()) {
|
||||
this.formatCommand(env, exec, cmd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
CachedExecutable cmd = env.getExecutables().get(command);
|
||||
if(cmd == null)
|
||||
throw new RunException("Befehl '%s' ist nicht bekannt", command);
|
||||
this.formatCommand(env, exec, cmd);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue