13
0
geforkt von Mirrors/Paper

SPIGOT-4608: Improve quality of MapMeta APIs

Dieser Commit ist enthalten in:
md_5 2019-02-05 21:29:03 +11:00
Ursprung 2ced02339a
Commit 3d19f011e9
3 geänderte Dateien mit 27 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -1244,7 +1244,7 @@ public final class CraftServer implements Server {
@Override
@Deprecated
public CraftMapView getMap(short id) {
public CraftMapView getMap(int id) {
PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps;
WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id);
if (worldmap == null) {

Datei anzeigen

@ -6,12 +6,15 @@ import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.NBTTagInt;
import net.minecraft.server.NBTTagString;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.map.MapView;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
@ -147,6 +150,22 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
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() {
return scaling != SCALING_EMPTY;
}

Datei anzeigen

@ -206,6 +206,13 @@ public class Commodore
super.visitMethodInsn( opcode, owner, name, "()I", itf );
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 )
{