Refactor; use URI.toURL() instead, use plugin logger instead
This commit is contained in:
@@ -18,6 +18,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
@@ -41,7 +42,7 @@ public class Main extends JavaPlugin {
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -72,7 +73,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
// such cap
|
||||
//Bukkit.getConsoleSender().sendMessage("Note: This Spigot/Bukkit plugin is highly verbose, so it will log a lot of events...");
|
||||
//Main.mainSmall.getLogger().info("Note: This Spigot/Bukkit plugin is highly verbose, so it will log a lot of events...");
|
||||
// register commands
|
||||
try {
|
||||
Objects.requireNonNull(this.getCommand("info")).setExecutor(new InfoCommand());
|
||||
@@ -106,7 +107,7 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
URL url = new URL(getPublicMessageWebhook());
|
||||
URL url = new URI(getPublicMessageWebhook()).toURL();
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
int responseCode = connection.getResponseCode();
|
||||
@@ -117,8 +118,8 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mainSmall.getLogger().warning("Invalid webhook URL provide for your public messages. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
mainSmall.getLogger().severe(String.format("Exception: %s%n", e));
|
||||
mainSmall.getLogger().severe("Invalid webhook URL provide for your public messages. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
//mainSmall.getLogger().severe(String.format("Exception: %s%n", e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,7 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
URL url = new URL(getNotifyWebhook());
|
||||
URL url = new URI(getNotifyWebhook()).toURL();
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
int responseCode = connection.getResponseCode();
|
||||
@@ -141,7 +142,7 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mainSmall.getLogger().warning("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
mainSmall.getLogger().severe("Invalid webhook URL provided for the event logs. Please provide the correct webhook and check for any typos. (Caught exception)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -185,14 +186,14 @@ public class Main extends JavaPlugin {
|
||||
public void registerEvents() {
|
||||
PlayerChat playerChat = new PlayerChat();
|
||||
PlayerCommandPreprocess playerCommandPreprocess = new PlayerCommandPreprocess();
|
||||
PlayerBedEnter playerBedEnter = new PlayerBedEnter();
|
||||
PlayerBedLeave playerBedLeave = new PlayerBedLeave();
|
||||
//PlayerBedEnter playerBedEnter = new PlayerBedEnter();
|
||||
//PlayerBedLeave playerBedLeave = new PlayerBedLeave(); // Redundant event
|
||||
WorldLoad worldLoad = new WorldLoad();
|
||||
WorldUnload worldUnload = new WorldUnload();
|
||||
getServer().getPluginManager().registerEvents(playerChat, this);
|
||||
getServer().getPluginManager().registerEvents(playerCommandPreprocess, this);
|
||||
getServer().getPluginManager().registerEvents(playerBedEnter, this);
|
||||
getServer().getPluginManager().registerEvents(playerBedLeave, this);
|
||||
//getServer().getPluginManager().registerEvents(playerBedEnter, this);
|
||||
//getServer().getPluginManager().registerEvents(playerBedLeave, this);
|
||||
getServer().getPluginManager().registerEvents(worldLoad, this);
|
||||
getServer().getPluginManager().registerEvents(worldUnload, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user