Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
14a6c330d2 v1.6.6: 1.21.5 support (#50)
Reviewed-on: #50
Co-authored-by: SBDeveloper <support@sbdevelopment.tech>
Co-committed-by: SBDeveloper <support@sbdevelopment.tech>
2025-03-27 19:55:31 +01:00
aaecbf447d Delete .github/dependabot.yml 2025-03-27 19:54:36 +01:00
e142050b7a Delete .github/workflows/maven.yml 2025-03-27 19:54:31 +01:00
7 changed files with 22 additions and 65 deletions

View file

@ -1,11 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View file

@ -1,26 +0,0 @@
name: Java CI
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 21
- name: Build with Maven
run: mvn -B package --file pom.xml
- run: mkdir -p target
- uses: actions/upload-artifact@master
with:
name: MapReflectionAPI
path: target

16
pom.xml
View file

@ -24,7 +24,7 @@
<groupId>tech.sbdevelopment</groupId> <groupId>tech.sbdevelopment</groupId>
<artifactId>MapReflectionAPI</artifactId> <artifactId>MapReflectionAPI</artifactId>
<version>1.6.4</version> <version>1.6.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>MapReflectionAPI</name> <name>MapReflectionAPI</name>
@ -48,7 +48,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version> <version>3.14.0</version>
<configuration> <configuration>
<release>11</release> <release>11</release>
<annotationProcessorPaths> <annotationProcessorPaths>
@ -119,7 +119,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version> <version>3.11.2</version>
<configuration> <configuration>
<release>11</release> <release>11</release>
<sourcepath>${maven.lombok.delombok-target}</sourcepath> <sourcepath>${maven.lombok.delombok-target}</sourcepath>
@ -166,13 +166,17 @@
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url> <url>https://repo.dmulloy2.net/repository/public/</url>
</repository> </repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version> <version>1.21.5-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -190,7 +194,7 @@
<dependency> <dependency>
<groupId>com.github.cryptomorin</groupId> <groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId> <artifactId>XSeries</artifactId>
<version>11.3.0</version> <version>13.1.0</version>
</dependency> </dependency>
<!-- Libraries below are provided by CraftBukkit --> <!-- Libraries below are provided by CraftBukkit -->
@ -203,7 +207,7 @@
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId> <artifactId>netty-transport</artifactId>
<version>4.1.114.Final</version> <version>4.1.118.Final</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -86,8 +86,8 @@ public class MapSender {
} }
private static final Class<?> packetPlayOutMapClass = getNMSClass("network.protocol.game", "PacketPlayOutMap"); private static final Class<?> packetPlayOutMapClass = getNMSClass("network.protocol.game", "PacketPlayOutMap");
private static final Class<?> worldMapData = supports(17) ? getNMSClass("world.level.saveddata.maps", "WorldMap$b") : null; private static final Class<?> worldMapData = supports(17) ? getNMSClass("world.level.saveddata.maps", supports(21, 2) ? "WorldMap$c" : "WorldMap$b") : null; //1.21.2+ uses WorldMap$c, 1.17+ uses WorldMap$b
private static final Class<?> mapId = supports(21) ? getNMSClass("world.level.saveddata.maps", "MapId") : null; private static final Class<?> mapIdClazz = supports(21) ? getNMSClass("world.level.saveddata.maps", "MapId") : null;
/** /**
* Send a map to a player * Send a map to a player
@ -124,7 +124,7 @@ public class MapSender {
content.array //Data content.array //Data
); );
Object mapId = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), id); Object mapId = ReflectionUtil.callConstructor(mapIdClazz, id);
packet = ReflectionUtil.callConstructor(packetPlayOutMapClass, packet = ReflectionUtil.callConstructor(packetPlayOutMapClass,
mapId, //ID mapId, //ID

View file

@ -69,8 +69,6 @@ public class MapWrapper extends AbstractMapWrapper {
private static final Class<?> entityMetadataPacketClass = getNMSClass("network.protocol.game", "PacketPlayOutEntityMetadata"); private static final Class<?> entityMetadataPacketClass = getNMSClass("network.protocol.game", "PacketPlayOutEntityMetadata");
private static final Class<?> entityItemFrameClass = getNMSClass("world.entity.decoration", "EntityItemFrame"); private static final Class<?> entityItemFrameClass = getNMSClass("world.entity.decoration", "EntityItemFrame");
private static final Class<?> dataWatcherItemClass = getNMSClass("network.syncher", "DataWatcher$Item"); private static final Class<?> dataWatcherItemClass = getNMSClass("network.syncher", "DataWatcher$Item");
private static final Class<?> minecraftKeyClass = getNMSClass("resources", "MinecraftKey");
private static final Class<?> builtInRegistriesClass = getNMSClass("core.registries", "BuiltInRegistries");
protected MapController controller = new MapController() { protected MapController controller = new MapController() {
private final Map<UUID, Integer> viewers = new HashMap<>(); private final Map<UUID, Integer> viewers = new HashMap<>();
@ -169,8 +167,8 @@ public class MapWrapper extends AbstractMapWrapper {
String inventoryMenuName; String inventoryMenuName;
if (supports(21)) { if (supports(21)) {
//1.21 = cc //1.21.5 = bQ, 1.21 - 1.21.4 = cc
inventoryMenuName = "cc"; inventoryMenuName = supports(21, 4) ? "bQ" : "cc";
} else if (supports(20)) { } else if (supports(20)) {
//1.20.5 = cb, 1.20.2 - 1.20.4 = bR, 1.20(.1) = bQ //1.20.5 = cb, 1.20.2 - 1.20.4 = bR, 1.20(.1) = bQ
inventoryMenuName = supports(20, 4) ? "cb" : supports(20, 2) ? "bR" : "bQ"; inventoryMenuName = supports(20, 4) ? "cb" : supports(20, 2) ? "bR" : "bQ";
@ -295,7 +293,7 @@ public class MapWrapper extends AbstractMapWrapper {
//1.20.5 uses new NBT compound system //1.20.5 uses new NBT compound system
if (supports(20, 4)) { if (supports(20, 4)) {
Object mapIdComponent = ReflectionUtil.getDeclaredField(getNMSClass("core.component", "DataComponents"), "B"); Object mapIdComponent = ReflectionUtil.getDeclaredField(getNMSClass("core.component", "DataComponents"), supports(21, 4) ? "M" : supports(21, 2) ? "L" : "B"); //1.21.2+ uses L, otherwise B
Object mapId1 = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), mapId); Object mapId1 = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), mapId);
// Use generic reflection because of generics // Use generic reflection because of generics
@ -330,7 +328,7 @@ public class MapWrapper extends AbstractMapWrapper {
String dataWatcherObjectName; String dataWatcherObjectName;
if (supports(21)) { //1.21 if (supports(21)) { //1.21
dataWatcherObjectName = "f"; dataWatcherObjectName = supports(21, 2) ? "e" : "f"; //1.21.2+ = e, 1.21(.1) = f
} else if (supports(19, 3)) { //1.19.3 and 1.20(.1) } else if (supports(19, 3)) { //1.19.3 and 1.20(.1)
dataWatcherObjectName = "g"; dataWatcherObjectName = "g";
} else if (supports(19)) { //1.19-1.19.2 } else if (supports(19)) { //1.19-1.19.2

View file

@ -64,10 +64,8 @@ public class MultiMapWrapper extends AbstractMapWrapper {
* Creates a new {@link MultiMapWrapper} from the given image. * Creates a new {@link MultiMapWrapper} from the given image.
* *
* @param imageMatrix The image matrix to wrap * @param imageMatrix The image matrix to wrap
* @deprecated Use {@link #MultiMapWrapper(ArrayImage, int, int)} instead, this method is meant for internal use only.
*/ */
@Deprecated(since = "1.6", forRemoval = true) protected MultiMapWrapper(ArrayImage[][] imageMatrix) {
public MultiMapWrapper(ArrayImage[][] imageMatrix) {
wrapperMatrix = new MapWrapper[imageMatrix.length][imageMatrix[0].length]; wrapperMatrix = new MapWrapper[imageMatrix.length][imageMatrix[0].length];
for (int row = 0; row < imageMatrix.length; row++) { for (int row = 0; row < imageMatrix.length; row++) {
@ -85,10 +83,8 @@ public class MultiMapWrapper extends AbstractMapWrapper {
* Creates a new {@link MultiMapWrapper} from the given image. * Creates a new {@link MultiMapWrapper} from the given image.
* *
* @param imageMatrix The image matrix to wrap * @param imageMatrix The image matrix to wrap
* @deprecated Use {@link #MultiMapWrapper(BufferedImage, int, int)} instead, this method is meant for internal use only.
*/ */
@Deprecated(since = "1.6", forRemoval = true) protected MultiMapWrapper(BufferedImage[][] imageMatrix) {
public MultiMapWrapper(BufferedImage[][] imageMatrix) {
wrapperMatrix = new MapWrapper[imageMatrix.length][imageMatrix[0].length]; wrapperMatrix = new MapWrapper[imageMatrix.length][imageMatrix[0].length];
for (int row = 0; row < imageMatrix.length; row++) { for (int row = 0; row < imageMatrix.length; row++) {

View file

@ -30,19 +30,15 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import sun.misc.Unsafe;
import tech.sbdevelopment.mapreflectionapi.MapReflectionAPI; import tech.sbdevelopment.mapreflectionapi.MapReflectionAPI;
import tech.sbdevelopment.mapreflectionapi.api.events.CreativeInventoryMapUpdateEvent; import tech.sbdevelopment.mapreflectionapi.api.events.CreativeInventoryMapUpdateEvent;
import tech.sbdevelopment.mapreflectionapi.api.events.MapCancelEvent; import tech.sbdevelopment.mapreflectionapi.api.events.MapCancelEvent;
import tech.sbdevelopment.mapreflectionapi.api.events.MapInteractEvent; import tech.sbdevelopment.mapreflectionapi.api.events.MapInteractEvent;
import tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil; import tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.cryptomorin.xseries.reflection.minecraft.MinecraftConnection.getConnection; import static com.cryptomorin.xseries.reflection.minecraft.MinecraftConnection.getConnection;
import static com.cryptomorin.xseries.reflection.minecraft.MinecraftConnection.getHandle;
import static tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil.*; import static tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil.*;
import static com.cryptomorin.xseries.reflection.XReflection.*; import static com.cryptomorin.xseries.reflection.XReflection.*;
@ -207,9 +203,9 @@ public class PacketListener implements Listener {
if (!(vec3d.getClass().isAssignableFrom(vec3DClass))) return new Vector(0, 0, 0); if (!(vec3d.getClass().isAssignableFrom(vec3DClass))) return new Vector(0, 0, 0);
Object vec3dNMS = vec3DClass.cast(vec3d); Object vec3dNMS = vec3DClass.cast(vec3d);
double x = (double) getDeclaredField(vec3dNMS, supports(19) ? "c" : supports(17) ? "b" : "x"); //1.19 = c, 1.18 = b, 1.16 = x double x = (double) getDeclaredField(vec3dNMS, supports(21, 2) ? "d" : supports(19) ? "c" : supports(17) ? "b" : "x"); //1.21.2+ = d, 1.19 = c, 1.18 = b, 1.16 = x
double y = (double) getDeclaredField(vec3dNMS, supports(19) ? "d" : supports(17) ? "c" : "y"); //1.19 = d, 1.18 = c, 1.16 = y double y = (double) getDeclaredField(vec3dNMS, supports(21, 2) ? "e" : supports(19) ? "d" : supports(17) ? "c" : "y"); //1.21.2+ = e, 1.19 = d, 1.18 = c, 1.16 = y
double z = (double) getDeclaredField(vec3dNMS, supports(19) ? "e" : supports(17) ? "d" : "z"); //1.19 = e, 1.18 = d, 1.16 = z double z = (double) getDeclaredField(vec3dNMS, supports(21, 2) ? "f" : supports(19) ? "e" : supports(17) ? "d" : "z"); //1.21.2+ = f, 1.19 = e, 1.18 = d, 1.16 = z
return new Vector(x, y, z); return new Vector(x, y, z);
} }