當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。