mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Changed /mmoedit to use Bukkit command info. Also fixed bug where
/mcrefresh was registered with the info of /mcgod
This commit is contained in:
parent
958095d11b
commit
c3db026fd9
@ -9,6 +9,8 @@ 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.commands.admin.AddxpCommand;
|
||||||
import com.gmail.nossr50.commands.admin.McgodCommand;
|
import com.gmail.nossr50.commands.admin.McgodCommand;
|
||||||
|
import com.gmail.nossr50.commands.admin.McrefreshCommand;
|
||||||
|
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
||||||
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;
|
||||||
@ -28,7 +30,6 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
|
|
||||||
public final class CommandRegistrationHelper {
|
public final class CommandRegistrationHelper {
|
||||||
private CommandRegistrationHelper() {};
|
private CommandRegistrationHelper() {};
|
||||||
|
|
||||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||||
|
|
||||||
public static void registerSkillCommands() {
|
public static void registerSkillCommands() {
|
||||||
@ -148,6 +149,15 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setPermission("mcmmo.commands.mcrefresh");
|
command.setPermission("mcmmo.commands.mcrefresh");
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||||
command.setExecutor(new McgodCommand());
|
command.setExecutor(new McrefreshCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerMmoeditCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("mmoedit");
|
||||||
|
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
|
||||||
|
command.setPermission("mcmmo.commands.mmoedit");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
|
||||||
|
command.setExecutor(new MmoeditCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
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.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;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class MmoeditCommand implements CommandExecutor {
|
public class MmoeditCommand implements CommandExecutor {
|
||||||
@ -20,28 +20,27 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
int newValue;
|
int newValue;
|
||||||
SkillType skill;
|
SkillType skill;
|
||||||
String skillName;
|
|
||||||
String usage = LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">");
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit")) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (!SkillTools.isSkill(args[0])) {
|
||||||
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])) {
|
||||||
Player player = (Player) sender;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[1]);
|
newValue = Integer.valueOf(args[1]);
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
skill = SkillTools.getSkillType(args[0]);
|
||||||
profile = Users.getProfile(player);
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill == SkillType.ALL) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -49,58 +48,29 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
profile.modifySkill(skill, newValue);
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit.others")) {
|
if (Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[2])) {
|
if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(usage);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
|
||||||
|
|
||||||
if (skill == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Misc.isInt(args[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[2]);
|
newValue = Integer.valueOf(args[2]);
|
||||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
skill = SkillTools.getSkillType(args[1]);
|
||||||
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
|
|
||||||
if (mcmmoPlayer != null) {
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
profile = mcmmoPlayer.getProfile();
|
if (mcMMOPlayer == null) {
|
||||||
|
|
||||||
if (profile == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
|
||||||
if (skill == SkillType.ALL) {
|
|
||||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skillName = Misc.getCapitalized(skill.toString());
|
|
||||||
|
|
||||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skillName, newValue));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
if (!profile.isLoaded()) {
|
||||||
@ -109,7 +79,24 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
profile.modifySkill(skill, newValue);
|
||||||
profile.save();
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
profile.modifySkill(skill, newValue);
|
||||||
|
|
||||||
|
// Check if the player is online before we try to send them a message.
|
||||||
|
if (player.isOnline()) {
|
||||||
|
if (skill == SkillType.ALL) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(skill.toString()), newValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
if (skill == SkillType.ALL) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
@ -117,12 +104,11 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
|||||||
import com.gmail.nossr50.chat.commands.ACommand;
|
import com.gmail.nossr50.chat.commands.ACommand;
|
||||||
import com.gmail.nossr50.chat.commands.PCommand;
|
import com.gmail.nossr50.chat.commands.PCommand;
|
||||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||||
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
|
||||||
import com.gmail.nossr50.commands.admin.SkillResetCommand;
|
import com.gmail.nossr50.commands.admin.SkillResetCommand;
|
||||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||||
@ -454,7 +453,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// Other commands
|
// Other commands
|
||||||
CommandRegistrationHelper.registerAddxpCommand();
|
CommandRegistrationHelper.registerAddxpCommand();
|
||||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
CommandRegistrationHelper.registerMmoeditCommand();
|
||||||
getCommand("inspect").setExecutor(new InspectCommand());
|
getCommand("inspect").setExecutor(new InspectCommand());
|
||||||
getCommand("xprate").setExecutor(new XprateCommand());
|
getCommand("xprate").setExecutor(new XprateCommand());
|
||||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||||
|
@ -690,4 +690,5 @@ Commands.Description.addlevels=Add mcMMO levels to a user
|
|||||||
Commands.Description.addxp=Add mcMMO XP to a user
|
Commands.Description.addxp=Add mcMMO XP to a user
|
||||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||||
|
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||||
Commands.Description.Skill=Display detailed mcMMO skill info for {0}
|
Commands.Description.Skill=Display detailed mcMMO skill info for {0}
|
||||||
|
@ -59,8 +59,7 @@ commands:
|
|||||||
aliases: []
|
aliases: []
|
||||||
description: Remove a user from the database
|
description: Remove a user from the database
|
||||||
mmoedit:
|
mmoedit:
|
||||||
aliases: []
|
description: Edit the mcMMO skill values for a user
|
||||||
description: Edit the skill values for a user
|
|
||||||
ptp:
|
ptp:
|
||||||
aliases: []
|
aliases: []
|
||||||
description: Teleport to a party member
|
description: Teleport to a party member
|
||||||
|
Loading…
Reference in New Issue
Block a user