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

Merge pull request #1374 from MisterFrans/dev-asyncbossbar

Added option to switch bossbar creation and management to async
This commit is contained in:
Zrips 2022-02-07 15:30:26 +02:00 committed by GitHub
commit faa72b80ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -34,7 +34,19 @@ public class BossBarManager {
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)
return;

View File

@ -102,7 +102,7 @@ public class GeneralConfigManager {
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
payForEachVTradeItem, allowEnchantingBoostedItems;
payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false;
public ItemStack guiBackButton, guiNextButton;
public CMIMaterial guiFiller;
@ -890,6 +890,8 @@ public class GeneralConfigManager {
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");
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");
@ -1161,4 +1163,8 @@ public class GeneralConfigManager {
public boolean isInformDuplicates() {
return InformDuplicates;
}
public boolean isBossBarAsync() {
return bossBarAsync;
}
}