Skip to content

Commit 655cf82

Browse files
authored
Merge pull request #140 from josemmo/develop
v1.3.2
2 parents a51c777 + a9ff08f commit 655cf82

File tree

16 files changed

+710
-1192
lines changed

16 files changed

+710
-1192
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/setup-java@v4
1818
with:
1919
distribution: 'temurin'
20-
java-version: '17'
20+
java-version: '21'
2121

2222
# Build plugin
2323
- name: Build with Maven

.github/workflows/tests.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
timeout-minutes: 8
9-
continue-on-error: ${{ matrix.version == '1.20.4' }}
9+
continue-on-error: ${{ matrix.version == '1.21.1' }}
1010
strategy:
1111
fail-fast: false
1212
matrix:
1313
flavor: ['bukkit', 'spigot', 'paper', 'purpur']
14-
version: ['1.20.4', '1.19.4', '1.18.2', '1.17.1', '1.16.5']
14+
version: ['1.21.1', '1.20.6', '1.19.4', '1.18.2', '1.17.1', '1.16.5']
1515
steps:
1616
# Download code from repository
1717
- name: Checkout code
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/setup-java@v4
2323
with:
2424
distribution: 'temurin'
25-
java-version: '17'
25+
java-version: '21'
2626

2727
# Build plugin
2828
- name: Build with Maven
@@ -33,7 +33,14 @@ jobs:
3333
uses: actions/setup-java@v4
3434
with:
3535
distribution: 'temurin'
36-
java-version: ${{ startsWith(matrix.version, '1.16') && '11' || (startsWith(matrix.version, '1.17') && '16' || '17') }}
36+
java-version: |
37+
${{
38+
startsWith(matrix.version, '1.16') && '11' ||
39+
startsWith(matrix.version, '1.17') && '16' ||
40+
startsWith(matrix.version, '1.18') && '17' ||
41+
startsWith(matrix.version, '1.19') && '17' ||
42+
'21'
43+
}}
3744
3845
# Setup Node.js
3946
- name: Setup Node.js

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Download the JAR file for the [latest release](https://github.com/josemmo/yamipa
2525
Before installing Yamipa make sure you meet the following requirements:
2626

2727
- CraftBukkit, Spigot or PaperMC 1.16 or higher
28-
- [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) v5.0.0 or higher
28+
- [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) v5.3.0 or higher
2929

3030
Here are the Minecraft distributions where Yamipa should be able to run:
3131
| Minecraft version | CraftBukkit | Spigot | PaperMC |
@@ -35,6 +35,7 @@ Here are the Minecraft distributions where Yamipa should be able to run:
3535
| 1.18 & 1.18.x ||||
3636
| 1.19 & 1.19.x ||||
3737
| 1.20 & 1.20.x ||||
38+
| 1.21 & 1.21.x ||||
3839

3940
## Configuration
4041
Yamipa is ready-to-go right out of the box. By default, it creates the following files and directories under the

automata/package-lock.json

Lines changed: 237 additions & 942 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automata/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node index.js"
77
},
88
"dependencies": {
9-
"mineflayer": "^4.14.0",
10-
"rcon-client": "^4.2.3"
9+
"mineflayer": "^4.21.0",
10+
"rcon-client": "^4.2.5"
1111
}
1212
}

automata/src/bot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function startBot() {
77
return new Promise(resolve => {
88
const bot = mineflayer.createBot({
99
host: '127.0.0.1',
10-
username: 'test'
10+
username: 'test',
1111
})
1212
bot.once('spawn', () => resolve(bot))
1313
})
@@ -23,6 +23,6 @@ export function placeBlockOnTheFloor(bot) {
2323
hand: 0,
2424
cursorX: 0,
2525
cursorY: 0,
26-
cursorZ: 0
26+
cursorZ: 0,
2727
})
2828
}

automata/src/rcon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const CONNECTION = {
55
host: '127.0.0.1',
66
port: 25575,
77
password: 'rcon',
8-
timeout: 1000*20
8+
timeout: 1000*20,
99
}
1010

