Permalink
Browse files

Add map meta key "mapid"

  • Loading branch information...
PseudoKnight committed Aug 8, 2018
1 parent ce6290d commit 6a8a2336ce7ca059a41eec85a64fe9f8ee36b3bc
@@ -2,6 +2,12 @@
public interface MCMapMeta extends MCItemMeta {
boolean hasMapId();
int getMapId();
void setMapId(int id);
MCColor getColor();
void setColor(MCColor color);
@@ -13,6 +13,21 @@ public BukkitMCMapMeta(MapMeta im) {
mm = im;
}
@Override
public boolean hasMapId() {
return mm.hasMapId();
}
@Override
public int getMapId() {
return mm.getMapId();
}
@Override
public void setMapId(int id) {
mm.setMapId(id);
}
@Override
public MCColor getColor() {
if(mm.hasColor()) {
@@ -528,15 +528,19 @@ public Construct itemMeta(MCItemStack is, Target t) {
} else {
ma.set("spawntype", new CString(spawntype.name(), t), t);
}
} else if(meta instanceof MCMapMeta && Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_11)) {
MCColor mapcolor = ((MCMapMeta) meta).getColor();
Construct color;
} else if(meta instanceof MCMapMeta) {
MCMapMeta mm = ((MCMapMeta) meta);
MCColor mapcolor = mm.getColor();
if(mapcolor == null) {
color = CNull.NULL;
ma.set("color", CNull.NULL, t);
} else {
color = color(mapcolor, t);
ma.set("color", color(mapcolor, t), t);
}
if(mm.hasMapId()) {
ma.set("mapid", new CInt(mm.getMapId(), t), t);
} else {
ma.set("mapid", CNull.NULL, t);
}
ma.set("color", color, t);
}
return ma;
}
@@ -868,6 +872,12 @@ public MCItemMeta itemMeta(Construct c, MCMaterial mat, Target t) throws ConfigR
throw new CREFormatException("Color was expected to be an array.", t);
}
}
if(ma.containsKey("mapid")) {
Construct cid = ma.get("mapid", t);
if(!(cid instanceof CNull)) {
((MCMapMeta) meta).setMapId(Static.getInt32(cid, t));
}
}
}
} catch (Exception ex) {
throw new CREFormatException(ex.getMessage(), t, ex);

0 comments on commit 6a8a233

Please sign in to comment.