Skip to content

Commit 696aeee

Browse files
committed
feat: completely re-organize proto files
1 parent d70d917 commit 696aeee

15 files changed

+317
-292
lines changed

src/main/java/com/mcdiamondfire/proto/ModAPIMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.mcdiamondfire.proto.messages.clientbound.plot.*;
66
import com.mcdiamondfire.proto.messages.clientbound.server.*;
77
import com.mcdiamondfire.proto.messages.serverbound.player.*;
8+
import com.mcdiamondfire.proto.messages.serverbound.plot.C2SCodeOperation;
9+
import com.mcdiamondfire.proto.messages.serverbound.plot.C2SMultiCodeOperations;
810
import com.mcdiamondfire.proto.messages.serverbound.server.C2SHandshakeRequest;
911

1012
import java.util.*;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
syntax = "proto3";
2+
import "common/data_type.proto";
3+
import "common/common_code.proto";
4+
5+
option java_package = "com.mcdiamondfire.proto.messages.clientbound.player";
6+
option java_multiple_files = true;
7+
8+
// Sent when the player switches modes.
9+
message S2CPlayerSwitchMode {
10+
PlayerMode mode = 1; // The mode the player is in.
11+
}
12+
13+
// Sent when the player opens a code chest.
14+
message S2CChestReference {
15+
ChestReference reference = 1; // The action reference.
16+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
syntax = "proto3";
2+
import "common/data_type.proto";
3+
import "common/common_player.proto";
4+
import "common/common_plot.proto";
5+
6+
option java_package = "com.mcdiamondfire.proto.messages.clientbound.plot";
7+
option java_multiple_files = true;
8+
9+
// Sent when the player joins a plot.
10+
message S2CPlotInfo {
11+
// Represents a player in a plot.
12+
message PlotPlayer {
13+
string user_name = 1; // The name of the player.
14+
string user_uuid = 2; // The UUID of the player (36 characters including dashes).
15+
bool is_owner = 3; // Whether the player is the owner of the plot.
16+
bool is_developer = 4; // Whether the player has developer permissions on the plot.
17+
bool is_builder = 5; // Whether the player has builder permissions on the plot.
18+
PlayerMode mode = 6; // The mode the player is in.
19+
}
20+
21+
int32 id = 1; // The identifier of the plot.
22+
string name = 2; // The name of the plot as a serialized component in JSON format.
23+
string owner_name = 3; // The name of the owner of the plot.
24+
string owner_uuid = 4; // The UUID of the owner of the plot (36 characters including dashes).
25+
int32 plot_size = 5; // The size of the plot (1 = Basic, 2 = Large, 3 = Massive, 4 = Mega).
26+
Region build_region = 6; // The build region of the plot.
27+
Region code_region = 7; // The code region of the plot.
28+
Region spawn_pos = 8; // The spawn location of the plot.
29+
bool is_owner = 11; // Whether the player is the owner of the plot.
30+
bool is_developer = 12; // Whether the player has developer permissions on the plot, is an administrator, or is the support member in a session.
31+
bool is_builder = 13; // Whether the player has builder permissions on the plot, is an administrator, or is the support member in a session.
32+
repeated PlotTag tags = 14; // The tags of this plot (e.g. "adventure", "combat", ...).
33+
string handle = 15; // The handle of the plot, or empty if none is set.
34+
repeated PlotPlayer players = 16; // The players currently on the plot.
35+
}
36+
37+
// Sent as a response to a C2SCodeOperation message,
38+
// error is true if the operation failed (see each operation for details),
39+
// template is not empty only if a get operation succeeded.
40+
message S2CCodeOperationResult {
41+
// Represents an error that occurred while performing a code operation.
42+
enum Error {
43+
NONE = 0; // No error, the operation succeeded.
44+
NO_PERMISSION = 1; // The player does not have developer permissions on the plot.
45+
NO_LOCATION = 2; // No location was provided for an operation that requires one.
46+
INVALID_LOCATION = 3; // The provided location is not within the code region of the plot or is an invalid code block position.
47+
NO_ACTION = 4; // No action was provided for an operation that requires one.
48+
ACTION_NOT_FOUND = 5; // The provided action or line starter was not found on the plot.
49+
NO_LOCATION_OR_TEMPLATE = 6; // Either a location or a template were not provided for an operation that requires both.
50+
INVALID_LOCATION_OR_TEMPLATE = 7; // The provided location is invalid or the provided template is not a valid code template.
51+
TEMPLATE_NOT_FIT = 8; // The provided template does not fit in the code region at the provided location.
52+
INVALID_TEMPLATE = 10; // The provided template is not a valid code template.
53+
INTERNAL_ERROR = 9; // An internal error occurred while performing the operation.
54+
NO_OPERATION = 11; // No operation was provided.
55+
}
56+
57+
oneof result {
58+
Error error = 1; // true if the operation failed, false otherwise
59+
string template = 2; // The template JSON string, only if a get operation succeeded.
60+
}
61+
}
62+
63+
// Sent as a response to a C2SMultiCodeOperations message,
64+
// contains the results of all operations requested.
65+
message S2CMultiCodeOperationsResult {
66+
repeated S2CCodeOperationResult results = 1; // The results of all operations requested.
67+
}
68+
69+
// Sent when the player joins a plot,
70+
// requires the player to have developer permissions on the plot.
71+
message S2CPlotLineStarters {
72+
repeated CodeLineStarter line_starter = 1; // The line starters on the plot.
73+
}
74+
75+
// Sent when a line starter is added or removed from the plot,
76+
// requires the player to have developer permissions on the plot.
77+
message S2CPlotLineStarterUpdate {
78+
// Represents an action performed on a line starter.
79+
enum Action {
80+
ADD = 0; // A line starter was added.
81+
REMOVE = 1; // A line starter was removed.
82+
}
83+
CodeLineStarter line_starter = 1; // The line starter that was added or removed.
84+
Action action = 2; // The action performed.
85+
}
86+
87+
// Sent when the plot finishes a lag measurement,
88+
// requires the player to have developer permissions on the plot,
89+
// and be profiling the plot.
90+
message S2CPlotProfiling {
91+
int32 cpu_usage = 1; // The CPU usage of the plot in percentage (0 to 100).
92+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
syntax = "proto3";
2+
import "common/common_player.proto";
3+
import "common/common_server.proto";
4+
5+
option java_package = "com.mcdiamondfire.proto.messages.clientbound.server";
6+
option java_multiple_files = true;
7+
8+
// Sent by the server when the player connects to it, respond with C2SHandshakeRequest.
9+
message S2CHello {
10+
11+
}
12+
13+
// Sent as a response to a C2SHandshakeRequest message.
14+
message S2CHandshakeResponse {
15+
enum Error {
16+
NONE = 0; // No error, the connection was successful.
17+
INVALID_PROTOCOL = 1; // The given protocol version is invalid.
18+
INCOMPATIBLE_PROTOCOL = 2; // The given protocol version is incompatible with the server.
19+
ALREADY_CONNECTED = 3; // The player is already connected.
20+
}
21+
message Success {
22+
ServerInfo server_info = 1; // The server info.
23+
PlayerInfo player_info = 2; // The player's info.
24+
}
25+
oneof result {
26+
Error error = 1; // The error that occurred, if any.
27+
Success success = 2; // The server and player info, if the connection was successful.
28+
}
29+
}
30+
31+
// Sent when the player joins the server.
32+
message S2CServerBooster {
33+
// Represents an active booster.
34+
message ActiveBooster {
35+
bool tipped = 1; // Whether the booster was tipped by the player.
36+
int32 multiplier = 2; // The multiplier of the booster (e.g. 2 for 2x).
37+
int64 time_remaining = 3; // The time remaining of the booster in milliseconds.
38+
string user_name = 4; // The name of the player who activated the booster.
39+
string user_uuid = 5; // The UUID of the player who activated the booster (36 characters including dashes).
40+
}
41+
42+
bool is_active = 1; // Whether a booster is currently active.
43+
optional ActiveBooster active_booster = 2; // The active booster, if any.
44+
}

src/main/proto/clientbound_plot.proto

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/main/proto/clientbound_server.proto

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
11
syntax = "proto3";
2-
import "data_type.proto";
32

4-
option java_package = "com.mcdiamondfire.proto.messages.clientbound.player";
3+
option java_package = "com.mcdiamondfire.proto.messages.common";
54
option java_multiple_files = true;
65

7-
// Represents general information about the player.
8-
message PlayerInfo {
9-
PlayerCurrency currency = 1; // The player's currency information.
10-
PlayerPermissions permissions = 2; // The player's permissions.
11-
}
12-
13-
// Represents the player's currency information.
14-
message PlayerCurrency {
15-
// Represents an unclaimed ticket bundle.
16-
message TicketBundle {
17-
string event_name = 1; // The name of the event the bundle is from.
18-
string prize_name = 2; // The name of the prize the bundle is for.
19-
int32 ticket_amount = 3; // The amount of tickets in the bundle.
20-
}
21-
22-
int32 tokens = 1; // The amount of tokens the player has.
23-
int32 tickets = 2; // The amount of tickets the player has.
24-
repeated TicketBundle ticket_bundles = 3; // The unclaimed ticket bundles the player has.
25-
int32 sparks = 4; // The amount of sparks the player has.
26-
}
27-
28-
// Represents the player's permissions, admins will have all permissions set to their highest level.
29-
message PlayerPermissions {
30-
int32 donor = 1; // The donor rank level of the player. (Noble, Emperor, Mythic, Overlord)
31-
int32 vip = 2; // The VIP rank level of the player. (VIP)
32-
int32 qa = 3; // The QA rank level of the player. (QA)
33-
int32 youtuber = 4; // The YouTube rank level of the player. (YouTube)
34-
int32 support = 5; // The support rank level of the player. (JrHelper, Helper, SrHelper)
35-
int32 moderation = 6; // The mod rank level of the player. (JrMod, Mod, SrMod)
36-
int32 admin = 7; // The admin rank level of the player. (Dev, Admin, Owner)
37-
}
38-
39-
// Sent when the player switches modes.
40-
message S2CPlayerSwitchMode {
41-
PlayerMode mode = 1; // The mode the player is in.
42-
}
43-
446
// Represents a reference to an action and its arguments,
457
// sent when the player opens a code chest and bundled in other messages.
46-
message S2CChestReference {
8+
message ChestReference {
479
// Represents a value type.
4810
enum Value {
4911
ANY_TYPE = 0; // Any value.

0 commit comments

Comments
 (0)