下面列出了怎么用org.bukkit.event.player.PlayerEggThrowEvent的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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;
}
@EventHandler
public void onEgg(PlayerEggThrowEvent e) {
if (!hatchingEnabled || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getWorld())) {
return;
}
if (!plugin.playerIsOnIsland(e.getPlayer())) {
e.setHatching(false);
}
}
@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);
}
@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());
}