當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemFrame類代碼示例

本文整理匯總了Java中org.bukkit.entity.ItemFrame的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame類的具體用法?Java ItemFrame怎麽用?Java ItemFrame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ItemFrame類屬於org.bukkit.entity包,在下文中一共展示了ItemFrame類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerClickItemFram

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler
public void onPlayerClickItemFram(PlayerInteractEntityEvent event) {
    if (!event.isCancelled() && event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) {
        for (Region region : regions) {
            if (region.contains(event.getRightClicked().getLocation())) {
                for (MatchTeam matchTeam : teams) {
                    if (matchTeam.containsPlayer(event.getPlayer())) {
                        FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                        if (filterResult == FilterResult.DENY) {
                            event.setCancelled(true);
                            event.getPlayer().sendMessage(message);
                        } else if (filterResult == FilterResult.ALLOW) {
                            event.setCancelled(false);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:21,代碼來源:BuildFilterType.java

示例2: onItemFrameDamage

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final EntityDamageByEntityEvent e) {
    // Check world
    if (!Util.inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getDamager() instanceof Projectile) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Projectile damage to itemframe");
        // Find out who fired the arrow
        Projectile p = (Projectile) e.getDamager();
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString());
        if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Shooter is mob");
            if (!Settings.allowMobDamageToItemFrames) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:25,代碼來源:IslandGuard.java

示例3: checkItemFrameRotate

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameRotate(PlayerInteractEntityEvent event) {
    if(event.getRightClicked() instanceof ItemFrame) {
        ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
        if(itemFrame.getItem() != null) {
            // If frame contains an item, right-click will rotate it, which is handled as a "use" event
            this.handleUse(event, getHangingBlockState(itemFrame), this.match.getParticipant(event.getPlayer()));
        } else if(event.getPlayer().getItemInHand() != null) {
            // If the frame is empty and it's right clicked with an item, this will place the item in the frame,
            // which is handled as a "place" event, with the placed item as the block material
            BlockState blockState = BlockStateUtils.cloneWithMaterial(itemFrame.getLocation().getBlock(),
                                                                      event.getPlayer().getItemInHand().getData());
            this.handleHangingPlace(event, blockState, event.getPlayer());
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:EventRuleMatchModule.java

示例4: onClickFrame

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST)
public void onClickFrame(PlayerInteractEntityEvent e){
	if(!(e.getRightClicked() instanceof ItemFrame)) return;
	String uuid = e.getPlayer().getUniqueId().toString();
	long curTime = System.currentTimeMillis();
	int posInList;
	if(uuidsClickItem.contains(uuid)){
		posInList = uuidsClickItem.indexOf(uuid);
		if(curTime < (lastClickItem.get(posInList) + 200)){
			e.getPlayer().sendMessage(tag + ChatColor.RED + "Please slow down clicking item frames!");
			Vector movDirection = e.getPlayer().getEyeLocation().getDirection();
			movDirection = movDirection.normalize().multiply(-2);
			e.getPlayer().setVelocity(movDirection);
			e.setCancelled(true);
		}
		if(curTime < (lastClickItem.get(posInList) + 50)){
			e.getPlayer().kickPlayer(tag + ChatColor.RED + "Please do not spam item frames!");
			
		}
		lastClickItem.set(posInList, curTime);
	}else{
		uuidsClickItem.add(uuid);
		lastClickItem.add(curTime);
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:26,代碼來源:Core.java

示例5: onplayerinteract

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler
public void onplayerinteract(PlayerInteractEntityEvent e) {
	Player p = e.getPlayer();
	if (ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.Enable")) {
		if (!ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.World.All_World")) {
			if (WorldUtils.getWPIEIF().contains(p.getWorld().getName())) {
				if ((e.getRightClicked() instanceof ItemFrame)) {
			        e.setCancelled(true);
				}
			}
		} else {
			if ((e.getRightClicked() instanceof ItemFrame)) {
		        e.setCancelled(true);
			}
		}
    }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:18,代碼來源:BasicFeatures.java

示例6: onEntityDamage

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
	if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Enable")) {
		if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.Enable")) {
      if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.EntityDamageByEntity")) {
      	if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.World.All_World")) {
      		if (WorldUtils.getWD().contains(e.getEntity().getWorld().getName())) {
      			e.setCancelled(true);
      			if (e.getEntity() instanceof ItemFrame) {
      			      e.setCancelled(true);
      			}
      		}
      	} else {
      		e.setCancelled(true);
      		if (e.getEntity() instanceof ItemFrame) {
     			      e.setCancelled(true);
     			}
      	}
      }
		}
	}
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:23,代碼來源:BasicFeatures.java

示例7: clearFrames

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
public void clearFrames() {
	if (this.mapWrappers != null) {
		for (MapWrapper wrapper : this.mapWrappers) {
			for (UUID uuid : worldPlayers) {
				Player player = Bukkit.getPlayer(uuid);
				if (player != null) {
					((MultiMapController) wrapper.getController()).clearFrames(player, this.itemFrameIds);
				}
			}
			wrapper.getController().clearViewers();
		}
		for (int[] iA : this.itemFrameIds) {
			for (int i : iA) {
				ItemFrame itemFrame = MapManagerPlugin.getItemFrameById(getWorld(), i);
				if (itemFrame != null) {
					itemFrame.removeMetadata("ANIMATED_FRAMES_META", plugin);
				}
			}
		}
	}
}
 
開發者ID:InventivetalentDev,項目名稱:AnimatedFrames,代碼行數:22,代碼來源:AnimatedFrame.java

示例8: createFrame

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@Synchronized
public AnimatedFrame createFrame(String name, String source, ItemFrame firstFrame, ItemFrame secondFrame) {
	if (frameMap.containsKey(name)) {
		throw new IllegalArgumentException("Frame '" + name + "' already exists");
	}
	JsonObject meta = new JsonObject();
	AsyncFrameCreationEvent creationEvent = new AsyncFrameCreationEvent(name, source, firstFrame, secondFrame, meta);
	Bukkit.getPluginManager().callEvent(creationEvent);
	name = creationEvent.getName();
	source = creationEvent.getSource();

	AnimatedFrame frame = new AnimatedFrame(firstFrame, new Vector3DDouble(firstFrame.getLocation().toVector()), new Vector3DDouble(secondFrame.getLocation().toVector()), name, source);
	frameMap.put(frame.getName(), frame);
	frame.setMeta(meta);

	return frame;
}
 
開發者ID:InventivetalentDev,項目名稱:AnimatedFrames,代碼行數:18,代碼來源:FrameManager.java

示例9: getMapWrapper

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
/**
 * @return the {@link MapWrapper} of the clicked frame
 */
public MapWrapper getMapWrapper() {
	if (this.mapWrapper != null) { return this.mapWrapper; }
	ItemFrame itemFrame = getItemFrame();
	if (itemFrame != null) {
		if (itemFrame.hasMetadata("MAP_WRAPPER_REF")) {
			List<MetadataValue> metadataValues = itemFrame.getMetadata("MAP_WRAPPER_REF");
			for (MetadataValue value : metadataValues) {
				MapWrapper wrapper = (MapWrapper) value.value();
				if (wrapper != null) {
					return this.mapWrapper = wrapper;
				}
			}
		}
	}
	return null;
}
 
開發者ID:InventivetalentDev,項目名稱:MapManager,代碼行數:20,代碼來源:MapInteractEvent.java

示例10: showInFrame

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@Override
public void showInFrame(Player player, int entityId, String debugInfo) {
	if (!isViewing(player)) {
		return;
	}
	//Create the ItemStack with the player's map ID
	ItemStack itemStack = new ItemStack(Material.MAP, 1, getMapId(player));
	if (debugInfo != null) {
		//Add the debug info to the display
		ItemMeta itemMeta = itemStack.getItemMeta();
		itemMeta.setDisplayName(debugInfo);
		itemStack.setItemMeta(itemMeta);
	}

	ItemFrame itemFrame = MapManagerPlugin.getItemFrameById(player.getWorld(), entityId);
	if (itemFrame != null) {
		//Add a reference to this MapWrapper (can be used in MapWrapper#getWrapperForId)
		itemFrame.removeMetadata("MAP_WRAPPER_REF", MapManagerPlugin.instance);
		itemFrame.setMetadata("MAP_WRAPPER_REF", new FixedMetadataValue(MapManagerPlugin.instance, DefaultMapWrapper.this));
	}

	sendItemFramePacket(player, entityId, itemStack);
}
 
開發者ID:InventivetalentDev,項目名稱:MapManager,代碼行數:24,代碼來源:DefaultMapWrapper.java

示例11: placePoster

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
private void placePoster(List<ItemStack> maps, int width, int height, final Block topLeftBlock, final BlockFace facing) {
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            Block block = Util.getRelative(topLeftBlock, facing, -y, x, 0);
            for (ItemFrame entity : block.getWorld().getEntitiesByClass(ItemFrame.class)) {
                if (entity.getLocation().getBlock().getRelative(entity.getAttachedFace()).getLocation().equals(block.getLocation())) {
                    entity.teleport(new Location(entity.getWorld(), 0, -1, 0)); //workaround so that respawning an item frame immediately works
                    entity.remove();
                    break;
                }
            }

            final ItemStack map = maps.get(y * width + x);
            ItemMeta meta = map.getItemMeta();
            meta.setDisplayName("");
            map.setItemMeta(meta);
            Util.attachItemFrame(Util.getRelative(topLeftBlock, facing, -y, x, 0), map, facing);
        }
    }
    propagateMaps(maps, topLeftBlock.getLocation());
}
 
開發者ID:leMaik,項目名稱:RpgPlus,代碼行數:22,代碼來源:ImagesComponent.java

示例12: onFrameBrake

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
@EventHandler
 public void onFrameBrake(HangingBreakByEntityEvent e) {
 	RedProtect.get().logger.debug("Is BlockListener - HangingBreakByEntityEvent event");
 	if (e.isCancelled()){
 		return;
 	}
 	
 	Entity remover = e.getRemover();
 	Entity ent = e.getEntity();
 	Location l = e.getEntity().getLocation();
 	    	
 	if ((ent instanceof ItemFrame || ent instanceof Painting) && remover instanceof Monster) {
 		Region r = RedProtect.get().rm.getTopRegion(l);
 		if (r != null && !r.canMobLoot()){
 			e.setCancelled(true);
}
     }    
 }
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:19,代碼來源:RPBlockListener.java

示例13: ItemFrameStorage

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
public ItemFrameStorage(ItemFrame frame, Location attachedLoc) throws CivException {
		if (frame != null) {
			this.frameID = frame.getUniqueId();
			this.location = frame.getLocation();
			this.attachedBlock = new BlockCoord(attachedLoc);
			CivGlobal.addProtectedItemFrame(this);
		} else {
			throw new CivException("Passed a null item frame to storage constructor.");
		}
		
//		this.frame = frame;
//		if (this.frame != null) {
//			CivGlobal.addProtectedItemFrame(this);
//		} else {
//			CivLog.error("Passed a null item frame!!!");
//			throw new CivException("Passed a null item frame.");
//		}
	}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:19,代碼來源:ItemFrameStorage.java

示例14: getItemFrame

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
public ItemFrame getItemFrame() {
	// Gets the item frame by loading in the chunk where it is supposed to reside.
	// Then searching for it's UUID.
	
	if (!this.location.getChunk().isLoaded()) {
		if (!this.location.getChunk().load()) {
			CivLog.error("Could not load chunk to get item frame at:"+this.location);
			return null;
		}
	}
	
	Entity ent = CivGlobal.getEntityClassFromUUID(this.location.getWorld(), ItemFrame.class, this.frameID);
	if (ent == null) {
		CivLog.error("Could not find frame from frame ID:"+this.frameID.toString());
		return null;
	}
	
	if (!(ent instanceof ItemFrame)) {
		CivLog.error("Could not get a frame with ID:"+this.frameID+" ... it was not a frame.");
		return null;
	}
	
	//TODO try and use a cache and isValid()?
	
	return (ItemFrame)ent;
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:27,代碼來源:ItemFrameStorage.java

示例15: moveframes_cmd

import org.bukkit.entity.ItemFrame; //導入依賴的package包/類
public void moveframes_cmd() throws CivException {
	Player player = getPlayer();
	Chunk chunk = player.getLocation().getChunk();
	
//	int x = this.getNamedInteger(1);
//	int y = this.getNamedInteger(2);
//	int z = this.getNamedInteger(3);
	
//	Location loc = new Location(player.getWorld(), x, y, z);
	
	for (Entity entity : chunk.getEntities()) {
		if (entity instanceof ItemFrame) {
			CivMessage.send(sender, "Teleported...");
			entity.teleport(entity.getLocation());
		}
	}
	
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:19,代碼來源:DebugCommand.java


注:本文中的org.bukkit.entity.ItemFrame類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。