Skip to content

Commit

Permalink
create cache more cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 24, 2023
1 parent a237c47 commit fce6c0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public void reloadPlugin() {
private void reloadConfiguration() {
try {
config = new Config();
if (isServerFolia) this.tpsCache = new TPSCache.Folia(this, config.max_tps_check_interval_millis);
else this.tpsCache = new TPSCache.Default(this, config.max_tps_check_interval_millis);
this.tpsCache = TPSCache.create(config.max_tps_check_interval_millis);
AnarchyExploitFixesModule.reloadModules();
config.saveConfig();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import io.papermc.paper.threadedregions.ThreadedRegionizer;
import io.papermc.paper.threadedregions.TickRegionScheduler;
import io.papermc.paper.threadedregions.TickRegions;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;

Expand All @@ -20,6 +22,14 @@ public interface TPSCache {
double getTPS(final Location location);
double getTPS(final World world, final int chunkX, final int chunkZ);

static @NotNull TPSCache create(final long checkDelayMillis) {
if (AnarchyExploitFixes.isServerFolia()) {
return new Folia(AnarchyExploitFixes.getInstance(), checkDelayMillis);
} else {
return new Default(AnarchyExploitFixes.getInstance(), checkDelayMillis);
}
}

class Default implements TPSCache {

private final Server server;
Expand Down

0 comments on commit fce6c0b

Please sign in to comment.