下面列出了org.bukkit.Material#MAP 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void sendAndRenderMap(User u, Player p, String newKey) {
ImageMapRenderer mapRenderer;
try {
mapRenderer = new ImageMapRenderer(p.getName(), newKey, serverIp);
} catch (WriterException e) {
mcAuthenticator.getC().sendDirect(p,
"&cThere was an error rendering your 2FA QR code!");
mcAuthenticator.handleException(e);
return;
}
if (!u.isInventoryStored())
u.storeInventory(p);
MapView map = Bukkit.createMap(p.getWorld());
map.getRenderers().forEach(map::removeRenderer);
map.addRenderer(mapRenderer);
ItemStack mapItem = new ItemStack(Material.MAP, 1, map.getId());
p.getInventory().setHeldItemSlot(0);
p.getInventory().setItemInMainHand(mapItem);
p.sendMap(map);
}
public Schematic(ASkyBlock plugin) {
this.plugin = plugin;
// Initialize
name = "";
heading = "";
description = "Default Island";
perm = "";
icon = Material.MAP;
rating = 50;
useDefaultChest = true;
biome = Settings.defaultBiome;
usePhysics = Settings.usePhysics;
file = null;
islandCompanion = new ArrayList<EntityType>();
islandCompanion.add(Settings.islandCompanion);
companionNames = Settings.companionNames;
defaultChestItems = Settings.chestItems;
visible = true;
order = 0;
bedrock = null;
chest = null;
welcomeSign = null;
topGrass = null;
playerSpawn = null;
//playerSpawnBlock = null;
partnerName = "";
}
/**
* @return the {@link MapWrapper} of the item
*/
public MapWrapper getMapWrapper() {
if (this.mapWrapper != null) { return this.mapWrapper; }
if (getItemStack() == null) { return null; }
if (getItemStack().getType() != Material.MAP) { return null; }
MapManager mapManager = ((MapManagerPlugin) Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager();
return this.mapWrapper = mapManager.getWrapperForId(getPlayer(), getItemStack().getDurability());
}
private boolean isOurGraphLegacy(ItemStack mapItem) {
if (mapItem.getType() != Material.MAP)
return false;
short mapId = mapItem.getDurability();
MapView mapView = Bukkit.getMap(mapId);
return mapView != null && isOurRenderer(mapView);
}
private int getMapSlot(Player player) {
PlayerInventory inventory = player.getInventory();
for (int i = 0; i < 9; i++) {
ItemStack item = inventory.getItem(i);
if (item != null && item.getType() == Material.MAP) {
return i;
}
}
return -1;
}
private boolean isOurGraphLegacy(ItemStack mapItem) {
if (mapItem.getType() != Material.MAP)
return false;
short mapId = mapItem.getDurability();
MapView mapView = Bukkit.getMap(mapId);
return mapView != null && isOurRenderer(mapView);
}
public static ItemMeta getItemMeta(net.minecraft.server.v1_7_R4.ItemStack item) {
if (!hasItemMeta(item)) {
return CraftItemFactory.instance().getItemMeta(getType(item));
}
Material mat = getType(item);
if (mat == Material.WRITTEN_BOOK || mat == Material.BOOK_AND_QUILL) {
return new CraftMetaBook(item.tag);
}
if (mat == Material.SKULL_ITEM) {
return new CraftMetaSkull(item.tag);
}
if (mat == Material.LEATHER_HELMET || mat == Material.LEATHER_CHESTPLATE || mat == Material.LEATHER_LEGGINGS || mat == Material.LEATHER_BOOTS) {
return new CraftMetaLeatherArmor(item.tag);
}
if (mat == Material.POTION) {
return new CraftMetaPotion(item.tag);
}
if (mat == Material.MAP) {
return new CraftMetaMap(item.tag);
}
if (mat == Material.FIREWORK) {
return new CraftMetaFirework(item.tag);
}
if (mat == Material.FIREWORK_CHARGE) {
return new CraftMetaCharge(item.tag);
}
if (mat == Material.ENCHANTED_BOOK) {
return new CraftMetaEnchantedBook(item.tag);
}
if (mat.toString().equals("BANNER")) {
return new BannerMeta(item.getData(), item.tag);
}
return new CraftMetaItem(item.tag);
}
private ItemMeta getItemMeta(Material material, CraftMetaItem meta) {
if (material == Material.AIR) {
return null;
}
if (material == Material.WRITTEN_BOOK || material == Material.BOOK_AND_QUILL) {
return (meta instanceof CraftMetaBook) ? meta : new CraftMetaBook(meta);
}
if (material == Material.SKULL_ITEM) {
return (meta instanceof CraftMetaSkull) ? meta : new CraftMetaSkull(meta);
}
if (material == Material.LEATHER_HELMET || material == Material.LEATHER_CHESTPLATE || material == Material.LEATHER_LEGGINGS || material == Material.LEATHER_BOOTS) {
return (meta instanceof CraftMetaLeatherArmor) ? meta : new CraftMetaLeatherArmor(meta);
}
if (material == Material.POTION) {
return (meta instanceof CraftMetaPotion) ? meta : new CraftMetaPotion(meta);
}
if (material == Material.MAP) {
return (meta instanceof CraftMetaMap) ? meta : new CraftMetaMap(meta);
}
if (material == Material.FIREWORK) {
return (meta instanceof CraftMetaFirework) ? meta : new CraftMetaFirework(meta);
}
if (material == Material.FIREWORK_CHARGE) {
return (meta instanceof CraftMetaCharge) ? meta : new CraftMetaCharge(meta);
}
if (material == Material.ENCHANTED_BOOK) {
return (meta instanceof CraftMetaEnchantedBook) ? meta : new CraftMetaEnchantedBook(meta);
}
if (material.toString().equals("BANNER")) {
if (meta != null && BannerMeta.class.isAssignableFrom(meta.getClass())) {
return meta;
} else {
return new BannerMeta(meta);
}
}
return new CraftMetaItem(meta);
}