char origins
This commit is contained in:
parent
3316c42ed8
commit
e9ede99d84
14 changed files with 516 additions and 373 deletions
|
@ -3,17 +3,13 @@ package game.command.commands;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import game.command.CommandEnvironment;
|
||||
import game.collect.Lists;
|
||||
import game.command.Command;
|
||||
import game.command.Executor;
|
||||
import game.command.RunException;
|
||||
import game.command.StringCompleter;
|
||||
import game.entity.Entity;
|
||||
import game.init.Config;
|
||||
import game.init.UniverseRegistry;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Position;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class CommandWarp extends Command {
|
||||
public CommandWarp() {
|
||||
|
@ -21,9 +17,9 @@ public class CommandWarp extends Command {
|
|||
|
||||
this.addString("warp", true, new StringCompleter() {
|
||||
public Collection<String> complete(CommandEnvironment env) {
|
||||
List<String> warps = Lists.newArrayList("spawn");
|
||||
warps.addAll(env.getServer().getWarps().keySet());
|
||||
return warps;
|
||||
// List<String> warps = Lists.newArrayList("spawn");
|
||||
// warps.addAll(env.getServer().getWarps().keySet());
|
||||
return env.getServer().getWarps().keySet();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -31,23 +27,23 @@ public class CommandWarp extends Command {
|
|||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String warp, List<Entity> entities) {
|
||||
Position pos;
|
||||
if(warp.equals("spawn")) {
|
||||
WorldServer world = env.getServer().getWorld(Config.spawnDim);
|
||||
world = world == null ? env.getServer().getSpace() : world;
|
||||
int y = Config.spawnY;
|
||||
while(world.getState(new BlockPos(Config.spawnX, y, Config.spawnZ)).getBlock().getMaterial().blocksMovement() && y < 511)
|
||||
y++;
|
||||
pos = new Position(Config.spawnX + 0.5d, (double)y, Config.spawnZ + 0.5d,
|
||||
Config.spawnYaw, Config.spawnPitch, world.dimension.getDimensionId());
|
||||
}
|
||||
else {
|
||||
pos = env.getServer().getWarps().get(warp);
|
||||
if(pos == null)
|
||||
throw new RunException("Warp '%s' existiert nicht", warp);
|
||||
else if(env.getServer().getWorld(pos.dim) == null)
|
||||
throw new RunException("Warp '%s' hat kein Level (%s)", warp, pos.dim);
|
||||
}
|
||||
Position // pos;
|
||||
// if(warp.equals("spawn")) {
|
||||
// WorldServer world = env.getServer().getWorld(Config.spawnDim);
|
||||
// world = world == null ? env.getServer().getSpace() : world;
|
||||
// int y = Config.spawnY;
|
||||
// while(world.getState(new BlockPos(Config.spawnX, y, Config.spawnZ)).getBlock().getMaterial().blocksMovement() && y < 511)
|
||||
// y++;
|
||||
// pos = new Position(Config.spawnX + 0.5d, (double)y, Config.spawnZ + 0.5d,
|
||||
// Config.spawnYaw, Config.spawnPitch, world.dimension.getDimensionId());
|
||||
// }
|
||||
// else {
|
||||
pos = env.getServer().getWarps().get(warp);
|
||||
if(pos == null)
|
||||
throw new RunException("Warp '%s' existiert nicht", warp);
|
||||
else if(env.getServer().getWorld(pos.dim) == null)
|
||||
throw new RunException("Warp '%s' hat kein Level (%s)", warp, pos.dim);
|
||||
// }
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(pos);
|
||||
exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x, (int)pos.y, (int)pos.z, UniverseRegistry.getDimension(pos.dim).getFormattedName(false));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue