Skip to content
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

Fix version check #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
14 changes: 9 additions & 5 deletions src/main/java/org/dynmap/towny/DynmapTownyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public class DynmapTownyPlugin extends JavaPlugin {
boolean chat_sendlogin;
boolean chat_sendquit;
String chatformat;
private final TaskScheduler scheduler;
private final Object scheduler;

public DynmapTownyPlugin() {
this.scheduler = isFoliaClassPresent() ? new FoliaTaskScheduler(this) : new BukkitTaskScheduler(this);
this.scheduler = townyVersionCheck() ? isFoliaClassPresent() ? new FoliaTaskScheduler(this) : new BukkitTaskScheduler(this) : null;
}

@Override
Expand Down Expand Up @@ -929,8 +929,8 @@ public void onEnable() {
townychat = (Chat)p;
}

if (Version.fromString(towny.getDescription().getVersion()).compareTo(requiredTownyVersion) < 0) {
getLogger().severe("Towny version does not meet required minimum version: " + requiredTownyVersion.toString());
if (!townyVersionCheck()) {
getLogger().severe("Towny version does not meet required minimum version: " + requiredTownyVersion);
this.getServer().getPluginManager().disablePlugin(this);
return;
} else {
Expand All @@ -945,6 +945,10 @@ public void onEnable() {
prepForChat();
}
}

private boolean townyVersionCheck() {
return Version.fromString(Towny.getPlugin().getDescription().getVersion()).compareTo(requiredTownyVersion) >= 0;
}

private void prepForChat() {
/* If townychat is active, and we've found dynmap API */
Expand Down Expand Up @@ -1069,7 +1073,7 @@ private void activate() {
updperiod = (per*20L);
stop = false;

scheduler.runAsyncRepeating(new TownyUpdate(), 40, per);
((TaskScheduler) scheduler).runAsyncRepeating(new TownyUpdate(), 40, per);

info("version " + this.getDescription().getVersion() + " is activated");
}
Expand Down