These commands cannot work for online players, period.

This commit is contained in:
GJ 2013-02-05 08:23:03 -05:00
parent 1c328e7ac7
commit ea32cb9e12
4 changed files with 56 additions and 39 deletions

View File

@ -52,8 +52,6 @@ public class McgodCommand implements CommandExecutor {
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// 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);
@ -61,21 +59,25 @@ public class McgodCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
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()) {
if (!player.isOnline()) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
if (profile.getGodMode()) {
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
}
}
}
profile.toggleGodMode();
return true;

View File

@ -28,8 +28,14 @@ public class McrefreshCommand implements CommandExecutor {
}
profile = Users.getPlayer(sender.getName()).getProfile();
profile.setRecentlyHurt(0);
profile.resetCooldowns();
profile.resetToolPrepMode();
profile.resetAbilityMode();
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
break;
return true;
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) {
@ -39,7 +45,6 @@ public class McrefreshCommand implements CommandExecutor {
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// 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);
@ -47,28 +52,29 @@ public class McrefreshCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
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"));
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
break;
default:
return false;
if (!player.isOnline()) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
profile.setRecentlyHurt(0);
profile.resetCooldowns();
profile.resetToolPrepMode();
profile.resetAbilityMode();
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
return true;
default:
return false;
}
}
}

View File

@ -50,16 +50,24 @@ public class McabilityCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
else {
Player player = mcMMOPlayer.getPlayer();
profile = mcMMOPlayer.getProfile();
if (!player.isOnline()) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
if (profile.getAbilityUse()) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
}
else {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability.On"));
}
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
}
profile.toggleAbilityUse();

View File

@ -437,6 +437,7 @@ Commands.mmoupdate.Start=[[GRAY]]Starting conversion...
Commands.mmoupdate.Finish=[[GREEN]]Conversion finished!
Commands.ModDescription=[[RED]]- Read brief mod description
Commands.NoConsole=This command does not support console usage.
Commands.Offline=[[RED]]This command does not work for offline players.
Commands.Other=[[GREEN]]--OTHER COMMANDS--
Commands.Party.Header=[[RED]]-----[][[GREEN]]PARTY[[RED]][]-----
Commands.Party.Status=[[DARK_GRAY]]NAME: [[WHITE]]{0} {1}