Remove API module
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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");
|
||||
private Config() {
|
||||
super(Config.configPath, "config");
|
||||
}
|
||||
|
||||
static Config config;
|
||||
static int version;
|
||||
static HashMap<ShopType, ShopTypeConfig> shopTypeConfigs;
|
||||
|
||||
public static void reload() {
|
||||
config = new Config();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
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;
|
||||
public static boolean usePermissionShopLimit = false;
|
||||
public static String shopCreationWord = "[SHOP]";
|
||||
private static void shopSettings() {
|
||||
String path = "shop-settings.";
|
||||
shopLimit = config.getInt(path + "player-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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.alttd.playershops.config;
|
||||
|
||||
import com.alttd.galaxy.configuration.AbstractConfiguration;
|
||||
import com.alttd.playershops.shop.ShopType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DatabaseConfig extends AbstractConfiguration {
|
||||
|
||||
private DatabaseConfig() {
|
||||
super(Config.configPath, "database");
|
||||
}
|
||||
|
||||
static DatabaseConfig config;
|
||||
static int version;
|
||||
static HashMap<ShopType, ShopTypeConfig> shopTypeConfigs;
|
||||
|
||||
public static void reload() {
|
||||
config = new DatabaseConfig();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(DatabaseConfig.class, null);
|
||||
|
||||
shopTypeConfigs = new HashMap<>();
|
||||
for (ShopType shopType : ShopType.values()) {
|
||||
shopTypeConfigs.put(shopType, new ShopTypeConfig(shopType.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static String DRIVER = "mysql";
|
||||
public static String IP = "localhost";
|
||||
public static String PORT = "3306";
|
||||
public static String DATABASE_NAME = "AltitudeQuests";
|
||||
public static String USERNAME = "root";
|
||||
public static String PASSWORD = "root";
|
||||
|
||||
private static void loadDatabase() {
|
||||
DRIVER = config.getString("database.driver", DRIVER);
|
||||
IP = config.getString("database.ip", IP);
|
||||
PORT = config.getString("database.port", PORT);
|
||||
DATABASE_NAME = config.getString("database.name", DATABASE_NAME);
|
||||
USERNAME = config.getString("database.username", USERNAME);
|
||||
PASSWORD = config.getString("database.password", PASSWORD);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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 {
|
||||
|
||||
public MessageConfig() {
|
||||
super(Config.configPath, "messageconfig");
|
||||
}
|
||||
|
||||
static MessageConfig config;
|
||||
static int version;
|
||||
static HashMap<ShopType, ShopTypeConfig> shopTypeConfigs;
|
||||
|
||||
public static void reload() {
|
||||
config = new MessageConfig();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
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>";
|
||||
public static String NO_SHOP_CREATE_PERMISSION = "<red>You don't have permission to create shops.</red>";
|
||||
public static String SHOP_LIMIT_REACHED = "<red>You cannot create this shop as you already have reached the limit (<limit>).</red>";
|
||||
|
||||
void loadErrorMessages() {
|
||||
SHOP_ALREADY_EXISTS = getString("errors.shop-already-exists", SHOP_ALREADY_EXISTS);
|
||||
NO_SHOP_CREATE_PERMISSION = getString("errors.no-shop-create-permission", NO_SHOP_CREATE_PERMISSION);
|
||||
SHOP_LIMIT_REACHED = getString("errors.shop-limit-reached", SHOP_LIMIT_REACHED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.alttd.playershops.config;
|
||||
|
||||
public class ShopTypeConfig {
|
||||
|
||||
private final String shopType;
|
||||
private final String configPath;
|
||||
private final String defaultPath;
|
||||
|
||||
public ShopTypeConfig(String shopType) {
|
||||
this.shopType = shopType;
|
||||
this.configPath = "shop.type." + this.shopType + ".";
|
||||
this.defaultPath = "shop.type.default.";
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Config.config.readConfig(ShopTypeConfig.class, this);
|
||||
}
|
||||
|
||||
private static void set(String path, Object def) {
|
||||
Config.config.set(path, def);
|
||||
}
|
||||
|
||||
private String getString(String path, String def) {
|
||||
set(defaultPath + path, def);
|
||||
return Config.config.getNode(configPath + path).getString(
|
||||
Config.config.getNode(defaultPath + path).getString(def));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user