Skip to content

Fixes async help unregister async #7962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev/patch
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions src/main/java/ch/njol/skript/command/ScriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ch.njol.skript.log.Verbosity;
import ch.njol.skript.util.Date;
import ch.njol.skript.util.EmptyStacktraceException;
import ch.njol.skript.util.Task;
import ch.njol.skript.util.Timespan;
import ch.njol.skript.util.Utils;
import ch.njol.skript.util.chat.BungeeConverter;
Expand Down Expand Up @@ -459,21 +460,27 @@ public void registerHelp() {
}

public void unregisterHelp() {
Bukkit.getHelpMap().getHelpTopics().removeAll(helps);
final HelpTopic aliases = Bukkit.getHelpMap().getHelpTopic("Aliases");
if (aliases != null && aliases instanceof IndexHelpTopic) {
try {
final Field topics = IndexHelpTopic.class.getDeclaredField("allTopics");
topics.setAccessible(true);
@SuppressWarnings("unchecked")
final ArrayList<HelpTopic> as = new ArrayList<>((Collection<HelpTopic>) topics.get(aliases));
as.removeAll(helps);
topics.set(aliases, as);
} catch (final Exception e) {
Skript.outdatedError(e);//, "error unregistering aliases for /" + getName());
new Task(Skript.getInstance(), 1) {
@Override
public void run() {
Bukkit.getHelpMap().getHelpTopics().removeAll(helps);

final HelpTopic aliases = Bukkit.getHelpMap().getHelpTopic("Aliases");
if (aliases != null && aliases instanceof IndexHelpTopic) {
try {
final Field topics = IndexHelpTopic.class.getDeclaredField("allTopics");
topics.setAccessible(true);
@SuppressWarnings("unchecked")
final ArrayList<HelpTopic> as = new ArrayList<>((Collection<HelpTopic>) topics.get(aliases));
as.removeAll(helps);
topics.set(aliases, as);
} catch (final Exception e) {
Skript.outdatedError(e);//, "error unregistering aliases for /" + getName());
}
}
helps.clear();
}
}
helps.clear();
};
}

public String getName() {
Expand Down