mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Added McMMOPlayerLevelDownEvent and McMMOPlayerLevelChangeEvent
This commit is contained in:
parent
964b2636fb
commit
956bf2d763
@ -17,6 +17,8 @@ Version 1.4.07-dev
|
|||||||
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable
|
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable
|
||||||
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
|
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
|
||||||
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
|
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
|
||||||
|
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
|
||||||
|
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
|
||||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||||
= Fixed bug with Skull Splitter not finding the locale string
|
= Fixed bug with Skull Splitter not finding the locale string
|
||||||
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
|
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
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.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -24,8 +25,17 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
protected void handleCommand(SkillType skill) {
|
protected void handleCommand(SkillType skill) {
|
||||||
profile.modifySkill(skill, value);
|
profile.modifySkill(skill, value);
|
||||||
|
|
||||||
if (player != null) {
|
if (player == null) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -106,7 +106,7 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(skill, 0);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user levels change
|
||||||
|
*/
|
||||||
|
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
|
||||||
|
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill) {
|
||||||
|
super(player, skill);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user loses levels in a skill
|
||||||
|
*/
|
||||||
|
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
|
||||||
|
private int levelsLost;
|
||||||
|
|
||||||
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill) {
|
||||||
|
super(player, skill);
|
||||||
|
this.levelsLost = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost) {
|
||||||
|
super(player, skill);
|
||||||
|
this.levelsLost = levelsLost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param levelsLost Set the number of levels lost in this event
|
||||||
|
*/
|
||||||
|
public void setLevelsLost(int levelsLost) {
|
||||||
|
this.levelsLost = levelsLost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of levels lost in this event
|
||||||
|
*/
|
||||||
|
public int getLevelsLost() {
|
||||||
|
return levelsLost;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
/**
|
/**
|
||||||
* Called when a user levels up in a skill
|
* Called when a user levels up in a skill
|
||||||
*/
|
*/
|
||||||
public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
|
||||||
private int levelsGained;
|
private int levelsGained;
|
||||||
|
|
||||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||||
|
Loading…
Reference in New Issue
Block a user