Skip to content

Commit 18ce75a

Browse files
1.20 update (#63)
* Start of the switch from version 1.19.2 to 1.20.1 * Use correct translation key for invalid player movement kick message * Resolve Conflicts * - Add 'damage type' registry and placeholders for 'trim pattern' and 'trim material' registries - Allow client to actually connect to the server * Remove unused import * updated project dependencies and gradle, cleaned up application module code for terminals * updated code generator registries for 1.20 * Fix PacketPlayOutPlayerInfo * added support for bitsets * updated block entities to 1.20 * added support for new 1.19.4 player chat, improved packet translators, added fastutil * added cache for signed messages, cleaned up the code a bit * fixed caching of signed messages, player messages now respect player's chat settings * added methods to send multiple packets as bundles --------- Co-authored-by: _tud <mmbakkar06@gmail.com>
1 parent 37e629f commit 18ce75a

File tree

160 files changed

+96781
-68399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+96781
-68399
lines changed

STYLE_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ subject to the following changes:
1212
- Comments and documentation must be indented to the same level as the surrounding code.
1313
- Code Changes:
1414
- Length:
15-
- The maximum line length is now 120 characters.
15+
- The maximum line length is 150 characters.
1616
- There is no maximum limit on the length of a method.
1717
- Only one statement is permitted per line.
1818
- There is no maximum parameter limit.

api/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ dependencies {
2424
implementation(libs.google.gson)
2525
implementation(libs.netty.all)
2626
implementation(libs.mojang.brigadier)
27-
}
27+
implementation(libs.fastutil)
2828

29-
tasks {
30-
jar {
31-
dependsOn(checkstyleMain)
32-
}
3329
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

api/src/main/java/org/machinemc/api/Server.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.machinemc.api.entities.Entity;
2525
import org.machinemc.api.entities.EntityManager;
2626
import org.machinemc.api.entities.Player;
27+
import org.machinemc.api.entities.damagetypes.DamageTypeManager;
2728
import org.machinemc.api.exception.ExceptionHandler;
2829
import org.machinemc.api.file.PlayerDataContainer;
2930
import org.machinemc.api.file.ServerProperties;
@@ -127,6 +128,11 @@ public interface Server {
127128
*/
128129
DimensionTypeManager getDimensionTypeManager();
129130

131+
/**
132+
* @return server's damage type manager
133+
*/
134+
DamageTypeManager getDamageTypeManager();
135+
130136
/**
131137
* @return server's messenger
132138
*/

api/src/main/java/org/machinemc/api/auth/MessageSignature.java

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is part of Machine.
3+
*
4+
* Machine is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License as published by the Free Software Foundation,
6+
* either version 3 of the License, or (at your option) any later version.
7+
*
8+
* Machine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
* See the GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License along with Machine.
13+
* If not, see https://www.gnu.org/licenses/.
14+
*/
15+
package org.machinemc.api.chat;
16+
17+
import org.jetbrains.annotations.Nullable;
18+
import org.machinemc.api.utils.Writable;
19+
import org.machinemc.scriptive.components.Component;
20+
21+
import java.util.Optional;
22+
23+
/**
24+
* Represents a chat type with message participants.
25+
*/
26+
public interface ChatBound extends Writable {
27+
28+
/**
29+
* Returns chat type of this chat bound for given messenger.
30+
* @param messenger messenger
31+
* @return chat type
32+
*/
33+
Optional<ChatType> getChatType(Messenger messenger);
34+
35+
/**
36+
* Sets new chat type of this chat bound using given messenger.
37+
* @param chatType chat type
38+
* @param messenger messenger
39+
*/
40+
void setChatType(ChatType chatType, Messenger messenger);
41+
42+
/**
43+
* @return source of the message
44+
*/
45+
Component getSource();
46+
47+
/**
48+
* @param component new source of the message
49+
*/
50+
void setSource(Component component);
51+
52+
/**
53+
* @return target of the message
54+
*/
55+
Optional<Component> getTarget();
56+
57+
/**
58+
* @param target new target of the message
59+
*/
60+
void setTarget(@Nullable Component target);
61+
62+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* This file is part of Machine.
3+
*
4+
* Machine is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License as published by the Free Software Foundation,
6+
* either version 3 of the License, or (at your option) any later version.
7+
*
8+
* Machine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
* See the GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License along with Machine.
13+
* If not, see https://www.gnu.org/licenses/.
14+
*/
15+
package org.machinemc.api.chat;
16+
17+
import org.machinemc.api.auth.PublicKeyData;
18+
19+
import java.security.PublicKey;
20+
import java.time.Instant;
21+
import java.util.UUID;
22+
23+
public interface ChatSession {
24+
25+
/**
26+
* @return id of this session
27+
*/
28+
UUID getUUID();
29+
30+
/**
31+
* @return public key data of this session
32+
*/
33+
PublicKeyData getData();
34+
35+
/**
36+
* @return public key of the session
37+
*/
38+
default PublicKey getPublicKey() {
39+
return getData().publicKey();
40+
}
41+
42+
/**
43+
* @return signature of the session
44+
*/
45+
default byte[] getSignature() {
46+
return getData().signature();
47+
}
48+
49+
/**
50+
* @return timestamp of the session
51+
*/
52+
default Instant getTimestamp() {
53+
return getData().timestamp();
54+
}
55+
56+
/**
57+
* @return whether the session is expired
58+
*/
59+
default boolean isExpired() {
60+
return getTimestamp().isBefore(Instant.now());
61+
}
62+
63+
}

api/src/main/java/org/machinemc/api/chat/ChatType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface ChatType extends NBTSerializable {
5353
* @param font font of the element
5454
*/
5555
record Element(ElementType type,
56-
Collection<Parameter> parameters,
56+
List<Parameter> parameters,
5757
String translationKey,
5858
@Nullable TextFormat format,
5959
@Nullable NamespacedKey font) implements NBTSerializable {
@@ -72,7 +72,7 @@ record Element(ElementType type,
7272
* @param font font of the element
7373
* @return created chat type element
7474
*/
75-
public static Element chat(final Collection<Parameter> parameters,
75+
public static Element chat(final List<Parameter> parameters,
7676
final String translationKey,
7777
final @Nullable TextFormat format,
7878
final @Nullable NamespacedKey font) {
@@ -86,7 +86,7 @@ public static Element chat(final Collection<Parameter> parameters,
8686
* @param font font of the element
8787
* @return created chat type element
8888
*/
89-
public static Element narration(final Collection<Parameter> parameters,
89+
public static Element narration(final List<Parameter> parameters,
9090
final String translationKey,
9191
final @Nullable TextFormat format,
9292
final @Nullable NamespacedKey font) {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* This file is part of Machine.
3+
*
4+
* Machine is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License as published by the Free Software Foundation,
6+
* either version 3 of the License, or (at your option) any later version.
7+
*
8+
* Machine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
* See the GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License along with Machine.
13+
* If not, see https://www.gnu.org/licenses/.
14+
*/
15+
package org.machinemc.api.chat;
16+
17+
import com.google.common.base.Preconditions;
18+
import org.jetbrains.annotations.Nullable;
19+
import org.jetbrains.annotations.Range;
20+
21+
import java.util.Objects;
22+
23+
public enum FilterType {
24+
25+
PASS_THROUGH,
26+
FULLY_FILTERED,
27+
PARTIALLY_FILTERED;
28+
29+
/**
30+
* @return numeric id of the filter type used by Minecraft protocol.
31+
*/
32+
public @Range(from = 0, to = 2) int getID() {
33+
return ordinal();
34+
}
35+
36+
/**
37+
* Returns filter type from its numeric id.
38+
* @param id id of the filter type
39+
* @return filter type for given id
40+
*/
41+
public static FilterType fromID(final @Range(from = 0, to = 2) int id) {
42+
Preconditions.checkArgument(id < values().length, "Unsupported filter type");
43+
return values()[id];
44+
}
45+
46+
47+
/**
48+
* Returns filter type of given name.
49+
* @param name name of the filter type
50+
* @return filter type with given name
51+
*/
52+
public static @Nullable FilterType getByName(final String name) {
53+
Objects.requireNonNull(name, "Name of the filter type can not be null");
54+
for (final FilterType value : values()) {
55+
if (value.name().equalsIgnoreCase(name))
56+
return value;
57+
}
58+
return null;
59+
}
60+
61+
}

api/src/main/java/org/machinemc/api/chat/MessageType.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
*/
1515
package org.machinemc.api.chat;
1616

17+
import com.google.common.base.Preconditions;
1718
import org.jetbrains.annotations.Nullable;
19+
import org.jetbrains.annotations.Range;
1820

1921
import java.util.Objects;
2022

@@ -23,6 +25,23 @@ public enum MessageType {
2325
CHAT,
2426
SYSTEM;
2527

28+
/**
29+
* @return numeric id of the message type used by Minecraft protocol.
30+
*/
31+
public @Range(from = 0, to = 1) int getID() {
32+
return ordinal();
33+
}
34+
35+
/**
36+
* Returns message type from its numeric id.
37+
* @param id id of the message type
38+
* @return message type for given id
39+
*/
40+
public static MessageType fromID(final @Range(from = 0, to = 1) int id) {
41+
Preconditions.checkArgument(id < values().length, "Unsupported message type");
42+
return values()[id];
43+
}
44+
2645
/**
2746
* Returns message type of given name.
2847
* @param name name of the message type

0 commit comments

Comments
 (0)