-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d69a14
commit 0609bc6
Showing
8 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/de/oliver/fancyholograms/storage/json/JsonAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package de.oliver.fancyholograms.storage.json; | ||
|
||
import de.oliver.fancyholograms.api.data.HologramData; | ||
import de.oliver.fancyholograms.api.data.TextHologramData; | ||
import de.oliver.fancyholograms.storage.json.model.*; | ||
|
||
public class JsonAdapter { | ||
|
||
public static JsonDataUnion toJson(TextHologramData data) { | ||
JsonHologramData hologramData = new JsonHologramData( | ||
data.getName(), | ||
data.getType(), | ||
new JsonLocation( | ||
data.getLocation().getWorld().getName(), | ||
data.getLocation().getX(), | ||
data.getLocation().getY(), | ||
data.getLocation().getZ(), | ||
data.getLocation().getYaw(), | ||
data.getLocation().getPitch() | ||
), | ||
data.getVisibilityDistance(), | ||
data.getVisibility(), | ||
data.getLinkedNpcName() | ||
); | ||
|
||
JsonDisplayHologramData displayHologramData = new JsonDisplayHologramData( | ||
new JsonVec3f( | ||
data.getScale().x(), | ||
data.getScale().y(), | ||
data.getScale().z() | ||
), | ||
new JsonVec3f( | ||
data.getTranslation().x(), | ||
data.getTranslation().y(), | ||
data.getTranslation().z() | ||
), | ||
data.getShadowRadius(), | ||
data.getShadowStrength(), | ||
data.getBrightness().getBlockLight(), | ||
data.getBrightness().getSkyLight(), | ||
data.getBillboard() | ||
); | ||
|
||
JsonTextHologramData textHologramData = new JsonTextHologramData( | ||
data.getText(), | ||
data.hasTextShadow(), | ||
data.isSeeThrough(), | ||
data.getTextAlignment(), | ||
data.getTextUpdateInterval(), | ||
data.getBackground().toString() | ||
); | ||
|
||
return new JsonDataUnion( | ||
hologramData, | ||
displayHologramData, | ||
textHologramData | ||
); | ||
} | ||
|
||
public static HologramData fromJson(JsonDataUnion data) { | ||
return null; | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...r/fancyholograms/storage/JsonStorage.java → ...cyholograms/storage/json/JsonStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonDataUnion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
public record JsonDataUnion( | ||
JsonHologramData hologram_data, | ||
JsonDisplayHologramData display_hologram_data, | ||
JsonTextHologramData text_hologram_data | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonDisplayHologramData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
import org.bukkit.entity.Display; | ||
|
||
public record JsonDisplayHologramData( | ||
JsonVec3f scale, | ||
JsonVec3f translation, | ||
float shadow_radius, | ||
float shadow_strength, | ||
int block_brightness, | ||
int sky_brightness, | ||
Display.Billboard billboard | ||
) { | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonHologramData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
import de.oliver.fancyholograms.api.data.property.Visibility; | ||
import de.oliver.fancyholograms.api.hologram.HologramType; | ||
|
||
public record JsonHologramData( | ||
String name, | ||
HologramType type, | ||
JsonLocation location, | ||
int visibilityDistance, | ||
Visibility visibility, | ||
String linkedNpcName | ||
) { | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
public record JsonLocation( | ||
String world, | ||
double x, | ||
double y, | ||
double z, | ||
float yaw, | ||
float pitch | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonTextHologramData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
import org.bukkit.entity.TextDisplay; | ||
|
||
import java.util.List; | ||
|
||
public record JsonTextHologramData( | ||
List<String> text, | ||
boolean text_shadow, | ||
boolean see_through, | ||
TextDisplay.TextAlignment text_alignment, | ||
int text_update_interval, | ||
String background_color | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/de/oliver/fancyholograms/storage/json/model/JsonVec3f.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.oliver.fancyholograms.storage.json.model; | ||
|
||
public record JsonVec3f( | ||
float x, | ||
float y, | ||
float z | ||
) { | ||
} |