commands, ...
This commit is contained in:
parent
66421e806e
commit
75f91dbf4c
44 changed files with 1035 additions and 631 deletions
|
@ -23,8 +23,7 @@ import game.clipboard.Rotation;
|
|||
import game.clipboard.RotationValue;
|
||||
import game.clipboard.Vector;
|
||||
import game.color.TextColor;
|
||||
import game.command.ScriptExecutor;
|
||||
import game.dimension.Dimension;
|
||||
import game.command.Executor;
|
||||
import game.entity.Entity;
|
||||
import game.entity.animal.EntityHorse;
|
||||
import game.entity.item.EntityItem;
|
||||
|
@ -41,7 +40,6 @@ import game.init.EntityRegistry;
|
|||
import game.init.Items;
|
||||
import game.init.RotationRegistry;
|
||||
import game.init.SoundEvent;
|
||||
import game.init.UniverseRegistry;
|
||||
import game.inventory.Container;
|
||||
import game.inventory.ContainerChest;
|
||||
import game.inventory.ContainerHorseInventory;
|
||||
|
@ -52,7 +50,6 @@ import game.inventory.InventoryPlayer;
|
|||
import game.inventory.Slot;
|
||||
import game.inventory.SlotCrafting;
|
||||
import game.item.ItemControl;
|
||||
import game.item.ItemSpaceNavigator;
|
||||
import game.item.ItemStack;
|
||||
import game.log.Log;
|
||||
import game.material.Material;
|
||||
|
@ -128,7 +125,7 @@ import game.world.WorldServer;
|
|||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
public class NetHandlerPlayServer extends NetHandler implements ICrafting, ScriptExecutor
|
||||
public class NetHandlerPlayServer extends NetHandler implements ICrafting, Executor
|
||||
{
|
||||
private static enum EditAction {
|
||||
SELECT("Auswahlmodus"), COPYPASTE("Kopiermodus"), TRANSFORM("Drehmodus");
|
||||
|
@ -335,10 +332,6 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
public boolean getAdmin() {
|
||||
return this.admin;
|
||||
}
|
||||
|
||||
public void setAdmin(boolean admin) {
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
public void setPassword(String pass) {
|
||||
this.password = pass;
|
||||
|
@ -1662,7 +1655,6 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
}
|
||||
this.addFeed(comp);
|
||||
}
|
||||
this.addFeed(TextColor.YELLOW + "time" + TextColor.GRAY + " = " + TextColor.ORANGE + ItemSpaceNavigator.formatImperialTime(this.entity.getServerWorld(), false));
|
||||
this.addFeed(TextColor.GREEN + "SVARs insgesamt registriert: %d", Config.VARS.size());
|
||||
return true;
|
||||
}
|
||||
|
@ -1672,10 +1664,6 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
// case 0:
|
||||
// break;
|
||||
// case 1:
|
||||
if(args[0].equals("time")) {
|
||||
this.addFeed(TextColor.YELLOW + "time" + TextColor.GRAY + " = " + TextColor.ORANGE + ItemSpaceNavigator.formatImperialTime(this.entity.getServerWorld(), false));
|
||||
return true;
|
||||
}
|
||||
Config.Value cfg = Config.VARS.get(args[0]);
|
||||
if(cfg == null)
|
||||
return false;
|
||||
|
@ -1692,29 +1680,6 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
// default:
|
||||
}
|
||||
else {
|
||||
if(args[0].equals("time")) {
|
||||
long time = this.entity.getServerWorld().getDayTime();
|
||||
Long fwd = parseDayTime(args[1]);
|
||||
if(fwd == null)
|
||||
return true;
|
||||
if(fwd >= 0L) {
|
||||
time -= this.entity.getServerWorld().getDayTime() % this.entity.getServerWorld().dimension.getRotationalPeriod();
|
||||
time += fwd;
|
||||
time += time <= this.entity.getServerWorld().getDayTime() ? this.entity.getServerWorld().dimension.getRotationalPeriod() : 0L;
|
||||
}
|
||||
else {
|
||||
Long add = parseTime(args[1]);
|
||||
if(add == null)
|
||||
return true;
|
||||
time += add;
|
||||
}
|
||||
for(WorldServer dim : this.server.getWorlds()) {
|
||||
dim.setDayTime(time);
|
||||
dim.resetWeather();
|
||||
}
|
||||
this.addFeed(TextColor.YELLOW + "time" + TextColor.GRAY + " -> " + TextColor.ORANGE + "%s", ItemSpaceNavigator.formatImperialTime(this.entity.getServerWorld(), false));
|
||||
return true;
|
||||
}
|
||||
Config.Value cv = Config.VARS.get(args[0]);
|
||||
if(cv == null)
|
||||
return false;
|
||||
|
@ -1757,221 +1722,172 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean setAdmin(String line) {
|
||||
if(!this.isAdmin() || !line.startsWith("!") || line.indexOf(' ') >= 0)
|
||||
return false;
|
||||
line = line.substring(1).trim();
|
||||
NetHandlerPlayServer conn = this.server.getPlayer(line);
|
||||
if(conn == null)
|
||||
return false;
|
||||
if(conn.isAdmin() && (conn == this || !this.local)) {
|
||||
this.addFeed(TextColor.DRED + "Kann diese Aktion nicht an einem Admin ausführen");
|
||||
return true;
|
||||
public void setAdmin(boolean admin) {
|
||||
this.admin = admin;
|
||||
if(!this.isAdmin() && this.entity != null && this.entity.noclip) {
|
||||
this.entity.noclip = false;
|
||||
this.entity.flying &= this.entity.hasEffect(Potion.flying);
|
||||
this.entity.fallDistance = 0.0F;
|
||||
this.sendPlayerAbilities();
|
||||
this.addFeed(TextColor.RED + "NoClip wurde deaktiviert");
|
||||
}
|
||||
conn.setAdmin(!conn.getAdmin());
|
||||
EntityNPC player = conn.getEntity();
|
||||
if(!conn.isAdmin() && player.noclip) {
|
||||
// player.setCheat(false);
|
||||
player.noclip = false;
|
||||
player.flying &= player.hasEffect(Potion.flying);
|
||||
player.fallDistance = 0.0F;
|
||||
conn.sendPlayerAbilities();
|
||||
conn.addFeed(TextColor.RED + "NoClip wurde deaktiviert");
|
||||
}
|
||||
this.addFeed((conn.getAdmin() ? TextColor.GREEN : TextColor.RED) + "Admin-Status von " + conn.getUser() + " wurde " +
|
||||
(conn.getAdmin() ? "gesetzt" : "zurückgenommen"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private Long parseInt(String input, long max) {
|
||||
long num;
|
||||
try {
|
||||
num = Long.parseLong(input);
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
this.addFeed(TextColor.DRED + "'%s' ist keine gültige Zahl", input);
|
||||
return null;
|
||||
}
|
||||
// private Long parseInt(String input, long max) {
|
||||
// long num;
|
||||
// try {
|
||||
// num = Long.parseLong(input);
|
||||
// }
|
||||
// catch(NumberFormatException e) {
|
||||
// this.addFeed(TextColor.DRED + "'%s' ist keine gültige Zahl", input);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if(num < 0) {
|
||||
// this.addFeed(TextColor.DRED + "Die Zeit muss mindestens 0 betragen", num);
|
||||
// return null;
|
||||
// }
|
||||
// else if(num > max) {
|
||||
// this.addFeed(TextColor.DRED + "Die Zeit darf höchstens %d betragen", num, max);
|
||||
// return null;
|
||||
// }
|
||||
// else {
|
||||
// return num;
|
||||
// }
|
||||
// }
|
||||
|
||||
if(num < 0) {
|
||||
this.addFeed(TextColor.DRED + "Die Zeit muss mindestens 0 betragen", num);
|
||||
return null;
|
||||
}
|
||||
else if(num > max) {
|
||||
this.addFeed(TextColor.DRED + "Die Zeit darf höchstens %d betragen", num, max);
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
private Long parseDayTime(String arg) {
|
||||
Dimension dim = this.entity.getServerWorld().dimension;
|
||||
if(arg.equalsIgnoreCase("sunrise"))
|
||||
return dim.getRotationalPeriod() / 6L;
|
||||
else if(arg.equalsIgnoreCase("day"))
|
||||
return dim.getRotationalPeriod() * 5L / 24L;
|
||||
else if(arg.equalsIgnoreCase("noon"))
|
||||
return dim.getRotationalPeriod() / 2L;
|
||||
else if(arg.equalsIgnoreCase("sunset"))
|
||||
return dim.getRotationalPeriod() * 5L / 6L;
|
||||
else if(arg.equalsIgnoreCase("night"))
|
||||
return dim.getRotationalPeriod() * 21L / 24L;
|
||||
else if(arg.equalsIgnoreCase("midnight"))
|
||||
return 0L;
|
||||
else if(arg.startsWith("@"))
|
||||
return this.parseInt(arg.substring(1), dim.getRotationalPeriod() - 1);
|
||||
else
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private Long parseTime(String arg) {
|
||||
Dimension dim = this.entity.getServerWorld().dimension;
|
||||
long t;
|
||||
if(arg.toLowerCase().endsWith("y"))
|
||||
t = dim.getOrbitalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("d"))
|
||||
t = dim.getRotationalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("h"))
|
||||
t = 1000L;
|
||||
else
|
||||
t = -1L;
|
||||
arg = t == -1L ? arg : arg.substring(0, arg.length() - 1);
|
||||
t = t < 1L ? 1L : t;
|
||||
Long l = this.parseInt(arg, Long.MAX_VALUE);
|
||||
return l == null ? null : (t * l);
|
||||
}
|
||||
|
||||
private Double parseCoordinate(String str, boolean center) {
|
||||
try {
|
||||
return (double)Integer.parseInt(str) + (center ? 0.5 : 0.0);
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
this.addFeed(TextColor.DRED + "'%s' ist keine gültige Zahl", str);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// private Double parseCoordinate(String str, boolean center) {
|
||||
// try {
|
||||
// return (double)Integer.parseInt(str) + (center ? 0.5 : 0.0);
|
||||
// }
|
||||
// catch(NumberFormatException e) {
|
||||
// this.addFeed(TextColor.DRED + "'%s' ist keine gültige Zahl", str);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
private boolean teleport(String line) {
|
||||
if(!Config.teleportAllowed && !this.isAdmin())
|
||||
return false;
|
||||
line = line.trim();
|
||||
String[] argv = line.split(" ", -1);
|
||||
// private boolean teleport(String line) {
|
||||
// if(!Config.teleportAllowed && !this.isAdmin())
|
||||
// return false;
|
||||
// line = line.trim();
|
||||
// String[] argv = line.split(" ", -1);
|
||||
// if(line.isEmpty() || argv.length == 0 || argv.length == 2) {
|
||||
// this.addFeed(TextColor.DRED + "+Spieler, @Warp, *Dimension oder X Y Z [Dimension]");
|
||||
// return true;
|
||||
// }
|
||||
String tgt = argv[0];
|
||||
if(tgt.equals("#")) {
|
||||
if(argv.length < 4) {
|
||||
this.addFeed(TextColor.DRED + "# X Y Z [Dimension]");
|
||||
return true;
|
||||
}
|
||||
Double ax = parseCoordinate(argv[1], true);
|
||||
if(ax == null)
|
||||
return true;
|
||||
Double ay = parseCoordinate(argv[2], false);
|
||||
if(ay == null)
|
||||
return true;
|
||||
Double az = parseCoordinate(argv[3], true);
|
||||
if(az == null)
|
||||
return true;
|
||||
int dimension = this.entity.worldObj.dimension.getDimensionId();
|
||||
if(argv.length > 4) {
|
||||
WorldServer world;
|
||||
try {
|
||||
world = this.server.getWorld(Integer.parseInt(argv[4]));
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
world = this.server.getWorld(argv[4]);
|
||||
}
|
||||
if(world == null) {
|
||||
this.addFeed(TextColor.DRED + "Dimension '%s' existiert nicht", argv[4]);
|
||||
return true;
|
||||
}
|
||||
dimension = world.dimension.getDimensionId();
|
||||
}
|
||||
this.entity.teleport(ax, ay, az, this.entity.rotYaw, this.entity.rotPitch, dimension);
|
||||
}
|
||||
if(tgt.startsWith("@")) {
|
||||
tgt = tgt.substring(1);
|
||||
if(tgt.equals("spawn")) {
|
||||
WorldServer world = this.server.getWorld(Config.spawnDim);
|
||||
world = world == null ? this.server.getSpace() : world;
|
||||
int y = Config.spawnY;
|
||||
while(world.getState(new BlockPos(Config.spawnX, y, Config.spawnZ)).getBlock().getMaterial().blocksMovement() && y < 511)
|
||||
y++;
|
||||
this.entity.teleport(Config.spawnX + 0.5d, (double)y, Config.spawnZ + 0.5d,
|
||||
Config.spawnYaw, Config.spawnPitch, world.dimension.getDimensionId());
|
||||
}
|
||||
else {
|
||||
Position pos = this.server.getWarps().get(tgt);
|
||||
if(pos == null) {
|
||||
this.addFeed(TextColor.DRED + "Warp '%s' existiert nicht", tgt);
|
||||
return true;
|
||||
}
|
||||
if(this.server.getWorld(pos.dim) == null) {
|
||||
this.addFeed(TextColor.DRED + "Warp '%s' hat kein Level (%s)", tgt, pos.dim);
|
||||
return true;
|
||||
}
|
||||
this.entity.teleport(pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(tgt.startsWith("*")) {
|
||||
tgt = tgt.substring(1);
|
||||
WorldServer world;
|
||||
try {
|
||||
world = this.server.getWorld(Integer.parseInt(tgt));
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
world = this.server.getWorld(tgt);
|
||||
}
|
||||
if(world == null) {
|
||||
this.addFeed(TextColor.DRED + "Dimension '%s' existiert nicht", tgt);
|
||||
return true;
|
||||
}
|
||||
// int dimension = world.dimension.getDimensionId();
|
||||
// int dimension = parseDimension(sender, tgt);
|
||||
BlockPos pos = this.entity.getPosition();
|
||||
// WorldServer world = Server.getServer().getWorld(dimension);
|
||||
pos = pos.getY() < 0 ? new BlockPos(pos.getX(), 0, pos.getZ()) : pos;
|
||||
if(world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) {
|
||||
while((world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) && pos.getY() < 511)
|
||||
pos = pos.up();
|
||||
}
|
||||
else {
|
||||
while(!(world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) && pos.getY() > 0)
|
||||
pos = pos.down();
|
||||
pos = pos.up();
|
||||
}
|
||||
this.entity.teleport(pos, world.dimension.getDimensionId());
|
||||
return true;
|
||||
}
|
||||
else if(tgt.startsWith("+")) {
|
||||
tgt = tgt.substring(1);
|
||||
NetHandlerPlayServer conn = this.server.getPlayer(tgt);
|
||||
if(conn == null) {
|
||||
Position pos = this.server.getOfflinePosition(tgt);
|
||||
if(pos == null) {
|
||||
this.addFeed(TextColor.DRED + "Spieler '%s' konnte nicht gefunden werden", tgt);
|
||||
return true;
|
||||
}
|
||||
this.entity.teleport(pos);
|
||||
}
|
||||
else {
|
||||
EntityNPC dest = conn.getEntity();
|
||||
if(dest != null)
|
||||
this.entity.teleport(dest.posX, dest.posY, dest.posZ, dest.rotYaw, dest.rotPitch, dest.worldObj.dimension.getDimensionId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// String tgt = argv[0];
|
||||
// if(tgt.equals("#")) {
|
||||
// if(argv.length < 4) {
|
||||
// this.addFeed(TextColor.DRED + "# X Y Z [Dimension]");
|
||||
// return true;
|
||||
// }
|
||||
// Double ax = parseCoordinate(argv[1], true);
|
||||
// if(ax == null)
|
||||
// return true;
|
||||
// Double ay = parseCoordinate(argv[2], false);
|
||||
// if(ay == null)
|
||||
// return true;
|
||||
// Double az = parseCoordinate(argv[3], true);
|
||||
// if(az == null)
|
||||
// return true;
|
||||
// int dimension = this.entity.worldObj.dimension.getDimensionId();
|
||||
// if(argv.length > 4) {
|
||||
// WorldServer world;
|
||||
// try {
|
||||
// world = this.server.getWorld(Integer.parseInt(argv[4]));
|
||||
// }
|
||||
// catch(NumberFormatException e) {
|
||||
// world = this.server.getWorld(argv[4]);
|
||||
// }
|
||||
// if(world == null) {
|
||||
// this.addFeed(TextColor.DRED + "Dimension '%s' existiert nicht", argv[4]);
|
||||
// return true;
|
||||
// }
|
||||
// dimension = world.dimension.getDimensionId();
|
||||
// }
|
||||
// this.entity.teleport(ax, ay, az, this.entity.rotYaw, this.entity.rotPitch, dimension);
|
||||
// }
|
||||
// if(tgt.startsWith("@")) {
|
||||
// tgt = tgt.substring(1);
|
||||
// if(tgt.equals("spawn")) {
|
||||
// WorldServer world = this.server.getWorld(Config.spawnDim);
|
||||
// world = world == null ? this.server.getSpace() : world;
|
||||
// int y = Config.spawnY;
|
||||
// while(world.getState(new BlockPos(Config.spawnX, y, Config.spawnZ)).getBlock().getMaterial().blocksMovement() && y < 511)
|
||||
// y++;
|
||||
// this.entity.teleport(Config.spawnX + 0.5d, (double)y, Config.spawnZ + 0.5d,
|
||||
// Config.spawnYaw, Config.spawnPitch, world.dimension.getDimensionId());
|
||||
// }
|
||||
// else {
|
||||
// Position pos = this.server.getWarps().get(tgt);
|
||||
// if(pos == null) {
|
||||
// this.addFeed(TextColor.DRED + "Warp '%s' existiert nicht", tgt);
|
||||
// return true;
|
||||
// }
|
||||
// if(this.server.getWorld(pos.dim) == null) {
|
||||
// this.addFeed(TextColor.DRED + "Warp '%s' hat kein Level (%s)", tgt, pos.dim);
|
||||
// return true;
|
||||
// }
|
||||
// this.entity.teleport(pos);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// else if(tgt.startsWith("*")) {
|
||||
// tgt = tgt.substring(1);
|
||||
// WorldServer world;
|
||||
// try {
|
||||
// world = this.server.getWorld(Integer.parseInt(tgt));
|
||||
// }
|
||||
// catch(NumberFormatException e) {
|
||||
// world = this.server.getWorld(tgt);
|
||||
// }
|
||||
// if(world == null) {
|
||||
// this.addFeed(TextColor.DRED + "Dimension '%s' existiert nicht", tgt);
|
||||
// return true;
|
||||
// }
|
||||
//// int dimension = world.dimension.getDimensionId();
|
||||
//// int dimension = parseDimension(sender, tgt);
|
||||
// BlockPos pos = this.entity.getPosition();
|
||||
//// WorldServer world = Server.getServer().getWorld(dimension);
|
||||
// pos = pos.getY() < 0 ? new BlockPos(pos.getX(), 0, pos.getZ()) : pos;
|
||||
// if(world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) {
|
||||
// while((world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) && pos.getY() < 511)
|
||||
// pos = pos.up();
|
||||
// }
|
||||
// else {
|
||||
// while(!(world.getState(pos).getBlock().getMaterial().blocksMovement() || world.getState(pos).getBlock().getMaterial().isLiquid()) && pos.getY() > 0)
|
||||
// pos = pos.down();
|
||||
// pos = pos.up();
|
||||
// }
|
||||
// this.entity.teleport(pos, world.dimension.getDimensionId());
|
||||
// return true;
|
||||
// }
|
||||
// else if(tgt.startsWith("+")) {
|
||||
// tgt = tgt.substring(1);
|
||||
// NetHandlerPlayServer conn = this.server.getPlayer(tgt);
|
||||
// if(conn == null) {
|
||||
// Position pos = this.server.getOfflinePosition(tgt);
|
||||
// if(pos == null) {
|
||||
// this.addFeed(TextColor.DRED + "Spieler '%s' konnte nicht gefunden werden", tgt);
|
||||
// return true;
|
||||
// }
|
||||
// this.entity.teleport(pos);
|
||||
// }
|
||||
// else {
|
||||
// EntityNPC dest = conn.getEntity();
|
||||
// if(dest != null)
|
||||
// this.entity.teleport(dest.posX, dest.posY, dest.posZ, dest.rotYaw, dest.rotPitch, dest.worldObj.dimension.getDimensionId());
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
private void runCommand(String command) {
|
||||
this.server.getScriptEnvironment().execute(command, this);
|
||||
if(this.isAdmin())
|
||||
this.server.getScriptEnvironment().execute(command, this);
|
||||
else
|
||||
this.addFeed(TextColor.DRED + "Nur Admins können Befehle ausführen");
|
||||
}
|
||||
|
||||
private List<String> completeCommand(String command) {
|
||||
|
@ -2007,7 +1923,7 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
}
|
||||
switch(packetIn.getType()) {
|
||||
case COMMAND:
|
||||
if(!this.teleport(msg) && !this.setVar(msg) && !this.setAdmin(msg))
|
||||
if(!this.setVar(msg))
|
||||
this.runCommand(msg); // this.addFeed(TextColor.RED + "Befehl wurde nicht gefunden");
|
||||
break;
|
||||
|
||||
|
@ -2032,27 +1948,27 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
}
|
||||
}
|
||||
|
||||
private Iterable<String> getWarpList(char pre) {
|
||||
switch(pre) {
|
||||
case '+':
|
||||
return Lists.newArrayList(this.server.getUsers());
|
||||
case '@':
|
||||
List<String> warps = Lists.newArrayList("spawn");
|
||||
for(String warp : this.server.getWarps().keySet()) {
|
||||
warps.add(warp);
|
||||
}
|
||||
return warps;
|
||||
case '*':
|
||||
return UniverseRegistry.getWorldNames();
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
// private Iterable<String> getWarpList(char pre) {
|
||||
// switch(pre) {
|
||||
// case '+':
|
||||
// return Lists.newArrayList(this.server.getUsers());
|
||||
// case '@':
|
||||
// List<String> warps = Lists.newArrayList("spawn");
|
||||
// for(String warp : this.server.getWarps().keySet()) {
|
||||
// warps.add(warp);
|
||||
// }
|
||||
// return warps;
|
||||
// case '*':
|
||||
// return UniverseRegistry.getWorldNames();
|
||||
// }
|
||||
// return Lists.newArrayList();
|
||||
// }
|
||||
|
||||
private static List<String> getVarList() {
|
||||
List<String> list = Lists.newArrayList(Config.VARS.keySet());
|
||||
list.add("time");
|
||||
return list;
|
||||
}
|
||||
// private static List<String> getVarList() {
|
||||
// List<String> list = ;
|
||||
// list.add("time");
|
||||
// return list;
|
||||
// }
|
||||
|
||||
private List<String> getVarCompletion(String var) {
|
||||
Config.Value v = Config.VARS.get(var);
|
||||
|
@ -2068,37 +1984,27 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
public void processComplete(CPacketComplete packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.server);
|
||||
if(!this.isAdmin()) {
|
||||
this.entity.connection.sendPacket(new S3APacketTabComplete(new String[0]));
|
||||
return;
|
||||
}
|
||||
this.pointedEntity = packetIn.getEntityId();
|
||||
this.pointedPosition = packetIn.getPosition();
|
||||
if(packetIn.getMessage().startsWith(" ")) {
|
||||
this.entity.connection.sendPacket(new S3APacketTabComplete(new String[0]));
|
||||
return;
|
||||
}
|
||||
List<String> list = Lists.<String>newArrayList(); // Command.getCompletions(this.playerEntity, packetIn.getMessage());
|
||||
|
||||
// for (String s : )
|
||||
// {
|
||||
// list.add(s);
|
||||
// }
|
||||
|
||||
// if(list == null) {
|
||||
// list = Lists.<String>newArrayList();
|
||||
List<String> list = Lists.<String>newArrayList();
|
||||
String s = packetIn.getMessage();
|
||||
char pre = s.startsWith("#") || s.startsWith("!") || s.startsWith("+") || s.startsWith("*") || s.startsWith("@") ? s.charAt(0) : 0;
|
||||
s = pre == 0 ? s : s.substring(1);
|
||||
String[] argv = s.split(" ", -1);
|
||||
s = argv[argv.length - 1];
|
||||
Iterable<String> res = pre == '#' && (Config.teleportAllowed || this.isAdmin()) ? (argv.length == 5 ? UniverseRegistry.getWorldNames() : Lists.newArrayList()) : ((pre == '+' || pre == '*' || pre == '@') && (Config.teleportAllowed || this.isAdmin()) ? (argv.length == 1 ? this.getWarpList(pre) : Lists.newArrayList()) : (pre == '!' && this.isAdmin() ? this.server.getAllUsernames() : ((this.isAdmin() ? (argv.length == 1 ? getVarList() : (argv.length == 2 ? (argv[0].equals("time") ? Lists.newArrayList("day", "night", "noon", "midnight", "sunrise", "sunset") : getVarCompletion(argv[0])) : Lists.newArrayList())) : Lists.newArrayList()))));
|
||||
Iterable<String> res = argv.length == 1 ? Lists.newArrayList(Config.VARS.keySet()) : (argv.length == 2 ? getVarCompletion(argv[0]) : Lists.newArrayList());
|
||||
for(String s1 : res) {
|
||||
if(s1.regionMatches(true, 0, s, 0, s.length()))
|
||||
list.add((argv.length == 1 && pre != 0 ? pre : "") + s1);
|
||||
list.add(s1);
|
||||
}
|
||||
// if(list.isEmpty()) {
|
||||
list.addAll(this.completeCommand(packetIn.getMessage()));
|
||||
// }
|
||||
// }
|
||||
|
||||
this.entity.connection.sendPacket(new S3APacketTabComplete((String[])list.toArray(new String[list.size()])));
|
||||
this.entity.connection.sendPacket(new S3APacketTabComplete(list.toArray(new String[list.size()])));
|
||||
}
|
||||
|
||||
private static boolean isFinite(double value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue