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:
@@ -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
|
||||
|
||||
@@ -207,6 +207,7 @@ public class RPGRegionsCommand {
|
||||
}
|
||||
|
||||
plugin.reloadConfig();
|
||||
plugin.markDebugDirty();
|
||||
plugin.getManagers().getRegenerationManager().reload();
|
||||
Bukkit.getPluginManager().callEvent(new RPGRegionsReloadEvent());
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user