-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
102 changed files
with
4,237 additions
and
127 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.idea/ | ||
build/ | ||
.gradle/ | ||
.kotlin/ | ||
logs/ |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
core/src/main/java/me/gamercoder215/socketmc/instruction/builder/TextureBuilder.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
70 changes: 70 additions & 0 deletions
70
core/src/main/java/me/gamercoder215/socketmc/screen/AbstractScreen.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,70 @@ | ||
package me.gamercoder215.socketmc.screen; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.*; | ||
|
||
/** | ||
* Represents a screen that can be displayed to the user. | ||
* <strong>This class is not legal for implementation!</strong> | ||
*/ | ||
public abstract class AbstractScreen implements Narratable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 5312276945725639371L; | ||
|
||
/** | ||
* Constructs a new screen. | ||
*/ | ||
protected AbstractScreen() {} | ||
|
||
/** | ||
* Gets the title of this screen. | ||
* @return Title in JSON Format | ||
*/ | ||
@NotNull | ||
public abstract String getTitleJSON(); | ||
|
||
@Override | ||
public String getNarrationMessageJSON() { | ||
return getTitleJSON(); | ||
} | ||
|
||
/** | ||
* Serializes this screen to a byte array. | ||
* @return Byte Array | ||
*/ | ||
@NotNull | ||
public final byte[] toByteArray() { | ||
try { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
ObjectOutputStream oos = new ObjectOutputStream(baos); | ||
|
||
oos.writeObject(this); | ||
oos.close(); | ||
|
||
return baos.toByteArray(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Deserializes a screen from a byte array. | ||
* @param bytes Byte Array | ||
* @return Deserialized Screem | ||
*/ | ||
@NotNull | ||
public static AbstractScreen fromByteArray(byte[] bytes) { | ||
try { | ||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | ||
ObjectInputStream ois = new ObjectInputStream(bais); | ||
|
||
ois.readObject(); | ||
return (AbstractScreen) ois.readObject(); | ||
} catch (IOException | ClassNotFoundException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.