mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Update /addxp to use Bukkit handling by default rather than ours.
This commit is contained in:
parent
c15fdae32e
commit
55b17e7d2b
@ -7,6 +7,7 @@ import org.bukkit.command.PluginCommand;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
|
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
|
||||||
|
import com.gmail.nossr50.commands.admin.AddxpCommand;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||||
@ -121,4 +122,13 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" }));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" }));
|
||||||
command.setExecutor(new AddlevelsCommand());
|
command.setExecutor(new AddlevelsCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerAddxpCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("addxp");
|
||||||
|
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
|
||||||
|
command.setPermission("mcmmo.commands.addxp");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" }));
|
||||||
|
command.setExecutor(new AddxpCommand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@ -16,71 +15,60 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
//TODO: Any way we can make this work for offline use?
|
|
||||||
public class AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Player modifiedPlayer;
|
Player modifiedPlayer;
|
||||||
int xp;
|
int xp;
|
||||||
SkillType skill;
|
SkillType skill;
|
||||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" });
|
McMMOPlayer mcMMOPlayer;
|
||||||
|
PlayerProfile profile;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp")) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
if (!SkillTools.isSkill(args[1])) {
|
if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.isInt(args[1])) {
|
if (!Misc.isInt(args[1])) {
|
||||||
modifiedPlayer = (Player) sender;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
xp = Integer.valueOf(args[1]);
|
xp = Integer.valueOf(args[1]);
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
skill = SkillTools.getSkillType(args[0]);
|
||||||
|
modifiedPlayer = (Player) sender;
|
||||||
|
mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
|
||||||
mcMMOPlayer.addXpOverride(skill, xp);
|
mcMMOPlayer.addXpOverride(skill, xp);
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] { xp }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||||
}
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] { xp, Misc.getCapitalized(skill.toString()) }));
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp.others")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.addxp.others")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifiedPlayer = mcMMO.p.getServer().getPlayer(args[0]);
|
modifiedPlayer = mcMMO.p.getServer().getPlayer(args[0]);
|
||||||
String playerName = modifiedPlayer.getName();
|
mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
profile = mcMMOPlayer.getProfile();
|
||||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
|
||||||
|
|
||||||
// TODO: Not sure if we actually need a null check here
|
//TODO: Any way we can make this work for offline use?
|
||||||
if (profile == null || !profile.isLoaded()) {
|
if (profile == null || !profile.isLoaded()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
return true;
|
return true;
|
||||||
@ -91,37 +79,31 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.isInt(args[2])) {
|
if (!Misc.isInt(args[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
xp = Integer.valueOf(args[2]);
|
xp = Integer.valueOf(args[2]);
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
skill = SkillTools.getSkillType(args[1]);
|
||||||
|
String playerName = modifiedPlayer.getName();
|
||||||
|
|
||||||
mcMMOPlayer.addXpOverride(skill, xp);
|
mcMMOPlayer.addXpOverride(skill, xp);
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { playerName }));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { playerName }));
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] { xp }));
|
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] { xp }));
|
||||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] { Misc.getCapitalized(skill.toString()), playerName }));
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] { xp, Misc.getCapitalized(skill.toString()) }));
|
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] { xp, Misc.getCapitalized(skill.toString()) }));
|
||||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,4 +687,5 @@ Smelting.SkillName=SMELTING
|
|||||||
|
|
||||||
#COMMAND DESCRIPTIONS
|
#COMMAND DESCRIPTIONS
|
||||||
Commands.Description.addlevels=Add mcMMO levels to a user
|
Commands.Description.addlevels=Add mcMMO levels to a user
|
||||||
|
Commands.Description.addxp=Add mcMMO XP to a user
|
||||||
Commands.Description.Skill=Detailed mcMMO skill info for {0}
|
Commands.Description.Skill=Detailed mcMMO skill info for {0}
|
||||||
|
@ -43,7 +43,7 @@ commands:
|
|||||||
description: Show your individual ranking in mcMMO
|
description: Show your individual ranking in mcMMO
|
||||||
addxp:
|
addxp:
|
||||||
aliases: []
|
aliases: []
|
||||||
description: Add XP to a user
|
description: Add mcMMO XP to a user
|
||||||
addlevels:
|
addlevels:
|
||||||
description: Add mcMMO levels to a user
|
description: Add mcMMO levels to a user
|
||||||
mcability:
|
mcability:
|
||||||
|
Loading…
Reference in New Issue
Block a user