Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.simplyvanilla.simplyrank.addresswhitelist.AddressWhitelistService;
Expand Down Expand Up @@ -46,6 +47,8 @@ public class SimplyRankPlugin extends JavaPlugin {

private MySqlClient mySqlClient = null;

private ScheduledTask cleanerTask;


@Override
public void onEnable() {
Expand Down Expand Up @@ -93,7 +96,7 @@ public void onEnable() {
this.playerDataService =
new PlayerDataService(mySqlRepository, mySqlRepository);
proxyService = new ProxyService(mySqlRepository, new ProxyCheckProvider(this.getConfig().getString("proxycheck-api-url", "https://proxycheck.io/v2/%s&vpn=1")));
Bukkit.getAsyncScheduler().runAtFixedRate(this, new ProxyTtlCleanupTask(proxyService, this.getConfig().getInt("proxycache-ttl", 720)), 1, 10, TimeUnit.SECONDS);
this.cleanerTask = Bukkit.getAsyncScheduler().runAtFixedRate(this, new ProxyTtlCleanupTask(proxyService, this.getConfig().getInt("proxycache-ttl", 720)), 1, 10, TimeUnit.SECONDS);

if (!this.playerDataService.groupExists("default")) {
GroupData defaultData = new GroupData(NamedTextColor.GRAY, "Member ");
Expand Down Expand Up @@ -156,6 +159,7 @@ public void onEnable() {
@Override
public void onDisable() {
instance = null;
if (this.cleanerTask != null) this.cleanerTask.cancel();
if (this.mySqlClient != null) {
this.mySqlClient.close();
}
Expand Down