mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Merge pull request #215 from btarb24/master
Player command to reset a skill level (for when cap is enabled)
This commit is contained in:
commit
ed6f48b5fe
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -26,6 +27,11 @@ public class McstatsCommand implements CommandExecutor {
|
|||||||
CommandHelper.printCombatSkills(player);
|
CommandHelper.printCombatSkills(player);
|
||||||
CommandHelper.printMiscSkills(player);
|
CommandHelper.printMiscSkills(player);
|
||||||
|
|
||||||
|
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||||
|
|
||||||
|
if (powerLevelCap > 0)
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||||
|
else
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.gmail.nossr50.commands.general;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
|
public class SkillResetCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ensure they have the skillreset perm
|
||||||
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillType skillType = null; //simple initialization
|
||||||
|
|
||||||
|
//make sure there's only one argument. output at least some kind of error if not
|
||||||
|
if (args.length != 1 && args[0] != null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//parse the skilltype that they sent
|
||||||
|
try
|
||||||
|
{
|
||||||
|
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
|
||||||
|
}catch(IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//reset the values in the hash table and persist them
|
||||||
|
PlayerProfile profile = Users.getProfile((Player)sender);
|
||||||
|
profile.resetSkill(skillType);
|
||||||
|
profile.save();
|
||||||
|
|
||||||
|
//display a success message to the user
|
||||||
|
if (skillType == SkillType.ALL)
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
|
else
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
private static int oldRate = Config.getInstance().xpGainMultiplier;
|
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
||||||
private static boolean xpEvent = false;
|
private static boolean xpEvent = false;
|
||||||
|
|
||||||
public XprateCommand (mcMMO plugin) {
|
public XprateCommand (mcMMO plugin) {
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ public class MccCommand implements CommandExecutor {
|
|||||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||||
|
|
||||||
|
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
|
||||||
|
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||||
|
}
|
||||||
|
|
||||||
if (Permissions.getInstance().mcAbility(player)) {
|
if (Permissions.getInstance().mcAbility(player)) {
|
||||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
|
|
||||||
public class Config extends ConfigLoader {
|
public class Config extends ConfigLoader {
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
public int xpGainMultiplier = 1;
|
public double xpGainMultiplier = 1;
|
||||||
|
|
||||||
private Config() {
|
private Config() {
|
||||||
super("config.yml");
|
super("config.yml");
|
||||||
@ -77,6 +77,7 @@ public class Config extends ConfigLoader {
|
|||||||
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
|
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
|
||||||
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
|
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
|
||||||
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
|
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
|
||||||
|
public boolean getCommandSkillResetEnabled() { return config.getBoolean("Commands.skillreset.Enabled", true); }
|
||||||
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
|
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
|
||||||
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
|
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
|
||||||
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
|
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
|
||||||
@ -342,7 +343,7 @@ public class Config extends ConfigLoader {
|
|||||||
/* General Settings */
|
/* General Settings */
|
||||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||||
public int getExperienceGainsGlobalMultiplier() { return config.getInt("Experience.Gains.Multiplier.Global", 1); }
|
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||||
|
@ -108,7 +108,7 @@ public class McMMOPlayer {
|
|||||||
* @param newValue The amount of XP to add
|
* @param newValue The amount of XP to add
|
||||||
*/
|
*/
|
||||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||||
int modifiedXp = xp * Config.getInstance().xpGainMultiplier;
|
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
||||||
addXPOverride(skillType, modifiedXp);
|
addXPOverride(skillType, modifiedXp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ public class McMMOPlayer {
|
|||||||
bonusModifier = calculatePartyXPModifier(skillType);
|
bonusModifier = calculatePartyXPModifier(skillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
||||||
|
|
||||||
if (bonusModifier > 0) {
|
if (bonusModifier > 0) {
|
||||||
if (bonusModifier >= 2) {
|
if (bonusModifier >= 2) {
|
||||||
|
@ -904,6 +904,21 @@ public class PlayerProfile {
|
|||||||
skills.put(skillType, skills.get(skillType) + newValue);
|
skills.put(skillType, skills.get(skillType) + newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetSkill(SkillType skillType)
|
||||||
|
{
|
||||||
|
//do a single skilltype
|
||||||
|
if (skillType != SkillType.ALL)
|
||||||
|
skills.put(skillType, 0);
|
||||||
|
else //do them all
|
||||||
|
{
|
||||||
|
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
||||||
|
{
|
||||||
|
if (skill != SkillType.ALL) // skip the "all" value
|
||||||
|
skills.put(skill, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Adds XP to the player, doesn't calculate for XP Rate
|
// * Adds XP to the player, doesn't calculate for XP Rate
|
||||||
// *
|
// *
|
||||||
|
@ -21,6 +21,7 @@ import com.gmail.nossr50.commands.general.InspectCommand;
|
|||||||
import com.gmail.nossr50.commands.general.McstatsCommand;
|
import com.gmail.nossr50.commands.general.McstatsCommand;
|
||||||
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
||||||
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
||||||
|
import com.gmail.nossr50.commands.general.SkillResetCommand;
|
||||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||||
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
||||||
import com.gmail.nossr50.commands.mc.MccCommand;
|
import com.gmail.nossr50.commands.mc.MccCommand;
|
||||||
@ -365,6 +366,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configInstance.getCommandSkillResetEnabled()) {
|
||||||
|
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||||
|
}
|
||||||
|
|
||||||
//Party commands
|
//Party commands
|
||||||
if (configInstance.getCommandAcceptEnabled()) {
|
if (configInstance.getCommandAcceptEnabled()) {
|
||||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||||
|
@ -384,6 +384,11 @@ public class Permissions {
|
|||||||
return player.hasPermission("mcmmo.commands.party");
|
return player.hasPermission("mcmmo.commands.party");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean skillReset(Player player) {
|
||||||
|
return player.hasPermission("mcmmo.skillreset");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MCMMO.CHAT.*
|
* MCMMO.CHAT.*
|
||||||
*/
|
*/
|
||||||
|
@ -321,6 +321,8 @@ Commands:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
mcstats:
|
mcstats:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
skillreset:
|
||||||
|
Enabled: true
|
||||||
mcability:
|
mcability:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
party:
|
party:
|
||||||
|
@ -408,7 +408,11 @@ Commands.Party.Teleport=<player> [[RED]]- Teleport to party member
|
|||||||
Commands.Party.Toggle=[[RED]]- Toggle Party Chat
|
Commands.Party.Toggle=[[RED]]- Toggle Party Chat
|
||||||
Commands.Party=<party-name> [[RED]]- Create/Join designated party
|
Commands.Party=<party-name> [[RED]]- Create/Join designated party
|
||||||
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
|
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
|
||||||
|
Commands.PowerLevel.Capped=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} [[DARK_RED]]MAX LEVEL: [[YELLOW]]{1}
|
||||||
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
|
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
|
||||||
|
Commands.Reset.All=[[GREEN]]All of your skill levels have been reset successfully.
|
||||||
|
Commands.Reset.Single=[[GREEN]]Your {0} skill level has been reset successfully.
|
||||||
|
Commands.Reset=[[RED]]Reset a skill's level to 0
|
||||||
Commands.Skill.Invalid=[[RED]]That is not a valid skillname!
|
Commands.Skill.Invalid=[[RED]]That is not a valid skillname!
|
||||||
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
|
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
|
||||||
Commands.SkillInfo=/<skill> [[RED]]- View detailed information about a skill
|
Commands.SkillInfo=/<skill> [[RED]]- View detailed information about a skill
|
||||||
|
@ -73,6 +73,9 @@ commands:
|
|||||||
p:
|
p:
|
||||||
aliases: [pc]
|
aliases: [pc]
|
||||||
description: Toggle Party chat or send party chat messages
|
description: Toggle Party chat or send party chat messages
|
||||||
|
skillreset:
|
||||||
|
aliases: []
|
||||||
|
description: Reset the level of one or all of your skills
|
||||||
excavation:
|
excavation:
|
||||||
aliases: []
|
aliases: []
|
||||||
description: Detailed skill info
|
description: Detailed skill info
|
||||||
@ -584,3 +587,5 @@ permissions:
|
|||||||
description: Allows access to the Axes skill
|
description: Allows access to the Axes skill
|
||||||
mcmmo.skills.acrobatics:
|
mcmmo.skills.acrobatics:
|
||||||
description: Allows access to the Acrobatics skill
|
description: Allows access to the Acrobatics skill
|
||||||
|
mcmmo.skillreset:
|
||||||
|
description: Allow reset of skill levels
|
Loading…
Reference in New Issue
Block a user