mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-26 22:06:07 +00:00
@@ -1,289 +1,267 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
protected String defaultGroup;
|
protected String defaultGroup;
|
||||||
protected boolean useLeases;
|
protected boolean useLeases;
|
||||||
protected boolean enableEconomy;
|
protected boolean enableEconomy;
|
||||||
protected String economySystem;
|
protected String economySystem;
|
||||||
protected boolean adminsOnly;
|
protected boolean adminsOnly;
|
||||||
protected boolean allowEmptyResidences;
|
protected boolean allowEmptyResidences;
|
||||||
protected int infoToolId;
|
protected int infoToolId;
|
||||||
protected int selectionToolId;
|
protected int selectionToolId;
|
||||||
protected boolean adminOps;
|
protected boolean adminOps;
|
||||||
protected String multiworldPlugin;
|
protected String multiworldPlugin;
|
||||||
protected boolean enableRentSystem;
|
protected boolean enableRentSystem;
|
||||||
protected boolean leaseAutoRenew;
|
protected boolean leaseAutoRenew;
|
||||||
protected int rentCheckInterval;
|
protected int rentCheckInterval;
|
||||||
protected int leaseCheckInterval;
|
protected int leaseCheckInterval;
|
||||||
protected int autoSaveInt;
|
protected int autoSaveInt;
|
||||||
protected boolean flagsInherit;
|
protected boolean flagsInherit;
|
||||||
protected ChatColor chatColor;
|
protected ChatColor chatColor;
|
||||||
protected boolean chatEnable;
|
protected boolean chatEnable;
|
||||||
protected boolean actionBar;
|
protected boolean actionBar;
|
||||||
protected int minMoveUpdate;
|
protected int minMoveUpdate;
|
||||||
protected FlagPermissions globalCreatorDefaults;
|
protected FlagPermissions globalCreatorDefaults;
|
||||||
protected FlagPermissions globalResidenceDefaults;
|
protected FlagPermissions globalResidenceDefaults;
|
||||||
protected Map<String,FlagPermissions> globalGroupDefaults;
|
protected Map<String, FlagPermissions> globalGroupDefaults;
|
||||||
protected String language;
|
protected String language;
|
||||||
protected boolean preventBuildInRent;
|
protected boolean preventBuildInRent;
|
||||||
protected boolean stopOnSaveError;
|
protected boolean stopOnSaveError;
|
||||||
protected boolean legacyperms;
|
protected boolean legacyperms;
|
||||||
protected String namefix;
|
protected String namefix;
|
||||||
protected boolean showIntervalMessages;
|
protected boolean showIntervalMessages;
|
||||||
protected boolean spoutEnable;
|
protected boolean spoutEnable;
|
||||||
protected boolean enableLeaseMoneyAccount;
|
protected boolean enableLeaseMoneyAccount;
|
||||||
protected boolean enableDebug;
|
protected boolean enableDebug;
|
||||||
protected List<Integer> customContainers;
|
protected List<Integer> customContainers;
|
||||||
protected List<Integer> customBothClick;
|
protected List<Integer> customBothClick;
|
||||||
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);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
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")
|
||||||
private void load(FileConfiguration config) {
|
private void load(FileConfiguration config) {
|
||||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||||
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"));
|
||||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault",
|
||||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault",true);
|
config.getConfigurationSection("Global"));
|
||||||
legacyperms = config.getBoolean("Global.LegacyPermissions",false);
|
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||||
namefix = config.getString("Global.ResidenceNameRegex",null);//"[^a-zA-Z0-9\\-\\_]"
|
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
namefix = config.getString("Global.ResidenceNameRegex", null);// "[^a-zA-Z0-9\\-\\_]"
|
||||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||||
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||||
if(node!=null)
|
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||||
{
|
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||||
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
if (node != null) {
|
||||||
if(keys!=null)
|
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||||
{
|
if (keys != null) {
|
||||||
for(String key: keys)
|
for (String key : keys) {
|
||||||
{
|
globalGroupDefaults.put(
|
||||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
key,
|
||||||
}
|
FlagPermissions.parseFromConfigNode(key,
|
||||||
}
|
config.getConfigurationSection("Global.GroupDefault")));
|
||||||
}
|
}
|
||||||
try {
|
}
|
||||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
}
|
||||||
} catch (Exception ex) {
|
try {
|
||||||
chatColor = ChatColor.DARK_PURPLE;
|
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor",
|
||||||
}
|
"DARK_PURPLE"));
|
||||||
}
|
} catch (Exception ex) {
|
||||||
|
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()
|
public boolean useLeases() {
|
||||||
{
|
return useLeases;
|
||||||
return enableRentSystem && enableEconomy();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean useLeases() {
|
public boolean useLegacyPermissions() {
|
||||||
return useLeases;
|
return legacyperms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowAdminsOnly() {
|
|
||||||
return adminsOnly;
|
|
||||||
}
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,34 +67,34 @@ import com.earth2me.essentials.Essentials;
|
|||||||
*/
|
*/
|
||||||
public class Residence extends JavaPlugin {
|
public class Residence extends JavaPlugin {
|
||||||
|
|
||||||
public static String bukkitver;
|
public static String bukkitver;
|
||||||
protected static ResidenceManager rmanager;
|
protected static ResidenceManager rmanager;
|
||||||
protected static SelectionManager smanager;
|
protected static SelectionManager smanager;
|
||||||
protected static PermissionManager gmanager;
|
protected static PermissionManager gmanager;
|
||||||
protected static ConfigManager cmanager;
|
protected static ConfigManager cmanager;
|
||||||
protected static ResidenceBlockListener blistener;
|
protected static ResidenceBlockListener blistener;
|
||||||
protected static ResidencePlayerListener plistener;
|
protected static ResidencePlayerListener plistener;
|
||||||
protected static ResidenceEntityListener elistener;
|
protected static ResidenceEntityListener elistener;
|
||||||
protected static TransactionManager tmanager;
|
protected static TransactionManager tmanager;
|
||||||
protected static PermissionListManager pmanager;
|
protected static PermissionListManager pmanager;
|
||||||
protected static LeaseManager leasemanager;
|
protected static LeaseManager leasemanager;
|
||||||
protected static WorldItemManager imanager;
|
protected static WorldItemManager imanager;
|
||||||
protected static WorldFlagManager wmanager;
|
protected static WorldFlagManager wmanager;
|
||||||
protected static RentManager rentmanager;
|
protected static RentManager rentmanager;
|
||||||
protected static ChatManager chatmanager;
|
protected static ChatManager chatmanager;
|
||||||
protected static Server server;
|
protected static Server server;
|
||||||
protected static HelpEntry helppages;
|
protected static HelpEntry helppages;
|
||||||
protected static Language language;
|
protected static Language language;
|
||||||
protected static EconomyInterface economy;
|
protected static EconomyInterface economy;
|
||||||
public final static int saveVersion = 1;
|
public final static int saveVersion = 1;
|
||||||
protected static File dataFolder;
|
protected static File dataFolder;
|
||||||
protected static int leaseBukkitId = -1;
|
protected static int leaseBukkitId = -1;
|
||||||
protected static int rentBukkitId = -1;
|
protected static int rentBukkitId = -1;
|
||||||
protected static int healBukkitId = -1;
|
protected static int healBukkitId = -1;
|
||||||
protected static int autosaveBukkitId = -1;
|
protected static int autosaveBukkitId = -1;
|
||||||
protected static boolean initsuccess = false;
|
protected static boolean initsuccess = false;
|
||||||
protected static List<String> resadminToggle;
|
protected static List<String> resadminToggle;
|
||||||
private final static String[] validLanguages = { "English", "Chinese" };
|
private final static String[] validLanguages = { "English", "Chinese" };
|
||||||
|
|
||||||
public static ResidenceBlockListener getBlockListener() {
|
public static ResidenceBlockListener getBlockListener() {
|
||||||
return blistener;
|
return blistener;
|
||||||
@@ -217,40 +216,38 @@ public class Residence extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean firstenable = true;
|
protected boolean firstenable = true;
|
||||||
|
|
||||||
protected Map<String, String> deleteConfirm;
|
protected Map<String, String> deleteConfirm;
|
||||||
|
|
||||||
private Runnable doHeals = new Runnable() {
|
private Runnable doHeals = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plistener.doHeals();
|
plistener.doHeals();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Runnable rentExpire = new Runnable() {
|
private Runnable rentExpire = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
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!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Runnable leaseExpire = new Runnable() {
|
private Runnable leaseExpire = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
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!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Runnable autoSave = new Runnable() {
|
private Runnable autoSave = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
||||||
|
+ ".yml");
|
||||||
try {
|
try {
|
||||||
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
|
||||||
+ ".yml");
|
|
||||||
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