296 lines
13 KiB
Java
296 lines
13 KiB
Java
package net.t2code.t2callayduplicate.config;
|
|
|
|
import net.t2code.t2callayduplicate.system.Main;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Particle;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
public class ConfigFile {
|
|
public static void create() {
|
|
File config = new File(Main.getPath(), "config.yml");
|
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
T2Cconfig.set("Plugin.Language", "ENGLISH", yamlConfiguration);
|
|
|
|
T2Cconfig.set("Plugin.updateCheck.onJoin",true,yamlConfiguration);
|
|
T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates",true,yamlConfiguration);
|
|
T2Cconfig.set("Plugin.updateCheck.timeInterval",60,yamlConfiguration);
|
|
|
|
T2Cconfig.set("Duplicate.SneakRequired", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Item.Enable", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Item.Material", Material.AMETHYST_SHARD.toString(), yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Item.Amount", 1, yamlConfiguration);
|
|
|
|
T2Cconfig.set("Duplicate.Particle.Enable", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Particle.Particle", "HEART", yamlConfiguration);
|
|
|
|
T2Cconfig.set("Duplicate.Sound.Enable", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Sound.Sound", "ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM", yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Sound.Volume", 3, yamlConfiguration);
|
|
|
|
T2Cconfig.set("Duplicate.Delay.Enable", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Delay.ProAllay", false, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Delay.ResetOnReload", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Delay.Seconds", 300, yamlConfiguration);
|
|
|
|
T2Cconfig.set("Duplicate.Cost.Enable", true, yamlConfiguration);
|
|
T2Cconfig.set("Duplicate.Cost.Price", 10.00, yamlConfiguration);
|
|
|
|
T2Cconfig.set("Messages.MiniMessagesEditorLink", "https://webui.adventure.kyori.net", yamlConfiguration);
|
|
T2Cconfig.set("Messages.Prefix", "<dark_gray>[<dark_red>T2C</dark_red><aqua>Allay</aqua><gold>Duplicate</gold>]</dark_gray>", yamlConfiguration);
|
|
|
|
T2Cconfig.set("Messages.ENGLISH.Plugin.NoPerm", "[prefix] <red>You are not authorized to do that!</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Duplicate", "[prefix] <green>Du You have duplicated an allay.</green>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Error.Delay", "[prefix] <red>You have to wait <gold>[min] minutes, [sec] seconds</gold> before you can duplicate the next allay.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Error.IncorrectItem", "[prefix] <red>You need <gold>[amount] [item]</gold> to be able to duplicate an allay.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Error.NoMoney", "[prefix] <red>You need <gold>[price] $</gold> to be able to duplicate an allay.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Error.Reset", "[prefix] <red>Player <gold>[player]</gold> not online!</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Error.CanNotBuild", "[prefix] <red>You are not authorized to do so at this area.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.Reset", "[prefix] <green>The delay of <gold>[player]</gold> has been reset.</green>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.ENGLISH.ResetAll", "[prefix] <green>The delay of all players has been reset.</green>", yamlConfiguration);
|
|
|
|
T2Cconfig.set("Messages.GERMAN.Plugin.NoPerm", "[prefix] <red>Dazu bist du nicht berechtigt!</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Duplicate", "[prefix] <green>Du hast ein Allay verdoppelt.</green>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Error.Delay", "[prefix] <red>Du musst noch <gold>[min] Minuten, [sec] Sekunden</gold> warten, befor du das nächste Allay duplizieren kannst.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Error.IncorrectItem", "[prefix] <red>Du benötigst <gold>[amount] [item]</gold> um einen Allay duplizieren kannst.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Error.NoMoney", "[prefix] <red>Du benötigst <gold>[price] $</gold> um einen Allay duplizieren kannst.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Error.Reset", "[prefix] <red>Spieler <gold>[player]</gold> nicht Online!</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Error.CanNotBuild", "[prefix] <red>Du bist an diesem Bereich nicht dazu berechtigt.</red>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.Reset", "[prefix] <green>Das Delay von <gold>[player]</gold> wurde zurückgesetzt.</green>", yamlConfiguration);
|
|
T2Cconfig.set("Messages.GERMAN.ResetAll", "[prefix] <green>Das Delay von allen Spielern wurde zurückgesetzt.</green>", yamlConfiguration);
|
|
try {
|
|
yamlConfiguration.save(config);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void select() {
|
|
File config = new File(Main.getPath(), "config.yml");
|
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
language = yamlConfiguration.getString("Plugin.Language");
|
|
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
|
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates");
|
|
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval");
|
|
|
|
sneakRequired = yamlConfiguration.getBoolean("Duplicate.SneakRequired");
|
|
itemEnable = yamlConfiguration.getBoolean("Duplicate.Item.Enable");
|
|
itemMaterial = yamlConfiguration.getString("Duplicate.Item.Material");
|
|
itemAmount = yamlConfiguration.getInt("Duplicate.Item.Amount");
|
|
|
|
particleEnable = yamlConfiguration.getBoolean("Duplicate.Particle.Enable");
|
|
try {
|
|
particleParticle = Particle.valueOf(yamlConfiguration.getString("Duplicate.Particle.Particle"));
|
|
} catch (Exception ex) {
|
|
T2Csend.error(Main.getPlugin(), "");
|
|
T2Csend.console(String.format("§4The particle %s does not exist, please check your config. The %s is used as particle.", yamlConfiguration.getString("Duplicate.Particle.Particle"), "HEART"));
|
|
T2Csend.error(Main.getPlugin(), "");
|
|
particleParticle = Particle.HEART;
|
|
}
|
|
|
|
soundEnable = yamlConfiguration.getBoolean("Duplicate.Sound.Enable");
|
|
try {
|
|
soundSound = Sound.valueOf(yamlConfiguration.getString("Duplicate.Sound.Sound"));
|
|
} catch (Exception ex) {
|
|
T2Csend.error(Main.getPlugin(), "");
|
|
T2Csend.console(String.format("§4The sound %s does not exist, please check your config. The %s is used as sound.", yamlConfiguration.getString("Duplicate.Sound.Sound"), "ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM"));
|
|
T2Csend.error(Main.getPlugin(), "");
|
|
soundSound = Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM;
|
|
}
|
|
soundVolume = yamlConfiguration.getInt("Duplicate.Sound.Volume");
|
|
|
|
delayEnable = yamlConfiguration.getBoolean("Duplicate.Delay.Enable");
|
|
delayProAllay = yamlConfiguration.getBoolean("Duplicate.Delay.ProAllay");
|
|
delayResetOnReload = yamlConfiguration.getBoolean("Duplicate.Delay.ResetOnReload");
|
|
delaySeconds = yamlConfiguration.getInt("Duplicate.Delay.Seconds");
|
|
|
|
costEnable = yamlConfiguration.getBoolean("Duplicate.Cost.Enable");
|
|
costPrice = yamlConfiguration.getDouble("Duplicate.Cost.Price");
|
|
|
|
prefix = yamlConfiguration.getString("Messages.Prefix");
|
|
|
|
noPerm = getMSG("Messages." + language + ".Plugin.NoPerm", yamlConfiguration);
|
|
duplicate = getMSG("Messages." + language + ".Duplicate", yamlConfiguration);
|
|
errorDelay = getMSG("Messages." + language + ".Error.Delay", yamlConfiguration);
|
|
errorIncorrectItem = getMSG("Messages." + language + ".Error.IncorrectItem", yamlConfiguration);
|
|
errorNoMoney = getMSG("Messages." + language + ".Error.NoMoney", yamlConfiguration);
|
|
errorReset = getMSG("Messages." + language + ".Error.Reset", yamlConfiguration);
|
|
errorCanNotBuild = getMSG("Messages." + language + ".Error.CanNotBuild", yamlConfiguration);
|
|
reset = getMSG("Messages." + language + ".Reset", yamlConfiguration);
|
|
ResetAll = getMSG("Messages." + language + ".ResetAll", yamlConfiguration);
|
|
|
|
|
|
}
|
|
|
|
private static String language;
|
|
|
|
|
|
private static Boolean updateCheckOnJoin;
|
|
private static Boolean updateCheckSeePreReleaseUpdates;
|
|
private static Integer updateCheckTimeInterval;
|
|
private static Boolean sneakRequired;
|
|
private static Boolean itemEnable;
|
|
private static String itemMaterial;
|
|
private static Integer itemAmount;
|
|
|
|
private static Boolean particleEnable;
|
|
private static Particle particleParticle;
|
|
|
|
private static Boolean soundEnable;
|
|
private static Sound soundSound;
|
|
private static Integer soundVolume;
|
|
|
|
private static Boolean delayEnable;
|
|
private static Boolean delayProAllay;
|
|
private static Boolean delayResetOnReload;
|
|
private static Integer delaySeconds;
|
|
|
|
private static Boolean costEnable;
|
|
private static Double costPrice;
|
|
|
|
private static String prefix;
|
|
private static String noPerm;
|
|
private static String duplicate;
|
|
private static String errorDelay;
|
|
private static String errorIncorrectItem;
|
|
private static String errorNoMoney;
|
|
private static String errorReset;
|
|
private static String errorCanNotBuild;
|
|
private static String reset;
|
|
private static String ResetAll;
|
|
|
|
public static String getLanguage() {
|
|
return language;
|
|
}
|
|
|
|
public static Boolean getUpdateCheckOnJoin() {
|
|
return updateCheckOnJoin;
|
|
}
|
|
|
|
public static Boolean getUpdateCheckSeePreReleaseUpdates() {
|
|
return updateCheckSeePreReleaseUpdates;
|
|
}
|
|
|
|
public static Integer getUpdateCheckTimeInterval() {
|
|
return updateCheckTimeInterval;
|
|
}
|
|
|
|
public static Boolean getSneakRequired() {
|
|
return sneakRequired;
|
|
}
|
|
|
|
public static Boolean getItemEnable() {
|
|
return itemEnable;
|
|
}
|
|
|
|
public static String getItemMaterial() {
|
|
return itemMaterial;
|
|
}
|
|
|
|
public static Integer getItemAmount() {
|
|
return itemAmount;
|
|
}
|
|
|
|
public static Boolean getParticleEnable() {
|
|
return particleEnable;
|
|
}
|
|
|
|
public static Particle getParticleParticle() {
|
|
return particleParticle;
|
|
}
|
|
|
|
public static Boolean getSoundEnable() {
|
|
return soundEnable;
|
|
}
|
|
|
|
public static Sound getSoundSound() {
|
|
return soundSound;
|
|
}
|
|
|
|
public static Integer getSoundVolume() {
|
|
return soundVolume;
|
|
}
|
|
|
|
public static Boolean getDelayEnable() {
|
|
return delayEnable;
|
|
}
|
|
|
|
public static Boolean getDelayProAllay() {
|
|
return delayProAllay;
|
|
}
|
|
|
|
public static Boolean getDelayResetOnReload() {
|
|
return delayResetOnReload;
|
|
}
|
|
|
|
public static Integer getDelaySeconds() {
|
|
return delaySeconds;
|
|
}
|
|
|
|
public static Boolean getCostEnable() {
|
|
return costEnable;
|
|
}
|
|
|
|
public static Double getCostPrice() {
|
|
return costPrice;
|
|
}
|
|
|
|
public static String getPrefix() {
|
|
return prefix;
|
|
}
|
|
|
|
public static String getNoPerm() {
|
|
return noPerm;
|
|
}
|
|
|
|
public static String getDuplicate() {
|
|
return duplicate;
|
|
}
|
|
|
|
public static String getErrorDelay() {
|
|
return errorDelay;
|
|
}
|
|
|
|
public static String getErrorIncorrectItem() {
|
|
return errorIncorrectItem;
|
|
}
|
|
|
|
public static String getErrorNoMoney() {
|
|
return errorNoMoney;
|
|
}
|
|
|
|
public static String getErrorReset() {
|
|
return errorReset;
|
|
}
|
|
|
|
public static String getErrorCanNotBuild() {
|
|
return errorCanNotBuild;
|
|
}
|
|
|
|
public static String getReset() {
|
|
return reset;
|
|
}
|
|
|
|
public static String getResetAll() {
|
|
return ResetAll;
|
|
}
|
|
|
|
private static String getMSG(String path, YamlConfiguration yamlConfiguration) {
|
|
String out;
|
|
if (yamlConfiguration.get(path) != null) {
|
|
out = T2Creplace.replace(prefix, yamlConfiguration.getString(path));
|
|
} else {
|
|
T2Csend.error(Main.getPlugin(), String.format("The message on the path [%s] was not found. Please check if the language [%s] exists.", path, language));
|
|
out = path;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
}
|