mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Event updates
This commit is contained in:
@ -2,10 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class AddlevelsCommand extends ExperienceCommand {
|
||||
@ -21,11 +20,14 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class MmoeditCommand extends ExperienceCommand {
|
||||
@ -22,20 +20,16 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
if (player == null || value == skillLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
|
||||
if (value > skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
|
||||
}
|
||||
else if (value < skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
|
||||
}
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@ -102,11 +102,16 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
int levelsRemoved = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user