Skip to content

Commit 6866522

Browse files
committed
feat: use formal terms
1 parent 9529961 commit 6866522

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/main/java/com/mcdiamondfire/proto/PluginMessages.java renamed to src/main/java/com/mcdiamondfire/proto/ModAPIMessages.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import java.util.*;
66

77
/**
8-
* Holds a mapping of plugin message classes to their string identifiers.
8+
* Holds a mapping of ModAPI message classes to their string identifiers.
99
*/
10-
public final class PluginMessages {
10+
public final class ModAPIMessages {
1111

1212
private static final Map<Class<? extends Message>, String> messages = new HashMap<>();
1313

@@ -25,22 +25,22 @@ public final class PluginMessages {
2525
messages.put(PlayerSwitchMode.class, "player_switch_mode");
2626
}
2727

28-
private PluginMessages() {
28+
private ModAPIMessages() {
2929
// Prevent instantiation.
3030
}
3131

3232
/**
33-
* Gets the identifier for a given plugin message class.
33+
* Gets the identifier for a given ModAPI message class.
3434
*
35-
* @param clazz the plugin message class
35+
* @param clazz the ModAPI message class
3636
* @return the identifier for the message class, or null if not registered
3737
*/
3838
public static String getMessageId(final Class<? extends Message> clazz) {
3939
return messages.get(clazz);
4040
}
4141

4242
/**
43-
* Gets an unmodifiable view of the registered plugin messages.
43+
* Gets an unmodifiable view of the registered ModAPI messages.
4444
*
4545
* @return a mapping of message classes to their identifiers
4646
*/

src/main/java/com/mcdiamondfire/proto/PluginMessageUtility.java renamed to src/main/java/com/mcdiamondfire/proto/ModAPIUtility.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,40 @@
77
import java.lang.reflect.InvocationTargetException;
88

99
/**
10-
* Utility class for serializing plugin messages to JSON format.
11-
*
12-
* @since 1.0.0
10+
* Utility class for serializing ModAPI messages to JSON format.
1311
*/
14-
public final class PluginMessageUtility {
12+
public final class ModAPIUtility {
1513

16-
private PluginMessageUtility() {
14+
private ModAPIUtility() {
1715
// Prevent instantiation.
1816
}
1917

2018
/**
21-
* Serializes a protobuf message to a JSON string,
19+
* Serializes a Protocol Message to a JSON string,
2220
* including the packet ID for identification on the receiving end.
2321
*
24-
* @param message the protobuf message to serialize
25-
* @return the serialized JSON string with packet ID
22+
* @param message the Protocol Message to serialize
23+
* @return the serialized JSON string with its packet ID included
2624
* @throws InvalidProtocolBufferException if serialization fails
2725
*/
2826
public static String serializeMessage(final Message message) throws InvalidProtocolBufferException {
2927
final String json = JsonFormat.printer().print(message);
3028
final JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
31-
jsonObject.add("packet_id", new JsonPrimitive(PluginMessages.getMessageId(message.getClass())));
29+
jsonObject.add("packet_id", new JsonPrimitive(ModAPIMessages.getMessageId(message.getClass())));
3230
return jsonObject.toString();
3331
}
3432

3533
/**
36-
* Deserializes a JSON string back into a protobuf message of the specified class.
34+
* Deserializes a JSON string back into a Protocol Message of the specified class.
3735
*
3836
* @param json the JSON string to deserialize
39-
* @param clazz the class of the protobuf message to deserialize into
40-
* @param <T> the type of the protobuf message
41-
* @return the deserialized protobuf message
37+
* @param clazz the class of the Protocol Message to deserialize into
38+
* @param <T> the type of the Protocol Message
39+
* @return the deserialized Protocol Message
4240
* @throws InvalidProtocolBufferException if deserialization fails
4341
* @throws JsonSyntaxException if the JSON is not properly formatted
4442
* @throws IllegalStateException if the JSON does not contain a valid packet ID
45-
* @throws RuntimeException if reflection fails
43+
* @throws RuntimeException if reflection fails to create a new builder instance
4644
* @throws ClassCastException if the built message is not of the expected type
4745
*/
4846
public static <T extends Message> T deserializeMessage(final String json, final Class<T> clazz) throws InvalidProtocolBufferException {

0 commit comments

Comments
 (0)