Skip to content

Commit

Permalink
v1.0.48
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker authored Nov 11, 2018
1 parent deab669 commit e32e346
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
9 changes: 8 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,29 @@ 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;
}

// 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++;
}
Expand Down
37 changes: 26 additions & 11 deletions src/me/zombie_striker/pluginconstructor/MapWallUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion src/me/zombie_striker/pluginconstructor/PlayerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e32e346

Please sign in to comment.