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

项目:AdvancedAchievements    文件:AchieveXPListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerExpChange(PlayerLevelChangeEvent event) {
    Player player = event.getPlayer();

    NormalAchievements category = NormalAchievements.LEVELS;
    if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
        return;
    }

    int previousMaxLevel = (int) plugin.getCacheManager().getAndIncrementStatisticAmount(category,
            player.getUniqueId(), 0);

    if (event.getNewLevel() <= previousMaxLevel) {
        return;
    }

    updateStatisticAndAwardAchievementsIfAvailable(player, category, event.getNewLevel() - previousMaxLevel);
}
项目:GoogleAnalyticsPlugin    文件:GoogleAnalyticsEventListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLevelChange(PlayerLevelChangeEvent event){
    if(enableEventLevelUp) {
        try {
            Player player = (Player) event.getPlayer();

            if(!player.hasPermission("googleanalyticsplugin.ignore")) {
                if(event.getOldLevel() < event.getNewLevel()) {
                    plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Levelup", String.format("Level %3s",  "" + player.getLevel()));
                }
            }               
        }
        catch(Exception e) {
            plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
        }
    }
}
项目:SwornRPG    文件:MinecraftXP.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLevelChange(PlayerLevelChangeEvent event)
{
    Player player = event.getPlayer();
    if (player.getGameMode() != GameMode.SURVIVAL)
        return;

    if (isFactionsApplicable(player, true))
        return;

    if (plugin.isDisabledWorld(player) || plugin.isCamping(player))
        return;

    // Only give xp for single level changes
    int oldLevel = event.getOldLevel();
    int newLevel = event.getNewLevel();
    if (newLevel - oldLevel != 1)
        return;

    String message = plugin.getPrefix() + FormatUtil.format(plugin.getMessage("mc_xp_gain"), xpGain);
    plugin.getExperienceHandler().handleXpGain(player, xpGain, message);
}
项目:ExpTreasury    文件:ExpLevelListener.java   
@EventHandler
public void onNewLevel(PlayerLevelChangeEvent event) {
    Player player = event.getPlayer();
    if (event.getNewLevel() == 30) {
        MessageFormat formatter = new MessageFormat(Language.getBundle().getString("exp-treasury.reminder"));
        player.sendMessage(formatter.format(new Object[]{30}));
    }

    if (event.getOldLevel() < event.getNewLevel() && bank.getConfig().getBoolean("fireworks")) {
        Firework firework = player.getWorld().spawn(event.getPlayer().getLocation(), Firework.class);
        FireworkMeta meta = firework.getFireworkMeta();
        meta.addEffects(FireworkEffect.builder().withColor(Color.BLACK, Color.YELLOW, Color.RED).withFlicker().withFade(Color.YELLOW, Color.RED, Color.BLACK).withTrail().build());
        meta.setPower(1);
        firework.setFireworkMeta(meta);
    }

}
项目:ArchersBattle    文件:PlayerListener.java   
@EventHandler
public void onLevelChange(PlayerLevelChangeEvent e) {
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (e.getNewLevel() == 0) {
        return;
    }
    if (e.getNewLevel() > 30) {
        e.getPlayer().setLevel(30);
    } else {
        Player p = e.getPlayer();
        Utils.flushSkillSelection(p);
    }
}
项目:BasicSurvivalPlus    文件:PlayerLvlListener.java   
@EventHandler
public void onPlayerLvlChanged(PlayerLevelChangeEvent event){
    Player player = event.getPlayer();
    if (player.getLevel() >= 60){
        return;
    }
    //增加血槽
    double healAdded = event.getNewLevel();
    player.setMaxHealth(20 + healAdded);

}
项目:Skript    文件:ExprLevel.java   
@Override
protected Integer[] get(final Event e, final Player[] source) {
    return super.get(source, new Converter<Player, Integer>() {
        @SuppressWarnings("null")
        @Override
        public Integer convert(final Player p) {
            if (e instanceof PlayerLevelChangeEvent && ((PlayerLevelChangeEvent) e).getPlayer() == p && !Delay.isDelayed(e)) {
                return getTime() < 0 ? ((PlayerLevelChangeEvent) e).getOldLevel() : ((PlayerLevelChangeEvent) e).getNewLevel();
            }
            return p.getLevel();
        }
    });
}
项目:BetonQuest    文件:ExperienceObjective.java   
@EventHandler
public void onLevelUp(PlayerLevelChangeEvent event) {
    String playerID = PlayerConverter.getID(event.getPlayer());
    if (!containsPlayer(playerID)) {
        return;
    }
    if (event.getNewLevel() >= level && checkConditions(playerID)) {
        completeObjective(playerID);
    }
}
项目:EpicQuest    文件:TypeLevelUp.java   
@EventHandler
public void onPlayerLevelChange(PlayerLevelChangeEvent event){

    Player player = event.getPlayer();
    EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
    List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.LEVEL_UP);

    for(EpicQuestTask task : taskList){
        int oldlevel = event.getOldLevel();
        int newlevel = event.getNewLevel();
        if(newlevel > oldlevel){
            task.ProgressTask(1, epicPlayer, true);
        }
    }
}
项目:Skript    文件:ExprLevel.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), PlayerLevelChangeEvent.class, PlayerDeathEvent.class);
}
项目:world-of-icerealm    文件:PerkNotifier.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerLevelChangeEvent evt) {
    if (evt.getNewLevel() % 5 == 0) {
        evt.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE + "Hey " + ChatColor.YELLOW + evt.getPlayer().getName() + ChatColor.LIGHT_PURPLE + "! Consider buying a perk using " + ChatColor.GREEN + "/perk" + ChatColor.LIGHT_PURPLE + " command!");
    }
}
项目:Peacecraft    文件:StatsListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLevelChange(PlayerLevelChangeEvent event) {
    this.module.getStatSystem().setStat("status.levels", event.getPlayer().getName(), event.getNewLevel());
}
项目:Merlin    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerLevelChange (PlayerLevelChangeEvent event)
  {
    sorcererManager.getSorcerer(event.getPlayer()).setLevel(
        event.getNewLevel());
  }