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


Java HangingBreakByEntityEvent类代码示例

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


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

示例1: onFrameBreak

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
public void onFrameBreak(HangingBreakByEntityEvent e) {
    if (e.getRemover() instanceof Player) {
        return;
    }
    Player p = (Player) e.getRemover();

    Map cpl = RegionMapGen.getPlayerLocations();
    cpl.put(p.getUniqueId(), RegionMapGen.getMap()[(int)p.getLocation().getX()][(int)p.getLocation().getZ()]);
    RegionMapGen.setPlayerLocations(cpl);

    if (cpl.get(p.getUniqueId()).equals("lava")) {
        Broadcast.toPlayer(p.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot break item frames in Warvale's territory.");
        e.setCancelled(true);
    } else if (cpl.get(p.getUniqueId()).equals(Main.get().getConfig().getString("Player-Data."+p.getUniqueId()+"Guild-Name"))) {
        e.setCancelled(false);
    } else {
        Broadcast.toPlayer(p, Broadcast.BroadcastType.FAILURE, "You cannot break item frames in "+cpl.get(p.getUniqueId())+"'s territory.");
        e.setCancelled(true);
    }
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:21,代码来源:RegionMapListener.java

示例2: onItemFrameDamage

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final HangingBreakByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: Hanging break by entity event");
        plugin.getLogger().info("DEBUG: cause = " + e.getCause());
        plugin.getLogger().info("DEBUG: entity = " + e.getEntity());
        plugin.getLogger().info("DEBUG: remover = " + e.getRemover());
    }
    // Check world
    if (!Util.inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Remover is mob");
        if (!Settings.allowMobDamageToItemFrames) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:23,代码来源:IslandGuard.java

示例3: onHangingDamaged

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler
  public void onHangingDamaged(HangingBreakByEntityEvent e) {
  	if (e.isCancelled()) {
          return;
      }
  	
      Entity ent = e.getRemover();
      Location loc = e.getEntity().getLocation();
      Region r = RedProtect.get().rm.getTopRegion(loc);
      if (r != null){
	return;
}
      
      if (ent instanceof Player) { 
      	Player p = (Player)ent;
          if (!bypassBuild(p, null, 0)) {
              e.setCancelled(true);
          }
      }
  }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:21,代码来源:RPGlobalListener.java

示例4: onFrameBrake

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的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

示例5: onHangingDamaged

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onHangingDamaged(HangingBreakByEntityEvent e) {
	if (e.isCancelled()) {
        return;
    }
	RedProtect.get().logger.debug("Is RPPlayerListener - HangingBreakByEntityEvent event");
    Entity ent = e.getRemover();
    Location loc = e.getEntity().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(loc);
    
    if (ent instanceof Player) {
        Player player = (Player)ent; 
        if (r != null && !r.canBuild(player) && !r.canBreak(e.getEntity().getType())) {
        	RPLang.sendMessage(player, "blocklistener.region.cantbuild");
            e.setCancelled(true);
        }
    } 
    if (ent instanceof Monster){
    	if (r != null && !r.canMobLoot()) {
            e.setCancelled(true);
        }
    }
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:24,代码来源:RPPlayerListener.java

示例6: onHangingBreakByEntityEvent

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHangingBreakByEntityEvent(HangingBreakByEntityEvent event) {
	User user = API.to(event.getRemover());
	if (user == null) return;
	ItemStack item = user.getItemInHand();
	UItem object = UItemManager.getInstance().getItem(item);
	if (object == null) return;
	
	UItemEvent result = 
			object.call(new UItemEventClick(user, object, item, true),
			object.call(new UItemEventClickEntity(user, object, item, true, event.getEntity()))
			);
	if (result.isCancelled()) {
		user.setItemInHand(result.getItem());
		event.setCancelled(true);
	}
}
 
开发者ID:imfanhua,项目名称:Minecraft-UAPI,代码行数:18,代码来源:UItemListener.java

示例7: onHangingBreak

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
    EntityProtection entityProtection = this.module.getProtectManager().getEntityProtection(event.getEntity().getType(), event.getEntity().getUniqueId());
    if(entityProtection.exists()) {
        if(event instanceof HangingBreakByEntityEvent) {
            HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
            if(entityEvent.getRemover() instanceof Player) {
                Player player = (Player) entityEvent.getRemover();

                if(entityProtection.getOwner().equals(player.getUniqueId()) || player.hasPermission(ProtectPermissions.MODIFY_ALL)) {
                    entityProtection.remove();
                    sendMessage(player, "protect.entity-unprotected");
                    return;
                }

                sendMessage(player, "protect.entity-protected-by", getDisplayName(this.module.getManager().getUsername(entityProtection.getOwner()), event.getEntity().getWorld().getName()));
            }
        }

        event.setCancelled(true);
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:23,代码来源:ProtectListener.java

示例8: onHangingEntityBreak

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
/**
 * Handles breaking paintings, item frames, leashes
 *
 * @param event The event
 */
@EventHandler
public void onHangingEntityBreak(HangingBreakByEntityEvent event) {
	if(!(event.getRemover() instanceof Player)) {
		return;
	}

	Player player = (Player) event.getRemover();
	NovaPlayer nPlayer = PlayerManager.getPlayer(player);
	boolean isLeash = event.getEntity() instanceof LeashHitch;

	if(RegionManager.get(event.getEntity()) != null
			&& (!plugin.getRegionManager().canInteract(player, event.getEntity()) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(isLeash ? GuildPermission.MOB_LEASH : GuildPermission.BLOCK_BREAK)))) {
		event.setCancelled(true);
		(isLeash ? Message.CHAT_REGION_DENY_UNLEASH : Message.CHAT_REGION_DENY_INTERACT).send(player);
	}
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:22,代码来源:RegionInteractListener.java

示例9: onItemFrameDamage

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final HangingBreakByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: Hanging break by entity event");
        plugin.getLogger().info("DEBUG: cause = " + e.getCause());
        plugin.getLogger().info("DEBUG: entity = " + e.getEntity());
        plugin.getLogger().info("DEBUG: remover = " + e.getRemover());
    }
    // Check world
    if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Remover is mob");
        if (!Settings.allowMobDamageToItemFrames) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:23,代码来源:IslandGuard.java

示例10: onHangingBreakByEntity

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
/**
 * On hanging break by entity.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {

	Player player;

	if (event.getRemover() instanceof Player
			&& !playerConf.get((player = (Player) event.getRemover()))
					.isAdminMod()) {

		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
				event.getEntity().getLocation());

		if ((land instanceof ILand && ((ILand) land).isBanned(player))
				|| !checkPermission(land, player,
						PermissionList.BUILD.getPermissionType())
				|| !checkPermission(land, player,
						PermissionList.BUILD_DESTROY.getPermissionType())) {
			messagePermission(player);
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:29,代码来源:PlayerListener.java

示例11: onHangingBreak

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onHangingBreak(HangingBreakByEntityEvent e) {
    if (e.getRemover() != null && e.getRemover() instanceof Player) {
        Player p = (Player) e.getRemover();
        User u = Necessities.getUM().getUser(p.getUniqueId());
        YamlConfiguration config = Necessities.getInstance().getConfig();
        if (config.contains("Necessities.Guilds") && config.getBoolean("Necessities.Guilds") && !p.hasPermission("Necessities.guilds.admin")) {
            Guild owner = Necessities.getGM().chunkOwner(e.getEntity().getLocation().getChunk());
            if (owner != null && u.getGuild() != owner) {
                Variables var = Necessities.getVar();
                u.getPlayer().sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You are not a part of that guild, and are not allowed to build there.");
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:pupnewfster,项目名称:Necessities,代码行数:17,代码来源:Listeners.java

示例12: onHangingBreakByEntity

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onHangingBreakByEntity(final ExtendedHangingBreakEvent ext) {
    if (ext.getBaseEvent() instanceof HangingBreakByEntityEvent) {
        final HangingBreakByEntityEvent event = (HangingBreakByEntityEvent)ext.getBaseEvent();
        if (event.getRemover().getType() == EntityType.PLAYER) {
            final Player player = (Player)event.getRemover();
            if (ext.getRegion() != null && ext.getRegion().getFlag(Flag.BUILD) && !ext.getRegion().isUser(player)) {
                event.setCancelled(true);
            }
        } else {
            if (ext.getRegion() != null && (ext.getRegion().getFlag(Flag.BUILD) || ext.getRegion().getFlag(Flag.MOB))) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:17,代码来源:BuildFlagListener.java

示例13: onBreakEvent

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
/**
 * Checks the player is allowed to break the hanging entity.
 *
 * @param event     event being handled
 */
@EventHandler (priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBreakEvent(HangingBreakByEntityEvent event) {
    if (!(event.getRemover() instanceof Player)) {
        return;
    }

    final Player player = (Player) event.getRemover();
    final Block block = event.getEntity().getLocation().getBlock();
    if (!canBuild(player, block)) {
        final Town town = plugin.getTown(block.getChunk());
        if (town == null) {
            player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_CANNOT_BUILD_HERE));
        } else {
            player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_ONLY_TOWN_MEMBERS_CAN_BREAK_BLOCKS, town.getName()));
        }
        event.setCancelled(true);
    }
}
 
开发者ID:JamesHealey94,项目名称:SimpleTowns,代码行数:24,代码来源:STListener.java

示例14: onPaintingBreak

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPaintingBreak(final HangingBreakByEntityEvent event)
{
	final ProtectHolder settings = prot.getSettings();
	Entity remover = event.getRemover();
	if ((event.getCause() == HangingBreakEvent.RemoveCause.ENTITY)
		&& ((remover instanceof Creeper) && getSettings().isCreeperBlockdamage())
		|| ((remover instanceof Wither) && getSettings().isWitherSpawnBlockdamage())
		|| ((remover instanceof Fireball) && getSettings().isFireballBlockdamage())
		|| ((remover instanceof TNTPrimed) && getSettings().isTntBlockdamage())
		|| ((remover instanceof WitherSkull) && getSettings().isWitherskullBlockdamage())
		|| ((remover instanceof ExplosiveMinecart) && getSettings().isTntMinecartBlockdamage()))
	{
		event.setCancelled(true);
	}
}
 
开发者ID:Curtis3321,项目名称:Essentials,代码行数:17,代码来源:EssentialsProtectEntityListener.java

示例15: onHangingDestroy

import org.bukkit.event.hanging.HangingBreakByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onHangingDestroy(HangingBreakByEntityEvent event) { // Item Frames and Paintings
    if (event.getRemover() != null && event.getRemover() instanceof Player) {
        if (isSpectating((Player) event.getRemover())) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:9,代码来源:SpectatorModule.java


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