mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -1,21 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
package com.bekvon.bukkit.residence;
|
package com.bekvon.bukkit.residence;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
@@ -58,14 +57,133 @@ public class ConfigManager {
|
|||||||
protected List<Integer> customRightClick;
|
protected List<Integer> customRightClick;
|
||||||
private boolean enforceAreaInsideArea;
|
private boolean enforceAreaInsideArea;
|
||||||
|
|
||||||
public ConfigManager(FileConfiguration config)
|
public ConfigManager(FileConfiguration config) {
|
||||||
{
|
|
||||||
globalCreatorDefaults = new FlagPermissions();
|
globalCreatorDefaults = new FlagPermissions();
|
||||||
globalResidenceDefaults = new FlagPermissions();
|
globalResidenceDefaults = new FlagPermissions();
|
||||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||||
this.load(config);
|
this.load(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allowAdminsOnly() {
|
||||||
|
return adminsOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowEmptyResidences() {
|
||||||
|
return allowEmptyResidences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean autoRenewLeases() {
|
||||||
|
return leaseAutoRenew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean chatEnabled() {
|
||||||
|
return chatEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean debugEnabled() {
|
||||||
|
return enableDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enabledRentSystem() {
|
||||||
|
return enableRentSystem && enableEconomy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enableEconomy() {
|
||||||
|
return enableEconomy && Residence.getEconomyManager() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enableLeaseMoneyAccount() {
|
||||||
|
return enableLeaseMoneyAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enableSpout() {
|
||||||
|
return spoutEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean flagsInherit() {
|
||||||
|
return flagsInherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAutoSaveInterval() {
|
||||||
|
return autoSaveInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getChatColor() {
|
||||||
|
return chatColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getCustomBothClick() {
|
||||||
|
return customBothClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getCustomContainers() {
|
||||||
|
return customContainers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getCustomRightClick() {
|
||||||
|
return customRightClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultGroup() {
|
||||||
|
return defaultGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEconomySystem() {
|
||||||
|
return economySystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnforceAreaInsideArea() {
|
||||||
|
return enforceAreaInsideArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlagPermissions getGlobalCreatorDefaultFlags() {
|
||||||
|
return globalCreatorDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, FlagPermissions> getGlobalGroupDefaultFlags() {
|
||||||
|
return globalGroupDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlagPermissions getGlobalResidenceDefaultFlags() {
|
||||||
|
return globalResidenceDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInfoToolID() {
|
||||||
|
return infoToolId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLeaseCheckInterval() {
|
||||||
|
return leaseCheckInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinMoveUpdateInterval() {
|
||||||
|
return minMoveUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMultiworldPlugin() {
|
||||||
|
return multiworldPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getOpsAreAdmins() {
|
||||||
|
return adminOps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRentCheckInterval() {
|
||||||
|
return rentCheckInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResidenceNameRegex() {
|
||||||
|
return namefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectionTooldID() {
|
||||||
|
return selectionToolId;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void load(FileConfiguration config) {
|
private void load(FileConfiguration config) {
|
||||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||||
@@ -88,8 +206,10 @@ public class ConfigManager {
|
|||||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||||
language = config.getString("Global.Language", "English");
|
language = config.getString("Global.Language", "English");
|
||||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault",
|
||||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
config.getConfigurationSection("Global"));
|
||||||
|
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault",
|
||||||
|
config.getConfigurationSection("Global"));
|
||||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||||
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||||
@@ -102,188 +222,46 @@ public class ConfigManager {
|
|||||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||||
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||||
if(node!=null)
|
if (node != null) {
|
||||||
{
|
|
||||||
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||||
if(keys!=null)
|
if (keys != null) {
|
||||||
{
|
for (String key : keys) {
|
||||||
for(String key: keys)
|
globalGroupDefaults.put(
|
||||||
{
|
key,
|
||||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
FlagPermissions.parseFromConfigNode(key,
|
||||||
|
config.getConfigurationSection("Global.GroupDefault")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor",
|
||||||
|
"DARK_PURPLE"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
chatColor = ChatColor.DARK_PURPLE;
|
chatColor = ChatColor.DARK_PURPLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useLegacyPermissions()
|
public boolean preventRentModify() {
|
||||||
{
|
return preventBuildInRent;
|
||||||
return legacyperms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultGroup() {
|
public boolean showIntervalMessages() {
|
||||||
return defaultGroup;
|
return showIntervalMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResidenceNameRegex()
|
public boolean stopOnSaveError() {
|
||||||
{
|
return stopOnSaveError;
|
||||||
return namefix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableEconomy() {
|
public boolean useActionBar() {
|
||||||
return enableEconomy && Residence.getEconomyManager()!=null;
|
return actionBar;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean enabledRentSystem()
|
|
||||||
{
|
|
||||||
return enableRentSystem && enableEconomy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useLeases() {
|
public boolean useLeases() {
|
||||||
return useLeases;
|
return useLeases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowAdminsOnly() {
|
public boolean useLegacyPermissions() {
|
||||||
return adminsOnly;
|
return legacyperms;
|
||||||
}
|
|
||||||
public boolean allowEmptyResidences()
|
|
||||||
{
|
|
||||||
return allowEmptyResidences;
|
|
||||||
}
|
|
||||||
public int getInfoToolID()
|
|
||||||
{
|
|
||||||
return infoToolId;
|
|
||||||
}
|
|
||||||
public int getSelectionTooldID()
|
|
||||||
{
|
|
||||||
return selectionToolId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getOpsAreAdmins()
|
|
||||||
{
|
|
||||||
return adminOps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMultiworldPlugin()
|
|
||||||
{
|
|
||||||
return multiworldPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean autoRenewLeases()
|
|
||||||
{
|
|
||||||
return leaseAutoRenew;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEconomySystem()
|
|
||||||
{
|
|
||||||
return economySystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRentCheckInterval()
|
|
||||||
{
|
|
||||||
return rentCheckInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLeaseCheckInterval()
|
|
||||||
{
|
|
||||||
return leaseCheckInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAutoSaveInterval()
|
|
||||||
{
|
|
||||||
return autoSaveInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean flagsInherit()
|
|
||||||
{
|
|
||||||
return flagsInherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean chatEnabled()
|
|
||||||
{
|
|
||||||
return chatEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean useActionBar()
|
|
||||||
{
|
|
||||||
return actionBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getChatColor()
|
|
||||||
{
|
|
||||||
return chatColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinMoveUpdateInterval()
|
|
||||||
{
|
|
||||||
return minMoveUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlagPermissions getGlobalCreatorDefaultFlags()
|
|
||||||
{
|
|
||||||
return globalCreatorDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlagPermissions getGlobalResidenceDefaultFlags()
|
|
||||||
{
|
|
||||||
return globalResidenceDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String,FlagPermissions> getGlobalGroupDefaultFlags()
|
|
||||||
{
|
|
||||||
return globalGroupDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguage()
|
|
||||||
{
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean preventRentModify()
|
|
||||||
{
|
|
||||||
return preventBuildInRent;
|
|
||||||
}
|
|
||||||
public boolean stopOnSaveError()
|
|
||||||
{
|
|
||||||
return stopOnSaveError;
|
|
||||||
}
|
|
||||||
public boolean showIntervalMessages()
|
|
||||||
{
|
|
||||||
return showIntervalMessages;
|
|
||||||
}
|
|
||||||
public boolean enableSpout()
|
|
||||||
{
|
|
||||||
return spoutEnable;
|
|
||||||
}
|
|
||||||
public boolean enableLeaseMoneyAccount()
|
|
||||||
{
|
|
||||||
return enableLeaseMoneyAccount;
|
|
||||||
}
|
|
||||||
public boolean debugEnabled()
|
|
||||||
{
|
|
||||||
return enableDebug;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getCustomContainers()
|
|
||||||
{
|
|
||||||
return customContainers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getCustomBothClick()
|
|
||||||
{
|
|
||||||
return customBothClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getCustomRightClick()
|
|
||||||
{
|
|
||||||
return customRightClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getEnforceAreaInsideArea() {
|
|
||||||
return enforceAreaInsideArea;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
package com.bekvon.bukkit.residence;
|
package com.bekvon.bukkit.residence;
|
||||||
|
|
||||||
@@ -57,8 +56,8 @@ import com.bekvon.bukkit.residence.selection.WorldEditSelectionManager;
|
|||||||
import com.bekvon.bukkit.residence.text.Language;
|
import com.bekvon.bukkit.residence.text.Language;
|
||||||
import com.bekvon.bukkit.residence.text.help.HelpEntry;
|
import com.bekvon.bukkit.residence.text.help.HelpEntry;
|
||||||
import com.bekvon.bukkit.residence.text.help.InformationPager;
|
import com.bekvon.bukkit.residence.text.help.InformationPager;
|
||||||
|
import com.bekvon.bukkit.residence.utils.ZipLibrary;
|
||||||
import com.bekvon.bukkit.residence.vaultinterface.ResidenceVaultAdapter;
|
import com.bekvon.bukkit.residence.vaultinterface.ResidenceVaultAdapter;
|
||||||
import com.bekvon.bukkit.residence.vaultinterface.ZipLibrary;
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,8 +232,7 @@ public class Residence extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
rentmanager.checkCurrentRents();
|
rentmanager.checkCurrentRents();
|
||||||
if (cmanager.showIntervalMessages()) {
|
if (cmanager.showIntervalMessages()) {
|
||||||
System.out
|
System.out.println("[Residence] - Rent Expirations checked!");
|
||||||
.println("[Residence] - Rent Expirations checked!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -244,8 +242,7 @@ public class Residence extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
leasemanager.doExpirations();
|
leasemanager.doExpirations();
|
||||||
if (cmanager.showIntervalMessages()) {
|
if (cmanager.showIntervalMessages()) {
|
||||||
System.out
|
System.out.println("[Residence] - Lease Expirations checked!");
|
||||||
.println("[Residence] - Lease Expirations checked!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -258,9 +255,7 @@ public class Residence extends JavaPlugin {
|
|||||||
saveYml();
|
saveYml();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger("Minecraft").log(
|
Logger.getLogger("Minecraft").log(Level.SEVERE, "[Residence] 插件数据 保存 错误", ex);
|
||||||
Level.SEVERE,
|
|
||||||
"[Residence] 插件数据 保存 错误", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -430,7 +425,7 @@ public class Residence extends JavaPlugin {
|
|||||||
if (this.getConfig().getInt("ResidenceVersion", 0) == 0) {
|
if (this.getConfig().getInt("ResidenceVersion", 0) == 0) {
|
||||||
this.writeDefaultConfigFromJar();
|
this.writeDefaultConfigFromJar();
|
||||||
this.getConfig().load("config.yml");
|
this.getConfig().load("config.yml");
|
||||||
System.out.println("[Residence] 配置文件不存在,写入默认配置文件.");
|
this.getLogger().warning("配置文件不存在,写入默认配置文件.");
|
||||||
}
|
}
|
||||||
cmanager = new ConfigManager(this.getConfig());
|
cmanager = new ConfigManager(this.getConfig());
|
||||||
String multiworld = cmanager.getMultiworldPlugin();
|
String multiworld = cmanager.getMultiworldPlugin();
|
||||||
@@ -438,7 +433,7 @@ public class Residence extends JavaPlugin {
|
|||||||
Plugin plugin = server.getPluginManager().getPlugin(multiworld);
|
Plugin plugin = server.getPluginManager().getPlugin(multiworld);
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
if (!plugin.isEnabled()) {
|
if (!plugin.isEnabled()) {
|
||||||
System.out.println("[Residence] - 加载多世界插件: " + multiworld);
|
this.getLogger().warning(" - 加载多世界插件: " + multiworld);
|
||||||
server.getPluginManager().enablePlugin(plugin);
|
server.getPluginManager().enablePlugin(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,14 +449,14 @@ public class Residence extends JavaPlugin {
|
|||||||
this.writeDefaultLanguageFile(lang);
|
this.writeDefaultLanguageFile(lang);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[Residence] 语言文件升级失败: " + lang + ".yml");
|
this.getLogger().warning("语言文件升级失败: " + lang + ".yml");
|
||||||
helppages = new HelpEntry("");
|
helppages = new HelpEntry("");
|
||||||
language = new Language();
|
language = new Language();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
||||||
+ ".yml");
|
+ ".yml");
|
||||||
|
try {
|
||||||
if (langFile.isFile()) {
|
if (langFile.isFile()) {
|
||||||
FileConfig langconfig = new FileConfig();
|
FileConfig langconfig = new FileConfig();
|
||||||
langconfig.load(langFile);
|
langconfig.load(langFile);
|
||||||
@@ -470,25 +465,27 @@ public class Residence extends JavaPlugin {
|
|||||||
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||||
language = Language.parseText(langconfig, "Language");
|
language = Language.parseText(langconfig, "Language");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("[Residence] 语言文件不存在...");
|
this.getLogger().warning("语言文件不存在...");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("[Residence] 语言文件载入失败: " + cmanager.getLanguage() + ".yml, 错误: "
|
this.getLogger().warning("语言文件载入失败: " + cmanager.getLanguage() + ".yml 写入默认语言文件");
|
||||||
+ ex.getMessage());
|
this.writeDefaultLanguageFile(cmanager.getLanguage());
|
||||||
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
|
FileConfig langconfig = new FileConfig();
|
||||||
helppages = new HelpEntry("");
|
langconfig.load(langFile);
|
||||||
language = new Language();
|
helppages = HelpEntry.parseHelp(langconfig, "CommandHelp");
|
||||||
|
HelpEntry.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||||
|
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||||
|
language = Language.parseText(langconfig, "Language");
|
||||||
}
|
}
|
||||||
economy = null;
|
economy = null;
|
||||||
if (this.getConfig().getBoolean("Global.EnableEconomy", false)) {
|
if (this.getConfig().getBoolean("Global.EnableEconomy", false)) {
|
||||||
System.out.println("[Residence] 扫描经济系统...");
|
this.getLogger().info("扫描经济系统...");
|
||||||
if (gmanager.getPermissionsPlugin() instanceof ResidenceVaultAdapter) {
|
if (gmanager.getPermissionsPlugin() instanceof ResidenceVaultAdapter) {
|
||||||
ResidenceVaultAdapter vault = (ResidenceVaultAdapter) gmanager
|
ResidenceVaultAdapter vault = (ResidenceVaultAdapter) gmanager
|
||||||
.getPermissionsPlugin();
|
.getPermissionsPlugin();
|
||||||
if (vault.economyOK()) {
|
if (vault.economyOK()) {
|
||||||
economy = vault;
|
economy = vault;
|
||||||
System.out
|
this.getLogger().info("发现 Vault 使用经济系统: " + vault.getEconomyName());
|
||||||
.println("[Residence] 发现 Vault 使用经济系统: " + vault.getEconomyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (economy == null) {
|
if (economy == null) {
|
||||||
@@ -498,7 +495,7 @@ public class Residence extends JavaPlugin {
|
|||||||
this.loadEssentialsEconomy();
|
this.loadEssentialsEconomy();
|
||||||
}
|
}
|
||||||
if (economy == null) {
|
if (economy == null) {
|
||||||
System.out.println("[Residence] 未找到经济系统...");
|
this.getLogger().warning("未找到经济系统...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -529,7 +526,7 @@ public class Residence extends JavaPlugin {
|
|||||||
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] 发现 WorldEdit");
|
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] 发现 WorldEdit");
|
||||||
} else {
|
} else {
|
||||||
smanager = new SelectionManager(server);
|
smanager = new SelectionManager(server);
|
||||||
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] WorldEdit 未找到!");
|
this.getLogger().warning("WorldEdit 未找到!");
|
||||||
}
|
}
|
||||||
|
|
||||||
blistener = new ResidenceBlockListener();
|
blistener = new ResidenceBlockListener();
|
||||||
@@ -581,7 +578,7 @@ public class Residence extends JavaPlugin {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
initsuccess = false;
|
initsuccess = false;
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
System.out.println("[Residence] - 初始化失败! 卸载插件! 错误:");
|
this.getLogger().warning(" - 初始化失败! 卸载插件! 错误:");
|
||||||
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,14 @@ public class ConfigLoader extends FileConfig {
|
|||||||
protected static boolean tip = true;
|
protected static boolean tip = true;
|
||||||
protected static Plugin plugin;
|
protected static Plugin plugin;
|
||||||
|
|
||||||
|
public static FileConfig getInstance() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveError(File file) {
|
||||||
|
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigLoader(Plugin p, File file) {
|
public ConfigLoader(Plugin p, File file) {
|
||||||
ConfigLoader.plugin = p;
|
ConfigLoader.plugin = p;
|
||||||
config = loadConfig(p, file, null, true);
|
config = loadConfig(p, file, null, true);
|
||||||
@@ -32,8 +40,7 @@ public class ConfigLoader extends FileConfig {
|
|||||||
|
|
||||||
public ConfigLoader(Plugin p, String filename) {
|
public ConfigLoader(Plugin p, String filename) {
|
||||||
ConfigLoader.plugin = p;
|
ConfigLoader.plugin = p;
|
||||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null,
|
config = loadConfig(p, new File(p.getDataFolder(), filename), null, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigLoader(Plugin p, String filename, boolean res) {
|
public ConfigLoader(Plugin p, String filename, boolean res) {
|
||||||
@@ -51,36 +58,6 @@ public class ConfigLoader extends FileConfig {
|
|||||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfig getInstance() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
|
||||||
tip = res ;
|
|
||||||
if (!file.getParentFile().exists()) {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
p.getLogger().info("创建新的文件夹" + file.getParentFile().getAbsolutePath() + "...");
|
|
||||||
}
|
|
||||||
if (!file.exists()) {
|
|
||||||
fileCreate(p, file, res);
|
|
||||||
} else {
|
|
||||||
if (ver != null) {
|
|
||||||
FileConfig configcheck = init(file);
|
|
||||||
String version = configcheck.getString("version");
|
|
||||||
if (version == null || !version.equals(ver)) {
|
|
||||||
p.saveResource(file.getName(), true);
|
|
||||||
p.getLogger().warning(
|
|
||||||
"配置文件: " + file.getName() + " 版本过低 正在升级...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tip)
|
|
||||||
p.getLogger().info(
|
|
||||||
"载入配置文件: " + file.getName()
|
|
||||||
+ (ver != null ? " 版本: " + ver : ""));
|
|
||||||
return init(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fileCreate(Plugin p, File file, boolean res) {
|
private void fileCreate(Plugin p, File file, boolean res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
p.saveResource(file.getName(), false);
|
p.saveResource(file.getName(), false);
|
||||||
@@ -95,8 +72,35 @@ public class ConfigLoader extends FileConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveError(File file) {
|
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
||||||
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
tip = res;
|
||||||
|
FileConfig tempConfig;
|
||||||
|
if (!file.getParentFile().exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
p.getLogger().info("创建新的文件夹" + file.getParentFile().getAbsolutePath() + "...");
|
||||||
|
}
|
||||||
|
if (!file.exists()) {
|
||||||
|
fileCreate(p, file, res);
|
||||||
|
} else {
|
||||||
|
if (ver != null) {
|
||||||
|
FileConfig configcheck = init(file);
|
||||||
|
String version = configcheck.getString("version");
|
||||||
|
if (version == null || !version.equals(ver)) {
|
||||||
|
p.saveResource(file.getName(), true);
|
||||||
|
p.getLogger().warning("配置文件: " + file.getName() + " 版本过低 正在升级...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tip) {
|
||||||
|
p.getLogger().info("载入配置文件: " + file.getName() + (ver != null ? " 版本: " + ver : ""));
|
||||||
|
}
|
||||||
|
tempConfig = init(file);
|
||||||
|
if (cantload) {
|
||||||
|
p.getLogger().warning("配置文件错误,写入默认的配置文件!");
|
||||||
|
fileCreate(p, file, res);
|
||||||
|
tempConfig = init(file);
|
||||||
|
}
|
||||||
|
return tempConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,33 +25,39 @@ import com.google.common.base.Charsets;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link Configuration} which saves all files in Yaml.
|
* An implementation of {@link Configuration} which saves all files in Yaml. Note that this
|
||||||
* Note that this implementation is not synchronized.
|
* implementation is not synchronized.
|
||||||
*/
|
*/
|
||||||
public class FileConfig extends YamlConfiguration {
|
public class FileConfig extends YamlConfiguration {
|
||||||
|
|
||||||
|
public static boolean cantload = false;
|
||||||
|
|
||||||
public static FileConfig init(File file) {
|
public static FileConfig init(File file) {
|
||||||
return FileConfig.loadConfiguration(file);
|
return FileConfig.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfig loadConfiguration(File file) {
|
public static FileConfig loadConfiguration(File file) {
|
||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
FileConfig config = new FileConfig();
|
FileConfig config = new FileConfig();
|
||||||
try {
|
try {
|
||||||
config.load(file);
|
config.load(file);
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
|
cantload = true;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||||
|
cantload = true;
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||||
|
cantload = true;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||||
|
|
||||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||||
|
|
||||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||||
yamlRepresenter, yamlOptions);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(File file) throws FileNotFoundException, IOException,
|
public void load(File file) throws FileNotFoundException, IOException,
|
||||||
@@ -66,8 +72,7 @@ public class FileConfig extends YamlConfiguration {
|
|||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
Files.createParentDirs(file);
|
Files.createParentDirs(file);
|
||||||
String data = saveToString();
|
String data = saveToString();
|
||||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
|
||||||
Charsets.UTF_8);
|
|
||||||
try {
|
try {
|
||||||
writer.write(data);
|
writer.write(data);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user