本文整理匯總了Java中org.bukkit.map.MapView.addRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java MapView.addRenderer方法的具體用法?Java MapView.addRenderer怎麽用?Java MapView.addRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.map.MapView
的用法示例。
在下文中一共展示了MapView.addRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: giveBeaconMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
/**
* 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);
}
示例2: onMapHold
import org.bukkit.map.MapView; //導入方法依賴的package包/類
/**
* 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()));
}
示例3: split
import org.bukkit.map.MapView; //導入方法依賴的package包/類
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;
}
示例4: getMapView
import org.bukkit.map.MapView; //導入方法依賴的package包/類
@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;
}
示例5: 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);
}
}
示例6: installRenderer
import org.bukkit.map.MapView; //導入方法依賴的package包/類
private MapView installRenderer(Player player, BufferedImage image) {
MapView mapView = Bukkit.createMap(player.getWorld());
mapView.getRenderers().forEach(mapView::removeRenderer);
mapView.addRenderer(new ImageRenderer(player, image));
return mapView;
}
示例7: installRenderer
import org.bukkit.map.MapView; //導入方法依賴的package包/類
private MapView installRenderer(Player player, GraphRenderer graphType) {
MapView mapView = Bukkit.createMap(player.getWorld());
mapView.getRenderers().forEach(mapView::removeRenderer);
mapView.addRenderer(graphType);
return mapView;
}
示例8: createHandler
import org.bukkit.map.MapView; //導入方法依賴的package包/類
public static void createHandler(MapView mapView, boolean overwrite) {
if (mapView != null) {
if (overwrite && mapView.getRenderers() != null) {
for (MapRenderer renderer : mapView.getRenderers()) {
mapView.removeRenderer(renderer);
}
}
mapView.addRenderer(new SkellettMapRenderer());
}
}
示例9: loadMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public boolean loadMap() {
MapView mapView = Bukkit.getMap(id);
if (mapView != null) {
Util.removeAllRenderers(mapView);
mapView.addRenderer(new ImageMapRenderer(image));
return true;
}
return false;
}
示例10: createNewMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
private void createNewMap(MapView map) {
// Every new map will get our renderer
//map.addRenderer(renderer);
MapState mapState = new MapState(map);
map.addRenderer(new MapWraper(mapState));
knownMaps.put(map.getId(), mapState);
}
示例11: giveBeaconMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
/**
* 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();
ItemStack offHand = player.getInventory().getItemInOffHand();
player.getInventory().setItemInOffHand(newMap);
//player.getInventory().setItemInOffHand(inHand);
if (offHand != null && !offHand.getType().equals(Material.AIR)) {
HashMap<Integer, ItemStack> leftOvers = player.getInventory().addItem(offHand);
if (!leftOvers.isEmpty()) {
player.sendMessage(ChatColor.RED + Lang.errorInventoryFull);
for (ItemStack item: leftOvers.values()) {
player.getWorld().dropItem(player.getLocation(), item);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 0.5F);
}
}
}
}
示例12: executeCommand
import org.bukkit.map.MapView; //導入方法依賴的package包/類
@Override
public void executeCommand(CommandSender sender, String[] arguments){
ItemStack stack = ((Player)sender).getItemInHand(); // Safe to cast since we check if they're non-player earlier.
if(stack == null || (stack.getType() != Material.MAP)){
commandFailure(sender, "You must be holding a map to use this command!");
return;
}
MapView view = Bukkit.getMap(stack.getDurability());
BufferedImage image;
try {
if(ArrayUtils.contains(arguments, "-l")){
image = IOHelper.fetchLocalImage(arguments[0]);
} else {
image = IOHelper.fetchImage(new URL(arguments[0]));
}
} catch (IOException e){
commandFailure(sender, "Failed to retrieve image!");
e.printStackTrace();
return;
}
IOHelper.resizeImage(image);
MapHelper.removeRenderers(view);
view.addRenderer(new ImageRenderer(image));
((Player)sender).sendMap(view); // Update the map now.
commandSuccess(sender, "Drawing " + arguments[0] + "...");
}
示例13: executeCommand
import org.bukkit.map.MapView; //導入方法依賴的package包/類
@Override
public void executeCommand(CommandSender sender, String[] arguments){
World world;
short id;
if(sender instanceof Player){
world = ((Player)sender).getWorld();
} else {
world = Bukkit.getWorlds().get(0);
}
if(arguments.length > 0){
id = Short.valueOf(arguments[0]);
} else {
if(sender instanceof Player){
ItemStack stack = ((Player)sender).getItemInHand();
if(stack == null || (stack.getType() != Material.MAP)){
commandFailure(sender, "You must be holding a map or provide an ID to reset to use this command!");
return;
}
id = stack.getDurability();
} else {
commandFailure(sender, "You need to provide an ID to reset");
return;
}
}
MapView view = Bukkit.getMap(id);
MapHelper.removeRenderers(view);
view.addRenderer(NMSHelper.getDefaultRenderer(id, world));
((Player)sender).sendMap(view); // Update the map now.
commandSuccess(sender, "Cleared map ID " + id + "!");
}
示例14: changeToSwuMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
/**
* Changes the given MapView to render a ChunkInfo map.
*
* Removes any other renderer from the MapView and adds the
* ChunkInfoRenderer as the only new one.
*
* @param map
* The MapView to change.
*/
public void changeToSwuMap(MapView map) {
if (map.isVirtual())
return;
for (MapRenderer renderer : map.getRenderers()) {
map.removeRenderer(renderer);
}
map.addRenderer(mapRenderer);
}
示例15: applyToMap
import org.bukkit.map.MapView; //導入方法依賴的package包/類
static MapView applyToMap(MapView map, BufferedImage image) {
for (MapRenderer renderer : map.getRenderers())
map.removeRenderer(renderer);
map.addRenderer(new ImageRenderer(image));
return map;
}