use of net.aufdemrand.denizen.utilities.maps.DenizenMapRenderer in project Denizen-For-Bukkit by DenizenScript.
the class MapCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element id = scriptEntry.getElement("map-id");
dWorld create = scriptEntry.getdObject("new");
Element reset = scriptEntry.getElement("reset");
dLocation resetLoc = scriptEntry.getdObject("reset-loc");
Element image = scriptEntry.getElement("image");
dScript script = scriptEntry.getdObject("script");
Element resize = scriptEntry.getElement("resize");
Element width = scriptEntry.getElement("width");
Element height = scriptEntry.getElement("height");
Element x = scriptEntry.getElement("x-value");
Element y = scriptEntry.getElement("y-value");
dB.report(scriptEntry, getName(), (id != null ? id.debug() : "") + (create != null ? create.debug() : "") + reset.debug() + (resetLoc != null ? resetLoc.debug() : "") + (image != null ? image.debug() : "") + (script != null ? script.debug() : "") + resize.debug() + (width != null ? width.debug() : "") + (height != null ? height.debug() : "") + x.debug() + y.debug());
MapView map = null;
if (create != null) {
map = Bukkit.getServer().createMap(create.getWorld());
scriptEntry.addObject("created_map", new Element(map.getId()));
} else if (id != null) {
map = Bukkit.getServer().getMap((short) id.asInt());
if (map == null) {
throw new CommandExecutionException("No map found for ID '" + id.asInt() + "'!");
}
} else {
throw new CommandExecutionException("The map command failed somehow! Report this to a developer!");
}
if (reset.asBoolean()) {
List<MapRenderer> oldRenderers = DenizenMapManager.removeDenizenRenderers(map);
for (MapRenderer renderer : oldRenderers) {
map.addRenderer(renderer);
}
if (resetLoc != null) {
map.setCenterX(resetLoc.getBlockX());
map.setCenterZ(resetLoc.getBlockZ());
map.setWorld(resetLoc.getWorld());
}
} else if (script != null) {
DenizenMapManager.removeDenizenRenderers(map);
((MapScriptContainer) script.getContainer()).applyTo(map);
} else {
DenizenMapRenderer dmr = DenizenMapManager.getDenizenRenderer(map);
if (image != null) {
int wide = width != null ? width.asInt() : resize.asBoolean() ? 128 : 0;
int high = height != null ? height.asInt() : resize.asBoolean() ? 128 : 0;
if (CoreUtilities.toLowerCase(image.asString()).endsWith(".gif")) {
dmr.addObject(new MapAnimatedImage(x.asString(), y.asString(), "true", false, image.asString(), wide, high));
} else {
dmr.addObject(new MapImage(x.asString(), y.asString(), "true", false, image.asString(), wide, high));
}
}
}
}
Aggregations