本文整理汇总了Java中org.bukkit.map.MapView类的典型用法代码示例。如果您正苦于以下问题:Java MapView类的具体用法?Java MapView怎么用?Java MapView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapView类属于org.bukkit.map包,在下文中一共展示了MapView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
// Map
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (UUID key : worldMap.playersVisibleOnMap.keySet()) { // Spigot string -> uuid
// If this cursor is for a player check visibility with vanish system
Player other = Bukkit.getPlayer(key); // Spigot
if (other != null && !player.canSee(other)) {
continue;
}
net.minecraft.world.storage.MapData.MapCoord decoration = (net.minecraft.world.storage.MapData.MapCoord) worldMap.playersVisibleOnMap.get(key);
cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize);
}
}
示例2: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
// Map
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (Object key : worldMap.playersVisibleOnMap.keySet()) {
// If this cursor is for a player check visibility with vanish system
Player other = Bukkit.getPlayerExact((String) key);
if (other != null && !player.canSee(other)) {
continue;
}
net.minecraft.world.storage.MapData.MapCoord decoration = (net.minecraft.world.storage.MapData.MapCoord) worldMap.playersVisibleOnMap.get(key);
cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize);
}
}
示例3: CTFGame
import org.bukkit.map.MapView; //导入依赖的package包/类
public CTFGame(GameType gt, String name, Location signLoc, Location teamSelectionLocation, Location characterSelectionLocation, LinkedList<CTFMap> maps, boolean balanceTeams)
{
super(gt, name, signLoc, maps);
flm = new FlagManager(this);
tbm = new TeamBalanceManager(this);
if(balanceTeams)
getTeamBalanceManager().startLoop();
this.teamSelectionLocation = teamSelectionLocation;
this.characterSelectionLocation = characterSelectionLocation;
// Maps
teamSizeRenderersMapId = MapManager.getNextFreeId(2);
teamSizeRenderers[0] = new SizeRenderer(BPMapPalette.getColor(BPMapPalette.RED, 2), BPMapPalette.getColor(BPMapPalette.RED, 0), getPlayersInTeam(Team.RED).size());
MapView rtsmv = Bukkit.getMap(teamSizeRenderersMapId);
teamSizeRenderers[0].set(rtsmv);
teamSizeRenderers[1] = new SizeRenderer(BPMapPalette.getColor(BPMapPalette.DARK_BLUE, 2), BPMapPalette.getColor(BPMapPalette.DARK_BLUE, 0), getPlayersInTeam(Team.BLUE).size());
MapView btsmv = Bukkit.getMap((short) (teamSizeRenderersMapId + 1));
teamSizeRenderers[1].set(btsmv);
}
示例4: AdventManager
import org.bukkit.map.MapView; //导入依赖的package包/类
public AdventManager(int year, ArrayList<AdventGift> gifts)
{
if(gifts.size() != LAST_DAY)
throw new IllegalArgumentException("gifts.size() != " + LAST_DAY + "; gifts.size() == " + gifts.size());
this.year = year;
this.gifts = gifts;
mapId = MapManager.getNextFreeId();
setDayOfMonth();
fillList();
setGift();
@SuppressWarnings("deprecation")
MapView mapView = Bukkit.getMap(mapId);
if(mapView == null)
throw new IllegalArgumentException("Bukkit.getMap(" + mapId + ") == null");
new AdventMapRenderer(this, dayOfMonth).set(mapView);
}
示例5: buildCombinedGraph
import org.bukkit.map.MapView; //导入依赖的package包/类
private void buildCombinedGraph(Player player, String[] args) {
List<GraphRenderer> renderers = Lists.newArrayList();
for (String arg : args) {
GraphRenderer renderer = graphTypes.get(arg);
if (renderer == null) {
player.sendMessage(ChatColor.DARK_RED + "Unknown graph type " + arg);
return;
}
renderers.add(renderer);
}
if (renderers.size() > MAX_COMBINED) {
player.sendMessage(ChatColor.DARK_RED + "Too many graphs");
} else {
CombinedGraph combinedGraph = new CombinedGraph(renderers.toArray(new GraphRenderer[renderers.size()]));
MapView view = installRenderer(player, combinedGraph);
giveMap(player, view);
}
}
示例6: execute
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
protected void execute(Event e) {
SkellettMapRenderer render = SkellettMapRenderer.getRenderer(map.getSingle(e));
if (render != null) {
render.update(new MapRenderTask() {
@SuppressWarnings("deprecation")
@Override
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
MapCursor cursor = new MapCursor((byte)x.getSingle(e).intValue(), (byte)y.getSingle(e).intValue(), (byte)direction.getSingle(e).intValue(), (byte) 2, true);
try {
MapCursor.Type type = MapCursor.Type.valueOf(cursorType.getSingle(e).replace("\"", "").trim().replace(" ", "_").toUpperCase());
if (type != null) {
cursor.setType(type);
}
} catch (IllegalArgumentException error) {
Bukkit.getConsoleSender().sendMessage(Skellett.cc(Skellett.prefix + "&cUnknown mapcursor type " + cursorType.getSingle(e)));
return;
}
mapCanvas.getCursors().addCursor(cursor);
}
});
}
}
示例7: execute
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
protected void execute(Event e) {
SkellettMapRenderer render = SkellettMapRenderer.getRenderer(map.getSingle(e));
if (render != null && image != null) {
Integer xget = 0;
Integer yget = 0;
if (x != null || y != null) {
xget = x.getSingle(e).intValue();
yget = y.getSingle(e).intValue();
}
final Integer xcoord = xget;
final Integer ycoord = yget;
render.update(new MapRenderTask() {
@Override
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
mapCanvas.drawImage(xcoord, ycoord, image.getSingle(e));
}
});
}
}
示例8: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
// Map
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (Map.Entry<UUID, MapData.MapCoord> key : worldMap.playersVisibleOnMap.entrySet()) {
// If this cursor is for a player check visibility with vanish system
Player other = Bukkit.getPlayer(key.getKey());
if (other != null && !player.canSee(other)) {
continue;
}
MapData.MapCoord decoration = key.getValue();
cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize);
}
}
示例9: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
// Map
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (Object key : worldMap.decorations.keySet()) {
// If this cursor is for a player check visibility with vanish system
Player other = Bukkit.getPlayerExact((String) key);
if (other != null && !player.canSee(other)) {
continue;
}
WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(key);
cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), decoration.type);
}
}
示例10: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public void render(MapView map, MapCanvas canvas, Player player) {
// Only render when on this world
if (!map.getWorld().equals(plugin.getBeaconzWorld())) {
return;
}
// Only render if the map is in a hand
ItemStack inMainHand = player.getInventory().getItemInMainHand();
ItemStack inOffHand = player.getInventory().getItemInOffHand();
if (inMainHand.getType().equals(Material.MAP) || inOffHand.getType().equals(Material.MAP)) {
//Bukkit.getLogger().info("DEBUG: render");
// here's where you do your drawing - see the Javadocs for the MapCanvas class for
// the methods you can use
canvas.drawText(10, 10, MinecraftFont.Font, Lang.beaconMapBeaconMap);
// Get the text
BeaconObj beacon = plugin.getRegister().getBeaconMap(map.getId());
if (beacon != null) {
canvas.drawText(10, 20, MinecraftFont.Font, Lang.generalLocation + ": " + beacon.getName());
canvas.setPixel(64, 64, (byte) 64);
} else {
canvas.drawText(10, 20, MinecraftFont.Font, Lang.beaconMapUnknownBeacon);
}
}
}
示例11: giveBeaconMap
import org.bukkit.map.MapView; //导入依赖的package包/类
/**
* Puts a beacon map in the player's main hand
* @param player
* @param beacon
*/
@SuppressWarnings("deprecation")
private void giveBeaconMap(Player player, BeaconObj beacon) {
// Make a map!
player.sendMessage(ChatColor.GREEN + Lang.beaconYouHaveAMap);
MapView map = Bukkit.createMap(getBeaconzWorld());
//map.setWorld(getBeaconzWorld());
map.setCenterX(beacon.getX());
map.setCenterZ(beacon.getZ());
map.getRenderers().clear();
map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin()));
map.addRenderer(new BeaconMap(getBeaconzPlugin()));
ItemStack newMap = new ItemStack(Material.MAP);
newMap.setDurability(map.getId());
ItemMeta meta = newMap.getItemMeta();
meta.setDisplayName("Beacon map for " + beacon.getName());
newMap.setItemMeta(meta);
// Each map is unique and the durability defines the map ID, register it
getRegister().addBeaconMap(map.getId(), beacon);
//getLogger().info("DEBUG: beacon id = " + beacon.getId());
// Put map into hand
ItemStack inHand = player.getInventory().getItemInMainHand();
player.getInventory().setItemInMainHand(newMap);
player.getInventory().addItem(inHand);
}
示例12: onMapHold
import org.bukkit.map.MapView; //导入依赖的package包/类
/**
* Make sure all player held maps have triangle overlays. (todo: make sure all maps on item frames do as well)
* There seem to be some bugs around this. It doesn't always take on the first try.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
public void onMapHold(final PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ItemStack itemInHand = player.getInventory().getItem(event.getNewSlot());
if (itemInHand == null) return;
if (!Material.MAP.equals(itemInHand.getType())) {
return;
}
if (!player.getWorld().equals(getBeaconzWorld())) {
return;
}
@SuppressWarnings("deprecation")
MapView map = Bukkit.getMap(itemInHand.getDurability());
for (MapRenderer renderer : map.getRenderers()) {
if (renderer instanceof TerritoryMapRenderer) {
return;
}
}
map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin()));
}
示例13: split
import org.bukkit.map.MapView; //导入依赖的package包/类
public MapImageSpliter split(Image data, Color color) {
if (this.split) return this;
this.split = true;
BufferedImage image = this.format(data, color);
MapManager manager = MapManager.getInstance();
int width = image.getWidth(null) / this.width;
int height = image.getHeight(null) / this.height;
for (int x = 0; x < this.width; x++) for (int y = 0; y < this.height; y++) {
MapView map = manager.newMap(this.getMapId(x, y), this.world);
manager.clearRender(map);
map.addRenderer(new MapImageRender(image.getSubimage(x * width, y * height, width, height)));
}
return this;
}
示例14: render
import org.bukkit.map.MapView; //导入依赖的package包/类
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
// Map
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (Object key : worldMap.g.keySet()) {
// If this cursor is for a player check visibility with vanish system
Player other = Bukkit.getPlayerExact((String) key);
if (other != null && !player.canSee(other)) {
continue;
}
WorldMapDecoration decoration = (WorldMapDecoration) worldMap.g.get(key);
cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), decoration.type);
}
}
示例15: get
import org.bukkit.map.MapView; //导入依赖的package包/类
@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 key = URLMap.getKey(worldName, url, x, y, width, height);
if (keyMap.containsKey(key)) {
URLMap map = keyMap.get(key);
map.priority = priority;
map.name = name;
map.xOverlay = xOverlay;
map.yOverlay = yOverlay;
return map;
}
World world = Bukkit.getWorld(worldName);
MapView mapView = Bukkit.createMap(world);
if (mapView == null) {
warning("Unable to create new map for url key " + key);
return null;
}
URLMap newMap = get(worldName, mapView.getId(), url, name, x, y, xOverlay, yOverlay, width, height, priority);
save();
return newMap;
}