当前位置: 首页>>代码示例>>Java>>正文


Java HangingBreakEvent.getEntity方法代码示例

本文整理汇总了Java中org.bukkit.event.hanging.HangingBreakEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java HangingBreakEvent.getEntity方法的具体用法?Java HangingBreakEvent.getEntity怎么用?Java HangingBreakEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.hanging.HangingBreakEvent的用法示例。


在下文中一共展示了HangingBreakEvent.getEntity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFrameBrake

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler
 public void onFrameBrake(HangingBreakEvent e) {
 	RedProtect.get().logger.debug("Is BlockListener - HangingBreakEvent event");
 	if (e.isCancelled()){
 		return;
 	}
 	
 	Entity ent = e.getEntity();
 	Location l = e.getEntity().getLocation();		
 	
 	if ((ent instanceof ItemFrame || ent instanceof Painting) && (e.getCause().toString().equals("EXPLOSION"))) {
 		Region r = RedProtect.get().rm.getTopRegion(l);
 		if (r != null && !r.canFire()){
 			e.setCancelled(true);
}
     }    
 }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:18,代码来源:RPBlockListener.java

示例2: onHangingBreakEvent

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
/**
 * Event handler to watch whenever an itemframe is broken by something other than a player..
 * This will remove the cache of the hoppers around it.
 * 
 * @param event HangingBreakEvent containing data about the broken hanging item. We care about the ItemFrame being removed.
 */
@EventHandler(ignoreCancelled=true)
public void onHangingBreakEvent(HangingBreakEvent event) {
    if (event.getEntity() instanceof ItemFrame) {
        //get the item frame entity
        ItemFrame itemFrame =  (ItemFrame)event.getEntity();

        //get the block location that represents the ItemFrame location
        Location itemFrameLocation = itemFrame.getLocation().getBlock().getLocation();
        
        //debug if requested
        if (plugin.debugLevel_get() > 0) plugin.getLogger().info("ItemFrame broken by non-player at (" + itemFrameLocation.toString() + ")");

        //an itemFrame was broken. Clear the cache from the hoppers around the frame.
        plugin.knownHoppersCache_ClearAroundLocation(itemFrameLocation);
    }
}
 
开发者ID:TheNut,项目名称:HopperFilterSimplified,代码行数:23,代码来源:HfsBlockListener.java

示例3: onItemFrameBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = HIGHEST, ignoreCancelled = true)
public void onItemFrameBreak(HangingBreakEvent ev) {
    if (!(ev.getEntity() instanceof ItemFrame)) return;
    ItemFrame f = (ItemFrame) ev.getEntity();
    if (f.getItem() == null || f.getItem().getType() == Material.AIR) return;
    if (ExhibitionFrame.fromItemFrame(f).isSet()) {
        if (ev.getCause() == HangingBreakEvent.RemoveCause.EXPLOSION) { // Explosion protect
            ev.setCancelled(true);
        } else {
            plugin.getLogger().warning(String.format("Exhibition broken: Location: %s, item: %s", f.getLocation().toString(),
                    f.getItem().toString()));
            f.setItem(new ItemStack(Material.AIR));
        }
    }
}
 
开发者ID:NyaaCat,项目名称:NyaaUtils,代码行数:16,代码来源:ExhibitionListener.java

示例4: onHangingBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHangingBreak(HangingBreakEvent event) {
  Hanging hanging = event.getEntity();
  if (event.getCause().equals(RemoveCause.OBSTRUCTION)) {
    hanging.getLocation().getBlock().breakNaturally();
    event.setCancelled(true);
  } else if (event.getCause().equals(RemoveCause.EXPLOSION)) {
    event.setCancelled(true);
  }

}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:12,代码来源:HangingListener.java

示例5: onHangingBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
	Entity hanging = event.getEntity();
	
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

	for(Arena a : am.getArenas())
		if(a.isArenaCuboidSet())
			if(a.getArenaCuboid().isInsideCuboid(hanging.getLocation()))
				if(!a.isInEditMode())
					event.setCancelled(true);
}
 
开发者ID:timvisee,项目名称:simple-survival-games,代码行数:13,代码来源:SSGHangingListener.java

示例6: onHangingBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGH)
public void onHangingBreak(HangingBreakEvent event) {
	if (event.isCancelled() || (event.getEntity().getType() != EntityType.ITEM_FRAME)) return;
	ItemFrame entity = (ItemFrame)event.getEntity();
	Frame frame = this.manager.getFrame(entity);
	if (frame == null) return;
	
	Player player = null;
	if (event instanceof HangingBreakByEntityEvent) {
		Entity remover = ((HangingBreakByEntityEvent)event).getRemover();
		if (remover.getType() == EntityType.PLAYER) {
			player = (Player) remover;
		}
	}

	if ((player != null) && Config.WORLDGUARD_ENABLED && Config.WORLDGUARD_BREAK && !player.hasPermission("FramePicture.ignoreWorldGuard"))
	{
		RegionManager rm = FramePicturePlugin.getWorldGuard().getRegionManager(player.getWorld());
		LocalPlayer localPlayer = FramePicturePlugin.getWorldGuard().wrapPlayer(player);
		if (!rm.getApplicableRegions(frame.getLocation()).canBuild(localPlayer)) {
			player.sendMessage(Lang.PREFIX.getText() + Lang.NO_PERMISSION.getText());
			event.setCancelled(true);
			return;
		}
	}
	
	this.manager.removeFrame(frame);
	if (player != null)
		player.sendMessage(Lang.PREFIX.getText() + Lang.FRAME_REMOVED.getText().replace("%id", String.valueOf(frame.getId())));
	
	for (Entity e : entity.getNearbyEntities(32.0, 32.0, 32.0)) {
		if (e.getType() != EntityType.PLAYER) continue;
		Player p = (Player)e;
		this.sendFrameDestroy(p, entity.getEntityId());
	}
}
 
