mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 01:17:44 +01:00
SPIGOT-4608: Improve quality of MapMeta APIs
This commit is contained in:
parent
2ced02339a
commit
3d19f011e9
@ -1244,7 +1244,7 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public CraftMapView getMap(short id) {
|
public CraftMapView getMap(int id) {
|
||||||
PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps;
|
PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps;
|
||||||
WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id);
|
WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id);
|
||||||
if (worldmap == null) {
|
if (worldmap == null) {
|
||||||
|
@ -6,12 +6,15 @@ import net.minecraft.server.NBTTagCompound;
|
|||||||
import net.minecraft.server.NBTTagInt;
|
import net.minecraft.server.NBTTagInt;
|
||||||
import net.minecraft.server.NBTTagString;
|
import net.minecraft.server.NBTTagString;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||||
import org.bukkit.inventory.meta.MapMeta;
|
import org.bukkit.inventory.meta.MapMeta;
|
||||||
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
|
||||||
@ -147,6 +150,22 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
|
|||||||
this.mapId = id;
|
this.mapId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMapView() {
|
||||||
|
return mapId != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapView getMapView() {
|
||||||
|
Preconditions.checkState(hasMapView(), "Item does not have map associated - check hasMapView() first!");
|
||||||
|
return Bukkit.getMap(mapId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMapView(MapView map) {
|
||||||
|
this.mapId = (map != null) ? map.getId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
boolean hasScaling() {
|
boolean hasScaling() {
|
||||||
return scaling != SCALING_EMPTY;
|
return scaling != SCALING_EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -206,6 +206,13 @@ public class Commodore
|
|||||||
super.visitMethodInsn( opcode, owner, name, "()I", itf );
|
super.visitMethodInsn( opcode, owner, name, "()I", itf );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// SPIGOT-4608
|
||||||
|
if ( (owner.equals( "org/bukkit/Bukkit" ) || owner.equals( "org/bukkit/Server" ) ) && name.equals( "getMap" ) && desc.equals( "(Lorg/bukkit/map/MapView;)S" ) )
|
||||||
|
{
|
||||||
|
// Should be same size on stack so just call other method
|
||||||
|
super.visitMethodInsn( opcode, owner, name, "(Lorg/bukkit/map/MapView;)I", itf );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( modern )
|
if ( modern )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user