mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-30 13:23:23 +01:00
Fix help for internal commands not working in standalone mode
This commit is contained in:
parent
5ae86a25c2
commit
524cc4713d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 GeorgH93
|
* Copyright (C) 2024 GeorgH93
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -12,7 +12,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||||
@ -20,6 +20,7 @@
|
|||||||
import at.pcgamingfreaks.Bukkit.Command.SubCommand;
|
import at.pcgamingfreaks.Bukkit.Command.SubCommand;
|
||||||
import at.pcgamingfreaks.Bukkit.Message.Message;
|
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||||
import at.pcgamingfreaks.Command.HelpData;
|
import at.pcgamingfreaks.Command.HelpData;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -40,6 +41,8 @@ public abstract class MinepacksCommand extends SubCommand
|
|||||||
@SuppressWarnings("FieldMayBeFinal")
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
private static MinepacksPlugin minepacksPlugin = null; // Will be set by reflection
|
private static MinepacksPlugin minepacksPlugin = null; // Will be set by reflection
|
||||||
@SuppressWarnings("FieldMayBeFinal")
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
|
private static Object minepacksCommandManager = null;
|
||||||
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
private static Method showHelp = null; // Will be set by reflection
|
private static Method showHelp = null; // Will be set by reflection
|
||||||
@SuppressWarnings("FieldMayBeFinal") // Will be overwritten by reflection
|
@SuppressWarnings("FieldMayBeFinal") // Will be overwritten by reflection
|
||||||
private static Message messageNoPermission = new Message(ChatColor.RED + "You don't have the permission to do that.");
|
private static Message messageNoPermission = new Message(ChatColor.RED + "You don't have the permission to do that.");
|
||||||
@ -182,11 +185,11 @@ public void showHelp(final @NotNull CommandSender sendTo, final @NotNull String
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
showHelp.invoke(getMinepacksPlugin().getCommandManager(), sendTo, usedMainCommandAlias, doGetHelp(sendTo));
|
showHelp.invoke(minepacksCommandManager, sendTo, usedMainCommandAlias, doGetHelp(sendTo));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
plugin.getLogger().log(Level.SEVERE, e, () -> "Failed to execute command " + usedMainCommandAlias);
|
plugin.getLogger().log(Level.SEVERE, e, () -> "Failed to show help for command " + usedMainCommandAlias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ public CommandManager(@NotNull Minepacks plugin)
|
|||||||
{
|
{
|
||||||
// Show help function
|
// Show help function
|
||||||
Reflection.setStaticField(MinepacksCommand.class, "minepacksPlugin", plugin); // Plugin instance
|
Reflection.setStaticField(MinepacksCommand.class, "minepacksPlugin", plugin); // Plugin instance
|
||||||
|
Reflection.setStaticField(MinepacksCommand.class, "minepacksCommandManager", this); // Command manager instance
|
||||||
Reflection.setStaticField(MinepacksCommand.class, "showHelp", this.getClass().getDeclaredMethod("sendHelp", CommandSender.class, String.class, Collection.class));
|
Reflection.setStaticField(MinepacksCommand.class, "showHelp", this.getClass().getDeclaredMethod("sendHelp", CommandSender.class, String.class, Collection.class));
|
||||||
Reflection.setStaticField(MinepacksCommand.class, "messageNoPermission", plugin.messageNoPermission); // No permission message
|
Reflection.setStaticField(MinepacksCommand.class, "messageNoPermission", plugin.messageNoPermission); // No permission message
|
||||||
Reflection.setStaticField(MinepacksCommand.class, "messageNotFromConsole", plugin.messageNotFromConsole); // Not from console message
|
Reflection.setStaticField(MinepacksCommand.class, "messageNotFromConsole", plugin.messageNotFromConsole); // Not from console message
|
||||||
|
Loading…
Reference in New Issue
Block a user