9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2026-01-06 15:41:35 +00:00

Improve performance at high player counts

This commit is contained in:
SamB440
2023-04-19 22:03:33 +01:00
parent 766fbfc1d4
commit 946156ec7c
3 changed files with 14 additions and 1 deletions

View File

@@ -318,9 +318,20 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
metrics.addCustomChart(new SimplePie("integration_type", () -> getConfig().getString("settings.integration.name")));
}
private Boolean debugEnabled;
// Called when the config is reloaded or the debug value was changed
public void markDebugDirty() {
this.debugEnabled = null;
}
@Override
public boolean debug() {
return this.getConfig().getBoolean("settings.dev.debug");
// This part of the code is called very often, caching the boolean gives a big performance boost at high player counts
if (this.debugEnabled == null) {
this.debugEnabled = this.getConfig().getBoolean("settings.dev.debug");
}
return debugEnabled;
}
@Override

View File

@@ -207,6 +207,7 @@ public class RPGRegionsCommand {
}
plugin.reloadConfig();
plugin.markDebugDirty();
plugin.getManagers().getRegenerationManager().reload();
Bukkit.getPluginManager().callEvent(new RPGRegionsReloadEvent());
long endTime = System.currentTimeMillis();

View File

@@ -69,6 +69,7 @@ public class RPGRegionsDebugCommand {
public void onEnable(CommandSender sender) {
final boolean newValue = !plugin.debug();
plugin.getConfig().set("settings.dev.debug", newValue);
plugin.markDebugDirty();
if (newValue) sender.sendMessage(ChatColor.GREEN + "Debug enabled.");
else sender.sendMessage(ChatColor.RED + "Debug disabled.");
}