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.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||||
command.setExecutor(new McgodCommand());
|
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;
|
package com.gmail.nossr50.commands.admin;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
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.mcMMO;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
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.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McrefreshCommand implements CommandExecutor {
|
public class McrefreshCommand 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) {
|
||||||
OfflinePlayer player;
|
|
||||||
PlayerProfile profile;
|
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) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
if (sender instanceof Player) {
|
if (!(sender instanceof Player)) {
|
||||||
player = (Player) sender;
|
return false;
|
||||||
profile = Users.getProfile(player);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile = Users.getPlayer(sender.getName()).getProfile();
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcrefresh.others")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) {
|
||||||
return true;
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
profile = Users.getProfile(player);
|
|
||||||
String playerName = player.getName();
|
|
||||||
|
|
||||||
if (profile == 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.
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
if (mcMMOPlayer == null) {
|
||||||
return true;
|
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.mcrefresh.Success", args[0]));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.setRecentlyHurt(0);
|
profile.setRecentlyHurt(0);
|
||||||
profile.resetCooldowns();
|
profile.resetCooldowns();
|
||||||
profile.resetToolPrepMode();
|
profile.resetToolPrepMode();
|
||||||
profile.resetAbilityMode();
|
profile.resetAbilityMode();
|
||||||
|
|
||||||
if (player.isOnline()) {
|
|
||||||
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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.McrefreshCommand;
|
|
||||||
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
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;
|
||||||
@ -441,7 +440,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getCommand("mcc").setExecutor(new MccCommand());
|
getCommand("mcc").setExecutor(new MccCommand());
|
||||||
CommandRegistrationHelper.registerMcgodCommand();
|
CommandRegistrationHelper.registerMcgodCommand();
|
||||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand());
|
CommandRegistrationHelper.registerMcrefreshCommand();
|
||||||
getCommand("mctop").setExecutor(new MctopCommand());
|
getCommand("mctop").setExecutor(new MctopCommand());
|
||||||
getCommand("mcrank").setExecutor(new McrankCommand());
|
getCommand("mcrank").setExecutor(new McrankCommand());
|
||||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||||
|
@ -688,5 +688,6 @@ 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.addxp=Add mcMMO XP to a user
|
||||||
Commands.Description.mcgod=Toggles mcMMO god-mode on/off
|
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||||
Commands.Description.Skill=Detailed mcMMO skill info for {0}
|
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||||
|
Commands.Description.Skill=Display detailed mcMMO skill info for {0}
|
||||||
|
@ -49,10 +49,9 @@ commands:
|
|||||||
aliases: []
|
aliases: []
|
||||||
description: Toggle whether or not abilities get readied on right click
|
description: Toggle whether or not abilities get readied on right click
|
||||||
mcrefresh:
|
mcrefresh:
|
||||||
aliases: []
|
|
||||||
description: Refresh all cooldowns for mcMMO
|
description: Refresh all cooldowns for mcMMO
|
||||||
mcgod:
|
mcgod:
|
||||||
description: Toggles mcMMO god-mode on/off
|
description: Toggle mcMMO god-mode on/off
|
||||||
mcstats:
|
mcstats:
|
||||||
aliases: [/stats]
|
aliases: [/stats]
|
||||||
description: Shows your mcMMO stats and xp
|
description: Shows your mcMMO stats and xp
|
||||||
|
Loading…
Reference in New Issue
Block a user