Java 类org.bukkit.map.MapView 实例源码
项目:Uranium
文件:CraftMapRenderer.java
@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);
}
}
项目:ThermosRebased
文件:CraftMapRenderer.java
@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);
}
}
项目:Breakpoint
文件:CTFGame.java
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);
}
项目:Breakpoint
文件:AdventManager.java
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);
}
项目:LagMonitor
文件:GraphCommand.java
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);
}
}
项目:Skellett
文件:EffMapDrawCursor.java
@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);
}
});
}
}
项目:Skellett
文件:EffMapDrawImage.java
@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));
}
});
}
}
项目:KCauldron
文件:CraftMapRenderer.java
@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);
}
}
项目:CauldronGit
文件:CraftMapRenderer.java
@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);
}
}
项目:Cauldron-Old
文件:CraftMapRenderer.java
@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);
}
}
项目:Cauldron-Reloaded
文件:CraftMapRenderer.java
@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);
}
}
项目:FFoKC
文件:CraftMapRenderer.java
@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);
}
}
项目:CraftBukkit
文件:CraftMapRenderer.java
@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);
}
}
项目:Breakpoint
文件:CTFGame.java
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);
}
项目:Breakpoint
文件:AdventManager.java
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);
}
项目:beaconz
文件:BeaconMap.java
@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);
}
}
}
项目:beaconz
文件:BeaconLinkListener.java
/**
* 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);
}
项目:beaconz
文件:BeaconLinkListener.java
/**
* 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()));
}
项目:Minecraft-UAPI
文件:MapImageSpliter.java
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;
}
项目:LagMonitor
文件:GraphCommand.java
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);
}
}
项目:Almura-Server
文件:CraftMapRenderer.java
@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);
}
}
项目:MagicLib
文件:MapController.java
@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;
}
项目:MagicLib
文件:URLMap.java
@SuppressWarnings("deprecation")
protected MapView getMapView() {
if (!enabled) {
return null;
}
MapView mapView = Bukkit.getMap(id);
if (mapView == null) {
enabled = false;
controller.warning("Failed to get map id " + id + " for key " + getKey() + ", disabled, use 'mmap fix' to re-enable");
return null;
}
List<MapRenderer> renderers = mapView.getRenderers();
boolean needsRenderer = false;
for (MapRenderer renderer : renderers) {
if (!(renderer instanceof URLMap)) {
mapView.removeRenderer(renderer);
needsRenderer = true;
}
}
if (needsRenderer) {
mapView.addRenderer(this);
}
return mapView;
}
项目:Tweakkit-Server
文件:CraftMapRenderer.java
@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);
}
}
项目:Cauldron
文件:CraftMapRenderer.java
@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);
}
}
项目:MCPainter
文件:MapHelper.java
/**
* Delete image map
* @param mapView map view to remove map
*/
public void deleteMap(MapView mapView) {
short mapId = mapView.getId();
List<MapRenderer> renderers = mapView.getRenderers();
File fileName = new File(ConfigProvider.getImgFolder(), mapId + ".png");
if (fileName.exists()) {
fileName.delete();
}
for (MapRenderer r : renderers) {
mapView.removeRenderer(r);
}
synchronized (m_mapList) {
Integer key = (int) mapId;
if (!m_mapList.containsKey(key)) {
return;
}
renderers = m_mapList.get(key);
for (MapRenderer mapRenderer : renderers) {
mapView.addRenderer(mapRenderer);
}
m_mapList.remove(key);
}
}
项目:MCPainter
文件:MapHelper.java
/**
* Store map image on disk
* @param mapView map to store
* @param img current map image
*/
public void storeMap(MapView mapView, BufferedImage img) {
List<MapRenderer> renderers = mapView.getRenderers();
short mapId = mapView.getId();
for (MapRenderer r : renderers) {
mapView.removeRenderer(r);
}
synchronized (m_mapList) {
Integer key = (int) mapId;
if (!m_mapList.containsKey(key)) {
m_mapList.put(key, renderers);
}
}
File fileName = new File(ConfigProvider.getImgFolder(), mapId + ".png");
try {
ImageIO.write(img, "png", fileName);
} catch (IOException ex) {
ExceptionHelper.printException(ex, "Error storing map image.");
}
}
项目:MCPainter
文件:ImgRenderer.java
/**
* Render image on the map
* @param mv Map item map view
* @param mc Map item map canvas
* @param player Player that the redraw is performed for
*/
@Override
public void render(final MapView mv, final MapCanvas mc, Player player) {
if (m_isRendered) {
return;
}
m_isRendered = true;
int idx = 0;
for (int y = 0; y < MAX_SIZE; y++) {
for (int x = 0; x < MAX_SIZE; x++) {
mc.setPixel(x, y, m_img[idx]);
idx++;
}
}
}
项目:ImgMap-BufferOverflow
文件:DrawYTVideoCommand.java
@Override
public void executeCommand(CommandSender sender, String[] arguments){
if(!ImgMap.isVideoStreamingEnabled()){
commandFailure(sender, "Videos have been disabled. Is it enabled in the configuration and is the FFmpeg executable for your OS in the ImgMap folder?");
return;
}
Player plyr = ((Player)sender);
if(plyr.getItemInHand().getType() != Material.MAP){
if(plyr.getItemInHand().getType() == Material.JUKEBOX){
//I'm allowed to have fun... right?
commandFailure(sender, "What masterpiece shall we play today? Oh wait... You can't stream music, unfortunately.");
return;
}
commandFailure(sender, "You can't stream videos onto that!");
return;
}
final MapView view = Bukkit.getMap(plyr.getItemInHand().getDurability());
// TODO: this entire part again
commandSuccess(sender, "Downloading video. The video will automatically start playing after it is finished.");
}
项目:ImgMap-BufferOverflow
文件:GifRenderer.java
@Override
public void render(MapView view, MapCanvas canvas, Player player){
if(cacher == null){
cacher = new CachingRunnable(view.getId(), file);
Thread thread = ThreadCallback.createThread(cacher, new Runnable() {
@Override
public void run() {
READY.compareAndSet(false, true);
}
});
thread.start();
} else if(READY.get()){
if(animation == null){
animation = new AnimationRunnable(cacher.getPackets(), cacher.getDelay());
animation.addPlayer(player);
animation.start();
} else {
animation.addPlayer(player);
}
}
}
项目:EndHQ-Libraries
文件:ImageRenderer.java
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
canvas.drawImage(0, 0, img);
if(m!=null) {
if(m.getParameterTypes().length==2) {
if(m.getParameterTypes()[0] == MapCanvas.class && m.getParameterTypes()[1] == Player.class) {
if(m.getReturnType().equals(Void.TYPE)) {
m.setAccessible(true);
try {
m.invoke(null, canvas, player);
} catch (Exception e) {
//e.printStackTrace();
BukkitPlugin.getInst().getLogger().info("Failed to write to map.");
}
}
}
}
}
}
项目:SpigotSource
文件:CraftMapRenderer.java
@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.decorations.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;
}
MapIcon decoration = (MapIcon) worldMap.decorations.get(key);
cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType());
}
}
项目:swu
文件:MapCommands.java
public boolean onCommand(CommandSender sender, Command cmd,
String cmdAlias, String[] args) {
if (cmd.getName().equals("swumap")) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be called by a player.");
return true;
}
Player p = (Player) sender;
final ItemStack item = p.getItemInHand();
if (!item.getType().equals(Material.MAP)) {
// TODO create a map and add it to the inventory instead of this
p.sendMessage("You don't have a written map in your hand, that can be converted");
return true;
}
MapView map = plugin.getServer().getMap(item.getDurability());
if (map == null) {
p.sendMessage("The map you're using couldn't be found by the server.");
return true;
}
plugin.changeToSwuMap(map);
}
return false;
}
项目:Craft-city
文件:CraftMapRenderer.java
@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);
}
}
项目:MCPBukkit
文件:CraftMapRenderer.java
@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.field_76198_e[y * 128 + x]);
}
}
// Cursors
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0) {
cursors.removeCursor(cursors.getCursor(0));
}
for (Object key : worldMap.field_76203_h.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.MapCoord decoration = (net.minecraft.world.storage.MapCoord) worldMap.field_76203_h.get(key);
cursors.addCursor(decoration.field_76214_b, decoration.field_76215_c, (byte) (decoration.field_76212_d & 15), (byte) (decoration.field_76216_a));
}
}
项目:Uranium
文件:CraftPlayer.java
@Override
public void sendMap(MapView map) {
if (getHandle().playerNetServerHandler == null) return;
RenderData data = ((CraftMapView) map).render(this);
for (int x = 0; x < 128; ++x) {
byte[] bytes = new byte[131];
bytes[1] = (byte) x;
for (int y = 0; y < 128; ++y) {
bytes[y + 3] = data.buffer[y * 128 + x];
}
net.minecraft.network.play.server.S34PacketMaps packet = new net.minecraft.network.play.server.S34PacketMaps(map.getId(), bytes);
getHandle().playerNetServerHandler.sendPacket(packet);
}
}
项目:SuperiorCraft
文件:GameManRenderer.java
@Override
public void render(MapView view, MapCanvas canvas, Player player) {
for (int i = GameManRenderer.i; i < 100; i++) {
canvas.setPixel(10, 10, (byte) 10);
GameManRenderer.i += 30;
}
//player.sendMessage("You've unlocked one of our greatest secrets...");
}
项目:Java-Snippets
文件:ImageRenderer.java
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
//the image is just for the player who requested a new key
if (image != null) {
canvas.drawImage(0, 0, image);
//release ressources in order to prevent memory leaks
image = null;
}
}
项目:SuperiorCraft
文件:GameManRenderer.java
@Override
public void render(MapView view, MapCanvas canvas, Player player) {
for (int i = GameManRenderer.i; i < 100; i++) {
canvas.setPixel(10, 10, (byte) 10);
GameManRenderer.i += 30;
}
//player.sendMessage("You've unlocked one of our greatest secrets...");
}
项目:SecureMyAccount
文件:ImageRenderer.java
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
//the image is just for the player who requested a new key
if (image != null && player.getUniqueId().equals(forPlayer)) {
canvas.drawImage(0, 0, image);
//release ressources in order to prevent memory leaks
image = null;
}
}