mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Update /mcrefresh to use Bukkit command info. Also updated a few
description strings.
This commit is contained in:
parent
b21dc8631a
commit
958095d11b
@ -141,4 +141,13 @@ public final class CommandRegistrationHelper {
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
public static void registerMcrefreshCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcrefresh");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
|
||||
command.setPermission("mcmmo.commands.mcrefresh");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McgodCommand());
|
||||
}
|
||||
}
|
||||
|
@ -1,77 +1,68 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer player;
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]");
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcrefresh")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer(sender.getName()).getProfile();
|
||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcrefresh.others")) {
|
||||
return true;
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
}
|
||||
|
||||
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
// 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.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||
break;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
|
||||
if (player.isOnline()) {
|
||||
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
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.PCommand;
|
||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||
import com.gmail.nossr50.commands.admin.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.admin.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||
@ -441,7 +440,7 @@ public class mcMMO extends JavaPlugin {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
CommandRegistrationHelper.registerMcgodCommand();
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand());
|
||||
CommandRegistrationHelper.registerMcrefreshCommand();
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
getCommand("mcrank").setExecutor(new McrankCommand());
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
|
@ -688,5 +688,6 @@ Smelting.SkillName=SMELTING
|
||||
#COMMAND DESCRIPTIONS
|
||||
Commands.Description.addlevels=Add mcMMO levels to a user
|
||||
Commands.Description.addxp=Add mcMMO XP to a user
|
||||
Commands.Description.mcgod=Toggles mcMMO god-mode on/off
|
||||
Commands.Description.Skill=Detailed mcMMO skill info for {0}
|
||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||
Commands.Description.Skill=Display detailed mcMMO skill info for {0}
|
||||
|
@ -49,10 +49,9 @@ commands:
|
||||
aliases: []
|
||||
description: Toggle whether or not abilities get readied on right click
|
||||
mcrefresh:
|
||||
aliases: []
|
||||
description: Refresh all cooldowns for mcMMO
|
||||
mcgod:
|
||||
description: Toggles mcMMO god-mode on/off
|
||||
description: Toggle mcMMO god-mode on/off
|
||||
mcstats:
|
||||
aliases: [/stats]
|
||||
description: Shows your mcMMO stats and xp
|
||||
|
Loading…
Reference in New Issue
Block a user