开发者ID:Howaner,项目名称:FramePicture,代码行数:37,代码来源:FrameListener.java

示例7: onHangingBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingBreak(HangingBreakEvent event)
{
    if (event.getCause() == HangingBreakEvent.RemoveCause.PHYSICS)
    {
        Hanging hanging = event.getEntity();
        Location location = hanging.getLocation();
        BaseAction cause = this.plannedHangingBreak.get(location);
        if (cause != null)
        {
            if (cause instanceof ActionPlayerBlock)
            {
                HangingBreak action;
                if (hanging instanceof ItemFrame)
                {
                    action = this.newAction(ItemframeBreak.class, location.getWorld());
                    ItemStack item = ((ItemFrame)hanging).getItem();
                    if (action != null && item != null)
                    {
                        ((ItemframeBreak)action).item = item;
                    }
                }
                else if (hanging instanceof Painting)
                {
                    action = this.newAction(PaintingBreak.class, location.getWorld());
                    ((PaintingBreak)action).art = ((Painting)hanging).getArt();
                }
                else
                {
                    action = this.newAction(HangingBreak.class, location.getWorld());
                }
                if (action != null)
                {
                    action.setLocation(location);
                    action.setHanging(hanging);
                    action.player = ((ActionPlayerBlock)cause).player;
                    action.setCause(cause);
                    this.logAction(action);
                }
            }
            // else // TODO
        }
        // else TODO this.module.getLog().info("Unexpected HangingBreakEvent");
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:46,代码来源:ListenerHanging.java

示例8: onHangingBreak

import org.bukkit.event.hanging.HangingBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onHangingBreak(final HangingBreakEvent event) {
	if (!this.module.canBeProtected(event.getEntity().getType(), event.getEntity().getLocation())) { return; }

	Optional<EntityProtection> prot = this.module.cache.getByUniqueId(event.getEntity().getUniqueId());
	if (!prot.isPresent()) { return; }

	if (event.getCause().equals(RemoveCause.EXPLOSION) || event.getCause().equals(RemoveCause.OBSTRUCTION)
			|| event.getCause().equals(RemoveCause.OBSTRUCTION) || event.getCause().equals(RemoveCause.DEFAULT)) { event.setCancelled(true); return; }

	if (event instanceof HangingBreakByEntityEvent) {
		Entity breaker = ((HangingBreakByEntityEvent)event).getRemover();
		breaker = Utility.getRealDamager(breaker);

		if (!(breaker instanceof Player)) { event.setCancelled(true); return; }

		if (this.canInteract(event.getEntity(), (Player) breaker)) {
			this.module.unprotect(prot.get());
		}
		else { debug(event.getEntity().getName() + " tried to break hanging!"); event.setCancelled(true); }
	}
	else {
		// Check if leash ib roken
		if (!event.getEntity().getType().equals(EntityType.LEASH_HITCH) || !event.getCause().equals(RemoveCause.ENTITY)) { return; }
		debug("hangingBreak() called!");

		// Leash broken so check if an protected entity was attached to it
		final LeashHitch leash = (LeashHitch) event.getEntity();
		Entity leashedEntity = null;

		final HashSet<Integer> nearbyPlayers = new HashSet<>();

		// Find owner & leashholder
		for (final Entity entity : leash.getNearbyEntities(16, 16, 16)) {
			if (entity instanceof LivingEntity && !(entity instanceof Player)) {
				final LivingEntity living = (LivingEntity) entity;
				if (living.isLeashed() && living.getLeashHolder().getUniqueId().equals(leash.getUniqueId())) {
					debug("Leashholder of " + living.getType() + " is: " + living.getLeashHolder().getType());
					leashedEntity = living;
				}
			}
			else if (entity instanceof Player) {
				final Optional<CraftoPlayer> player = CraftoPlayer.getPlayer(entity.getUniqueId());
				if (!player.isPresent()) { warn("Player " + entity.getName() + " is missing a craftoplayer instance!"); continue; }
				nearbyPlayers.add(player.get().getId());
				debug("Found a player nearby with id: " + player.get().getId());
			}
		}

		// If leashed was found check protectionse etc
		if (leashedEntity != null) {
			prot = this.module.cache.getByUniqueId(leashedEntity.getUniqueId());
			if (!prot.isPresent()) { debug("failed to find protection for " + leashedEntity.getType()); return; }
			debug("Found entityprotection with id: " + prot.get().getId());

			if (nearbyPlayers.contains(prot.get().getOwnerId())) { debug("Owner is nearby! Returning..."); return; }

			for (final int playerId : nearbyPlayers) {
				final Optional<CraftoPlayer> otherPlayer = CraftoPlayer.getPlayer(playerId);
				if (!otherPlayer.isPresent()) { continue; }

				if (this.module.isAllowedToInteract(prot.get(), otherPlayer.get())) { debug("WhitelistedPlayer nearby! Returning..."); return; }
			}

			event.setCancelled(true);
		}
	}
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:69,代码来源:EntityProtectionBreakListener.java


注:本文中的org.bukkit.event.hanging.HangingBreakEvent.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。