summaryrefslogtreecommitdiff
path: root/src/main/java/dev/deeve/containeraudit/Plugin.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/deeve/containeraudit/Plugin.java')
-rw-r--r--src/main/java/dev/deeve/containeraudit/Plugin.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/dev/deeve/containeraudit/Plugin.java b/src/main/java/dev/deeve/containeraudit/Plugin.java
new file mode 100644
index 0000000..a92d6c0
--- /dev/null
+++ b/src/main/java/dev/deeve/containeraudit/Plugin.java
@@ -0,0 +1,44 @@
+package dev.deeve.containeraudit;
+
+
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.logging.Logger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.sql.SQLException;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class Plugin extends JavaPlugin {
+ public static Logger logger;
+
+
+ public void onEnable() {
+ logger = getLogger();
+ getDataFolder().mkdirs();
+
+ try {
+ Database.connect(new File(getDataFolder(), "database.db").getPath(), logger);
+ List<String> ignores = new ArrayList();
+ Path okay = Paths.get(getDataFolder().getPath(), "okay.txt");
+
+ if (Files.exists(okay)) {
+ ignores = Files.readAllLines(okay);
+ }
+
+ getServer().getPluginManager().registerEvents(new ChestListener(ignores), this);
+ Database.createTables();
+ }
+ catch (SQLException | IOException ex) {
+ logger.log(Level.SEVERE, "Database error: (not enabling plugin)");
+ ex.printStackTrace();
+ return;
+ }
+
+ }
+}