rework some stuff
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
package com.alttd.playershops.config;
|
||||
|
||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
||||
import com.alttd.playershops.shop.ShopType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Config extends AbstractConfiguration {
|
||||
|
||||
public static File configPath = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "com/alttd/playershops");
|
||||
public static File configPath = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "playershops");
|
||||
private Config() {
|
||||
super(Config.configPath, "config");
|
||||
}
|
||||
|
||||
static Config config;
|
||||
static int version;
|
||||
static HashMap<ShopType, ShopTypeConfig> shopTypeConfigs;
|
||||
|
||||
public static void reload() {
|
||||
config = new Config();
|
||||
@@ -25,11 +22,6 @@ public class Config extends AbstractConfiguration {
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(Config.class, null);
|
||||
|
||||
shopTypeConfigs = new HashMap<>();
|
||||
for (ShopType shopType : ShopType.values()) {
|
||||
shopTypeConfigs.put(shopType, new ShopTypeConfig(shopType.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static int shopLimit = 100;
|
||||
@@ -37,15 +29,9 @@ public class Config extends AbstractConfiguration {
|
||||
public static String shopCreationWord = "[SHOP]";
|
||||
private static void shopSettings() {
|
||||
String path = "shop-settings.";
|
||||
shopLimit = config.getInt(path + "player-shop-limit", shopLimit);
|
||||
shopLimit = config.getInt(path + "default-shop-limit", shopLimit);
|
||||
usePermissionShopLimit = config.getBoolean(path + "use-permission-based-shop-limit", usePermissionShopLimit);
|
||||
shopCreationWord = config.getString(path + "creation-word", shopCreationWord);
|
||||
}
|
||||
|
||||
public static String shopLimitPermission = "shop.buildlimit";
|
||||
private static void permissionSettings() {
|
||||
String path = "permission.";
|
||||
shopLimitPermission = config.getString(path + "build-limit", shopLimitPermission);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class DatabaseConfig extends AbstractConfiguration {
|
||||
public static String DRIVER = "mysql";
|
||||
public static String IP = "localhost";
|
||||
public static String PORT = "3306";
|
||||
public static String DATABASE_NAME = "AltitudeQuests";
|
||||
public static String DATABASE_NAME = "PlayerShops";
|
||||
public static String USERNAME = "root";
|
||||
public static String PASSWORD = "root";
|
||||
|
||||
@@ -38,4 +38,12 @@ public class DatabaseConfig extends AbstractConfiguration {
|
||||
USERNAME = config.getString("database.username", USERNAME);
|
||||
PASSWORD = config.getString("database.password", PASSWORD);
|
||||
}
|
||||
|
||||
// Time in seconds between database tasks
|
||||
public static int queueDelay = 5;
|
||||
public static int maxDatabaseConnections = 10;
|
||||
private static void databaseSettings() {
|
||||
queueDelay = config.getInt("database.queue.delay" , queueDelay);
|
||||
maxDatabaseConnections = config.getInt("database.maximum-connections" , maxDatabaseConnections);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.alttd.playershops.config;
|
||||
|
||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
||||
import com.alttd.playershops.shop.ShopType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MessageConfig extends AbstractConfiguration {
|
||||
|
||||
@@ -13,7 +10,6 @@ public class MessageConfig extends AbstractConfiguration {
|
||||
|
||||
static MessageConfig config;
|
||||
static int version;
|
||||
static HashMap<ShopType, ShopTypeConfig> shopTypeConfigs;
|
||||
|
||||
public static void reload() {
|
||||
config = new MessageConfig();
|
||||
@@ -22,11 +18,6 @@ public class MessageConfig extends AbstractConfiguration {
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(Config.class, null);
|
||||
|
||||
shopTypeConfigs = new HashMap<>();
|
||||
for (ShopType shopType : ShopType.values()) {
|
||||
shopTypeConfigs.put(shopType, new ShopTypeConfig(shopType.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static String SHOP_ALREADY_EXISTS = "<red>This block is already a Shop</red>";
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.alttd.playershops.config;
|
||||
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShopTypeConfig {
|
||||
|
||||
private final String shopType;
|
||||
@@ -27,4 +33,22 @@ public class ShopTypeConfig {
|
||||
Config.config.getNode(defaultPath + path).getString(def));
|
||||
}
|
||||
|
||||
private List<String> getStringList(String path, List<String> def) {
|
||||
try {
|
||||
set(defaultPath + path, def);
|
||||
return Config.config.getNode(configPath + path).getList(TypeToken.get(String.class),
|
||||
Config.config.getNode(defaultPath + path).getList(TypeToken.get(String.class), def));
|
||||
} catch(SerializationException ignore) {}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<String> activeSignLines = List.of("<green>[Shop]", "", "", "");
|
||||
public List<String> inActiveSignLines = List.of("<green>[Shop]", "right click", "to manage", "<ownername>");
|
||||
public List<String> expiredSignLines = List.of("[Shop]", "expired", "", "<ownername>");
|
||||
private void textSettings() {
|
||||
activeSignLines = getStringList("sign.active-lines", activeSignLines);
|
||||
inActiveSignLines = getStringList("sign.inactive-lines", inActiveSignLines);
|
||||
expiredSignLines = getStringList("sign.expired-lines", expiredSignLines);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user