1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

Code clean up

- Updated MythicMobs to the latest version
- Fix player double checking when interacts in world
This commit is contained in:
montlikadani 2018-12-17 20:50:14 +01:00
parent 0592c6da62
commit dfbf7963da
8 changed files with 87 additions and 97 deletions

Binary file not shown.

BIN
libs/MythicMobs-4.5.0.jar Normal file

Binary file not shown.

View File

@ -36,13 +36,12 @@ public class HookEconomyTask implements Runnable {
@Override @Override
public void run() { public void run() {
if (setVault()) if (setVault())
return; return;
// no Economy found // no Economy found
Jobs.setEconomy(this.plugin, new BlackholeEconomy()); Jobs.setEconomy(plugin, new BlackholeEconomy());
Bukkit.getServer().getLogger().severe("==================== " + this.plugin.getDescription().getName() + " ===================="); Bukkit.getServer().getLogger().severe("==================== " + plugin.getDescription().getName() + " ====================");
Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!"); Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
Bukkit.getServer().getLogger().severe("Please install them first!"); Bukkit.getServer().getLogger().severe("Please install them first!");
Bukkit.getServer().getLogger().severe("You can find the latest versions here:"); Bukkit.getServer().getLogger().severe("You can find the latest versions here:");
@ -63,8 +62,8 @@ public class HookEconomyTask implements Runnable {
if (economy == null) if (economy == null)
return false; return false;
Jobs.setEconomy(this.plugin, new VaultEconomy(economy)); Jobs.setEconomy(plugin, new VaultEconomy(economy));
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] Successfully linked with Vault."); Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
return true; return true;
} }

View File

@ -735,7 +735,7 @@ public class Jobs extends JavaPlugin {
public void onEnable() { public void onEnable() {
instance = this; instance = this;
this.setEnabled(true); setEnabled(true);
versionCheckManager = new VersionChecker(this); versionCheckManager = new VersionChecker(this);
@ -752,12 +752,12 @@ public class Jobs extends JavaPlugin {
setNms((NMS) nmsClass.getConstructor().newInstance()); setNms((NMS) nmsClass.getConstructor().newInstance());
} else { } else {
System.out.println("Something went wrong, please note down version and contact author, version: " + version); System.out.println("Something went wrong, please note down version and contact author, version: " + version);
this.setEnabled(false); setEnabled(false);
} }
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) { | SecurityException e) {
System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version); System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version);
this.setEnabled(false); setEnabled(false);
e.printStackTrace(); e.printStackTrace();
return; return;
} }
@ -835,7 +835,7 @@ public class Jobs extends JavaPlugin {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");
this.setEnabled(false); setEnabled(false);
} }
} }

View File

@ -44,7 +44,6 @@ public class PermissionHandler {
} }
public void recalculatePermissions(JobsPlayer jPlayer) { public void recalculatePermissions(JobsPlayer jPlayer) {
if (jPlayer == null) if (jPlayer == null)
return; return;
@ -56,9 +55,9 @@ public class PermissionHandler {
// remove old permissions // remove old permissions
String permName = "jobs.players." + player.getName(); String permName = "jobs.players." + player.getName();
Permission permission = this.plugin.getServer().getPluginManager().getPermission(permName); Permission permission = plugin.getServer().getPluginManager().getPermission(permName);
if (permission != null) { if (permission != null) {
this.plugin.getServer().getPluginManager().removePermission(permission); plugin.getServer().getPluginManager().removePermission(permission);
changed = true; changed = true;
} }
@ -73,16 +72,15 @@ public class PermissionHandler {
if (job != null) { if (job != null) {
for (JobPermission perm : job.getPermissions()) { for (JobPermission perm : job.getPermissions()) {
if (perm.getLevelRequirement() <= 0) { if (perm.getLevelRequirement() <= 0) {
if (perm.isValue()) { if (perm.isValue())
permissions.put(perm.getNode(), true); permissions.put(perm.getNode(), true);
} else { else {
/* /*
* If the key exists, don't put a false node in * If the key exists, don't put a false node in
* This is in case we already have a true node there * This is in case we already have a true node there
*/ */
if (!permissions.containsKey(perm.getNode())) { if (!permissions.containsKey(perm.getNode()))
permissions.put(perm.getNode(), false); permissions.put(perm.getNode(), false);
}
} }
} }
} }
@ -117,16 +115,15 @@ public class PermissionHandler {
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) { for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
String perm = one.getKey(); String perm = one.getKey();
boolean node = one.getValue(); boolean node = one.getValue();
if (node) { if (node)
permissions.put(perm, true); permissions.put(perm, true);
} else { else {
/* /*
* If the key exists, don't put a false node in * If the key exists, don't put a false node in
* This is in case we already have a true node there * This is in case we already have a true node there
*/ */
if (!permissions.containsKey(perm)) { if (!permissions.containsKey(perm))
permissions.put(perm, false); permissions.put(perm, false);
}
} }
} }
@ -141,12 +138,11 @@ public class PermissionHandler {
* If the key exists, don't put a false node in * If the key exists, don't put a false node in
* This is in case we already have a true node there * This is in case we already have a true node there
*/ */
if (perm.isValue()) { if (perm.isValue())
permissions.put(perm.getNode(), true); permissions.put(perm.getNode(), true);
} else { else {
if (!permissions.containsKey(perm.getNode())) { if (!permissions.containsKey(perm.getNode()))
permissions.put(perm.getNode(), false); permissions.put(perm.getNode(), false);
}
} }
} }
} }
@ -180,16 +176,15 @@ public class PermissionHandler {
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) { for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
String perm = one.getKey(); String perm = one.getKey();
boolean node = one.getValue(); boolean node = one.getValue();
if (node) { if (node)
permissions.put(perm, true); permissions.put(perm, true);
} else { else {
/* /*
* If the key exists, don't put a false node in * If the key exists, don't put a false node in
* This is in case we already have a true node there * This is in case we already have a true node there
*/ */
if (!permissions.containsKey(perm)) { if (!permissions.containsKey(perm))
permissions.put(perm, false); permissions.put(perm, false);
}
} }
} }
} }
@ -198,7 +193,7 @@ public class PermissionHandler {
// add new permissions (if applicable) // add new permissions (if applicable)
if (permissions.size() > 0) { if (permissions.size() > 0) {
this.plugin.getServer().getPluginManager().addPermission(new Permission(permName, PermissionDefault.FALSE, permissions)); plugin.getServer().getPluginManager().addPermission(new Permission(permName, PermissionDefault.FALSE, permissions));
changed = true; changed = true;
} }
} }
@ -210,14 +205,13 @@ public class PermissionHandler {
// find old attachment // find old attachment
PermissionAttachment attachment = null; PermissionAttachment attachment = null;
for (PermissionAttachmentInfo pai : player.getEffectivePermissions()) { for (PermissionAttachmentInfo pai : player.getEffectivePermissions()) {
if (pai.getAttachment() != null && pai.getAttachment().getPlugin() instanceof Jobs) { if (pai.getAttachment() != null && pai.getAttachment().getPlugin() instanceof Jobs)
attachment = pai.getAttachment(); attachment = pai.getAttachment();
}
} }
// create if attachment doesn't exist // create if attachment doesn't exist
if (attachment == null) { if (attachment == null) {
attachment = player.addAttachment(this.plugin); attachment = player.addAttachment(plugin);
attachment.setPermission(permName, true); attachment.setPermission(permName, true);
} }
@ -226,8 +220,8 @@ public class PermissionHandler {
} }
public void registerPermissions() { public void registerPermissions() {
PluginManager pm = this.plugin.getServer().getPluginManager(); PluginManager pm = plugin.getServer().getPluginManager();
for (World world : this.plugin.getServer().getWorlds()) { for (World world : plugin.getServer().getWorlds()) {
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null) if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE)); pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
} }
@ -245,22 +239,23 @@ public class PermissionHandler {
} }
public boolean hasWorldPermission(Player player, String world) { public boolean hasWorldPermission(Player player, String world) {
if (!player.hasPermission("jobs.use")) { if (!player.hasPermission("jobs.use"))
return false; return false;
}
return player.hasPermission("jobs.world." + world.toLowerCase()); return player.hasPermission("jobs.world." + world.toLowerCase());
} }
public boolean hasWorldPermission(JobsPlayer player) { public boolean hasWorldPermission(JobsPlayer player) {
if (player.getPlayer() == null) if (player.getPlayer() == null)
return false; return false;
return hasWorldPermission(player, player.getPlayer().getWorld().getName()); return hasWorldPermission(player, player.getPlayer().getWorld().getName());
} }
public boolean hasWorldPermission(JobsPlayer player, String world) { public boolean hasWorldPermission(JobsPlayer player, String world) {
if (!Jobs.getPermissionManager().hasPermission(player, "jobs.use")) { if (!Jobs.getPermissionManager().hasPermission(player, "jobs.use"))
return false; return false;
}
return Jobs.getPermissionManager().hasPermission(player, "jobs.world." + world.toLowerCase()); return Jobs.getPermissionManager().hasPermission(player, "jobs.world." + world.toLowerCase());
} }

