mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-22 18:26:08 +01:00
Prevent infinite recursion in command aliases.
This commit is contained in:
parent
4317d6db46
commit
a4a3a18c30
@ -21,7 +21,12 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -145,10 +150,18 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
sendConsoleHelpCommands(sender);
|
||||
} else {
|
||||
String commandToExecute;
|
||||
String defaultCommand;
|
||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", "island create");
|
||||
defaultCommand = "island create";
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", defaultCommand);
|
||||
} else {
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", "island controlpanel");
|
||||
defaultCommand = "island controlpanel";
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", defaultCommand);
|
||||
}
|
||||
|
||||
if (commandToExecute.trim().equalsIgnoreCase("island") || commandToExecute.trim().equalsIgnoreCase("is")) {
|
||||
commandToExecute = defaultCommand;
|
||||
Bukkit.getLogger().warning("Cannot redirect /island to /island or /is, would result in an endless loop. Using the default.");
|
||||
}
|
||||
|
||||
if (commandToExecute.startsWith("/")) {
|
||||
|
Loading…
Reference in New Issue
Block a user