Fix stack overflow when disabling commands from other addons (#4680)

This commit is contained in:
Josh Roy 2021-12-11 22:16:23 -05:00 committed by GitHub
parent dc27af78bf
commit dae519494e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -749,7 +749,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
if (getSettings().isCommandDisabled(commandLabel)) {
if (getKnownCommandsProvider().getKnownCommands().containsKey(commandLabel)) {
final Command newCmd = getKnownCommandsProvider().getKnownCommands().get(commandLabel);
if (!(newCmd instanceof PluginIdentifiableCommand) || ((PluginIdentifiableCommand) newCmd).getPlugin() != this) {
if (!(newCmd instanceof PluginIdentifiableCommand) || !isEssentialsPlugin(((PluginIdentifiableCommand) newCmd).getPlugin())) {
return newCmd.execute(cSender, commandLabel, args);
}
}
@ -824,6 +824,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
}
}
private boolean isEssentialsPlugin(Plugin plugin) {
return plugin.getDescription().getMain().contains("com.earth2me.essentials") || plugin.getDescription().getMain().contains("net.essentialsx");
}
public void cleanupOpenInventories() {
for (final User user : getOnlineUsers()) {
if (user.isRecipeSee()) {