mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -1,289 +1,267 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
package com.bekvon.bukkit.residence;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ConfigManager {
|
||||
protected String defaultGroup;
|
||||
protected boolean useLeases;
|
||||
protected boolean enableEconomy;
|
||||
protected String economySystem;
|
||||
protected boolean adminsOnly;
|
||||
protected boolean allowEmptyResidences;
|
||||
protected int infoToolId;
|
||||
protected int selectionToolId;
|
||||
protected boolean adminOps;
|
||||
protected String multiworldPlugin;
|
||||
protected boolean enableRentSystem;
|
||||
protected boolean leaseAutoRenew;
|
||||
protected int rentCheckInterval;
|
||||
protected int leaseCheckInterval;
|
||||
protected int autoSaveInt;
|
||||
protected boolean flagsInherit;
|
||||
protected ChatColor chatColor;
|
||||
protected boolean chatEnable;
|
||||
protected boolean actionBar;
|
||||
protected int minMoveUpdate;
|
||||
protected FlagPermissions globalCreatorDefaults;
|
||||
protected FlagPermissions globalResidenceDefaults;
|
||||
protected Map<String,FlagPermissions> globalGroupDefaults;
|
||||
protected String language;
|
||||
protected boolean preventBuildInRent;
|
||||
protected boolean stopOnSaveError;
|
||||
protected boolean legacyperms;
|
||||
protected String namefix;
|
||||
protected boolean showIntervalMessages;
|
||||
protected boolean spoutEnable;
|
||||
protected boolean enableLeaseMoneyAccount;
|
||||
protected boolean enableDebug;
|
||||
protected List<Integer> customContainers;
|
||||
protected List<Integer> customBothClick;
|
||||
protected List<Integer> customRightClick;
|
||||
private boolean enforceAreaInsideArea;
|
||||
protected String defaultGroup;
|
||||
protected boolean useLeases;
|
||||
protected boolean enableEconomy;
|
||||
protected String economySystem;
|
||||
protected boolean adminsOnly;
|
||||
protected boolean allowEmptyResidences;
|
||||
protected int infoToolId;
|
||||
protected int selectionToolId;
|
||||
protected boolean adminOps;
|
||||
protected String multiworldPlugin;
|
||||
protected boolean enableRentSystem;
|
||||
protected boolean leaseAutoRenew;
|
||||
protected int rentCheckInterval;
|
||||
protected int leaseCheckInterval;
|
||||
protected int autoSaveInt;
|
||||
protected boolean flagsInherit;
|
||||
protected ChatColor chatColor;
|
||||
protected boolean chatEnable;
|
||||
protected boolean actionBar;
|
||||
protected int minMoveUpdate;
|
||||
protected FlagPermissions globalCreatorDefaults;
|
||||
protected FlagPermissions globalResidenceDefaults;
|
||||
protected Map<String, FlagPermissions> globalGroupDefaults;
|
||||
protected String language;
|
||||
protected boolean preventBuildInRent;
|
||||
protected boolean stopOnSaveError;
|
||||
protected boolean legacyperms;
|
||||
protected String namefix;
|
||||
protected boolean showIntervalMessages;
|
||||
protected boolean spoutEnable;
|
||||
protected boolean enableLeaseMoneyAccount;
|
||||
protected boolean enableDebug;
|
||||
protected List<Integer> customContainers;
|
||||
protected List<Integer> customBothClick;
|
||||
protected List<Integer> customRightClick;
|
||||
private boolean enforceAreaInsideArea;
|
||||
|
||||
public ConfigManager(FileConfiguration config)
|
||||
{
|
||||
globalCreatorDefaults = new FlagPermissions();
|
||||
globalResidenceDefaults = new FlagPermissions();
|
||||
globalGroupDefaults = new HashMap<String,FlagPermissions>();
|
||||
this.load(config);
|
||||
}
|
||||
public ConfigManager(FileConfiguration config) {
|
||||
globalCreatorDefaults = new FlagPermissions();
|
||||
globalResidenceDefaults = new FlagPermissions();
|
||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||
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) {
|
||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||
language = config.getString("Global.Language","English");
|
||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault",true);
|
||||
legacyperms = config.getBoolean("Global.LegacyPermissions",false);
|
||||
namefix = config.getString("Global.ResidenceNameRegex",null);//"[^a-zA-Z0-9\\-\\_]"
|
||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||
if(node!=null)
|
||||
{
|
||||
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||
if(keys!=null)
|
||||
{
|
||||
for(String key: keys)
|
||||
{
|
||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
||||
} catch (Exception ex) {
|
||||
chatColor = ChatColor.DARK_PURPLE;
|
||||
}
|
||||
}
|
||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||
language = config.getString("Global.Language", "English");
|
||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault",
|
||||
config.getConfigurationSection("Global"));
|
||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault",
|
||||
config.getConfigurationSection("Global"));
|
||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||
namefix = config.getString("Global.ResidenceNameRegex", null);// "[^a-zA-Z0-9\\-\\_]"
|
||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||
ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||
if (node != null) {
|
||||
Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||
if (keys != null) {
|
||||
for (String key : keys) {
|
||||
globalGroupDefaults.put(
|
||||
key,
|
||||
FlagPermissions.parseFromConfigNode(key,
|
||||
config.getConfigurationSection("Global.GroupDefault")));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor",
|
||||
"DARK_PURPLE"));
|
||||
} catch (Exception ex) {
|
||||
chatColor = ChatColor.DARK_PURPLE;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean useLegacyPermissions()
|
||||
{
|
||||
return legacyperms;
|
||||
}
|
||||
public boolean preventRentModify() {
|
||||
return preventBuildInRent;
|
||||
}
|
||||
|
||||
public String getDefaultGroup() {
|
||||
return defaultGroup;
|
||||
}
|
||||
public boolean showIntervalMessages() {
|
||||
return showIntervalMessages;
|
||||
}
|
||||
|
||||
public String getResidenceNameRegex()
|
||||
{
|
||||
return namefix;
|
||||
}
|
||||
public boolean stopOnSaveError() {
|
||||
return stopOnSaveError;
|
||||
}
|
||||
|
||||
public boolean enableEconomy() {
|
||||
return enableEconomy && Residence.getEconomyManager()!=null;
|
||||
}
|
||||
public boolean useActionBar() {
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
public boolean enabledRentSystem()
|
||||
{
|
||||
return enableRentSystem && enableEconomy();
|
||||
}
|
||||
public boolean useLeases() {
|
||||
return useLeases;
|
||||
}
|
||||
|
||||
public boolean useLeases() {
|
||||
return useLeases;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public boolean useLegacyPermissions() {
|
||||
return legacyperms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
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.help.HelpEntry;
|
||||
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.ZipLibrary;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
/**
|
||||
@@ -68,34 +67,34 @@ import com.earth2me.essentials.Essentials;
|
||||
*/
|
||||
public class Residence extends JavaPlugin {
|
||||
|
||||
public static String bukkitver;
|
||||
protected static ResidenceManager rmanager;
|
||||
protected static SelectionManager smanager;
|
||||
protected static PermissionManager gmanager;
|
||||
protected static ConfigManager cmanager;
|
||||
protected static ResidenceBlockListener blistener;
|
||||
protected static ResidencePlayerListener plistener;
|
||||
protected static ResidenceEntityListener elistener;
|
||||
protected static TransactionManager tmanager;
|
||||
protected static PermissionListManager pmanager;
|
||||
protected static LeaseManager leasemanager;
|
||||
protected static WorldItemManager imanager;
|
||||
protected static WorldFlagManager wmanager;
|
||||
protected static RentManager rentmanager;
|
||||
protected static ChatManager chatmanager;
|
||||
protected static Server server;
|
||||
protected static HelpEntry helppages;
|
||||
protected static Language language;
|
||||
protected static EconomyInterface economy;
|
||||
public final static int saveVersion = 1;
|
||||
protected static File dataFolder;
|
||||
protected static int leaseBukkitId = -1;
|
||||
protected static int rentBukkitId = -1;
|
||||
protected static int healBukkitId = -1;
|
||||
protected static int autosaveBukkitId = -1;
|
||||
protected static boolean initsuccess = false;
|
||||
protected static List<String> resadminToggle;
|
||||
private final static String[] validLanguages = { "English", "Chinese" };
|
||||
public static String bukkitver;
|
||||
protected static ResidenceManager rmanager;
|
||||
protected static SelectionManager smanager;
|
||||
protected static PermissionManager gmanager;
|
||||
protected static ConfigManager cmanager;
|
||||
protected static ResidenceBlockListener blistener;
|
||||
protected static ResidencePlayerListener plistener;
|
||||
protected static ResidenceEntityListener elistener;
|
||||
protected static TransactionManager tmanager;
|
||||
protected static PermissionListManager pmanager;
|
||||
protected static LeaseManager leasemanager;
|
||||
protected static WorldItemManager imanager;
|
||||
protected static WorldFlagManager wmanager;
|
||||
protected static RentManager rentmanager;
|
||||
protected static ChatManager chatmanager;
|
||||
protected static Server server;
|
||||
protected static HelpEntry helppages;
|
||||
protected static Language language;
|
||||
protected static EconomyInterface economy;
|
||||
public final static int saveVersion = 1;
|
||||
protected static File dataFolder;
|
||||
protected static int leaseBukkitId = -1;
|
||||
protected static int rentBukkitId = -1;
|
||||
protected static int healBukkitId = -1;
|
||||
protected static int autosaveBukkitId = -1;
|
||||
protected static boolean initsuccess = false;
|
||||
protected static List<String> resadminToggle;
|
||||
private final static String[] validLanguages = { "English", "Chinese" };
|
||||
|
||||
public static ResidenceBlockListener getBlockListener() {
|
||||
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
|
||||
public void run() {
|
||||
plistener.doHeals();
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable rentExpire = new Runnable() {
|
||||
private Runnable rentExpire = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rentmanager.checkCurrentRents();
|
||||
if (cmanager.showIntervalMessages()) {
|
||||
System.out
|
||||
.println("[Residence] - Rent Expirations checked!");
|
||||
System.out.println("[Residence] - Rent Expirations checked!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable leaseExpire = new Runnable() {
|
||||
private Runnable leaseExpire = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
leasemanager.doExpirations();
|
||||
if (cmanager.showIntervalMessages()) {
|
||||
System.out
|
||||
.println("[Residence] - Lease Expirations checked!");
|
||||
System.out.println("[Residence] - Lease Expirations checked!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable autoSave = new Runnable() {
|
||||
private Runnable autoSave = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -258,9 +255,7 @@ public class Residence extends JavaPlugin {
|
||||
saveYml();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger("Minecraft").log(
|
||||
Level.SEVERE,
|
||||
"[Residence] 插件数据 保存 错误", ex);
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, "[Residence] 插件数据 保存 错误", ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -430,7 +425,7 @@ public class Residence extends JavaPlugin {
|
||||
if (this.getConfig().getInt("ResidenceVersion", 0) == 0) {
|
||||
this.writeDefaultConfigFromJar();
|
||||
this.getConfig().load("config.yml");
|
||||
System.out.println("[Residence] 配置文件不存在,写入默认配置文件.");
|
||||
this.getLogger().warning("配置文件不存在,写入默认配置文件.");
|
||||
}
|
||||
cmanager = new ConfigManager(this.getConfig());
|
||||
String multiworld = cmanager.getMultiworldPlugin();
|
||||
@@ -438,7 +433,7 @@ public class Residence extends JavaPlugin {
|
||||
Plugin plugin = server.getPluginManager().getPlugin(multiworld);
|
||||
if (plugin != null) {
|
||||
if (!plugin.isEnabled()) {
|
||||
System.out.println("[Residence] - 加载多世界插件: " + multiworld);
|
||||
this.getLogger().warning(" - 加载多世界插件: " + multiworld);
|
||||
server.getPluginManager().enablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
@@ -454,14 +449,14 @@ public class Residence extends JavaPlugin {
|
||||
this.writeDefaultLanguageFile(lang);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("[Residence] 语言文件升级失败: " + lang + ".yml");
|
||||
this.getLogger().warning("语言文件升级失败: " + lang + ".yml");
|
||||
helppages = new HelpEntry("");
|
||||
language = new Language();
|
||||
}
|
||||
}
|
||||
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
||||
+ ".yml");
|
||||
try {
|
||||
File langFile = new File(new File(dataFolder, "Language"), cmanager.getLanguage()
|
||||
+ ".yml");
|
||||
if (langFile.isFile()) {
|
||||
FileConfig langconfig = new FileConfig();
|
||||
langconfig.load(langFile);
|
||||
@@ -470,25 +465,27 @@ public class Residence extends JavaPlugin {
|
||||
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||
language = Language.parseText(langconfig, "Language");
|
||||
} else {
|
||||
System.out.println("[Residence] 语言文件不存在...");
|
||||
this.getLogger().warning("语言文件不存在...");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("[Residence] 语言文件载入失败: " + cmanager.getLanguage() + ".yml, 错误: "
|
||||
+ ex.getMessage());
|
||||
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
|
||||
helppages = new HelpEntry("");
|
||||
language = new Language();
|
||||
this.getLogger().warning("语言文件载入失败: " + cmanager.getLanguage() + ".yml 写入默认语言文件");
|
||||
this.writeDefaultLanguageFile(cmanager.getLanguage());
|
||||
FileConfig langconfig = new FileConfig();
|
||||
langconfig.load(langFile);
|
||||
helppages = HelpEntry.parseHelp(langconfig, "CommandHelp");
|
||||
HelpEntry.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
|
||||
language = Language.parseText(langconfig, "Language");
|
||||
}
|
||||
economy = null;
|
||||
if (this.getConfig().getBoolean("Global.EnableEconomy", false)) {
|
||||
System.out.println("[Residence] 扫描经济系统...");
|
||||
this.getLogger().info("扫描经济系统...");
|
||||
if (gmanager.getPermissionsPlugin() instanceof ResidenceVaultAdapter) {
|
||||
ResidenceVaultAdapter vault = (ResidenceVaultAdapter) gmanager
|
||||
.getPermissionsPlugin();
|
||||
if (vault.economyOK()) {
|
||||
economy = vault;
|
||||
System.out
|
||||
.println("[Residence] 发现 Vault 使用经济系统: " + vault.getEconomyName());
|
||||
this.getLogger().info("发现 Vault 使用经济系统: " + vault.getEconomyName());
|
||||
}
|
||||
}
|
||||
if (economy == null) {
|
||||
@@ -498,7 +495,7 @@ public class Residence extends JavaPlugin {
|
||||
this.loadEssentialsEconomy();
|
||||
}
|
||||
if (economy == null) {
|
||||
System.out.println("[Residence] 未找到经济系统...");
|
||||
this.getLogger().warning("未找到经济系统...");
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -529,7 +526,7 @@ public class Residence extends JavaPlugin {
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] 发现 WorldEdit");
|
||||
} else {
|
||||
smanager = new SelectionManager(server);
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] WorldEdit 未找到!");
|
||||
this.getLogger().warning("WorldEdit 未找到!");
|
||||
}
|
||||
|
||||
blistener = new ResidenceBlockListener();
|
||||
@@ -581,7 +578,7 @@ public class Residence extends JavaPlugin {
|
||||
} catch (Exception ex) {
|
||||
initsuccess = false;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
System.out.println("[Residence] - 初始化失败! 卸载插件! 错误:");
|
||||
this.getLogger().warning(" - 初始化失败! 卸载插件! 错误:");
|
||||
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 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) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, true);
|
||||
@@ -32,8 +40,7 @@ public class ConfigLoader extends FileConfig {
|
||||
|
||||
public ConfigLoader(Plugin p, String filename) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null,
|
||||
true);
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null, true);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (res) {
|
||||
p.saveResource(file.getName(), false);
|
||||
@@ -95,8 +72,35 @@ public class ConfigLoader extends FileConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveError(File file) {
|
||||
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
||||
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
||||
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;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml.
|
||||
* Note that this implementation is not synchronized.
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml. Note that this
|
||||
* implementation is not synchronized.
|
||||
*/
|
||||
public class FileConfig extends YamlConfiguration {
|
||||
|
||||
public static boolean cantload = false;
|
||||
|
||||
public static FileConfig init(File file) {
|
||||
return FileConfig.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public static FileConfig loadConfiguration(File file) {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
FileConfig config = new FileConfig();
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (FileNotFoundException ex) {
|
||||
cantload = true;
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
cantload = true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
cantload = true;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||
|
||||
@Override
|
||||
public void load(File file) throws FileNotFoundException, IOException,
|
||||
@@ -66,8 +72,7 @@ public class FileConfig extends YamlConfiguration {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Files.createParentDirs(file);
|
||||
String data = saveToString();
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||
Charsets.UTF_8);
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user