flewkey
/
mc.2a03.party
Archived
1
0
Fork 0

Move parsePosition method to PlayerPosition constructor.

Signed-off-by: Ryan Fox <flewkey@2a03.party>
master
Ryan Fox 3 years ago
parent 8bb516465d
commit 75249a6a42
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
  1. 2
      src/party/_2a03/mc/command/SpawnCommand.java
  2. 19
      src/party/_2a03/mc/server/Config.java
  3. 13
      src/party/_2a03/mc/server/PlayerPosition.java

@ -13,7 +13,7 @@ import party._2a03.mc.server.PlayerPosition;
public class SpawnCommand {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
LiteralArgumentBuilder<CommandSource> literalargumentbuilder = Commands.func_197057_a("spawn").executes((source) -> {
PlayerPosition position = Config.parsePosition(Config.getData("spawn"));
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
if (position.world == null) {
if (source.getSource().func_197034_c(2)) {
source.getSource().func_197030_a(new TranslationTextComponent("Spawn not found, do /spawn set"), false);

@ -45,7 +45,7 @@ public class Config {
JSONObject item = members.getJSONObject(i);
String item_uuid = item.getString("uuid");
if (item_uuid.equals(uuid)) {
home = parsePosition(item.getJSONArray("home"));
home = new PlayerPosition(item.getJSONArray("home"));
}
}
if (home == null) {
@ -80,20 +80,9 @@ public class Config {
json.put(key, data);
saveConfig();
}
public static PlayerPosition parsePosition(JSONArray data) {
double x = data.getDouble(0);
double y = data.getDouble(1);
double z = data.getDouble(2);
float yaw = data.getFloat(3);
float pitch = data.getFloat(4);
int dimension_id = data.getInt(5);
if (dimension_id != -2) {
ServerWorld world = worlds.get(DimensionType.func_186069_a(dimension_id));
return new PlayerPosition(x, y, z, yaw, pitch, world);
} else {
return new PlayerPosition();
}
public static ServerWorld getWorld(int dimension_id) {
return worlds.get(DimensionType.func_186069_a(dimension_id));
}
private static void saveConfig() {

@ -2,6 +2,7 @@ package party._2a03.mc.server;
import org.json.JSONArray;
import net.minecraft.world.server.ServerWorld;
import party._2a03.mc.server.Config;
public class PlayerPosition {
public double x;
@ -13,6 +14,18 @@ public class PlayerPosition {
public PlayerPosition() {
}
public PlayerPosition(JSONArray data) {
int dimension_id = data.getInt(5);
if (dimension_id != -2) {
this.x = data.getDouble(0);
this.y = data.getDouble(1);
this.z = data.getDouble(2);
this.yaw = data.getFloat(3);
this.pitch = data.getFloat(4);
this.world = Config.getWorld(dimension_id);
}
}
public PlayerPosition(double p_x, double p_y, double p_z, float p_yaw, float p_pitch, ServerWorld p_world) {
this.x = p_x;