Java 类org.bukkit.event.player.PlayerEggThrowEvent 实例源码

项目:bskyblock    文件:IslandGuard.java   
/**
 * Handle visitor chicken egg throwing
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEggThrow(PlayerEggThrowEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("egg throwing = " + e.getEventName());
    }
    if (!Util.inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getIslands().playerIsOnIsland(e.getPlayer()) || plugin.getIslands().isAtSpawn(e.getPlayer().getLocation())) {
        return;
    }
    // Check island
    Island island = plugin.getIslands().getProtectedIslandAt(e.getPlayer().getLocation());
    if (island == null) {
        return;
    }
    if (!island.getFlag(SettingsFlag.THROW_EGGS)) {
        e.setHatching(false);
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        //e.getPlayer().updateInventory();
    }
}
项目:AmazingEgss    文件:l.java   
/** @EVENTS **/

    @EventHandler

    public void tirarhuevo(PlayerEggThrowEvent e){

        if (e.isHatching()){
            Location loc = e.getPlayer().getLocation();

            for(int i = 0; i <360; i+=5) {
                Location particleloc = loc;
                particleloc.setZ(particleloc.getZ() + Math.cos(i) * 0.6);
                particleloc.setX(particleloc.getX() + Math.sin(i) * 0.5);
                particleloc.setY(particleloc.getY() + 0.05);
                loc.getWorld().playEffect(particleloc, Effect.valueOf(plugin.particle), 51);
            }

            Location location = e.getPlayer().getLocation();
            e.getPlayer().playSound(location, Sound.valueOf(plugin.sound), 1, 1);
        }
    }
项目:Statz    文件:EggsThrownListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEggThrow(final PlayerEggThrowEvent event) {

    final PlayerStat stat = PlayerStat.EGGS_THROWN;

    // Get player
    final Player player = (Player) event.getPlayer();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
            player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName()));

}
项目:acidisland    文件:IslandGuard.java   
/**
 * Handle visitor chicken egg throwing
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEggThrow(PlayerEggThrowEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("egg throwing = " + e.getEventName());
    }
    if (!inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getGrid().playerIsOnIsland(e.getPlayer()) || plugin.getGrid().isAtSpawn(e.getPlayer().getLocation())) {
        return;
    }
    // Check island
    Island island = plugin.getGrid().getProtectedIslandAt(e.getPlayer().getLocation());
    if (island == null) {
        return;
    }
    if (!island.getIgsFlag(SettingsFlag.EGGS)) {
        e.setHatching(false);
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        //e.getPlayer().updateInventory();
    }

    return;
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Handle visitor chicken egg throwing
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEggThrow(PlayerEggThrowEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("egg throwing = " + e.getEventName());
    }
    if (!inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getGrid().playerIsOnIsland(e.getPlayer()) || plugin.getGrid().isAtSpawn(e.getPlayer().getLocation())) {
        return;
    }
    // Check island
    Island island = plugin.getGrid().getProtectedIslandAt(e.getPlayer().getLocation());
    if (island == null) {
        return;
    }
    if (!island.getIgsFlag(SettingsFlag.EGGS)) {
        e.setHatching(false);
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        //e.getPlayer().updateInventory();
    }

    return;
}
项目:WC    文件:CatchMob.java   
@EventHandler
public void onEgg(PlayerEggThrowEvent e){
    Player p = e.getPlayer();

    if (p.getInventory().getItemInMainHand() == null) return;
    if (!p.getInventory().getItemInMainHand().hasItemMeta() || !p.getInventory().getItemInMainHand().getItemMeta().hasDisplayName()) return;
    if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(pe.getPokeEgg().getItemMeta().getDisplayName())) {
        e.setHatching(false);
    }
}
项目:PA    文件:CatchMob.java   
@EventHandler
public void onEgg(PlayerEggThrowEvent e){
    Player p = e.getPlayer();

    if (p.getInventory().getItemInMainHand() == null) return;
    if (!p.getInventory().getItemInMainHand().hasItemMeta() || !p.getInventory().getItemInMainHand().getItemMeta().hasDisplayName()) return;
    if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(pe.getPokeEgg().getItemMeta().getDisplayName())) {
        e.setHatching(false);
    }
}
项目:buildinggame    文件:ChickenSpawnByEgg.java   
/**
    * Handles players breaking join signs
    *
    * @param e an event indicating that an egg is thrown
    * @see PlayerEggThrowEvent
    * @since 3.1.2
    */
@EventHandler
public void onPlayerEggThrowEvent(PlayerEggThrowEvent e) {
    if (ArenaManager.getInstance().getArena(e.getPlayer()) == null)
        return;

    if (e.isHatching())
        e.setHatching(false);
}
项目:RedProtect    文件:RPPlayerListener.java   
@EventHandler
public void PlayerTrownEgg(PlayerEggThrowEvent e){
    Location l = e.getEgg().getLocation();
    Player p = e.getPlayer();
    Region r = RedProtect.get().rm.getTopRegion(l);

    if (r != null && !r.canBuild(p)){
        e.setHatching(false);
        RPLang.sendMessage(p, "playerlistener.region.canthatch");
    }
}
项目:SimpleEgg    文件:ListenerEggEvents.java   
/**
 * This fires after the damage event does, so this, somehow, works.
 */
