Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 424603a

Browse files
committed
Moved log and error to Server.java
1 parent 6fdb1a7 commit 424603a

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/main/java/io/github/chafficui/CrucialAPI/Main.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.chafficui.CrucialAPI;
22

33
import io.github.chafficui.CrucialAPI.Utils.Plugin;
4+
import io.github.chafficui.CrucialAPI.Utils.Server;
45
import io.github.chafficui.CrucialAPI.exceptions.CrucialException;
56
import io.github.chafficui.CrucialAPI.Utils.Stats;
67
import org.bukkit.Bukkit;
@@ -13,14 +14,17 @@
1314
import java.net.URL;
1415
import java.nio.channels.Channels;
1516
import java.nio.channels.ReadableByteChannel;
16-
import java.util.logging.Logger;
1717

1818
public final class Main extends JavaPlugin {
1919
private final String version = getDescription().getVersion();
2020

2121
@Override
2222
public void onEnable() {
2323
// Plugin startup logic
24+
if(!Server.checkCompatibility("1.15", "1.16", "1.17")) {
25+
Server.error("Your server is not compatible with this plugin. Please update to 1.15 or 1.16 or 1.17.");
26+
}
27+
2428
new Stats(this, 9549);
2529
try {
2630
setupConfig();
@@ -31,30 +35,22 @@ public void onEnable() {
3135
ex.printStackTrace();
3236
}
3337
}
34-
log(ChatColor.DARK_GREEN + getDescription().getName() + " is now enabled (Version: " + version + ") made by "
38+
Server.log(ChatColor.DARK_GREEN + getDescription().getName() + " is now enabled (Version: " + version + ") made by "
3539
+ ChatColor.AQUA + getDescription().getAuthors() + ".");
3640
}
3741

3842
@Override
3943
public void onDisable() {
4044
// Plugin shutdown logic
4145
Bukkit.getScheduler().cancelTasks(this);
42-
log(ChatColor.DARK_GREEN + getDescription().getName() + " is now disabled.");
46+
Server.log(ChatColor.DARK_GREEN + getDescription().getName() + " is now disabled.");
4347
}
4448

4549
public
4650
File getFile(){
4751
return super.getFile();
4852
}
4953

50-
public void log(String message){
51-
Logger.getLogger("CrucialAPI").info(message);
52-
}
53-
54-
public void error(String message){
55-
Logger.getLogger("CrucialAPI").severe(message);
56-
}
57-
5854
public String getVersion() {
5955
return version;
6056
}

src/main/java/io/github/chafficui/CrucialAPI/Utils/Server.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package io.github.chafficui.CrucialAPI.Utils;
22

3-
import io.github.chafficui.CrucialAPI.Main;
43
import org.bukkit.Bukkit;
54

5+
import java.util.logging.Logger;
6+
67
public class Server {
7-
private static final Main plugin = Main.getPlugin(Main.class);
8+
private final static Logger logger = Logger.getLogger("CrucialAPI");
89

910
public static String getVersion(){
1011
return Bukkit.getVersion();
@@ -26,10 +27,10 @@ public static boolean checkCompatibility(String... validVersions){
2627
}
2728

2829
public static void log(String message){
29-
plugin.log(message);
30+
logger.info(message);
3031
}
3132

3233
public static void error(String message){
33-
plugin.error(message);
34+
logger.severe(message);
3435
}
3536
}

0 commit comments

Comments
 (0)