Don't allow the server to increment the mapcount information.
This commit is contained in:
parent
c61f97d0eb
commit
219ac93dc4
@ -5,6 +5,7 @@ import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -14,11 +15,13 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import net.minecraft.server.v1_7_R4.EntityItemFrame;
|
||||
import net.minecraft.server.v1_7_R4.PersistentCollection;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
@ -45,6 +48,20 @@ public class Map implements Listener
|
||||
|
||||
public Map(MiniPlugin plugin, String location, Block corner1, Block corner2, BlockFace facingDirection)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
// Make sure the world doesn't change the mapcount information
|
||||
PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps;
|
||||
Field f = collection.getClass().getDeclaredField("a");
|
||||
f.setAccessible(true);
|
||||
f.set(collection, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
plugin.RegisterEvents(this);
|
||||
|
||||
// Clear out the area to make room for the picture
|
||||
@ -122,8 +139,9 @@ public class Map implements Listener
|
||||
|
||||
// Load image
|
||||
BufferedImage image = loadImage(location);
|
||||
|
||||
if (image == null){
|
||||
|
||||
if (image == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot load image at '" + location + "'");
|
||||
}
|
||||
|
||||
@ -229,9 +247,9 @@ public class Map implements Listener
|
||||
return xOk ? BlockFace.EAST : BlockFace.NORTH;
|
||||
}
|
||||
|
||||
private MapView getMap(BufferedImage image)
|
||||
private MapView getMap(World world, BufferedImage image)
|
||||
{
|
||||
MapView map = Bukkit.createMap(Bukkit.getWorlds().get(0));
|
||||
MapView map = Bukkit.createMap(world);
|
||||
|
||||
for (MapRenderer r : map.getRenderers())
|
||||
{
|
||||
@ -304,7 +322,7 @@ public class Map implements Listener
|
||||
|
||||
ItemFrame itemFrame = spawnItemFrame(block, face);
|
||||
|
||||
MapView map = getMap(image);
|
||||
MapView map = getMap(block.getWorld(), image);
|
||||
|
||||
_maps.put(itemFrame, map);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user