
net.minecraft.server.CommandWorldBorder Maven / Gradle / Ivy
package net.minecraft.server;
import java.util.List;
public class CommandWorldBorder extends CommandAbstract {
public CommandWorldBorder() {
}
public String getCommand() {
return "worldborder";
}
public int a() {
return 2;
}
public String getUsage(ICommandListener icommandlistener) {
return "commands.worldborder.usage";
}
public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
if (astring.length < 1) {
throw new ExceptionUsage("commands.worldborder.usage");
} else {
WorldBorder worldborder = this.d();
double d0;
double d1;
long i;
if (astring[0].equals("set")) {
if (astring.length != 2 && astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.set.usage");
}
d0 = worldborder.j();
d1 = a(astring[1], 1.0D, 6.0E7D);
i = astring.length > 2 ? a(astring[2], 0L, 9223372036854775L) * 1000L : 0L;
if (i > 0L) {
worldborder.transitionSizeBetween(d0, d1, i);
if (d0 > d1) {
a(icommandlistener, this, "commands.worldborder.setSlowly.shrink.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)), Long.toString(i / 1000L));
} else {
a(icommandlistener, this, "commands.worldborder.setSlowly.grow.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)), Long.toString(i / 1000L));
}
} else {
worldborder.setSize(d1);
a(icommandlistener, this, "commands.worldborder.set.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)));
}
} else if (astring[0].equals("add")) {
if (astring.length != 2 && astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.add.usage");
}
d0 = worldborder.getSize();
d1 = d0 + a(astring[1], -d0, 6.0E7D - d0);
i = worldborder.i() + (astring.length > 2 ? a(astring[2], 0L, 9223372036854775L) * 1000L : 0L);
if (i > 0L) {
worldborder.transitionSizeBetween(d0, d1, i);
if (d0 > d1) {
a(icommandlistener, this, "commands.worldborder.setSlowly.shrink.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)), Long.toString(i / 1000L));
} else {
a(icommandlistener, this, "commands.worldborder.setSlowly.grow.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)), Long.toString(i / 1000L));
}
} else {
worldborder.setSize(d1);
a(icommandlistener, this, "commands.worldborder.set.success", String.format("%.1f", Double.valueOf(d1)), String.format("%.1f", Double.valueOf(d0)));
}
} else if (astring[0].equals("center")) {
if (astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.center.usage");
}
BlockPosition blockposition = icommandlistener.getChunkCoordinates();
double d2 = b((double) blockposition.getX() + 0.5D, astring[1], true);
double d3 = b((double) blockposition.getZ() + 0.5D, astring[2], true);
worldborder.setCenter(d2, d3);
a(icommandlistener, this, "commands.worldborder.center.success", Double.valueOf(d2), Double.valueOf(d3));
} else if (astring[0].equals("damage")) {
if (astring.length < 2) {
throw new ExceptionUsage("commands.worldborder.damage.usage");
}
if (astring[1].equals("buffer")) {
if (astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.damage.buffer.usage");
}
d0 = a(astring[2], 0.0D);
d1 = worldborder.getDamageBuffer();
worldborder.setDamageBuffer(d0);
a(icommandlistener, this, "commands.worldborder.damage.buffer.success", String.format("%.1f", Double.valueOf(d0)), String.format("%.1f", Double.valueOf(d1)));
} else if (astring[1].equals("amount")) {
if (astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.damage.amount.usage");
}
d0 = a(astring[2], 0.0D);
d1 = worldborder.getDamageAmount();
worldborder.setDamageAmount(d0);
a(icommandlistener, this, "commands.worldborder.damage.amount.success", String.format("%.2f", Double.valueOf(d0)), String.format("%.2f", Double.valueOf(d1)));
}
} else if (astring[0].equals("warning")) {
if (astring.length < 2) {
throw new ExceptionUsage("commands.worldborder.warning.usage");
}
int j = a(astring[2], 0);
int k;
if (astring[1].equals("time")) {
if (astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.warning.time.usage");
}
k = worldborder.getWarningTime();
worldborder.setWarningTime(j);
a(icommandlistener, this, "commands.worldborder.warning.time.success", Integer.valueOf(j), Integer.valueOf(k));
} else if (astring[1].equals("distance")) {
if (astring.length != 3) {
throw new ExceptionUsage("commands.worldborder.warning.distance.usage");
}
k = worldborder.getWarningDistance();
worldborder.setWarningDistance(j);
a(icommandlistener, this, "commands.worldborder.warning.distance.success", Integer.valueOf(j), Integer.valueOf(k));
}
} else {
if (!astring[0].equals("get")) {
throw new ExceptionUsage("commands.worldborder.usage");
}
d0 = worldborder.getSize();
icommandlistener.setCommandStat(CommandObjectiveExecutor.EnumCommandResult.QUERY_RESULT, MathHelper.floor(d0 + 0.5D));
icommandlistener.sendMessage(new ChatMessage("commands.worldborder.get.success", String.format("%.0f", Double.valueOf(d0))));
}
}
}
protected WorldBorder d() {
return MinecraftServer.getServer().worldServer[0].getWorldBorder();
}
public List tabComplete(ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
return astring.length == 1 ? a(astring, "set", "center", "damage", "warning", "add", "get") : (astring.length == 2 && astring[0].equals("damage") ? a(astring, "buffer", "amount") : (astring.length >= 2 && astring.length <= 3 && astring[0].equals("center") ? b(astring, 1, blockposition) : (astring.length == 2 && astring[0].equals("warning") ? a(astring, "time", "distance") : null)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy