add commands
This commit is contained in:
parent
e78bd9cce6
commit
4d406a70e1
14 changed files with 189 additions and 12 deletions
|
@ -482,7 +482,7 @@ public class Client implements IThreadListener {
|
|||
@Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius")
|
||||
public int rainParticleRange = 10;
|
||||
@Variable(name = "crosshair_size", category = CVarCategory.GUI, min = 0, max = 32, display = "Größe des Fadenkreuzes")
|
||||
public int crosshairSize = 10;
|
||||
public int crosshairSize = 6;
|
||||
@Variable(name = "crosshair_color_notarget", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (ohne Ziel)")
|
||||
public int crosshairColorBase = 0xffcfcfcf;
|
||||
@Variable(name = "crosshair_color_target", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (mit Ziel)")
|
||||
|
|
|
@ -8,7 +8,6 @@ import client.Client;
|
|||
import client.gui.element.Dropdown;
|
||||
import client.gui.element.Dropdown.Handle;
|
||||
import client.gui.element.Element;
|
||||
import client.gui.element.Field;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.GlState;
|
||||
import client.vars.CVar;
|
||||
|
|
|
@ -156,6 +156,14 @@ public abstract class Command implements Executable {
|
|||
return this.addParameter(shortName, new DoubleParser(name, null, min, max, false));
|
||||
}
|
||||
|
||||
protected Command addYaw(String name, boolean defaulted) {
|
||||
return this.addParameter(new DoubleParser(name, defaulted ? DefType.YAW : null, -180.0, 180.0, false));
|
||||
}
|
||||
|
||||
protected Command addPitch(String name, boolean defaulted) {
|
||||
return this.addParameter(new DoubleParser(name, defaulted ? DefType.PITCH : null, -89.0, 89.0, false));
|
||||
}
|
||||
|
||||
protected Command addDouble(String name, double min, double max) {
|
||||
return this.addParameter(new DoubleParser(name, null, min, max, false));
|
||||
}
|
||||
|
|
|
@ -271,5 +271,10 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandReturn());
|
||||
this.registerExecutable(new CommandDeathspot());
|
||||
this.registerExecutable(new CommandLoad());
|
||||
this.registerExecutable(new CommandWarps());
|
||||
this.registerExecutable(new CommandSetwarp());
|
||||
this.registerExecutable(new CommandDelwarp());
|
||||
this.registerExecutable(new CommandShowwarp());
|
||||
this.registerExecutable(new CommandTphere());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
|
||||
public class CommandDelwarp extends Command {
|
||||
public CommandDelwarp() {
|
||||
super("delwarp");
|
||||
|
||||
this.addString("warp", false, (env, last) -> env.getServer().getWarps().keySet());
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, String warp) {
|
||||
if(!env.getServer().getWarps().containsKey(warp))
|
||||
throw new RunException("Warp '%s' existiert nicht", warp);
|
||||
Position pos = env.getServer().getWarps().remove(warp);
|
||||
Dimension wdim = pos.getDimension();
|
||||
exec.log("Warp %s bei %d, %d, %d in %s entfernt", warp, ExtMath.floord(pos.xCoord), ExtMath.floord(pos.yCoord), ExtMath.floord(pos.zCoord), wdim == null ? "<?>" : wdim.getFormattedName(false));
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class CommandPlayers extends Command {
|
|||
exec.log(TextColor.GREEN + "Es " + (players.size() == 1 ? "ist" : "sind") + " " + TextColor.YELLOW + "%d" + TextColor.GREEN + " Spieler online", players.size());
|
||||
for(Player player : players) {
|
||||
EntityNPC entity = player.getPresentEntity();
|
||||
exec.log("%s%s" + TextColor.GRAY + ": '%s" + TextColor.GRAY + "'" + (coords ? " [" + TextColor.ORANGE + "%s @ %d, %d, %d" + TextColor.GRAY + "]" : ""), player.isAdmin() ? TextColor.RED : TextColor.NEON, player.getUser(), entity == null ? TextColor.DGRAY + "<->" : TextColor.ACID + entity.getCommandName(), entity == null ? null : entity.worldObj.dimension.getFormattedName(false), entity == null ? null : ExtMath.floord(entity.posX), entity == null ? null : ExtMath.floord(entity.posY), entity == null ? null : ExtMath.floord(entity.posZ));
|
||||
exec.log("%s%s" + TextColor.GRAY + ": '%s" + TextColor.GRAY + "'" + (coords && entity != null ? " [" + TextColor.ORANGE + "%s @ %d, %d, %d" + TextColor.GRAY + "]" : ""), player.isAdmin() ? TextColor.RED : TextColor.NEON, player.getUser(), entity == null ? TextColor.DGRAY + "<->" : TextColor.ACID + entity.getCommandName(), entity == null ? null : entity.worldObj.dimension.getFormattedName(false), entity == null ? null : ExtMath.floord(entity.posX), entity == null ? null : ExtMath.floord(entity.posY), entity == null ? null : ExtMath.floord(entity.posZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Position;
|
||||
import common.util.Vec3;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
|
||||
public class CommandSetwarp extends Command {
|
||||
public CommandSetwarp() {
|
||||
super("setwarp");
|
||||
|
||||
this.addString("warp", false);
|
||||
this.addVector("position", true, false);
|
||||
this.addDimension("dim", true);
|
||||
this.setParamsOptional();
|
||||
this.addYaw("yaw", true);
|
||||
this.addPitch("pitch", true);
|
||||
this.addFlag("replace", 'r');
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, String warp, Vec3 position, Dimension dim, Double yaw, Double pitch, boolean replace) {
|
||||
if(env.getServer().getWarps().containsKey(warp)) {
|
||||
if(replace) {
|
||||
Position pos = env.getServer().getWarps().get(warp);
|
||||
Dimension wdim = pos.getDimension();
|
||||
if(wdim != null)
|
||||
exec.log("Alte Position %d, %d, %d in %s entfernt", ExtMath.floord(pos.xCoord), ExtMath.floord(pos.yCoord), ExtMath.floord(pos.zCoord), dim.getFormattedName(false));
|
||||
}
|
||||
else {
|
||||
throw new RunException("Warp '%s' existiert bereits", warp);
|
||||
}
|
||||
}
|
||||
env.getServer().getWarps().put(warp, new Position(position.xCoord, position.yCoord, position.zCoord, yaw == null ? 0.0f : yaw.floatValue(), pitch == null ? 0.0f : pitch.floatValue(), dim));
|
||||
exec.log("Warp '%s' auf %d, %d, %d in %s gesetzt", warp, ExtMath.floord(position.xCoord), ExtMath.floord(position.yCoord), ExtMath.floord(position.zCoord), dim.getFormattedName(false));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
|
||||
public class CommandShowwarp extends Command {
|
||||
public CommandShowwarp() {
|
||||
super("showwarp");
|
||||
|
||||
this.addString("warp", false, (env, last) -> env.getServer().getWarps().keySet());
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, String warp) {
|
||||
if(!env.getServer().getWarps().containsKey(warp))
|
||||
throw new RunException("Warp '%s' existiert nicht", warp);
|
||||
Position pos = env.getServer().getWarps().get(warp);
|
||||
Dimension wdim = pos.getDimension();
|
||||
exec.log("Warp %s ist bei %.2f, %.2f, %.2f [%.1f, %.1f] in %s", warp, pos.xCoord, pos.yCoord, pos.zCoord, pos.yaw(), pos.pitch(), wdim == null ? "<?>" : wdim.getFormattedName(false));
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import common.entity.Entity;
|
|||
import common.entity.types.EntityLiving;
|
||||
import common.init.EntityRegistry;
|
||||
import common.tags.TagObject;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
import common.util.Vec3;
|
||||
import server.command.Command;
|
||||
|
@ -55,7 +56,7 @@ public class CommandSpawn extends Command {
|
|||
tag != null && tag.hasInt("damage") ? tag.getInt("damage") : 0, tag != null && tag.hasBool("fire") && tag.getBool("fire"),
|
||||
exec.isPlayer() && tag != null && tag.hasBool("summoned") && tag.getBool("summoned") ? ((Player)exec).getPresentEntity() : null);
|
||||
}
|
||||
exec.log("%sBlitz bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), (int)pos.xCoord, (int)pos.yCoord, (int)pos.zCoord, world.dimension.getFormattedName(false));
|
||||
exec.log("%sBlitz bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), ExtMath.floord(pos.xCoord), ExtMath.floord(pos.yCoord), ExtMath.floord(pos.zCoord), world.dimension.getFormattedName(false));
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
|
@ -82,7 +83,7 @@ public class CommandSpawn extends Command {
|
|||
}
|
||||
spawned.add("#" + entity.getId());
|
||||
}
|
||||
exec.log("%s%s bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), EntityRegistry.getEntityName(type), (int)pos.xCoord, (int)pos.yCoord, (int)pos.zCoord, world.dimension.getFormattedName(false));
|
||||
exec.log("%s%s bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), EntityRegistry.getEntityName(type), ExtMath.floord(pos.xCoord), ExtMath.floord(pos.yCoord), ExtMath.floord(pos.zCoord), world.dimension.getFormattedName(false));
|
||||
return Util.buildLines(",", spawned);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.Entity;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Vec3;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
|
@ -17,8 +18,8 @@ public class CommandTele extends Command {
|
|||
this.addVector("position", false, true);
|
||||
this.addDimension("dim", true);
|
||||
this.setParamsOptional();
|
||||
this.addDouble("yaw", -180.0, 180.0);
|
||||
this.addDouble("pitch", -89.0, 89.0);
|
||||
this.addYaw("yaw", false);
|
||||
this.addPitch("pitch", false);
|
||||
|
||||
this.setParamsRequired();
|
||||
this.addEntityList("entities", 'e', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
|
@ -27,7 +28,7 @@ public class CommandTele extends Command {
|
|||
public Object exec(CommandEnvironment env, Executor exec, Vec3 position, Dimension dim, Double yaw, Double pitch, List<Entity> entities) {
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(position.xCoord, position.yCoord, position.zCoord, yaw == null ? entity.rotYaw : yaw.floatValue(), pitch == null ? entity.rotPitch : pitch.floatValue(), dim);
|
||||
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)position.xCoord, (int)position.yCoord, (int)position.zCoord, dim.getFormattedName(false));
|
||||
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), ExtMath.floord(position.xCoord), ExtMath.floord(position.yCoord), ExtMath.floord(position.zCoord), dim.getFormattedName(false));
|
||||
}
|
||||
return entities.size();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class CommandTp extends Command {
|
|||
|
||||
this.addEntity("target", false, UserPolicy.NOT_SELF);
|
||||
|
||||
this.addEntityList("entities", 'e', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
this.addEntityList("entities", true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, Entity target, List<Entity> entities) {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.command.UserPolicy;
|
||||
|
||||
public class CommandTphere extends Command {
|
||||
public CommandTphere() {
|
||||
super("tphere");
|
||||
|
||||
this.addEntityList("entities", false, UserPolicy.NON_ADMINS_NOT_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<Entity> entities) {
|
||||
Position pos = exec.getExecPos();
|
||||
if(pos == null)
|
||||
throw new RunException("Keine Position zum Teleportieren vorhanden");
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(pos);
|
||||
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
|
||||
}
|
||||
return entities.size();
|
||||
}
|
||||
}
|
|
@ -40,10 +40,8 @@ public class CommandWarp extends Command {
|
|||
// }
|
||||
// else {
|
||||
pos = env.getServer().getWarps().get(warp);
|
||||
if(pos == null)
|
||||
if(pos == null || pos.getDimension() == null)
|
||||
throw new RunException("Warp '%s' existiert nicht", warp);
|
||||
else if(pos.getDimension() == null)
|
||||
throw new RunException("Warp '%s' hat keine Dimension", warp);
|
||||
// }
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(pos);
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Dimension;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
|
||||
public class CommandWarps extends Command {
|
||||
public CommandWarps() {
|
||||
super("warps");
|
||||
|
||||
this.setParamsOptional();
|
||||
this.addDimension("dim", false);
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, Dimension dim) {
|
||||
Map<String, Position> warps = env.getServer().getWarps();
|
||||
if(warps.isEmpty()) {
|
||||
exec.log(TextColor.DGRAY + "Es sind keine Warps definiert");
|
||||
return;
|
||||
}
|
||||
int n = 0;
|
||||
for(Entry<String, Position> warp : warps.entrySet()) {
|
||||
Dimension wdim = warp.getValue().getDimension();
|
||||
if(wdim != null && (dim == null || wdim == dim))
|
||||
n++;
|
||||
}
|
||||
if(dim != null && n == 0) {
|
||||
exec.log(TextColor.DGRAY + "Es sind keine Warps in %s vorhanden", dim.getFormattedName(false));
|
||||
return;
|
||||
}
|
||||
exec.log(TextColor.GREEN + "Es " + (n == 1 ? "ist" : "sind") + " " + TextColor.YELLOW + "%d" + TextColor.GREEN + " Warp" + (n == 1 ? "" : "s") + " " + (dim == null ? "" : "in Dimension %s ") + "vorhanden", n, dim == null ? null : dim.getFormattedName(false));
|
||||
for(Entry<String, Position> warp : warps.entrySet()) {
|
||||
Position pos = warp.getValue();
|
||||
Dimension wdim = pos.getDimension();
|
||||
if(wdim != null && (dim == null || wdim == dim))
|
||||
exec.log(TextColor.NEON + "%s" + TextColor.GRAY + ": " + TextColor.ORANGE + "%s" + (dim == null ? " @ " : "") + "%d, %d, %d", warp.getKey(), dim != null ? "" : wdim.getFormattedName(false), ExtMath.floord(pos.xCoord), ExtMath.floord(pos.yCoord), ExtMath.floord(pos.zCoord));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue