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


Java Creeper.getTarget方法代码示例

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


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

示例1: onBreakHanging

import org.bukkit.entity.Creeper; //导入方法依赖的package包/类
/**
 * Prevents the breakage of hanging items
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onBreakHanging(final HangingBreakByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info(e.getRemover().toString());
    }
    if (Util.inWorld(e.getEntity())) {
        if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) {
            e.setCancelled(true);
            return;
        }
        // Check if creeper griefing is allowed
        if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) {
            // Find out who the creeper was targeting
            Creeper creeper = (Creeper)e.getRemover();
            if (creeper.getTarget() instanceof Player) {
                Player target = (Player)creeper.getTarget();
                // Check if the target is on their own island or not
                if (!plugin.getIslands().locationIsOnIsland(target, e.getEntity().getLocation())) {
                    // They are a visitor tsk tsk
                    e.setCancelled(true);
                    return;
                }
            }
            // Check if this creeper was lit by a visitor
            if (litCreeper.contains(creeper.getUniqueId())) {
                if (DEBUG) {
                    plugin.getLogger().info("DBEUG: preventing creeper from damaging");
                }
                e.setCancelled(true);
                return;
            }
        }
        if (e.getRemover() instanceof Player) {
            Player p = (Player) e.getRemover();
            // This permission bypasses protection
            if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
                return;
            }
            if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) {
                return;
            }
            // Not allowed
            Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:54,代码来源:IslandGuard.java

示例2: onBreakHanging

import org.bukkit.entity.Creeper; //导入方法依赖的package包/类
/**
 * Prevents the breakage of hanging items
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onBreakHanging(final HangingBreakByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info(e.getRemover().toString());
    }
    if (inWorld(e.getEntity())) {
        if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperDamage) {
            e.setCancelled(true);
            return;
        }
        // Check if creeper griefing is allowed
        if ((e.getRemover() instanceof Creeper) && !Settings.allowCreeperGriefing) {
            // Find out who the creeper was targeting
            Creeper creeper = (Creeper)e.getRemover();
            if (creeper.getTarget() instanceof Player) {
                Player target = (Player)creeper.getTarget();
                // Check if the target is on their own island or not
                if (!plugin.getGrid().locationIsOnIsland(target, e.getEntity().getLocation())) {
                    // They are a visitor tsk tsk
                    e.setCancelled(true);
                    return;
                }
            }
            // Check if this creeper was lit by a visitor
            if (litCreeper.contains(creeper.getUniqueId())) {
                if (DEBUG) {
                    plugin.getLogger().info("DBEUG: preventing creeper from damaging");
                }
                e.setCancelled(true);
                return;
            }
        }
        if (e.getRemover() instanceof Player) {
            Player p = (Player) e.getRemover();
            // This permission bypasses protection
            if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
                return;
            }
            if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) {
                return;
            }
            // Not allowed
            Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:54,代码来源:IslandGuard.java


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