1111
export async function waitForServer() {

pom.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.josemmo.bukkit.plugin</groupId>
88
<artifactId>YamipaPlugin</artifactId>
9-
<version>1.3.1</version>
9+
<version>1.3.2</version>
1010

1111
<properties>
1212
<maven.compiler.source>8</maven.compiler.source>
@@ -42,15 +42,15 @@
4242
<dependency>
4343
<groupId>org.spigotmc</groupId>
4444
<artifactId>spigot-api</artifactId>
45-
<version>1.20.4-R0.1-SNAPSHOT</version>
45+
<version>1.21.1-R0.1-SNAPSHOT</version>
4646
<scope>provided</scope>
4747
</dependency>
4848

49-
<!-- https://repo.dmulloy2.net/service/rest/repository/browse/public/com/comphenix/protocol/ProtocolLib/ -->
49+
<!-- https://jitpack.io/com/github/dmulloy2/ProtocolLib/ -->
5050
<dependency>
51-
<groupId>com.comphenix.protocol</groupId>
51+
<groupId>com.github.dmulloy2</groupId>
5252
<artifactId>ProtocolLib</artifactId>
53-
<version>5.2.0-SNAPSHOT</version>
53+
<version>1e3fa2d36e</version>
5454
<scope>provided</scope>
5555
</dependency>
5656

@@ -66,7 +66,7 @@
6666
<dependency>
6767
<groupId>org.bstats</groupId>
6868
<artifactId>bstats-bukkit</artifactId>
69-
<version>3.0.2</version>
69+
<version>3.1.0</version>
7070
</dependency>
7171

7272
<!-- https://central.sonatype.com/artifact/net.luckperms/api -->
@@ -93,35 +93,35 @@
9393
<scope>provided</scope>
9494
</dependency>
9595

96-
<!-- https://jitpack.io/com/github/TechFortress/GriefPrevention/ -->
96+
<!-- https://jitpack.io/com/github/GriefPrevention/GriefPrevention/ -->
9797
<dependency>
98-
<groupId>com.github.TechFortress</groupId>
98+
<groupId>com.github.GriefPrevention</groupId>
9999
<artifactId>GriefPrevention</artifactId>
100-
<version>16.18.2</version>
100+
<version>16.18.4</version>
101101
<scope>provided</scope>
102102
</dependency>
103103

104104
<!-- https://jitpack.io/com/github/TownyAdvanced/towny/ -->
105105
<dependency>
106-
<groupId>com.github.TownyAdvanced</groupId>
106+
<groupId>com.github.TownyAdvanced.Towny</groupId>
107107
<artifactId>towny</artifactId>
108-
<version>0.100.1.17</version>
108+
<version>0.100.4.4</version>
109109
<scope>provided</scope>
110110
</dependency>
111111

112112
<!-- https://jitpack.io/com/github/Angeschossen/LandsAPI/ -->
113113
<dependency>
114-
<groupId>com.github.angeschossen</groupId>
114+
<groupId>com.github.Angeschossen</groupId>
115115
<artifactId>LandsAPI</artifactId>
116-
<version>6.44.10</version>
116+
<version>7.9.17</version>
117117
<scope>provided</scope>
118118
</dependency>
119119

120120
<!-- https://central.sonatype.com/artifact/org.jetbrains/annotations -->
121121
<dependency>
122122
<groupId>org.jetbrains</groupId>
123123
<artifactId>annotations</artifactId>
124-
<version>24.1.0</version>
124+
<version>26.0.0</version>
125125
<scope>provided</scope>
126126
</dependency>
127127
</dependencies>

src/main/java/io/josemmo/bukkit/plugin/packets/EntityMetadataPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class EntityMetadataPacket extends PacketContainer {
2020
private final List<WrappedDataValue> values = new ArrayList<>(); // For >= 1.19.3
2121

2222
static {
23-
USE_DATA_WATCHER = (Internals.MINECRAFT_VERSION < 19.3f);
23+
USE_DATA_WATCHER = (Internals.MINECRAFT_VERSION < 19.3);
2424
ITEM_INDEX = (Internals.MINECRAFT_VERSION < 17) ? 7 : 8;
2525
ROTATION_INDEX = ITEM_INDEX + 1;
2626
}

src/main/java/io/josemmo/bukkit/plugin/packets/MapDataPacket.java

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,65 @@
22

33
import com.comphenix.protocol.PacketType;
44
import com.comphenix.protocol.events.PacketContainer;
5+
import com.comphenix.protocol.injector.StructureCache;
6+
import com.comphenix.protocol.reflect.ExactReflection;
57
import com.comphenix.protocol.reflect.StructureModifier;
8+
import com.comphenix.protocol.utility.MinecraftReflection;
69
import io.josemmo.bukkit.plugin.utils.Internals;
710
import org.jetbrains.annotations.NotNull;
811
import org.jetbrains.annotations.Nullable;
12+
import java.lang.reflect.Constructor;
13+
import java.lang.reflect.ParameterizedType;
14+
import java.util.Optional;
915

1016
public class MapDataPacket extends PacketContainer {
1117
private static final int LOCKED_INDEX;
18+
private static final @Nullable Constructor<?> MAP_ID_CONSTRUCTOR;
1219
private @Nullable StructureModifier<?> mapDataModifier;
1320

1421
static {
1522
LOCKED_INDEX = (Internals.MINECRAFT_VERSION < 17) ? 1 : 0;
23+
if (Internals.MINECRAFT_VERSION < 20.5) {
24+
MAP_ID_CONSTRUCTOR = null;
25+
} else {
26+
Class<?> mapIdClass = MinecraftReflection.getNullableNMS("world.level.saveddata.maps.MapId");
27+
MAP_ID_CONSTRUCTOR = ExactReflection.fromClass(mapIdClass, true).findConstructor(int.class);
28+
}
1629
}
1730

1831
public MapDataPacket() {
1932
super(PacketType.Play.Server.MAP);
2033
getModifier().writeDefaults();
2134

2235
if (Internals.MINECRAFT_VERSION < 17) {
23-
// Disable tracking position
24-
getBooleans().write(0, false);
25-
} else {
26-
// Create modifier for map data instance
36+
getBooleans().write(0, false); // Disable tracking position
37+
} else if (Internals.MINECRAFT_VERSION < 20.5) {
2738
Class<?> mapDataType = getModifier().getField(4).getType();
2839
Object mapDataInstance = getModifier().read(4);
2940
mapDataModifier = new StructureModifier<>(mapDataType).withTarget(mapDataInstance);
41+
} else {
42+
ParameterizedType genericType = (ParameterizedType) getModifier().getField(4).getGenericType();
43+
Class<?> mapDataType = (Class<?>) genericType.getActualTypeArguments()[0];
44+
Object mapDataInstance = StructureCache.newInstance(mapDataType);
45+
getModifier().write(3, Optional.empty());
46+
getModifier().write(4, Optional.of(mapDataInstance));
47+
mapDataModifier = new StructureModifier<>(mapDataType).withTarget(mapDataInstance);
3048
}
3149
}
3250

51+
@SuppressWarnings({"unchecked", "rawtypes"})
3352
public @NotNull MapDataPacket setId(int id) {
34-
getIntegers().write(0, id);
53+
if (MAP_ID_CONSTRUCTOR == null) {
54+
getIntegers().write(0, id);
55+
} else {
56+
try {
57+
Class<?> mapIdClass = MAP_ID_CONSTRUCTOR.getDeclaringClass();
58+
Object mapIdInstance = MAP_ID_CONSTRUCTOR.newInstance(id);
59+
((StructureModifier) getSpecificModifier(mapIdClass)).write(0, mapIdInstance);
60+
} catch (Exception e) {
61+
throw new RuntimeException("Failed to instantiate MapId for map #" + id);
62+
}
63+
}
3564
return this;
3665
}
3766

0 commit comments

Comments
 (0)