summaryrefslogtreecommitdiff
path: root/src/main/java/dev/deeve/containeraudit/Plugin.java
blob: a92d6c0a0a6c6ba878e7e70d5d97462afc969585 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
    }

  }
}