View File

@ -99,31 +99,31 @@ public class PlayerManager {
} }
public void addPlayerToMap(PlayerInfo info) { public void addPlayerToMap(PlayerInfo info) {
this.PlayerUUIDMap.put(info.getUuid(), info); PlayerUUIDMap.put(info.getUuid(), info);
this.PlayerIDMap.put(info.getID(), info); PlayerIDMap.put(info.getID(), info);
if (info.getName() != null) if (info.getName() != null)
this.PlayerNameMap.put(info.getName().toLowerCase(), info); PlayerNameMap.put(info.getName().toLowerCase(), info);
} }
public void addPlayerToCache(JobsPlayer jPlayer) { public void addPlayerToCache(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null) if (jPlayer.getUserName() != null)
this.playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer); playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getPlayerUUID() != null) if (jPlayer.getPlayerUUID() != null)
this.playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer); playersUUIDCache.put(jPlayer.getPlayerUUID(), jPlayer);
} }
public void addPlayer(JobsPlayer jPlayer) { public void addPlayer(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null) if (jPlayer.getUserName() != null)
this.players.put(jPlayer.getUserName().toLowerCase(), jPlayer); players.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getPlayerUUID() != null) if (jPlayer.getPlayerUUID() != null)
this.playersUUID.put(jPlayer.getPlayerUUID(), jPlayer); playersUUID.put(jPlayer.getPlayerUUID(), jPlayer);
} }
public JobsPlayer removePlayer(Player player) { public JobsPlayer removePlayer(Player player) {
if (player == null) if (player == null)
return null; return null;
this.players.remove(player.getName().toLowerCase()); players.remove(player.getName().toLowerCase());
JobsPlayer jPlayer = this.playersUUID.remove(player.getUniqueId()); JobsPlayer jPlayer = playersUUID.remove(player.getUniqueId());
return jPlayer; return jPlayer;
} }
@ -167,14 +167,14 @@ public class PlayerManager {
*/ */
public void playerJoin(Player player) { public void playerJoin(Player player) {
JobsPlayer jPlayer = this.playersUUIDCache.get(player.getUniqueId()); JobsPlayer jPlayer = playersUUIDCache.get(player.getUniqueId());
if (jPlayer == null || Jobs.getGCManager().MultiServerCompatability()) { if (jPlayer == null || Jobs.getGCManager().MultiServerCompatability()) {
jPlayer = Jobs.getJobsDAO().loadFromDao(player); jPlayer = Jobs.getJobsDAO().loadFromDao(player);
jPlayer.loadLogFromDao(); jPlayer.loadLogFromDao();
} }
this.addPlayer(jPlayer); addPlayer(jPlayer);
AutoJoinJobs(player); AutoJoinJobs(player);
jPlayer.onConnect(); jPlayer.onConnect();
jPlayer.reloadHonorific(); jPlayer.reloadHonorific();
@ -188,7 +188,7 @@ public class PlayerManager {
* @param playername * @param playername
*/ */
public void playerQuit(Player player) { public void playerQuit(Player player) {
JobsPlayer jPlayer = this.getJobsPlayer(player); JobsPlayer jPlayer = getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return; return;
if (Jobs.getGCManager().saveOnDisconnect()) { if (Jobs.getGCManager().saveOnDisconnect()) {
@ -209,12 +209,12 @@ public class PlayerManager {
* 2) Perform save on all players on copied list. * 2) Perform save on all players on copied list.
* 3) Garbage collect the real list to remove any offline players with saved data * 3) Garbage collect the real list to remove any offline players with saved data
*/ */
ArrayList<JobsPlayer> list = new ArrayList<>(this.players.values()); ArrayList<JobsPlayer> list = new ArrayList<>(players.values());
for (JobsPlayer jPlayer : list) for (JobsPlayer jPlayer : list)
jPlayer.save(); jPlayer.save();
Iterator<JobsPlayer> iter = this.players.values().iterator(); Iterator<JobsPlayer> iter = players.values().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
JobsPlayer jPlayer = iter.next(); JobsPlayer jPlayer = iter.next();
if (!jPlayer.isOnline() && jPlayer.isSaved()) if (!jPlayer.isOnline() && jPlayer.isSaved())
@ -261,10 +261,10 @@ public class PlayerManager {
} }
public JobsPlayer getJobsPlayer(UUID uuid) { public JobsPlayer getJobsPlayer(UUID uuid) {
JobsPlayer jPlayer = this.playersUUID.get(uuid); JobsPlayer jPlayer = playersUUID.get(uuid);
if (jPlayer != null) if (jPlayer != null)
return jPlayer; return jPlayer;
return this.playersUUIDCache.get(uuid); return playersUUIDCache.get(uuid);
} }
/** /**
@ -273,10 +273,10 @@ public class PlayerManager {
* @return the player job info of the player * @return the player job info of the player
*/ */
public JobsPlayer getJobsPlayer(String playerName) { public JobsPlayer getJobsPlayer(String playerName) {
JobsPlayer jPlayer = this.players.get(playerName.toLowerCase()); JobsPlayer jPlayer = players.get(playerName.toLowerCase());
if (jPlayer != null) if (jPlayer != null)
return jPlayer; return jPlayer;
return this.playersCache.get(playerName.toLowerCase()); return playersCache.get(playerName.toLowerCase());
} }
/** /**
@ -376,10 +376,9 @@ public class PlayerManager {
if (!jPlayer.isInJob(job)) if (!jPlayer.isInJob(job))
return false; return false;
// JobsJoin event
JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job); JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job);
Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent); Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent);
// If event is canceled, dont do anything // If event is canceled, don't do anything
if (jobsleaveevent.isCancelled()) if (jobsleaveevent.isCancelled())
return false; return false;
@ -704,7 +703,7 @@ public class PlayerManager {
* Perform reload * Perform reload
*/ */
public void reload() { public void reload() {
for (JobsPlayer jPlayer : this.players.values()) { for (JobsPlayer jPlayer : players.values()) {
for (JobProgression progression : jPlayer.getJobProgression()) { for (JobProgression progression : jPlayer.getJobProgression()) {
String jobName = progression.getJob().getName(); String jobName = progression.getJob().getName();
Job job = Jobs.getJob(jobName); Job job = Jobs.getJob(jobName);
@ -793,7 +792,7 @@ public class PlayerManager {
continue; continue;
for (String onelore : oneItem.getLore()) { for (String onelore : oneItem.getLore()) {
if (lore.size() == 0 || !lore.contains(onelore)) if (lore.size() < 0 || !lore.contains(onelore))
continue main; continue main;
} }
@ -930,7 +929,7 @@ public class PlayerManager {
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount)); boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
} }
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata())) { if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) {
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner"); Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner");
if (amount != null) if (amount != null)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));

View File

@ -139,8 +139,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSelection(PlayerInteractEvent event) { public void onSelection(PlayerInteractEvent event) {
if (event.getPlayer() == null)
return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
return; return;
@ -210,9 +208,8 @@ public class JobsListener implements Listener {
public void onShopGuiClose(InventoryCloseEvent event) { public void onShopGuiClose(InventoryCloseEvent event) {
if (Jobs.getShopManager().GuiList.isEmpty()) if (Jobs.getShopManager().GuiList.isEmpty())
return; return;
if (Jobs.getShopManager().GuiList.containsKey(event.getPlayer().getName())) { if (Jobs.getShopManager().GuiList.containsKey(event.getPlayer().getName()))
Jobs.getShopManager().GuiList.remove(event.getPlayer().getName()); Jobs.getShopManager().GuiList.remove(event.getPlayer().getName());
}
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
@ -284,9 +281,9 @@ public class JobsListener implements Listener {
// make sure plugin is enabled // make sure plugin is enabled
if (!plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
if (!Jobs.getGCManager().MultiServerCompatability()) { if (!Jobs.getGCManager().MultiServerCompatability())
Jobs.getPlayerManager().playerJoin(event.getPlayer()); Jobs.getPlayerManager().playerJoin(event.getPlayer());
} else { else {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -118,7 +118,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void villagerTradeInventoryClick(InventoryClickEvent event) { public void villagerTradeInventoryClick(InventoryClickEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
@ -204,7 +204,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCowMilking(PlayerInteractEntityEvent event) { public void onCowMilking(PlayerInteractEntityEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -260,13 +260,13 @@ public class JobsPaymentListener implements Listener {
Long Timer = System.currentTimeMillis(); Long Timer = System.currentTimeMillis();
cow.setMetadata(CowMetadata, new FixedMetadataValue(this.plugin, Timer)); cow.setMetadata(CowMetadata, new FixedMetadataValue(plugin, Timer));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShear(PlayerShearEntityEvent event) { public void onEntityShear(PlayerShearEntityEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -278,7 +278,7 @@ public class JobsPaymentListener implements Listener {
// mob spawner, no payment or experience // mob spawner, no payment or experience
if (sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) { if (sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
sheep.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), this.plugin); sheep.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
return; return;
} }
@ -304,7 +304,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBrewEvent(BrewEvent event) { public void onBrewEvent(BrewEvent event) {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
@ -348,7 +348,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
@ -412,7 +412,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
Block block = event.getBlock(); Block block = event.getBlock();
@ -448,7 +448,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) { public void onPlayerFish(PlayerFishEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -475,7 +475,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAnimalTame(EntityTameEvent event) { public void onAnimalTame(EntityTameEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -486,7 +486,7 @@ public class JobsPaymentListener implements Listener {
// mob spawner, no payment or experience // mob spawner, no payment or experience
if (animal.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) { if (animal.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
animal.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), this.plugin); animal.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
return; return;
} }
@ -513,7 +513,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryCraft(CraftItemEvent event) { public void onInventoryCraft(CraftItemEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
@ -665,7 +665,7 @@ public class JobsPaymentListener implements Listener {
for (int i = 0; i < preInv.length; i++) { for (int i = 0; i < preInv.length; i++) {
preInv[i] = preInv[i] != null ? preInv[i].clone() : null; preInv[i] = preInv[i] != null ? preInv[i].clone() : null;
} }
return Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
final ItemStack[] postInv = player.getInventory().getContents(); final ItemStack[] postInv = player.getInventory().getContents();
@ -715,7 +715,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryRepair(InventoryClickEvent event) { public void onInventoryRepair(InventoryClickEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
@ -791,7 +791,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEnchantItem(EnchantItemEvent event) { public void onEnchantItem(EnchantItemEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEnchanter() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEnchanter().getWorld())) if (event.getEnchanter() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEnchanter().getWorld()))
@ -847,7 +847,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) {
try { try {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
if (event.getDestination().getType() != InventoryType.FURNACE) if (event.getDestination().getType() != InventoryType.FURNACE)
return; return;
@ -871,7 +871,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToBrewingStand(InventoryMoveItemEvent event) { public void onInventoryMoveItemEventToBrewingStand(InventoryMoveItemEvent event) {
try { try {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
if (event.getDestination().getType() != InventoryType.BREWING) if (event.getDestination().getType() != InventoryType.BREWING)
return; return;
@ -894,7 +894,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) { public void onFurnaceSmelt(FurnaceSmeltEvent event) {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
@ -961,7 +961,7 @@ public class JobsPaymentListener implements Listener {
damage = s; damage = s;
if (ent.hasMetadata(entityDamageByPlayer)) if (ent.hasMetadata(entityDamageByPlayer))
damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble(); damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble();
ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(this.plugin, damage)); ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(plugin, damage));
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@ -987,7 +987,7 @@ public class JobsPaymentListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
if (ent.hasMetadata(entityDamageByPlayer)) if (ent.hasMetadata(entityDamageByPlayer))
damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble(); damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble();
ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(this.plugin, damage)); ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(plugin, damage));
} }
} }
@ -995,7 +995,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -1106,14 +1106,14 @@ public class JobsPaymentListener implements Listener {
return; return;
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) || event.getSpawnReason().equals(SpawnReason.SPAWNER_EGG)) { if (event.getSpawnReason().equals(SpawnReason.SPAWNER) || event.getSpawnReason().equals(SpawnReason.SPAWNER_EGG)) {
LivingEntity creature = event.getEntity(); LivingEntity creature = event.getEntity();
creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(this.plugin, true)); creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(plugin, true));
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingPlaceEvent(HangingPlaceEvent event) { public void onHangingPlaceEvent(HangingPlaceEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -1140,7 +1140,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingBreakEvent(HangingBreakByEntityEvent event) { public void onHangingBreakEvent(HangingBreakByEntityEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -1266,7 +1266,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureBreed(CreatureSpawnEvent event) { public void onCreatureBreed(CreatureSpawnEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -1314,7 +1314,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerEat(FoodLevelChangeEvent event) { public void onPlayerEat(FoodLevelChangeEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
@ -1354,7 +1354,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTntExplode(EntityExplodeEvent event) { public void onTntExplode(EntityExplodeEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity())) if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity()))
@ -1419,7 +1419,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -1487,7 +1487,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemConsume(PlayerItemConsumeEvent event) { public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -1520,7 +1520,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler @EventHandler
public void onExplore(JobsChunkChangeEvent event) { public void onExplore(JobsChunkChangeEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!this.plugin.isEnabled()) if (!plugin.isEnabled())
return; return;
//disabling plugin in world //disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))