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


Java Squid类代码示例

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


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

示例1: onCreatureSpawn

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event == null || event.isCancelled() || event.getLocation() == null || !plugin.isSkyWorld(event.getLocation().getWorld())) {
        return; // Bail out, we don't care
    }
    if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) {
        return; // Allow it, the above method would have blocked it if it should be blocked.
    }
    checkLimits(event, event.getEntity().getType(), event.getLocation());
    if (!event.isCancelled() && event.getEntity() instanceof Squid) {
        Location loc = event.getLocation();
        int z = loc.getBlockZ();
        int x = loc.getBlockX();
        if (loc.getWorld().getBiome(x, z) == Biome.DEEP_OCEAN && LocationUtil.findRoofBlock(loc).getType() == Material.PRISMARINE) {
            loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
            event.setCancelled(true);
        }
    }
    if (!event.isCancelled() && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) {
        IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation());
        if (islandInfo != null && islandInfo.getLeader() != null) {
            event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader()));
            event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName()));
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:27,代码来源:SpawnEvents.java

示例2: squidLoot

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void squidLoot(EntityDeathEvent e) {
    EntityDamageEvent ede = e.getEntity().getLastDamageCause();
    if (!(ede instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent edbee = (EntityDamageByEntityEvent) ede;
    Entity damager = edbee.getDamager();
    if (!Config.useSquidLoot || r.nextInt(100) > Config.squidLootChance || !(damager instanceof Player)) return;
    Player p = (Player) damager;
    Entity ent = e.getEntity();
    if (!(ent instanceof Squid)) return;
    Squid squid = (Squid) ent;
    if (!RUtils.isInInfectedWorld(squid) || !RUtils.isInInfectedWorld(p)) return;
    List<String> lootSets = Config.squidLootSets;
    if (lootSets.isEmpty()) return;
    String lootSet = lootSets.get(r.nextInt(lootSets.size()));
    final LootChest lc = LootChest.getLootChest(lootSet);
    if (lc == null) return;
    Location l = squid.getLocation();
    World w = l.getWorld();
    for (ItemStack drop : lc.getRandomLoot()) w.dropItemNaturally(l, drop);
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:22,代码来源:SurvivorsListener.java

示例3: onProjectileHit

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onProjectileHit(ProjectileHitEvent event) {
    Projectile proj = event.getEntity();
    if (proj == null)
        return;
    
    UUID projId = proj.getUniqueId();
    if (squidEggIds.contains(projId)) {
        squidEggIds.remove(projId);
        Squid squid = (Squid) proj.getWorld().spawn(proj.getLocation(), EntityType.SQUID.getEntityClass());
        proj.remove();
        
        squidMobIds.add(squid.getUniqueId());
    }
}
 
开发者ID:YaLTeR,项目名称:UnexpectedFishing,代码行数:16,代码来源:UnexpectedFishingListener.java

示例4: onLingeringPotionDamage

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
        plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
        plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
        plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
    }
    if (!Util.inWorld(e.getEntity().getLocation())) {
        return;
    }
    if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
        return;
    }
    if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
        UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
        // Self damage
        if (attacker.equals(e.getEntity().getUniqueId())) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
            return;
        }
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        boolean inNether = false;
        if (e.getEntity().getWorld().equals(IslandWorld.getNetherWorld())) {
            inNether = true;
        }
        // Monsters being hurt
        if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
            // Normal island check
            if (island != null && island.getMembers().contains(attacker)) {
                // Members always allowed
                return;
            }
            if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
                return;
            }
            // Not allowed
            e.setCancelled(true);
            return;
        }

        // Mobs being hurt
        if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
                || e.getEntity() instanceof Villager) {
            if (island != null && (island.getFlag(SettingsFlag.HURT_ANIMALS) || island.getMembers().contains(attacker))) {
                return;
            }
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
            e.setCancelled(true);
            return;
        }

        // Establish whether PVP is allowed or not.
        boolean pvp = false;
        if ((inNether && island != null && island.getFlag(SettingsFlag.PVP_NETHER) || (!inNether && island != null && island.getFlag(SettingsFlag.PVP_OVERWORLD)))) {
            if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
            pvp = true;
        }

        // Players being hurt PvP
        if (e.getEntity() instanceof Player) {
            if (!pvp) {
                if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:72,代码来源:IslandGuard1_9.java

示例5: onCreatureSpawn

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getEntity() instanceof Squid) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:WorldListener.java

示例6: CanarySquid

import org.bukkit.entity.Squid; //导入依赖的package包/类
public CanarySquid(net.canarymod.api.entity.living.animal.Squid entity) {
    super(entity);
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:4,代码来源:CanarySquid.java

示例7: onLingeringPotionDamage

import org.bukkit.entity.Squid; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
        plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
        plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
        plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
    }
    if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
        return;
    }
    if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
        return;
    }
    if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
        UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
        // Self damage
        if (attacker.equals(e.getEntity().getUniqueId())) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
            return;
        }
        Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
        boolean inNether = false;
        if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
            inNether = true;
        }
        // Monsters being hurt
        if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
            // Normal island check
            if (island != null && island.getMembers().contains(attacker)) {
                // Members always allowed
                return;
            }
            if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
                return;
            }
            // Not allowed
            e.setCancelled(true);
            return;
        }

        // Mobs being hurt
        if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
                || e.getEntity() instanceof Villager) {
            if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
                return;
            }
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
            e.setCancelled(true);
            return;
        }

        // Establish whether PVP is allowed or not.
        boolean pvp = false;
        if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
            if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
            pvp = true;
        }

        // Players being hurt PvP
        if (e.getEntity() instanceof Player) {
            if (pvp) {
                if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
                return;
            } else {
                if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
                e.setCancelled(true);
                return;
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:76,代码来源:IslandGuard1_9.java


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