mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-17 20:11:21 +02:00
Update all code formatting to use tabs for indentation.
This commit is contained in:
@@ -177,3 +177,4 @@ v 2.0:
|
|||||||
- Expand GlobalGroups.yml and groups.yml to cover the VanishNoPacket plugin. Demonstrating how to negate and add nodes when using the '*' permission with inheritance.
|
- Expand GlobalGroups.yml and groups.yml to cover the VanishNoPacket plugin. Demonstrating how to negate and add nodes when using the '*' permission with inheritance.
|
||||||
- Fix silly nested throw/catch statements. Errors are now correctly generated when reading yml's.
|
- Fix silly nested throw/catch statements. Errors are now correctly generated when reading yml's.
|
||||||
- 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.
|
@@ -23,11 +23,13 @@ public class GMConfiguration {
|
|||||||
private YamlConfiguration GMconfig;
|
private YamlConfiguration GMconfig;
|
||||||
|
|
||||||
public GMConfiguration(GroupManager plugin) {
|
public GMConfiguration(GroupManager plugin) {
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
if (!plugin.getDataFolder().exists()) {
|
if (!plugin.getDataFolder().exists()) {
|
||||||
plugin.getDataFolder().mkdirs();
|
plugin.getDataFolder().mkdirs();
|
||||||
}
|
}
|
||||||
@@ -55,17 +57,21 @@ public class GMConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpOverride() {
|
public boolean isOpOverride() {
|
||||||
|
|
||||||
return GMconfig.getBoolean("settings.config.opOverrides", true);
|
return GMconfig.getBoolean("settings.config.opOverrides", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isToggleValidate() {
|
public boolean isToggleValidate() {
|
||||||
|
|
||||||
return GMconfig.getBoolean("settings.config.validate_toggle", true);
|
return GMconfig.getBoolean("settings.config.validate_toggle", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getMirrorsMap() {
|
public Map<String, Object> getMirrorsMap() {
|
||||||
|
|
||||||
// Try to fetch the old mirror path first
|
// Try to fetch the old mirror path first
|
||||||
if (GMconfig.isConfigurationSection("settings.permission.world.mirror")) {
|
if (GMconfig.isConfigurationSection("settings.permission.world.mirror")) {
|
||||||
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.permission.world.mirror").getValues(false);
|
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.permission.world.mirror").getValues(false);
|
||||||
} else if (GMconfig.isConfigurationSection("settings.mirrors")){
|
} else if (GMconfig.isConfigurationSection("settings.mirrors")) {
|
||||||
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.mirrors").getValues(false);
|
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.mirrors").getValues(false);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -73,10 +79,12 @@ public class GMConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSaveInterval() {
|
public Integer getSaveInterval() {
|
||||||
|
|
||||||
return GMconfig.getInt("settings.data.save.minutes", 10);
|
return GMconfig.getInt("settings.data.save.minutes", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getBackupDuration() {
|
public Integer getBackupDuration() {
|
||||||
|
|
||||||
return GMconfig.getInt("settings.data.save.hours", 24);
|
return GMconfig.getInt("settings.data.save.hours", 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,8 +24,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -42,6 +40,7 @@ public class GlobalGroups {
|
|||||||
protected File GlobalGroupsFile = null;
|
protected File GlobalGroupsFile = null;
|
||||||
|
|
||||||
public GlobalGroups(GroupManager plugin) {
|
public GlobalGroups(GroupManager plugin) {
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
@@ -50,6 +49,7 @@ public class GlobalGroups {
|
|||||||
* @return the haveGroupsChanged
|
* @return the haveGroupsChanged
|
||||||
*/
|
*/
|
||||||
public boolean haveGroupsChanged() {
|
public boolean haveGroupsChanged() {
|
||||||
|
|
||||||
if (this.haveGroupsChanged) {
|
if (this.haveGroupsChanged) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -65,12 +65,15 @@ public class GlobalGroups {
|
|||||||
* @return the timeStampGroups
|
* @return the timeStampGroups
|
||||||
*/
|
*/
|
||||||
public long getTimeStampGroups() {
|
public long getTimeStampGroups() {
|
||||||
|
|
||||||
return timeStampGroups;
|
return timeStampGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param timeStampGroups the timeStampGroups to set
|
* @param timeStampGroups the timeStampGroups to set
|
||||||
*/
|
*/
|
||||||
protected void setTimeStampGroups(long timeStampGroups) {
|
protected void setTimeStampGroups(long timeStampGroups) {
|
||||||
|
|
||||||
this.timeStampGroups = timeStampGroups;
|
this.timeStampGroups = timeStampGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +82,7 @@ public class GlobalGroups {
|
|||||||
* the haveGroupsChanged to set
|
* the haveGroupsChanged to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsChanged(boolean haveGroupsChanged) {
|
public void setGroupsChanged(boolean haveGroupsChanged) {
|
||||||
|
|
||||||
this.haveGroupsChanged = haveGroupsChanged;
|
this.haveGroupsChanged = haveGroupsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +122,7 @@ public class GlobalGroups {
|
|||||||
try {
|
try {
|
||||||
allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
//ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
throw new IllegalArgumentException("Your " + GlobalGroupsFile.getPath() + " file is invalid. See console for details.", ex);
|
throw new IllegalArgumentException("Your " + GlobalGroupsFile.getPath() + " file is invalid. See console for details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +192,7 @@ public class GlobalGroups {
|
|||||||
|
|
||||||
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
//GlobalGroupsFile = null;
|
// GlobalGroupsFile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +201,7 @@ public class GlobalGroups {
|
|||||||
|
|
||||||
public void writeGroups(boolean overwrite) {
|
public void writeGroups(boolean overwrite) {
|
||||||
|
|
||||||
//File GlobalGroupsFile = new File(plugin.getDataFolder(), "globalgroups.yml");
|
// File GlobalGroupsFile = new File(plugin.getDataFolder(), "globalgroups.yml");
|
||||||
|
|
||||||
if (haveGroupsChanged()) {
|
if (haveGroupsChanged()) {
|
||||||
if (overwrite || (!overwrite && (getTimeStampGroups() >= GlobalGroupsFile.lastModified()))) {
|
if (overwrite || (!overwrite && (getTimeStampGroups() >= GlobalGroupsFile.lastModified()))) {
|
||||||
@@ -242,7 +246,7 @@ public class GlobalGroups {
|
|||||||
}
|
}
|
||||||
removeGroupsChangedFlag();
|
removeGroupsChangedFlag();
|
||||||
} else {
|
} else {
|
||||||
//Check for newer file as no local changes.
|
// Check for newer file as no local changes.
|
||||||
if (getTimeStampGroups() < GlobalGroupsFile.lastModified()) {
|
if (getTimeStampGroups() < GlobalGroupsFile.lastModified()) {
|
||||||
System.out.print("Newer GlobalGroups file found (Loading changes)!");
|
System.out.print("Newer GlobalGroups file found (Loading changes)!");
|
||||||
// Backup GlobalGroups file
|
// Backup GlobalGroups file
|
||||||
@@ -255,6 +259,7 @@ public class GlobalGroups {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Backup the BlobalGroups file
|
* Backup the BlobalGroups file
|
||||||
|
*
|
||||||
* @param w
|
* @param w
|
||||||
*/
|
*/
|
||||||
private void backupFile() {
|
private void backupFile() {
|
||||||
@@ -273,6 +278,7 @@ public class GlobalGroups {
|
|||||||
* @param groupToAdd
|
* @param groupToAdd
|
||||||
*/
|
*/
|
||||||
public void addGroup(Group groupToAdd) {
|
public void addGroup(Group groupToAdd) {
|
||||||
|
|
||||||
// Create a new group if it already exists
|
// Create a new group if it already exists
|
||||||
if (hasGroup(groupToAdd.getName())) {
|
if (hasGroup(groupToAdd.getName())) {
|
||||||
groupToAdd = groupToAdd.clone();
|
groupToAdd = groupToAdd.clone();
|
||||||
@@ -291,6 +297,7 @@ public class GlobalGroups {
|
|||||||
* @param newGroup
|
* @param newGroup
|
||||||
*/
|
*/
|
||||||
public Group newGroup(Group newGroup) {
|
public Group newGroup(Group newGroup) {
|
||||||
|
|
||||||
// Push a new group
|
// Push a new group
|
||||||
if (!groups.containsKey(newGroup.getName().toLowerCase())) {
|
if (!groups.containsKey(newGroup.getName().toLowerCase())) {
|
||||||
groups.put(newGroup.getName().toLowerCase(), newGroup);
|
groups.put(newGroup.getName().toLowerCase(), newGroup);
|
||||||
@@ -306,6 +313,7 @@ public class GlobalGroups {
|
|||||||
* @param groupName
|
* @param groupName
|
||||||
*/
|
*/
|
||||||
public boolean removeGroup(String groupName) {
|
public boolean removeGroup(String groupName) {
|
||||||
|
|
||||||
// Push a new group
|
// Push a new group
|
||||||
if (groups.containsKey(groupName.toLowerCase())) {
|
if (groups.containsKey(groupName.toLowerCase())) {
|
||||||
groups.remove(groupName.toLowerCase());
|
groups.remove(groupName.toLowerCase());
|
||||||
@@ -324,6 +332,7 @@ public class GlobalGroups {
|
|||||||
* @return true if the group exists
|
* @return true if the group exists
|
||||||
*/
|
*/
|
||||||
public boolean hasGroup(String groupName) {
|
public boolean hasGroup(String groupName) {
|
||||||
|
|
||||||
return groups.containsKey(groupName.toLowerCase());
|
return groups.containsKey(groupName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,6 +388,7 @@ public class GlobalGroups {
|
|||||||
* @return List of all group names
|
* @return List of all group names
|
||||||
*/
|
*/
|
||||||
public List<String> getGroupsPermissions(String groupName) {
|
public List<String> getGroupsPermissions(String groupName) {
|
||||||
|
|
||||||
if (!hasGroup(groupName))
|
if (!hasGroup(groupName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -391,6 +401,7 @@ public class GlobalGroups {
|
|||||||
* @return Set containing all group names.
|
* @return Set containing all group names.
|
||||||
*/
|
*/
|
||||||
public Set<String> getGlobalGroups() {
|
public Set<String> getGlobalGroups() {
|
||||||
|
|
||||||
return groups.keySet();
|
return groups.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +409,7 @@ public class GlobalGroups {
|
|||||||
* Resets GlobalGroups.
|
* Resets GlobalGroups.
|
||||||
*/
|
*/
|
||||||
public void resetGlobalGroups() {
|
public void resetGlobalGroups() {
|
||||||
|
|
||||||
this.groups = new HashMap<String, Group>();
|
this.groups = new HashMap<String, Group>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,6 +418,7 @@ public class GlobalGroups {
|
|||||||
* @return a collection of the groups
|
* @return a collection of the groups
|
||||||
*/
|
*/
|
||||||
public Collection<Group> getGroupList() {
|
public Collection<Group> getGroupList() {
|
||||||
|
|
||||||
return groups.values();
|
return groups.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +429,7 @@ public class GlobalGroups {
|
|||||||
* @return Group object
|
* @return Group object
|
||||||
*/
|
*/
|
||||||
public Group getGroup(String groupName) {
|
public Group getGroup(String groupName) {
|
||||||
|
|
||||||
if (!hasGroup(groupName))
|
if (!hasGroup(groupName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -427,6 +441,7 @@ public class GlobalGroups {
|
|||||||
* @return the globalGroupsFile
|
* @return the globalGroupsFile
|
||||||
*/
|
*/
|
||||||
public File getGlobalGroupsFile() {
|
public File getGlobalGroupsFile() {
|
||||||
|
|
||||||
return GlobalGroupsFile;
|
return GlobalGroupsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,6 +449,7 @@ public class GlobalGroups {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeGroupsChangedFlag() {
|
public void removeGroupsChangedFlag() {
|
||||||
|
|
||||||
setGroupsChanged(false);
|
setGroupsChanged(false);
|
||||||
for (Group g : groups.values()) {
|
for (Group g : groups.values()) {
|
||||||
g.flagAsSaved();
|
g.flagAsSaved();
|
||||||
|
@@ -45,7 +45,6 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -68,6 +67,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
* @return the validateOnlinePlayer
|
* @return the validateOnlinePlayer
|
||||||
*/
|
*/
|
||||||
public boolean isValidateOnlinePlayer() {
|
public boolean isValidateOnlinePlayer() {
|
||||||
|
|
||||||
return validateOnlinePlayer;
|
return validateOnlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
* @param validateOnlinePlayer the validateOnlinePlayer to set
|
* @param validateOnlinePlayer the validateOnlinePlayer to set
|
||||||
*/
|
*/
|
||||||
public void setValidateOnlinePlayer(boolean validateOnlinePlayer) {
|
public void setValidateOnlinePlayer(boolean validateOnlinePlayer) {
|
||||||
|
|
||||||
this.validateOnlinePlayer = validateOnlinePlayer;
|
this.validateOnlinePlayer = validateOnlinePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
setLoaded(false);
|
setLoaded(false);
|
||||||
|
|
||||||
// Un-register this service.
|
// Un-register this service.
|
||||||
@@ -117,14 +119,13 @@ public class GroupManager extends JavaPlugin {
|
|||||||
BukkitPermissions = null;
|
BukkitPermissions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXAMPLE: Custom code, here we just output some info so we can check that
|
// EXAMPLE: Custom code, here we just output some info so we can check that all is well
|
||||||
// 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);
|
GroupManager.logger.removeHandler(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Override
|
// @Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -143,7 +144,6 @@ public class GroupManager extends JavaPlugin {
|
|||||||
globalGroups = new GlobalGroups(this);
|
globalGroups = new GlobalGroups(this);
|
||||||
worldsHolder = new WorldsHolder(this);
|
worldsHolder = new WorldsHolder(this);
|
||||||
|
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
if (worldsHolder == null) {
|
if (worldsHolder == null) {
|
||||||
GroupManager.logger.severe("Can't enable " + pdfFile.getName() + " version " + pdfFile.getVersion() + ", bad loading!");
|
GroupManager.logger.severe("Can't enable " + pdfFile.getName() + " version " + pdfFile.getVersion() + ", bad loading!");
|
||||||
@@ -154,15 +154,15 @@ public class GroupManager extends JavaPlugin {
|
|||||||
// Set a few defaults (reloads)
|
// Set a few defaults (reloads)
|
||||||
setLoaded(false);
|
setLoaded(false);
|
||||||
|
|
||||||
// Initialize the world listener and bukkit permissions to handle
|
// Initialize the world listener and bukkit permissions to handle events.
|
||||||
// events.
|
|
||||||
WorldEvents = new GMWorldListener(this);
|
WorldEvents = new GMWorldListener(this);
|
||||||
BukkitPermissions = new BukkitPermissions(this);
|
BukkitPermissions = new BukkitPermissions(this);
|
||||||
|
|
||||||
enableScheduler();
|
enableScheduler();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Schedule a Bukiit Permissions update for 1 tick later. All plugins
|
* Schedule a Bukiit Permissions update for 1 tick later. All
|
||||||
|
* plugins
|
||||||
* will be loaded by then
|
* will be loaded by then
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
/*
|
/*
|
||||||
* Throw an error so Bukkit knows about it.
|
* Throw an error so Bukkit knows about it.
|
||||||
*/
|
*/
|
||||||
throw new IllegalArgumentException(ex.getMessage(),ex);
|
throw new IllegalArgumentException(ex.getMessage(), ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,18 +229,22 @@ public class GroupManager extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLoaded() {
|
public static boolean isLoaded() {
|
||||||
|
|
||||||
return isLoaded;
|
return isLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLoaded(boolean isLoaded) {
|
public static void setLoaded(boolean isLoaded) {
|
||||||
|
|
||||||
GroupManager.isLoaded = isLoaded;
|
GroupManager.isLoaded = isLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getResourceAsStream(String fileName) {
|
public InputStream getResourceAsStream(String fileName) {
|
||||||
|
|
||||||
return this.getClassLoader().getResourceAsStream(fileName);
|
return this.getClassLoader().getResourceAsStream(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareFileFields() {
|
private void prepareFileFields() {
|
||||||
|
|
||||||
// configFile = new File(this.getDataFolder(), "config.yml");
|
// configFile = new File(this.getDataFolder(), "config.yml");
|
||||||
backupFolder = new File(this.getDataFolder(), "backup");
|
backupFolder = new File(this.getDataFolder(), "backup");
|
||||||
if (!backupFolder.exists()) {
|
if (!backupFolder.exists()) {
|
||||||
@@ -249,16 +253,19 @@ public class GroupManager extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void prepareConfig() {
|
private void prepareConfig() {
|
||||||
|
|
||||||
config = new GMConfiguration(this);
|
config = new GMConfiguration(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableScheduler() {
|
public void enableScheduler() {
|
||||||
|
|
||||||
if (worldsHolder != null) {
|
if (worldsHolder != null) {
|
||||||
disableScheduler();
|
disableScheduler();
|
||||||
commiter = new Runnable() {
|
commiter = new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
worldsHolder.saveChanges(false);
|
worldsHolder.saveChanges(false);
|
||||||
GroupManager.logger.log(Level.INFO, " Data files refreshed.");
|
GroupManager.logger.log(Level.INFO, " Data files refreshed.");
|
||||||
@@ -268,7 +275,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
scheduler = new ScheduledThreadPoolExecutor(1);
|
scheduler = new ScheduledThreadPoolExecutor(1);
|
||||||
long minutes = (long)getGMConfig().getSaveInterval();
|
long minutes = (long) getGMConfig().getSaveInterval();
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
|
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
|
||||||
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
|
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
|
||||||
@@ -280,6 +287,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableScheduler() {
|
public void disableScheduler() {
|
||||||
|
|
||||||
if (scheduler != null) {
|
if (scheduler != null) {
|
||||||
try {
|
try {
|
||||||
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
|
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
|
||||||
@@ -297,6 +305,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void commit() {
|
public void commit() {
|
||||||
|
|
||||||
if (worldsHolder != null) {
|
if (worldsHolder != null) {
|
||||||
worldsHolder.saveChanges();
|
worldsHolder.saveChanges();
|
||||||
}
|
}
|
||||||
@@ -307,10 +316,12 @@ public class GroupManager extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
|
||||||
worldsHolder.reloadAll();
|
worldsHolder.reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldsHolder getWorldsHolder() {
|
public WorldsHolder getWorldsHolder() {
|
||||||
|
|
||||||
return worldsHolder;
|
return worldsHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +332,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public AnjoPermissionsHandler getPermissionHandler() {
|
public AnjoPermissionsHandler getPermissionHandler() {
|
||||||
|
|
||||||
return worldsHolder.getDefaultWorld().getPermissionsHandler();
|
return worldsHolder.getDefaultWorld().getPermissionsHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +344,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public WorldDataHolder getData() {
|
public WorldDataHolder getData() {
|
||||||
|
|
||||||
return worldsHolder.getDefaultWorld();
|
return worldsHolder.getDefaultWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,6 +355,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public OverloadedWorldHolder getOverloadedClassData() {
|
public OverloadedWorldHolder getOverloadedClassData() {
|
||||||
|
|
||||||
return worldsHolder.getDefaultWorld();
|
return worldsHolder.getDefaultWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +369,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
@SuppressWarnings({ "deprecation" })
|
@SuppressWarnings({ "deprecation" })
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
|
|
||||||
boolean playerCanDo = false;
|
boolean playerCanDo = false;
|
||||||
boolean isConsole = false;
|
boolean isConsole = false;
|
||||||
Player senderPlayer = null, targetPlayer = null;
|
Player senderPlayer = null, targetPlayer = null;
|
||||||
@@ -362,7 +377,6 @@ public class GroupManager extends JavaPlugin {
|
|||||||
User senderUser = null;
|
User senderUser = null;
|
||||||
boolean isOpOverride = config.isOpOverride();
|
boolean isOpOverride = config.isOpOverride();
|
||||||
|
|
||||||
|
|
||||||
// DETERMINING PLAYER INFORMATION
|
// DETERMINING PLAYER INFORMATION
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
senderPlayer = (Player) sender;
|
senderPlayer = (Player) sender;
|
||||||
@@ -622,8 +636,8 @@ public class GroupManager extends JavaPlugin {
|
|||||||
auxUser.removeSubGroup(auxGroup);
|
auxUser.removeSubGroup(auxGroup);
|
||||||
sender.sendMessage(ChatColor.YELLOW + "You removed subgroup '" + auxGroup.getName() + "' from player '" + auxUser.getName() + "' list.");
|
sender.sendMessage(ChatColor.YELLOW + "You removed subgroup '" + auxGroup.getName() + "' from player '" + auxUser.getName() + "' list.");
|
||||||
|
|
||||||
//targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
// targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||||
//if (targetPlayer != null)
|
// if (targetPlayer != null)
|
||||||
// BukkitPermissions.updatePermissions(targetPlayer);
|
// BukkitPermissions.updatePermissions(targetPlayer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -881,7 +895,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
permissionResult = permissionHandler.checkFullGMPermission(auxUser, args[1], false);
|
permissionResult = permissionHandler.checkFullGMPermission(auxUser, args[1], false);
|
||||||
|
|
||||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
||||||
//No permissions found in GM so fall through and check Bukkit.
|
// No permissions found in GM so fall through and check Bukkit.
|
||||||
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
|
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1078,8 +1092,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Seems OK
|
// Seems OK
|
||||||
// auxString =
|
// auxString = permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||||
// permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
|
||||||
if (permissionResult.owner instanceof Group) {
|
if (permissionResult.owner instanceof Group) {
|
||||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||||
sender.sendMessage(ChatColor.RED + "The group inherits the a negation permission from group: " + permissionResult.owner.getName());
|
sender.sendMessage(ChatColor.RED + "The group inherits the a negation permission from group: " + permissionResult.owner.getName());
|
||||||
@@ -1300,7 +1313,8 @@ public class GroupManager extends JavaPlugin {
|
|||||||
if (!auxUser.isSubGroupsEmpty() && auxGroup2 == null)
|
if (!auxUser.isSubGroupsEmpty() && auxGroup2 == null)
|
||||||
for (Group subGroup : auxUser.subGroupListCopy()) {
|
for (Group subGroup : auxUser.subGroupListCopy()) {
|
||||||
auxGroup2 = permissionHandler.nextGroupWithVariable(subGroup, args[1]);
|
auxGroup2 = permissionHandler.nextGroupWithVariable(subGroup, args[1]);
|
||||||
if (auxGroup2 != null) continue;
|
if (auxGroup2 != null)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (auxGroup2 == null) {
|
if (auxGroup2 == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!");
|
sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!");
|
||||||
@@ -1974,7 +1988,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
if (Arrays.asList(this.getServer().getOfflinePlayers()).contains(Bukkit.getOfflinePlayer(playerName))) {
|
if (Arrays.asList(this.getServer().getOfflinePlayers()).contains(Bukkit.getOfflinePlayer(playerName))) {
|
||||||
match.add(playerName);
|
match.add(playerName);
|
||||||
} else {
|
} else {
|
||||||
//look for partial matches
|
// look for partial matches
|
||||||
for (OfflinePlayer offline : this.getServer().getOfflinePlayers()) {
|
for (OfflinePlayer offline : this.getServer().getOfflinePlayers()) {
|
||||||
if (offline.getName().toLowerCase().startsWith(playerName.toLowerCase()))
|
if (offline.getName().toLowerCase().startsWith(playerName.toLowerCase()))
|
||||||
match.add(offline.getName());
|
match.add(offline.getName());
|
||||||
@@ -2003,6 +2017,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
* @return the config
|
* @return the config
|
||||||
*/
|
*/
|
||||||
public GMConfiguration getGMConfig() {
|
public GMConfiguration getGMConfig() {
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2010,10 +2025,12 @@ public class GroupManager extends JavaPlugin {
|
|||||||
* @return the backupFolder
|
* @return the backupFolder
|
||||||
*/
|
*/
|
||||||
public File getBackupFolder() {
|
public File getBackupFolder() {
|
||||||
|
|
||||||
return backupFolder;
|
return backupFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GlobalGroups getGlobalGroups() {
|
public static GlobalGroups getGlobalGroups() {
|
||||||
|
|
||||||
return globalGroups;
|
return globalGroups;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -5,17 +5,18 @@ import org.anjocaido.groupmanager.GroupManager;
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Created by ElgarL
|
* Created by ElgarL
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BukkitPermsUpdateTask implements Runnable {
|
public class BukkitPermsUpdateTask implements Runnable {
|
||||||
|
|
||||||
public BukkitPermsUpdateTask() {
|
public BukkitPermsUpdateTask() {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// Signal loaded and update BukkitPermissions.
|
// Signal loaded and update BukkitPermissions.
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
GroupManager.BukkitPermissions.collectPermissions();
|
GroupManager.BukkitPermissions.collectPermissions();
|
||||||
|
@@ -24,21 +24,25 @@ public abstract class DataUnit {
|
|||||||
private ArrayList<String> permissions = new ArrayList<String>();
|
private ArrayList<String> permissions = new ArrayList<String>();
|
||||||
|
|
||||||
public DataUnit(WorldDataHolder dataSource, String name) {
|
public DataUnit(WorldDataHolder dataSource, String name) {
|
||||||
|
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataUnit(String name) {
|
public DataUnit(String name) {
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every group is matched only by their names and DataSources names.
|
* Every group is matched only by their names and DataSources names.
|
||||||
|
*
|
||||||
* @param o
|
* @param o
|
||||||
* @return true if they are equal. false if not.
|
* @return true if they are equal. false if not.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
|
||||||
if (o instanceof DataUnit) {
|
if (o instanceof DataUnit) {
|
||||||
DataUnit go = (DataUnit) o;
|
DataUnit go = (DataUnit) o;
|
||||||
if (this.getName().equalsIgnoreCase(go.getName())) {
|
if (this.getName().equalsIgnoreCase(go.getName())) {
|
||||||
@@ -61,6 +65,7 @@ public abstract class DataUnit {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
||||||
int hash = 5;
|
int hash = 5;
|
||||||
hash = 71 * hash + (this.name != null ? this.name.toLowerCase().hashCode() : 0);
|
hash = 71 * hash + (this.name != null ? this.name.toLowerCase().hashCode() : 0);
|
||||||
return hash;
|
return hash;
|
||||||
@@ -72,6 +77,7 @@ public abstract class DataUnit {
|
|||||||
* @param source
|
* @param source
|
||||||
*/
|
*/
|
||||||
public void setDataSource(WorldDataHolder source) {
|
public void setDataSource(WorldDataHolder source) {
|
||||||
|
|
||||||
this.dataSource = source;
|
this.dataSource = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +87,7 @@ public abstract class DataUnit {
|
|||||||
* @return the dataSource
|
* @return the dataSource
|
||||||
*/
|
*/
|
||||||
public WorldDataHolder getDataSource() {
|
public WorldDataHolder getDataSource() {
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +95,12 @@ public abstract class DataUnit {
|
|||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flagAsChanged() {
|
public void flagAsChanged() {
|
||||||
|
|
||||||
WorldDataHolder testSource = getDataSource();
|
WorldDataHolder testSource = getDataSource();
|
||||||
String source = "";
|
String source = "";
|
||||||
|
|
||||||
@@ -101,18 +110,20 @@ public abstract class DataUnit {
|
|||||||
source = testSource.getName();
|
source = testSource.getName();
|
||||||
|
|
||||||
GroupManager.logger.finest("DataSource: " + source + " - DataUnit: " + getName() + " flagged as changed!");
|
GroupManager.logger.finest("DataSource: " + source + " - DataUnit: " + getName() + " flagged as changed!");
|
||||||
// for(StackTraceElement st: Thread.currentThread().getStackTrace()){
|
// for(StackTraceElement st: Thread.currentThread().getStackTrace()){
|
||||||
// GroupManager.logger.finest(st.toString());
|
// GroupManager.logger.finest(st.toString());
|
||||||
// }
|
// }
|
||||||
sorted = false;
|
sorted = false;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChanged() {
|
public boolean isChanged() {
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flagAsSaved() {
|
public void flagAsSaved() {
|
||||||
|
|
||||||
WorldDataHolder testSource = getDataSource();
|
WorldDataHolder testSource = getDataSource();
|
||||||
String source = "";
|
String source = "";
|
||||||
|
|
||||||
@@ -126,10 +137,12 @@ public abstract class DataUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSamePermissionNode(String permission) {
|
public boolean hasSamePermissionNode(String permission) {
|
||||||
|
|
||||||
return permissions.contains(permission);
|
return permissions.contains(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPermission(String permission) {
|
public void addPermission(String permission) {
|
||||||
|
|
||||||
if (!hasSamePermissionNode(permission)) {
|
if (!hasSamePermissionNode(permission)) {
|
||||||
permissions.add(permission);
|
permissions.add(permission);
|
||||||
}
|
}
|
||||||
@@ -137,6 +150,7 @@ public abstract class DataUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removePermission(String permission) {
|
public boolean removePermission(String permission) {
|
||||||
|
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
return permissions.remove(permission);
|
return permissions.remove(permission);
|
||||||
}
|
}
|
||||||
@@ -144,17 +158,21 @@ public abstract class DataUnit {
|
|||||||
/**
|
/**
|
||||||
* Use this only to list permissions.
|
* Use this only to list permissions.
|
||||||
* You can't edit the permissions using the returned ArrayList instance
|
* You can't edit the permissions using the returned ArrayList instance
|
||||||
|
*
|
||||||
* @return a copy of the permission list
|
* @return a copy of the permission list
|
||||||
*/
|
*/
|
||||||
public List<String> getPermissionList() {
|
public List<String> getPermissionList() {
|
||||||
|
|
||||||
return Collections.unmodifiableList(permissions);
|
return Collections.unmodifiableList(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSorted() {
|
public boolean isSorted() {
|
||||||
|
|
||||||
return this.sorted;
|
return this.sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortPermissions() {
|
public void sortPermissions() {
|
||||||
|
|
||||||
if (!isSorted()) {
|
if (!isSorted()) {
|
||||||
Collections.sort(permissions, StringPermissionComparator.getInstance());
|
Collections.sort(permissions, StringPermissionComparator.getInstance());
|
||||||
sorted = true;
|
sorted = true;
|
||||||
|
@@ -25,7 +25,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
private ArrayList<String> inherits = new ArrayList<String>();
|
private ArrayList<String> inherits = new ArrayList<String>();
|
||||||
/**
|
/**
|
||||||
*This one holds the fields in INFO node.
|
* This one holds the fields in INFO node.
|
||||||
* like prefix = 'c'
|
* like prefix = 'c'
|
||||||
* or build = false
|
* or build = false
|
||||||
*/
|
*/
|
||||||
@@ -37,6 +37,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public Group(WorldDataHolder source, String name) {
|
public Group(WorldDataHolder source, String name) {
|
||||||
|
|
||||||
super(source, name);
|
super(source, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public Group(String name) {
|
public Group(String name) {
|
||||||
|
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,15 +57,18 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @return true if this is a global group
|
* @return true if this is a global group
|
||||||
*/
|
*/
|
||||||
public boolean isGlobal() {
|
public boolean isGlobal() {
|
||||||
|
|
||||||
return (getDataSource() == null);
|
return (getDataSource() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this group
|
* Clone this group
|
||||||
|
*
|
||||||
* @return a clone of this group
|
* @return a clone of this group
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Group clone() {
|
public Group clone() {
|
||||||
|
|
||||||
Group clone;
|
Group clone;
|
||||||
|
|
||||||
if (isGlobal()) {
|
if (isGlobal()) {
|
||||||
@@ -83,10 +88,12 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this to deliver a group from a different dataSource to another
|
* Use this to deliver a group from a different dataSource to another
|
||||||
|
*
|
||||||
* @param dataSource
|
* @param dataSource
|
||||||
* @return Null or Clone
|
* @return Null or Clone
|
||||||
*/
|
*/
|
||||||
public Group clone(WorldDataHolder dataSource) {
|
public Group clone(WorldDataHolder dataSource) {
|
||||||
|
|
||||||
if (dataSource.groupExists(this.getName())) {
|
if (dataSource.groupExists(this.getName())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -109,9 +116,11 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* an unmodifiable list of inherits list
|
* an unmodifiable list of inherits list
|
||||||
* You can't manage the list by here
|
* You can't manage the list by here
|
||||||
* Lol... version 0.6 had a problem because this.
|
* Lol... version 0.6 had a problem because this.
|
||||||
|
*
|
||||||
* @return the inherits
|
* @return the inherits
|
||||||
*/
|
*/
|
||||||
public List<String> getInherits() {
|
public List<String> getInherits() {
|
||||||
|
|
||||||
return Collections.unmodifiableList(inherits);
|
return Collections.unmodifiableList(inherits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +128,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @param inherit the inherits to set
|
* @param inherit the inherits to set
|
||||||
*/
|
*/
|
||||||
public void addInherits(Group inherit) {
|
public void addInherits(Group inherit) {
|
||||||
|
|
||||||
if (!isGlobal()) {
|
if (!isGlobal()) {
|
||||||
if (!this.getDataSource().groupExists(inherit.getName())) {
|
if (!this.getDataSource().groupExists(inherit.getName())) {
|
||||||
getDataSource().addGroup(inherit);
|
getDataSource().addGroup(inherit);
|
||||||
@@ -135,6 +145,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeInherits(String inherit) {
|
public boolean removeInherits(String inherit) {
|
||||||
|
|
||||||
if (!isGlobal()) {
|
if (!isGlobal()) {
|
||||||
if (this.inherits.contains(inherit.toLowerCase())) {
|
if (this.inherits.contains(inherit.toLowerCase())) {
|
||||||
this.inherits.remove(inherit.toLowerCase());
|
this.inherits.remove(inherit.toLowerCase());
|
||||||
@@ -150,6 +161,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @return the variables
|
* @return the variables
|
||||||
*/
|
*/
|
||||||
public GroupVariables getVariables() {
|
public GroupVariables getVariables() {
|
||||||
|
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +170,7 @@ public class Group extends DataUnit implements Cloneable {
|
|||||||
* @param varList
|
* @param varList
|
||||||
*/
|
*/
|
||||||
public void setVariables(Map<String, Object> varList) {
|
public void setVariables(Map<String, Object> varList) {
|
||||||
|
|
||||||
if (!isGlobal()) {
|
if (!isGlobal()) {
|
||||||
GroupVariables temp = new GroupVariables(this, varList);
|
GroupVariables temp = new GroupVariables(this, varList);
|
||||||
variables.clearVars();
|
variables.clearVars();
|
||||||
|
@@ -15,6 +15,7 @@ public class GroupVariables extends Variables implements Cloneable {
|
|||||||
private Group owner;
|
private Group owner;
|
||||||
|
|
||||||
public GroupVariables(Group owner) {
|
public GroupVariables(Group owner) {
|
||||||
|
|
||||||
super(owner);
|
super(owner);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
addVar("prefix", "");
|
addVar("prefix", "");
|
||||||
@@ -23,6 +24,7 @@ public class GroupVariables extends Variables implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GroupVariables(Group owner, Map<String, Object> varList) {
|
public GroupVariables(Group owner, Map<String, Object> varList) {
|
||||||
|
|
||||||
super(owner);
|
super(owner);
|
||||||
variables = varList;
|
variables = varList;
|
||||||
if (variables.get("prefix") == null) {
|
if (variables.get("prefix") == null) {
|
||||||
@@ -46,9 +48,11 @@ public class GroupVariables extends Variables implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A clone of all vars here.
|
* A clone of all vars here.
|
||||||
|
*
|
||||||
* @return GroupVariables clone
|
* @return GroupVariables clone
|
||||||
*/
|
*/
|
||||||
protected GroupVariables clone(Group newOwner) {
|
protected GroupVariables clone(Group newOwner) {
|
||||||
|
|
||||||
GroupVariables clone = new GroupVariables(newOwner);
|
GroupVariables clone = new GroupVariables(newOwner);
|
||||||
for (String key : variables.keySet()) {
|
for (String key : variables.keySet()) {
|
||||||
clone.variables.put(key, variables.get(key));
|
clone.variables.put(key, variables.get(key));
|
||||||
@@ -59,10 +63,12 @@ public class GroupVariables extends Variables implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a var from the list
|
* Remove a var from the list
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeVar(String name) {
|
public void removeVar(String name) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.variables.remove(name);
|
this.variables.remove(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -82,6 +88,7 @@ public class GroupVariables extends Variables implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Group getOwner() {
|
public Group getOwner() {
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@ import java.util.Map;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author gabrielcouto/ElgarL
|
* @author gabrielcouto/ElgarL
|
||||||
@@ -40,6 +39,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public User(WorldDataHolder source, String name) {
|
public User(WorldDataHolder source, String name) {
|
||||||
|
|
||||||
super(source, name);
|
super(source, name);
|
||||||
this.group = source.getDefaultGroup().getName();
|
this.group = source.getDefaultGroup().getName();
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public User clone() {
|
public User clone() {
|
||||||
|
|
||||||
User clone = new User(getDataSource(), this.getName());
|
User clone = new User(getDataSource(), this.getName());
|
||||||
clone.group = this.group;
|
clone.group = this.group;
|
||||||
for (String perm : this.getPermissionList()) {
|
for (String perm : this.getPermissionList()) {
|
||||||
@@ -67,6 +68,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* @return null if given dataSource already contains the same user
|
* @return null if given dataSource already contains the same user
|
||||||
*/
|
*/
|
||||||
public User clone(WorldDataHolder dataSource) {
|
public User clone(WorldDataHolder dataSource) {
|
||||||
|
|
||||||
if (dataSource.isUserDeclared(this.getName())) {
|
if (dataSource.isUserDeclared(this.getName())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -85,6 +87,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Group getGroup() {
|
public Group getGroup() {
|
||||||
|
|
||||||
Group result = getDataSource().getGroup(group);
|
Group result = getDataSource().getGroup(group);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
this.setGroup(getDataSource().getDefaultGroup());
|
this.setGroup(getDataSource().getDefaultGroup());
|
||||||
@@ -97,6 +100,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* @return the group
|
* @return the group
|
||||||
*/
|
*/
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
|
|
||||||
Group result = getDataSource().getGroup(group);
|
Group result = getDataSource().getGroup(group);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
group = getDataSource().getDefaultGroup().getName();
|
group = getDataSource().getDefaultGroup().getName();
|
||||||
@@ -110,6 +114,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setGroup(String group) {
|
public void setGroup(String group) {
|
||||||
|
|
||||||
this.group = group;
|
this.group = group;
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded())
|
||||||
@@ -122,6 +127,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* the group to set
|
* the group to set
|
||||||
*/
|
*/
|
||||||
public void setGroup(Group group) {
|
public void setGroup(Group group) {
|
||||||
|
|
||||||
setGroup(group, true);
|
setGroup(group, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +137,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setGroup(Group group, Boolean updatePerms) {
|
public void setGroup(Group group, Boolean updatePerms) {
|
||||||
|
|
||||||
if (!this.getDataSource().groupExists(group.getName())) {
|
if (!this.getDataSource().groupExists(group.getName())) {
|
||||||
getDataSource().addGroup(group);
|
getDataSource().addGroup(group);
|
||||||
}
|
}
|
||||||
@@ -157,6 +164,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean addSubGroup(Group subGroup) {
|
public boolean addSubGroup(Group subGroup) {
|
||||||
|
|
||||||
// Don't allow adding a subgroup if it's already set as the primary.
|
// Don't allow adding a subgroup if it's already set as the primary.
|
||||||
if (this.group.equalsIgnoreCase(subGroup.getName())) {
|
if (this.group.equalsIgnoreCase(subGroup.getName())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -185,18 +193,22 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int subGroupsSize() {
|
public int subGroupsSize() {
|
||||||
|
|
||||||
return subGroups.size();
|
return subGroups.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubGroupsEmpty() {
|
public boolean isSubGroupsEmpty() {
|
||||||
|
|
||||||
return subGroups.isEmpty();
|
return subGroups.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsSubGroup(Group subGroup) {
|
public boolean containsSubGroup(Group subGroup) {
|
||||||
|
|
||||||
return subGroups.contains(subGroup.getName());
|
return subGroups.contains(subGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeSubGroup(Group subGroup) {
|
public boolean removeSubGroup(Group subGroup) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (subGroups.remove(subGroup.getName())) {
|
if (subGroups.remove(subGroup.getName())) {
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
@@ -212,6 +224,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Group> subGroupListCopy() {
|
public ArrayList<Group> subGroupListCopy() {
|
||||||
|
|
||||||
ArrayList<Group> val = new ArrayList<Group>();
|
ArrayList<Group> val = new ArrayList<Group>();
|
||||||
for (String gstr : subGroups) {
|
for (String gstr : subGroups) {
|
||||||
Group g = getDataSource().getGroup(gstr);
|
Group g = getDataSource().getGroup(gstr);
|
||||||
@@ -225,6 +238,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> subGroupListStringCopy() {
|
public ArrayList<String> subGroupListStringCopy() {
|
||||||
|
|
||||||
return new ArrayList<String>(subGroups);
|
return new ArrayList<String>(subGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +246,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* @return the variables
|
* @return the variables
|
||||||
*/
|
*/
|
||||||
public UserVariables getVariables() {
|
public UserVariables getVariables() {
|
||||||
|
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +255,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
* @param varList
|
* @param varList
|
||||||
*/
|
*/
|
||||||
public void setVariables(Map<String, Object> varList) {
|
public void setVariables(Map<String, Object> varList) {
|
||||||
|
|
||||||
//UserVariables temp = new UserVariables(this, varList);
|
//UserVariables temp = new UserVariables(this, varList);
|
||||||
variables.clearVars();
|
variables.clearVars();
|
||||||
for (String key : varList.keySet()) {
|
for (String key : varList.keySet()) {
|
||||||
@@ -254,6 +270,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public User updatePlayer(Player player) {
|
public User updatePlayer(Player player) {
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
bukkitPlayer = player;
|
bukkitPlayer = player;
|
||||||
}
|
}
|
||||||
@@ -261,6 +278,7 @@ public class User extends DataUnit implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getBukkitPlayer() {
|
public Player getBukkitPlayer() {
|
||||||
|
|
||||||
if (bukkitPlayer == null) {
|
if (bukkitPlayer == null) {
|
||||||
bukkitPlayer = Bukkit.getPlayer(this.getName());
|
bukkitPlayer = Bukkit.getPlayer(this.getName());
|
||||||
}
|
}
|
||||||
|
@@ -15,11 +15,13 @@ public class UserVariables extends Variables {
|
|||||||
private User owner;
|
private User owner;
|
||||||
|
|
||||||
public UserVariables(User owner) {
|
public UserVariables(User owner) {
|
||||||
|
|
||||||
super(owner);
|
super(owner);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserVariables(User owner, Map<String, Object> varList) {
|
public UserVariables(User owner, Map<String, Object> varList) {
|
||||||
|
|
||||||
super(owner);
|
super(owner);
|
||||||
this.variables = varList;
|
this.variables = varList;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@@ -27,9 +29,11 @@ public class UserVariables extends Variables {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A clone of all vars here.
|
* A clone of all vars here.
|
||||||
|
*
|
||||||
* @return UserVariables clone
|
* @return UserVariables clone
|
||||||
*/
|
*/
|
||||||
protected UserVariables clone(User newOwner) {
|
protected UserVariables clone(User newOwner) {
|
||||||
|
|
||||||
UserVariables clone = new UserVariables(newOwner);
|
UserVariables clone = new UserVariables(newOwner);
|
||||||
for (String key : variables.keySet()) {
|
for (String key : variables.keySet()) {
|
||||||
clone.variables.put(key, variables.get(key));
|
clone.variables.put(key, variables.get(key));
|
||||||
@@ -43,6 +47,7 @@ public class UserVariables extends Variables {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public User getOwner() {
|
public User getOwner() {
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*A class that holds variables of a user/group.
|
* A class that holds variables of a user/group.
|
||||||
* In groups, it holds the contents of INFO node.
|
* In groups, it holds the contents of INFO node.
|
||||||
* Like:
|
* Like:
|
||||||
* prefix
|
* prefix
|
||||||
@@ -24,6 +24,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
protected Map<String, Object> variables = new HashMap<String, Object>();
|
protected Map<String, Object> variables = new HashMap<String, Object>();
|
||||||
|
|
||||||
public Variables(DataUnit owner) {
|
public Variables(DataUnit owner) {
|
||||||
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,10 +33,12 @@ public abstract class Variables implements Cloneable {
|
|||||||
* examples:
|
* examples:
|
||||||
* addVar("build",true);
|
* addVar("build",true);
|
||||||
* addVar("prefix","c");
|
* addVar("prefix","c");
|
||||||
|
*
|
||||||
* @param name key name of the var
|
* @param name key name of the var
|
||||||
* @param o the object value of the var
|
* @param o the object value of the var
|
||||||
*/
|
*/
|
||||||
public void addVar(String name, Object o) {
|
public void addVar(String name, Object o) {
|
||||||
|
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -48,19 +51,23 @@ public abstract class Variables implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the object inside the var
|
* Returns the object inside the var
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return a Object if exists. null if doesn't exists
|
* @return a Object if exists. null if doesn't exists
|
||||||
*/
|
*/
|
||||||
public Object getVarObject(String name) {
|
public Object getVarObject(String name) {
|
||||||
|
|
||||||
return variables.get(name);
|
return variables.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the String value for the given var name
|
* Get the String value for the given var name
|
||||||
|
*
|
||||||
* @param name the var key name
|
* @param name the var key name
|
||||||
* @return "" if null. or the toString() value of object
|
* @return "" if null. or the toString() value of object
|
||||||
*/
|
*/
|
||||||
public String getVarString(String name) {
|
public String getVarString(String name) {
|
||||||
|
|
||||||
Object o = variables.get(name);
|
Object o = variables.get(name);
|
||||||
try {
|
try {
|
||||||
return o == null ? "" : o.toString();
|
return o == null ? "" : o.toString();
|
||||||
@@ -75,6 +82,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
* @return false if null. or a Boolean.parseBoolean of the string
|
* @return false if null. or a Boolean.parseBoolean of the string
|
||||||
*/
|
*/
|
||||||
public Boolean getVarBoolean(String name) {
|
public Boolean getVarBoolean(String name) {
|
||||||
|
|
||||||
Object o = variables.get(name);
|
Object o = variables.get(name);
|
||||||
try {
|
try {
|
||||||
return o == null ? false : Boolean.parseBoolean(o.toString());
|
return o == null ? false : Boolean.parseBoolean(o.toString());
|
||||||
@@ -89,6 +97,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
* @return -1 if null. or a parseInt of the string
|
* @return -1 if null. or a parseInt of the string
|
||||||
*/
|
*/
|
||||||
public Integer getVarInteger(String name) {
|
public Integer getVarInteger(String name) {
|
||||||
|
|
||||||
Object o = variables.get(name);
|
Object o = variables.get(name);
|
||||||
try {
|
try {
|
||||||
return o == null ? -1 : Integer.parseInt(o.toString());
|
return o == null ? -1 : Integer.parseInt(o.toString());
|
||||||
@@ -103,6 +112,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
* @return -1 if null. or a parseDouble of the string
|
* @return -1 if null. or a parseDouble of the string
|
||||||
*/
|
*/
|
||||||
public Double getVarDouble(String name) {
|
public Double getVarDouble(String name) {
|
||||||
|
|
||||||
Object o = variables.get(name);
|
Object o = variables.get(name);
|
||||||
try {
|
try {
|
||||||
return o == null ? -1.0D : Double.parseDouble(o.toString());
|
return o == null ? -1.0D : Double.parseDouble(o.toString());
|
||||||
@@ -113,34 +123,42 @@ public abstract class Variables implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* All variable keys this is holding
|
* All variable keys this is holding
|
||||||
|
*
|
||||||
* @return Set of all variable names.
|
* @return Set of all variable names.
|
||||||
*/
|
*/
|
||||||
public Set<String> getVarKeyList() {
|
public Set<String> getVarKeyList() {
|
||||||
|
|
||||||
return variables.keySet();
|
return variables.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verify is a var exists
|
* verify is a var exists
|
||||||
|
*
|
||||||
* @param name the key name of the var
|
* @param name the key name of the var
|
||||||
* @return true if that var exists
|
* @return true if that var exists
|
||||||
*/
|
*/
|
||||||
public boolean hasVar(String name) {
|
public boolean hasVar(String name) {
|
||||||
|
|
||||||
return variables.containsKey(name);
|
return variables.containsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the quantity of vars this is holding
|
* Returns the quantity of vars this is holding
|
||||||
|
*
|
||||||
* @return the number of vars
|
* @return the number of vars
|
||||||
*/
|
*/
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
|
|
||||||
return variables.size();
|
return variables.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a var from the list
|
* Remove a var from the list
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public void removeVar(String name) {
|
public void removeVar(String name) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
variables.remove(name);
|
variables.remove(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -149,6 +167,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Object parseVariableValue(String value) {
|
public static Object parseVariableValue(String value) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Integer i = Integer.parseInt(value);
|
Integer i = Integer.parseInt(value);
|
||||||
return i;
|
return i;
|
||||||
@@ -169,6 +188,7 @@ public abstract class Variables implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearVars() {
|
public void clearVars() {
|
||||||
|
|
||||||
variables.clear();
|
variables.clear();
|
||||||
owner.flagAsChanged();
|
owner.flagAsChanged();
|
||||||
}
|
}
|
||||||
@@ -177,10 +197,12 @@ public abstract class Variables implements Cloneable {
|
|||||||
* @return the owner
|
* @return the owner
|
||||||
*/
|
*/
|
||||||
public DataUnit getOwner() {
|
public DataUnit getOwner() {
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
|
||||||
return variables.isEmpty();
|
return variables.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This container holds all Groups loaded from the relevant groupsFile.
|
* This container holds all Groups loaded from the relevant groupsFile.
|
||||||
*
|
*
|
||||||
@@ -31,9 +29,11 @@ public class GroupsDataHolder {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
protected GroupsDataHolder() {
|
protected GroupsDataHolder() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataSource(WorldDataHolder dataSource) {
|
public void setDataSource(WorldDataHolder dataSource) {
|
||||||
|
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
//push this data source to the users, so they pull the correct groups data.
|
//push this data source to the users, so they pull the correct groups data.
|
||||||
for (Group group : groups.values())
|
for (Group group : groups.values())
|
||||||
@@ -44,6 +44,7 @@ public class GroupsDataHolder {
|
|||||||
* @return the defaultGroup
|
* @return the defaultGroup
|
||||||
*/
|
*/
|
||||||
public Group getDefaultGroup() {
|
public Group getDefaultGroup() {
|
||||||
|
|
||||||
return defaultGroup;
|
return defaultGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ public class GroupsDataHolder {
|
|||||||
* @param defaultGroup the defaultGroup to set
|
* @param defaultGroup the defaultGroup to set
|
||||||
*/
|
*/
|
||||||
public void setDefaultGroup(Group defaultGroup) {
|
public void setDefaultGroup(Group defaultGroup) {
|
||||||
|
|
||||||
this.defaultGroup = defaultGroup;
|
this.defaultGroup = defaultGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +60,7 @@ public class GroupsDataHolder {
|
|||||||
* @return the groups
|
* @return the groups
|
||||||
*/
|
*/
|
||||||
public Map<String, Group> getGroups() {
|
public Map<String, Group> getGroups() {
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +68,7 @@ public class GroupsDataHolder {
|
|||||||
* @param groups the groups to set
|
* @param groups the groups to set
|
||||||
*/
|
*/
|
||||||
public void setGroups(Map<String, Group> groups) {
|
public void setGroups(Map<String, Group> groups) {
|
||||||
|
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ public class GroupsDataHolder {
|
|||||||
* @return the groupsFile
|
* @return the groupsFile
|
||||||
*/
|
*/
|
||||||
public File getGroupsFile() {
|
public File getGroupsFile() {
|
||||||
|
|
||||||
return groupsFile;
|
return groupsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +84,7 @@ public class GroupsDataHolder {
|
|||||||
* @param groupsFile the groupsFile to set
|
* @param groupsFile the groupsFile to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsFile(File groupsFile) {
|
public void setGroupsFile(File groupsFile) {
|
||||||
|
|
||||||
this.groupsFile = groupsFile;
|
this.groupsFile = groupsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +92,7 @@ public class GroupsDataHolder {
|
|||||||
* @return the haveGroupsChanged
|
* @return the haveGroupsChanged
|
||||||
*/
|
*/
|
||||||
public boolean HaveGroupsChanged() {
|
public boolean HaveGroupsChanged() {
|
||||||
|
|
||||||
return haveGroupsChanged;
|
return haveGroupsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +100,7 @@ public class GroupsDataHolder {
|
|||||||
* @param haveGroupsChanged the haveGroupsChanged to set
|
* @param haveGroupsChanged the haveGroupsChanged to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsChanged(boolean haveGroupsChanged) {
|
public void setGroupsChanged(boolean haveGroupsChanged) {
|
||||||
|
|
||||||
this.haveGroupsChanged = haveGroupsChanged;
|
this.haveGroupsChanged = haveGroupsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +108,7 @@ public class GroupsDataHolder {
|
|||||||
* @return the timeStampGroups
|
* @return the timeStampGroups
|
||||||
*/
|
*/
|
||||||
public long getTimeStampGroups() {
|
public long getTimeStampGroups() {
|
||||||
|
|
||||||
return timeStampGroups;
|
return timeStampGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +116,7 @@ public class GroupsDataHolder {
|
|||||||
* @param timeStampGroups the timeStampGroups to set
|
* @param timeStampGroups the timeStampGroups to set
|
||||||
*/
|
*/
|
||||||
public void setTimeStampGroups(long timeStampGroups) {
|
public void setTimeStampGroups(long timeStampGroups) {
|
||||||
|
|
||||||
this.timeStampGroups = timeStampGroups;
|
this.timeStampGroups = timeStampGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
* @param ph
|
* @param ph
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder(WorldDataHolder ph) {
|
public OverloadedWorldHolder(WorldDataHolder ph) {
|
||||||
|
|
||||||
super(ph.getName());
|
super(ph.getName());
|
||||||
this.setGroupsFile(ph.getGroupsFile());
|
this.setGroupsFile(ph.getGroupsFile());
|
||||||
this.setUsersFile(ph.getUsersFile());
|
this.setUsersFile(ph.getUsersFile());
|
||||||
@@ -41,6 +42,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public User getUser(String userName) {
|
public User getUser(String userName) {
|
||||||
|
|
||||||
//OVERLOADED CODE
|
//OVERLOADED CODE
|
||||||
String userNameLowered = userName.toLowerCase();
|
String userNameLowered = userName.toLowerCase();
|
||||||
if (overloadedUsers.containsKey(userNameLowered)) {
|
if (overloadedUsers.containsKey(userNameLowered)) {
|
||||||
@@ -61,6 +63,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addUser(User theUser) {
|
public void addUser(User theUser) {
|
||||||
|
|
||||||
if (theUser.getDataSource() != this) {
|
if (theUser.getDataSource() != this) {
|
||||||
theUser = theUser.clone(this);
|
theUser = theUser.clone(this);
|
||||||
}
|
}
|
||||||
@@ -89,6 +92,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean removeUser(String userName) {
|
public boolean removeUser(String userName) {
|
||||||
|
|
||||||
//OVERLOADED CODE
|
//OVERLOADED CODE
|
||||||
if (overloadedUsers.containsKey(userName.toLowerCase())) {
|
if (overloadedUsers.containsKey(userName.toLowerCase())) {
|
||||||
overloadedUsers.remove(userName.toLowerCase());
|
overloadedUsers.remove(userName.toLowerCase());
|
||||||
@@ -105,6 +109,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeGroup(String groupName) {
|
public boolean removeGroup(String groupName) {
|
||||||
|
|
||||||
if (groupName.equals(getDefaultGroup())) {
|
if (groupName.equals(getDefaultGroup())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -140,6 +145,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<User> getUserList() {
|
public Collection<User> getUserList() {
|
||||||
|
|
||||||
Collection<User> overloadedList = new ArrayList<User>();
|
Collection<User> overloadedList = new ArrayList<User>();
|
||||||
Collection<User> normalList = getUsers().values();
|
Collection<User> normalList = getUsers().values();
|
||||||
for (User u : normalList) {
|
for (User u : normalList) {
|
||||||
@@ -158,6 +164,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
* @return true if user is overloaded.
|
* @return true if user is overloaded.
|
||||||
*/
|
*/
|
||||||
public boolean isOverloaded(String userName) {
|
public boolean isOverloaded(String userName) {
|
||||||
|
|
||||||
return overloadedUsers.containsKey(userName.toLowerCase());
|
return overloadedUsers.containsKey(userName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +173,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
* @param userName
|
* @param userName
|
||||||
*/
|
*/
|
||||||
public void overloadUser(String userName) {
|
public void overloadUser(String userName) {
|
||||||
|
|
||||||
if (!isOverloaded(userName)) {
|
if (!isOverloaded(userName)) {
|
||||||
User theUser = getUser(userName);
|
User theUser = getUser(userName);
|
||||||
theUser = theUser.clone();
|
theUser = theUser.clone();
|
||||||
@@ -181,6 +189,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
* @param userName
|
* @param userName
|
||||||
*/
|
*/
|
||||||
public void removeOverload(String userName) {
|
public void removeOverload(String userName) {
|
||||||
|
|
||||||
overloadedUsers.remove(userName.toLowerCase());
|
overloadedUsers.remove(userName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +202,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
|
|||||||
* @return user object
|
* @return user object
|
||||||
*/
|
*/
|
||||||
public User surpassOverload(String userName) {
|
public User surpassOverload(String userName) {
|
||||||
|
|
||||||
if (!isOverloaded(userName)) {
|
if (!isOverloaded(userName)) {
|
||||||
return getUser(userName);
|
return getUser(userName);
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.anjocaido.groupmanager.data.User;
|
import org.anjocaido.groupmanager.data.User;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This container holds all Users loaded from the relevant usersFile.
|
* This container holds all Users loaded from the relevant usersFile.
|
||||||
*
|
*
|
||||||
@@ -30,9 +28,11 @@ public class UsersDataHolder {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
protected UsersDataHolder() {
|
protected UsersDataHolder() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataSource(WorldDataHolder dataSource) {
|
public void setDataSource(WorldDataHolder dataSource) {
|
||||||
|
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
//push this data source to the users, so they pull the correct groups data.
|
//push this data source to the users, so they pull the correct groups data.
|
||||||
for (User user : users.values())
|
for (User user : users.values())
|
||||||
@@ -44,6 +44,7 @@ public class UsersDataHolder {
|
|||||||
* @return the users
|
* @return the users
|
||||||
*/
|
*/
|
||||||
public Map<String, User> getUsers() {
|
public Map<String, User> getUsers() {
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ public class UsersDataHolder {
|
|||||||
* @param users the users to set
|
* @param users the users to set
|
||||||
*/
|
*/
|
||||||
public void setUsers(Map<String, User> users) {
|
public void setUsers(Map<String, User> users) {
|
||||||
|
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +60,7 @@ public class UsersDataHolder {
|
|||||||
* @return the usersFile
|
* @return the usersFile
|
||||||
*/
|
*/
|
||||||
public File getUsersFile() {
|
public File getUsersFile() {
|
||||||
|
|
||||||
return usersFile;
|
return usersFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +68,7 @@ public class UsersDataHolder {
|
|||||||
* @param usersFile the usersFile to set
|
* @param usersFile the usersFile to set
|
||||||
*/
|
*/
|
||||||
public void setUsersFile(File usersFile) {
|
public void setUsersFile(File usersFile) {
|
||||||
|
|
||||||
this.usersFile = usersFile;
|
this.usersFile = usersFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ public class UsersDataHolder {
|
|||||||
* @return the haveUsersChanged
|
* @return the haveUsersChanged
|
||||||
*/
|
*/
|
||||||
public boolean HaveUsersChanged() {
|
public boolean HaveUsersChanged() {
|
||||||
|
|
||||||
return haveUsersChanged;
|
return haveUsersChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +84,7 @@ public class UsersDataHolder {
|
|||||||
* @param haveUsersChanged the haveUsersChanged to set
|
* @param haveUsersChanged the haveUsersChanged to set
|
||||||
*/
|
*/
|
||||||
public void setUsersChanged(boolean haveUsersChanged) {
|
public void setUsersChanged(boolean haveUsersChanged) {
|
||||||
|
|
||||||
this.haveUsersChanged = haveUsersChanged;
|
this.haveUsersChanged = haveUsersChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +92,7 @@ public class UsersDataHolder {
|
|||||||
* @return the timeStampUsers
|
* @return the timeStampUsers
|
||||||
*/
|
*/
|
||||||
public long getTimeStampUsers() {
|
public long getTimeStampUsers() {
|
||||||
|
|
||||||
return timeStampUsers;
|
return timeStampUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +100,7 @@ public class UsersDataHolder {
|
|||||||
* @param timeStampUsers the timeStampUsers to set
|
* @param timeStampUsers the timeStampUsers to set
|
||||||
*/
|
*/
|
||||||
public void setTimeStampUsers(long timeStampUsers) {
|
public void setTimeStampUsers(long timeStampUsers) {
|
||||||
|
|
||||||
this.timeStampUsers = timeStampUsers;
|
this.timeStampUsers = timeStampUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,27 +62,30 @@ public class WorldDataHolder {
|
|||||||
*/
|
*/
|
||||||
protected AnjoPermissionsHandler permissionsHandler;
|
protected AnjoPermissionsHandler permissionsHandler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent direct instantiation
|
* Prevent direct instantiation
|
||||||
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public WorldDataHolder(String worldName) {
|
public WorldDataHolder(String worldName) {
|
||||||
|
|
||||||
name = worldName;
|
name = worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main constructor for a new WorldDataHolder
|
* The main constructor for a new WorldDataHolder
|
||||||
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
* @param groups
|
* @param groups
|
||||||
* @param users
|
* @param users
|
||||||
*/
|
*/
|
||||||
public WorldDataHolder(String worldName, GroupsDataHolder groups, UsersDataHolder users) {
|
public WorldDataHolder(String worldName, GroupsDataHolder groups, UsersDataHolder users) {
|
||||||
|
|
||||||
this.name = worldName;
|
this.name = worldName;
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
|
|
||||||
//this.defaultGroup = defaultGroup;
|
// this.defaultGroup = defaultGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,6 +94,7 @@ public class WorldDataHolder {
|
|||||||
* This should be called whenever a set of world data is fetched.
|
* This should be called whenever a set of world data is fetched.
|
||||||
*/
|
*/
|
||||||
public void updateDataSource() {
|
public void updateDataSource() {
|
||||||
|
|
||||||
this.groups.setDataSource(this);
|
this.groups.setDataSource(this);
|
||||||
this.users.setDataSource(this);
|
this.users.setDataSource(this);
|
||||||
}
|
}
|
||||||
@@ -103,6 +107,7 @@ public class WorldDataHolder {
|
|||||||
* @return class that manage that user permission
|
* @return class that manage that user permission
|
||||||
*/
|
*/
|
||||||
public User getUser(String userName) {
|
public User getUser(String userName) {
|
||||||
|
|
||||||
if (getUsers().containsKey(userName.toLowerCase())) {
|
if (getUsers().containsKey(userName.toLowerCase())) {
|
||||||
return getUsers().get(userName.toLowerCase());
|
return getUsers().get(userName.toLowerCase());
|
||||||
}
|
}
|
||||||
@@ -112,9 +117,11 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a user to the list. If it already exists, overwrite the old.
|
* Add a user to the list. If it already exists, overwrite the old.
|
||||||
|
*
|
||||||
* @param theUser the user you want to add to the permission list
|
* @param theUser the user you want to add to the permission list
|
||||||
*/
|
*/
|
||||||
public void addUser(User theUser) {
|
public void addUser(User theUser) {
|
||||||
|
|
||||||
if (theUser.getDataSource() != this) {
|
if (theUser.getDataSource() != this) {
|
||||||
theUser = theUser.clone(this);
|
theUser = theUser.clone(this);
|
||||||
}
|
}
|
||||||
@@ -133,10 +140,12 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the user from the list. (he might become a default user)
|
* Removes the user from the list. (he might become a default user)
|
||||||
|
*
|
||||||
* @param userName the username from the user to remove
|
* @param userName the username from the user to remove
|
||||||
* @return true if it had something to remove
|
* @return true if it had something to remove
|
||||||
*/
|
*/
|
||||||
public boolean removeUser(String userName) {
|
public boolean removeUser(String userName) {
|
||||||
|
|
||||||
if (getUsers().containsKey(userName.toLowerCase())) {
|
if (getUsers().containsKey(userName.toLowerCase())) {
|
||||||
getUsers().remove(userName.toLowerCase());
|
getUsers().remove(userName.toLowerCase());
|
||||||
setUsersChanged(true);
|
setUsersChanged(true);
|
||||||
@@ -153,14 +162,17 @@ public class WorldDataHolder {
|
|||||||
* @return true if we have data for this player.
|
* @return true if we have data for this player.
|
||||||
*/
|
*/
|
||||||
public boolean isUserDeclared(String userName) {
|
public boolean isUserDeclared(String userName) {
|
||||||
|
|
||||||
return getUsers().containsKey(userName.toLowerCase());
|
return getUsers().containsKey(userName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the default group of the file.
|
* Change the default group of the file.
|
||||||
|
*
|
||||||
* @param group the group you want make default.
|
* @param group the group you want make default.
|
||||||
*/
|
*/
|
||||||
public void setDefaultGroup(Group group) {
|
public void setDefaultGroup(Group group) {
|
||||||
|
|
||||||
if (!getGroups().containsKey(group.getName().toLowerCase()) || (group.getDataSource() != this)) {
|
if (!getGroups().containsKey(group.getName().toLowerCase()) || (group.getDataSource() != this)) {
|
||||||
addGroup(group);
|
addGroup(group);
|
||||||
}
|
}
|
||||||
@@ -172,18 +184,22 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default group of the file
|
* Returns the default group of the file
|
||||||
|
*
|
||||||
* @return the default group
|
* @return the default group
|
||||||
*/
|
*/
|
||||||
public Group getDefaultGroup() {
|
public Group getDefaultGroup() {
|
||||||
|
|
||||||
return groups.getDefaultGroup();
|
return groups.getDefaultGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a group of the given name
|
* Returns a group of the given name
|
||||||
|
*
|
||||||
* @param groupName the name of the group
|
* @param groupName the name of the group
|
||||||
* @return a group if it is found. null if not found.
|
* @return a group if it is found. null if not found.
|
||||||
*/
|
*/
|
||||||
public Group getGroup(String groupName) {
|
public Group getGroup(String groupName) {
|
||||||
|
|
||||||
if (groupName.toLowerCase().startsWith("g:"))
|
if (groupName.toLowerCase().startsWith("g:"))
|
||||||
return GroupManager.getGlobalGroups().getGroup(groupName);
|
return GroupManager.getGlobalGroups().getGroup(groupName);
|
||||||
else
|
else
|
||||||
@@ -193,10 +209,12 @@ public class WorldDataHolder {
|
|||||||
/**
|
/**
|
||||||
* Check if a group exists.
|
* Check if a group exists.
|
||||||
* Its the same of getGroup, but check if it is null.
|
* Its the same of getGroup, but check if it is null.
|
||||||
|
*
|
||||||
* @param groupName the name of the group
|
* @param groupName the name of the group
|
||||||
* @return true if exists. false if not.
|
* @return true if exists. false if not.
|
||||||
*/
|
*/
|
||||||
public boolean groupExists(String groupName) {
|
public boolean groupExists(String groupName) {
|
||||||
|
|
||||||
if (groupName.toLowerCase().startsWith("g:"))
|
if (groupName.toLowerCase().startsWith("g:"))
|
||||||
return GroupManager.getGlobalGroups().hasGroup(groupName);
|
return GroupManager.getGlobalGroups().hasGroup(groupName);
|
||||||
else
|
else
|
||||||
@@ -205,9 +223,11 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a group to the list
|
* Add a group to the list
|
||||||
|
*
|
||||||
* @param groupToAdd
|
* @param groupToAdd
|
||||||
*/
|
*/
|
||||||
public void addGroup(Group groupToAdd) {
|
public void addGroup(Group groupToAdd) {
|
||||||
|
|
||||||
if (groupToAdd.getName().toLowerCase().startsWith("g:")) {
|
if (groupToAdd.getName().toLowerCase().startsWith("g:")) {
|
||||||
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
||||||
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
|
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
|
||||||
@@ -226,10 +246,13 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the group from the list
|
* Remove the group from the list
|
||||||
|
*
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* @return true if had something to remove. false the group was default or non-existant
|
* @return true if had something to remove. false the group was default or
|
||||||
|
* non-existant
|
||||||
*/
|
*/
|
||||||
public boolean removeGroup(String groupName) {
|
public boolean removeGroup(String groupName) {
|
||||||
|
|
||||||
if (groupName.toLowerCase().startsWith("g:")) {
|
if (groupName.toLowerCase().startsWith("g:")) {
|
||||||
return GroupManager.getGlobalGroups().removeGroup(groupName);
|
return GroupManager.getGlobalGroups().removeGroup(groupName);
|
||||||
}
|
}
|
||||||
@@ -251,10 +274,12 @@ public class WorldDataHolder {
|
|||||||
/**
|
/**
|
||||||
* Creates a new User with the given name
|
* Creates a new User with the given name
|
||||||
* and adds it to this holder.
|
* and adds it to this holder.
|
||||||
|
*
|
||||||
* @param userName the username you want
|
* @param userName the username you want
|
||||||
* @return null if user already exists. or new User
|
* @return null if user already exists. or new User
|
||||||
*/
|
*/
|
||||||
public User createUser(String userName) {
|
public User createUser(String userName) {
|
||||||
|
|
||||||
if (getUsers().containsKey(userName.toLowerCase())) {
|
if (getUsers().containsKey(userName.toLowerCase())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -268,10 +293,12 @@ public class WorldDataHolder {
|
|||||||
/**
|
/**
|
||||||
* Creates a new Group with the given name
|
* Creates a new Group with the given name
|
||||||
* and adds it to this holder
|
* and adds it to this holder
|
||||||
|
*
|
||||||
* @param groupName the groupname you want
|
* @param groupName the groupname you want
|
||||||
* @return null if group already exists. or new Group
|
* @return null if group already exists. or new Group
|
||||||
*/
|
*/
|
||||||
public Group createGroup(String groupName) {
|
public Group createGroup(String groupName) {
|
||||||
|
|
||||||
if (groupName.toLowerCase().startsWith("g:")) {
|
if (groupName.toLowerCase().startsWith("g:")) {
|
||||||
Group newGroup = new Group(groupName);
|
Group newGroup = new Group(groupName);
|
||||||
return GroupManager.getGlobalGroups().newGroup(newGroup);
|
return GroupManager.getGlobalGroups().newGroup(newGroup);
|
||||||
@@ -292,6 +319,7 @@ public class WorldDataHolder {
|
|||||||
* @return a collection of the groups
|
* @return a collection of the groups
|
||||||
*/
|
*/
|
||||||
public Collection<Group> getGroupList() {
|
public Collection<Group> getGroupList() {
|
||||||
|
|
||||||
return getGroups().values();
|
return getGroups().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,6 +328,7 @@ public class WorldDataHolder {
|
|||||||
* @return a collection of the users
|
* @return a collection of the users
|
||||||
*/
|
*/
|
||||||
public Collection<User> getUserList() {
|
public Collection<User> getUserList() {
|
||||||
|
|
||||||
return getUsers().values();
|
return getUsers().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +336,7 @@ public class WorldDataHolder {
|
|||||||
* reads the file again
|
* reads the file again
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
reloadGroups();
|
reloadGroups();
|
||||||
reloadUsers();
|
reloadUsers();
|
||||||
@@ -319,6 +349,7 @@ public class WorldDataHolder {
|
|||||||
* Refresh Group data from file
|
* Refresh Group data from file
|
||||||
*/
|
*/
|
||||||
public void reloadGroups() {
|
public void reloadGroups() {
|
||||||
|
|
||||||
GroupManager.setLoaded(false);
|
GroupManager.setLoaded(false);
|
||||||
try {
|
try {
|
||||||
// temporary holder in case the load fails.
|
// temporary holder in case the load fails.
|
||||||
@@ -346,6 +377,7 @@ public class WorldDataHolder {
|
|||||||
* Refresh Users data from file
|
* Refresh Users data from file
|
||||||
*/
|
*/
|
||||||
public void reloadUsers() {
|
public void reloadUsers() {
|
||||||
|
|
||||||
GroupManager.setLoaded(false);
|
GroupManager.setLoaded(false);
|
||||||
try {
|
try {
|
||||||
// temporary holder in case the load fails.
|
// temporary holder in case the load fails.
|
||||||
@@ -406,6 +438,7 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a NEW data holder containing data read from the files
|
* Returns a NEW data holder containing data read from the files
|
||||||
*
|
*
|
||||||
@@ -417,11 +450,14 @@ public class WorldDataHolder {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static WorldDataHolder load(String worldName, File groupsFile, File usersFile) throws FileNotFoundException, IOException {
|
public static WorldDataHolder load(String worldName, File groupsFile, File usersFile) throws FileNotFoundException, IOException {
|
||||||
|
|
||||||
WorldDataHolder ph = new WorldDataHolder(worldName);
|
WorldDataHolder ph = new WorldDataHolder(worldName);
|
||||||
|
|
||||||
GroupManager.setLoaded(false);
|
GroupManager.setLoaded(false);
|
||||||
if (groupsFile != null) loadGroups(ph, groupsFile);
|
if (groupsFile != null)
|
||||||
if (usersFile != null) loadUsers(ph, usersFile);
|
loadGroups(ph, groupsFile);
|
||||||
|
if (usersFile != null)
|
||||||
|
loadUsers(ph, usersFile);
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
|
|
||||||
return ph;
|
return ph;
|
||||||
@@ -436,7 +472,7 @@ public class WorldDataHolder {
|
|||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
protected static void loadGroups(WorldDataHolder ph, File groupsFile) throws FileNotFoundException, IOException {
|
protected static void loadGroups(WorldDataHolder ph, File groupsFile) throws FileNotFoundException, IOException {
|
||||||
|
|
||||||
// READ GROUPS FILE
|
// READ GROUPS FILE
|
||||||
@@ -473,7 +509,6 @@ public class WorldDataHolder {
|
|||||||
throw new IllegalArgumentException("Your " + groupsFile.getPath() + " file is invalid. See console for details.", ex);
|
throw new IllegalArgumentException("Your " + groupsFile.getPath() + " file is invalid. See console for details.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Iterator<String> groupItr = allGroupsNode.keySet().iterator();
|
Iterator<String> groupItr = allGroupsNode.keySet().iterator();
|
||||||
String groupKey;
|
String groupKey;
|
||||||
Integer groupCount = 0;
|
Integer groupCount = 0;
|
||||||
@@ -570,14 +605,14 @@ public class WorldDataHolder {
|
|||||||
thisGrp.addPermission(o.toString());
|
thisGrp.addPermission(o.toString());
|
||||||
|
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
// Ignore this entry as it's null. It can be safely dropped
|
// Ignore this entry as it's null. It can be
|
||||||
|
// safely dropped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new IllegalArgumentException("Invalid formatting found in 'permissions' section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath(), ex);
|
throw new IllegalArgumentException("Invalid formatting found in 'permissions' section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (nodeData instanceof String) {
|
} else if (nodeData instanceof String) {
|
||||||
/*
|
/*
|
||||||
* Only add this permission if it's not empty.
|
* Only add this permission if it's not empty.
|
||||||
@@ -589,7 +624,8 @@ public class WorldDataHolder {
|
|||||||
throw new IllegalArgumentException("Unknown type of 'permissions' node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
throw new IllegalArgumentException("Unknown type of 'permissions' node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Sort all permissions so they are in the correct order for checking.
|
* Sort all permissions so they are in the correct order for
|
||||||
|
* checking.
|
||||||
*/
|
*/
|
||||||
thisGrp.sortPermissions();
|
thisGrp.sortPermissions();
|
||||||
}
|
}
|
||||||
@@ -605,7 +641,8 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
if (nodeData == null) {
|
if (nodeData == null) {
|
||||||
/*
|
/*
|
||||||
* No info section was found, so leave all variables as defaults.
|
* No info section was found, so leave all variables as
|
||||||
|
* defaults.
|
||||||
*/
|
*/
|
||||||
GroupManager.logger.warning("The group '" + thisGrp.getName() + "' has no 'info' section!");
|
GroupManager.logger.warning("The group '" + thisGrp.getName() + "' has no 'info' section!");
|
||||||
GroupManager.logger.warning("Using default values: " + groupsFile.getPath());
|
GroupManager.logger.warning("Using default values: " + groupsFile.getPath());
|
||||||
@@ -652,7 +689,7 @@ public class WorldDataHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else
|
} else
|
||||||
throw new IllegalArgumentException("Unknown entry found in 'inheritance' section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
throw new IllegalArgumentException("Unknown entry found in 'inheritance' section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||||
|
|
||||||
// END GROUP
|
// END GROUP
|
||||||
@@ -686,7 +723,7 @@ public class WorldDataHolder {
|
|||||||
ph.setGroupsFile(groupsFile);
|
ph.setGroupsFile(groupsFile);
|
||||||
ph.setTimeStampGroups(groupsFile.lastModified());
|
ph.setTimeStampGroups(groupsFile.lastModified());
|
||||||
|
|
||||||
//return ph;
|
// return ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -698,7 +735,7 @@ public class WorldDataHolder {
|
|||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
protected static void loadUsers(WorldDataHolder ph, File usersFile) throws FileNotFoundException, IOException {
|
protected static void loadUsers(WorldDataHolder ph, File usersFile) throws FileNotFoundException, IOException {
|
||||||
|
|
||||||
// READ USERS FILE
|
// READ USERS FILE
|
||||||
@@ -830,8 +867,7 @@ public class WorldDataHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// USER INFO NODE
|
||||||
//USER INFO NODE
|
|
||||||
|
|
||||||
nodeData = null;
|
nodeData = null;
|
||||||
try {
|
try {
|
||||||
@@ -851,8 +887,7 @@ public class WorldDataHolder {
|
|||||||
} else
|
} else
|
||||||
throw new IllegalArgumentException("Unknown entry found in 'info' section for user: " + thisUser.getName() + " in file: " + usersFile.getPath());
|
throw new IllegalArgumentException("Unknown entry found in 'info' section for user: " + thisUser.getName() + " in file: " + usersFile.getPath());
|
||||||
|
|
||||||
//END INFO NODE
|
// END INFO NODE
|
||||||
|
|
||||||
|
|
||||||
// PRIMARY GROUP
|
// PRIMARY GROUP
|
||||||
|
|
||||||
@@ -884,10 +919,12 @@ public class WorldDataHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a dataHolder in a specified file
|
* Write a dataHolder in a specified file
|
||||||
|
*
|
||||||
* @param ph
|
* @param ph
|
||||||
* @param groupsFile
|
* @param groupsFile
|
||||||
*/
|
*/
|
||||||
public static void writeGroups(WorldDataHolder ph, File groupsFile) {
|
public static void writeGroups(WorldDataHolder ph, File groupsFile) {
|
||||||
|
|
||||||
Map<String, Object> root = new HashMap<String, Object>();
|
Map<String, Object> root = new HashMap<String, Object>();
|
||||||
|
|
||||||
Map<String, Object> groupsMap = new HashMap<String, Object>();
|
Map<String, Object> groupsMap = new HashMap<String, Object>();
|
||||||
@@ -952,26 +989,30 @@ public class WorldDataHolder {
|
|||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded())
|
||||||
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
||||||
|
|
||||||
/*FileWriter tx = null;
|
/*
|
||||||
try {
|
* FileWriter tx = null;
|
||||||
tx = new FileWriter(groupsFile, false);
|
* try {
|
||||||
tx.write(yaml.dump(root));
|
* tx = new FileWriter(groupsFile, false);
|
||||||
tx.flush();
|
* tx.write(yaml.dump(root));
|
||||||
} catch (Exception e) {
|
* tx.flush();
|
||||||
} finally {
|
* } catch (Exception e) {
|
||||||
try {
|
* } finally {
|
||||||
tx.close();
|
* try {
|
||||||
} catch (IOException ex) {
|
* tx.close();
|
||||||
}
|
* } catch (IOException ex) {
|
||||||
}*/
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a dataHolder in a specified file
|
* Write a dataHolder in a specified file
|
||||||
|
*
|
||||||
* @param ph
|
* @param ph
|
||||||
* @param usersFile
|
* @param usersFile
|
||||||
*/
|
*/
|
||||||
public static void writeUsers(WorldDataHolder ph, File usersFile) {
|
public static void writeUsers(WorldDataHolder ph, File usersFile) {
|
||||||
|
|
||||||
Map<String, Object> root = new HashMap<String, Object>();
|
Map<String, Object> root = new HashMap<String, Object>();
|
||||||
|
|
||||||
Map<String, Object> usersMap = new HashMap<String, Object>();
|
Map<String, Object> usersMap = new HashMap<String, Object>();
|
||||||
@@ -990,7 +1031,7 @@ public class WorldDataHolder {
|
|||||||
} else {
|
} else {
|
||||||
aUserMap.put("group", user.getGroup().getName());
|
aUserMap.put("group", user.getGroup().getName());
|
||||||
}
|
}
|
||||||
//USER INFO NODE - BETA
|
// USER INFO NODE - BETA
|
||||||
if (user.getVariables().getSize() > 0) {
|
if (user.getVariables().getSize() > 0) {
|
||||||
Map<String, Object> infoMap = new HashMap<String, Object>();
|
Map<String, Object> infoMap = new HashMap<String, Object>();
|
||||||
aUserMap.put("info", infoMap);
|
aUserMap.put("info", infoMap);
|
||||||
@@ -998,12 +1039,12 @@ public class WorldDataHolder {
|
|||||||
infoMap.put(infoKey, user.getVariables().getVarObject(infoKey));
|
infoMap.put(infoKey, user.getVariables().getVarObject(infoKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//END USER INFO NODE - BETA
|
// END USER INFO NODE - BETA
|
||||||
aUserMap.put("permissions", user.getPermissionList());
|
aUserMap.put("permissions", user.getPermissionList());
|
||||||
|
|
||||||
//SUBGROUPS NODE - BETA
|
// SUBGROUPS NODE - BETA
|
||||||
aUserMap.put("subgroups", user.subGroupListStringCopy());
|
aUserMap.put("subgroups", user.subGroupListStringCopy());
|
||||||
//END SUBGROUPS NODE - BETA
|
// END SUBGROUPS NODE - BETA
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!root.isEmpty()) {
|
if (!root.isEmpty()) {
|
||||||
@@ -1028,38 +1069,46 @@ public class WorldDataHolder {
|
|||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded())
|
||||||
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
||||||
|
|
||||||
/*FileWriter tx = null;
|
/*
|
||||||
try {
|
* FileWriter tx = null;
|
||||||
tx = new FileWriter(usersFile, false);
|
* try {
|
||||||
tx.write(yaml.dump(root));
|
* tx = new FileWriter(usersFile, false);
|
||||||
tx.flush();
|
* tx.write(yaml.dump(root));
|
||||||
} catch (Exception e) {
|
* tx.flush();
|
||||||
} finally {
|
* } catch (Exception e) {
|
||||||
try {
|
* } finally {
|
||||||
tx.close();
|
* try {
|
||||||
} catch (IOException ex) {
|
* tx.close();
|
||||||
}
|
* } catch (IOException ex) {
|
||||||
}*/
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't use this. Unless you want to make this plugin to interact with original Nijikokun Permissions
|
* Don't use this. Unless you want to make this plugin to interact with
|
||||||
* This method is supposed to make the original one reload the file, and propagate the changes made here.
|
* original Nijikokun Permissions
|
||||||
|
* This method is supposed to make the original one reload the file, and
|
||||||
|
* propagate the changes made here.
|
||||||
*
|
*
|
||||||
* Prefer to use the AnjoCaido's fake version of Nijikokun's Permission plugin.
|
* Prefer to use the AnjoCaido's fake version of Nijikokun's Permission
|
||||||
* The AnjoCaido's Permission can propagate the changes made on this plugin instantly,
|
* plugin.
|
||||||
|
* The AnjoCaido's Permission can propagate the changes made on this plugin
|
||||||
|
* instantly,
|
||||||
* without need to save the file.
|
* without need to save the file.
|
||||||
*
|
*
|
||||||
* @param server the server that holds the plugin
|
* @param server the server that holds the plugin
|
||||||
* @deprecated it is not used anymore... unless if you use original Permissions
|
* @deprecated it is not used anymore... unless if you use original
|
||||||
|
* Permissions
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void reloadOldPlugins(Server server) {
|
public static void reloadOldPlugins(Server server) {
|
||||||
|
|
||||||
// Only reload permissions
|
// Only reload permissions
|
||||||
PluginManager pm = server.getPluginManager();
|
PluginManager pm = server.getPluginManager();
|
||||||
Plugin[] plugins = pm.getPlugins();
|
Plugin[] plugins = pm.getPlugins();
|
||||||
for (int i = 0; i < plugins.length; i++) {
|
for (int i = 0; i < plugins.length; i++) {
|
||||||
//plugins[i].getConfiguration().load();
|
// plugins[i].getConfiguration().load();
|
||||||
try {
|
try {
|
||||||
plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]);
|
plugins[i].getClass().getMethod("setupPermissions").invoke(plugins[i]);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -1072,6 +1121,7 @@ public class WorldDataHolder {
|
|||||||
* @return the permissionsHandler
|
* @return the permissionsHandler
|
||||||
*/
|
*/
|
||||||
public AnjoPermissionsHandler getPermissionsHandler() {
|
public AnjoPermissionsHandler getPermissionsHandler() {
|
||||||
|
|
||||||
if (permissionsHandler == null) {
|
if (permissionsHandler == null) {
|
||||||
permissionsHandler = new AnjoPermissionsHandler(this);
|
permissionsHandler = new AnjoPermissionsHandler(this);
|
||||||
}
|
}
|
||||||
@@ -1082,6 +1132,7 @@ public class WorldDataHolder {
|
|||||||
* @param haveUsersChanged the haveUsersChanged to set
|
* @param haveUsersChanged the haveUsersChanged to set
|
||||||
*/
|
*/
|
||||||
public void setUsersChanged(boolean haveUsersChanged) {
|
public void setUsersChanged(boolean haveUsersChanged) {
|
||||||
|
|
||||||
users.setUsersChanged(haveUsersChanged);
|
users.setUsersChanged(haveUsersChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,6 +1141,7 @@ public class WorldDataHolder {
|
|||||||
* @return true if any user data has changed
|
* @return true if any user data has changed
|
||||||
*/
|
*/
|
||||||
public boolean haveUsersChanged() {
|
public boolean haveUsersChanged() {
|
||||||
|
|
||||||
if (users.HaveUsersChanged()) {
|
if (users.HaveUsersChanged()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1105,6 +1157,7 @@ public class WorldDataHolder {
|
|||||||
* @param setGroupsChanged the haveGroupsChanged to set
|
* @param setGroupsChanged the haveGroupsChanged to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsChanged(boolean setGroupsChanged) {
|
public void setGroupsChanged(boolean setGroupsChanged) {
|
||||||
|
|
||||||
groups.setGroupsChanged(setGroupsChanged);
|
groups.setGroupsChanged(setGroupsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,6 +1166,7 @@ public class WorldDataHolder {
|
|||||||
* @return true if any group data has changed.
|
* @return true if any group data has changed.
|
||||||
*/
|
*/
|
||||||
public boolean haveGroupsChanged() {
|
public boolean haveGroupsChanged() {
|
||||||
|
|
||||||
if (groups.HaveGroupsChanged()) {
|
if (groups.HaveGroupsChanged()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1128,6 +1182,7 @@ public class WorldDataHolder {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeUsersChangedFlag() {
|
public void removeUsersChangedFlag() {
|
||||||
|
|
||||||
setUsersChanged(false);
|
setUsersChanged(false);
|
||||||
for (User u : getUsers().values()) {
|
for (User u : getUsers().values()) {
|
||||||
u.flagAsSaved();
|
u.flagAsSaved();
|
||||||
@@ -1138,6 +1193,7 @@ public class WorldDataHolder {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeGroupsChangedFlag() {
|
public void removeGroupsChangedFlag() {
|
||||||
|
|
||||||
setGroupsChanged(false);
|
setGroupsChanged(false);
|
||||||
for (Group g : getGroups().values()) {
|
for (Group g : getGroups().values()) {
|
||||||
g.flagAsSaved();
|
g.flagAsSaved();
|
||||||
@@ -1148,6 +1204,7 @@ public class WorldDataHolder {
|
|||||||
* @return the usersFile
|
* @return the usersFile
|
||||||
*/
|
*/
|
||||||
public File getUsersFile() {
|
public File getUsersFile() {
|
||||||
|
|
||||||
return users.getUsersFile();
|
return users.getUsersFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1155,6 +1212,7 @@ public class WorldDataHolder {
|
|||||||
* @param file the usersFile to set
|
* @param file the usersFile to set
|
||||||
*/
|
*/
|
||||||
public void setUsersFile(File file) {
|
public void setUsersFile(File file) {
|
||||||
|
|
||||||
users.setUsersFile(file);
|
users.setUsersFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1162,6 +1220,7 @@ public class WorldDataHolder {
|
|||||||
* @return the groupsFile
|
* @return the groupsFile
|
||||||
*/
|
*/
|
||||||
public File getGroupsFile() {
|
public File getGroupsFile() {
|
||||||
|
|
||||||
return groups.getGroupsFile();
|
return groups.getGroupsFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,6 +1228,7 @@ public class WorldDataHolder {
|
|||||||
* @param file the groupsFile to set
|
* @param file the groupsFile to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsFile(File file) {
|
public void setGroupsFile(File file) {
|
||||||
|
|
||||||
groups.setGroupsFile(file);
|
groups.setGroupsFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1176,6 +1236,7 @@ public class WorldDataHolder {
|
|||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,13 +1244,16 @@ public class WorldDataHolder {
|
|||||||
* Resets Groups.
|
* Resets Groups.
|
||||||
*/
|
*/
|
||||||
public void resetGroups() {
|
public void resetGroups() {
|
||||||
//setDefaultGroup(null);
|
|
||||||
|
// setDefaultGroup(null);
|
||||||
groups.setGroups(new HashMap<String, Group>());
|
groups.setGroups(new HashMap<String, Group>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets Users
|
* Resets Users
|
||||||
*/
|
*/
|
||||||
public void resetUsers() {
|
public void resetUsers() {
|
||||||
|
|
||||||
users.setUsers(new HashMap<String, User>());
|
users.setUsers(new HashMap<String, User>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1197,12 +1261,15 @@ public class WorldDataHolder {
|
|||||||
* @return the groups
|
* @return the groups
|
||||||
*/
|
*/
|
||||||
public Map<String, Group> getGroups() {
|
public Map<String, Group> getGroups() {
|
||||||
|
|
||||||
return groups.getGroups();
|
return groups.getGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the users
|
* @return the users
|
||||||
*/
|
*/
|
||||||
public Map<String, User> getUsers() {
|
public Map<String, User> getUsers() {
|
||||||
|
|
||||||
return users.getUsers();
|
return users.getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,24 +1277,31 @@ public class WorldDataHolder {
|
|||||||
* @return the groups
|
* @return the groups
|
||||||
*/
|
*/
|
||||||
public GroupsDataHolder getGroupsObject() {
|
public GroupsDataHolder getGroupsObject() {
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param groupsDataHolder the GroupsDataHolder to set
|
* @param groupsDataHolder the GroupsDataHolder to set
|
||||||
*/
|
*/
|
||||||
public void setGroupsObject(GroupsDataHolder groupsDataHolder) {
|
public void setGroupsObject(GroupsDataHolder groupsDataHolder) {
|
||||||
|
|
||||||
groups = groupsDataHolder;
|
groups = groupsDataHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the users
|
* @return the users
|
||||||
*/
|
*/
|
||||||
public UsersDataHolder getUsersObject() {
|
public UsersDataHolder getUsersObject() {
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param usersDataHolder the UsersDataHolder to set
|
* @param usersDataHolder the UsersDataHolder to set
|
||||||
*/
|
*/
|
||||||
public void setUsersObject(UsersDataHolder usersDataHolder) {
|
public void setUsersObject(UsersDataHolder usersDataHolder) {
|
||||||
|
|
||||||
users = usersDataHolder;
|
users = usersDataHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,12 +1309,15 @@ public class WorldDataHolder {
|
|||||||
* @return the timeStampGroups
|
* @return the timeStampGroups
|
||||||
*/
|
*/
|
||||||
public long getTimeStampGroups() {
|
public long getTimeStampGroups() {
|
||||||
|
|
||||||
return groups.getTimeStampGroups();
|
return groups.getTimeStampGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the timeStampUsers
|
* @return the timeStampUsers
|
||||||
*/
|
*/
|
||||||
public long getTimeStampUsers() {
|
public long getTimeStampUsers() {
|
||||||
|
|
||||||
return users.getTimeStampUsers();
|
return users.getTimeStampUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1248,16 +1325,20 @@ public class WorldDataHolder {
|
|||||||
* @param timeStampGroups the timeStampGroups to set
|
* @param timeStampGroups the timeStampGroups to set
|
||||||
*/
|
*/
|
||||||
protected void setTimeStampGroups(long timeStampGroups) {
|
protected void setTimeStampGroups(long timeStampGroups) {
|
||||||
|
|
||||||
groups.setTimeStampGroups(timeStampGroups);
|
groups.setTimeStampGroups(timeStampGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param timeStampUsers the timeStampUsers to set
|
* @param timeStampUsers the timeStampUsers to set
|
||||||
*/
|
*/
|
||||||
protected void setTimeStampUsers(long timeStampUsers) {
|
protected void setTimeStampUsers(long timeStampUsers) {
|
||||||
|
|
||||||
users.setTimeStampUsers(timeStampUsers);
|
users.setTimeStampUsers(timeStampUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeStamps() {
|
public void setTimeStamps() {
|
||||||
|
|
||||||
if (getGroupsFile() != null)
|
if (getGroupsFile() != null)
|
||||||
setTimeStampGroups(getGroupsFile().lastModified());
|
setTimeStampGroups(getGroupsFile().lastModified());
|
||||||
if (getUsersFile() != null)
|
if (getUsersFile() != null)
|
||||||
|
@@ -56,6 +56,7 @@ public class WorldsHolder {
|
|||||||
* @param plugin
|
* @param plugin
|
||||||
*/
|
*/
|
||||||
public WorldsHolder(GroupManager plugin) {
|
public WorldsHolder(GroupManager plugin) {
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// Setup folders and check files exist for the primary world
|
// Setup folders and check files exist for the primary world
|
||||||
verifyFirstRun();
|
verifyFirstRun();
|
||||||
@@ -66,6 +67,7 @@ public class WorldsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialLoad() {
|
private void initialLoad() {
|
||||||
|
|
||||||
// load the initial world
|
// load the initial world
|
||||||
initialWorldLoading();
|
initialWorldLoading();
|
||||||
// Configure and load any mirrors and additional worlds as defined in config.yml
|
// Configure and load any mirrors and additional worlds as defined in config.yml
|
||||||
@@ -75,6 +77,7 @@ public class WorldsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialWorldLoading() {
|
private void initialWorldLoading() {
|
||||||
|
|
||||||
//Load the default world
|
//Load the default world
|
||||||
loadWorld(serverDefaultWorldName);
|
loadWorld(serverDefaultWorldName);
|
||||||
//defaultWorld = getUpdatedWorldData(serverDefaultWorldName);
|
//defaultWorld = getUpdatedWorldData(serverDefaultWorldName);
|
||||||
@@ -87,9 +90,8 @@ public class WorldsHolder {
|
|||||||
* Create the data files if they don't already exist,
|
* Create the data files if they don't already exist,
|
||||||
* and they are not mirrored.
|
* and they are not mirrored.
|
||||||
*/
|
*/
|
||||||
for (World world: plugin.getServer().getWorlds())
|
for (World world : plugin.getServer().getWorlds())
|
||||||
if ((!worldsData.containsKey(world.getName().toLowerCase()))
|
if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase()))))
|
||||||
&& ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase()))))
|
|
||||||
setupWorldFolder(world.getName());
|
setupWorldFolder(world.getName());
|
||||||
/*
|
/*
|
||||||
* Loop over all folders within the worlds folder
|
* Loop over all folders within the worlds folder
|
||||||
@@ -103,12 +105,11 @@ public class WorldsHolder {
|
|||||||
* don't load any worlds which are already loaded
|
* don't load any worlds which are already loaded
|
||||||
* or fully mirrored worlds that don't need data.
|
* or fully mirrored worlds that don't need data.
|
||||||
*/
|
*/
|
||||||
if (!worldsData.containsKey(folder.getName().toLowerCase())
|
if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
|
||||||
&& ((!mirrorsGroup.containsKey(folder.getName().toLowerCase()))
|
|
||||||
|| (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
|
|
||||||
/*
|
/*
|
||||||
* Call setupWorldFolder to check case sensitivity
|
* Call setupWorldFolder to check case sensitivity
|
||||||
* and convert to lower case, before we attempt to load this world.
|
* and convert to lower case, before we attempt to load this
|
||||||
|
* world.
|
||||||
*/
|
*/
|
||||||
setupWorldFolder(folder.getName());
|
setupWorldFolder(folder.getName());
|
||||||
loadWorld(folder.getName().toLowerCase());
|
loadWorld(folder.getName().toLowerCase());
|
||||||
@@ -120,6 +121,7 @@ public class WorldsHolder {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public void mirrorSetUp() {
|
public void mirrorSetUp() {
|
||||||
|
|
||||||
mirrorsGroup.clear();
|
mirrorsGroup.clear();
|
||||||
mirrorsUser.clear();
|
mirrorsUser.clear();
|
||||||
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
|
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
|
||||||
@@ -199,7 +201,7 @@ public class WorldsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a datasource for any worlds not already loaded
|
// Create a datasource for any worlds not already loaded
|
||||||
for (String world : mirroredWorlds){
|
for (String world : mirroredWorlds) {
|
||||||
if (!worldsData.containsKey(world.toLowerCase())) {
|
if (!worldsData.containsKey(world.toLowerCase())) {
|
||||||
setupWorldFolder(world);
|
setupWorldFolder(world);
|
||||||
loadWorld(world, true);
|
loadWorld(world, true);
|
||||||
@@ -212,6 +214,7 @@ public class WorldsHolder {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void reloadAll() {
|
public void reloadAll() {
|
||||||
|
|
||||||
// Load global groups
|
// Load global groups
|
||||||
GroupManager.getGlobalGroups().load();
|
GroupManager.getGlobalGroups().load();
|
||||||
|
|
||||||
@@ -235,6 +238,7 @@ public class WorldsHolder {
|
|||||||
* @param worldName
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public void reloadWorld(String worldName) {
|
public void reloadWorld(String worldName) {
|
||||||
|
|
||||||
if (!mirrorsGroup.containsKey(worldName.toLowerCase()))
|
if (!mirrorsGroup.containsKey(worldName.toLowerCase()))
|
||||||
getWorldData(worldName).reloadGroups();
|
getWorldData(worldName).reloadGroups();
|
||||||
if (!mirrorsUser.containsKey(worldName.toLowerCase()))
|
if (!mirrorsUser.containsKey(worldName.toLowerCase()))
|
||||||
@@ -246,6 +250,7 @@ public class WorldsHolder {
|
|||||||
* (call this function to auto overwrite files)
|
* (call this function to auto overwrite files)
|
||||||
*/
|
*/
|
||||||
public void saveChanges() {
|
public void saveChanges() {
|
||||||
|
|
||||||
saveChanges(true);
|
saveChanges(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +258,7 @@ public class WorldsHolder {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void saveChanges(boolean overwrite) {
|
public void saveChanges(boolean overwrite) {
|
||||||
|
|
||||||
ArrayList<WorldDataHolder> alreadyDone = new ArrayList<WorldDataHolder>();
|
ArrayList<WorldDataHolder> alreadyDone = new ArrayList<WorldDataHolder>();
|
||||||
Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
|
Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
|
||||||
|
|
||||||
@@ -278,7 +284,7 @@ public class WorldsHolder {
|
|||||||
if (w.haveGroupsChanged()) {
|
if (w.haveGroupsChanged()) {
|
||||||
if (overwrite || (!overwrite && (w.getTimeStampGroups() >= w.getGroupsFile().lastModified()))) {
|
if (overwrite || (!overwrite && (w.getTimeStampGroups() >= w.getGroupsFile().lastModified()))) {
|
||||||
// Backup Groups file
|
// Backup Groups file
|
||||||
backupFile(w,true);
|
backupFile(w, true);
|
||||||
|
|
||||||
WorldDataHolder.writeGroups(w, w.getGroupsFile());
|
WorldDataHolder.writeGroups(w, w.getGroupsFile());
|
||||||
//w.removeGroupsChangedFlag();
|
//w.removeGroupsChangedFlag();
|
||||||
@@ -292,7 +298,7 @@ public class WorldsHolder {
|
|||||||
if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
|
if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
|
||||||
System.out.print("Newer Groups file found (Loading changes)!");
|
System.out.print("Newer Groups file found (Loading changes)!");
|
||||||
// Backup Groups file
|
// Backup Groups file
|
||||||
backupFile(w,true);
|
backupFile(w, true);
|
||||||
w.reloadGroups();
|
w.reloadGroups();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,7 +306,7 @@ public class WorldsHolder {
|
|||||||
if (w.haveUsersChanged()) {
|
if (w.haveUsersChanged()) {
|
||||||
if (overwrite || (!overwrite && (w.getTimeStampUsers() >= w.getUsersFile().lastModified()))) {
|
if (overwrite || (!overwrite && (w.getTimeStampUsers() >= w.getUsersFile().lastModified()))) {
|
||||||
// Backup Users file
|
// Backup Users file
|
||||||
backupFile(w,false);
|
backupFile(w, false);
|
||||||
|
|
||||||
WorldDataHolder.writeUsers(w, w.getUsersFile());
|
WorldDataHolder.writeUsers(w, w.getUsersFile());
|
||||||
//w.removeUsersChangedFlag();
|
//w.removeUsersChangedFlag();
|
||||||
@@ -314,7 +320,7 @@ public class WorldsHolder {
|
|||||||
if (w.getTimeStampUsers() < w.getUsersFile().lastModified()) {
|
if (w.getTimeStampUsers() < w.getUsersFile().lastModified()) {
|
||||||
System.out.print("Newer Users file found (Loading changes)!");
|
System.out.print("Newer Users file found (Loading changes)!");
|
||||||
// Backup Users file
|
// Backup Users file
|
||||||
backupFile(w,false);
|
backupFile(w, false);
|
||||||
w.reloadUsers();
|
w.reloadUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,6 +330,7 @@ public class WorldsHolder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Backup the Groups/Users file
|
* Backup the Groups/Users file
|
||||||
|
*
|
||||||
* @param w
|
* @param w
|
||||||
* @param groups
|
* @param groups
|
||||||
*/
|
*/
|
||||||
@@ -349,6 +356,7 @@ public class WorldsHolder {
|
|||||||
* @return OverloadedWorldHolder
|
* @return OverloadedWorldHolder
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder getWorldData(String worldName) {
|
public OverloadedWorldHolder getWorldData(String worldName) {
|
||||||
|
|
||||||
String worldNameLowered = worldName.toLowerCase();
|
String worldNameLowered = worldName.toLowerCase();
|
||||||
|
|
||||||
// Find this worlds data
|
// Find this worlds data
|
||||||
@@ -361,12 +369,14 @@ public class WorldsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the requested world data and update it's dataSource to be relevant for this world
|
* Get the requested world data and update it's dataSource to be relevant
|
||||||
|
* for this world
|
||||||
*
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
* @return updated world holder
|
* @return updated world holder
|
||||||
*/
|
*/
|
||||||
private OverloadedWorldHolder getUpdatedWorldData(String worldName) {
|
private OverloadedWorldHolder getUpdatedWorldData(String worldName) {
|
||||||
|
|
||||||
String worldNameLowered = worldName.toLowerCase();
|
String worldNameLowered = worldName.toLowerCase();
|
||||||
|
|
||||||
if (worldsData.containsKey(worldNameLowered)) {
|
if (worldsData.containsKey(worldNameLowered)) {
|
||||||
@@ -386,6 +396,7 @@ public class WorldsHolder {
|
|||||||
* @return null if matching returned no player, or more than one.
|
* @return null if matching returned no player, or more than one.
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder getWorldDataByPlayerName(String playerName) {
|
public OverloadedWorldHolder getWorldDataByPlayerName(String playerName) {
|
||||||
|
|
||||||
List<Player> matchPlayer = plugin.getServer().matchPlayer(playerName);
|
List<Player> matchPlayer = plugin.getServer().matchPlayer(playerName);
|
||||||
if (matchPlayer.size() == 1) {
|
if (matchPlayer.size() == 1) {
|
||||||
return getWorldData(matchPlayer.get(0));
|
return getWorldData(matchPlayer.get(0));
|
||||||
@@ -401,34 +412,41 @@ public class WorldsHolder {
|
|||||||
* @return OverloadedWorldHolder
|
* @return OverloadedWorldHolder
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder getWorldData(Player player) {
|
public OverloadedWorldHolder getWorldData(Player player) {
|
||||||
|
|
||||||
return getWorldData(player.getWorld().getName());
|
return getWorldData(player.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It does getWorld(worldName).getPermissionsHandler()
|
* It does getWorld(worldName).getPermissionsHandler()
|
||||||
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
* @return AnjoPermissionsHandler
|
* @return AnjoPermissionsHandler
|
||||||
*/
|
*/
|
||||||
public AnjoPermissionsHandler getWorldPermissions(String worldName) {
|
public AnjoPermissionsHandler getWorldPermissions(String worldName) {
|
||||||
|
|
||||||
return getWorldData(worldName).getPermissionsHandler();
|
return getWorldData(worldName).getPermissionsHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the PermissionsHandler for this player data
|
* Returns the PermissionsHandler for this player data
|
||||||
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return AnjoPermissionsHandler
|
* @return AnjoPermissionsHandler
|
||||||
*/
|
*/
|
||||||
public AnjoPermissionsHandler getWorldPermissions(Player player) {
|
public AnjoPermissionsHandler getWorldPermissions(Player player) {
|
||||||
|
|
||||||
return getWorldData(player).getPermissionsHandler();
|
return getWorldData(player).getPermissionsHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id does getWorldDataByPlayerName(playerName).
|
* Id does getWorldDataByPlayerName(playerName).
|
||||||
* If it doesnt return null, it will return result.getPermissionsHandler()
|
* If it doesnt return null, it will return result.getPermissionsHandler()
|
||||||
|
*
|
||||||
* @param playerName
|
* @param playerName
|
||||||
* @return null if the player matching gone wrong.
|
* @return null if the player matching gone wrong.
|
||||||
*/
|
*/
|
||||||
public AnjoPermissionsHandler getWorldPermissionsByPlayerName(String playerName) {
|
public AnjoPermissionsHandler getWorldPermissionsByPlayerName(String playerName) {
|
||||||
|
|
||||||
WorldDataHolder dh = getWorldDataByPlayerName(playerName);
|
WorldDataHolder dh = getWorldDataByPlayerName(playerName);
|
||||||
if (dh != null) {
|
if (dh != null) {
|
||||||
return dh.getPermissionsHandler();
|
return dh.getPermissionsHandler();
|
||||||
@@ -450,6 +468,7 @@ public class WorldsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupWorldFolder(String worldName) {
|
public void setupWorldFolder(String worldName) {
|
||||||
|
|
||||||
String worldNameLowered = worldName.toLowerCase();
|
String worldNameLowered = worldName.toLowerCase();
|
||||||
|
|
||||||
worldsFolder = new File(plugin.getDataFolder(), "worlds");
|
worldsFolder = new File(plugin.getDataFolder(), "worlds");
|
||||||
@@ -543,15 +562,18 @@ public class WorldsHolder {
|
|||||||
*
|
*
|
||||||
* Load a world from file.
|
* Load a world from file.
|
||||||
* If it already been loaded, summon reload method from dataHolder.
|
* If it already been loaded, summon reload method from dataHolder.
|
||||||
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public void loadWorld(String worldName) {
|
public void loadWorld(String worldName) {
|
||||||
|
|
||||||
loadWorld(worldName, false);
|
loadWorld(worldName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a world from file.
|
* Load a world from file.
|
||||||
* If it already been loaded, summon reload method from dataHolder.
|
* If it already been loaded, summon reload method from dataHolder.
|
||||||
|
*
|
||||||
* @param worldName
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public void loadWorld(String worldName, Boolean isMirror) {
|
public void loadWorld(String worldName, Boolean isMirror) {
|
||||||
@@ -567,8 +589,8 @@ public class WorldsHolder {
|
|||||||
if ((isMirror) || (thisWorldFolder.exists() && thisWorldFolder.isDirectory())) {
|
if ((isMirror) || (thisWorldFolder.exists() && thisWorldFolder.isDirectory())) {
|
||||||
|
|
||||||
// Setup file handles, if not mirrored
|
// Setup file handles, if not mirrored
|
||||||
File groupsFile = (mirrorsGroup.containsKey(worldNameLowered))? null : new File(thisWorldFolder, "groups.yml");
|
File groupsFile = (mirrorsGroup.containsKey(worldNameLowered)) ? null : new File(thisWorldFolder, "groups.yml");
|
||||||
File usersFile = (mirrorsUser.containsKey(worldNameLowered))? null : new File(thisWorldFolder, "users.yml");
|
File usersFile = (mirrorsUser.containsKey(worldNameLowered)) ? null : new File(thisWorldFolder, "users.yml");
|
||||||
|
|
||||||
if ((groupsFile != null) && (!groupsFile.exists())) {
|
if ((groupsFile != null) && (!groupsFile.exists())) {
|
||||||
throw new IllegalArgumentException("Groups file for world '" + worldName + "' doesnt exist: " + groupsFile.getPath());
|
throw new IllegalArgumentException("Groups file for world '" + worldName + "' doesnt exist: " + groupsFile.getPath());
|
||||||
@@ -618,6 +640,7 @@ public class WorldsHolder {
|
|||||||
* @return true if world is loaded or mirrored. false if not listed
|
* @return true if world is loaded or mirrored. false if not listed
|
||||||
*/
|
*/
|
||||||
public boolean isInList(String worldName) {
|
public boolean isInList(String worldName) {
|
||||||
|
|
||||||
if (worldsData.containsKey(worldName.toLowerCase()) || mirrorsGroup.containsKey(worldName.toLowerCase()) || mirrorsUser.containsKey(worldName.toLowerCase())) {
|
if (worldsData.containsKey(worldName.toLowerCase()) || mirrorsGroup.containsKey(worldName.toLowerCase()) || mirrorsUser.containsKey(worldName.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -631,6 +654,7 @@ public class WorldsHolder {
|
|||||||
* @return true if it has its own holder. false if not.
|
* @return true if it has its own holder. false if not.
|
||||||
*/
|
*/
|
||||||
public boolean hasOwnData(String worldName) {
|
public boolean hasOwnData(String worldName) {
|
||||||
|
|
||||||
if (worldsData.containsKey(worldName.toLowerCase()) && (!mirrorsGroup.containsKey(worldName.toLowerCase()) || !mirrorsUser.containsKey(worldName.toLowerCase()))) {
|
if (worldsData.containsKey(worldName.toLowerCase()) && (!mirrorsGroup.containsKey(worldName.toLowerCase()) || !mirrorsUser.containsKey(worldName.toLowerCase()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -641,6 +665,7 @@ public class WorldsHolder {
|
|||||||
* @return the defaultWorld
|
* @return the defaultWorld
|
||||||
*/
|
*/
|
||||||
public OverloadedWorldHolder getDefaultWorld() {
|
public OverloadedWorldHolder getDefaultWorld() {
|
||||||
|
|
||||||
return getUpdatedWorldData(serverDefaultWorldName);
|
return getUpdatedWorldData(serverDefaultWorldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,6 +676,7 @@ public class WorldsHolder {
|
|||||||
* @return ArrayList<OverloadedWorldHolder> of all loaded worlds
|
* @return ArrayList<OverloadedWorldHolder> of all loaded worlds
|
||||||
*/
|
*/
|
||||||
public ArrayList<OverloadedWorldHolder> allWorldsDataList() {
|
public ArrayList<OverloadedWorldHolder> allWorldsDataList() {
|
||||||
|
|
||||||
ArrayList<OverloadedWorldHolder> list = new ArrayList<OverloadedWorldHolder>();
|
ArrayList<OverloadedWorldHolder> list = new ArrayList<OverloadedWorldHolder>();
|
||||||
for (OverloadedWorldHolder data : worldsData.values()) {
|
for (OverloadedWorldHolder data : worldsData.values()) {
|
||||||
if ((!list.contains(data)) && (!mirrorsGroup.containsKey(data.getName().toLowerCase()) || !mirrorsUser.containsKey(data.getName().toLowerCase()))) {
|
if ((!list.contains(data)) && (!mirrorsGroup.containsKey(data.getName().toLowerCase()) || !mirrorsUser.containsKey(data.getName().toLowerCase()))) {
|
||||||
|
@@ -6,7 +6,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -20,10 +19,12 @@ public class GMGroupEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ public class GMGroupEvent extends Event {
|
|||||||
protected Action action;
|
protected Action action;
|
||||||
|
|
||||||
public GMGroupEvent(Group group, Action action) {
|
public GMGroupEvent(Group group, Action action) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.group = group;
|
this.group = group;
|
||||||
@@ -44,30 +46,30 @@ public class GMGroupEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GMGroupEvent(String groupName, Action action) {
|
public GMGroupEvent(String groupName, Action action) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction(){
|
public Action getAction() {
|
||||||
|
|
||||||
return this.action;
|
return this.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group getGroup() {
|
public Group getGroup() {
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
|
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
GROUP_PERMISSIONS_CHANGED,
|
GROUP_PERMISSIONS_CHANGED, GROUP_INHERITANCE_CHANGED, GROUP_INFO_CHANGED, GROUP_ADDED, GROUP_REMOVED,
|
||||||
GROUP_INHERITANCE_CHANGED,
|
|
||||||
GROUP_INFO_CHANGED,
|
|
||||||
GROUP_ADDED,
|
|
||||||
GROUP_REMOVED,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void schedule(final GMGroupEvent event) {
|
public void schedule(final GMGroupEvent event) {
|
||||||
@@ -76,6 +78,7 @@ public class GMGroupEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
}, 1) == -1)
|
}, 1) == -1)
|
||||||
|
@@ -5,7 +5,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -19,10 +18,12 @@ public class GMSystemEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,20 +32,19 @@ public class GMSystemEvent extends Event {
|
|||||||
protected Action action;
|
protected Action action;
|
||||||
|
|
||||||
public GMSystemEvent(Action action) {
|
public GMSystemEvent(Action action) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction(){
|
public Action getAction() {
|
||||||
|
|
||||||
return this.action;
|
return this.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
RELOADED,
|
RELOADED, SAVED, DEFAULT_GROUP_CHANGED, VALIDATE_TOGGLE,
|
||||||
SAVED,
|
|
||||||
DEFAULT_GROUP_CHANGED,
|
|
||||||
VALIDATE_TOGGLE,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void schedule(final GMSystemEvent event) {
|
public void schedule(final GMSystemEvent event) {
|
||||||
@@ -53,6 +53,7 @@ public class GMSystemEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
}, 1) == -1)
|
}, 1) == -1)
|
||||||
|
@@ -6,7 +6,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -20,10 +19,12 @@ public class GMUserEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ public class GMUserEvent extends Event {
|
|||||||
protected Action action;
|
protected Action action;
|
||||||
|
|
||||||
public GMUserEvent(User user, Action action) {
|
public GMUserEvent(User user, Action action) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@@ -44,32 +46,30 @@ public class GMUserEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GMUserEvent(String userName, Action action) {
|
public GMUserEvent(String userName, Action action) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction(){
|
public Action getAction() {
|
||||||
|
|
||||||
return this.action;
|
return this.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
|
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
USER_PERMISSIONS_CHANGED,
|
USER_PERMISSIONS_CHANGED, USER_INHERITANCE_CHANGED, USER_INFO_CHANGED, USER_GROUP_CHANGED, USER_SUBGROUP_CHANGED, USER_ADDED, USER_REMOVED,
|
||||||
USER_INHERITANCE_CHANGED,
|
|
||||||
USER_INFO_CHANGED,
|
|
||||||
USER_GROUP_CHANGED,
|
|
||||||
USER_SUBGROUP_CHANGED,
|
|
||||||
USER_ADDED,
|
|
||||||
USER_REMOVED,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void schedule(final GMUserEvent event) {
|
public void schedule(final GMUserEvent event) {
|
||||||
@@ -78,6 +78,7 @@ public class GMUserEvent extends Event {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
}, 1) == -1)
|
}, 1) == -1)
|
||||||
|
@@ -6,7 +6,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -18,16 +17,19 @@ public class GMWorldListener implements Listener {
|
|||||||
private final GroupManager plugin;
|
private final GroupManager plugin;
|
||||||
|
|
||||||
public GMWorldListener(GroupManager instance) {
|
public GMWorldListener(GroupManager instance) {
|
||||||
|
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
registerEvents();
|
registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onWorldInit(WorldInitEvent event) {
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
|
|
||||||
String worldName = event.getWorld().getName();
|
String worldName = event.getWorld().getName();
|
||||||
|
|
||||||
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
|
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
|
||||||
|
@@ -3,7 +3,6 @@ package org.anjocaido.groupmanager.events;
|
|||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
import org.anjocaido.groupmanager.data.User;
|
import org.anjocaido.groupmanager.data.User;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -13,30 +12,42 @@ import org.anjocaido.groupmanager.data.User;
|
|||||||
public class GroupManagerEventHandler {
|
public class GroupManagerEventHandler {
|
||||||
|
|
||||||
protected static void callEvent(GMGroupEvent event) {
|
protected static void callEvent(GMGroupEvent event) {
|
||||||
|
|
||||||
event.schedule(event);
|
event.schedule(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void callEvent(GMUserEvent event) {
|
protected static void callEvent(GMUserEvent event) {
|
||||||
|
|
||||||
event.schedule(event);
|
event.schedule(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void callEvent(GMSystemEvent event) {
|
protected static void callEvent(GMSystemEvent event) {
|
||||||
|
|
||||||
event.schedule(event);
|
event.schedule(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(Group group, GMGroupEvent.Action action) {
|
public static void callEvent(Group group, GMGroupEvent.Action action) {
|
||||||
|
|
||||||
callEvent(new GMGroupEvent(group, action));
|
callEvent(new GMGroupEvent(group, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(String groupName, GMGroupEvent.Action action) {
|
public static void callEvent(String groupName, GMGroupEvent.Action action) {
|
||||||
|
|
||||||
callEvent(new GMGroupEvent(groupName, action));
|
callEvent(new GMGroupEvent(groupName, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(User user, GMUserEvent.Action action) {
|
public static void callEvent(User user, GMUserEvent.Action action) {
|
||||||
|
|
||||||
callEvent(new GMUserEvent(user, action));
|
callEvent(new GMUserEvent(user, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(String userName, GMUserEvent.Action action) {
|
public static void callEvent(String userName, GMUserEvent.Action action) {
|
||||||
|
|
||||||
callEvent(new GMUserEvent(userName, action));
|
callEvent(new GMUserEvent(userName, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(GMSystemEvent.Action action) {
|
public static void callEvent(GMSystemEvent.Action action) {
|
||||||
|
|
||||||
callEvent(new GMSystemEvent(action));
|
callEvent(new GMSystemEvent(action));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -39,6 +39,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @param holder
|
* @param holder
|
||||||
*/
|
*/
|
||||||
public AnjoPermissionsHandler(WorldDataHolder holder) {
|
public AnjoPermissionsHandler(WorldDataHolder holder) {
|
||||||
|
|
||||||
ph = holder;
|
ph = holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean has(Player player, String permission) {
|
public boolean has(Player player, String permission) {
|
||||||
|
|
||||||
return permission(player, permission);
|
return permission(player, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +65,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean permission(Player player, String permission) {
|
public boolean permission(Player player, String permission) {
|
||||||
|
|
||||||
return checkUserPermission(ph.getUser(player.getName()).updatePlayer(player), permission);
|
return checkUserPermission(ph.getUser(player.getName()).updatePlayer(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return true if the player has the permission
|
* @return true if the player has the permission
|
||||||
*/
|
*/
|
||||||
public boolean permission(String playerName, String permission) {
|
public boolean permission(String playerName, String permission) {
|
||||||
|
|
||||||
return checkUserPermission(ph.getUser(playerName), permission);
|
return checkUserPermission(ph.getUser(playerName), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +89,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getGroup(String userName) {
|
public String getGroup(String userName) {
|
||||||
|
|
||||||
return ph.getUser(userName).getGroup().getName();
|
return ph.getUser(userName).getGroup().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +102,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAllPlayersPermissions(String userName) {
|
public List<String> getAllPlayersPermissions(String userName) {
|
||||||
|
|
||||||
List<String> perms = new ArrayList<String>();
|
List<String> perms = new ArrayList<String>();
|
||||||
|
|
||||||
perms.addAll(getAllPlayersPermissions(userName, true));
|
perms.addAll(getAllPlayersPermissions(userName, true));
|
||||||
@@ -143,8 +149,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
boolean negated = (perm.startsWith("-"));
|
boolean negated = (perm.startsWith("-"));
|
||||||
// Perm doesn't already exists and there is no negation for it
|
// Perm doesn't already exists and there is no negation for it
|
||||||
// or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms)
|
// or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms)
|
||||||
if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm))
|
if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm)) || (negated && !playerPermArray.contains(perm.substring(1)) && !playerPermArray.contains("-" + perm)))
|
||||||
|| (negated && !playerPermArray.contains(perm.substring(1)) && !playerPermArray.contains("-" + perm)))
|
|
||||||
playerPermArray.add(perm);
|
playerPermArray.add(perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +160,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
return playerPermArray;
|
return playerPermArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> populatePerms (List<String> permsList, boolean includeChildren) {
|
private Set<String> populatePerms(List<String> permsList, boolean includeChildren) {
|
||||||
|
|
||||||
// Create a new array so it's modifiable.
|
// Create a new array so it's modifiable.
|
||||||
List<String> perms = new ArrayList<String>(permsList);
|
List<String> perms = new ArrayList<String>(permsList);
|
||||||
@@ -186,7 +191,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Process child nodes if required,
|
* Process child nodes if required,
|
||||||
* or this is a negated node AND we used * to include all permissions,
|
* or this is a negated node AND we used * to include all
|
||||||
|
* permissions,
|
||||||
* in which case we need to remove all children of that node.
|
* in which case we need to remove all children of that node.
|
||||||
*/
|
*/
|
||||||
if ((includeChildren) || (negated && allPerms)) {
|
if ((includeChildren) || (negated && allPerms)) {
|
||||||
@@ -236,6 +242,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean inGroup(String name, String group) {
|
public boolean inGroup(String name, String group) {
|
||||||
|
|
||||||
if (hasGroupInInheritance(ph.getUser(name).getGroup(), group)) {
|
if (hasGroupInInheritance(ph.getUser(name).getGroup(), group)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -326,6 +333,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getGroupPrefix(String groupName) {
|
public String getGroupPrefix(String groupName) {
|
||||||
|
|
||||||
Group g = ph.getGroup(groupName);
|
Group g = ph.getGroup(groupName);
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
return "";
|
return "";
|
||||||
@@ -341,6 +349,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getGroupSuffix(String groupName) {
|
public String getGroupSuffix(String groupName) {
|
||||||
|
|
||||||
Group g = ph.getGroup(groupName);
|
Group g = ph.getGroup(groupName);
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
return "";
|
return "";
|
||||||
@@ -357,6 +366,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canGroupBuild(String groupName) {
|
public boolean canGroupBuild(String groupName) {
|
||||||
|
|
||||||
Group g = ph.getGroup(groupName);
|
Group g = ph.getGroup(groupName);
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -374,6 +384,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getGroupPermissionString(String groupName, String variable) {
|
public String getGroupPermissionString(String groupName, String variable) {
|
||||||
|
|
||||||
Group start = ph.getGroup(groupName);
|
Group start = ph.getGroup(groupName);
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -395,6 +406,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getGroupPermissionInteger(String groupName, String variable) {
|
public int getGroupPermissionInteger(String groupName, String variable) {
|
||||||
|
|
||||||
Group start = ph.getGroup(groupName);
|
Group start = ph.getGroup(groupName);
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -416,6 +428,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getGroupPermissionBoolean(String group, String variable) {
|
public boolean getGroupPermissionBoolean(String group, String variable) {
|
||||||
|
|
||||||
Group start = ph.getGroup(group);
|
Group start = ph.getGroup(group);
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -437,6 +450,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getGroupPermissionDouble(String group, String variable) {
|
public double getGroupPermissionDouble(String group, String variable) {
|
||||||
|
|
||||||
Group start = ph.getGroup(group);
|
Group start = ph.getGroup(group);
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -457,6 +471,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUserPermissionString(String user, String variable) {
|
public String getUserPermissionString(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return "";
|
return "";
|
||||||
@@ -473,6 +488,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getUserPermissionInteger(String user, String variable) {
|
public int getUserPermissionInteger(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -489,6 +505,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getUserPermissionBoolean(String user, String variable) {
|
public boolean getUserPermissionBoolean(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -505,6 +522,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getUserPermissionDouble(String user, String variable) {
|
public double getUserPermissionDouble(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -523,6 +541,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getPermissionString(String user, String variable) {
|
public String getPermissionString(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return "";
|
return "";
|
||||||
@@ -562,6 +581,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getPermissionInteger(String user, String variable) {
|
public int getPermissionInteger(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -601,6 +621,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getPermissionBoolean(String user, String variable) {
|
public boolean getPermissionBoolean(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -640,6 +661,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getPermissionDouble(String user, String variable) {
|
public double getPermissionDouble(String user, String variable) {
|
||||||
|
|
||||||
User auser = ph.getUser(user);
|
User auser = ph.getUser(user);
|
||||||
if (auser == null) {
|
if (auser == null) {
|
||||||
return -1.0D;
|
return -1.0D;
|
||||||
@@ -676,6 +698,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return PermissionCheckResult
|
* @return PermissionCheckResult
|
||||||
*/
|
*/
|
||||||
public PermissionCheckResult checkUserOnlyPermission(User user, String permission) {
|
public PermissionCheckResult checkUserOnlyPermission(User user, String permission) {
|
||||||
|
|
||||||
user.sortPermissions();
|
user.sortPermissions();
|
||||||
PermissionCheckResult result = new PermissionCheckResult();
|
PermissionCheckResult result = new PermissionCheckResult();
|
||||||
result.askedPermission = permission;
|
result.askedPermission = permission;
|
||||||
@@ -699,6 +722,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return the node if permission is found. if not found, return null
|
* @return the node if permission is found. if not found, return null
|
||||||
*/
|
*/
|
||||||
public PermissionCheckResult checkGroupOnlyPermission(Group group, String permission) {
|
public PermissionCheckResult checkGroupOnlyPermission(Group group, String permission) {
|
||||||
|
|
||||||
group.sortPermissions();
|
group.sortPermissions();
|
||||||
PermissionCheckResult result = new PermissionCheckResult();
|
PermissionCheckResult result = new PermissionCheckResult();
|
||||||
result.owner = group;
|
result.owner = group;
|
||||||
@@ -721,6 +745,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return true if permission was found. false if not, or was negated.
|
* @return true if permission was found. false if not, or was negated.
|
||||||
*/
|
*/
|
||||||
public boolean checkUserPermission(User user, String permission) {
|
public boolean checkUserPermission(User user, String permission) {
|
||||||
|
|
||||||
PermissionCheckResult result = checkFullGMPermission(user, permission, true);
|
PermissionCheckResult result = checkFullGMPermission(user, permission, true);
|
||||||
if (result.resultType == PermissionCheckResult.Type.EXCEPTION || result.resultType == PermissionCheckResult.Type.FOUND) {
|
if (result.resultType == PermissionCheckResult.Type.EXCEPTION || result.resultType == PermissionCheckResult.Type.FOUND) {
|
||||||
return true;
|
return true;
|
||||||
@@ -752,6 +777,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return PermissionCheckResult
|
* @return PermissionCheckResult
|
||||||
*/
|
*/
|
||||||
public PermissionCheckResult checkFullGMPermission(User user, String targetPermission, Boolean checkBukkit) {
|
public PermissionCheckResult checkFullGMPermission(User user, String targetPermission, Boolean checkBukkit) {
|
||||||
|
|
||||||
PermissionCheckResult result = new PermissionCheckResult();
|
PermissionCheckResult result = new PermissionCheckResult();
|
||||||
result.accessLevel = targetPermission;
|
result.accessLevel = targetPermission;
|
||||||
result.resultType = PermissionCheckResult.Type.NOTFOUND;
|
result.resultType = PermissionCheckResult.Type.NOTFOUND;
|
||||||
@@ -813,6 +839,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Group nextGroupWithVariable(Group start, String variable, List<Group> alreadyChecked) {
|
public Group nextGroupWithVariable(Group start, String variable, List<Group> alreadyChecked) {
|
||||||
|
|
||||||
return nextGroupWithVariable(start, variable);
|
return nextGroupWithVariable(start, variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -829,6 +856,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return The group if found. Null if not.
|
* @return The group if found. Null if not.
|
||||||
*/
|
*/
|
||||||
public Group nextGroupWithVariable(Group start, String targetVariable) {
|
public Group nextGroupWithVariable(Group start, String targetVariable) {
|
||||||
|
|
||||||
if (start == null || targetVariable == null) {
|
if (start == null || targetVariable == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -870,6 +898,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean searchGroupInInheritance(Group start, String askedGroup, List<Group> alreadyChecked) {
|
public boolean searchGroupInInheritance(Group start, String askedGroup, List<Group> alreadyChecked) {
|
||||||
|
|
||||||
return hasGroupInInheritance(start, askedGroup);
|
return hasGroupInInheritance(start, askedGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,6 +914,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return true if it inherits the group.
|
* @return true if it inherits the group.
|
||||||
*/
|
*/
|
||||||
public boolean hasGroupInInheritance(Group start, String askedGroup) {
|
public boolean hasGroupInInheritance(Group start, String askedGroup) {
|
||||||
|
|
||||||
if (start == null || askedGroup == null) {
|
if (start == null || askedGroup == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -920,6 +950,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean checkGroupPermissionWithInheritance(Group start, String permission, List<Group> alreadyChecked) {
|
public boolean checkGroupPermissionWithInheritance(Group start, String permission, List<Group> alreadyChecked) {
|
||||||
|
|
||||||
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
||||||
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -942,6 +973,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return PermissionCheckResult
|
* @return PermissionCheckResult
|
||||||
*/
|
*/
|
||||||
public PermissionCheckResult checkGroupPermissionWithInheritance(Group start, String targetPermission) {
|
public PermissionCheckResult checkGroupPermissionWithInheritance(Group start, String targetPermission) {
|
||||||
|
|
||||||
if (start == null || targetPermission == null) {
|
if (start == null || targetPermission == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -982,6 +1014,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Group nextGroupWithPermission(Group start, String permission, List<Group> alreadyChecked) {
|
public Group nextGroupWithPermission(Group start, String permission, List<Group> alreadyChecked) {
|
||||||
|
|
||||||
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
||||||
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
||||||
return (Group) checkGroupPermissionWithInheritance(start, permission).owner;
|
return (Group) checkGroupPermissionWithInheritance(start, permission).owner;
|
||||||
@@ -1003,6 +1036,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ArrayList<String> listAllGroupsInherited(Group start, ArrayList<String> alreadyChecked) {
|
public ArrayList<String> listAllGroupsInherited(Group start, ArrayList<String> alreadyChecked) {
|
||||||
|
|
||||||
return listAllGroupsInherited(start);
|
return listAllGroupsInherited(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,6 +1050,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return the group that passed on test. null if no group passed.
|
* @return the group that passed on test. null if no group passed.
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> listAllGroupsInherited(Group start) {
|
public ArrayList<String> listAllGroupsInherited(Group start) {
|
||||||
|
|
||||||
if (start == null) {
|
if (start == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1055,6 +1090,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* @return PermissionCheckResult.Type
|
* @return PermissionCheckResult.Type
|
||||||
*/
|
*/
|
||||||
public PermissionCheckResult.Type comparePermissionString(String userAccessLevel, String fullPermissionName) {
|
public PermissionCheckResult.Type comparePermissionString(String userAccessLevel, String fullPermissionName) {
|
||||||
|
|
||||||
int userAccessLevelLength;
|
int userAccessLevelLength;
|
||||||
if (userAccessLevel == null || fullPermissionName == null || fullPermissionName.length() == 0 || (userAccessLevelLength = userAccessLevel.length()) == 0) {
|
if (userAccessLevel == null || fullPermissionName == null || fullPermissionName.length() == 0 || (userAccessLevelLength = userAccessLevel.length()) == 0) {
|
||||||
return PermissionCheckResult.Type.NOTFOUND;
|
return PermissionCheckResult.Type.NOTFOUND;
|
||||||
@@ -1080,12 +1116,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (userAccessLevel.charAt(userAccessLevel.length() - 1) == '*') {
|
if (userAccessLevel.charAt(userAccessLevel.length() - 1) == '*') {
|
||||||
return userAccessLevel.regionMatches(true, userAccessLevelOffset, fullPermissionName, fullPermissionNameOffset, userAccessLevelLength - userAccessLevelOffset - 1) ?
|
return userAccessLevel.regionMatches(true, userAccessLevelOffset, fullPermissionName, fullPermissionNameOffset, userAccessLevelLength - userAccessLevelOffset - 1) ? result : PermissionCheckResult.Type.NOTFOUND;
|
||||||
result : PermissionCheckResult.Type.NOTFOUND;
|
|
||||||
} else {
|
} else {
|
||||||
return userAccessLevel.regionMatches(true, userAccessLevelOffset, fullPermissionName, fullPermissionNameOffset,
|
return userAccessLevel.regionMatches(true, userAccessLevelOffset, fullPermissionName, fullPermissionNameOffset, Math.max(userAccessLevelLength - userAccessLevelOffset, fullPermissionName.length() - fullPermissionNameOffset)) ? result : PermissionCheckResult.Type.NOTFOUND;
|
||||||
Math.max(userAccessLevelLength - userAccessLevelOffset, fullPermissionName.length() - fullPermissionNameOffset)) ?
|
|
||||||
result : PermissionCheckResult.Type.NOTFOUND;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1099,6 +1132,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] getGroups(String userName) {
|
public String[] getGroups(String userName) {
|
||||||
|
|
||||||
ArrayList<String> allGroups = listAllGroupsInherited(ph.getUser(userName).getGroup());
|
ArrayList<String> allGroups = listAllGroupsInherited(ph.getUser(userName).getGroup());
|
||||||
for (Group subg : ph.getUser(userName).subGroupListCopy()) {
|
for (Group subg : ph.getUser(userName).subGroupListCopy()) {
|
||||||
allGroups.addAll(listAllGroupsInherited(subg));
|
allGroups.addAll(listAllGroupsInherited(subg));
|
||||||
@@ -1120,6 +1154,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Group breadthFirstSearch(Group start, String targerPermission) {
|
private Group breadthFirstSearch(Group start, String targerPermission) {
|
||||||
|
|
||||||
if (start == null || targerPermission == null) {
|
if (start == null || targerPermission == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1149,11 +1184,13 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group getDefaultGroup() {
|
public Group getDefaultGroup() {
|
||||||
|
|
||||||
return ph.getDefaultGroup();
|
return ph.getDefaultGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInfoString(String entryName, String path, boolean isGroup) {
|
public String getInfoString(String entryName, String path, boolean isGroup) {
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
Group data = ph.getGroup(entryName);
|
Group data = ph.getGroup(entryName);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -1171,6 +1208,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInfoInteger(String entryName, String path, boolean isGroup) {
|
public int getInfoInteger(String entryName, String path, boolean isGroup) {
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
Group data = ph.getGroup(entryName);
|
Group data = ph.getGroup(entryName);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -1188,6 +1226,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getInfoDouble(String entryName, String path, boolean isGroup) {
|
public double getInfoDouble(String entryName, String path, boolean isGroup) {
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
Group data = ph.getGroup(entryName);
|
Group data = ph.getGroup(entryName);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -1206,6 +1245,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getInfoBoolean(String entryName, String path, boolean isGroup) {
|
public boolean getInfoBoolean(String entryName, String path, boolean isGroup) {
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
Group data = ph.getGroup(entryName);
|
Group data = ph.getGroup(entryName);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -1223,21 +1263,25 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addUserInfo(String name, String path, Object data) {
|
public void addUserInfo(String name, String path, Object data) {
|
||||||
|
|
||||||
ph.getUser(name).getVariables().addVar(path, data);
|
ph.getUser(name).getVariables().addVar(path, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUserInfo(String name, String path) {
|
public void removeUserInfo(String name, String path) {
|
||||||
|
|
||||||
ph.getUser(name).getVariables().removeVar(path);
|
ph.getUser(name).getVariables().removeVar(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGroupInfo(String name, String path, Object data) {
|
public void addGroupInfo(String name, String path, Object data) {
|
||||||
|
|
||||||
ph.getGroup(name).getVariables().addVar(path, data);
|
ph.getGroup(name).getVariables().addVar(path, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeGroupInfo(String name, String path) {
|
public void removeGroupInfo(String name, String path) {
|
||||||
|
|
||||||
ph.getGroup(name).getVariables().removeVar(path);
|
ph.getGroup(name).getVariables().removeVar(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
*/
|
* USA.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.anjocaido.groupmanager.permissions;
|
package org.anjocaido.groupmanager.permissions;
|
||||||
|
|
||||||
@@ -47,7 +48,6 @@ import org.bukkit.permissions.PermissionAttachment;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* BukkitPermissions overrides to force GM reponses to Superperms
|
* BukkitPermissions overrides to force GM reponses to Superperms
|
||||||
@@ -67,6 +67,7 @@ public class BukkitPermissions {
|
|||||||
* @return the player_join
|
* @return the player_join
|
||||||
*/
|
*/
|
||||||
public boolean isPlayer_join() {
|
public boolean isPlayer_join() {
|
||||||
|
|
||||||
return player_join;
|
return player_join;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ public class BukkitPermissions {
|
|||||||
* @param player_join the player_join to set
|
* @param player_join the player_join to set
|
||||||
*/
|
*/
|
||||||
public void setPlayer_join(boolean player_join) {
|
public void setPlayer_join(boolean player_join) {
|
||||||
|
|
||||||
this.player_join = player_join;
|
this.player_join = player_join;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +94,7 @@ public class BukkitPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPermissions(GroupManager plugin) {
|
public BukkitPermissions(GroupManager plugin) {
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.collectPermissions();
|
this.collectPermissions();
|
||||||
this.registerEvents();
|
this.registerEvents();
|
||||||
@@ -101,14 +104,15 @@ public class BukkitPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
|
|
||||||
PluginManager manager = plugin.getServer().getPluginManager();
|
PluginManager manager = plugin.getServer().getPluginManager();
|
||||||
|
|
||||||
manager.registerEvents(new PlayerEvents(), plugin);
|
manager.registerEvents(new PlayerEvents(), plugin);
|
||||||
manager.registerEvents(new BukkitEvents(), plugin);
|
manager.registerEvents(new BukkitEvents(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void collectPermissions() {
|
public void collectPermissions() {
|
||||||
|
|
||||||
registeredPermissions.clear();
|
registeredPermissions.clear();
|
||||||
|
|
||||||
for (Permission perm : Bukkit.getPluginManager().getPermissions()) {
|
for (Permission perm : Bukkit.getPluginManager().getPermissions()) {
|
||||||
@@ -118,18 +122,20 @@ public class BukkitPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePermissions(Player player) {
|
public void updatePermissions(Player player) {
|
||||||
|
|
||||||
this.updatePermissions(player, null);
|
this.updatePermissions(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push all permissions which are registered with GM for this player, on this world to Bukkit
|
* Push all permissions which are registered with GM for this player, on
|
||||||
|
* this world to Bukkit
|
||||||
* and make it update for the child nodes.
|
* and make it update for the child nodes.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param world
|
* @param world
|
||||||
*/
|
*/
|
||||||
public void updatePermissions(Player player, String world) {
|
public void updatePermissions(Player player, String world) {
|
||||||
|
|
||||||
if (player == null || !GroupManager.isLoaded()) {
|
if (player == null || !GroupManager.isLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -159,11 +165,12 @@ public class BukkitPermissions {
|
|||||||
Boolean value = false;
|
Boolean value = false;
|
||||||
for (String permission : playerPermArray) {
|
for (String permission : playerPermArray) {
|
||||||
value = (!permission.startsWith("-"));
|
value = (!permission.startsWith("-"));
|
||||||
newPerms.put((value? permission : permission.substring(1)), value);
|
newPerms.put((value ? permission : permission.substring(1)), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is put in place until such a time as Bukkit pull 466 is implemented
|
* This is put in place until such a time as Bukkit pull 466 is
|
||||||
|
* implemented
|
||||||
* https://github.com/Bukkit/Bukkit/pull/466
|
* https://github.com/Bukkit/Bukkit/pull/466
|
||||||
*/
|
*/
|
||||||
try { // Codename_B source
|
try { // Codename_B source
|
||||||
@@ -194,15 +201,15 @@ public class BukkitPermissions {
|
|||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
for (String key : permList) {
|
for (String key : permList) {
|
||||||
String a = key.charAt(0) == '-'? key.substring(1):key;
|
String a = key.charAt(0) == '-' ? key.substring(1) : key;
|
||||||
Map<String, Boolean> allchildren = GroupManager.BukkitPermissions.getAllChildren(a, new HashSet<String>());
|
Map<String, Boolean> allchildren = GroupManager.BukkitPermissions.getAllChildren(a, new HashSet<String>());
|
||||||
if (allchildren != null) {
|
if (allchildren != null) {
|
||||||
|
|
||||||
ListIterator<String> itr = result.listIterator();
|
ListIterator<String> itr = result.listIterator();
|
||||||
|
|
||||||
while (itr.hasNext()){
|
while (itr.hasNext()) {
|
||||||
String node = (String) itr.next();
|
String node = (String) itr.next();
|
||||||
String b = node.charAt(0) == '-'? node.substring(1):node;
|
String b = node.charAt(0) == '-' ? node.substring(1) : node;
|
||||||
|
|
||||||
// Insert the parent node before the child
|
// Insert the parent node before the child
|
||||||
if (allchildren.containsKey(b)) {
|
if (allchildren.containsKey(b)) {
|
||||||
@@ -219,7 +226,6 @@ public class BukkitPermissions {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all permissions which are registered with superperms.
|
* Fetch all permissions which are registered with superperms.
|
||||||
* {can include child nodes)
|
* {can include child nodes)
|
||||||
@@ -254,7 +260,8 @@ public class BukkitPermissions {
|
|||||||
* null is empty
|
* null is empty
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
* @param playerPermArray current list of perms to check against for negations
|
* @param playerPermArray current list of perms to check against for
|
||||||
|
* negations
|
||||||
* @return Map of child permissions
|
* @return Map of child permissions
|
||||||
*/
|
*/
|
||||||
public Map<String, Boolean> getAllChildren(String node, Set<String> playerPermArray) {
|
public Map<String, Boolean> getAllChildren(String node, Set<String> playerPermArray) {
|
||||||
@@ -269,7 +276,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
Map<String, Boolean> children = getChildren(now);
|
Map<String, Boolean> children = getChildren(now);
|
||||||
|
|
||||||
if ((children != null) && (!playerPermArray.contains("-"+now))) {
|
if ((children != null) && (!playerPermArray.contains("-" + now))) {
|
||||||
for (String childName : children.keySet()) {
|
for (String childName : children.keySet()) {
|
||||||
if (!alreadyVisited.containsKey(childName)) {
|
if (!alreadyVisited.containsKey(childName)) {
|
||||||
stack.push(childName);
|
stack.push(childName);
|
||||||
@@ -279,13 +286,15 @@ public class BukkitPermissions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
alreadyVisited.remove(node);
|
alreadyVisited.remove(node);
|
||||||
if (!alreadyVisited.isEmpty()) return alreadyVisited;
|
if (!alreadyVisited.isEmpty())
|
||||||
|
return alreadyVisited;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of the child permissions (1 node deep) as registered with Bukkit.
|
* Returns a map of the child permissions (1 node deep) as registered with
|
||||||
|
* Bukkit.
|
||||||
* null is empty
|
* null is empty
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
@@ -308,6 +317,7 @@ public class BukkitPermissions {
|
|||||||
* @return List<String> of permissions
|
* @return List<String> of permissions
|
||||||
*/
|
*/
|
||||||
public List<String> listPerms(Player player) {
|
public List<String> listPerms(Player player) {
|
||||||
|
|
||||||
List<String> perms = new ArrayList<String>();
|
List<String> perms = new ArrayList<String>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -332,6 +342,7 @@ public class BukkitPermissions {
|
|||||||
* force Bukkit to update every OnlinePlayers permissions.
|
* force Bukkit to update every OnlinePlayers permissions.
|
||||||
*/
|
*/
|
||||||
public void updateAllPlayers() {
|
public void updateAllPlayers() {
|
||||||
|
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
updatePermissions(player);
|
updatePermissions(player);
|
||||||
}
|
}
|
||||||
@@ -341,6 +352,7 @@ public class BukkitPermissions {
|
|||||||
* force Bukkit to update this Players permissions.
|
* force Bukkit to update this Players permissions.
|
||||||
*/
|
*/
|
||||||
public void updatePlayer(Player player) {
|
public void updatePlayer(Player player) {
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
this.updatePermissions(player, null);
|
this.updatePermissions(player, null);
|
||||||
}
|
}
|
||||||
@@ -351,6 +363,7 @@ public class BukkitPermissions {
|
|||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
private void removeAttachment(Player player) {
|
private void removeAttachment(Player player) {
|
||||||
|
|
||||||
if (attachments.containsKey(player)) {
|
if (attachments.containsKey(player)) {
|
||||||
try {
|
try {
|
||||||
player.removeAttachment(attachments.get(player));
|
player.removeAttachment(attachments.get(player));
|
||||||
@@ -371,7 +384,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
Iterator<Player> itr = attachments.keySet().iterator();
|
Iterator<Player> itr = attachments.keySet().iterator();
|
||||||
|
|
||||||
while (itr.hasNext()){
|
while (itr.hasNext()) {
|
||||||
Player player = itr.next();
|
Player player = itr.next();
|
||||||
try {
|
try {
|
||||||
player.removeAttachment(attachments.get(player));
|
player.removeAttachment(attachments.get(player));
|
||||||
@@ -395,6 +408,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
|
||||||
setPlayer_join(true);
|
setPlayer_join(true);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@@ -413,11 +427,13 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { // has changed worlds
|
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { // has changed worlds
|
||||||
|
|
||||||
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
|
updatePermissions(event.getPlayer(), event.getPlayer().getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -428,6 +444,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
|
||||||
if (!GroupManager.isLoaded())
|
if (!GroupManager.isLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -444,6 +461,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPluginEnable(PluginEnableEvent event) {
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
|
||||||
if (!GroupManager.isLoaded())
|
if (!GroupManager.isLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -453,6 +471,7 @@ public class BukkitPermissions {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPluginDisable(PluginDisableEvent event) {
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
|
|
||||||
collectPermissions();
|
collectPermissions();
|
||||||
// updateAllPlayers();
|
// updateAllPlayers();
|
||||||
}
|
}
|
||||||
|
@@ -169,7 +169,7 @@ public abstract class PermissionsReaderInterface {
|
|||||||
*/
|
*/
|
||||||
public abstract double getPermissionDouble(String userName, String node);
|
public abstract double getPermissionDouble(String userName, String node);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
/**
|
/**
|
||||||
* Gets the appropriate prefix for the user.
|
* Gets the appropriate prefix for the user.
|
||||||
* This method is a utility method for chat plugins to get the user's prefix
|
* This method is a utility method for chat plugins to get the user's prefix
|
||||||
@@ -193,36 +193,47 @@ public abstract class PermissionsReaderInterface {
|
|||||||
public abstract String getUserSuffix(String user);
|
public abstract String getUserSuffix(String user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the group object representing the default group of the given world.
|
* Returns the group object representing the default group of the given
|
||||||
* This method will return null if the object does not exist or the world has no default group.
|
* world.
|
||||||
* @return Group object representing default world, or null if it doesn't exist or is not defined.
|
* This method will return null if the object does not exist or the world
|
||||||
|
* has no default group.
|
||||||
|
*
|
||||||
|
* @return Group object representing default world, or null if it doesn't
|
||||||
|
* exist or is not defined.
|
||||||
*/
|
*/
|
||||||
public abstract Group getDefaultGroup();
|
public abstract Group getDefaultGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a array of the names of all parent groups in the same world.
|
* Gets a array of the names of all parent groups in the same world.
|
||||||
|
*
|
||||||
* @param name Target user's name
|
* @param name Target user's name
|
||||||
* @return An array containing the names of all parent groups (including ancestors) that are in the same world
|
* @return An array containing the names of all parent groups (including
|
||||||
|
* ancestors) that are in the same world
|
||||||
*/
|
*/
|
||||||
public abstract String[] getGroups(String name);
|
public abstract String[] getGroups(String name);
|
||||||
|
|
||||||
public abstract String getInfoString(String entryName, String path, boolean isGroup);
|
public abstract String getInfoString(String entryName, String path, boolean isGroup);
|
||||||
|
|
||||||
//public abstract String getInfoString(String entryName, String path, boolean isGroup, Comparator<String> comparator);
|
//public abstract String getInfoString(String entryName, String path, boolean isGroup, Comparator<String> comparator);
|
||||||
|
|
||||||
public abstract int getInfoInteger(String entryName, String path, boolean isGroup);
|
public abstract int getInfoInteger(String entryName, String path, boolean isGroup);
|
||||||
|
|
||||||
//public abstract int getInfoInteger(String entryName, String path, boolean isGroup, Comparator<Integer> comparator);
|
//public abstract int getInfoInteger(String entryName, String path, boolean isGroup, Comparator<Integer> comparator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a double from the Info node without inheritance.
|
* Gets a double from the Info node without inheritance.
|
||||||
|
*
|
||||||
* @param entryName
|
* @param entryName
|
||||||
* @param path
|
* @param path
|
||||||
* @param isGroup
|
* @param isGroup
|
||||||
* @return -1 if not found
|
* @return -1 if not found
|
||||||
*/
|
*/
|
||||||
public abstract double getInfoDouble(String entryName, String path, boolean isGroup);
|
public abstract double getInfoDouble(String entryName, String path, boolean isGroup);
|
||||||
|
|
||||||
//public abstract double getInfoDouble(String entryName, String path, boolean isGroup, Comparator<Double> comparator);
|
//public abstract double getInfoDouble(String entryName, String path, boolean isGroup, Comparator<Double> comparator);
|
||||||
|
|
||||||
public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup);
|
public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup);
|
||||||
|
|
||||||
//public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup, Comparator<Boolean> comparator);
|
//public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup, Comparator<Boolean> comparator);
|
||||||
|
|
||||||
public abstract void addUserInfo(String name, String path, Object data);
|
public abstract void addUserInfo(String name, String path, Object data);
|
||||||
@@ -232,7 +243,8 @@ public abstract class PermissionsReaderInterface {
|
|||||||
public abstract void addGroupInfo(String name, String path, Object data);
|
public abstract void addGroupInfo(String name, String path, Object data);
|
||||||
|
|
||||||
public abstract void removeGroupInfo(String name, String path);
|
public abstract void removeGroupInfo(String name, String path);
|
||||||
//////////////////////////////
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
public abstract List<String> getAllPlayersPermissions(String userName);
|
public abstract List<String> getAllPlayersPermissions(String userName);
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ public class GMLoggerHandler extends ConsoleHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(LogRecord record) {
|
public void publish(LogRecord record) {
|
||||||
|
|
||||||
String message = "GroupManager - " + record.getLevel() + " - " + record.getMessage();
|
String message = "GroupManager - " + record.getLevel() + " - " + record.getMessage();
|
||||||
if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
|
if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
|
||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
|
@@ -6,47 +6,10 @@ package org.anjocaido.groupmanager.utils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Just a list of commands for this plugin
|
* Just a list of commands for this plugin
|
||||||
|
*
|
||||||
* @author gabrielcouto
|
* @author gabrielcouto
|
||||||
*/
|
*/
|
||||||
public enum GroupManagerPermissions {
|
public enum GroupManagerPermissions {
|
||||||
|
|
||||||
manuadd,
|
manuadd, manudel, manuaddsub, manudelsub, mangadd, mangdel, manuaddp, manudelp, manulistp, manucheckp, mangaddp, mangdelp, manglistp, mangcheckp, mangaddi, mangdeli, manuaddv, manudelv, manulistv, manucheckv, mangaddv, mangdelv, manglistv, mangcheckv, manwhois, tempadd, tempdel, templist, tempdelall, mansave, manload, listgroups, manpromote, mandemote, mantogglevalidate, mantogglesave, manworld, manselect, manclear
|
||||||
manudel,
|
|
||||||
manuaddsub,
|
|
||||||
manudelsub,
|
|
||||||
mangadd,
|
|
||||||
mangdel,
|
|
||||||
manuaddp,
|
|
||||||
manudelp,
|
|
||||||
manulistp,
|
|
||||||
manucheckp,
|
|
||||||
mangaddp,
|
|
||||||
mangdelp,
|
|
||||||
manglistp,
|
|
||||||
mangcheckp,
|
|
||||||
mangaddi,
|
|
||||||
mangdeli,
|
|
||||||
manuaddv,
|
|
||||||
manudelv,
|
|
||||||
manulistv,
|
|
||||||
manucheckv,
|
|
||||||
mangaddv,
|
|
||||||
mangdelv,
|
|
||||||
manglistv,
|
|
||||||
mangcheckv,
|
|
||||||
manwhois,
|
|
||||||
tempadd,
|
|
||||||
tempdel,
|
|
||||||
templist,
|
|
||||||
tempdelall,
|
|
||||||
mansave,
|
|
||||||
manload,
|
|
||||||
listgroups,
|
|
||||||
manpromote,
|
|
||||||
mandemote,
|
|
||||||
mantogglevalidate,
|
|
||||||
mantogglesave,
|
|
||||||
manworld,
|
|
||||||
manselect,
|
|
||||||
manclear
|
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@ public class StringPermissionComparator implements Comparator<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(String permA, String permB) {
|
public int compare(String permA, String permB) {
|
||||||
|
|
||||||
boolean ap = permA.startsWith("+");
|
boolean ap = permA.startsWith("+");
|
||||||
boolean bp = permB.startsWith("+");
|
boolean bp = permB.startsWith("+");
|
||||||
boolean am = permA.startsWith("-");
|
boolean am = permA.startsWith("-");
|
||||||
@@ -38,9 +39,11 @@ public class StringPermissionComparator implements Comparator<String> {
|
|||||||
}
|
}
|
||||||
return permA.compareToIgnoreCase(permB);
|
return permA.compareToIgnoreCase(permB);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StringPermissionComparator instance;
|
private static StringPermissionComparator instance;
|
||||||
|
|
||||||
public static StringPermissionComparator getInstance() {
|
public static StringPermissionComparator getInstance() {
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new StringPermissionComparator();
|
instance = new StringPermissionComparator();
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author gabrielcouto
|
* @author gabrielcouto
|
||||||
@@ -36,6 +35,7 @@ public abstract class Tasks {
|
|||||||
* @return stack trace as a string
|
* @return stack trace as a string
|
||||||
*/
|
*/
|
||||||
public static String getStackTraceAsString(Exception exception) {
|
public static String getStackTraceAsString(Exception exception) {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
exception.printStackTrace(pw);
|
exception.printStackTrace(pw);
|
||||||
@@ -43,6 +43,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(InputStream src, File dst) throws IOException {
|
public static void copy(InputStream src, File dst) throws IOException {
|
||||||
|
|
||||||
InputStream in = src;
|
InputStream in = src;
|
||||||
OutputStream out = new FileOutputStream(dst);
|
OutputStream out = new FileOutputStream(dst);
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(File src, File dst) throws IOException {
|
public static void copy(File src, File dst) throws IOException {
|
||||||
|
|
||||||
InputStream in = new FileInputStream(src);
|
InputStream in = new FileInputStream(src);
|
||||||
copy(in, dst);
|
copy(in, dst);
|
||||||
}
|
}
|
||||||
@@ -87,8 +89,9 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removeOldFiles(GroupManager gm, File folder) {
|
public static void removeOldFiles(GroupManager gm, File folder) {
|
||||||
|
|
||||||
if (folder.isDirectory()) {
|
if (folder.isDirectory()) {
|
||||||
long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000);
|
long oldTime = System.currentTimeMillis() - (((long) gm.getGMConfig().getBackupDuration() * 60 * 60) * 1000);
|
||||||
for (File olds : folder.listFiles()) {
|
for (File olds : folder.listFiles()) {
|
||||||
if (olds.isFile()) {
|
if (olds.isFile()) {
|
||||||
if (olds.lastModified() < oldTime) {
|
if (olds.lastModified() < oldTime) {
|
||||||
@@ -103,6 +106,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getDateString() {
|
public static String getDateString() {
|
||||||
|
|
||||||
GregorianCalendar now = new GregorianCalendar();
|
GregorianCalendar now = new GregorianCalendar();
|
||||||
String date = "";
|
String date = "";
|
||||||
date += now.get(Calendar.DAY_OF_MONTH);
|
date += now.get(Calendar.DAY_OF_MONTH);
|
||||||
@@ -114,6 +118,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getStringListInString(List<String> list) {
|
public static String getStringListInString(List<String> list) {
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -128,6 +133,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getStringArrayInString(String[] list) {
|
public static String getStringArrayInString(String[] list) {
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -142,6 +148,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getGroupListInString(List<Group> list) {
|
public static String getGroupListInString(List<Group> list) {
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -156,6 +163,7 @@ public abstract class Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String join(String[] arr, String separator) {
|
public static String join(String[] arr, String separator) {
|
||||||
|
|
||||||
if (arr.length == 0)
|
if (arr.length == 0)
|
||||||
return "";
|
return "";
|
||||||
String out = arr[0].toString();
|
String out = arr[0].toString();
|
||||||
|
Reference in New Issue
Block a user