本文整理汇总了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);
}
}
示例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.");
}
}
示例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);
}
}
}
示例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);
}
}
示例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");
}
示例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");
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
示例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]);
}
}
}