From d4ebaf61d4549d64b15845a1b1cb4b058e7e7687 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Thu, 27 Jul 2023 19:38:32 -0400 Subject: [PATCH] Fix weather command --- .../essentials/commands/Commandweather.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandweather.java index 1dc9b4198..ab7de23b2 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandweather.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandweather.java @@ -31,16 +31,18 @@ public class Commandweather extends EssentialsCommand { isStorm = args[0].equalsIgnoreCase("storm"); } - final World world = user.getWorld(); + ess.scheduleEntityDelayedTask(user.getBase(), () -> { + final World world = user.getWorld(); - if (args.length > 1) { + if (args.length > 1) { + world.setStorm(isStorm); + world.setWeatherDuration(Integer.parseInt(args[1]) * 20); + user.sendMessage(isStorm ? tl("weatherStormFor", world.getName(), args[1]) : tl("weatherSunFor", world.getName(), args[1])); + return; + } world.setStorm(isStorm); - world.setWeatherDuration(Integer.parseInt(args[1]) * 20); - user.sendMessage(isStorm ? tl("weatherStormFor", world.getName(), args[1]) : tl("weatherSunFor", world.getName(), args[1])); - return; - } - world.setStorm(isStorm); - user.sendMessage(isStorm ? tl("weatherStorm", world.getName()) : tl("weatherSun", world.getName())); + user.sendMessage(isStorm ? tl("weatherStorm", world.getName()) : tl("weatherSun", world.getName())); + }); } @Override @@ -55,14 +57,16 @@ public class Commandweather extends EssentialsCommand { throw new Exception(tl("weatherInvalidWorld", args[0])); } - if (args.length > 2) { + ess.scheduleLocationDelayedTask(world.getSpawnLocation(), () -> { + if (args.length > 2) { + world.setStorm(isStorm); + world.setWeatherDuration(Integer.parseInt(args[2]) * 20); + sender.sendMessage(isStorm ? tl("weatherStormFor", world.getName(), args[2]) : tl("weatherSunFor", world.getName(), args[2])); + return; + } world.setStorm(isStorm); - world.setWeatherDuration(Integer.parseInt(args[2]) * 20); - sender.sendMessage(isStorm ? tl("weatherStormFor", world.getName(), args[2]) : tl("weatherSunFor", world.getName(), args[2])); - return; - } - world.setStorm(isStorm); - sender.sendMessage(isStorm ? tl("weatherStorm", world.getName()) : tl("weatherSun", world.getName())); + sender.sendMessage(isStorm ? tl("weatherStorm", world.getName()) : tl("weatherSun", world.getName())); + }); } @Override