@EventHandler
public void eggCollide(PlayerEggThrowEvent event) {
    if (eggTracker.getEntry(event.getEgg()) != null) {
        eggTracker.getEntry(event.getEgg()).setPlayer(event.getPlayer());
        event.setHatching(false);
    } else {
        return;
    }

    // The player is undefined before we set it above. So to make sure the
    // local var is in fact a true copy, we will define it post assignment.
    EggTrackerEntry entry = eggTracker.getEntry(event.getEgg());

    if (entry.getPlayer().hasPermission("SimpleEgg." + entry.getEntity().getType().toString().replaceAll("_", "").toLowerCase())) {
        if (!captureManager.ownerConfliction(entry)) {
            if (expenseHandler.hasMaterials(entry.getPlayer())) {
                captureManager.makeSpawnEgg(entry);
            } else {
                entry.getPlayer().sendMessage(Text.tag + "You need " + Text.a + expenseHandler.requiredMaterials() + Text.b + " to capture a mob.");
                refundEgg(entry.getPlayer());
            }
        } else {
            entry.getPlayer().sendMessage(Text.tag + "You do not own this mob.");
            refundEgg(entry.getPlayer());
        }
    } else {
        entry.getPlayer().sendMessage(Text.tag + "You do not have permission to capture this mob type.");
        refundEgg(entry.getPlayer());
    }

    eggTracker.removeEntry(entry);
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent e) {
    final Location l = BukkitUtil.getLocation(e.getEgg().getLocation());
    if (PlotSquared.isPlotWorld(l.getWorld())) {
        final Player p = e.getPlayer();
        final PlotPlayer pp = BukkitUtil.getPlayer(p);
        Plot plot = MainUtil.getPlot(l);
        if (plot == null) {
            if (!MainUtil.isPlotAreaAbs(l)) {
                return;
            }
            if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
                MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road");
                e.setHatching(false);
                return;
            }
        } else {
            if (!plot.hasOwner()) {
                if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
                    MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.unowned");
                    e.setHatching(false);
                    return;
                }
            } else if (!plot.isAdded(pp.getUUID())) {
                if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
                    if (MainUtil.isPlotArea(l)) {
                        MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.other");
                        e.setHatching(false);
                        return;
                    }
                }
            }
        }
    }
}
项目:uSkyBlock    文件:GriefEvents.java   
@EventHandler
public void onEgg(PlayerEggThrowEvent e) {
    if (!hatchingEnabled || e.getPlayer() == null || !plugin.isSkyAssociatedWorld(e.getPlayer().getWorld())) {
        return;
    }
    if (!plugin.playerIsOnIsland(e.getPlayer())) {
        e.setHatching(false);
    }
}
项目:PlotSquared    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
    Location l = BukkitUtil.getLocation(event.getEgg().getLocation());
    PlotArea area = l.getPlotArea();
    if (area == null) {
        return;
    }
    Player player = event.getPlayer();
    PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
    Plot plot = area.getPlot(l);
    if (plot == null) {
        if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
            MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
            event.setHatching(false);
        }
    } else if (!plot.hasOwner()) {
        if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
            MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
            event.setHatching(false);
        }
    } else if (!plot.isAdded(plotPlayer.getUUID())) {
        if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
            MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
            event.setHatching(false);
        }
    }
}
项目:TheSurvivalGames    文件:ThrowableSpawnEggs.java   
@EventHandler
public void throwEgg(PlayerEggThrowEvent event) {
    Egg egg = event.getEgg();
    if (this.eggs.containsKey(egg)) {
        EntityType entityType = (EntityType) this.eggs.get(egg);
        Entity entity = egg.getWorld().spawnEntity(egg.getLocation(), entityType);
        if (entityType == EntityType.SHEEP) {
            ((Sheep) entity).setColor(org.bukkit.DyeColor.values()[((int) (java.lang.Math.random() * org.bukkit.DyeColor.values().length))]);
            event.setHatching(false);
        }
    }
}
项目:tregmine    文件:EggListener.java   
@EventHandler
public void onEggThrown(PlayerEggThrowEvent event)
{
    TregminePlayer player = plugin.getPlayer(event.getPlayer());

    if (!player.hasBlockPermission(player.getLocation(), true)) {
        event.setHatching(false);
    }
}
项目:HeavySpleef    文件:FlagSplegg.java   
@EventHandler
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
    SpleefPlayer player = heavySpleef.getSpleefPlayer(event.getPlayer());
    GameManager manager = heavySpleef.getGameManager();

    Game game = manager.getGame(player);
    if (game == null || !game.isFlagPresent(FlagSplegg.class)) {
        return;
    }

    event.setHatching(false);
}
项目:Blueprint-A-Bukkit-Plugin    文件:PlayerListener.java   
@EventHandler
public void onPlayerEggThrowEvent(final PlayerEggThrowEvent pete) {
    final String playerId = ConfigHandler.getDefaultBukkitConfig().getBoolean("use.UUIDs", true) ? pete.getPlayer().getUniqueId().toString() : pete.getPlayer().getPlayer().getName();
    if (DataHandler.isPlayerActive(playerId)) {
        pete.setHatching(false);
    }
}
项目:SurvivalPlus    文件:ChickenSpawn.java   
@EventHandler
public void onEggThrown(PlayerEggThrowEvent e)
{
    e.setHatching(true);
    e.setNumHatches((byte)1);
}
项目:StarQuestCode    文件:TreeListener.java   
/**
 * @param event  
 * Don't think this event should be here, but left it in as I'm just tidying up the code and it runs OK
 */
@EventHandler
  public void onPlayerTalk(PlayerEggThrowEvent event) {}