mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +01:00
Updating /xprate to use Bukkit command API
This commit is contained in:
parent
6d486401b5
commit
bb945a765c
@ -12,6 +12,7 @@ import com.gmail.nossr50.commands.admin.McgodCommand;
|
|||||||
import com.gmail.nossr50.commands.admin.McrefreshCommand;
|
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.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;
|
||||||
@ -168,4 +169,14 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
||||||
command.setExecutor(new SkillresetCommand());
|
command.setExecutor(new SkillresetCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerXprateCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("xprate");
|
||||||
|
command.setDescription(LocaleLoader.getString("Commands.Description.xprate"));
|
||||||
|
command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "<" + LocaleLoader.getString("Commands.Usage.True") + "|" + LocaleLoader.getString("Commands.Usage.False")+ ">"));
|
||||||
|
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset"));
|
||||||
|
command.setExecutor(new XprateCommand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,88 +6,70 @@ 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.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String usage1 = LocaleLoader.getString("Commands.xprate.proper.0");
|
|
||||||
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
|
||||||
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (!args[0].equalsIgnoreCase("reset")) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset")) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.reset")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMO.p.toggleXpEventEnabled();
|
mcMMO.p.toggleXpEventEnabled();
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Misc.isInt(args[0])) {
|
|
||||||
sender.sendMessage(usage3);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (Misc.isInt(args[0])) {
|
if (!Misc.isInt(args[0])) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set")) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.set")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
|
||||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
||||||
}
|
return false;
|
||||||
else {
|
|
||||||
sender.sendMessage(usage3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int newRate = Misc.getInt(args[0]);
|
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newRate);
|
int newXpRate = Misc.getInt(args[0]);
|
||||||
|
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", newRate));
|
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newRate));
|
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(usage1);
|
|
||||||
sender.sendMessage(usage2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage1);
|
return false;
|
||||||
sender.sendMessage(usage2);
|
|
||||||
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.XprateCommand;
|
|
||||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||||
import com.gmail.nossr50.commands.player.MccCommand;
|
import com.gmail.nossr50.commands.player.MccCommand;
|
||||||
@ -453,7 +452,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||||
CommandRegistrationHelper.registerMmoeditCommand();
|
CommandRegistrationHelper.registerMmoeditCommand();
|
||||||
getCommand("inspect").setExecutor(new InspectCommand());
|
getCommand("inspect").setExecutor(new InspectCommand());
|
||||||
getCommand("xprate").setExecutor(new XprateCommand());
|
CommandRegistrationHelper.registerXprateCommand();
|
||||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||||
CommandRegistrationHelper.registerSkillresetCommand();
|
CommandRegistrationHelper.registerSkillresetCommand();
|
||||||
|
|
||||||
|
@ -490,13 +490,16 @@ Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click
|
|||||||
Commands.Usage.1=[[RED]]Proper usage is /{0} {1}
|
Commands.Usage.1=[[RED]]Proper usage is /{0} {1}
|
||||||
Commands.Usage.2=[[RED]]Proper usage is /{0} {1} {2}
|
Commands.Usage.2=[[RED]]Proper usage is /{0} {1} {2}
|
||||||
Commands.Usage.3=[[RED]]Proper usage is /{0} {1} {2} {3}
|
Commands.Usage.3=[[RED]]Proper usage is /{0} {1} {2} {3}
|
||||||
|
Commands.Usage.False=false
|
||||||
Commands.Usage.Level=level
|
Commands.Usage.Level=level
|
||||||
Commands.Usage.Message=message
|
Commands.Usage.Message=message
|
||||||
Commands.Usage.Page=page
|
Commands.Usage.Page=page
|
||||||
Commands.Usage.PartyName=party-name
|
Commands.Usage.PartyName=party-name
|
||||||
Commands.Usage.Password=password
|
Commands.Usage.Password=password
|
||||||
Commands.Usage.Player=player
|
Commands.Usage.Player=player
|
||||||
|
Commands.Usage.Rate=rate
|
||||||
Commands.Usage.Skill=skill
|
Commands.Usage.Skill=skill
|
||||||
|
Commands.Usage.True=true
|
||||||
Commands.Usage.XP=xp
|
Commands.Usage.XP=xp
|
||||||
mcMMO.NoInvites=[[RED]]You have no invites at this time
|
mcMMO.NoInvites=[[RED]]You have no invites at this time
|
||||||
mcMMO.NoPermission=[[DARK_RED]]Insufficient permissions.
|
mcMMO.NoPermission=[[DARK_RED]]Insufficient permissions.
|
||||||
@ -691,3 +694,4 @@ Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
|||||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
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}
|
||||||
Commands.Description.skillreset=Reset mcMMO levels for a user
|
Commands.Description.skillreset=Reset mcMMO levels for a user
|
||||||
|
Commands.Description.xprate=Modify the mcMMO XP rate or start an mcMMO XP event
|
||||||
|
Loading…
Reference in New Issue
Block a user