SteamWar/BauSystem2.0
Archiviert
12
0

Update Warp
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Chaoscaot 2021-11-11 22:01:08 +01:00
Ursprung e1bf93ab3a
Commit 8b3b2f9ddb

Datei anzeigen

@ -31,6 +31,7 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Getter
public class Warp {
@ -38,22 +39,19 @@ public class Warp {
private final Instant created;
private final YAPIONObject object;
private String name;
private double x;
private double y;
private double z;
private float yaw;
private float pitch;
private Location location;
private Material mat;
private String creator;
private Warp(YAPIONObject object) {
this.object = object;
name = object.getPlainValue("name");
x = object.getPlainValue("x");
y = object.getPlainValue("y");
z = object.getPlainValue("z");
yaw = object.getPlainValue("yaw");
pitch = object.getPlainValue("pitch");
double x = object.getPlainValue("x");
double y = object.getPlainValue("y");
double z = object.getPlainValue("z");
float yaw = object.getPlainValue("yaw");
float pitch = object.getPlainValue("pitch");
location = new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch);
mat = Material.getMaterial(object.getPlainValue("material"));
creator = object.getPlainValue("owner");
created = Instant.ofEpochSecond(object.getPlainValue("time"));
@ -80,11 +78,7 @@ public class Warp {
public static Warp createWarp(String name, double x, double y, double z, float yaw, float pitch, Material mat, String creator) {
Warp warp = new Warp();
warp.setName(name);
warp.setX(x);
warp.setY(y);
warp.setZ(z);
warp.setYaw(yaw);
warp.setPitch(pitch);
warp.setLocation(new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch));
warp.setMat(mat);
warp.setCreator(creator);
YAPIONArray warpsObject = WorldData.getWarpData();
@ -103,31 +97,6 @@ public class Warp {
object.add("name", name);
}
public void setX(double x) {
this.x = x;
object.add("x", x);
}
public void setY(double y) {
this.y = y;
object.add("y", y);
}
public void setZ(double z) {
this.z = z;
object.add("z", z);
}
public void setYaw(float yaw) {
this.yaw = yaw;
object.add("yaw", yaw);
}
public void setPitch(float pitch) {
this.pitch = pitch;
object.add("pitch", pitch);
}
public void setMat(Material mat) {
this.mat = mat;
object.add("material", mat.name());
@ -138,18 +107,55 @@ public class Warp {
object.add("owner", creator);
}
public void setLocation(Location location) {
this.location = location;
}
public void delete() {
YAPIONArray warpsObject = WorldData.getWarpData();
warpsObject.removeIf(yapionAnyType -> ((YAPIONObject) yapionAnyType).getPlainValue("name").equals(name));
}
public Location toLocation() {
return new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch);
public void teleport(Player player) {
player.teleport(location, PlayerTeleportEvent.TeleportCause.PLUGIN);
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
}
public void teleport(Player player) {
Location loc = toLocation();
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
player.playSound(loc, Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
public void normalize(String str) {
/*
x > x
y > y
z > z
w > yaw
p > pitch
*/
if(str.contains("x")) {
location.setX(0.5 + location.getBlockX());
}
if(str.contains("y")) {
location.setY(location.getBlockY());
}
if(str.contains("z")) {
location.setZ(0.5 + location.getBlockZ());
}
if(str.contains("w")) {
location.setYaw(Location.normalizeYaw(location.getYaw()));
}
if(str.contains("p")) {
location.setPitch(Location.normalizePitch(location.getPitch()));
}
save();
}
private void save() {
object.add("name", name);
YAPIONObject loc = new YAPIONObject();
loc.add("x", location.getX());
loc.add("y", location.getY());
loc.add("z", location.getZ());
loc.add("yaw", location.getYaw());
loc.add("pitch", location.getPitch());
object.add("location", loc);
object.add("creator", creator);
}
}