当前位置: 首页>>代码示例>>Java>>正文


Java MapView.getId方法代码示例

本文整理汇总了Java中org.bukkit.map.MapView.getId方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getId方法的具体用法?Java MapView.getId怎么用?Java MapView.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.map.MapView的用法示例。


在下文中一共展示了MapView.getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SBPrime,项目名称:MCPainter,代码行数:29,代码来源:MapHelper.java

示例2: storeMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
/**
 * 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.");
    }
}
 
开发者ID:SBPrime,项目名称:MCPainter,代码行数:28,代码来源:MapHelper.java

示例3: render

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@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);
		}
	}
}
 
开发者ID:CirnoTheGenius,项目名称:ImgMap-BufferOverflow,代码行数:24,代码来源:GifRenderer.java

示例4: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftPlayer.java

示例5: run

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@Override
public void run() {
    MapView createdView = installRenderer(player, resultImage);
    //stack count 0 prevents the item from being dropped
    ItemStack mapItem = new ItemStack(Material.MAP, 0, createdView.getId());
    player.getInventory().addItem(mapItem);
    player.sendMessage(ChatColor.DARK_GREEN + "Here is your secret code. Just scan it with your phone");
    player.sendMessage(ChatColor.DARK_GREEN + "Then drop it in order to remove it");
}
 
开发者ID:games647,项目名称:SecureMyAccount,代码行数:10,代码来源:MapGiver.java

示例6: giveMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
private void giveMap(Player player, MapView mapView) {
    PlayerInventory inventory = player.getInventory();
    //amount=0 makes the item disappear if the user drop or try to use it
    ItemStack mapItem = new ItemStack(Material.MAP, 1, mapView.getId());
    inventory.addItem(mapItem);

    player.sendMessage(ChatColor.DARK_GREEN + "You received a map with the graph");
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:9,代码来源:GraphCommand.java

示例7: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@Override
public void sendMap(MapView map) {
    if (getHandle().playerConnection == 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];
        }
        PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), bytes);
        getHandle().playerConnection.sendPacket(packet);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:16,代码来源:CraftPlayer.java

示例8: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@Override
public void sendMap(MapView map) {
    if (getHandle().playerConnection == null) return;

    RenderData data = ((CraftMapView) map).render(this);
    Collection<MapIcon> icons = new ArrayList<MapIcon>();
    for (MapCursor cursor : data.cursors) {
        if (cursor.isVisible()) {
            icons.add(new MapIcon(cursor.getRawType(), cursor.getX(), cursor.getY(), cursor.getDirection()));
        }
    }

    PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), icons, data.buffer, 0, 0, 0, 0);
    getHandle().playerConnection.sendPacket(packet);
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:16,代码来源:CraftPlayer.java

示例9: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
public void sendMap(MapView map) {
    if (getHandle().playerConnection == 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];
        }
        Packet131ItemData packet = new Packet131ItemData((short) Material.MAP.getId(), map.getId(), bytes);
        getHandle().playerConnection.sendPacket(packet);
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:15,代码来源:CraftPlayer.java

示例10: getMapItem

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected ItemStack getMapItem(String name, MapView mapView) {
    short id = 0;
    if (mapView != null) {
        id = mapView.getId();
    }
    return getMapItem(name, id);
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:9,代码来源:MapController.java

示例11: fix

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean fix(World world, int maxIds) {
    if (enabled) return true;

    MapView mapView = Bukkit.getMap(id);
    if (mapView != null) {
        enabled = true;
        return true;
    }
    int retry = 0;
    boolean matched = false;
    while (!matched && retry < maxIds) {
        MapView newView = Bukkit.createMap(world);
        short newId = newView.getId();
        matched = (newView != null && newId == id);
        if (newId < 0 || newId > id) break;
        retry++;
    }

    mapView = getMapView();
    if (mapView == null) {
        controller.warning("Failed to fix map id " + id + " for key " + getKey());
    } else {
        enabled = true;
    }

    return enabled;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:30,代码来源:URLMap.java

示例12: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@Override
public void sendMap(MapView map) {
    if (getHandle().playerConnection == null) return;

    RenderData data = ((CraftMapView) map).render(this);
    Collection<MapIcon> icons = new ArrayList<MapIcon>();
    for (MapCursor cursor : data.cursors) {
        if (cursor.isVisible()) {
            icons.add(new MapIcon(cursor.getRawType(), cursor.getX(), cursor.getY(), cursor.getDirection()));
        }
    }

    PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 0, 0);
    getHandle().playerConnection.sendPacket(packet);
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:16,代码来源:CraftPlayer.java

示例13: sendMap

import org.bukkit.map.MapView; //导入方法依赖的package包/类
public void sendMap(MapView map) {
    if (getHandle().field_71135_a == 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.packet.Packet131MapData packet = new net.minecraft.network.packet.Packet131MapData((short) Material.MAP.getId(), map.getId(), bytes);
        getHandle().field_71135_a.func_72567_b(packet);
    }
}
 
开发者ID:agaricusb,项目名称:MCPBukkit,代码行数:15,代码来源:CraftPlayer.java

示例14: render

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
	for (MapState state : maps) {
		if (state.getMapID() == map.getId()) {
			int scaleBits = 7 + map.getScale().ordinal();
			int mapScale = 1 << map.getScale().ordinal();
			int edgeSize = (127 * mapScale);
			int blocksPerPixel = edgeSize / 128;
			
			int blocksX = 1, blocksZ = 1;
			int playerX = player.getLocation().getBlockX();
			int playerZ = player.getLocation().getBlockZ();
			int maxX = (int) (Math.ceil((radius - blocksX / 2) / blocksX) * 2 + 1);
			int maxZ = (int) (Math.ceil((radius - blocksZ / 2) / blocksZ) * 2 + 1);
			for (int z = -maxZ / 2; z <= maxZ / 2; z++) {
				for (int x = -maxX / 2; x <= maxX / 2; x++) {
					double distance = Math.sqrt(((z * blocksZ) ^ 2) + ((x * blocksX) ^ 2));
					if(distance < radius){
						double xCord = (playerX + x);
						double zCord = (playerZ + z);
						int secLocX = (int)xCord >> scaleBits;
						int secLocZ = (int)zCord >> scaleBits;
			
						MapSection section = state.getMapSection(secLocX, secLocZ);
						byte color = getRandomColor();
						
						//double varX = (((xCord / (secLocX != 0 ? secLocX : 1)) / edgeSize) * 128) / edgeSize;
						//double varZ = (((zCord / (secLocZ != 0 ? secLocZ : 1)) / edgeSize) * 128) / edgeSize;
						
						
						double varX = Math.floor(Math.abs(xCord) / (Math.abs(secLocX) + 1));
						int pixelX =  (int) Math.floor(varX / blocksPerPixel);
						
						double varZ = Math.floor(Math.abs(zCord) / (Math.abs(secLocX) + 1));
						int pixelZ =  (int) Math.floor(varZ / blocksPerPixel);
						
						// ? / 128 = xzCord / edgeSize
						//Math: pixel / 128 = step1 / edgeLength  
						
						section.setPixel(pixelX, pixelZ, color);
					}
				}
			}
			

			// Next we determine if we have left the bounds of the current
			// map section
			// and if so we fix it
			int sectionX = (int) Math.floor(player.getLocation().getBlockX() >> scaleBits);
			int sectionZ = (int) Math.floor(player.getLocation().getBlockZ() >> scaleBits);
			if (state.getLastSectionX() != sectionX || state.getLastSectionZ() != sectionZ) {
				int xStart = sectionX * edgeSize;
				int xEnd = xStart + edgeSize;
				map.setCenterX(xEnd - (64 * mapScale));
				state.setSectionX(sectionX);
				
				int zStart = sectionZ * edgeSize;
				int zEnd = zStart + edgeSize;
				map.setCenterZ(zEnd - (64 * mapScale));
				state.setSectionZ(sectionZ);
				
				player.sendMessage("Map Center: " + map.getCenterX() + " " + map.getCenterZ() + ", Sec X: "
						+ sectionX + ", Sec Z: " + sectionZ + ", X: " + xStart + " - " + xEnd + ", Z: " + zStart
						+ " - " + zEnd);
			}
			renderMap(state, sectionX, sectionZ, canvas);
			break;
		}
	}
}
 
开发者ID:robotman3000,项目名称:Spigot-Plus,代码行数:72,代码来源:MinimapRenderer.java

示例15: render

import org.bukkit.map.MapView; //导入方法依赖的package包/类
@Override
public void render(MapView view, MapCanvas canvas, Player player) {
    if (renderTask == null)
        return;

    ChunkInfoRenderingRequest request = renderedRequests.get(view.getId());
    if (request == null) {
        request = new ChunkInfoRenderingRequest(view.getId(),
                view.getCenterX(), view.getCenterZ(), view.getWorld()
                        .getName());
        renderedRequests.put(view.getId(), request);
        renderTask.add(request);
    }

    MapCursor cursor;

    final Location location = player.getLocation();
    final int playerX = ((location.getBlockX() - view.getCenterX()) >> 3) /*
                                                                           * +
                                                                           * 128
                                                                           */;
    final int playerZ = ((location.getBlockZ() - view.getCenterZ()) >> 3) /*
                                                                           * +
                                                                           * 128
                                                                           */;
    if (playerX < 128 && playerX >= -128 && playerZ < 128
            || playerZ >= -128) {
        final byte direction = (byte) (((int) location.getYaw() + 360) % 360 * 16 / 360);
        if (canvas.getCursors().size() == 0) {
            canvas.getCursors().addCursor(playerX, playerZ, direction,
                    MapCursor.Type.WHITE_POINTER.getValue());
        } else {
            cursor = canvas.getCursors().getCursor(0);
            cursor.setDirection(direction);
            cursor.setX((byte) (playerX));
            cursor.setY((byte) (playerZ));
        }
    }

    if (!request.isDone())
        return;

    final byte[][] data = request.getData();
    for (int ii = 0; ii < 2; ii++) {
        int currentLine = request.nextLine();
        for (int i = 0; i < 128; i++) {
            canvas.setPixel(i, currentLine, data[currentLine][i]);
        }
    }
}
 
开发者ID:hapm,项目名称:swu,代码行数:51,代码来源:ChunkInfoRenderer.java


注:本文中的org.bukkit.map.MapView.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。