Advertisement
Guest User

CoreProtect 2.14.4 Config.java

a guest
Jan 3rd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 53.54 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package net.coreprotect.model;
  7.  
  8. import java.io.File;
  9. import java.io.RandomAccessFile;
  10. import java.sql.Connection;
  11. import java.sql.ResultSet;
  12. import java.sql.Statement;
  13. import java.util.ArrayList;
  14. import java.util.Collections;
  15. import java.util.HashMap;
  16. import java.util.Iterator;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.UUID;
  20. import java.util.concurrent.ConcurrentHashMap;
  21. import net.coreprotect.CoreProtect;
  22. import net.coreprotect.Functions;
  23. import net.coreprotect.consumer.Queue;
  24. import net.coreprotect.database.Database;
  25. import net.coreprotect.patch.Patch;
  26. import org.bukkit.World;
  27. import org.bukkit.entity.Player;
  28. import org.bukkit.inventory.ItemStack;
  29.  
  30. public class Config extends Queue {
  31.     public static String driver = "com.mysql.jdbc.Driver";
  32.     public static String sqlite = "plugins/CoreProtect/database.db";
  33.     public static String host = "127.0.0.1";
  34.     public static int port = 3306;
  35.     public static String database = "database";
  36.     public static String username = "root";
  37.     public static String password = "";
  38.     public static String prefix = "co_";
  39.     public static boolean server_running = false;
  40.     public static boolean converter_running = false;
  41.     public static boolean purge_running = false;
  42.     public static int world_id = 0;
  43.     public static int material_id = 0;
  44.     public static int entity_id = 0;
  45.     public static int art_id = 0;
  46.     public static Map<String, Integer> worlds = Collections.synchronizedMap(new HashMap());
  47.     public static Map<Integer, String> worlds_reversed = Collections.synchronizedMap(new HashMap());
  48.     public static Map<String, Integer> materials = Collections.synchronizedMap(new HashMap());
  49.     public static Map<Integer, String> materials_reversed = Collections.synchronizedMap(new HashMap());
  50.     public static Map<String, Integer> entities = Collections.synchronizedMap(new HashMap());
  51.     public static Map<Integer, String> entities_reversed = Collections.synchronizedMap(new HashMap());
  52.     public static Map<String, Integer> art = Collections.synchronizedMap(new HashMap());
  53.     public static Map<Integer, String> art_reversed = Collections.synchronizedMap(new HashMap());
  54.     public static Map<String, Integer> config = Collections.synchronizedMap(new HashMap());
  55.     public static Map<String, int[]> rollback_hash = Collections.synchronizedMap(new HashMap());
  56.     public static Map<String, Boolean> inspecting = Collections.synchronizedMap(new HashMap());
  57.     public static Map<String, Object[]> lookup_cache = Collections.synchronizedMap(new HashMap());
  58.     public static Map<String, Object[]> break_cache = Collections.synchronizedMap(new HashMap());
  59.     public static Map<String, Object[]> piston_cache = Collections.synchronizedMap(new HashMap());
  60.     public static Map<String, Object[]> entity_cache = Collections.synchronizedMap(new HashMap());
  61.     public static Map<String, Boolean> blacklist = Collections.synchronizedMap(new HashMap());
  62.     public static Map<String, Integer> logging_chest = Collections.synchronizedMap(new HashMap());
  63.     public static Map<String, List<ItemStack[]>> old_container = Collections.synchronizedMap(new HashMap());
  64.     public static Map<String, List<ItemStack[]>> force_containers = Collections.synchronizedMap(new HashMap());
  65.     public static Map<String, Integer> lookup_type = Collections.synchronizedMap(new HashMap());
  66.     public static Map<String, Integer> lookup_page = Collections.synchronizedMap(new HashMap());
  67.     public static Map<String, String> lookup_command = Collections.synchronizedMap(new HashMap());
  68.     public static Map<String, List<Object>> lookup_blist = Collections.synchronizedMap(new HashMap());
  69.     public static Map<String, List<Object>> lookup_elist = Collections.synchronizedMap(new HashMap());
  70.     public static Map<String, List<String>> lookup_e_userlist = Collections.synchronizedMap(new HashMap());
  71.     public static Map<String, List<String>> lookup_ulist = Collections.synchronizedMap(new HashMap());
  72.     public static Map<String, List<Integer>> lookup_alist = Collections.synchronizedMap(new HashMap());
  73.     public static Map<String, Integer[]> lookup_radius = Collections.synchronizedMap(new HashMap());
  74.     public static Map<String, String> lookup_time = Collections.synchronizedMap(new HashMap());
  75.     public static Map<String, Integer> lookup_rows = Collections.synchronizedMap(new HashMap());
  76.     public static Map<String, String> uuid_cache = Collections.synchronizedMap(new HashMap());
  77.     public static Map<String, String> uuid_cache_reversed = Collections.synchronizedMap(new HashMap());
  78.     public static Map<String, Integer> player_id_cache = Collections.synchronizedMap(new HashMap());
  79.     public static Map<Integer, String> player_id_cache_reversed = Collections.synchronizedMap(new HashMap());
  80.     public static Map<String, List<Object[]>> last_rollback = Collections.synchronizedMap(new HashMap());
  81.     public static Map<String, Boolean> active_rollbacks = Collections.synchronizedMap(new HashMap());
  82.     public static Map<UUID, Object[]> entity_block_mapper = Collections.synchronizedMap(new HashMap());
  83.     public static ConcurrentHashMap<String, String> language = new ConcurrentHashMap();
  84.     public static List<String> databaseTables = new ArrayList();
  85.  
  86.     public Config() {
  87.     }
  88.  
  89.     private static void checkPlayers(Connection connection) {
  90.         player_id_cache.clear();
  91.         Iterator var1 = CoreProtect.getInstance().getServer().getOnlinePlayers().iterator();
  92.  
  93.         while(var1.hasNext()) {
  94.             Player player = (Player)var1.next();
  95.             if (player_id_cache.get(player.getName().toLowerCase()) == null) {
  96.                 Database.loadUserID(connection, player.getName(), player.getUniqueId().toString());
  97.             }
  98.         }
  99.  
  100.     }
  101.  
  102.     private static void loadBlacklist() {
  103.         try {
  104.             blacklist.clear();
  105.             String blacklist = "plugins/CoreProtect/blacklist.txt";
  106.             boolean exists = (new File(blacklist)).exists();
  107.             if (exists) {
  108.                 RandomAccessFile blfile = new RandomAccessFile(blacklist, "rw");
  109.                 long blc = blfile.length();
  110.                 if (blc > 0L) {
  111.                     while(blfile.getFilePointer() < blfile.length()) {
  112.                         String blacklist_user = blfile.readLine().replaceAll(" ", "").toLowerCase();
  113.                         if (blacklist_user.length() > 0) {
  114.                             blacklist.put(blacklist_user, true);
  115.                         }
  116.                     }
  117.                 }
  118.  
  119.                 blfile.close();
  120.             }
  121.         } catch (Exception var6) {
  122.             var6.printStackTrace();
  123.         }
  124.  
  125.     }
  126.  
  127.     private static void loadConfig() {
  128.         try {
  129.             String confighead = "#CoreProtect Config\n";
  130.             String noisy = "\n# If enabled, extra data is displayed when doing rollbacks and restores.\n# If disabled, you can manually trigger it in-game by adding \"#verbose\"\n# to the end of your rollback statement.\nverbose: true\n";
  131.             String mysql = "\n# MySQL is optional and not required.\n# If you prefer to use MySQL, enable the following and fill out the fields.\nuse-mysql: false\ntable-prefix: co_\nmysql-host: 127.0.0.1\nmysql-port: 3306\nmysql-database: database\nmysql-username: root\nmysql-password: \n";
  132.             String update = "\n# If enabled, CoreProtect will check for updates when your server starts up.\n# If an update is available, you'll be notified via your server console.\ncheck-updates: true\n";
  133.             String api = "\n# If enabled, other plugins will be able to utilize the CoreProtect API.\napi-enabled: true\n";
  134.             String defaultradius = "\n# If no radius is specified in a rollback or restore, this value will be\n# used as the radius. Set to \"0\" to disable automatically adding a radius.\ndefault-radius: 10\n";
  135.             String maxradius = "\n# The maximum radius that can be used in a command. Set to \"0\" to disable.\n# To run a rollback or restore without a radius, you can use \"r:#global\".\nmax-radius: 100\n";
  136.             String rollbackitems = "\n# If enabled, items taken from containers (etc) will be included in rollbacks.\nrollback-items: true\n";
  137.             String rollbackentities = "\n# If enabled, entities, such as killed animals, will be included in rollbacks.\nrollback-entities: true\n";
  138.             String skipgenericdata = "\n# If enabled, generic data, like zombies burning in daylight, won't be logged.\nskip-generic-data: true\n";
  139.             String blockplace = "\n# Logs blocks placed by players.\nblock-place: true\n";
  140.             String blockbreak = "\n# Logs blocks broken by players.\nblock-break: true\n";
  141.             String naturalbreak = "\n# Logs blocks that break off of other blocks; for example, a sign or torch\n# falling off of a dirt block that a player breaks. This is required for\n# beds/doors to properly rollback.\nnatural-break: true\n";
  142.             String blockmovement = "\n# Properly track block movement, such as sand or gravel falling.\nblock-movement: true\n";
  143.             String pistons = "\n# Properly track blocks moved by pistons.\npistons: true\n";
  144.             String blockburn = "\n# Logs blocks that burn up in a fire.\nblock-burn: true\n";
  145.             String blockignite = "\n# Logs when a block naturally ignites, such as from fire spreading.\nblock-ignite: true\n";
  146.             String explosions = "\n# Logs explosions, such as TNT and Creepers.\nexplosions: true\n";
  147.             String entitychange = "\n# Track when an entity changes a block, such as an Enderman destroying blocks.\nentity-change: true\n";
  148.             String entitykills = "\n# Logs killed entities, such as killed cows and enderman.\nentity-kills: true\n";
  149.             String signtext = "\n# Logs text on signs. If disabled, signs will be blank when rolled back.\nsign-text: true\n";
  150.             String buckets = "\n# Logs lava and water sources placed/removed by players who are using buckets.\nbuckets: true\n";
  151.             String leafdecay = "\n# Logs natural tree leaf decay.\nleaf-decay: true\n";
  152.             String treegrowth = "\n# Logs tree growth. Trees are linked to the player who planted the sappling.\ntree-growth: true\n";
  153.             String mushroomgrowth = "\n# Logs mushroom growth.\nmushroom-growth: true\n";
  154.             String vinegrowth = "\n# Logs natural vine growth.\nvine-growth: true\n";
  155.             String portals = "\n# Logs when portals such as Nether portals generate naturally.\nportals: true\n";
  156.             String waterflow = "\n# Logs water flow. If water destroys other blocks, such as torches,\n# this allows it to be properly rolled back.\nwater-flow: true\n";
  157.             String lavaflow = "\n# Logs lava flow. If lava destroys other blocks, such as torches,\n# this allows it to be properly rolled back.\nlava-flow: true\n";
  158.             String liquidtracking = "\n# Allows liquid to be properly tracked and linked to players.\n# For example, if a player places water which flows and destroys torches,\n# it can all be properly restored by rolling back that single player.\nliquid-tracking: true\n";
  159.             String itemlogging = "\n# Track item transactions, such as when a player takes items from a\n# chest, furnace, or dispenser. Necessary for any item based rollbacks.\nitem-transactions: true\n";
  160.             String playerinteract = "\n# Track player interactions, such as when a player opens a door, presses\n# a button, or opens a chest. Player interactions can't be rolled back.\nplayer-interactions: true\n";
  161.             String playermessages = "\n# Logs messages that players send in the chat.\nplayer-messages: true\n";
  162.             String playercommands = "\n# Logs all commands used by players.\nplayer-commands: true\n";
  163.             String playersessions = "\n# Logs the logins and logouts of players.\nplayer-sessions: true\n";
  164.             String usernamechanges = "\n# Logs when a player changes their Minecraft username.\nusername-changes: true\n";
  165.             String worldedit = "\n# Logs changes made via the plugin \"WorldEdit\" if it's in use on your server.\nworldedit: true\n";
  166.             config.clear();
  167.             File config_file = new File("plugins/CoreProtect/config.yml");
  168.             boolean exists = config_file.exists();
  169.             if (!exists) {
  170.                 config_file.createNewFile();
  171.             }
  172.  
  173.             File dir = new File("plugins/CoreProtect");
  174.             String[] children = dir.list();
  175.             if (children != null) {
  176.                 String[] var41 = children;
  177.                 int var42 = children.length;
  178.  
  179.                 for(int var43 = 0; var43 < var42; ++var43) {
  180.                     String element = var41[var43];
  181.                     String filename = element;
  182.                     if (!element.startsWith(".") && element.endsWith(".yml")) {
  183.                         try {
  184.                             String key = filename.replaceAll(".yml", "-");
  185.                             if (key.equals("config-")) {
  186.                                 key = "";
  187.                             }
  188.  
  189.                             RandomAccessFile configfile = new RandomAccessFile("plugins/CoreProtect/" + filename, "rw");
  190.                             long config_length = configfile.length();
  191.                             if (config_length > 0L) {
  192.                                 while(configfile.getFilePointer() < configfile.length()) {
  193.                                     String line = configfile.readLine();
  194.                                     if (line.contains(":") && !line.startsWith("#")) {
  195.                                         line = line.replaceFirst(":", "§ ");
  196.                                         String[] i2 = line.split("§");
  197.                                         String option = i2[0].trim().toLowerCase();
  198.                                         String setting;
  199.                                         if (key.length() == 0) {
  200.                                             if (option.equals("verbose")) {
  201.                                                 setting = i2[1].trim().toLowerCase();
  202.                                                 if (setting.startsWith("t")) {
  203.                                                     config.put(key + "verbose", 1);
  204.                                                 } else if (setting.startsWith("f")) {
  205.                                                     config.put("verbose", 0);
  206.                                                 }
  207.                                             }
  208.  
  209.                                             if (option.equals("use-mysql")) {
  210.                                                 setting = i2[1].trim().toLowerCase();
  211.                                                 if (setting.startsWith("t")) {
  212.                                                     config.put("use-mysql", 1);
  213.                                                 } else if (setting.startsWith("f")) {
  214.                                                     config.put("use-mysql", 0);
  215.                                                 }
  216.                                             }
  217.  
  218.                                             if (option.equals("table-prefix")) {
  219.                                                 prefix = i2[1].trim();
  220.                                             }
  221.  
  222.                                             if (option.equals("mysql-host")) {
  223.                                                 host = i2[1].trim();
  224.                                             }
  225.  
  226.                                             if (option.equals("mysql-port")) {
  227.                                                 setting = i2[1].trim();
  228.                                                 setting = setting.replaceAll("[^0-9]", "");
  229.                                                 if (setting.length() == 0) {
  230.                                                     setting = "0";
  231.                                                 }
  232.  
  233.                                                 port = Integer.parseInt(setting);
  234.                                             }
  235.  
  236.                                             if (option.equals("mysql-database")) {
  237.                                                 database = i2[1].trim();
  238.                                             }
  239.  
  240.                                             if (option.equals("mysql-username")) {
  241.                                                 username = i2[1].trim();
  242.                                             }
  243.  
  244.                                             if (option.equals("mysql-password")) {
  245.                                                 password = i2[1].trim();
  246.                                             }
  247.  
  248.                                             if (option.equals("check-updates")) {
  249.                                                 setting = i2[1].trim().toLowerCase();
  250.                                                 if (setting.startsWith("t")) {
  251.                                                     config.put("check-updates", 1);
  252.                                                 } else if (setting.startsWith("f")) {
  253.                                                     config.put("check-updates", 0);
  254.                                                 }
  255.                                             }
  256.  
  257.                                             if (option.equals("api-enabled")) {
  258.                                                 setting = i2[1].trim().toLowerCase();
  259.                                                 if (setting.startsWith("t")) {
  260.                                                     config.put("api-enabled", 1);
  261.                                                 } else if (setting.startsWith("f")) {
  262.                                                     config.put("api-enabled", 0);
  263.                                                 }
  264.                                             }
  265.  
  266.                                             if (option.equals("default-radius")) {
  267.                                                 setting = i2[1].trim();
  268.                                                 setting = setting.replaceAll("[^0-9]", "");
  269.                                                 if (setting.length() == 0) {
  270.                                                     setting = "0";
  271.                                                 }
  272.  
  273.                                                 config.put("default-radius", Integer.parseInt(setting));
  274.                                             }
  275.  
  276.                                             if (option.equals("max-radius")) {
  277.                                                 setting = i2[1].trim();
  278.                                                 setting = setting.replaceAll("[^0-9]", "");
  279.                                                 if (setting.length() == 0) {
  280.                                                     setting = "0";
  281.                                                 }
  282.  
  283.                                                 config.put("max-radius", Integer.parseInt(setting));
  284.                                             }
  285.  
  286.                                             if (option.equals("rollback-items")) {
  287.                                                 setting = i2[1].trim().toLowerCase();
  288.                                                 if (setting.startsWith("t")) {
  289.                                                     config.put("rollback-items", 1);
  290.                                                 } else if (setting.startsWith("f")) {
  291.                                                     config.put("rollback-items", 0);
  292.                                                 }
  293.                                             }
  294.  
  295.                                             if (option.equals("rollback-entities")) {
  296.                                                 setting = i2[1].trim().toLowerCase();
  297.                                                 if (setting.startsWith("t")) {
  298.                                                     config.put("rollback-entities", 1);
  299.                                                 } else if (setting.startsWith("f")) {
  300.                                                     config.put("rollback-entities", 0);
  301.                                                 }
  302.                                             }
  303.                                         }
  304.  
  305.                                         if (option.equals("skip-generic-data")) {
  306.                                             setting = i2[1].trim().toLowerCase();
  307.                                             if (setting.startsWith("t")) {
  308.                                                 config.put(key + "skip-generic-data", 1);
  309.                                             } else if (setting.startsWith("f")) {
  310.                                                 config.put(key + "skip-generic-data", 0);
  311.                                             }
  312.                                         }
  313.  
  314.                                         if (option.equals("block-place")) {
  315.                                             setting = i2[1].trim().toLowerCase();
  316.                                             if (setting.startsWith("t")) {
  317.                                                 config.put(key + "block-place", 1);
  318.                                             } else if (setting.startsWith("f")) {
  319.                                                 config.put(key + "block-place", 0);
  320.                                             }
  321.                                         }
  322.  
  323.                                         if (option.equals("block-break")) {
  324.                                             setting = i2[1].trim().toLowerCase();
  325.                                             if (setting.startsWith("t")) {
  326.                                                 config.put(key + "block-break", 1);
  327.                                             } else if (setting.startsWith("f")) {
  328.                                                 config.put(key + "block-break", 0);
  329.                                             }
  330.                                         }
  331.  
  332.                                         if (option.equals("natural-break")) {
  333.                                             setting = i2[1].trim().toLowerCase();
  334.                                             if (setting.startsWith("t")) {
  335.                                                 config.put(key + "natural-break", 1);
  336.                                             } else if (setting.startsWith("f")) {
  337.                                                 config.put(key + "natural-break", 0);
  338.                                             }
  339.                                         }
  340.  
  341.                                         if (option.equals("block-movement")) {
  342.                                             setting = i2[1].trim().toLowerCase();
  343.                                             if (setting.startsWith("t")) {
  344.                                                 config.put(key + "block-movement", 1);
  345.                                             } else if (setting.startsWith("f")) {
  346.                                                 config.put(key + "block-movement", 0);
  347.                                             }
  348.                                         }
  349.  
  350.                                         if (option.equals("pistons")) {
  351.                                             setting = i2[1].trim().toLowerCase();
  352.                                             if (setting.startsWith("t")) {
  353.                                                 config.put(key + "pistons", 1);
  354.                                             } else if (setting.startsWith("f")) {
  355.                                                 config.put(key + "pistons", 0);
  356.                                             }
  357.                                         }
  358.  
  359.                                         if (option.equals("block-burn")) {
  360.                                             setting = i2[1].trim().toLowerCase();
  361.                                             if (setting.startsWith("t")) {
  362.                                                 config.put(key + "block-burn", 1);
  363.                                             } else if (setting.startsWith("f")) {
  364.                                                 config.put(key + "block-burn", 0);
  365.                                             }
  366.                                         }
  367.  
  368.                                         if (option.equals("block-ignite")) {
  369.                                             setting = i2[1].trim().toLowerCase();
  370.                                             if (setting.startsWith("t")) {
  371.                                                 config.put(key + "block-ignite", 1);
  372.                                             } else if (setting.startsWith("f")) {
  373.                                                 config.put(key + "block-ignite", 0);
  374.                                             }
  375.                                         }
  376.  
  377.                                         if (option.equals("explosions")) {
  378.                                             setting = i2[1].trim().toLowerCase();
  379.                                             if (setting.startsWith("t")) {
  380.                                                 config.put(key + "explosions", 1);
  381.                                             } else if (setting.startsWith("f")) {
  382.                                                 config.put(key + "explosions", 0);
  383.                                             }
  384.                                         }
  385.  
  386.                                         if (option.equals("entity-change")) {
  387.                                             setting = i2[1].trim().toLowerCase();
  388.                                             if (setting.startsWith("t")) {
  389.                                                 config.put(key + "entity-change", 1);
  390.                                             } else if (setting.startsWith("f")) {
  391.                                                 config.put(key + "entity-change", 0);
  392.                                             }
  393.                                         }
  394.  
  395.                                         if (option.equals("entity-kills")) {
  396.                                             setting = i2[1].trim().toLowerCase();
  397.                                             if (setting.startsWith("t")) {
  398.                                                 config.put(key + "entity-kills", 1);
  399.                                             } else if (setting.startsWith("f")) {
  400.                                                 config.put(key + "entity-kills", 0);
  401.                                             }
  402.                                         }
  403.  
  404.                                         if (option.equals("sign-text")) {
  405.                                             setting = i2[1].trim().toLowerCase();
  406.                                             if (setting.startsWith("t")) {
  407.                                                 config.put(key + "sign-text", 1);
  408.                                             } else if (setting.startsWith("f")) {
  409.                                                 config.put(key + "sign-text", 0);
  410.                                             }
  411.                                         }
  412.  
  413.                                         if (option.equals("buckets")) {
  414.                                             setting = i2[1].trim().toLowerCase();
  415.                                             if (setting.startsWith("t")) {
  416.                                                 config.put(key + "buckets", 1);
  417.                                             } else if (setting.startsWith("f")) {
  418.                                                 config.put(key + "buckets", 0);
  419.                                             }
  420.                                         }
  421.  
  422.                                         if (option.equals("leaf-decay")) {
  423.                                             setting = i2[1].trim().toLowerCase();
  424.                                             if (setting.startsWith("t")) {
  425.                                                 config.put(key + "leaf-decay", 1);
  426.                                             } else if (setting.startsWith("f")) {
  427.                                                 config.put(key + "leaf-decay", 0);
  428.                                             }
  429.                                         }
  430.  
  431.                                         if (option.equals("tree-growth")) {
  432.                                             setting = i2[1].trim().toLowerCase();
  433.                                             if (setting.startsWith("t")) {
  434.                                                 config.put(key + "tree-growth", 1);
  435.                                             } else if (setting.startsWith("f")) {
  436.                                                 config.put(key + "tree-growth", 0);
  437.                                             }
  438.                                         }
  439.  
  440.                                         if (option.equals("mushroom-growth")) {
  441.                                             setting = i2[1].trim().toLowerCase();
  442.                                             if (setting.startsWith("t")) {
  443.                                                 config.put(key + "mushroom-growth", 1);
  444.                                             } else if (setting.startsWith("f")) {
  445.                                                 config.put(key + "mushroom-growth", 0);
  446.                                             }
  447.                                         }
  448.  
  449.                                         if (option.equals("vine-growth")) {
  450.                                             setting = i2[1].trim().toLowerCase();
  451.                                             if (setting.startsWith("t")) {
  452.                                                 config.put(key + "vine-growth", 1);
  453.                                             } else if (setting.startsWith("f")) {
  454.                                                 config.put(key + "vine-growth", 0);
  455.                                             }
  456.                                         }
  457.  
  458.                                         if (option.equals("portals")) {
  459.                                             setting = i2[1].trim().toLowerCase();
  460.                                             if (setting.startsWith("t")) {
  461.                                                 config.put(key + "portals", 1);
  462.                                             } else if (setting.startsWith("f")) {
  463.                                                 config.put(key + "portals", 0);
  464.                                             }
  465.                                         }
  466.  
  467.                                         if (option.equals("water-flow")) {
  468.                                             setting = i2[1].trim().toLowerCase();
  469.                                             if (setting.startsWith("t")) {
  470.                                                 config.put(key + "water-flow", 1);
  471.                                             } else if (setting.startsWith("f")) {
  472.                                                 config.put(key + "water-flow", 0);
  473.                                             }
  474.                                         }
  475.  
  476.                                         if (option.equals("lava-flow")) {
  477.                                             setting = i2[1].trim().toLowerCase();
  478.                                             if (setting.startsWith("t")) {
  479.                                                 config.put(key + "lava-flow", 1);
  480.                                             } else if (setting.startsWith("f")) {
  481.                                                 config.put(key + "lava-flow", 0);
  482.                                             }
  483.                                         }
  484.  
  485.                                         if (option.equals("liquid-tracking")) {
  486.                                             setting = i2[1].trim().toLowerCase();
  487.                                             if (setting.startsWith("t")) {
  488.                                                 config.put(key + "liquid-tracking", 1);
  489.                                             } else if (setting.startsWith("f")) {
  490.                                                 config.put(key + "liquid-tracking", 0);
  491.                                             }
  492.                                         }
  493.  
  494.                                         if (option.equals("item-transactions")) {
  495.                                             setting = i2[1].trim().toLowerCase();
  496.                                             if (setting.startsWith("t")) {
  497.                                                 config.put(key + "item-transactions", 1);
  498.                                             } else if (setting.startsWith("f")) {
  499.                                                 config.put(key + "item-transactions", 0);
  500.                                             }
  501.                                         }
  502.  
  503.                                         if (option.equals("player-interactions")) {
  504.                                             setting = i2[1].trim().toLowerCase();
  505.                                             if (setting.startsWith("t")) {
  506.                                                 config.put(key + "player-interactions", 1);
  507.                                             } else if (setting.startsWith("f")) {
  508.                                                 config.put(key + "player-interactions", 0);
  509.                                             }
  510.                                         }
  511.  
  512.                                         if (option.equals("player-messages")) {
  513.                                             setting = i2[1].trim().toLowerCase();
  514.                                             if (setting.startsWith("t")) {
  515.                                                 config.put(key + "player-messages", 1);
  516.                                             } else if (setting.startsWith("f")) {
  517.                                                 config.put(key + "player-messages", 0);
  518.                                             }
  519.                                         }
  520.  
  521.                                         if (option.equals("player-commands")) {
  522.                                             setting = i2[1].trim().toLowerCase();
  523.                                             if (setting.startsWith("t")) {
  524.                                                 config.put(key + "player-commands", 1);
  525.                                             } else if (setting.startsWith("f")) {
  526.                                                 config.put(key + "player-commands", 0);
  527.                                             }
  528.                                         }
  529.  
  530.                                         if (option.equals("player-sessions")) {
  531.                                             setting = i2[1].trim().toLowerCase();
  532.                                             if (setting.startsWith("t")) {
  533.                                                 config.put(key + "player-sessions", 1);
  534.                                             } else if (setting.startsWith("f")) {
  535.                                                 config.put(key + "player-sessions", 0);
  536.                                             }
  537.                                         }
  538.  
  539.                                         if (option.equals("username-changes")) {
  540.                                             setting = i2[1].trim().toLowerCase();
  541.                                             if (setting.startsWith("t")) {
  542.                                                 config.put(key + "username-changes", 1);
  543.                                             } else if (setting.startsWith("f")) {
  544.                                                 config.put(key + "username-changes", 0);
  545.                                             }
  546.                                         }
  547.  
  548.                                         if (option.equals("worldedit")) {
  549.                                             setting = i2[1].trim().toLowerCase();
  550.                                             if (setting.startsWith("t")) {
  551.                                                 config.put(key + "worldedit", 1);
  552.                                             } else if (setting.startsWith("f")) {
  553.                                                 config.put(key + "worldedit", 0);
  554.                                             }
  555.                                         }
  556.                                     }
  557.                                 }
  558.                             }
  559.  
  560.                             if (key.length() == 0) {
  561.                                 if (config_length < 1L) {
  562.                                     configfile.write(confighead.getBytes());
  563.                                 }
  564.  
  565.                                 if (config.get("verbose") == null) {
  566.                                     config.put("verbose", 1);
  567.                                     configfile.seek(configfile.length());
  568.                                     configfile.write(noisy.getBytes());
  569.                                 }
  570.  
  571.                                 if (config.get("use-mysql") == null) {
  572.                                     config.put("use-mysql", 0);
  573.                                     configfile.seek(configfile.length());
  574.                                     configfile.write(mysql.getBytes());
  575.                                 }
  576.  
  577.                                 if (config.get("check-updates") == null) {
  578.                                     config.put("check-updates", 1);
  579.                                     configfile.seek(configfile.length());
  580.                                     configfile.write(update.getBytes());
  581.                                 }
  582.  
  583.                                 if (config.get("api-enabled") == null) {
  584.                                     config.put("api-enabled", 1);
  585.                                     configfile.seek(configfile.length());
  586.                                     configfile.write(api.getBytes());
  587.                                 }
  588.  
  589.                                 if (config.get("default-radius") == null) {
  590.                                     config.put("default-radius", 10);
  591.                                     configfile.seek(configfile.length());
  592.                                     configfile.write(defaultradius.getBytes());
  593.                                 }
  594.  
  595.                                 if (config.get("max-radius") == null) {
  596.                                     config.put("max-radius", 100);
  597.                                     configfile.seek(configfile.length());
  598.                                     configfile.write(maxradius.getBytes());
  599.                                 }
  600.  
  601.                                 if (config.get("rollback-items") == null) {
  602.                                     config.put("rollback-items", 1);
  603.                                     configfile.seek(configfile.length());
  604.                                     configfile.write(rollbackitems.getBytes());
  605.                                 }
  606.  
  607.                                 if (config.get("rollback-entities") == null) {
  608.                                     config.put("rollback-entities", 1);
  609.                                     configfile.seek(configfile.length());
  610.                                     configfile.write(rollbackentities.getBytes());
  611.                                 }
  612.  
  613.                                 if (config.get("skip-generic-data") == null) {
  614.                                     config.put("skip-generic-data", 1);
  615.                                     configfile.seek(configfile.length());
  616.                                     configfile.write(skipgenericdata.getBytes());
  617.                                 }
  618.  
  619.                                 if (config.get("block-place") == null) {
  620.                                     config.put("block-place", 1);
  621.                                     configfile.seek(configfile.length());
  622.                                     configfile.write(blockplace.getBytes());
  623.                                 }
  624.  
  625.                                 if (config.get("block-break") == null) {
  626.                                     config.put("block-break", 1);
  627.                                     configfile.seek(configfile.length());
  628.                                     configfile.write(blockbreak.getBytes());
  629.                                 }
  630.  
  631.                                 if (config.get("natural-break") == null) {
  632.                                     config.put("natural-break", 1);
  633.                                     configfile.seek(configfile.length());
  634.                                     configfile.write(naturalbreak.getBytes());
  635.                                 }
  636.  
  637.                                 if (config.get("block-movement") == null) {
  638.                                     config.put("block-movement", 1);
  639.                                     configfile.seek(configfile.length());
  640.                                     configfile.write(blockmovement.getBytes());
  641.                                 }
  642.  
  643.                                 if (config.get("pistons") == null) {
  644.                                     config.put("pistons", 1);
  645.                                     configfile.seek(configfile.length());
  646.                                     configfile.write(pistons.getBytes());
  647.                                 }
  648.  
  649.                                 if (config.get("block-burn") == null) {
  650.                                     config.put("block-burn", 1);
  651.                                     configfile.seek(configfile.length());
  652.                                     configfile.write(blockburn.getBytes());
  653.                                 }
  654.  
  655.                                 if (config.get("block-ignite") == null) {
  656.                                     config.put("block-ignite", 1);
  657.                                     configfile.seek(configfile.length());
  658.                                     configfile.write(blockignite.getBytes());
  659.                                 }
  660.  
  661.                                 if (config.get("explosions") == null) {
  662.                                     config.put("explosions", 1);
  663.                                     configfile.seek(configfile.length());
  664.                                     configfile.write(explosions.getBytes());
  665.                                 }
  666.  
  667.                                 if (config.get("entity-change") == null) {
  668.                                     config.put("entity-change", 1);
  669.                                     configfile.seek(configfile.length());
  670.                                     configfile.write(entitychange.getBytes());
  671.                                 }
  672.  
  673.                                 if (config.get("entity-kills") == null) {
  674.                                     config.put("entity-kills", 1);
  675.                                     configfile.seek(configfile.length());
  676.                                     configfile.write(entitykills.getBytes());
  677.                                 }
  678.  
  679.                                 if (config.get("sign-text") == null) {
  680.                                     config.put("sign-text", 1);
  681.                                     configfile.seek(configfile.length());
  682.                                     configfile.write(signtext.getBytes());
  683.                                 }
  684.  
  685.                                 if (config.get("buckets") == null) {
  686.                                     config.put("buckets", 1);
  687.                                     configfile.seek(configfile.length());
  688.                                     configfile.write(buckets.getBytes());
  689.                                 }
  690.  
  691.                                 if (config.get("leaf-decay") == null) {
  692.                                     config.put("leaf-decay", 1);
  693.                                     configfile.seek(configfile.length());
  694.                                     configfile.write(leafdecay.getBytes());
  695.                                 }
  696.  
  697.                                 if (config.get("tree-growth") == null) {
  698.                                     config.put("tree-growth", 1);
  699.                                     configfile.seek(configfile.length());
  700.                                     configfile.write(treegrowth.getBytes());
  701.                                 }
  702.  
  703.                                 if (config.get("mushroom-growth") == null) {
  704.                                     config.put("mushroom-growth", 1);
  705.                                     configfile.seek(configfile.length());
  706.                                     configfile.write(mushroomgrowth.getBytes());
  707.                                 }
  708.  
  709.                                 if (config.get("vine-growth") == null) {
  710.                                     config.put("vine-growth", 1);
  711.                                     configfile.seek(configfile.length());
  712.                                     configfile.write(vinegrowth.getBytes());
  713.                                 }
  714.  
  715.                                 if (config.get("portals") == null) {
  716.                                     config.put("portals", 1);
  717.                                     configfile.seek(configfile.length());
  718.                                     configfile.write(portals.getBytes());
  719.                                 }
  720.  
  721.                                 if (config.get("water-flow") == null) {
  722.                                     config.put("water-flow", 1);
  723.                                     configfile.seek(configfile.length());
  724.                                     configfile.write(waterflow.getBytes());
  725.                                 }
  726.  
  727.                                 if (config.get("lava-flow") == null) {
  728.                                     config.put("lava-flow", 1);
  729.                                     configfile.seek(configfile.length());
  730.                                     configfile.write(lavaflow.getBytes());
  731.                                 }
  732.  
  733.                                 if (config.get("liquid-tracking") == null) {
  734.                                     config.put("liquid-tracking", 1);
  735.                                     configfile.seek(configfile.length());
  736.                                     configfile.write(liquidtracking.getBytes());
  737.                                 }
  738.  
  739.                                 if (config.get("item-transactions") == null) {
  740.                                     config.put("item-transactions", 1);
  741.                                     configfile.seek(configfile.length());
  742.                                     configfile.write(itemlogging.getBytes());
  743.                                 }
  744.  
  745.                                 if (config.get("player-interactions") == null) {
  746.                                     config.put("player-interactions", 1);
  747.                                     configfile.seek(configfile.length());
  748.                                     configfile.write(playerinteract.getBytes());
  749.                                 }
  750.  
  751.                                 if (config.get("player-messages") == null) {
  752.                                     config.put("player-messages", 1);
  753.                                     configfile.seek(configfile.length());
  754.                                     configfile.write(playermessages.getBytes());
  755.                                 }
  756.  
  757.                                 if (config.get("player-commands") == null) {
  758.                                     config.put("player-commands", 1);
  759.                                     configfile.seek(configfile.length());
  760.                                     configfile.write(playercommands.getBytes());
  761.                                 }
  762.  
  763.                                 if (config.get("player-sessions") == null) {
  764.                                     config.put("player-sessions", 1);
  765.                                     configfile.seek(configfile.length());
  766.                                     configfile.write(playersessions.getBytes());
  767.                                 }
  768.  
  769.                                 if (config.get("username-changes") == null) {
  770.                                     config.put("username-changes", 1);
  771.                                     configfile.seek(configfile.length());
  772.                                     configfile.write(usernamechanges.getBytes());
  773.                                 }
  774.  
  775.                                 if (config.get("worldedit") == null) {
  776.                                     config.put("worldedit", 1);
  777.                                     configfile.seek(configfile.length());
  778.                                     configfile.write(worldedit.getBytes());
  779.                                 }
  780.                             }
  781.  
  782.                             configfile.close();
  783.                         } catch (Exception var54) {
  784.                             var54.printStackTrace();
  785.                         }
  786.                     }
  787.                 }
  788.             }
  789.  
  790.             if ((Integer)config.get("use-mysql") == 0) {
  791.                 prefix = "co_";
  792.             }
  793.  
  794.             loadBlacklist();
  795.         } catch (Exception var55) {
  796.             var55.printStackTrace();
  797.         }
  798.  
  799.     }
  800.  
  801.     public static void loadDatabase() {
  802.         if ((Integer)config.get("use-mysql") == 0) {
  803.             try {
  804.                 File tempFile = File.createTempFile("CoreProtect_" + System.currentTimeMillis(), ".tmp");
  805.                 tempFile.setExecutable(true);
  806.                 if (!tempFile.canExecute()) {
  807.                     File tempFolder = new File("cache");
  808.                     boolean exists = tempFolder.exists();
  809.                     if (!exists) {
  810.                         tempFolder.mkdir();
  811.                     }
  812.  
  813.                     System.setProperty("java.io.tmpdir", "cache");
  814.                 }
  815.  
  816.                 tempFile.delete();
  817.             } catch (Exception var3) {
  818.                 var3.printStackTrace();
  819.             }
  820.         }
  821.  
  822.         Functions.createDatabaseTables(prefix, false);
  823.     }
  824.  
  825.     private static void loadTypes(Statement statement) {
  826.         try {
  827.             materials.clear();
  828.             materials_reversed.clear();
  829.             material_id = 0;
  830.             String query = "SELECT id,material FROM " + prefix + "material_map";
  831.             ResultSet rs = statement.executeQuery(query);
  832.  
  833.             int id;
  834.             String entity;
  835.             while(rs.next()) {
  836.                 id = rs.getInt("id");
  837.                 entity = rs.getString("material");
  838.                 materials.put(entity, id);
  839.                 materials_reversed.put(id, entity);
  840.                 if (id > material_id) {
  841.                     material_id = id;
  842.                 }
  843.             }
  844.  
  845.             rs.close();
  846.             art.clear();
  847.             art_reversed.clear();
  848.             art_id = 0;
  849.             query = "SELECT id,art FROM " + prefix + "art_map";
  850.             rs = statement.executeQuery(query);
  851.  
  852.             while(rs.next()) {
  853.                 id = rs.getInt("id");
  854.                 entity = rs.getString("art");
  855.                 art.put(entity, id);
  856.                 art_reversed.put(id, entity);
  857.                 if (id > art_id) {
  858.                     art_id = id;
  859.                 }
  860.             }
  861.  
  862.             rs.close();
  863.             entities.clear();
  864.             entities_reversed.clear();
  865.             entity_id = 0;
  866.             query = "SELECT id,entity FROM " + prefix + "entity_map";
  867.             rs = statement.executeQuery(query);
  868.  
  869.             while(rs.next()) {
  870.                 id = rs.getInt("id");
  871.                 entity = rs.getString("entity");
  872.                 entities.put(entity, id);
  873.                 entities_reversed.put(id, entity);
  874.                 if (id > entity_id) {
  875.                     entity_id = id;
  876.                 }
  877.             }
  878.  
  879.             rs.close();
  880.         } catch (Exception var5) {
  881.             var5.printStackTrace();
  882.         }
  883.  
  884.         BlockInfo.loadData();
  885.     }
  886.  
  887.     private static void loadWorlds(Statement statement) {
  888.         try {
  889.             worlds.clear();
  890.             worlds_reversed.clear();
  891.             world_id = 0;
  892.             String query = "SELECT id,world FROM " + prefix + "world";
  893.             ResultSet rs = statement.executeQuery(query);
  894.  
  895.             while(rs.next()) {
  896.                 int id = rs.getInt("id");
  897.                 String world = rs.getString("world");
  898.                 worlds.put(world, id);
  899.                 worlds_reversed.put(id, world);
  900.                 if (id > world_id) {
  901.                     world_id = id;
  902.                 }
  903.             }
  904.  
  905.             List<World> worlds = CoreProtect.getInstance().getServer().getWorlds();
  906.             Iterator var10 = worlds.iterator();
  907.  
  908.             while(var10.hasNext()) {
  909.                 World world = (World)var10.next();
  910.                 String worldname = world.getName();
  911.                 if (worlds.get(worldname) == null) {
  912.                     int id = world_id + 1;
  913.                     worlds.put(worldname, id);
  914.                     worlds_reversed.put(id, worldname);
  915.                     world_id = id;
  916.                     Queue.queueWorldInsert(id, worldname);
  917.                 }
  918.             }
  919.         } catch (Exception var8) {
  920.             var8.printStackTrace();
  921.         }
  922.  
  923.     }
  924.  
  925.     public static boolean performInitialization() {
  926.         try {
  927.             loadConfig();
  928.             loadDatabase();
  929.             Connection connection = Database.getConnection(true);
  930.             Statement statement = connection.createStatement();
  931.             checkPlayers(connection);
  932.             loadWorlds(statement);
  933.             loadTypes(statement);
  934.             if (Functions.checkWorldEdit()) {
  935.                 Functions.loadWorldEdit();
  936.             }
  937.  
  938.             server_running = true;
  939.             boolean validVersion = Patch.versionCheck(statement);
  940.             statement.close();
  941.             connection.close();
  942.             return validVersion;
  943.         } catch (Exception var3) {
  944.             var3.printStackTrace();
  945.             return false;
  946.         }
  947.     }
  948. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement