当前位置: 首页>>代码示例>>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;未经允许,请勿转载。