mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-20 18:32:49 +00:00
Merge remote branch 'remotes/origin/groupmanager'
This commit is contained in:
commit
00c87c0e60
|
@ -179,4 +179,5 @@ v 2.0:
|
||||||
- Unregister the worldsHolder as a service on a reload/shutdown instead of the whole plugin.
|
- Unregister the worldsHolder as a service on a reload/shutdown instead of the whole plugin.
|
||||||
- Update all code formatting to use tabs for indentation.
|
- Update all code formatting to use tabs for indentation.
|
||||||
- Stop using our own deprecated methods as we tell others to do.
|
- Stop using our own deprecated methods as we tell others to do.
|
||||||
- Finally remove all deprecated methods.
|
- Finally remove all deprecated methods.
|
||||||
|
- Re-initialize the WorldsHolder on a reload, as un-registering and re-registering a new holder means all plugins have to check for the new service on every quiery.
|
|
@ -235,13 +235,14 @@ groups:
|
||||||
g:towny_default:
|
g:towny_default:
|
||||||
permissions:
|
permissions:
|
||||||
- towny.chat.general
|
- towny.chat.general
|
||||||
|
- towny.chat.local
|
||||||
|
|
||||||
g:towny_builder:
|
g:towny_builder:
|
||||||
permissions:
|
permissions:
|
||||||
- towny.town.*
|
- towny.town.*
|
||||||
- towny.nation.*
|
- towny.nation.*
|
||||||
- towny.chat.tc
|
- towny.chat.town
|
||||||
- towny.chat.nc
|
- towny.chat.nation
|
||||||
- towny.wild.build.6
|
- towny.wild.build.6
|
||||||
- towny.wild.destroy.6
|
- towny.wild.destroy.6
|
||||||
- towny.wild.destroy.14
|
- towny.wild.destroy.14
|
||||||
|
|
|
@ -56,25 +56,7 @@ public class GroupManager extends JavaPlugin {
|
||||||
private Map<CommandSender, String> selectedWorlds = new HashMap<CommandSender, String>();
|
private Map<CommandSender, String> selectedWorlds = new HashMap<CommandSender, String>();
|
||||||
private WorldsHolder worldsHolder;
|
private WorldsHolder worldsHolder;
|
||||||
private boolean validateOnlinePlayer = true;
|
private boolean validateOnlinePlayer = true;
|
||||||
|
|
||||||
private String lastError = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the validateOnlinePlayer
|
|
||||||
*/
|
|
||||||
public boolean isValidateOnlinePlayer() {
|
|
||||||
|
|
||||||
return validateOnlinePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param validateOnlinePlayer the validateOnlinePlayer to set
|
|
||||||
*/
|
|
||||||
public void setValidateOnlinePlayer(boolean validateOnlinePlayer) {
|
|
||||||
|
|
||||||
this.validateOnlinePlayer = validateOnlinePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isLoaded = false;
|
private static boolean isLoaded = false;
|
||||||
protected GMConfiguration config;
|
protected GMConfiguration config;
|
||||||
|
|
||||||
|
@ -89,13 +71,28 @@ public class GroupManager extends JavaPlugin {
|
||||||
private OverloadedWorldHolder dataHolder = null;
|
private OverloadedWorldHolder dataHolder = null;
|
||||||
private AnjoPermissionsHandler permissionHandler = null;
|
private AnjoPermissionsHandler permissionHandler = null;
|
||||||
|
|
||||||
|
private String lastError = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
|
onDisable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
onEnable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable(boolean restarting) {
|
||||||
|
|
||||||
setLoaded(false);
|
setLoaded(false);
|
||||||
|
|
||||||
// Unregister this service.
|
if (!restarting) {
|
||||||
this.getServer().getServicesManager().unregister(this.worldsHolder);
|
// Unregister this service if we are shutting down.
|
||||||
|
this.getServer().getServicesManager().unregister(this.worldsHolder);
|
||||||
|
}
|
||||||
|
|
||||||
disableScheduler(); // Shutdown before we save, so it doesn't interfere.
|
disableScheduler(); // Shutdown before we save, so it doesn't interfere.
|
||||||
if (worldsHolder != null) {
|
if (worldsHolder != null) {
|
||||||
|
@ -118,18 +115,26 @@ public class GroupManager extends JavaPlugin {
|
||||||
// EXAMPLE: Custom code, here we just output some info so we can check that all is well
|
// EXAMPLE: Custom code, here we just output some info so we can check that all is well
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
|
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
|
||||||
GroupManager.logger.removeHandler(ch);
|
|
||||||
|
if (!restarting)
|
||||||
|
GroupManager.logger.removeHandler(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onEnable(boolean restarting) {
|
||||||
public void onEnable() {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
/*
|
||||||
|
* reset local variables.
|
||||||
|
*/
|
||||||
|
overloadedUsers = new HashMap<String, ArrayList<User>>();
|
||||||
|
selectedWorlds = new HashMap<CommandSender, String>();
|
||||||
lastError = "";
|
lastError = "";
|
||||||
|
|
||||||
GroupManager.logger.setUseParentHandlers(false);
|
if (!restarting) {
|
||||||
ch = new GMLoggerHandler();
|
GroupManager.logger.setUseParentHandlers(false);
|
||||||
GroupManager.logger.addHandler(ch);
|
ch = new GMLoggerHandler();
|
||||||
|
GroupManager.logger.addHandler(ch);
|
||||||
|
}
|
||||||
logger.setLevel(Level.ALL);
|
logger.setLevel(Level.ALL);
|
||||||
|
|
||||||
// Create the backup folder, if it doesn't exist.
|
// Create the backup folder, if it doesn't exist.
|
||||||
|
@ -138,7 +143,11 @@ public class GroupManager extends JavaPlugin {
|
||||||
prepareConfig();
|
prepareConfig();
|
||||||
// Load the global groups
|
// Load the global groups
|
||||||
globalGroups = new GlobalGroups(this);
|
globalGroups = new GlobalGroups(this);
|
||||||
worldsHolder = new WorldsHolder(this);
|
|
||||||
|
if (!restarting)
|
||||||
|
worldsHolder = new WorldsHolder(this);
|
||||||
|
else
|
||||||
|
worldsHolder.resetWorldsHolder();
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
if (worldsHolder == null) {
|
if (worldsHolder == null) {
|
||||||
|
@ -169,7 +178,9 @@ public class GroupManager extends JavaPlugin {
|
||||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||||
|
|
||||||
// Register as a service
|
// Register as a service
|
||||||
this.getServer().getServicesManager().register(WorldsHolder.class, this.worldsHolder, this, ServicePriority.Lowest);
|
if (!restarting)
|
||||||
|
this.getServer().getServicesManager().register(WorldsHolder.class, this.worldsHolder, this, ServicePriority.Lowest);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -222,6 +233,22 @@ public class GroupManager extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the validateOnlinePlayer
|
||||||
|
*/
|
||||||
|
public boolean isValidateOnlinePlayer() {
|
||||||
|
|
||||||
|
return validateOnlinePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param validateOnlinePlayer the validateOnlinePlayer to set
|
||||||
|
*/
|
||||||
|
public void setValidateOnlinePlayer(boolean validateOnlinePlayer) {
|
||||||
|
|
||||||
|
this.validateOnlinePlayer = validateOnlinePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLoaded() {
|
public static boolean isLoaded() {
|
||||||
|
|
||||||
|
@ -1633,11 +1660,10 @@ public class GroupManager extends JavaPlugin {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the last error as we are attempting a fresh load.
|
* Attempting a fresh load.
|
||||||
*/
|
*/
|
||||||
lastError = "";
|
onDisable(true);
|
||||||
onDisable();
|
onEnable(true);
|
||||||
onEnable();
|
|
||||||
|
|
||||||
sender.sendMessage("All settings and worlds were reloaded!");
|
sender.sendMessage("All settings and worlds were reloaded!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,19 @@ public class WorldsHolder {
|
||||||
public WorldsHolder(GroupManager plugin) {
|
public WorldsHolder(GroupManager plugin) {
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
resetWorldsHolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetWorldsHolder() {
|
||||||
|
|
||||||
|
mirrorsGroup = new HashMap<String, String>();
|
||||||
|
mirrorsUser = new HashMap<String, String>();
|
||||||
|
|
||||||
// Setup folders and check files exist for the primary world
|
// Setup folders and check files exist for the primary world
|
||||||
verifyFirstRun();
|
verifyFirstRun();
|
||||||
initialLoad();
|
initialLoad();
|
||||||
if (serverDefaultWorldName == null) {
|
if (serverDefaultWorldName == null)
|
||||||
throw new IllegalStateException("There is no default group! OMG!");
|
throw new IllegalStateException("There is no default group! OMG!");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialLoad() {
|
private void initialLoad() {
|
||||||
|
|
Loading…
Reference in a new issue