org.bukkit.event.player.PlayerEggThrowEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerEggThrowEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handle visitor chicken egg throwing
 * @param e - event
 */
@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;
}
 
Example #2
Source File: GriefEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onEgg(PlayerEggThrowEvent e) {
    if (!hatchingEnabled || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getWorld())) {
        return;
    }
    if (!plugin.playerIsOnIsland(e.getPlayer())) {
        e.setHatching(false);
    }
}
 
Example #3
Source File: FlagSplegg.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #4
Source File: EggsThrownListener.java    From Statz with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEggThrow(final PlayerEggThrowEvent event) {

	final PlayerStat stat = PlayerStat.EGGS_THROWN;

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

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

	PlayerStatSpecification specification = new EggsThrownSpecification(player.getUniqueId(), 1,
			player.getWorld().getName());

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery());

}