Added Spigot 1.20.4 support
This commit is contained in:
parent
8206cb403b
commit
89cbc9b8be
5 changed files with 42 additions and 39 deletions
2
.github/dependabot.yml
vendored
2
.github/dependabot.yml
vendored
|
@ -8,4 +8,4 @@ updates:
|
||||||
- package-ecosystem: "maven" # See documentation for possible values
|
- package-ecosystem: "maven" # See documentation for possible values
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "daily"
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -31,7 +31,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="temurin-11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
4
pom.xml
4
pom.xml
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
<groupId>tech.sbdevelopment</groupId>
|
<groupId>tech.sbdevelopment</groupId>
|
||||||
<artifactId>MapReflectionAPI</artifactId>
|
<artifactId>MapReflectionAPI</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.6.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MapReflectionAPI</name>
|
<name>MapReflectionAPI</name>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package tech.sbdevelopment.mapreflectionapi.api;
|
package tech.sbdevelopment.mapreflectionapi.api;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -33,7 +34,6 @@ import tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.Ref;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -43,6 +43,7 @@ import static tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtils.*;
|
||||||
/**
|
/**
|
||||||
* A {@link MapWrapper} wraps one image.
|
* A {@link MapWrapper} wraps one image.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public class MapWrapper extends AbstractMapWrapper {
|
public class MapWrapper extends AbstractMapWrapper {
|
||||||
private static final String REFERENCE_METADATA = "MAP_WRAPPER_REF";
|
private static final String REFERENCE_METADATA = "MAP_WRAPPER_REF";
|
||||||
protected ArrayImage content;
|
protected ArrayImage content;
|
||||||
|
@ -108,7 +109,8 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull ArrayImage content) {
|
public void update(@NotNull ArrayImage content) {
|
||||||
MapContentUpdateEvent event = new MapContentUpdateEvent(MapWrapper.this, content);
|
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
|
||||||
|
MapContentUpdateEvent event = new MapContentUpdateEvent(MapWrapper.this, content, async);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (Configuration.getInstance().isImageCache()) {
|
if (Configuration.getInstance().isImageCache()) {
|
||||||
|
@ -165,27 +167,25 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
String inventoryMenuName;
|
String inventoryMenuName;
|
||||||
if (supports(20)) { //1.20
|
if (supports(20)) {
|
||||||
inventoryMenuName = PATCH_NUMBER == 2 ? "bR" : "bQ"; //1.20.2 = bR, 1.20(.1) = bQ
|
//>= 1.20.2 = bR, 1.20(.1) = bQ
|
||||||
} else if (supports(19)) { //1.19
|
inventoryMenuName = supports(20, 2) ? "bR" : "bQ";
|
||||||
inventoryMenuName = PATCH_NUMBER == 3 ? "bO" : "bT"; //1.19.4 = bO, >= 1.19.3 = bT
|
} else if (supports(19)) {
|
||||||
} else if (supports(18)) { //1.18
|
//1.19.4 = bO, >= 1.19.3 = bT
|
||||||
inventoryMenuName = PATCH_NUMBER == 1 ? "bV" : "bU"; //1.18.1 = ap, 1.18(.2) = ao
|
inventoryMenuName = supports(19, 3) ? "bO" : "bT";
|
||||||
} else if (supports(17)) { //1.17, same as 1.18(.2)
|
} else if (supports(18)) {
|
||||||
|
//1.18.1 = ap, 1.18(.2) = ao
|
||||||
|
inventoryMenuName = supports(18, 1) ? "bV" : "bU";
|
||||||
|
} else if (supports(17)) {
|
||||||
|
//1.17, same as 1.18(.2)
|
||||||
inventoryMenuName = "bU";
|
inventoryMenuName = "bU";
|
||||||
} else { //1.12-1.16
|
} else {
|
||||||
|
//1.12-1.16
|
||||||
inventoryMenuName = "defaultContainer";
|
inventoryMenuName = "defaultContainer";
|
||||||
}
|
}
|
||||||
Object inventoryMenu = ReflectionUtil.getField(getHandle(player), inventoryMenuName);
|
Object inventoryMenu = ReflectionUtil.getField(getHandle(player), inventoryMenuName);
|
||||||
|
|
||||||
ItemStack stack;
|
Object nmsStack = asCraftItemStack(player);
|
||||||
if (supports(13)) {
|
|
||||||
stack = new ItemStack(MAP_MATERIAL, 1);
|
|
||||||
} else {
|
|
||||||
stack = new ItemStack(MAP_MATERIAL, 1, (short) getMapId(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
Object nmsStack = createCraftItemStack(stack, (short) getMapId(player));
|
|
||||||
|
|
||||||
Object packet;
|
Object packet;
|
||||||
if (supports(17)) { //1.17+
|
if (supports(17)) { //1.17+
|
||||||
|
@ -298,6 +298,13 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object asCraftItemStack(Player player) {
|
||||||
|
return createCraftItemStack(supports(13)
|
||||||
|
? new ItemStack(MAP_MATERIAL, 1)
|
||||||
|
: new ItemStack(MAP_MATERIAL, 1, (short) getMapId(player)
|
||||||
|
), (short) getMapId(player));
|
||||||
|
}
|
||||||
|
|
||||||
private Object createCraftItemStack(@NotNull ItemStack stack, int mapId) {
|
private Object createCraftItemStack(@NotNull ItemStack stack, int mapId) {
|
||||||
if (mapId < 0) return null;
|
if (mapId < 0) return null;
|
||||||
|
|
||||||
|
@ -310,7 +317,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
} else if (supports(19)) { //1.19
|
} else if (supports(19)) { //1.19
|
||||||
nbtObjectName = "v";
|
nbtObjectName = "v";
|
||||||
} else if (supports(18)) { //1.18
|
} else if (supports(18)) { //1.18
|
||||||
nbtObjectName = PATCH_NUMBER == 1 ? "t" : "u"; //1.18.1 = t, 1.18(.2) = u
|
nbtObjectName = supports(18, 1) ? "t" : "u"; //1.18.1 = t, 1.18(.2) = u
|
||||||
} else { //1.13 - 1.17
|
} else { //1.13 - 1.17
|
||||||
nbtObjectName = "getOrCreateTag";
|
nbtObjectName = "getOrCreateTag";
|
||||||
}
|
}
|
||||||
|
@ -329,7 +336,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
} else if (supports(19)) { //1.19-1.19.2
|
} else if (supports(19)) { //1.19-1.19.2
|
||||||
dataWatcherObjectName = "ao";
|
dataWatcherObjectName = "ao";
|
||||||
} else if (supports(18)) { //1.18
|
} else if (supports(18)) { //1.18
|
||||||
dataWatcherObjectName = PATCH_NUMBER == 1 ? "ap" : "ao"; //1.18.1 = ap, 1.18(.2) = ao
|
dataWatcherObjectName = supports(18, 1) ? "ap" : "ao"; //1.18.1 = ap, 1.18(.2) = ao
|
||||||
} else if (supports(17)) { //1.17
|
} else if (supports(17)) { //1.17
|
||||||
dataWatcherObjectName = "ao";
|
dataWatcherObjectName = "ao";
|
||||||
} else if (supports(14)) { //1.14 - 1.16
|
} else if (supports(14)) { //1.14 - 1.16
|
||||||
|
@ -341,7 +348,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
}
|
}
|
||||||
Object dataWatcherObject = ReflectionUtil.getDeclaredField(entityItemFrameClass, dataWatcherObjectName);
|
Object dataWatcherObject = ReflectionUtil.getDeclaredField(entityItemFrameClass, dataWatcherObjectName);
|
||||||
|
|
||||||
ReflectionUtil.ListParam list = new ReflectionUtil.ListParam<>();
|
ReflectionUtil.ListParam<Object> list = new ReflectionUtil.ListParam<>();
|
||||||
|
|
||||||
Object packet;
|
Object packet;
|
||||||
if (supports(19, 3)) { //1.19.3
|
if (supports(19, 3)) { //1.19.3
|
||||||
|
@ -379,13 +386,4 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
sendPacketSync(player, packet);
|
sendPacketSync(player, packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ArrayImage getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapController getController() {
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ import java.util.regex.Pattern;
|
||||||
* A useful resource used to compare mappings is <a href="https://minidigger.github.io/MiniMappingViewer/#/spigot">Mini's Mapping Viewer</a>
|
* A useful resource used to compare mappings is <a href="https://minidigger.github.io/MiniMappingViewer/#/spigot">Mini's Mapping Viewer</a>
|
||||||
*
|
*
|
||||||
* @author Crypto Morin
|
* @author Crypto Morin
|
||||||
* @version 7.1.0
|
* @version 7.1.0.0.1
|
||||||
*/
|
*/
|
||||||
public final class ReflectionUtils {
|
public final class ReflectionUtils {
|
||||||
/**
|
/**
|
||||||
|
@ -106,8 +106,13 @@ public final class ReflectionUtils {
|
||||||
*/
|
*/
|
||||||
public static final int MINOR_NUMBER;
|
public static final int MINOR_NUMBER;
|
||||||
/**
|
/**
|
||||||
* The raw patch version number.
|
* The raw patch version number. Refers to the <a href="https://en.wikipedia.org/wiki/Software_versioning">major.minor.patch version scheme</a>.
|
||||||
* E.g. {@code 1.19.2} to {@code 2}
|
* E.g.
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code v1.20.4} to {@code 4}</li>
|
||||||
|
* <li>{@code v1.18.2} to {@code 2}</li>
|
||||||
|
* <li>{@code v1.19.1} to {@code 1}</li>
|
||||||
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* I'd not recommend developers to support individual patches at all. You should always support the latest patch.
|
* I'd not recommend developers to support individual patches at all. You should always support the latest patch.
|
||||||
* For example, between v1.14.0, v1.14.1, v1.14.2, v1.14.3 and v1.14.4 you should only support v1.14.4
|
* For example, between v1.14.0, v1.14.1, v1.14.2, v1.14.3 and v1.14.4 you should only support v1.14.4
|
||||||
|
@ -195,7 +200,7 @@ public final class ReflectionUtils {
|
||||||
/* 17 */ 1,// \_!_/
|
/* 17 */ 1,// \_!_/
|
||||||
/* 18 */ 2,
|
/* 18 */ 2,
|
||||||
/* 19 */ 4,
|
/* 19 */ 4,
|
||||||
/* 20 */ 2,
|
/* 20 */ 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (minorVersion > patches.length) return null;
|
if (minorVersion > patches.length) return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue