From c9f15c8ad49bb2c253e9bacbf6d650e16047edd3 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 22 Dec 2018 14:26:45 +0100 Subject: [PATCH] Re-added payInCreative boolean If a group has jobs.paycreative permission then this booelean ignores. --- .../jobs/MythicMobs/MythicMobs2Listener.java | 2 +- .../jobs/MythicMobs/MythicMobs4Listener.java | 2 +- .../jobs/config/GeneralConfigManager.java | 13 +++++++ .../jobs/listeners/JobsPaymentListener.java | 34 +++++++++---------- .../jobs/listeners/McMMOlistener.java | 2 +- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs2Listener.java b/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs2Listener.java index ec56347f..3f27734f 100644 --- a/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs2Listener.java +++ b/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs2Listener.java @@ -51,7 +51,7 @@ public class MythicMobs2Listener implements Listener { if (pDamager == null) return; // check if in creative - if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative")) + if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) diff --git a/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java b/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java index ec658979..a3577d76 100644 --- a/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java +++ b/src/main/java/com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java @@ -52,7 +52,7 @@ public class MythicMobs4Listener implements Listener { if (pDamager == null) return; // check if in creative - if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative")) + if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index e6a3b8f6..103b207c 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 economyAsync; protected boolean isBroadcastingSkillups; protected boolean isBroadcastingLevelups; + protected boolean payInCreative; protected boolean payExploringWhenFlying; protected boolean addXpPlayer; protected boolean hideJobsWithoutPermission; @@ -222,6 +223,15 @@ public class GeneralConfigManager { return isBroadcastingLevelups; } + /** + * Function that tells if the player should be paid while in creative + * @return true - pay in creative + * @return false - do not pay in creative + */ + public synchronized boolean payInCreative() { + return payInCreative; + } + /** * Function that tells if the player should be paid while exploring and flying * @return true - pay @@ -529,6 +539,9 @@ public class GeneralConfigManager { "Use jobs.nearspawner.[amount] to define multiplayer. Example jobs.nearspawner.-0.5 will pay half of payment, jobs.nearspawner.-1 will not pay at all"); payNearSpawner = c.get("enable-pay-near-spawner", false); + c.getW().addComment("enable-pay-creative", "Option to allow payment to be made in creative mode. This ignoring when a group has 'jobs.paycreative' permission."); + payInCreative = c.get("enable-pay-creative", false); + c.getW().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); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 22570e30..5f22ac9e 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -170,7 +170,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -228,7 +228,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -288,7 +288,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -363,7 +363,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -433,7 +433,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -457,7 +457,7 @@ public class JobsPaymentListener implements Listener { Player player = event.getPlayer(); // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -495,7 +495,7 @@ public class JobsPaymentListener implements Listener { if (player == null || !player.isOnline()) return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -556,7 +556,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -779,7 +779,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -816,7 +816,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -1125,7 +1125,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1155,7 +1155,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1193,7 +1193,7 @@ public class JobsPaymentListener implements Listener { if (player == null || !player.isOnline()) return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1296,7 +1296,7 @@ public class JobsPaymentListener implements Listener { if (player != null && closest < 30.0) { // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1335,7 +1335,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1388,7 +1388,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) @@ -1544,7 +1544,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/McMMOlistener.java b/src/main/java/com/gamingmesh/jobs/listeners/McMMOlistener.java index f176d6e8..2df93625 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/McMMOlistener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/McMMOlistener.java @@ -51,7 +51,7 @@ public class McMMOlistener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative")) + if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative()) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);