diff --git a/changelog.txt b/changelog.txt index b8592ea..f4959f9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +1.0.48 + Fixed PlayerList error when player's disconnect + +1.0.47 + Added fix for maps in 1.13. + Fixed gif maps. + 1.0.46 Removed error printout for 1.12 for glowing enchantment. @@ -20,7 +27,7 @@ Fixed mapwall another time. It seems the customimagerenderers are not replaced across reloads. 1.0.39 - Fixed mapwall again. Fixed redunant code. Made map walls x500 more efficient. + Fixed mapwall again. Fixed redundant code. Made map walls x500 more efficient. 1.0.38 Added ability to go over for map wall if image is too big. This will stop cutoffs, at the sake of adding an extra map diff --git a/plugin.yml b/plugin.yml index 53c7347..e35d61f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ main: me.zombie_striker.pluginconstructor.PluginConstructorAPI -version: 1.0.46 +version: 1.0.48 api-version: 1.13 name: PluginConstructorAPI author: diff --git a/src/me/zombie_striker/pluginconstructor/CustomImageRenderer.java b/src/me/zombie_striker/pluginconstructor/CustomImageRenderer.java index 529bd0a..c4e0f9b 100644 --- a/src/me/zombie_striker/pluginconstructor/CustomImageRenderer.java +++ b/src/me/zombie_striker/pluginconstructor/CustomImageRenderer.java @@ -29,11 +29,13 @@ public class CustomImageRenderer extends MapRenderer { public static int TICK_FOR_STILLS = 500; public CustomImageRenderer(BufferedImage[] bi, int ticks) { + super(true); this.image = bi; this.ticks = ticks; } public CustomImageRenderer(BufferedImage bi, int ticks) { + super(true); this.image = new BufferedImage[1]; image[0] = bi; this.ticks = ticks; @@ -41,14 +43,15 @@ public CustomImageRenderer(BufferedImage bi, int ticks) { // maps update multiple times per second. // for still images, set ticks to 100; - @Override public void render(MapView view, MapCanvas canvas, Player player) { if (cTicks >= ticks) { if (image != null && image[frameCount] != null) canvas.drawImage(0, 0, image[frameCount]); - frameCount=frameCount++%image.length; - cTicks=0; + frameCount = (frameCount + 1);// % image.length; + if (frameCount >= image.length) + frameCount = 0; + cTicks = 0; } cTicks++; } diff --git a/src/me/zombie_striker/pluginconstructor/MapWallUtil.java b/src/me/zombie_striker/pluginconstructor/MapWallUtil.java index e4f86aa..c0e6eb3 100644 --- a/src/me/zombie_striker/pluginconstructor/MapWallUtil.java +++ b/src/me/zombie_striker/pluginconstructor/MapWallUtil.java @@ -31,11 +31,14 @@ public class MapWallUtil { @SuppressWarnings("deprecation") - public static ItemStack getMap(BufferedImage BUFFEREDIMAGE) { - + public static ItemStack getMap(BufferedImage BUFFEREDIMAGE) { + MapView mv = Bukkit.createMap(Bukkit.getWorlds().get(0)); short mapIds = mv.getId(); - ItemStack is = new ItemStack(Material.MAP, 1, (short) mapIds); + Material map = Material.MAP; + if (ReflectionUtil.isVersionHigherThan(1, 13)) + map = Material.FILLED_MAP; + ItemStack is = new ItemStack(map, 1, (short) mapIds); for (MapRenderer mr : mv.getRenderers()) { mv.removeRenderer(mr); } @@ -70,12 +73,19 @@ public static ItemStack[][] getMaps(BufferedImage[] whole) { } for (int x = 0; x < wd1; x++) { for (int y = 0; y < hd1; y++) { - MapView mv = Bukkit.createMap(Bukkit.getWorlds().get(0)); - short mapIds = mv.getId(); - ItemStack is = new ItemStack(Material.MAP, 1, (short) mapIds); - stacks[x][y] = is; - for (MapRenderer mr : mv.getRenderers()) { - mv.removeRenderer(mr); + Material map; + MapView mv; + ItemStack is; + mv = Bukkit.createMap(Bukkit.getWorlds().get(0)); + if (ReflectionUtil.isVersionHigherThan(1, 13)) { + map = Material.FILLED_MAP; + is= new ItemStack(map, 1); + org.bukkit.inventory.meta.MapMeta mapmeta = (org.bukkit.inventory.meta.MapMeta) is.getItemMeta(); + mapmeta.setMapId(mv.getId()); + is.setItemMeta(mapmeta); + } else { + map = Material.MAP; + is= new ItemStack(map, 1, (short) mv.getId()); } BufferedImage[] bip = new BufferedImage[frames]; for (int frame = 0; frame < frames; frame++) { @@ -94,8 +104,13 @@ public static ItemStack[][] getMaps(BufferedImage[] whole) { continue; bip[frame] = whole[frame].getSubimage(x * 128, y * 128, cW, cH); } - mv.addRenderer(new CustomImageRenderer(bip, ((frames > 1) ? 0 : CustomImageRenderer.TICK_FOR_STILLS))); - + CustomImageRenderer cir = new CustomImageRenderer(bip, + ((frames > 1) ? 0 : CustomImageRenderer.TICK_FOR_STILLS)); + for (MapRenderer mr : mv.getRenderers()) { + mv.removeRenderer(mr); + } + mv.addRenderer(cir); + stacks[x][y] = is; } } return stacks; diff --git a/src/me/zombie_striker/pluginconstructor/PlayerList.java b/src/me/zombie_striker/pluginconstructor/PlayerList.java index fd6ce22..d6ababe 100644 --- a/src/me/zombie_striker/pluginconstructor/PlayerList.java +++ b/src/me/zombie_striker/pluginconstructor/PlayerList.java @@ -121,6 +121,8 @@ private static Object invokeChatSerializerA(String text) { PROPERTY = ReflectionUtil.getOLDAuthlibClass("properties.Property"); PROPERTY_CONSTRUCTOR = (Constructor) ReflectionUtil .getConstructor(PROPERTY, new Class[] { String.class, String.class, String.class }).get(); + } else { + PROPERTY_MAP = ReflectionUtil.getMojangAuthClass("properties.PropertyMap"); } WORLD_GAME_MODE_NOT_SET = a() ? ReflectionUtil.getEnumConstant(WORLD_GAME_MODE_CLASS, "NOT_SET") : null; @@ -507,7 +509,13 @@ public void callBack(Skin skin, boolean successful, Exception exception) { try { Object map = ReflectionUtil.invokeMethod(profile, "getProperties", new Class[0]); if (skin.getBase64() != null && skin.getSignedBase64() != null) { - ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { String.class }, "textures"); + if (!ReflectionUtil.isVersionHigherThan(1, 13)) { + ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { String.class }, + "textures"); + } else { + ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { Object.class }, + "textures"); + } Object prop = ReflectionUtil.instantiate(PROPERTY_CONSTRUCTOR, "textures", skin.getBase64(), skin.getSignedBase64()); Method m = null; @@ -579,6 +587,8 @@ private static void sendOLDTabPackets(Player player, Object packet, String name, } private static void sendPacket(Object packet, Player player) { + if(player==null) + return; Object handle = getHandle(player); Object playerConnection = ReflectionUtil.getInstanceField(handle, "playerConnection"); ReflectionUtil.invokeMethod(playerConnection, "sendPacket", new Class[] { PACKET_CLASS }, packet);