summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-04-13 14:40:26 +0100
committerElgarL <ElgarL@palmergames.com>2012-04-13 14:40:26 +0100
commit3005bc1ca076f620a06c2bfc8517565b0b5a38b8 (patch)
treedb6120a3833a6dea4f074a50184682f216bdb383 /EssentialsGroupManager/src/org/anjocaido/groupmanager/utils
parent6b33504c09dc5cabcd0d78c0f442dcc34e882a64 (diff)
downloadEssentials-3005bc1ca076f620a06c2bfc8517565b0b5a38b8.tar
Essentials-3005bc1ca076f620a06c2bfc8517565b0b5a38b8.tar.gz
Essentials-3005bc1ca076f620a06c2bfc8517565b0b5a38b8.tar.lz
Essentials-3005bc1ca076f620a06c2bfc8517565b0b5a38b8.tar.xz
Essentials-3005bc1ca076f620a06c2bfc8517565b0b5a38b8.zip
Update all code formatting to use tabs for indentation.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/utils')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java21
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java41
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java102
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java71
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java216
5 files changed, 213 insertions, 238 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java
index 87b6806ab..de5348b17 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java
@@ -9,18 +9,19 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
/**
- *
+ *
* @author gabrielcouto
*/
public class GMLoggerHandler extends ConsoleHandler {
- @Override
- public void publish(LogRecord record) {
- String message = "GroupManager - " + record.getLevel() + " - " + record.getMessage();
- if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
- System.err.println(message);
- } else {
- System.out.println(message);
- }
- }
+ @Override
+ public void publish(LogRecord record) {
+
+ String message = "GroupManager - " + record.getLevel() + " - " + record.getMessage();
+ if (record.getLevel().equals(Level.SEVERE) || record.getLevel().equals(Level.WARNING)) {
+ System.err.println(message);
+ } else {
+ System.out.println(message);
+ }
+ }
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java
index 0262bb33e..f8cef89c7 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java
@@ -6,47 +6,10 @@ package org.anjocaido.groupmanager.utils;
/**
* Just a list of commands for this plugin
+ *
* @author gabrielcouto
*/
public enum GroupManagerPermissions {
- 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
+ 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
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java
index 88ac48427..eb6633863 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java
@@ -7,61 +7,61 @@ package org.anjocaido.groupmanager.utils;
import org.anjocaido.groupmanager.data.DataUnit;
/**
- *
+ *
* @author gabrielcouto
*/
public class PermissionCheckResult {
- /**
- * It should be the owner of the access level found.
- *
- * Use instanceof to find the owner type
- */
- public DataUnit owner;
- /**
- * The permission node found in the DataUnit.
- */
- public String accessLevel;
- /**
- * The full name of the permission you are looking for
- */
- public String askedPermission;
- /**
- * The result conclusion of the search.
- * It determines if the owner can do, or not.
- *
- * It even determines if it has an owner.
- */
- public Type resultType = Type.NOTFOUND;
+ /**
+ * It should be the owner of the access level found.
+ *
+ * Use instanceof to find the owner type
+ */
+ public DataUnit owner;
+ /**
+ * The permission node found in the DataUnit.
+ */
+ public String accessLevel;
+ /**
+ * The full name of the permission you are looking for
+ */
+ public String askedPermission;
+ /**
+ * The result conclusion of the search.
+ * It determines if the owner can do, or not.
+ *
+ * It even determines if it has an owner.
+ */
+ public Type resultType = Type.NOTFOUND;
- /**
- * The type of result the search can give.
- */
- public enum Type {
+ /**
+ * The type of result the search can give.
+ */
+ public enum Type {
- /**
- * If found a matching node starting with '+'.
- * It means the user CAN do the permission.
- */
- EXCEPTION,
- /**
- * If found a matching node starting with '-'.
- * It means the user CANNOT do the permission.
- */
- NEGATION,
- /**
- * If just found a common matching node.
- * IT means the user CAN do the permission.
- */
- FOUND,
- /**
- * If no matchin node was found.
- * It means the user CANNOT do the permission.
- *
- * owner field and accessLevel field should not be considered,
- * when type is
- * NOTFOUND
- */
- NOTFOUND
- }
+ /**
+ * If found a matching node starting with '+'.
+ * It means the user CAN do the permission.
+ */
+ EXCEPTION,
+ /**
+ * If found a matching node starting with '-'.
+ * It means the user CANNOT do the permission.
+ */
+ NEGATION,
+ /**
+ * If just found a common matching node.
+ * IT means the user CAN do the permission.
+ */
+ FOUND,
+ /**
+ * If no matchin node was found.
+ * It means the user CANNOT do the permission.
+ *
+ * owner field and accessLevel field should not be considered,
+ * when type is
+ * NOTFOUND
+ */
+ NOTFOUND
+ }
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java
index ab2fd605b..5a56cd9fc 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java
@@ -7,43 +7,46 @@ package org.anjocaido.groupmanager.utils;
import java.util.Comparator;
/**
- *
+ *
* @author gabrielcouto
*/
public class StringPermissionComparator implements Comparator<String> {
- @Override
- public int compare(String permA, String permB) {
- boolean ap = permA.startsWith("+");
- boolean bp = permB.startsWith("+");
- boolean am = permA.startsWith("-");
- boolean bm = permB.startsWith("-");
- if (ap && bp) {
- return 0;
- }
- if (ap && !bp) {
- return -1;
- }
- if (!ap && bp) {
- return 1;
- }
- if (am && bm) {
- return 0;
- }
- if (am && !bm) {
- return -1;
- }
- if (!am && bm) {
- return 1;
- }
- return permA.compareToIgnoreCase(permB);
- }
- private static StringPermissionComparator instance;
+ @Override
+ public int compare(String permA, String permB) {
- public static StringPermissionComparator getInstance() {
- if (instance == null) {
- instance = new StringPermissionComparator();
- }
- return instance;
- }
+ boolean ap = permA.startsWith("+");
+ boolean bp = permB.startsWith("+");
+ boolean am = permA.startsWith("-");
+ boolean bm = permB.startsWith("-");
+ if (ap && bp) {
+ return 0;
+ }
+ if (ap && !bp) {
+ return -1;
+ }
+ if (!ap && bp) {
+ return 1;
+ }
+ if (am && bm) {
+ return 0;
+ }
+ if (am && !bm) {
+ return -1;
+ }
+ if (!am && bm) {
+ return 1;
+ }
+ return permA.compareToIgnoreCase(permB);
+ }
+
+ private static StringPermissionComparator instance;
+
+ public static StringPermissionComparator getInstance() {
+
+ if (instance == null) {
+ instance = new StringPermissionComparator();
+ }
+ return instance;
+ }
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
index 663da1123..d75737c66 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
@@ -22,13 +22,12 @@ import java.util.List;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
-
/**
- *
+ *
* @author gabrielcouto
*/
public abstract class Tasks {
-
+
/**
* Gets the exception stack trace as a string.
*
@@ -36,35 +35,38 @@ public abstract class Tasks {
* @return stack trace as a string
*/
public static String getStackTraceAsString(Exception exception) {
+
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
return sw.toString();
}
- public static void copy(InputStream src, File dst) throws IOException {
- InputStream in = src;
- OutputStream out = new FileOutputStream(dst);
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- out.close();
- try {
- in.close();
- } catch (Exception e) {
- }
- }
-
- public static void copy(File src, File dst) throws IOException {
- InputStream in = new FileInputStream(src);
- copy(in, dst);
- }
-
- /**
+ public static void copy(InputStream src, File dst) throws IOException {
+
+ InputStream in = src;
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ try {
+ in.close();
+ } catch (Exception e) {
+ }
+ }
+
+ public static void copy(File src, File dst) throws IOException {
+
+ InputStream in = new FileInputStream(src);
+ copy(in, dst);
+ }
+
+ /**
* Appends a string to a file
*
* @param data
@@ -82,86 +84,92 @@ public abstract class Tasks {
out.append(System.getProperty("line.separator"));
out.append(data);
out.append(System.getProperty("line.separator"));
-
+
out.close();
}
- public static void removeOldFiles(GroupManager gm, File folder) {
- if (folder.isDirectory()) {
- long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000);
- for (File olds : folder.listFiles()) {
- if (olds.isFile()) {
- if (olds.lastModified() < oldTime) {
- try {
- olds.delete();
- } catch (Exception e) {
- }
- }
- }
- }
- }
- }
-
- public static String getDateString() {
- GregorianCalendar now = new GregorianCalendar();
- String date = "";
- date += now.get(Calendar.DAY_OF_MONTH);
- date += "-";
- date += now.get(Calendar.HOUR);
- date += "-";
- date += now.get(Calendar.MINUTE);
- return date;
- }
-
- public static String getStringListInString(List<String> list) {
- if (list == null) {
- return "";
- }
- String result = "";
- for (int i = 0; i < list.size(); i++) {
- result += list.get(i);
- if (i < list.size() - 1) {
- result += ", ";
- }
- }
- return result;
- }
-
- public static String getStringArrayInString(String[] list) {
- if (list == null) {
- return "";
- }
- String result = "";
- for (int i = 0; i < list.length; i++) {
- result += list[i];
- if (i < ((list.length) - 1)) {
- result += ", ";
- }
- }
- return result;
- }
-
- public static String getGroupListInString(List<Group> list) {
- if (list == null) {
- return "";
- }
- String result = "";
- for (int i = 0; i < list.size(); i++) {
- result += list.get(i).getName();
- if (i < list.size() - 1) {
- result += ", ";
- }
- }
- return result;
- }
-
- public static String join(String[] arr, String separator) {
- if (arr.length == 0)
- return "";
- String out = arr[0].toString();
- for (int i = 1; i < arr.length; i++)
- out += separator + arr[i];
- return out;
- }
+ public static void removeOldFiles(GroupManager gm, File folder) {
+
+ if (folder.isDirectory()) {
+ long oldTime = System.currentTimeMillis() - (((long) gm.getGMConfig().getBackupDuration() * 60 * 60) * 1000);
+ for (File olds : folder.listFiles()) {
+ if (olds.isFile()) {
+ if (olds.lastModified() < oldTime) {
+ try {
+ olds.delete();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static String getDateString() {
+
+ GregorianCalendar now = new GregorianCalendar();
+ String date = "";
+ date += now.get(Calendar.DAY_OF_MONTH);
+ date += "-";
+ date += now.get(Calendar.HOUR);
+ date += "-";
+ date += now.get(Calendar.MINUTE);
+ return date;
+ }
+
+ public static String getStringListInString(List<String> list) {
+
+ if (list == null) {
+ return "";
+ }
+ String result = "";
+ for (int i = 0; i < list.size(); i++) {
+ result += list.get(i);
+ if (i < list.size() - 1) {
+ result += ", ";
+ }
+ }
+ return result;
+ }
+
+ public static String getStringArrayInString(String[] list) {
+
+ if (list == null) {
+ return "";
+ }
+ String result = "";
+ for (int i = 0; i < list.length; i++) {
+ result += list[i];
+ if (i < ((list.length) - 1)) {
+ result += ", ";
+ }
+ }
+ return result;
+ }
+
+ public static String getGroupListInString(List<Group> list) {
+
+ if (list == null) {
+ return "";
+ }
+ String result = "";
+ for (int i = 0; i < list.size(); i++) {
+ result += list.get(i).getName();
+ if (i < list.size() - 1) {
+ result += ", ";
+ }
+ }
+ return result;
+ }
+
+ public static String join(String[] arr, String separator) {
+
+ if (arr.length == 0)
+ return "";
+ String out = arr[0].toString();
+ for (int i = 1; i < arr.length; i++)
+ out += separator + arr[i];
+ return out;
+ }
}