From add9bbf34f0d1c70e7ea93c47e546286bd84a8a0 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Mon, 29 Mar 2021 15:28:15 +0200 Subject: [PATCH] More work --- src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java | 8 ++++---- .../com/gamingmesh/jobs/commands/list/signupdate.java | 7 +++---- .../java/com/gamingmesh/jobs/container/JobsPlayer.java | 9 +++------ .../com/gamingmesh/jobs/listeners/JobsListener.java | 10 ++++------ 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index e3ccbc2f..186b5b58 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -162,15 +162,15 @@ public class SignUtil { public void updateAllSign(Job job) { for (SignTopType types : SignTopType.values()) { if (types != SignTopType.questtoplist) - SignUpdate(job, types); + signUpdate(job, types); } } - public boolean SignUpdate(Job job) { - return SignUpdate(job, SignTopType.toplist); + public boolean signUpdate(Job job) { + return signUpdate(job, SignTopType.toplist); } - public boolean SignUpdate(Job job, SignTopType type) { + public boolean signUpdate(Job job, SignTopType type) { if (!Jobs.getGCManager().SignsEnabled) return true; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/signupdate.java b/src/main/java/com/gamingmesh/jobs/commands/list/signupdate.java index ade00cea..cc345a24 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/signupdate.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/signupdate.java @@ -20,7 +20,7 @@ public class signupdate implements Cmd { } if (args[0].equalsIgnoreCase("all")) { - Jobs.getJobs().forEach(Jobs.getSignUtil()::SignUpdate); + Jobs.getJobs().forEach(Jobs.getSignUtil()::signUpdate); return true; } @@ -33,14 +33,13 @@ public class signupdate implements Cmd { if (args.length == 2) { SignTopType type = SignTopType.getType(args[1]); if (type != null) { - Jobs.getSignUtil().SignUpdate(oldjob, type); + Jobs.getSignUtil().signUpdate(oldjob, type); } return true; } - Jobs.getSignUtil().SignUpdate(oldjob); - + Jobs.getSignUtil().signUpdate(oldjob); return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 0275e2b5..f9f9c499 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -1257,12 +1257,9 @@ public class JobsPlayer { this.setSaved(false); if (questSignUpdateShed == null) { - questSignUpdateShed = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - Jobs.getSignUtil().SignUpdate(job, SignTopType.questtoplist); - questSignUpdateShed = null; - } + questSignUpdateShed = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + Jobs.getSignUtil().signUpdate(job, SignTopType.questtoplist); + questSignUpdateShed = null; }, Jobs.getGCManager().getSavePeriod() * 60 * 20L); } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 1006c296..a0b500c4 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -303,7 +303,7 @@ public class JobsListener implements Listener { event.setCancelled(true); - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> signUtil.SignUpdate(job, type), 1L); + plugin.getServer().getScheduler().runTaskLater(plugin, () -> signUtil.signUpdate(job, type), 1L); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @@ -358,7 +358,7 @@ public class JobsListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onCropGrown(final BlockGrowEvent event) { if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) { - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> Jobs.getBpManager().remove(event.getBlock()), 1L); + plugin.getServer().getScheduler().runTaskLater(plugin, () -> Jobs.getBpManager().remove(event.getBlock()), 1L); } } @@ -448,10 +448,8 @@ public class JobsListener implements Listener { Chunk from = event.getFrom().getChunk(); Chunk to = event.getTo().getChunk(); - if (from == to) - return; - - plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to)); + if (from != to) + plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to)); } @EventHandler