mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 02:28:03 +01:00
Fixed some possible errors if bad command arguments were used.
This commit is contained in:
parent
2b7f21fee4
commit
74ee210514
@ -30,7 +30,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
int levels;
|
int levels;
|
||||||
SkillType skill;
|
SkillType skill;
|
||||||
String skillName;
|
String skillName;
|
||||||
String usage = ChatColor.RED + "Proper usage is /addlevels <playername> <skillname> <levels>"; //TODO: Needs more locale.
|
String usage = ChatColor.RED + "Proper usage is /addlevels [playername] <skill> <level>"; //TODO: Needs more locale.
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||||
return true;
|
return true;
|
||||||
@ -54,10 +54,13 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
|
|
||||||
PP.addLevels(skill, levels);
|
PP.addLevels(skill, levels);
|
||||||
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||||
@ -90,9 +93,12 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
if (modifiedPlayer.isOnline()) {
|
if (modifiedPlayer.isOnline()) {
|
||||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
sender.sendMessage(usage);
|
||||||
|
@ -13,6 +13,7 @@ import com.gmail.nossr50.commands.CommandHelper;
|
|||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
|
|
||||||
|
//TODO: Any way we can make this work for offline use?
|
||||||
public class AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
int xp;
|
int xp;
|
||||||
SkillType skill;
|
SkillType skill;
|
||||||
String skillName;
|
String skillName;
|
||||||
String usage = ChatColor.RED + "Proper usage is /addxp <playername> <skillname> <xp>"; //TODO: Needs more locale.
|
String usage = ChatColor.RED + "Proper usage is /addxp [player] <skill> <xp>"; //TODO: Needs more locale.
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||||
return true;
|
return true;
|
||||||
@ -57,10 +58,13 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
else {
|
else {
|
||||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||||
@ -91,9 +95,12 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
else {
|
else {
|
||||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
sender.sendMessage(usage);
|
||||||
|
@ -25,7 +25,7 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
OfflinePlayer target;
|
OfflinePlayer target;
|
||||||
PlayerProfile PP;
|
PlayerProfile PP;
|
||||||
String usage = "Proper usage is /inspect <playername>"; //TODO: Needs more locale.
|
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
int newValue;
|
int newValue;
|
||||||
SkillType skill;
|
SkillType skill;
|
||||||
String skillName;
|
String skillName;
|
||||||
String usage = ChatColor.RED + "Proper usage is /mmoedit <playername> <skillname> <newvalue>"; //TODO: Needs more locale.
|
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <newvalue>"; //TODO: Needs more locale.
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||||
return true;
|
return true;
|
||||||
@ -54,10 +54,13 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
|
|
||||||
PP.modifySkill(skill, newValue);
|
PP.modifySkill(skill, newValue);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||||
@ -90,9 +93,12 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
if (modifiedPlayer.isOnline()) {
|
if (modifiedPlayer.isOnline()) {
|
||||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
sender.sendMessage(usage);
|
||||||
|
@ -1,124 +1,88 @@
|
|||||||
package com.gmail.nossr50.commands.general;
|
package com.gmail.nossr50.commands.general;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
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.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private static int oldrate = LoadProperties.xpGainMultiplier;
|
private static int oldrate = LoadProperties.xpGainMultiplier;
|
||||||
|
public static boolean xpevent = false;
|
||||||
public static boolean xpevent = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
@Override
|
||||||
if(args.length <= 0)
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
{
|
String usage1 = mcLocale.getString("Commands.xprate.proper");
|
||||||
System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
String usage2 = mcLocale.getString("Commands.xprate.proper2");
|
||||||
System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
String usage3 = mcLocale.getString("Commands.xprate.proper3");
|
||||||
}
|
|
||||||
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
return true;
|
||||||
{
|
}
|
||||||
if(xpevent)
|
|
||||||
{
|
switch (args.length) {
|
||||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
case 1:
|
||||||
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
if (args[0].equalsIgnoreCase("reset")) {
|
||||||
xpevent = !xpevent;
|
if (xpevent) {
|
||||||
LoadProperties.xpGainMultiplier = oldrate;
|
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
} else
|
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
||||||
{
|
}
|
||||||
LoadProperties.xpGainMultiplier = oldrate;
|
|
||||||
}
|
xpevent = !xpevent;
|
||||||
}
|
LoadProperties.xpGainMultiplier = oldrate;
|
||||||
|
}
|
||||||
if(args.length >= 1 && m.isInt(args[0]))
|
else {
|
||||||
{
|
LoadProperties.xpGainMultiplier = oldrate;
|
||||||
oldrate = LoadProperties.xpGainMultiplier;
|
}
|
||||||
|
}
|
||||||
if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")))
|
else if (m.isInt(args[0])) {
|
||||||
{
|
sender.sendMessage(usage3);
|
||||||
if(args[1].equalsIgnoreCase("true"))
|
}
|
||||||
xpevent = true;
|
else {
|
||||||
else
|
sender.sendMessage(usage2);
|
||||||
xpevent = false;
|
}
|
||||||
} else
|
|
||||||
{
|
return true;
|
||||||
System.out.println(mcLocale.getString("Commands.xprate.proper3"));
|
|
||||||
return true;
|
case 2:
|
||||||
}
|
if (m.isInt(args[0])) {
|
||||||
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
oldrate = LoadProperties.xpGainMultiplier;
|
||||||
if(xpevent = true)
|
|
||||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||||
{
|
xpevent = Boolean.valueOf(args[1]);
|
||||||
x.sendMessage(ChatColor.GOLD+"XP EVENT FOR mcMMO HAS STARTED!"); //TODO: Needs more locale.
|
}
|
||||||
x.sendMessage(ChatColor.GOLD+"mcMMO XP RATE IS NOW "+LoadProperties.xpGainMultiplier+"x!!"); //TODO: Needs more locale.
|
else {
|
||||||
}
|
sender.sendMessage(usage3);
|
||||||
|
}
|
||||||
System.out.println("The XP RATE was modified to "+LoadProperties.xpGainMultiplier); //TODO: Needs more locale.
|
|
||||||
}
|
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
||||||
|
|
||||||
return true;
|
if (xpevent) {
|
||||||
}
|
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
x.sendMessage(mcLocale.getString("Commands.xprate.started"));
|
||||||
Player player = (Player) sender;
|
x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier}));
|
||||||
|
}
|
||||||
if(!mcPermissions.getInstance().admin(player))
|
}
|
||||||
{
|
else {
|
||||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
|
sender.sendMessage("The XP RATE was modified to " + LoadProperties.xpGainMultiplier); //TODO: Locale
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
if(args.length <= 0)
|
else {
|
||||||
{
|
sender.sendMessage(usage1);
|
||||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
sender.sendMessage(usage2);
|
||||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
}
|
||||||
}
|
|
||||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
return true;
|
||||||
{
|
|
||||||
if(xpevent)
|
default:
|
||||||
{
|
sender.sendMessage(usage1);
|
||||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
sender.sendMessage(usage2);
|
||||||
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
return true;
|
||||||
xpevent = !xpevent;
|
}
|
||||||
LoadProperties.xpGainMultiplier = oldrate;
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
LoadProperties.xpGainMultiplier = oldrate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(args.length >= 1 && m.isInt(args[0]))
|
|
||||||
{
|
|
||||||
oldrate = LoadProperties.xpGainMultiplier;
|
|
||||||
|
|
||||||
if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")))
|
|
||||||
{
|
|
||||||
if(args[1].equalsIgnoreCase("true"))
|
|
||||||
xpevent = true;
|
|
||||||
else
|
|
||||||
xpevent = false;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper3"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
|
||||||
if(xpevent = true)
|
|
||||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
x.sendMessage(mcLocale.getString("Commands.xprate.started"));
|
|
||||||
x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class mcPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean arcaneBypass(Player player) {
|
public boolean arcaneBypass(Player player) {
|
||||||
return player.hasPermission(("mcmmo.bypass.arcanebypass"));
|
return player.hasPermission("mcmmo.bypass.arcanebypass");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -321,12 +321,12 @@ Party.PasswordSet=[[GREEN]]Party password set to {0}
|
|||||||
Party.CouldNotKick=[[DARK_RED]]Could not kick player {0}
|
Party.CouldNotKick=[[DARK_RED]]Could not kick player {0}
|
||||||
Party.NotInYourParty=[[DARK_RED]]{0} is not in your party
|
Party.NotInYourParty=[[DARK_RED]]{0} is not in your party
|
||||||
Party.CouldNotSetOwner=[[DARK_RED]]Could not set owner to {0}
|
Party.CouldNotSetOwner=[[DARK_RED]]Could not set owner to {0}
|
||||||
Commands.xprate.proper=[[DARK_AQUA]]Proper usage is /{0} [integer] [true:false]
|
Commands.xprate.proper=[[RED]]Proper usage to change the XP rate is /xprate <integer> <true/false>
|
||||||
Commands.xprate.proper2=[[DARK_AQUA]]Also you can type /{0} reset to turn everything back to normal
|
Commands.xprate.proper2=[[RED]]Proper usage to reset the XP rate to default is /xprate reset
|
||||||
Commands.xprate.proper3=[[RED]]Enter true or false for the second value
|
Commands.xprate.proper3=[[RED]]Please specify true or false to indicate if this is an xp event or not
|
||||||
Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!!
|
Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!!
|
||||||
Commands.xprate.started=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED!
|
Commands.xprate.started=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED!
|
||||||
Commands.xprate.started2=[[GOLD]]mcMMO XP RATE IS NOW {0}x!!
|
Commands.xprate.started2=[[GOLD]]mcMMO XP RATE IS NOW {0}x!
|
||||||
Commands.xplock.locked=[[GOLD]]Your XP BAR is now locked to {0}!
|
Commands.xplock.locked=[[GOLD]]Your XP BAR is now locked to {0}!
|
||||||
Commands.xplock.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]!
|
Commands.xplock.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]!
|
||||||
Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining
|
Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining
|
||||||
|
Loading…
Reference in New Issue
Block a user