diff options
author | Flarp <flurpdadurp@gmail.com> | 2023-12-28 16:54:23 -0500 |
---|---|---|
committer | Flarp <flurpdadurp@gmail.com> | 2023-12-28 16:54:23 -0500 |
commit | ecfecaf19410e91437764cf42e9a61276ae6a09b (patch) | |
tree | e928a3d8b8d1f0e63907e69df6544dec6dbbcdfc /src/main/java/dev/deeve/containeraudit/Plugin.java | |
download | container-audit-ecfecaf19410e91437764cf42e9a61276ae6a09b.tar.gz |
First commit
Diffstat (limited to 'src/main/java/dev/deeve/containeraudit/Plugin.java')
-rw-r--r-- | src/main/java/dev/deeve/containeraudit/Plugin.java | 44 |
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; + } + + } +} |