From 0dca69e89109b087ec9ff4a94cc82c5204ea01f5 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Wed, 27 Feb 2019 19:02:00 +0100 Subject: [PATCH] Added option to config to pay exploring when player gliding - Now not generates the bossbar options when using 1.8 or lower versions. --- .../jobs/config/GeneralConfigManager.java | 40 +++++++++---------- .../jobs/listeners/JobsPaymentListener.java | 25 ++++++------ 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 1de1d389..ca49697f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -49,6 +49,7 @@ public class GeneralConfigManager { protected boolean isBroadcastingLevelups; protected boolean payInCreative; protected boolean payExploringWhenFlying; + public boolean payExploringWhenGliding; protected boolean addXpPlayer; public boolean payItemDurabilityLoss; protected boolean hideJobsWithoutPermission; @@ -516,6 +517,11 @@ public class GeneralConfigManager { c.addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flies"); payExploringWhenFlying = c.get("enable-pay-for-exploring-when-flying", false); + if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1)) { + c.addComment("enable-pay-for-exploring-when-gliding", "Option to allow payment to be made for exploring when player gliding."); + payExploringWhenGliding = c.get("enable-pay-for-exploring-when-gliding", false); + } + c.addComment("add-xp-player", "Adds the Jobs xp received to the player's Minecraft XP bar"); addXpPlayer = c.get("add-xp-player", false); @@ -821,27 +827,21 @@ public class GeneralConfigManager { c.addComment("ActionBars.Messages.EnabledByDefault", "When this set to true player will see action bar messages by default"); ActionBarsMessageByDefault = c.get("ActionBars.Messages.EnabledByDefault", true); - c.addComment("BossBar.Enabled", "Enables BossBar feature", "Works only from 1.9 mc version"); - BossBarEnabled = c.get("BossBar.Enabled", true); + if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1)) { + c.addComment("BossBar.Enabled", "Enables BossBar feature", "Works only from 1.9 mc version"); + BossBarEnabled = c.get("BossBar.Enabled", true); - if (BossBarEnabled == true) { - if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1)) { - Jobs.consoleMsg("&c[Jobs] Your server version don't support BossBar. This feature will be disabled."); - c.set("BossBar.Enabled", false); - BossBarEnabled = false; - } + c.addComment("BossBar.Messages.EnabledByDefault", "When this set to true player will see Bossbar messages by default"); + BossBarsMessageByDefault = c.get("BossBar.Messages.EnabledByDefault", true); + + c.addComment("BossBar.ShowOnEachAction", "If enabled boss bar will update after each action", + "If disabled, BossBar will update only on each payment. This can save some server resources"); + BossBarShowOnEachAction = c.get("BossBar.ShowOnEachAction", false); + 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.Messages.EnabledByDefault", "When this set to true player will see Bossbar messages by default"); - BossBarsMessageByDefault = c.get("BossBar.Messages.EnabledByDefault", true); - - c.addComment("BossBar.ShowOnEachAction", "If enabled boss bar will update after each action", - "If disabled, BossBar will update only on each payment. This can save some server resources"); - BossBarShowOnEachAction = c.get("BossBar.ShowOnEachAction", false); - 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("ShowActionBars", "You can enable/disable message shown for players in action bar"); TitleChangeActionBar = c.get("ShowActionBars.OnTitleChange", true); LevelChangeActionBar = c.get("ShowActionBars.OnLevelChange", true); @@ -855,11 +855,11 @@ public class GeneralConfigManager { c.addComment("Sounds", "Sounds", "Extra sounds on some events", "All sounds can be found in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html"); SoundLevelupUse = c.get("Sounds.LevelUp.use", true); - SoundLevelupSound = c.get("Sounds.LevelUp.sound", "ENTITY_PLAYER_LEVELUP"); + SoundLevelupSound = c.get("Sounds.LevelUp.sound", Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1) ? "LEVEL_UP " : "ENTITY_PLAYER_LEVELUP"); SoundLevelupVolume = c.get("Sounds.LevelUp.volume", 1); SoundLevelupPitch = c.get("Sounds.LevelUp.pitch", 3); SoundTitleChangeUse = c.get("Sounds.TitleChange.use", true); - SoundTitleChangeSound = c.get("Sounds.TitleChange.sound", "ENTITY_PLAYER_LEVELUP"); + SoundTitleChangeSound = c.get("Sounds.TitleChange.sound", Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1) ? "LEVEL_UP " : "ENTITY_PLAYER_LEVELUP"); SoundTitleChangeVolume = c.get("Sounds.TitleChange.volume", 1); SoundTitleChangePitch = c.get("Sounds.TitleChange.pitch", 3); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f9abdda9..346ced07 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -241,19 +241,16 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; - // Fix bug when the player has not joined a job, milk a cow and get paid - for (com.gamingmesh.jobs.container.Job jobs : Jobs.getJobs()) { - if (jPlayer.isInJob(jobs) && Jobs.getGCManager().CowMilkingTimer > 0) { - if (cow.hasMetadata(CowMetadata)) { - long time = cow.getMetadata(CowMetadata).get(0).asLong(); - if (System.currentTimeMillis() < time + Jobs.getGCManager().CowMilkingTimer) { - long timer = ((Jobs.getGCManager().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000); - jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer)); + if (Jobs.getGCManager().CowMilkingTimer > 0) { + if (cow.hasMetadata(CowMetadata)) { + long time = cow.getMetadata(CowMetadata).get(0).asLong(); + if (System.currentTimeMillis() < time + Jobs.getGCManager().CowMilkingTimer) { + long timer = ((Jobs.getGCManager().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000); + jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer)); - if (Jobs.getGCManager().CancelCowMilking) - event.setCancelled(true); - return; - } + if (Jobs.getGCManager().CancelCowMilking) + event.setCancelled(true); + return; } } } @@ -1626,6 +1623,10 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().payExploringWhenFlying() && player.isFlying()) return; + + if (!Jobs.getGCManager().payExploringWhenGliding && player.isGliding()) + return; + ExploreRespond respond = Jobs.getExplore().ChunkRespond(player, event.getNewChunk()); if (!respond.isNewChunk())