From ce877a08654f035ea5b53cae663d7eb2ab688d99 Mon Sep 17 00:00:00 2001 From: alan67160 <20385640+alan67160@users.noreply.github.com> Date: Thu, 28 Sep 2023 01:48:00 +0800 Subject: [PATCH] Update PluginUtils.java allow PluginUtils.fromString() accept loc without yaw and pitch --- .../servertutorialplus/helpers/PluginUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/nl/martenm/servertutorialplus/helpers/PluginUtils.java b/src/main/java/nl/martenm/servertutorialplus/helpers/PluginUtils.java index abab423..38f6d4a 100644 --- a/src/main/java/nl/martenm/servertutorialplus/helpers/PluginUtils.java +++ b/src/main/java/nl/martenm/servertutorialplus/helpers/PluginUtils.java @@ -82,10 +82,12 @@ public static Location fromString(ServerTutorialPlus plugin, String message) { double x = Double.parseDouble(data[1]); double y = Double.parseDouble(data[2]); double z = Double.parseDouble(data[3]); - float yaw = Float.parseFloat(data[4]); - float pitch = Float.parseFloat(data[5]); - return new Location(plugin.getServer().getWorld(world), x, y, z, yaw, pitch); - + if (data.size() == 6) { + float yaw = Float.parseFloat(data[4]); + float pitch = Float.parseFloat(data[5]); + return new Location(plugin.getServer().getWorld(world), x, y, z, yaw, pitch); + } + return new Location(plugin.getServer().getWorld(world), x, y, z); } public static String fromLocation(Location loc) {