mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fixed bug with toggle commands not properly displaying the success message.
This commit is contained in:
parent
97b9214d6e
commit
fd9154e009
@ -9,6 +9,7 @@ Key:
|
||||
|
||||
Version 1.4.08-dev
|
||||
+ Added the possibility to gain experience when using Fishing "Shake"
|
||||
= Fixed bug with toggle commands not properly displaying the success message.
|
||||
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
||||
|
||||
Version 1.4.07
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@ -17,13 +18,13 @@ public class McabilityCommand extends ToggleCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
|
||||
protected void sendSuccessMessage(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@ -17,13 +18,13 @@ public class McgodCommand extends ToggleCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
|
||||
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
|
||||
protected void sendSuccessMessage(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@ -17,17 +18,17 @@ public class McrefreshCommand extends ToggleCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
protected void sendSuccessMessage(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -18,9 +17,6 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ToggleCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
@ -34,10 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
applyCommandAction();
|
||||
applyCommandAction(UserManager.getPlayer(sender.getName()));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
@ -47,20 +40,18 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
applyCommandAction();
|
||||
sendSuccessMessage(sender);
|
||||
applyCommandAction(mcMMOPlayer);
|
||||
sendSuccessMessage(sender, playerName);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -81,6 +72,6 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
protected abstract void applyCommandAction();
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
|
||||
protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user