From 044549d535274463141463c1107bbfad0f1329be Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sun, 9 Jun 2024 16:58:21 +0200 Subject: [PATCH] do this --- .../m724/realweather/RealWeatherPlugin.java | 2 +- .../m724/realweather/commands/GeoCommand.java | 13 ++++++-- src/main/resources/plugin.yml | 30 +++++++------------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java index 4f20809..370326f 100644 --- a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java +++ b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java @@ -109,7 +109,7 @@ public class RealWeatherPlugin extends JavaPlugin { } catch (ProviderException e) { logger.severe("Couldn't initialize provider!"); logger.severe("Possible causes:"); - logger.severe("1. Your API key is invalid"); + logger.severe("1. Your API key is invalid, or was added too recently"); logger.severe("2. The provider or your internet is down"); e.printStackTrace(); diff --git a/src/main/java/eu/m724/realweather/commands/GeoCommand.java b/src/main/java/eu/m724/realweather/commands/GeoCommand.java index 874befa..1ca8d5b 100644 --- a/src/main/java/eu/m724/realweather/commands/GeoCommand.java +++ b/src/main/java/eu/m724/realweather/commands/GeoCommand.java @@ -36,8 +36,15 @@ public class GeoCommand implements CommandExecutor { sender.sendMessage("Add arguments to use this command in console"); } } else if (args.length >= 2) { - double latitude = Double.parseDouble(args[0]); - double longitude = Double.parseDouble(args[1]); + double latitude, longitude; + + try { + latitude = Double.parseDouble(args[0]); + longitude = Double.parseDouble(args[1]); + } catch (NumberFormatException e) { + sender.sendMessage("Arguments should be latitude and longitude"); + return true; + } Coordinates coordinates = new Coordinates(latitude, longitude); Location location = GlobalConstants.getMapper().coordinatesToLocation(player.getWorld(), coordinates); @@ -51,7 +58,7 @@ public class GeoCommand implements CommandExecutor { player.spigot().sendMessage(component); if (args.length == 3) { - if (args[2].equalsIgnoreCase("tp") && player != null && player.hasPermission("realweather.geo.tp")) { + if (args[2].equalsIgnoreCase("tp") && player != null && player.hasPermission("realweather.command.geo.tp")) { Location targetLoc = location.getWorld().getHighestBlockAt(location).getLocation().add(0, 1, 0); player.teleport(targetLoc); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 712b441..3ce3052 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,41 +9,33 @@ load: STARTUP main: eu.m724.realweather.RealWeatherPlugin commands: - realweather: - description: AIO RealWeather command - aliases: rw - permission: realweather.command + rwadmin: + description: RealWeather admin command + permission: realweather.admin permission-message: You do not have permission to use this command. # usage is processed in code geo: description: Convert lat,lon to x,y,z and vice versa - permission: realweather.geo + permission: realweather.command.geo permission-message: You do not have permission to use this command. # usage is processed in code localtime: description: Get real time in current location - permission: realweather.localtime + permission: realweather.command.localtime permission-message: You do not have permission to use this command. permissions: # Commands - realweather.command: - description: Allows /realweather (individual nodes are still necessary for subcommands) - realweather.command.status: - description: /realweather status - realweather.command.*: - description: All /realweather commands - children: - realweather.command: true - realweather.command.status: true - - realweather.geo: + realweather.admin: + description: Allows admin management with /rwadmin + + realweather.command.geo: description: Allows /geo default: true - realweather.geo.tp: + realweather.comamnd.geo.tp: description: Allows teleportation using /geo - realweather.localtime: + realweather.command.localtime: description: Allows /localtime default: true