1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Added option to switch bossbar creation and management to async

This commit is contained in:
François 2022-01-24 20:59:12 +01:00
parent 55a0705826
commit 4f553aa4fd
2 changed files with 20 additions and 2 deletions

View File

@ -34,7 +34,19 @@ public class BossBarManager {
player.getUpdateBossBarFor().clear(); player.getUpdateBossBarFor().clear();
} }
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) { public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain)
{
if(Jobs.getGCManager().isBossBarAsync())
{
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> ShowJobProgressionInTask(player, jobProg, expGain));
}
else
{
ShowJobProgressionInTask(player, jobProg, expGain);
}
}
private synchronized void ShowJobProgressionInTask(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault) if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
return; return;

View File

@ -102,7 +102,7 @@ public class GeneralConfigManager {
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse, BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled, DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
payForEachVTradeItem, allowEnchantingBoostedItems; payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false;
public ItemStack guiBackButton, guiNextButton; public ItemStack guiBackButton, guiNextButton;
public CMIMaterial guiFiller; public CMIMaterial guiFiller;
@ -890,6 +890,8 @@ public class GeneralConfigManager {
c.addComment("BossBar.Timer", "How long in sec to show BossBar for player", c.addComment("BossBar.Timer", "How long in sec to show BossBar for player",
"If you have disabled ShowOnEachAction, then keep this number higher than payment interval for better experience"); "If you have disabled ShowOnEachAction, then keep this number higher than payment interval for better experience");
BossBarTimer = c.get("BossBar.Timer", economyBatchDelay + 1); BossBarTimer = c.get("BossBar.Timer", economyBatchDelay + 1);
c.addComment("BossBar.Async", "If enabled, bossbar creation and management will be asynchronous.", "This avoids TPS drops when the ShowOnEachAction option is activated.");
bossBarAsync = c.get("BossBar.Async", false);
} }
c.addComment("ShowActionBars", "You can enable/disable message shown for players in action bar"); c.addComment("ShowActionBars", "You can enable/disable message shown for players in action bar");
@ -1161,4 +1163,8 @@ public class GeneralConfigManager {
public boolean isInformDuplicates() { public boolean isInformDuplicates() {
return InformDuplicates; return InformDuplicates;
} }
public boolean isBossBarAsync() {
return bossBarAsync;
}
} }