mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 15:09:24 +00:00
Initial commit
This commit is contained in:
28
common/pom.xml
Normal file
28
common/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>me.zimzaza4</groupId>
|
||||
<artifactId>GeyserUtils</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>geyserutils-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.zimzaza4.geyserutils.common.channel;
|
||||
|
||||
public class GeyserUtilsChannels {
|
||||
public static final String MAIN = "geyserutils:main";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.zimzaza4.geyserutils.common.form.element;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Value;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Accessors( fluent = true )
|
||||
public class NpcDialogueButton implements Serializable {
|
||||
private String text;
|
||||
private List<String> commands;
|
||||
private ButtonMode mode;
|
||||
|
||||
public enum ButtonMode {
|
||||
BUTTON_MODE,
|
||||
ON_ENTER,
|
||||
ON_EXIT
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CameraShakePacket extends Packet {
|
||||
|
||||
float intensity;
|
||||
float duration;
|
||||
int type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.zimzaza4.geyserutils.common.form.element.NpcDialogueButton;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Accessors(fluent = true)
|
||||
@Getter
|
||||
@Setter
|
||||
public class NpcDialogueFormDataPacket extends Packet {
|
||||
|
||||
String formId;
|
||||
String title;
|
||||
String dialogue;
|
||||
String skinData;
|
||||
int bindEntity;
|
||||
List<NpcDialogueButton> buttons;
|
||||
String action;
|
||||
boolean hasNextForm;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
public class NpcFormResponsePacket extends Packet {
|
||||
String formId;
|
||||
int buttonId;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public abstract class Packet implements Serializable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.zimzaza4.geyserutils.common.util;
|
||||
|
||||
import me.zimzaza4.geyserutils.common.packet.Packet;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class CustomPayloadPacketUtils {
|
||||
|
||||
public static byte[] encodePacket(Packet packet) {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream outputStream = new ObjectOutputStream(byteArrayOutputStream)) {
|
||||
outputStream.writeObject(packet);
|
||||
outputStream.flush();
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Packet decodePacket(byte[] bytes) {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
||||
try (ObjectInputStream inputStream = new ObjectInputStream(byteArrayInputStream)) {
|
||||
return (Packet) inputStream.readObject();
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user