Skip to content

Commit

Permalink
Update to v1.20.6-0.1.2 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitch215 authored Jun 1, 2024
2 parents b23ca98 + c550f5e commit af55228
Show file tree
Hide file tree
Showing 102 changed files with 4,237 additions and 127 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ contact_links:
about: Download the SocketMC Mod on Modrinth
- name: Jenkins
url: https://ci.codemc.io/job/gmitch215/job/SocketMC/
about: View the Jenkins builds for SocketMC
about: View the Jenkins builds for SocketMC
- name: Trello
url: https://trello.com/b/29CtpNlW/socketmc
about: View the Trello board for SocketMC
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/
build/
.gradle/
.kotlin/
logs/
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ You can download them from the following locations:

![GitHub release (latest by date)](https://img.shields.io/github/v/release/gmitch215/SocketMC)
[![Static Badge](https://img.shields.io/badge/documentation-javadoc-yellow)](https://socketmc.gmitch215.xyz/)
[![Static Badge](https://img.shields.io/badge/wiki-github-dgreen)](https://github.com/gmitch215/SocketMC/wiki)
[![Static Badge](https://img.shields.io/badge/detailed_wiki-gitbook-dgreen)](https://docs.gmitch215.xyz/socketmc/)

<details>
<summary>Maven</summary>
Expand All @@ -64,13 +66,20 @@ You can download them from the following locations:
</repositories>

<dependencies>
<!-- Include Core Module -->
<dependency>
<groupId>me.gamercoder215.socketmc</groupId>
<artifactId>socketmc-core</artifactId>
<version>[VERSION]</version>
</dependency>

<dependency>
<groupId>me.gamercoder215.socketmc</groupId>
<artifactId>socketmc-spigot</artifactId>
<version>[VERSION]</version>
</dependency>

<!-- Alternatively, use the Paper Build -->
<!-- Alternatively, use the Paper Build instead of Spigot -->
<dependency>
<groupId>me.gamercoder215.socketmc</groupId>
<artifactId>socketmc-paper</artifactId>
Expand All @@ -91,6 +100,8 @@ repositories {
}
dependencies {
// Include Core Module
implementation 'me.gamercoder215.socketmc:socketmc-core:[VERSION]'
implementation 'me.gamercoder215.socketmc:socketmc-spigot:[VERSION]'
// Alternatively, use the Paper Build
Expand All @@ -108,6 +119,8 @@ repositories {
}

dependencies {
// Include Core Module
implementation("me.gamercoder215.socketmc:socketmc-core:[VERSION]")
implementation("me.gamercoder215.socketmc:socketmc-spigot:[VERSION]")

// Alternatively, use the Paper Build
Expand Down
18 changes: 14 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import groovy.json.JsonSlurper
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.net.*

plugins {
Expand Down Expand Up @@ -48,7 +49,7 @@ tasks {

allprojects {
val mc = "1.20.6"
val pr = "0.1.1"
val pr = "0.1.2"

project.ext["minecraft_version"] = mc
project.ext["project_version"] = pr
Expand Down Expand Up @@ -141,7 +142,15 @@ subprojects {
}

compileKotlin {
kotlinOptions.jvmTarget = jdk.toString()
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(jdk.toString()))
}
}

javadoc {
options {
showFromProtected()
}
}

jacocoTestReport {
Expand All @@ -168,8 +177,9 @@ subprojects {
}

java {
sourceCompatibility = jdk
targetCompatibility = jdk
toolchain {
languageVersion.set(JavaLanguageVersion.of(jdk.toString()))
}
}

dependencies {
Expand Down
14 changes: 14 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ tasks {
javadoc {
enabled = true

val s = File.separator
val packages = sourceSets["main"].allJava.map { it.path }
.map { it
.substringAfter("src${s}main${s}java${s}")
.substringBeforeLast(s)
}
.toSet()
.filter { it.isNotEmpty() }
for (pkg in packages) {
val packageInfo = file("src/main/javadoc/$pkg/package-info.java")
if (!packageInfo.exists())
throw IllegalStateException("Package ${pkg.replace(s, ".")} does not have a package-info.java file")
}

sourceSets["main"].allJava.srcDir("src/main/javadoc")

options {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package me.gamercoder215.socketmc.instruction;

import me.gamercoder215.socketmc.instruction.util.Identifier;
import me.gamercoder215.socketmc.instruction.util.Text;
import me.gamercoder215.socketmc.instruction.util.render.RenderBuffer;
import me.gamercoder215.socketmc.screen.AbstractScreen;
import me.gamercoder215.socketmc.util.Identifier;
import me.gamercoder215.socketmc.util.render.text.Text;
import me.gamercoder215.socketmc.util.render.RenderBuffer;
import me.gamercoder215.socketmc.log.AuditLog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -76,6 +77,16 @@ public final class Instruction implements Serializable {
*/
public static final String OPEN_BOOK_AND_QUILL = "open_book_and_quill";

/**
* Instruction to open a GUI screen on the client's screen.
*/
public static final String OPEN_SCREEN = "open_screen";

/**
* Instruction to close the current GUI screen on the client's screen.
*/
public static final String CLOSE_SCREEN = "close_screen";

@Serial
private static final long serialVersionUID = -4177824277470078500L;

Expand Down Expand Up @@ -867,23 +878,6 @@ public static Instruction drawHorizontalLine(int x, int y, int width, @NotNull C
return new Instruction(DRAW_SHAPE, List.of("line_h", x, y, width, color.getRGB() | (alpha << 24), millis));
}

/**
* Creates a {@link #PLAY_AUDIO} instruction.
* @param file Path to Audio File
* @return Play Audio Instruction
*/
@NotNull
public static Instruction playAudio(@NotNull File file) {
if (file == null) throw new IllegalArgumentException("File cannot be null");
if (!file.exists()) throw new IllegalArgumentException("File does not exist");

try {
return playAudio(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeException("Failed to read audio file", e);
}
}

/**
* Creates a {@link #DRAW_BUFFER} instruction.
* @param buffer Render Buffer
Expand Down Expand Up @@ -912,6 +906,23 @@ public static Instruction drawBuffer(@NotNull RenderBuffer buffer, long millis)
return new Instruction(DRAW_BUFFER, List.of(buffer, millis));
}

/**
* Creates a {@link #PLAY_AUDIO} instruction.
* @param file Path to Audio File
* @return Play Audio Instruction
*/
@NotNull
public static Instruction playAudio(@NotNull File file) {
if (file == null) throw new IllegalArgumentException("File cannot be null");
if (!file.exists()) throw new IllegalArgumentException("File does not exist");

try {
return playAudio(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeException("Failed to read audio file", e);
}
}

/**
* Creates a {@link #PLAY_AUDIO} instruction.
* @param file Input Stream to Audio File
Expand Down Expand Up @@ -1084,6 +1095,27 @@ public static Instruction openBookAndQuill() {
return new Instruction(OPEN_BOOK_AND_QUILL, List.of());
}

/**
* Creates a {@link #OPEN_SCREEN} instruction.
* @param screen Screen to Open
* @return Open Screen Instruction
*/
@NotNull
public static Instruction openScreen(@NotNull AbstractScreen screen) {
if (screen == null) throw new IllegalArgumentException("Screen cannot be null");

return new Instruction(OPEN_SCREEN, List.of(screen));
}

/**
* Creates a {@link #CLOSE_SCREEN} instruction.
* @return Close Screen Instruction
*/
@NotNull
public static Instruction closeScreen() {
return new Instruction(CLOSE_SCREEN, List.of());
}

// <editor-fold defaultstate="collapsed" desc="Instruction Serialization">
// Serialization

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.gamercoder215.socketmc.instruction.builder;

import me.gamercoder215.socketmc.instruction.Instruction;
import me.gamercoder215.socketmc.instruction.util.Identifier;
import me.gamercoder215.socketmc.util.Identifier;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
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);
}
}

}
Loading

0 comments on commit af55228

Please sign in to comment.