Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,17 @@ public static BlockPos toBlockPos(Location location) { // TODO: Paper renamed 'C
}

// TODO: Paper renamed some NMS methods, switch back to direct calls once on Paper NMS
public static MethodHandle reflectPaperRenamed(Class<?> clazz, String spigot, String paper, Class<?>... params) {
return ReflectionHelper.getMethodHandle(clazz, Denizen.supportsPaper ? paper : spigot, params);
public static MethodHandle reflectPaperRenamed(Class<?> clazz, String spigot, String paper) {
return reflectPaperRenamed(clazz, spigot, paper, null, null);
}

public static MethodHandle reflectPaperRenamed(Class<?> clazz, String spigot, String paper, Class<?>[] params) {
return reflectPaperRenamed(clazz, spigot, paper, params, params);
}

public static MethodHandle reflectPaperRenamed(Class<?> clazz, String spigot, String paper, Class<?>[] spigotParams, Class<?>[] paperParams) {
boolean supportsPaper = Denizen.supportsPaper;
return ReflectionHelper.getMethodHandle(clazz, supportsPaper ? paper : spigot, supportsPaper ? paperParams : spigotParams);
}

public Handler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static net.minecraft.world.item.crafting.RecipeHolder<?> getNMSRecipe(Nam
return ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().byKey(nmsKey).orElse(null);
}

public static final MethodHandle CRAFT_ITEM_STACK_AS_TEMPLATE = Handler.reflectPaperRenamed(CraftItemStack.class, "asNMSTemplate", "asTemplate", ItemStack.class);
public static final MethodHandle CRAFT_ITEM_STACK_AS_TEMPLATE = Handler.reflectPaperRenamed(CraftItemStack.class, "asNMSTemplate", "asTemplate", new Class<?>[] {ItemStack.class});
Comment thread
mcmonkey4eva marked this conversation as resolved.

public static ItemStackTemplate asNMSTemplate(ItemStack item) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.denizenscript.denizen.nms.v26_2.helpers;

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.interfaces.PacketHelper;
import com.denizenscript.denizen.nms.v26_2.Handler;
Expand Down Expand Up @@ -329,15 +330,27 @@ public void setMapData(MapCanvas canvas, byte[] bytes, int x, int y, MapImage im
if (anyChanged) {
// Flag the whole image as dirty
MapItemSavedData map = (MapItemSavedData) MAPVIEW_WORLDMAP.get(canvas.getMapView());
map.setColorsDirty(Math.max(x, 0), Math.max(y, 0));
map.setColorsDirty(width + x - 1, height + y - 1);
int maxX = Math.max(x, 0);
int maxY = Math.max(y, 0);
int mapWidth = width + x - 1;
int mapHeight = height + y - 1;
if (Denizen.supportsPaper) {
MAP_ITEM_SET_COLORS.invoke(map, maxX, maxY, true);
MAP_ITEM_SET_COLORS.invoke(map, mapWidth, mapHeight, true);
}
else {
MAP_ITEM_SET_COLORS.invoke(map, maxX, maxY);
MAP_ITEM_SET_COLORS.invoke(map, mapWidth, mapHeight);
}
}
}
catch (Throwable ex) {
Debug.echoError(ex);
}
}

public static final MethodHandle MAP_ITEM_SET_COLORS = Handler.reflectPaperRenamed(MapItemSavedData.class, "setColorsDirty", "setColorsDirty", new Class<?>[] {int.class, int.class}, new Class<?>[] {int.class, int.class, boolean.class});

@Override
public void setNetworkManagerFor(Player player) {
DenizenNetworkManagerImpl.setNetworkManager(player);
Expand Down