use of org.bukkit.map.MapView in project Denizen-For-Bukkit by DenizenScript.
the class dPlayer method adjust.
@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
// -->
if (mechanism.matches("level") && mechanism.requireInteger()) {
setLevel(value.asInt());
}
// -->
if (mechanism.matches("item_slot") && mechanism.requireInteger()) {
if (isOnline()) {
getPlayerEntity().getInventory().setHeldItemSlot(value.asInt() - 1);
} else {
getNBTEditor().setItemInHand(value.asInt() - 1);
}
}
// -->
if (mechanism.matches("item_on_cursor") && mechanism.requireObject(dItem.class)) {
getPlayerEntity().setItemOnCursor(value.asType(dItem.class).getItemStack());
}
// TODO: Player achievement tags.
if (mechanism.matches("award_achievement") && mechanism.requireEnum(false, Achievement.values())) {
getPlayerEntity().awardAchievement(Achievement.valueOf(value.asString().toUpperCase()));
}
// -->
if (mechanism.matches("health_scale") && mechanism.requireDouble()) {
getPlayerEntity().setHealthScale(value.asDouble());
}
// -->
if (mechanism.matches("scale_health") && mechanism.requireBoolean()) {
getPlayerEntity().setHealthScaled(value.asBoolean());
}
// Allow offline editing of health values
if (mechanism.matches("max_health") && mechanism.requireDouble()) {
setMaxHealth(value.asDouble());
}
if (mechanism.matches("health") && mechanism.requireDouble()) {
setHealth(value.asDouble());
}
// -->
if (mechanism.matches("resource_pack") || mechanism.matches("texture_pack")) {
getPlayerEntity().setResourcePack(value.asString());
}
// -->
if (mechanism.matches("saturation") && mechanism.requireFloat()) {
getPlayerEntity().setSaturation(value.asFloat());
}
// -->
if (mechanism.matches("send_map") && mechanism.requireInteger()) {
MapView map = Bukkit.getServer().getMap((short) value.asInt());
if (map != null) {
getPlayerEntity().sendMap(map);
} else {
dB.echoError("No map found for ID " + value.asInt() + "!");
}
}
// -->
if (mechanism.matches("food_level") && mechanism.requireInteger()) {
setFoodLevel(value.asInt());
}
// -->
if (mechanism.matches("bed_spawn_location") && mechanism.requireObject(dLocation.class)) {
setBedSpawnLocation(value.asType(dLocation.class));
}
// -->
if (mechanism.matches("can_fly") && mechanism.requireBoolean()) {
getPlayerEntity().setAllowFlight(value.asBoolean());
}
// -->
if (mechanism.matches("fly_speed") && mechanism.requireFloat()) {
setFlySpeed(value.asFloat());
}
// -->
if (mechanism.matches("flying") && mechanism.requireBoolean()) {
getPlayerEntity().setFlying(value.asBoolean());
}
// -->
if (mechanism.matches("gamemode") && mechanism.requireEnum(false, GameMode.values())) {
setGameMode(GameMode.valueOf(value.asString().toUpperCase()));
}
// -->
if (mechanism.matches("kick")) {
getPlayerEntity().kickPlayer(mechanism.getValue().asString());
}
// -->
if (mechanism.matches("weather") && mechanism.requireEnum(false, WeatherType.values())) {
getPlayerEntity().setPlayerWeather(WeatherType.valueOf(value.asString().toUpperCase()));
}
// -->
if (mechanism.matches("reset_weather")) {
getPlayerEntity().resetPlayerWeather();
}
// -->
if (mechanism.matches("player_list_name")) {
getPlayerEntity().setPlayerListName(value.asString());
}
// -->
if (mechanism.matches("display_name")) {
getPlayerEntity().setDisplayName(value.asString());
return;
}
// -->
if (mechanism.matches("show_workbench") && mechanism.requireObject(dLocation.class)) {
getPlayerEntity().openWorkbench(mechanism.getValue().asType(dLocation.class), true);
return;
}
// -->
if (mechanism.matches("location") && mechanism.requireObject(dLocation.class)) {
setLocation(value.asType(dLocation.class));
}
// -->
if (mechanism.matches("time") && mechanism.requireInteger()) {
getPlayerEntity().setPlayerTime(value.asInt(), true);
}
// -->
if (mechanism.matches("freeze_time")) {
if (mechanism.requireInteger("Invalid integer specified. Assuming current world time.")) {
getPlayerEntity().setPlayerTime(value.asInt(), false);
} else {
getPlayerEntity().setPlayerTime(getPlayerEntity().getWorld().getTime(), false);
}
}
// -->
if (mechanism.matches("reset_time")) {
getPlayerEntity().resetPlayerTime();
}
// -->
if (mechanism.matches("walk_speed") && mechanism.requireFloat()) {
getPlayerEntity().setWalkSpeed(value.asFloat());
}
// -->
if (mechanism.matches("exhaustion") && mechanism.requireFloat()) {
getPlayerEntity().setExhaustion(value.asFloat());
}
// -->
if (mechanism.matches("show_entity") && mechanism.requireObject(dEntity.class)) {
NMSHandler.getInstance().getEntityHelper().unhideEntity(getPlayerEntity(), value.asType(dEntity.class).getBukkitEntity());
}
// -->
if (mechanism.matches("hide_entity")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length > 0 && new Element(split[0]).matchesType(dEntity.class)) {
dEntity entity = value.asType(dEntity.class);
if (!entity.isSpawned()) {
dB.echoError("Can't hide the unspawned entity '" + split[0] + "'!");
} else if (split.length > 1 && new Element(split[1]).isBoolean()) {
NMSHandler.getInstance().getEntityHelper().hideEntity(getPlayerEntity(), entity.getBukkitEntity(), new Element(split[1]).asBoolean());
} else {
NMSHandler.getInstance().getEntityHelper().hideEntity(getPlayerEntity(), entity.getBukkitEntity(), false);
}
} else {
dB.echoError("'" + split[0] + "' is not a valid entity!");
}
}
}
// -->
if (mechanism.matches("show_boss_bar")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length == 2 && new Element(split[0]).isDouble()) {
NMSHandler.getInstance().getPlayerHelper().showSimpleBossBar(getPlayerEntity(), split[1], new Element(split[0]).asDouble() / 200);
} else {
NMSHandler.getInstance().getPlayerHelper().showSimpleBossBar(getPlayerEntity(), split[0], 1.0);
}
} else {
NMSHandler.getInstance().getPlayerHelper().removeSimpleBossBar(getPlayerEntity());
}
}
// -->
if (mechanism.matches("fake_experience")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length > 0 && new Element(split[0]).isFloat()) {
if (split.length > 1 && new Element(split[1]).isInt()) {
NMSHandler.getInstance().getPacketHelper().showExperience(getPlayerEntity(), new Element(split[0]).asFloat(), new Element(split[1]).asInt());
} else {
NMSHandler.getInstance().getPacketHelper().showExperience(getPlayerEntity(), new Element(split[0]).asFloat(), getPlayerEntity().getLevel());
}
} else {
dB.echoError("'" + split[0] + "' is not a valid decimal number!");
}
} else {
NMSHandler.getInstance().getPacketHelper().resetExperience(getPlayerEntity());
}
}
// -->
if (mechanism.matches("fake_health")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 3);
if (split.length > 0 && new Element(split[0]).isFloat()) {
if (split.length > 1 && new Element(split[1]).isInt()) {
if (split.length > 2 && new Element(split[2]).isFloat()) {
NMSHandler.getInstance().getPacketHelper().showHealth(getPlayerEntity(), new Element(split[0]).asFloat(), new Element(split[1]).asInt(), new Element(split[2]).asFloat());
} else {
NMSHandler.getInstance().getPacketHelper().showHealth(getPlayerEntity(), new Element(split[0]).asFloat(), new Element(split[1]).asInt(), getPlayerEntity().getSaturation());
}
} else {
NMSHandler.getInstance().getPacketHelper().showHealth(getPlayerEntity(), new Element(split[0]).asFloat(), getPlayerEntity().getFoodLevel(), getPlayerEntity().getSaturation());
}
} else {
dB.echoError("'" + split[0] + "' is not a valid decimal number!");
}
} else {
NMSHandler.getInstance().getPacketHelper().resetHealth(getPlayerEntity());
}
}
// -->
if (mechanism.matches("fake_equipment")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 3);
if (split.length > 0 && new Element(split[0]).matchesType(dEntity.class)) {
String slot = split[1].toUpperCase();
if (split.length > 1 && (new Element(slot).matchesEnum(EquipmentSlot.values()) || slot.equals("MAIN_HAND") || slot.equals("BOOTS"))) {
if (split.length > 2 && new Element(split[2]).matchesType(dItem.class)) {
if (slot.equals("MAIN_HAND")) {
slot = "HAND";
} else if (slot.equals("BOOTS")) {
slot = "FEET";
}
NMSHandler.getInstance().getPacketHelper().showEquipment(getPlayerEntity(), new Element(split[0]).asType(dEntity.class).getLivingEntity(), EquipmentSlot.valueOf(slot), new Element(split[2]).asType(dItem.class).getItemStack());
} else if (split.length > 2) {
dB.echoError("'" + split[2] + "' is not a valid dItem!");
}
} else if (split.length > 1) {
dB.echoError("'" + split[1] + "' is not a valid slot; must be HAND, OFF_HAND, BOOTS, LEGS, CHEST, or HEAD!");
} else {
NMSHandler.getInstance().getPacketHelper().resetEquipment(getPlayerEntity(), new Element(split[0]).asType(dEntity.class).getLivingEntity());
}
} else {
dB.echoError("'" + split[0] + "' is not a valid dEntity!");
}
}
}
// -->
if (mechanism.matches("item_message")) {
ItemChangeMessage.sendMessage(getPlayerEntity(), value.asString());
}
// -->
if (mechanism.matches("show_endcredits")) {
NMSHandler.getInstance().getPlayerHelper().showEndCredits(getPlayerEntity());
}
// -->
if (mechanism.matches("spectate") && mechanism.requireObject(dEntity.class)) {
NMSHandler.getInstance().getPacketHelper().forceSpectate(getPlayerEntity(), value.asType(dEntity.class).getBukkitEntity());
}
// -->
if (mechanism.matches("open_book")) {
NMSHandler.getInstance().getPacketHelper().openBook(getPlayerEntity(), EquipmentSlot.HAND);
}
// -->
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2) && mechanism.matches("open_offhand_book")) {
NMSHandler.getInstance().getPacketHelper().openBook(getPlayerEntity(), EquipmentSlot.OFF_HAND);
}
// -->
if (mechanism.matches("edit_sign") && mechanism.requireObject(dLocation.class)) {
if (!NMSHandler.getInstance().getPacketHelper().showSignEditor(getPlayerEntity(), value.asType(dLocation.class))) {
dB.echoError("Can't edit non-sign materials!");
}
}
// -->
if (mechanism.matches("tab_list_info")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (split.length > 0) {
String header = split[0];
String footer = "";
if (split.length > 1) {
footer = split[1];
}
NMSHandler.getInstance().getPacketHelper().showTabListHeaderFooter(getPlayerEntity(), header, footer);
} else {
dB.echoError("Must specify a header and footer to show!");
}
} else {
NMSHandler.getInstance().getPacketHelper().resetTabListHeaderFooter(getPlayerEntity());
}
}
// -->
if (mechanism.matches("sign_update")) {
if (!value.asString().isEmpty()) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2);
if (dLocation.matches(split[0]) && split.length > 1) {
dList lines = dList.valueOf(split[1]);
getPlayerEntity().sendSignChange(dLocation.valueOf(split[0]), lines.toArray(4));
} else {
dB.echoError("Must specify a valid location and at least one sign line!");
}
} else {
dB.echoError("Must specify a valid location and at least one sign line!");
}
}
// -->
if (mechanism.matches("banner_update")) {
if (value.asString().length() > 0) {
String[] split = value.asString().split("[\\|" + dList.internal_escape + "]");
List<org.bukkit.block.banner.Pattern> patterns = new ArrayList<org.bukkit.block.banner.Pattern>();
if (split.length > 2) {
List<String> splitList;
for (int i = 2; i > split.length; i++) {
String string = split[i];
try {
splitList = CoreUtilities.split(string, '/', 2);
patterns.add(new org.bukkit.block.banner.Pattern(DyeColor.valueOf(splitList.get(0).toUpperCase()), PatternType.valueOf(splitList.get(1).toUpperCase())));
} catch (Exception e) {
dB.echoError("Could not apply pattern to banner: " + string);
}
}
}
if (dLocation.matches(split[0]) && split.length > 1) {
dLocation location = dLocation.valueOf(split[0]);
DyeColor base;
try {
base = DyeColor.valueOf(split[1].toUpperCase());
} catch (Exception e) {
dB.echoError("Could not apply base color to banner: " + split[1]);
return;
}
NMSHandler.getInstance().getPacketHelper().showBannerUpdate(getPlayerEntity(), location, base, patterns);
} else {
dB.echoError("Must specify a valid location and a base color!");
}
}
}
// -->
if (mechanism.matches("action_bar")) {
NMSHandler.getInstance().getPacketHelper().sendActionBarMessage(getPlayerEntity(), value.asString());
}
// -->
if (mechanism.matches("name")) {
String name = value.asString();
if (name.length() > 16) {
dB.echoError("Must specify a name with no more than 16 characters.");
} else {
NMSHandler.getInstance().getProfileEditor().setPlayerName(getPlayerEntity(), value.asString());
}
}
// -->
if (mechanism.matches("skin")) {
String name = value.asString();
if (name.length() > 16) {
dB.echoError("Must specify a name with no more than 16 characters.");
} else {
NMSHandler.getInstance().getProfileEditor().setPlayerSkin(getPlayerEntity(), value.asString());
}
}
// -->
if (mechanism.matches("skin_blob")) {
NMSHandler.getInstance().getProfileEditor().setPlayerSkinBlob(getPlayerEntity(), value.asString());
}
// -->
if (mechanism.matches("is_whitelisted") && mechanism.requireBoolean()) {
getPlayerEntity().setWhitelisted(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("is_op") && mechanism.requireBoolean()) {
getOfflinePlayer().setOp(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("is_banned") && mechanism.requireBoolean()) {
getOfflinePlayer().setBanned(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("money") && mechanism.requireDouble() && Depends.economy != null) {
double bal = Depends.economy.getBalance(getOfflinePlayer());
double goal = value.asDouble();
if (goal > bal) {
Depends.economy.depositPlayer(getOfflinePlayer(), goal - bal);
} else if (bal > goal) {
Depends.economy.withdrawPlayer(getOfflinePlayer(), bal - goal);
}
}
if (Depends.chat != null) {
// -->
if (mechanism.matches("chat_prefix")) {
Depends.chat.setPlayerPrefix(getPlayerEntity(), value.asString());
}
// -->
if (mechanism.matches("chat_suffix")) {
Depends.chat.setPlayerSuffix(getPlayerEntity(), value.asString());
}
}
// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}
// Pass along to dEntity mechanism handler if not already handled.
if (!mechanism.fulfilled()) {
Adjustable entity = new dEntity(getPlayerEntity());
entity.adjust(mechanism);
}
}
use of org.bukkit.map.MapView in project Denizen-For-Bukkit by DenizenScript.
the class DenizenMapManager method reloadMaps.
public static void reloadMaps() {
Map<Short, List<MapRenderer>> oldMapRenderers = new HashMap<Short, List<MapRenderer>>();
for (Map.Entry<Short, DenizenMapRenderer> entry : mapRenderers.entrySet()) {
DenizenMapRenderer renderer = entry.getValue();
oldMapRenderers.put(entry.getKey(), renderer.getOldRenderers());
renderer.deactivate();
}
mapRenderers.clear();
downloadedByUrl.clear();
mapsConfig = YamlConfiguration.loadConfiguration(mapsFile);
ConfigurationSection mapsSection = mapsConfig.getConfigurationSection("MAPS");
if (mapsSection == null) {
return;
}
for (String key : mapsSection.getKeys(false)) {
short mapId = Short.valueOf(key);
MapView mapView = Bukkit.getServer().getMap(mapId);
if (mapView == null) {
dB.echoError("Map #" + key + " does not exist. Has it been removed? Deleting from maps.yml...");
mapsSection.set(key, null);
continue;
}
ConfigurationSection objectsData = mapsSection.getConfigurationSection(key + ".objects");
List<MapRenderer> oldRenderers;
if (oldMapRenderers.containsKey(mapId)) {
oldRenderers = oldMapRenderers.get(mapId);
} else {
oldRenderers = mapView.getRenderers();
for (MapRenderer oldRenderer : oldRenderers) {
mapView.removeRenderer(oldRenderer);
}
}
DenizenMapRenderer renderer = new DenizenMapRenderer(oldRenderers, mapsSection.getBoolean(key + ".auto update", false));
List<String> objects = new ArrayList<String>(objectsData.getKeys(false));
Collections.sort(objects, new NaturalOrderComparator());
for (String objectKey : objects) {
String type = objectsData.getString(objectKey + ".type").toUpperCase();
String xTag = objectsData.getString(objectKey + ".x");
String yTag = objectsData.getString(objectKey + ".y");
String visibilityTag = objectsData.getString(objectKey + ".visibility");
boolean debug = objectsData.getBoolean(objectKey + ".debug");
MapObject object = null;
if (type.equals("CURSOR")) {
object = new MapCursor(xTag, yTag, visibilityTag, debug, objectsData.getString(objectKey + ".direction"), objectsData.getString(objectKey + ".cursor"));
} else if (type.equals("IMAGE")) {
String file = objectsData.getString(objectKey + ".image");
int width = objectsData.getInt(objectKey + ".width", 0);
int height = objectsData.getInt(objectKey + ".height", 0);
if (CoreUtilities.toLowerCase(file).endsWith(".gif")) {
object = new MapAnimatedImage(xTag, yTag, visibilityTag, debug, file, width, height);
} else {
object = new MapImage(xTag, yTag, visibilityTag, debug, file, width, height);
}
} else if (type.equals("TEXT")) {
object = new MapText(xTag, yTag, visibilityTag, debug, objectsData.getString(objectKey + ".text"));
}
if (object != null) {
renderer.addObject(object);
}
}
mapView.addRenderer(renderer);
mapRenderers.put(mapId, renderer);
}
for (Map.Entry<Short, List<MapRenderer>> entry : oldMapRenderers.entrySet()) {
short id = entry.getKey();
if (!mapRenderers.containsKey(id)) {
MapView mapView = Bukkit.getServer().getMap(id);
if (mapView != null) {
for (MapRenderer renderer : entry.getValue()) {
mapView.addRenderer(renderer);
}
}
// If it's null, the server no longer has the map - don't do anything about it
}
}
ConfigurationSection downloadedImages = mapsConfig.getConfigurationSection("DOWNLOADED");
if (downloadedImages == null) {
return;
}
for (String image : downloadedImages.getKeys(false)) {
downloadedByUrl.put(CoreUtilities.toLowerCase(downloadedImages.getString(image)), image.replace("DOT", "."));
}
}
use of org.bukkit.map.MapView in project MagicPlugin by elBukkit.
the class MapSpell method onCast.
@SuppressWarnings("deprecation")
@Override
public SpellResult onCast(ConfigurationSection parameters) {
World world = getWorld();
MapView newMap = Bukkit.createMap(world);
Location location = getLocation();
newMap.setCenterX(location.getBlockX());
newMap.setCenterZ(location.getBlockZ());
MapView.Scale scale = newMap.getScale();
String scaleType = parameters.getString("scale");
if (scaleType != null) {
try {
scale = MapView.Scale.valueOf(scaleType.toUpperCase());
} catch (Exception ignored) {
}
}
newMap.setScale(scale);
ItemStack newMapItem = new ItemStack(Material.MAP, 1, newMap.getId());
world.dropItemNaturally(getLocation(), newMapItem);
return SpellResult.CAST;
}
use of org.bukkit.map.MapView in project MagicPlugin by elBukkit.
the class MaterialBrush method update.
@Override
@SuppressWarnings("deprecation")
public boolean update(final Mage fromMage, final Location target) {
if (mode == BrushMode.CLONE || mode == BrushMode.REPLICATE) {
if (cloneSource == null) {
isValid = false;
return true;
}
if (cloneTarget == null)
cloneTarget = target;
materialTarget = toTargetLocation(target);
if (materialTarget.getY() < 0 || materialTarget.getWorld() == null || materialTarget.getY() > materialTarget.getWorld().getMaxHeight()) {
isValid = false;
} else {
Block block = materialTarget.getBlock();
if (!block.getChunk().isLoaded())
return false;
updateFromBlock(block, fromMage.getRestrictedMaterialSet());
isValid = fillWithAir || material != Material.AIR;
}
}
if (mode == BrushMode.SCHEMATIC) {
if (!checkSchematic()) {
return true;
}
if (cloneTarget == null) {
isValid = false;
return true;
}
Vector diff = target.toVector().subtract(cloneTarget.toVector());
com.elmakers.mine.bukkit.api.block.MaterialAndData newMaterial = schematic.getBlock(diff);
if (newMaterial == null) {
isValid = false;
} else {
updateFrom(newMaterial);
isValid = fillWithAir || newMaterial.getMaterial() != Material.AIR;
}
}
if (mode == BrushMode.MAP && mapId >= 0) {
if (mapCanvas == null) {
try {
MapView mapView = Bukkit.getMap((short) mapId);
if (mapView != null) {
Player player = fromMage != null ? fromMage.getPlayer() : null;
List<MapRenderer> renderers = mapView.getRenderers();
if (renderers.size() > 0) {
mapCanvas = new BufferedMapCanvas();
MapRenderer renderer = renderers.get(0);
// This is mainly here as a hack for my own urlmaps that do their own caching
// Bukkit *seems* to want to do caching at the MapView level, but looking at the code-
// they cache but never use the cache?
// Anyway render gets called constantly so I'm not re-rendering on each render... but then
// how to force a render to a canvas? So we re-initialize.
renderer.initialize(mapView);
renderer.render(mapView, mapCanvas, player);
}
}
} catch (Exception ex) {
controller.getLogger().log(Level.WARNING, "Error reading map id " + mapId, ex);
}
}
isValid = false;
if (mapCanvas != null && cloneTarget != null) {
Vector diff = target.toVector().subtract(cloneTarget.toVector());
// TODO : Different orientations, centering, scaling, etc
// We default to 1/8 scaling for now to make the portraits work well.
DyeColor mapColor = DyeColor.WHITE;
if (orientVector.getBlockY() > orientVector.getBlockZ() || orientVector.getBlockY() > orientVector.getBlockX()) {
if (orientVector.getBlockX() > orientVector.getBlockZ()) {
mapColor = mapCanvas.getDyeColor(Math.abs((int) (diff.getBlockX() * scale + BufferedMapCanvas.CANVAS_WIDTH / 2) % BufferedMapCanvas.CANVAS_WIDTH), Math.abs((int) (-diff.getBlockY() * scale + BufferedMapCanvas.CANVAS_HEIGHT / 2) % BufferedMapCanvas.CANVAS_HEIGHT));
} else {
mapColor = mapCanvas.getDyeColor(Math.abs((int) (diff.getBlockZ() * scale + BufferedMapCanvas.CANVAS_WIDTH / 2) % BufferedMapCanvas.CANVAS_WIDTH), Math.abs((int) (-diff.getBlockY() * scale + BufferedMapCanvas.CANVAS_HEIGHT / 2) % BufferedMapCanvas.CANVAS_HEIGHT));
}
} else {
mapColor = mapCanvas.getDyeColor(Math.abs((int) (diff.getBlockX() * scale + BufferedMapCanvas.CANVAS_WIDTH / 2) % BufferedMapCanvas.CANVAS_WIDTH), Math.abs((int) (diff.getBlockZ() * scale + BufferedMapCanvas.CANVAS_HEIGHT / 2) % BufferedMapCanvas.CANVAS_HEIGHT));
}
if (mapColor != null) {
this.material = mapMaterialBase;
this.data = (short) mapColor.getWoolData();
isValid = true;
}
}
}
return true;
}
use of org.bukkit.map.MapView in project MagicPlugin by elBukkit.
the class MapController method get.
@Nullable
@SuppressWarnings("deprecation")
private URLMap get(String worldName, String url, String name, int x, int y, Integer xOverlay, Integer yOverlay, int width, int height, Integer priority, String playerName) {
URLMap existing = null;
if (url == null) {
existing = playerMap.get(playerName);
} else {
String key = URLMap.getKey(worldName, url, playerName, x, y, width, height);
existing = keyMap.get(key);
}
if (existing != null) {
existing.priority = priority;
existing.name = name;
existing.xOverlay = xOverlay;
existing.yOverlay = yOverlay;
return existing;
}
World world = Bukkit.getWorld(worldName);
MapView mapView = Bukkit.createMap(world);
if (mapView == null) {
if (url == null) {
warning("Unable to create new map for player " + playerName);
} else {
warning("Unable to create new map for url " + url);
}
return null;
}
URLMap newMap = get(worldName, mapView.getId(), url, name, x, y, xOverlay, yOverlay, width, height, priority, playerName);
save();
return newMap;
}
Aggregations