summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/nbproject/build-impl.xml14
-rw-r--r--Essentials/nbproject/genfiles.properties4
-rw-r--r--Essentials/nbproject/project.properties10
-rw-r--r--Essentials/nbproject/project.xml11
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java48
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java128
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java84
-rw-r--r--Essentials/src/com/earth2me/essentials/ExecuteTimer.java84
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandme.java14
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java69
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java33
-rw-r--r--Essentials/src/config.yml1
-rw-r--r--Essentials/src/examples/bpermissions.yml1
-rw-r--r--Essentials/src/examples/permissionsbukkit.yml3
-rw-r--r--Essentials/src/examples/permissionsex.yml1
-rw-r--r--Essentials/src/messages.properties5
-rw-r--r--Essentials/src/messages_da.properties5
-rw-r--r--Essentials/src/messages_de.properties5
-rw-r--r--Essentials/src/messages_en.properties5
-rw-r--r--Essentials/src/messages_fr.properties5
-rw-r--r--Essentials/src/messages_nl.properties5
-rw-r--r--EssentialsGeoIP/nbproject/genfiles.properties2
-rw-r--r--EssentialsGroupManager/src/Changelog.txt7
-rw-r--r--EssentialsGroupManager/src/config.yml6
-rw-r--r--EssentialsGroupManager/src/groups.yml1
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java1
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java25
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java29
-rw-r--r--EssentialsGroupManager/src/plugin.yml2
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java (renamed from EssentialsUpdate/src/com/earth2me/essentials/update/WorkListener.java)5
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java402
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java13
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java7
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java25
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java3
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java126
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java28
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/Version.java2
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java77
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java9
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java62
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/ErrorsCommand.java71
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/HelpCommand.java18
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java (renamed from EssentialsUpdate/src/com/earth2me/essentials/update/IrcBot.java)22
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java32
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/StartupCommand.java77
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/UsernameUtil.java124
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java26
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java91
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java4
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java4
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java4
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java4
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java12
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java121
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java7
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java59
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java8
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java57
-rw-r--r--EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java66
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java7
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java2
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java2
-rw-r--r--build.xml18
-rw-r--r--lib/PermissionsEx-javadoc.jarbin0 -> 378789 bytes
-rw-r--r--lib/PermissionsEx.jarbin116307 -> 132878 bytes
-rw-r--r--lib/nblibraries.properties1
72 files changed, 1388 insertions, 874 deletions
diff --git a/Essentials/nbproject/build-impl.xml b/Essentials/nbproject/build-impl.xml
index 21661c925..0816b04c9 100644
--- a/Essentials/nbproject/build-impl.xml
+++ b/Essentials/nbproject/build-impl.xml
@@ -601,6 +601,13 @@ is divided into following sections:
<propertyfile file="${built-jar.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
+ <antcall target="-maybe-call-dep">
+ <param name="call.built.properties" value="${built-jar.properties}"/>
+ <param location="${project.EssentialsGroupManager}" name="call.subproject"/>
+ <param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
+ <param name="call.target" value="jar"/>
+ <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
+ </antcall>
</target>
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
<target depends="init" name="-check-automatic-build">
@@ -1038,6 +1045,13 @@ is divided into following sections:
<propertyfile file="${built-clean.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
+ <antcall target="-maybe-call-dep">
+ <param name="call.built.properties" value="${built-clean.properties}"/>
+ <param location="${project.EssentialsGroupManager}" name="call.subproject"/>
+ <param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
+ <param name="call.target" value="clean"/>
+ <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
+ </antcall>
</target>
<target depends="init" name="-do-clean">
<delete dir="${build.dir}"/>
diff --git a/Essentials/nbproject/genfiles.properties b/Essentials/nbproject/genfiles.properties
index 9242cfd2b..d39edfe18 100644
--- a/Essentials/nbproject/genfiles.properties
+++ b/Essentials/nbproject/genfiles.properties
@@ -3,8 +3,8 @@ build.xml.script.CRC32=3233ee78
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=4b596d89
-nbproject/build-impl.xml.script.CRC32=dbc81ee1
+nbproject/build-impl.xml.data.CRC32=a830bc14
+nbproject/build-impl.xml.script.CRC32=64a00ba6
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
index bea59e4ab..079cf2b0c 100644
--- a/Essentials/nbproject/project.properties
+++ b/Essentials/nbproject/project.properties
@@ -68,7 +68,7 @@ file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHO
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.iCo6.jar=../lib/iCo6.jar
-file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
+file.reference.junit-4.5.jar=../lib/junit_4/junit-4.5.jar
file.reference.lombok-0.10.1.jar=../lib/lombok-0.10.1.jar
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
@@ -80,7 +80,6 @@ jar.compress=true
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.Permissions3.jar}:\
- ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}:\
${file.reference.iCo6.jar}:\
@@ -89,7 +88,9 @@ javac.classpath=\
${file.reference.PermissionsEx.jar}:\
${file.reference.bPermissions.jar}:\
${file.reference.PermissionsBukkit-1.2.jar}:\
- ${file.reference.lombok-0.10.1.jar}
+ ${file.reference.lombok-0.10.1.jar}:\
+ ${reference.EssentialsGroupManager.jar}:\
+ ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
@@ -110,6 +111,7 @@ javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
+javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
@@ -126,6 +128,8 @@ jnlp.signing.keystore=
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=true
platform.active=default_platform
+project.EssentialsGroupManager=../EssentialsGroupManager
+reference.EssentialsGroupManager.jar=../EssentialsGroupManager/dist/EssentialsGroupManager.jar
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
diff --git a/Essentials/nbproject/project.xml b/Essentials/nbproject/project.xml
index 354722f09..ac9690fc3 100644
--- a/Essentials/nbproject/project.xml
+++ b/Essentials/nbproject/project.xml
@@ -14,6 +14,15 @@
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>../lib/nblibraries.properties</definitions>
</libraries>
- <references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
+ <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
+ <reference>
+ <foreign-project>EssentialsGroupManager</foreign-project>
+ <artifact-type>jar</artifact-type>
+ <script>build.xml</script>
+ <target>jar</target>
+ <clean-target>clean</clean-target>
+ <id>jar</id>
+ </reference>
+ </references>
</configuration>
</project>
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 27543dae3..a571483f6 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -33,7 +33,6 @@ import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
import com.earth2me.essentials.signs.SignEntityListener;
import com.earth2me.essentials.signs.SignPlayerListener;
-import java.math.BigInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.command.PluginCommand;
@@ -58,12 +57,10 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient List<IConf> confList;
private transient Backup backup;
private transient ItemDb itemDb;
- private transient EssentialsUpdateTimer updateTimer;
private transient final Methods paymentMethod = new Methods();
- private transient final static boolean enableErrorLogging = false;
- private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
private transient PermissionsHandler permissionsHandler;
private transient UserMap userMap;
+ private transient ExecuteTimer execTimer;
@Override
public ISettings getSettings()
@@ -94,32 +91,36 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void onEnable()
{
+ execTimer = new ExecuteTimer();
+ execTimer.start();
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
if (javaversion == null || javaversion.length < 2 || Integer.parseInt(javaversion[1]) < 6)
{
LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version"));
}
- if (enableErrorLogging)
- {
- LOGGER.addHandler(errorHandler);
- }
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
+ execTimer.mark("Upgrade");
confList = new ArrayList<IConf>();
settings = new Settings(this);
confList.add(settings);
+ execTimer.mark("Settings");
upgrade.afterSettings();
+ execTimer.mark("Upgrade2");
Util.updateLocale(settings.getLocale(), this);
userMap = new UserMap(this);
confList.add(userMap);
+ execTimer.mark("Init(Usermap)");
spawn = new Spawn(getServer(), this.getDataFolder());
confList.add(spawn);
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
+ execTimer.mark("Init(Spawn/Warp)");
worth = new Worth(this.getDataFolder());
confList.add(worth);
itemDb = new ItemDb(this);
confList.add(itemDb);
+ execTimer.mark("Init(Worth/ItemDB)");
reload();
backup = new Backup(this);
@@ -191,6 +192,7 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
+ //TODO: Check if this should be here, and not above before reload()
jail = new Jail(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
confList.add(jail);
@@ -207,19 +209,19 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
Economy.setEss(this);
- if (getSettings().isUpdateEnabled())
+ execTimer.mark("RegListeners");
+ LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
+ final String timeroutput = execTimer.end();
+ if (getSettings().isDebug())
{
- updateTimer = new EssentialsUpdateTimer(this);
- getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
+ LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
- LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
}
@Override
public void onDisable()
{
Trade.closeLog();
- LOGGER.removeHandler(errorHandler);
}
@Override
@@ -230,6 +232,7 @@ public class Essentials extends JavaPlugin implements IEssentials
for (IConf iConf : confList)
{
iConf.reloadConfig();
+ execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
}
Util.updateLocale(settings.getLocale(), this);
@@ -479,14 +482,6 @@ public class Essentials extends JavaPlugin implements IEssentials
{
LOGGER.log(logRecord);
}
- else
- {
- if (enableErrorLogging)
- {
- errorHandler.publish(logRecord);
- errorHandler.flush();
- }
- }
}
@Override
@@ -609,10 +604,12 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public int broadcastMessage(final IUser sender, final String message)
{
- if (sender == null) {
+ if (sender == null)
+ {
return getServer().broadcastMessage(message);
}
- if (sender.isHidden()) {
+ if (sender.isHidden())
+ {
return 0;
}
final Player[] players = getServer().getOnlinePlayers();
@@ -629,11 +626,6 @@ public class Essentials extends JavaPlugin implements IEssentials
return players.length;
}
- public Map<BigInteger, String> getErrors()
- {
- return errorHandler.getErrors();
- }
-
@Override
public int scheduleAsyncDelayedTask(final Runnable run)
{
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java b/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java
deleted file mode 100644
index 68dc5fbce..000000000
--- a/Essentials/src/com/earth2me/essentials/EssentialsErrorHandler.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.earth2me.essentials;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-
-class EssentialsErrorHandler extends Handler
-{
- private final Map<BigInteger, String> errors = new HashMap<BigInteger, String>();
- private final List<LogRecord> records = new LinkedList<LogRecord>();
-
- public EssentialsErrorHandler()
- {
- }
-
- @Override
- public void publish(LogRecord lr)
- {
- if (lr.getThrown() == null || lr.getLevel().intValue() < Level.WARNING.intValue())
- {
- return;
- }
- synchronized (records)
- {
- records.add(lr);
- }
- }
-
- @Override
- public void flush()
- {
- synchronized (records)
- {
- sortRecords();
- }
- }
-
- @Override
- public void close() throws SecurityException
- {
- synchronized (records)
- {
- sortRecords();
- }
- }
-
- private void sortRecords()
- {
- for (LogRecord lr : records)
- {
- try
- {
- if (lr.getThrown() == null)
- {
- return;
- }
- Throwable tr = lr.getThrown();
- StackTraceElement[] elements = tr.getStackTrace();
- if (elements == null || elements.length <= 0)
- {
- return;
- }
- boolean essentialsFound = false;
- for (StackTraceElement stackTraceElement : elements)
- {
- if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
- {
- essentialsFound = true;
- break;
- }
- }
- if (!essentialsFound && tr.getCause() != null)
- {
- Throwable cause = tr.getCause();
- StackTraceElement[] elements2 = cause.getStackTrace();
- if (elements2 != null)
- {
- for (StackTraceElement stackTraceElement : elements2)
- {
- if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
- {
- essentialsFound = true;
- break;
- }
- }
- }
- }
- StringBuilder sb = new StringBuilder();
- sb.append("[").append(lr.getLevel().getName()).append("] ").append(lr.getMessage()).append("\n");
- sb.append(tr.getMessage()).append("\n");
- for (StackTraceElement stackTraceElement : tr.getStackTrace())
- {
- sb.append(stackTraceElement.toString()).append("\n");
- }
- if (tr.getCause() != null && tr.getCause().getStackTrace() != null)
- {
- sb.append(tr.getCause().getMessage()).append("\n");
- for (StackTraceElement stackTraceElement : tr.getCause().getStackTrace())
- {
- sb.append(stackTraceElement.toString()).append("\n");
- }
- }
- String errorReport = sb.toString();
- byte[] bytesOfMessage = errorReport.getBytes("UTF-8");
- MessageDigest md = MessageDigest.getInstance("MD5");
- BigInteger bi = new BigInteger(md.digest(bytesOfMessage));
- errors.put(bi, errorReport);
- }
- catch (Throwable t)
- {
- //Ignore all exceptions inside the exception handler
- }
- }
- records.clear();
- }
-
- Map<BigInteger, String> getErrors()
- {
- return errors;
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java
deleted file mode 100644
index 6f7579d4e..000000000
--- a/Essentials/src/com/earth2me/essentials/EssentialsUpdateTimer.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.earth2me.essentials;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.bukkit.entity.Player;
-
-
-class EssentialsUpdateTimer implements Runnable
-{
- private transient URL url;
- private final transient IEssentials ess;
- private static final Logger LOGGER = Logger.getLogger("Minecraft");
- private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
-
- public EssentialsUpdateTimer(final IEssentials ess)
- {
- this.ess = ess;
- try
- {
- url = new URL("http://essentialsupdate.appspot.com/check");
- }
- catch (MalformedURLException ex)
- {
- LOGGER.log(Level.SEVERE, "Invalid url!", ex);
- }
- }
-
- @Override
- public void run()
- {
- try
- {
- final StringBuilder builder = new StringBuilder();
- String bukkitVersion = ess.getServer().getVersion();
- final Matcher versionMatch = pattern.matcher(bukkitVersion);
- if (versionMatch.matches())
- {
- bukkitVersion = versionMatch.group(4);
- }
- builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
- builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
- final URLConnection conn = url.openConnection();
- conn.setConnectTimeout(10000);
- conn.setDoOutput(true);
- conn.connect();
- final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
- writer.write(builder.toString());
- writer.flush();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- final String ret = reader.readLine();
- writer.close();
- reader.close();
- if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
- {
- LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
- if (ret.startsWith("New Version"))
- {
- for (Player player : ess.getServer().getOnlinePlayers())
- {
- final User user = ess.getUser(player);
- if (user.isAuthorized("essentials.admin.notices.update"))
- {
- user.sendMessage(ret);
- }
- }
- }
- }
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
- }
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/ExecuteTimer.java b/Essentials/src/com/earth2me/essentials/ExecuteTimer.java
new file mode 100644
index 000000000..7a88018c2
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/ExecuteTimer.java
@@ -0,0 +1,84 @@
+package com.earth2me.essentials;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ExecuteTimer
+{
+ private final List<ExecuteRecord> times;
+
+ public ExecuteTimer()
+ {
+ times = new ArrayList<ExecuteRecord>();
+ }
+
+ public void start()
+ {
+ times.clear();
+ mark("start");
+
+ }
+
+ public void mark(final String label)
+ {
+ if (!times.isEmpty() || "start".equals(label))
+ {
+ times.add(new ExecuteRecord(label, System.currentTimeMillis()));
+ }
+ }
+
+ public String end()
+ {
+ final StringBuilder output = new StringBuilder();
+ output.append("execution time: ");
+ String mark;
+ long time0 = 0;
+ long time1 = 0;
+ long time2 = 0;
+ long duration;
+
+ for (ExecuteRecord pair : times)
+ {
+ mark = (String)pair.getMark();
+ time2 = (Long)pair.getTime();
+ if (time1 > 0)
+ {
+ duration = time2 - time1;
+ output.append(mark).append(": ").append(duration).append("ms - ");
+ }
+ else
+ {
+ time0 = time2;
+ }
+ time1 = time2;
+ }
+ duration = time1 - time0;
+ output.append("Total: ").append(duration).append("ms");
+ times.clear();
+ return output.toString();
+ }
+
+
+ static private class ExecuteRecord
+ {
+ private final String mark;
+ private final long time;
+
+ public ExecuteRecord(final String mark, final long time)
+ {
+ this.mark = mark;
+ this.time = time;
+ }
+
+ public String getMark()
+ {
+ return mark;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+ }
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index d058d892a..7ffa0c138 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -124,8 +124,10 @@ public interface ISettings extends IConf
boolean useBukkitPermissions();
boolean addPrefixSuffix();
-
- boolean isUpdateEnabled();
+
+ boolean disablePrefix();
+
+ boolean disableSuffix();
long getAutoAfk();
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index e59c3c2b2..ca076c272 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -498,11 +498,15 @@ public class Settings implements ISettings
{
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
-
- @Override
- public boolean isUpdateEnabled()
+
+ public boolean disablePrefix()
+ {
+ return config.getBoolean("disablePrefix", false);
+ }
+
+ public boolean disableSuffix()
{
- return config.getBoolean("update-check", false);
+ return config.getBoolean("disableSuffix", false);
}
@Override
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index bcc871eab..f0754cdb4 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
- private boolean justPortaled = false;
private CommandSender replyTo = null;
private transient User teleportRequester;
private transient boolean teleportRequestHere;
@@ -156,16 +155,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.base = new OfflinePlayer(getName(), ess);
}
- public boolean getJustPortaled()
- {
- return justPortaled;
- }
-
- public void setJustPortaled(final boolean value)
- {
- justPortaled = value;
- }
-
@Override
public void setReplyTo(final CommandSender user)
{
@@ -269,12 +258,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (ess.getSettings().addPrefixSuffix())
{
- final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
- final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
- nickname.insert(0, prefix);
- nickname.append(suffix);
- if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
+ if (!ess.getSettings().disablePrefix())
+ {
+ final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
+ nickname.insert(0, prefix);
+ }
+ if (!ess.getSettings().disableSuffix())
+ {
+ final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
+ nickname.append(suffix);
+ if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
+ {
+ nickname.append("§f");
+ }
+ }
+ else
{
nickname.append("§f");
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
index 02bcecdc2..779e78420 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
@@ -24,15 +24,13 @@ public class Commandme extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- final StringBuilder message = new StringBuilder();
- message.append("* ");
- message.append(user.getDisplayName());
- message.append(' ');
- for (int i = 0; i < args.length; i++)
+
+ String message = getFinalArg(args, 0);
+ if (user.isAuthorized("essentials.chat.color"))
{
- message.append(args[i]);
- message.append(' ');
+ message = message.replaceAll("&([0-9a-f])", "§$1");
}
- ess.broadcastMessage(user, message.toString());
+
+ ess.broadcastMessage(user, Util.format("action", user.getDisplayName(), message));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java
new file mode 100644
index 000000000..20b3806e0
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/perm/GroupManagerHandler.java
@@ -0,0 +1,69 @@
+package com.earth2me.essentials.perm;
+
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+import org.anjocaido.groupmanager.GroupManager;
+import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
+
+
+public class GroupManagerHandler implements IPermissionsHandler
+{
+ private final transient GroupManager groupManager;
+
+ public GroupManagerHandler(final Plugin permissionsPlugin)
+ {
+ groupManager = ((GroupManager)permissionsPlugin);
+ }
+
+ @Override
+ public String getGroup(final Player base)
+ {
+ final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.getGroup(base.getName());
+ }
+
+ @Override
+ public List<String> getGroups(final Player base)
+ {
+ final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return Arrays.asList(handler.getGroups(base.getName()));
+ }
+
+ @Override
+ public boolean canBuild(final Player base, final String group)
+ {
+ final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.canUserBuild(base.getName());
+ }
+
+ @Override
+ public boolean inGroup(final Player base, final String group)
+ {
+ AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.inGroup(base.getName(), group);
+ }
+
+ @Override
+ public boolean hasPermission(final Player base, final String node)
+ {
+ AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.has(base, node);
+ }
+
+ @Override
+ public String getPrefix(final Player base)
+ {
+ AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.getUserPrefix(base.getName());
+ }
+
+ @Override
+ public String getSuffix(final Player base)
+ {
+ AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
+ return handler.getUserSuffix(base.getName());
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java
index 5b7bb7b81..4062a162c 100644
--- a/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java
@@ -77,7 +77,7 @@ public class PermissionsExHandler implements IPermissionsHandler
{
return null;
}
- return user.getPrefix();
+ return user.getPrefix(base.getWorld().getName());
}
@Override
@@ -88,6 +88,7 @@ public class PermissionsExHandler implements IPermissionsHandler
{
return null;
}
- return user.getSuffix();
+
+ return user.getSuffix(base.getWorld().getName());
}
}
diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
index 8adff346a..ab69d9fe4 100644
--- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
@@ -111,17 +111,6 @@ public class PermissionsHandler implements IPermissionsHandler
return;
}
- final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
- if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
- {
- if (!(handler instanceof PermissionsBukkitHandler))
- {
- LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
- handler = new PermissionsBukkitHandler(permBukkitPlugin);
- }
- return;
- }
-
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
if (bPermPlugin != null && bPermPlugin.isEnabled())
{
@@ -132,6 +121,28 @@ public class PermissionsHandler implements IPermissionsHandler
}
return;
}
+
+ final Plugin GMplugin = pluginManager.getPlugin("GroupManager");
+ if (GMplugin != null && GMplugin.isEnabled())
+ {
+ if (!(handler instanceof GroupManagerHandler))
+ {
+ LOGGER.log(Level.INFO, "Essentials: Using GroupManager based permissions.");
+ handler = new GroupManagerHandler(GMplugin);
+ }
+ return;
+ }
+
+ final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
+ if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
+ {
+ if (!(handler instanceof PermissionsBukkitHandler))
+ {
+ LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
+ handler = new PermissionsBukkitHandler(permBukkitPlugin);
+ }
+ return;
+ }
final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (permPlugin != null && permPlugin.isEnabled())
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index b5ad0d95a..472887d5d 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -144,7 +144,6 @@ player-commands:
- nick
- pay
- ping
- - portal
- powertool
- protect
- r
diff --git a/Essentials/src/examples/bpermissions.yml b/Essentials/src/examples/bpermissions.yml
index aeae4ea80..6b7900c4f 100644
--- a/Essentials/src/examples/bpermissions.yml
+++ b/Essentials/src/examples/bpermissions.yml
@@ -31,7 +31,6 @@ groups:
- essentials.nick
- essentials.pay
- essentials.ping
- - essentials.portal
- essentials.powertool
- essentials.protect
- essentials.sethome
diff --git a/Essentials/src/examples/permissionsbukkit.yml b/Essentials/src/examples/permissionsbukkit.yml
index 243752232..2251985e7 100644
--- a/Essentials/src/examples/permissionsbukkit.yml
+++ b/Essentials/src/examples/permissionsbukkit.yml
@@ -38,8 +38,7 @@ groups:
essentials.msg: true
essentials.nick: true
essentials.pay: true
- essentials.ping: true
- essentials.portal: true
+ essentials.ping: true
essentials.powertool: true
essentials.protect: true
essentials.sethome: true
diff --git a/Essentials/src/examples/permissionsex.yml b/Essentials/src/examples/permissionsex.yml
index 47407cd62..3dc6354fb 100644
--- a/Essentials/src/examples/permissionsex.yml
+++ b/Essentials/src/examples/permissionsex.yml
@@ -37,7 +37,6 @@ groups:
- essentials.nick
- essentials.pay
- essentials.ping
- - essentials.portal
- essentials.powertool
- essentials.protect
- essentials.sethome
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index c3019473c..ef149d68c 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by:
+action = * {0} {1}
addedToAccount = \u00a7a{0} has been added to your account.
addedToOthersAccount = \u00a7a{0} has been added to {1} account.
alertBroke = broke:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Notice: Your configuration file has a corrupt {0} n
couldNotFindTemplate = Could not find template {0}
creatingConfigFromTemplate = Creating config from template: {0}
creatingEmptyConfig = Creating empty config: {0}
-creatingPortal = Creating portal at {0},{1},{2}.
day = day
days = days
defaultBanReason = The Ban Hammer has spoken!
@@ -83,7 +83,6 @@ gcentities = entities
gcfree = Free memory: {0} MB
gcmax = Maximum memory: {0} MB
gctotal = Allocated memory: {0} MB
-generatingPortal = \u00a77Generating an exit portal.
geoIpUrlEmpty = GeoIP download url is empty.
geoIpUrlInvalid = GeoIP download url is invalid.
geoipJoinFormat = Player {0} comes from {1}
@@ -331,7 +330,6 @@ unlimitedItemPermission = \u00a7cNo permission for unlimited item {0}.
unlimitedItems = Unlimited items:
unmutedPlayer = Player {0} unmuted.
upgradingFilesError = Error while upgrading the files
-userCreatedPortal = {0} used a portal and generated an exit portal.
userDoesNotExist = The user {0} does not exist.
userIsAway = {0} is now AFK
userIsNotAway = {0} is no longer AFK
@@ -339,7 +337,6 @@ userJailed = \u00a77You have been jailed
userUsedPortal = {0} used an existing exit portal.
userdataMoveBackError = Failed to move userdata/{0}.tmp to userdata/{1}
userdataMoveError = Failed to move userdata/{0} to userdata/{1}.tmp
-usingPortal = \u00a77Teleporting via portal to an existing portal.
usingTempFolderForTesting = Using temp folder for testing:
versionMismatch = Version mismatch! Please update {0} to the same version.
versionMismatchAll = Version mismatch! Please update all Essentials jars to the same version.
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 5ca3048b6..960fd8321 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by: papand13, papand13@gmail.com
+action = * {0} {1}
addedToAccount = \u00a7a{0} er tilf\u00f8jet til din konto.
addedToOthersAccount = \u00a7a{0} er blevet tilf\u00f8jet til {1} konto.
alertBroke = \u00f8delagde:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Notice: Din konfigurations fil har en korrupt {0} n
couldNotFindTemplate = Kunne ikke finde skabelon {0}
creatingConfigFromTemplate = Opretter config fra skabelon: {0}
creatingEmptyConfig = Opretter tom config: {0}
-creatingPortal = Opretter portal ved {0},{1},{2}.
day = dag
days = dage
defaultBanReason = Ban hammeren har talt!
@@ -83,7 +83,6 @@ gcentities = enheder
gcfree = Free memory: {0} MB
gcmax = Maximum memory: {0} MB
gctotal = Allocated memory: {0} MB
-generatingPortal = \u00a77Genererer en udgangs portal.
geoIpUrlEmpty = GeoIP download url er tom.
geoIpUrlInvalid = GeoIP download url er ugyldig.
geoipJoinFormat = Spiller {0} kommer fra {1}
@@ -330,7 +329,6 @@ unlimitedItemPermission = \u00a7cIngen tilladelse til ubegr\u00e6nset element {0
unlimitedItems = Uendelige elementer:
unmutedPlayer = Spiller {0} ikke-d\u00e6mpet.
upgradingFilesError = Fejl under opgradering af filer
-userCreatedPortal = {0} bruge en portal og genererede en udgangs portal.
userDoesNotExist = Brugeren {0} eksisterer ikke.
userIsAway = {0} er nu AFK
userIsNotAway = {0} er ikke l\u00e6ngere AFK
@@ -338,7 +336,6 @@ userJailed = \u00a77Du er blevet f\u00e6ngslet
userUsedPortal = {0} brugte en eksisterende udgangs portal.
userdataMoveBackError = Kunne ikke flytte userdata/{0}.tmp til userdata/{1}
userdataMoveError = Kunne ikke flytte userdata/{0} til userdata/{1}.tmp
-usingPortal = \u00a77Teleporterede via portal til en eksisterende portal.
usingTempFolderForTesting = Bruger temp mappe for testing:
versionMismatch = Version matcher ikke! Venligst opdater {0} til den nyeste version.
versionMismatchAll = Version matcher ikke! Venligst opdater alle Essentials jar''er til samme version.
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index da78e0778..f0ec0f493 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by:
+action = * {0} {1}
addedToAccount = \u00a7a{0} wurden zu deiner Geldb\u00f6rse hinzugef\u00fcgt.
addedToOthersAccount = \u00a7a{0} wurden zu {1}s Konto hinzugef\u00fcgt.
alertBroke = zerst\u00f6rt:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Hinweis: Deine Konfigurationsdatei hat einen ung\u0
couldNotFindTemplate = Vorlage {0} konnte nicht gefunden werden.
creatingConfigFromTemplate = Erstelle Konfiguration aus Vorlage: {0}
creatingEmptyConfig = Erstelle leere Konfiguration: {0}
-creatingPortal = Erzeuge Portal bei {0},{1},{2}.
day = Tag
days = Tage
defaultBanReason = Der Bann-Hammer hat gesprochen!
@@ -83,7 +83,6 @@ gcentities = Einheiten
gcfree = Freier Speicher: {0} MB
gcmax = Maximaler Speicher: {0} MB
gctotal = Reservierter Speicher: {0} MB
-generatingPortal = \u00a77Erstelle ein Ausgangsportal.
geoIpUrlEmpty = GeoIP Download-URL ist leer.
geoIpUrlInvalid = GeoIP Download-URL ist ung\u00fcltig.
geoipJoinFormat = Spieler {0} kommt aus {1}
@@ -330,7 +329,6 @@ unlimitedItemPermission = \u00a7cDu hast keine Rechte f\u00fcr {0}.
unlimitedItems = Unendliche Objekte:
unmutedPlayer = Spieler {0} ist nicht mehr stumm.
upgradingFilesError = Fehler beim Aktualisieren der Dateien
-userCreatedPortal = {0} benutzt ein Portal und hat ein Ausgangsportal erstellt.
userDoesNotExist = Spieler {0} existiert nicht.
userIsAway = {0} ist abwesend.
userIsNotAway = {0} ist wieder da.
@@ -338,7 +336,6 @@ userJailed = \u00a77Du wurdest eingesperrt.
userUsedPortal = {0} benutzt ein vorhandenes Ausgangsportal.
userdataMoveBackError = Verschieben von userdata/{0}.tmp nach userdata/{1} gescheitert.
userdataMoveError = Verschieben von userdata/{0} nach userdata/{1}.tmp gescheitert.
-usingPortal = \u00a77Teleportiere durch Portal zum Ausgangsportal.
usingTempFolderForTesting = Benutze tempor\u00e4ren Ordner zum Testen:
versionMismatch = Versionen nicht identisch! Bitte aktualisiere {0}.
versionMismatchAll = Versionen ungleich! Bitte aktualisiere alle Essentials jars auf die gleiche Version.
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 144d1ec72..e4d40adf2 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by:
+action = * {0} {1}
addedToAccount = \u00a7a{0} has been added to your account.
addedToOthersAccount = \u00a7a{0} has been added to {1} account.
alertBroke = broke:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Notice: Your configuration file has a corrupt {0} n
couldNotFindTemplate = Could not find template {0}
creatingConfigFromTemplate = Creating config from template: {0}
creatingEmptyConfig = Creating empty config: {0}
-creatingPortal = Creating portal at {0},{1},{2}.
day = day
days = days
defaultBanReason = The Ban Hammer has spoken!
@@ -83,7 +83,6 @@ gcentities = entities
gcfree = Free memory: {0} MB
gcmax = Maximum memory: {0} MB
gctotal = Allocated memory: {0} MB
-generatingPortal = \u00a77Generating an exit portal.
geoIpUrlEmpty = GeoIP download url is empty.
geoIpUrlInvalid = GeoIP download url is invalid.
geoipJoinFormat = Player {0} comes from {1}
@@ -330,7 +329,6 @@ unlimitedItemPermission = \u00a7cNo permission for unlimited item {0}.
unlimitedItems = Unlimited items:
unmutedPlayer = Player {0} unmuted.
upgradingFilesError = Error while upgrading the files
-userCreatedPortal = {0} used a portal and generated an exit portal.
userDoesNotExist = The user {0} does not exist.
userIsAway = {0} is now AFK
userIsNotAway = {0} is no longer AFK
@@ -338,7 +336,6 @@ userJailed = \u00a77You have been jailed
userUsedPortal = {0} used an existing exit portal.
userdataMoveBackError = Failed to move userdata/{0}.tmp to userdata/{1}
userdataMoveError = Failed to move userdata/{0} to userdata/{1}.tmp
-usingPortal = \u00a77Teleporting via portal to an existing portal.
usingTempFolderForTesting = Using temp folder for testing:
versionMismatch = Version mismatch! Please update {0} to the same version.
versionMismatchAll = Version mismatch! Please update all Essentials jars to the same version.
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index 7fd1cd910..b96f48339 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by:
+action = * {0} {1}
addedToAccount = \u00a7a{0} a \u00e9t\u00e9 rajout\u00e9 a votre compte.
addedToOthersAccount = \u00a7a{0} a \u00e9t\u00e9 ajout\u00e9 \u00e0 {1} compte.
alertBroke = a cass\u00e9:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Annonce: Votre fichier de configuration a un {0} n\
couldNotFindTemplate = Le mod\u00e8le {0} est introuvable
creatingConfigFromTemplate = Cr\u00e9ation de la configuration \u00e0 partir du mod\u00e8le : {0}
creatingEmptyConfig = Cr\u00e9ation d''une configuration vierge : {0}
-creatingPortal = Cr\u00e9ation d''un portail \u00e0 {0},{1},{2}.
day = jour
days = jours
defaultBanReason = Le marteau du ban a frapp\u00e9!
@@ -83,7 +83,6 @@ gcentities = entit\u00e9s
gcfree = Free memory: {0} Mo
gcmax = M\u00e9moire maximale: {0} Mo
gctotal = Allocated memory: {0} Mo
-generatingPortal = \u00a77G\u00e9n\u00e9ration d''un portail de sortie.
geoIpUrlEmpty = L''url de t\u00e9l\u00e9chargement de GeoIP est vide.
geoIpUrlInvalid = L''url de t\u00e9l\u00e9chargement de GeoIP est invalide.
geoipJoinFormat = Joueur {0} vient de {1}
@@ -330,7 +329,6 @@ unlimitedItemPermission = \u00a7cPas de permission pour l''objet illimit\u00e9 {
unlimitedItems = Objets illimit\u00e9s:
unmutedPlayer = Le joueur {0} n''est plus muet.
upgradingFilesError = Erreur durant la mise \u00e0 jour des fichiers.
-userCreatedPortal = {0} a utilis\u00e9 un portail et a g\u00e9n\u00e9r\u00e9 un portail de sortie.
userDoesNotExist = L''utilisateur {0} n''existe pas.
userIsAway = {0} s''est mis en AFK
userIsNotAway = {0} n''est plus inactif
@@ -338,7 +336,6 @@ userJailed = \u00a77Vous avez \u00e9t\u00e9 emprisonn\u00e9
userUsedPortal = {0} a utilis\u00e9 un portail existant.
userdataMoveBackError = Echec du d\u00e9placement de userdata/{0}.tmp \u00e0 userdata/{1}
userdataMoveError = Echec du d\u00e9placement de userdata/{0} \u00e0 userdata/{1}.tmp
-usingPortal = \u00a77T\u00e9l\u00e9portation via portail vers un portail existant.
usingTempFolderForTesting = Utilise un fichier temporaire pour un test.
versionMismatch = Versions diff\u00e9rentes! Mettez s''il vous pla\u00eet {0} \u00e0 la m\u00eame version.
versionMismatchAll = Mauvaise version! S''il vous plait mettez des jars Essentiels de version identique.
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index e12fc07b8..f5d9fdc70 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -2,6 +2,7 @@
# Single quotes have to be doubled: ''
# Translations start here
# by: Geertje123
+action = * {0} {1}
addedToAccount = \u00a7a{0} is gestort op je account.
addedToOthersAccount = \u00a7a{0} is overgemaakt naar {1}''s rekening
alertBroke = gebroken:
@@ -44,7 +45,6 @@ corruptNodeInConfig = \u00a74Waarschuwing: Het configuratiebestand bevat een fou
couldNotFindTemplate = Het sjabloon kon niet worden gevonden {0}
creatingConfigFromTemplate = Bezig met aanmaken van een config vanaf sjabloon: {0}
creatingEmptyConfig = Bezig met een lege config aanmaken: {0}
-creatingPortal = Bezig met cre\u00ebren van portal bij {0},{1},{2}.
day = dag
days = dagen
defaultBanReason = De Ban Hamer heeft gesproken!
@@ -83,7 +83,6 @@ gcentities = entities
gcfree = Vrij geheugen: {0} MB
gcmax = Maximaal geheugen: {0} MB
gctotal = Gealloceerd geheugen: {0} MB
-generatingPortal = \u00a77Uitgangs portal aan het cre\u00ebren.
geoIpUrlEmpty = GeoIP download url is leeg.
geoIpUrlInvalid = GeoIP download url is ongeldig.
geoipJoinFormat = Speler {0} komt uit {1}
@@ -330,7 +329,6 @@ unlimitedItemPermission = \u00a7cOnbevoegd om oneindig {0} te hebben.
unlimitedItems = Oneindige voorwerpen:
unmutedPlayer = Speler {0} mag weer spreken.
upgradingFilesError = Fout tijdens het upgraden van de bestanden
-userCreatedPortal = {0} gebruikte een portal en maakte een uitgangs portal.
userDoesNotExist = Speler {0} bestaat niet.
userIsAway = {0} is nu AFK
userIsNotAway = {0} is niet meer AFK
@@ -338,7 +336,6 @@ userJailed = \u00a77Je bent in de gevangenis gezet.
userUsedPortal = {0} gebruikte een bestaande uitgangs portal.
userdataMoveBackError = Fout bij het verplaasten van userdata/{0}.tmp naar userdata/{1}
userdataMoveError = Fout bij het verplaasten van userdata/{0} naar userdata/{1}.tmp
-usingPortal = \u00a77Bezig met via de portal naar de uitgangs portal.
usingTempFolderForTesting = Tijdelijke map om te testen:
versionMismatch = Verkeerde versie! Update {0} naar dezelfde versie.
versionMismatchAll = Verkeerde versie! Update alle Essentials jars naar dezelfde versie.
diff --git a/EssentialsGeoIP/nbproject/genfiles.properties b/EssentialsGeoIP/nbproject/genfiles.properties
index 8a865da7b..397a15928 100644
--- a/EssentialsGeoIP/nbproject/genfiles.properties
+++ b/EssentialsGeoIP/nbproject/genfiles.properties
@@ -1,6 +1,6 @@
build.xml.data.CRC32=cbf94f59
build.xml.script.CRC32=c4b1bb0e
-build.xml.stylesheet.CRC32=28e38971@1.43.1.45
+build.xml.stylesheet.CRC32=28e38971@1.44.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=cbf94f59
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 6729907b5..9a2eff5f2 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -48,4 +48,9 @@ v 1.4:
Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
- Fixed reading world mirrors from the config.
- Simplified config.yml while retaining backwards compatibility.
- - Added data.save.hours setting to config. This allow control over how long backups are retained. \ No newline at end of file
+ - Added data.save.hours setting to config. This allow control over how long backups are retained.
+v 1.5:
+ - Fixed opOverrides and bukkit_perms_override to read the correct entries.
+ - Better commenting in config.yml
+ - Fixed GM to recognize Superperm child nodes.
+ If you add a node like Towny.admin GM will now correctly report on all child nodes. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index 25fb5dcd0..6bea3e3e0 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -1,9 +1,10 @@
settings:
config:
# With this enabled anyone set as op has full permissions when managing GroupManager
+ # The user will be able to promote players to the same group or even above.
opOverrides: true
- # If enabled any bukkit permissiosn which default to true will be left enabled.
+ # If enabled any plugins bukkit permissions which default to true will be left enabled.
# If the player is op any permissions set to Op will follow suit.
bukkit_perms_override: false
@@ -21,6 +22,9 @@ settings:
mirrors:
# Worlds listed here have their permissions mirrored in their children.
+ # the first element 'world' is the main worlds name
+ # subsequent elements '- world_nether' are worlds which will use the same
+ # user/groups permissions as the parent.
world:
- world_nether
- world2
diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml
index 32954d22f..6db09bdf2 100644
--- a/EssentialsGroupManager/src/groups.yml
+++ b/EssentialsGroupManager/src/groups.yml
@@ -39,7 +39,6 @@ groups:
- essentials.nick
- essentials.pay
- essentials.ping
- - essentials.portal
- essentials.powertool
- essentials.protect
- essentials.sethome
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index ad2945076..521b8c1fb 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -52,10 +52,10 @@ public class GMConfiguration {
}
public boolean isOpOverride() {
- return GMconfig.getBoolean("settings.config.bukkit_perms_override", true);
+ return GMconfig.getBoolean("settings.config.opOverrides", true);
}
public boolean isBukkitPermsOverride() {
- return GMconfig.getBoolean("settings.config.opOverrides", true);
+ return GMconfig.getBoolean("settings.config.bukkit_perms_override", false);
}
public Map<String, Object> getMirrorsMap() {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index 5ef4fc537..a450b4bee 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -763,6 +763,7 @@ public class GroupManager extends JavaPlugin {
permissionResult = permissionHandler.checkFullUserPermission(auxUser, args[1]);
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
+ sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
return false;
}
//PARECE OK
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index cb9fdf628..203ac95a9 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -7,6 +7,7 @@ package org.anjocaido.groupmanager.permissions;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.StringTokenizer;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
@@ -14,6 +15,7 @@ import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.anjocaido.groupmanager.utils.PermissionCheckResult.Type;
+import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
@@ -93,8 +95,19 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
for (String group : getGroups(userName)) {
for (String perm : ph.getGroup(group).getPermissionList()) {
- if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
+ if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) {
playerPermArray.add(perm);
+
+ Map<String, Boolean> children = GroupManager.BukkitPermissions.getChildren(perm);
+ if (children != null) {
+ for (String child : children.keySet()) {
+ if (children.get(child))
+ if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
+ playerPermArray.add(child);
+ }
+ }
+
+ }
}
}
@@ -566,6 +579,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|| result.resultType.equals(PermissionCheckResult.Type.FOUND)) {
return true;
}
+ if (Bukkit.getPlayer(user.getName()).hasPermission(permission))
+ return true;
+
return false;
}
@@ -587,7 +603,6 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
PermissionCheckResult resultUser = checkUserOnlyPermission(user, targetPermission);
if (!resultUser.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
return resultUser;
-
}
//IT ONLY CHECKS GROUPS PERMISSIONS IF RESULT FOR USER IS NOT FOUND
@@ -603,6 +618,12 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
return resultSubGroup;
}
}
+
+ if (Bukkit.getPlayer(user.getName()).hasPermission(targetPermission)) {
+ result.resultType = PermissionCheckResult.Type.FOUND;
+ result.owner = user;
+ return result;
+ }
//THEN IT RETURNS A NOT FOUND
return result;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 6a5968c22..9bc38f933 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -150,8 +150,19 @@ public class BukkitPermissions {
value = true;
}
- if (value == true)
+ if (value == true){
+ // Set the root permission
attachment.setPermission(permission, value);
+ // fetch and set all children of this permission node
+ Map<String, Boolean> children = permission.getChildren();
+ if (children != null) {
+ for (String child : children.keySet()) {
+ if (children.get(child))
+ attachment.setPermission(child, true);
+ }
+ }
+
+ }
}
// Add any missing permissions for this player (non bukkit plugins)
@@ -171,6 +182,22 @@ public class BukkitPermissions {
player.recalculatePermissions();
}
+ /**
+ * Returns a map of the child permissions as defined by the supplying plugin
+ * null is empty
+ *
+ * @param node
+ * @return
+ */
+ public Map<String, Boolean> getChildren(String node) {
+ for (Permission permission : registeredPermissions) {
+ if (permission.getName() == node) {
+ return permission.getChildren();
+ }
+ }
+ return null;
+ }
+
public List<String> listPerms(Player player) {
List<String> perms = new ArrayList<String>();
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml
index 596b4a8d8..b5af09739 100644
--- a/EssentialsGroupManager/src/plugin.yml
+++ b/EssentialsGroupManager/src/plugin.yml
@@ -1,5 +1,5 @@
name: GroupManager
-version: "1.4 (Phoenix)"
+version: "1.5 (Phoenix)"
main: org.anjocaido.groupmanager.GroupManager
website: http://www.anjocaido.info/
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/WorkListener.java b/EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java
index da6bdb978..487e372c8 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/WorkListener.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java
@@ -1,12 +1,11 @@
package com.earth2me.essentials.update;
-import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
-public abstract class WorkListener
+public abstract class AbstractWorkListener
{
- public WorkListener(final Plugin plugin, final VersionInfo newVersionInfo)
+ public AbstractWorkListener(final Plugin plugin, final VersionInfo newVersionInfo)
{
this.plugin = plugin;
this.newVersionInfo = newVersionInfo;
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java
index 3caa22cc3..ec62566ca 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java
@@ -1,16 +1,16 @@
package com.earth2me.essentials.update;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.bukkit.Bukkit;
+import com.earth2me.essentials.update.chat.Command;
+import com.earth2me.essentials.update.chat.ConfigCommand;
+import com.earth2me.essentials.update.chat.ErrorsCommand;
+import com.earth2me.essentials.update.chat.HelpCommand;
+import com.earth2me.essentials.update.chat.IrcBot;
+import com.earth2me.essentials.update.chat.ListCommand;
+import com.earth2me.essentials.update.chat.StartupCommand;
+import com.earth2me.essentials.update.chat.UsernameUtil;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -21,7 +21,6 @@ import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
-import org.jibble.pircbot.User;
public class EssentialsHelp extends PlayerListener
@@ -29,14 +28,19 @@ public class EssentialsHelp extends PlayerListener
private transient Player chatUser;
private final transient Server server;
private final transient Plugin plugin;
- private final static Charset UTF8 = Charset.forName("utf-8");
private transient IrcBot ircBot;
+ private final transient Map<String, Command> commands = new HashMap<String, Command>();
public EssentialsHelp(final Plugin plugin)
{
super();
this.plugin = plugin;
this.server = plugin.getServer();
+ commands.put("!help", new HelpCommand());
+ commands.put("!list", new ListCommand());
+ commands.put("!startup", new StartupCommand(plugin));
+ commands.put("!errors", new ErrorsCommand(plugin));
+ commands.put("!config", new ConfigCommand(plugin));
}
public void registerEvents()
@@ -46,7 +50,7 @@ public class EssentialsHelp extends PlayerListener
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Low, plugin);
}
- public void onCommand(CommandSender sender)
+ public void onCommand(final CommandSender sender)
{
if (sender instanceof Player && sender.hasPermission("essentials.helpchat"))
{
@@ -74,11 +78,7 @@ public class EssentialsHelp extends PlayerListener
public void onDisable()
{
- if ( ircBot != null)
- {
- ircBot.quit();
- ircBot = null;
- }
+ closeConnection();
}
private boolean sendChatMessage(final Player player, final String message)
@@ -90,35 +90,19 @@ public class EssentialsHelp extends PlayerListener
}
if (ircBot == null)
{
- if (messageCleaned.equalsIgnoreCase("yes"))
- {
- player.sendMessage("Connecting...");
- connectToIRC(player);
- return true;
- }
- if (messageCleaned.equalsIgnoreCase("no") || message.equalsIgnoreCase("!quit"))
- {
- chatUser = null;
- return true;
- }
- return false;
+ return handleAnswer(messageCleaned, player);
}
else
{
- if (ircBot.isKicked()) {
- chatUser = null;
- ircBot.quit();
- ircBot = null;
+ if (ircBot.isKicked())
+ {
+ closeConnection();
return false;
}
- final String lowMessage = messageCleaned.toLowerCase();
+ final String lowMessage = messageCleaned.toLowerCase(Locale.ENGLISH);
if (lowMessage.startsWith("!quit"))
{
- chatUser = null;
- if (ircBot != null) {
- ircBot.quit();
- ircBot = null;
- }
+ closeConnection();
player.sendMessage("Connection closed.");
return true;
}
@@ -126,52 +110,8 @@ public class EssentialsHelp extends PlayerListener
{
return false;
}
- if (lowMessage.startsWith("!list"))
- {
- final User[] members = ircBot.getUsers();
- final StringBuilder sb = new StringBuilder();
- for (User user : members)
- {
- if (sb.length() > 0)
- {
- sb.append("§f, ");
- }
- if (user.isOp() || user.hasVoice())
- {
- sb.append("§6");
- }
- else
- {
- sb.append("§7");
- }
- sb.append(user.getPrefix()).append(user.getNick());
- }
- player.sendMessage(sb.toString());
- return true;
- }
- if (lowMessage.startsWith("!help"))
+ if (handleCommands(lowMessage, player))
{
- player.sendMessage("Commands: (Note: Files send to the chat will be public viewable.)");
- player.sendMessage("!errors - Send the last server errors to the chat.");
- player.sendMessage("!startup - Send the last startup messages to the chat.");
- player.sendMessage("!config - Sends your Essentials config to the chat.");
- player.sendMessage("!list - List all players in chat.");
- player.sendMessage("!quit - Leave chat.");
- return true;
- }
- if (lowMessage.startsWith("!errors"))
- {
- sendErrors();
- return true;
- }
- if (lowMessage.startsWith("!startup"))
- {
- sendStartup();
- return true;
- }
- if (lowMessage.startsWith("!config"))
- {
- sendConfig();
return true;
}
ircBot.sendMessage(messageCleaned);
@@ -180,300 +120,62 @@ public class EssentialsHelp extends PlayerListener
}
}
- private String buildIrcName()
+ private void closeConnection()
{
- final StringBuilder nameBuilder = new StringBuilder();
- nameBuilder.append(chatUser.getName());
-
- final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(server.getVersion());
- if (versionMatch.matches())
- {
- nameBuilder.append(" CB");
- nameBuilder.append(versionMatch.group(4));
- }
-
- final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
- if (essentials != null)
- {
- nameBuilder.append(" ESS");
- nameBuilder.append(essentials.getDescription().getVersion());
- }
-
- final Plugin groupManager = server.getPluginManager().getPlugin("GroupManager");
- if (groupManager != null)
- {
- nameBuilder.append(" GM");
- if (!groupManager.isEnabled())
- {
- nameBuilder.append('!');
- }
- }
-
- final Plugin pex = server.getPluginManager().getPlugin("PermissionsEx");
- if (pex != null)
- {
- nameBuilder.append(" PEX");
- if (!pex.isEnabled())
- {
- nameBuilder.append('!');
- }
- nameBuilder.append(pex.getDescription().getVersion());
- }
-
- final Plugin pb = server.getPluginManager().getPlugin("PermissionsBukkit");
- if (pb != null)
- {
- nameBuilder.append(" PB");
- if (!pb.isEnabled())
- {
- nameBuilder.append('!');
- }
- nameBuilder.append(pb.getDescription().getVersion());
- }
-
- final Plugin bp = server.getPluginManager().getPlugin("bPermissions");
- if (bp != null)
- {
- nameBuilder.append(" BP");
- if (!bp.isEnabled())
- {
- nameBuilder.append('!');
- }
- nameBuilder.append(bp.getDescription().getVersion());
- }
-
- final Plugin perm = server.getPluginManager().getPlugin("Permissions");
- if (perm != null)
+ chatUser = null;
+ if (ircBot != null)
{
- nameBuilder.append(" P");
- if (!perm.isEnabled())
- {
- nameBuilder.append('!');
- }
- nameBuilder.append(perm.getDescription().getVersion());
+ ircBot.quit();
+ ircBot = null;
}
-
- return nameBuilder.toString();
}
- private void connectToIRC(final Player player)
+ private boolean handleAnswer(final String message, final Player player)
{
- ircBot = new IrcBot(player, "Ess_" + player.getName(), buildIrcName());
- }
-
- private void sendErrors()
- {
- BufferedReader page = null;
- try
+ if (message.equalsIgnoreCase("yes"))
{
- File bukkitFolder = plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile();
- if (bukkitFolder == null || !bukkitFolder.exists())
- {
- chatUser.sendMessage("Bukkit folder not found.");
- return;
- }
- File logFile = new File(bukkitFolder, "server.log");
- if (!logFile.exists())
- {
- chatUser.sendMessage("Server log not found.");
- return;
- }
- FileInputStream fis = new FileInputStream(logFile);
- if (logFile.length() > 1000000)
- {
- fis.skip(logFile.length() - 1000000);
- }
- page = new BufferedReader(new InputStreamReader(fis));
- final StringBuilder input = new StringBuilder();
- String line;
- Pattern pattern = Pattern.compile("^[0-9 :-]+\\[INFO\\].*");
- while ((line = page.readLine()) != null)
- {
- if (!pattern.matcher(line).matches())
- {
- input.append(line).append("\n");
- }
- }
- if (input.length() > 10000)
- {
- input.delete(0, input.length() - 10000);
- }
- final PastieUpload pastie = new PastieUpload();
- final String url = pastie.send(input.toString());
- String message = "Errors: " + url;
- chatUser.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
- ircBot.sendMessage(message);
- }
- catch (IOException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, null, ex);
- chatUser.sendMessage(ex.getMessage());
+ player.sendMessage("Connecting...");
+ connectToIRC(player);
+ return true;
}
- finally
+ if (message.equalsIgnoreCase("no") || message.equalsIgnoreCase("!quit"))
{
- try
- {
- if (page != null)
- {
- page.close();
- }
- }
- catch (IOException ex)
- {
- Logger.getLogger(EssentialsHelp.class.getName()).log(Level.SEVERE, null, ex);
- }
+ chatUser = null;
+ return true;
}
+ return false;
}
- private void sendStartup()
+ private boolean handleCommands(final String lowMessage, final Player player)
{
- BufferedReader page = null;
- try
- {
- File bukkitFolder = plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile();
- if (bukkitFolder == null || !bukkitFolder.exists())
- {
- chatUser.sendMessage("Bukkit folder not found.");
- return;
- }
- File logFile = new File(bukkitFolder, "server.log");
- if (!logFile.exists())
- {
- chatUser.sendMessage("Server log not found.");
- return;
- }
- FileInputStream fis = new FileInputStream(logFile);
- if (logFile.length() > 1000000)
- {
- fis.skip(logFile.length() - 1000000);
- }
- page = new BufferedReader(new InputStreamReader(fis));
- final StringBuilder input = new StringBuilder();
- String line;
- Pattern patternStart = Pattern.compile("^[0-9 :-]+\\[INFO\\] Starting minecraft server version.*");
- Pattern patternEnd = Pattern.compile("^[0-9 :-]+\\[INFO\\] Done \\([0-9.,]+s\\)! For help, type \"help\".*");
- boolean log = false;
- while ((line = page.readLine()) != null)
- {
- if (patternStart.matcher(line).matches())
- {
- if (input.length() > 0)
- {
- input.delete(0, input.length());
- }
- log = true;
- }
- if (log)
- {
- input.append(line).append("\n");
- }
- if (patternEnd.matcher(line).matches())
- {
- log = false;
- }
- }
- if (input.length() > 10000)
- {
- input.delete(0, input.length() - 10000);
- }
- final PastieUpload pastie = new PastieUpload();
- final String url = pastie.send(input.toString());
- String message = "Startup: " + url;
- chatUser.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
- ircBot.sendMessage(message);
- }
- catch (IOException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, null, ex);
- chatUser.sendMessage(ex.getMessage());
- }
- finally
+ final String[] parts = lowMessage.split(" ");
+ if (commands.containsKey(parts[0]))
{
- try
- {
- if (page != null)
- {
- page.close();
- }
- }
- catch (IOException ex)
- {
- Logger.getLogger(EssentialsHelp.class.getName()).log(Level.SEVERE, null, ex);
- }
+ commands.get(parts[0]).run(ircBot, player);
+ return true;
}
+ return false;
}
- private void sendConfig()
+ private void connectToIRC(final Player player)
{
- BufferedReader page = null;
- try
- {
- File configFolder = new File(plugin.getDataFolder().getParentFile(), "Essentials");
- if (!configFolder.exists())
- {
- chatUser.sendMessage("Essentials plugin folder not found.");
- return;
- }
- File configFile = new File(configFolder, "config.yml");
- if (!configFile.exists())
- {
- chatUser.sendMessage("Essentials config file not found.");
- return;
- }
- page = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
- final StringBuilder input = new StringBuilder();
- String line;
- while ((line = page.readLine()) != null)
- {
- input.append(line).append("\n");
- }
- final PastieUpload pastie = new PastieUpload();
- final String url = pastie.send(input.toString());
- String message = "Essentials config.yml: " + url;
- chatUser.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
- ircBot.sendMessage(message);
-
- }
- catch (IOException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, null, ex);
- chatUser.sendMessage(ex.getMessage());
- }
- finally
- {
- try
- {
- if (page != null)
- {
- page.close();
- }
- }
- catch (IOException ex)
- {
- Logger.getLogger(EssentialsHelp.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
+ ircBot = new IrcBot(player, "Ess_" + player.getName(), UsernameUtil.createUsername(player));
}
@Override
- public void onPlayerChat(PlayerChatEvent event)
+ public void onPlayerChat(final PlayerChatEvent event)
{
if (event.getPlayer() == chatUser)
{
- boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
+ final boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
event.setCancelled(success);
return;
}
}
@Override
- public void onPlayerQuit(PlayerQuitEvent event)
+ public void onPlayerQuit(final PlayerQuitEvent event)
{
- chatUser = null;
- if (ircBot != null) {
- ircBot.quit();
- ircBot = null;
- }
- return;
+ closeConnection();
}
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java
index d4ee6c0fc..98dbeb2ef 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials.update;
import com.earth2me.essentials.update.UpdateCheck.CheckResult;
+import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -16,26 +17,20 @@ public class EssentialsUpdate extends JavaPlugin
public void onEnable()
{
if (!getDataFolder().exists() && !getDataFolder().mkdirs() ) {
- Bukkit.getLogger().severe("Could not create data folder:"+getDataFolder().getPath());
+ Bukkit.getLogger().log(Level.SEVERE, "Could not create data folder: {0}", getDataFolder().getPath());
}
essentialsHelp = new EssentialsHelp(this);
essentialsHelp.registerEvents();
final UpdateCheck updateCheck = new UpdateCheck(this);
+ updateCheck.checkForUpdates();
updateProcess = new UpdateProcess(this, updateCheck);
updateProcess.registerEvents();
- Bukkit.getLogger().info("EssentialsUpdate " + getDescription().getVersion() + " loaded.");
+ Bukkit.getLogger().log(Level.INFO, "EssentialsUpdate {0} loaded.", getDescription().getVersion());
if (updateCheck.isEssentialsInstalled())
{
- updateCheck.checkForUpdates();
- final Version myVersion = new Version(getDescription().getVersion());
- if (updateCheck.getResult() == CheckResult.NEW_ESS && myVersion.equals(updateCheck.getNewVersion()))
- {
- Bukkit.getLogger().info("Versions of EssentialsUpdate and Essentials do not match. Starting automatic update.");
- updateProcess.doAutomaticUpdate();
- }
updateCheck.scheduleUpdateTask();
}
else
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java b/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java
index 8727d2f3b..b48d95dd2 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java
@@ -12,7 +12,8 @@ import java.net.URL;
import java.net.URLConnection;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.logging.Logger;
+import java.util.logging.Level;
+import org.bukkit.Bukkit;
public class GetFile
@@ -53,7 +54,7 @@ public class GetFile
}
catch (NoSuchAlgorithmException ex)
{
- // Ignore because the code is never called
+ throw new RuntimeException(ex);
}
}
@@ -101,7 +102,7 @@ public class GetFile
}
if (brokenFile && !file.delete())
{
- Logger.getLogger("Minecraft").severe("Could not delete file " + file.getPath());
+ Bukkit.getLogger().log(Level.SEVERE, "Could not delete file {0}", file.getPath());
}
}
finally
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java
index dcda252a0..29afc4d3f 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java
@@ -3,7 +3,6 @@ package com.earth2me.essentials.update;
import java.io.File;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
@@ -22,7 +21,7 @@ public class UpdateCheck
private final transient Plugin plugin;
private transient boolean essentialsInstalled;
- public UpdateCheck(Plugin plugin)
+ public UpdateCheck(final Plugin plugin)
{
this.plugin = plugin;
updateFile = new UpdateFile(plugin);
@@ -31,21 +30,20 @@ public class UpdateCheck
private void checkForEssentials()
{
- PluginManager pm = plugin.getServer().getPluginManager();
- Plugin essentials = pm.getPlugin("Essentials");
- if (essentials == null)
+ final PluginManager pluginManager = plugin.getServer().getPluginManager();
+ final Plugin essentials = pluginManager.getPlugin("Essentials");
+ essentialsInstalled = essentials != null;
+ if (essentialsInstalled)
+ {
+ currentVersion = new Version(essentials.getDescription().getVersion());
+ }
+ else
{
- essentialsInstalled = false;
if (new File(plugin.getDataFolder().getParentFile(), "Essentials.jar").exists())
{
Bukkit.getLogger().severe("Essentials.jar found, but not recognized by Bukkit. Broken download?");
}
}
- else
- {
- essentialsInstalled = true;
- currentVersion = new Version(essentials.getDescription().getVersion());
- }
}
public void scheduleUpdateTask()
@@ -71,16 +69,17 @@ public class UpdateCheck
return result;
}
- int getNewBukkitVersion()
+ public int getNewBukkitVersion()
{
return bukkitResult;
}
- VersionInfo getNewVersionInfo()
+ public VersionInfo getNewVersionInfo()
{
return updateFile.getVersions().get(newVersion);
}
+
public enum CheckResult
{
NEW_ESS, NEW_ESS_BUKKIT, NEW_BUKKIT, OK, UNKNOWN
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java
index 8f34bffc4..95ef5e64e 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java
@@ -14,13 +14,14 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.configuration.file.YamlConfiguration;
public class UpdateFile
{
- private final static Logger LOGGER = Logger.getLogger("Minecraft");
+ private final static Logger LOGGER = Bukkit.getLogger();
private final static String UPDATE_URL = "http://goo.gl/67jev";
private final static BigInteger PUBLIC_KEY = new BigInteger("5ha6a2d4qdy17ttkg8evh74sl5a87djojwenu12k1lvy8ui6003e6l06rntczpoh99mhc3txj8mqlxw111oyy9yl7s7qpyluyzix3j1odxrxx4u52gxvyu6qiteapczkzvi7rxgeqsozz7b19rdx73a7quo9ybwpz1cr82r7x5k0pg2a73pjjsv2j1awr13azo7klrcxp9y5xxwf5qv1s3tw4zqftli18u0ek5qkbzfbgk1v5n2f11pkwwk6p0mibrn26wnjbv11vyiqgu95o7busmt6vf5q7grpcenl637w83mbin56s3asj1131b2mscj9xep3cbj7la9tgsxl5bj87vzy8sk2d34kzwqdqgh9nry43nqqus12l1stmiv184r8r3jcy8w43e8h1u1mzklldb5eytkuhayqik8l3ns04hwt8sgacvw534be8sx26qrn5s1", 36);
private final transient File file;
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
index 80434480f..1b26f1d32 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
@@ -1,10 +1,14 @@
package com.earth2me.essentials.update;
+import com.earth2me.essentials.update.states.InstallationFinishedEvent;
import com.earth2me.essentials.update.states.StateMachine;
-import java.util.List;
+import com.earth2me.essentials.update.tasks.SelfUpdate;
+import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.event.CustomEventListener;
+import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerChatEvent;
@@ -23,6 +27,7 @@ public class UpdateProcess extends PlayerListener
public UpdateProcess(final Plugin plugin, final UpdateCheck updateCheck)
{
+ super();
this.plugin = plugin;
this.updateCheck = updateCheck;
}
@@ -32,6 +37,77 @@ public class UpdateProcess extends PlayerListener
final PluginManager pluginManager = plugin.getServer().getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
+ pluginManager.registerEvent(Type.PLAYER_JOIN, this, Priority.Normal, plugin);
+ pluginManager.registerEvent(Type.CUSTOM_EVENT, new CustomEventListener()
+ {
+ @Override
+ public void onCustomEvent(final Event event)
+ {
+ if (event instanceof InstallationFinishedEvent)
+ {
+ UpdateProcess.this.currentPlayer = null;
+ }
+ }
+ }, Priority.Normal, plugin);
+ }
+
+ public boolean selfUpdate()
+ {
+ if (new Version(plugin.getDescription().getVersion()).compareTo(updateCheck.getNewVersion()) < 0)
+ {
+ if (currentPlayer != null)
+ {
+ currentPlayer.sendMessage("A newer version of EssentialsUpdate is found. Downloading new file and reloading server.");
+ }
+ Bukkit.getLogger().log(Level.INFO, "A newer version of EssentialsUpdate is found. Downloading new file and reloading server.");
+ new SelfUpdate(new AbstractWorkListener(plugin, updateCheck.getNewVersionInfo())
+ {
+ @Override
+ public void onWorkAbort(final String message)
+ {
+ if (message != null && !message.isEmpty()
+ && UpdateProcess.this.currentPlayer != null
+ && UpdateProcess.this.currentPlayer.isOnline())
+ {
+ UpdateProcess.this.currentPlayer.sendMessage(message);
+ }
+ if (message != null && !message.isEmpty())
+ {
+ Bukkit.getLogger().log(Level.SEVERE, message);
+ }
+ UpdateProcess.this.currentPlayer = null;
+ }
+
+ @Override
+ public void onWorkDone(final String message)
+ {
+ if (message != null && !message.isEmpty()
+ && UpdateProcess.this.currentPlayer != null
+ && UpdateProcess.this.currentPlayer.isOnline())
+ {
+ UpdateProcess.this.currentPlayer.sendMessage(message);
+ }
+ if (message != null && !message.isEmpty())
+ {
+ Bukkit.getLogger().log(Level.INFO, message);
+ }
+ UpdateProcess.this.currentPlayer = null;
+ }
+ }).start();
+ return true;
+ }
+ if (updateCheck.getResult() == UpdateCheck.CheckResult.NEW_ESS_BUKKIT)
+ {
+ final String message = "Please update bukkit to version " + updateCheck.getNewBukkitVersion() + " before updating Essentials.";
+ if (currentPlayer != null)
+ {
+ currentPlayer.sendMessage(message);
+ }
+ Bukkit.getLogger().log(Level.INFO, message);
+ currentPlayer = null;
+ return true;
+ }
+ return false;
}
@Override
@@ -58,6 +134,14 @@ public class UpdateProcess extends PlayerListener
public void onPlayerJoin(final PlayerJoinEvent event)
{
final Player player = event.getPlayer();
+ if (currentPlayer.getName().equals(player.getName()))
+ {
+ currentPlayer = player;
+ player.sendMessage("You quit the game, while the installation wizard was running.");
+ player.sendMessage("The installation wizard will now resume.");
+ player.sendMessage("You can exit the wizard by typing quit into the chat.");
+ stateMachine.resumeInstallation(player);
+ }
if (player.hasPermission("essentials.update") && !updateCheck.isEssentialsInstalled())
{
player.sendMessage("Hello " + player.getDisplayName());
@@ -82,48 +166,22 @@ public class UpdateProcess extends PlayerListener
}
}
- public void doAutomaticUpdate()
- {
-
- final VersionInfo info = updateCheck.getNewVersionInfo();
- final List<String> changelog = info.getChangelog();
- Bukkit.getLogger().info("Essentials changelog " + updateCheck.getNewVersion().toString());
- for (String line : changelog)
- {
- Bukkit.getLogger().info(" - " + line);
- }
- final UpdatesDownloader downloader = new UpdatesDownloader(plugin, info);
- downloader.start();
- }
-
- public void doManualUpdate()
- {
- }
-
public void onCommand(final CommandSender sender)
{
- if (sender instanceof Player && sender.hasPermission("essentials.install"))
+ if (sender instanceof Player && sender.hasPermission("essentials.update"))
{
if (currentPlayer == null)
{
currentPlayer = (Player)sender;
- if (updateCheck.isEssentialsInstalled())
+ if (selfUpdate())
{
- doManualUpdate();
+ return;
}
- else
+ stateMachine = new StateMachine(plugin, currentPlayer, updateCheck);
+ final StateMachine.MachineResult result = stateMachine.askQuestion();
+ if (result == StateMachine.MachineResult.DONE)
{
- sender.sendMessage("Thank you for choosing Essentials.");
- sender.sendMessage("The following installation wizard will guide you through the installation of Essentials.");
- sender.sendMessage("Your answers will be saved for a later update.");
- sender.sendMessage("Please answer the messages with yes or no, if not otherwise stated.");
- sender.sendMessage("Write bye/exit/quit if you want to exit the wizard at anytime.");
- stateMachine = new StateMachine(plugin, currentPlayer, updateCheck.getNewVersionInfo());
- final StateMachine.MachineResult result = stateMachine.askQuestion();
- if (result == StateMachine.MachineResult.DONE)
- {
- startWork();
- }
+ startWork();
}
}
if (!currentPlayer.equals(sender))
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java
deleted file mode 100644
index 717163726..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.earth2me.essentials.update;
-
-import org.bukkit.plugin.Plugin;
-
-
-public class UpdatesDownloader extends WorkListener
-{
- public UpdatesDownloader(final Plugin plugin, final VersionInfo newVersionInfo)
- {
- super(plugin, newVersionInfo);
- }
-
- public void start()
- {
- }
-
- @Override
- public void onWorkAbort(String message)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void onWorkDone(String message)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java b/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java
index 8e6cbc97f..a82f49abf 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java
@@ -147,7 +147,7 @@ public class Version implements Comparable<Version>
hash = 71 * hash + this.major;
hash = 71 * hash + this.minor;
hash = 71 * hash + this.build;
- hash = 71 * hash + (this.type != null ? this.type.hashCode() : 0);
+ hash = 71 * hash + (this.type == null ? 0 : this.type.hashCode());
return hash;
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
new file mode 100644
index 000000000..824383285
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
@@ -0,0 +1,77 @@
+package com.earth2me.essentials.update.chat;
+
+import com.earth2me.essentials.update.PastieUpload;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import org.bukkit.plugin.Plugin;
+
+
+public abstract class AbstractFileCommand implements Command
+{
+ private final transient Plugin plugin;
+ private final static Charset UTF8 = Charset.forName("utf-8");
+
+ public AbstractFileCommand(final Plugin plugin)
+ {
+ this.plugin = plugin;
+ }
+
+ protected BufferedReader getServerLogReader() throws IOException
+ {
+ final File bukkitFolder = plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile();
+ if (bukkitFolder == null || !bukkitFolder.exists())
+ {
+ throw new IOException("Bukkit folder not found.");
+ }
+ final File logFile = new File(bukkitFolder, "server.log");
+ if (!logFile.exists())
+ {
+ throw new IOException("Server log not found.");
+ }
+ final FileInputStream fis = new FileInputStream(logFile);
+ try
+ {
+ if (logFile.length() > 1000000)
+ {
+ fis.skip(logFile.length() - 1000000);
+ }
+ return new BufferedReader(new InputStreamReader(fis));
+ }
+ catch (IOException ex)
+ {
+ fis.close();
+ throw ex;
+ }
+ }
+
+ protected BufferedReader getPluginConfig(final String pluginName, final String fileName) throws IOException
+ {
+ final File configFolder = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile(), pluginName);
+ if (!configFolder.exists())
+ {
+ throw new IOException(pluginName + " plugin folder not found.");
+ }
+ final File configFile = new File(configFolder, fileName);
+ if (!configFile.exists())
+ {
+ throw new IOException(pluginName + " plugin file " + fileName + " not found.");
+ }
+ return new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
+
+ }
+
+ protected String uploadToPastie(final StringBuilder input) throws IOException
+ {
+ if (input.length() > 15000)
+ {
+ input.delete(0, input.length() - 15000);
+ input.append("## Cropped after 15000 bytes");
+ }
+ final PastieUpload pastie = new PastieUpload();
+ return pastie.send(input.toString());
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java
new file mode 100644
index 000000000..ad4c75e43
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java
@@ -0,0 +1,9 @@
+package com.earth2me.essentials.update.chat;
+
+import org.bukkit.entity.Player;
+
+
+public interface Command
+{
+ void run(final IrcBot ircBot, final Player player);
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java
new file mode 100644
index 000000000..5fda07106
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java
@@ -0,0 +1,62 @@
+package com.earth2me.essentials.update.chat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+
+public class ConfigCommand extends AbstractFileCommand implements Command
+{
+ public ConfigCommand(final Plugin plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ public void run(final IrcBot ircBot, final Player player)
+ {
+ BufferedReader page = null;
+ try
+ {
+ page = getPluginConfig("Essentials", "config.yml");
+ final StringBuilder input = new StringBuilder();
+ do
+ {
+ final String line = page.readLine();
+ if (line == null) {
+ break;
+ } else {
+ input.append(line).append("\n");
+ }
+ } while (true);
+ page.close();
+ final String message = "Essentials config.yml: " + uploadToPastie(input);
+ player.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
+ ircBot.sendMessage(message);
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if (page != null)
+ {
+ page.close();
+ }
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ }
+
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ErrorsCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ErrorsCommand.java
new file mode 100644
index 000000000..41aa551c4
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ErrorsCommand.java
@@ -0,0 +1,71 @@
+package com.earth2me.essentials.update.chat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+
+public class ErrorsCommand extends AbstractFileCommand implements Command
+{
+ private final transient Pattern pattern = Pattern.compile("^[0-9 :-]+\\[INFO\\].*");
+
+ public ErrorsCommand(final Plugin plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ public void run(final IrcBot ircBot, final Player player)
+ {
+ BufferedReader page = null;
+ try
+ {
+ page = getServerLogReader();
+ final StringBuilder input = new StringBuilder();
+ do
+ {
+ final String line = page.readLine();
+ if (line == null)
+ {
+ break;
+ }
+ else
+ {
+ if (!pattern.matcher(line).matches())
+ {
+ input.append(line).append("\n");
+ }
+ }
+ }
+ while (true);
+ page.close();
+ final String message = "Errors: " + uploadToPastie(input);
+ player.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
+ ircBot.sendMessage(message);
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if (page != null)
+ {
+ page.close();
+ }
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ }
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/HelpCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/HelpCommand.java
new file mode 100644
index 000000000..a6f76cece
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/HelpCommand.java
@@ -0,0 +1,18 @@
+package com.earth2me.essentials.update.chat;
+
+import org.bukkit.entity.Player;
+
+
+public class HelpCommand implements Command
+{
+ @Override
+ public void run(final IrcBot ircBot, final Player player)
+ {
+ player.sendMessage("Commands: (Note: Files send to the chat will be public viewable.)");
+ player.sendMessage("!errors - Send the last server errors to the chat.");
+ player.sendMessage("!startup - Send the last startup messages to the chat.");
+ player.sendMessage("!config - Sends your Essentials config to the chat.");
+ player.sendMessage("!list - List all players in chat.");
+ player.sendMessage("!quit - Leave chat.");
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/IrcBot.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java
index a314df15d..31e9384ee 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/IrcBot.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.update;
+package com.earth2me.essentials.update.chat;
import java.io.IOException;
import java.util.logging.Level;
@@ -95,7 +95,9 @@ public class IrcBot extends PircBot
}
@Override
- protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason)
+ protected void onKick(final String channel, final String kickerNick,
+ final String kickerLogin, final String kickerHostname,
+ final String recipientNick, final String reason)
{
if (recipientNick.equals(getNick()))
{
@@ -111,25 +113,33 @@ public class IrcBot extends PircBot
}
@Override
- protected void onMessage(String channel, String sender, String login, String hostname, String message)
+ protected void onMessage(final String channel, final String sender,
+ final String login, final String hostname,
+ final String message)
{
player.sendMessage(formatChatMessage(sender, message, false));
}
@Override
- protected void onAction(String sender, String login, String hostname, String target, String action)
+ protected void onAction(final String sender, final String login,
+ final String hostname, final String target,
+ final String action)
{
player.sendMessage(formatChatMessage(sender, action, true));
}
@Override
- protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice)
+ protected void onNotice(final String sourceNick, final String sourceLogin,
+ final String sourceHostname, final String target,
+ final String notice)
{
player.sendMessage(formatChatMessage(sourceNick, notice, false));
}
@Override
- protected void onTopic(String channel, String topic, String setBy, long date, boolean changed)
+ protected void onTopic(final String channel, final String topic,
+ final String setBy, final long date,
+ final boolean changed)
{
player.sendMessage(formatChatMessage(channel, topic, false));
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java
new file mode 100644
index 000000000..9aa932efa
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java
@@ -0,0 +1,32 @@
+package com.earth2me.essentials.update.chat;
+
+import org.bukkit.entity.Player;
+import org.jibble.pircbot.User;
+
+
+public class ListCommand implements Command
+{
+ @Override
+ public void run(final IrcBot ircBot, final Player player)
+ {
+ final User[] members = ircBot.getUsers();
+ final StringBuilder message = new StringBuilder();
+ for (User user : members)
+ {
+ if (message.length() > 0)
+ {
+ message.append("§f, ");
+ }
+ if (user.isOp() || user.hasVoice())
+ {
+ message.append("§6");
+ }
+ else
+ {
+ message.append("§7");
+ }
+ message.append(user.getPrefix()).append(user.getNick());
+ }
+ player.sendMessage(message.toString());
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/StartupCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/StartupCommand.java
new file mode 100644
index 000000000..f244d6e3a
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/StartupCommand.java
@@ -0,0 +1,77 @@
+package com.earth2me.essentials.update.chat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+
+public class StartupCommand extends AbstractFileCommand implements Command
+{
+ private final transient Pattern patternStart = Pattern.compile("^[0-9 :-]+\\[INFO\\] Starting minecraft server version.*");
+ private final transient Pattern patternEnd = Pattern.compile("^[0-9 :-]+\\[INFO\\] Done \\([0-9.,]+s\\)! For help, type \"help\".*");
+
+ public StartupCommand(final Plugin plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ public void run(final IrcBot ircBot, final Player player)
+ {
+ BufferedReader page = null;
+ try
+ {
+ page = getServerLogReader();
+ final StringBuilder input = new StringBuilder();
+ String line;
+ boolean log = false;
+ while ((line = page.readLine()) != null)
+ {
+ if (patternStart.matcher(line).matches())
+ {
+ if (input.length() > 0)
+ {
+ input.delete(0, input.length());
+ }
+ log = true;
+ }
+ if (log)
+ {
+ input.append(line).append("\n");
+ }
+ if (patternEnd.matcher(line).matches())
+ {
+ log = false;
+ }
+ }
+ page.close();
+ final String message = "Startup: " + uploadToPastie(input);
+ player.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
+ ircBot.sendMessage(message);
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if (page != null)
+ {
+ page.close();
+ }
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, null, ex);
+ player.sendMessage(ex.getMessage());
+ }
+ }
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/UsernameUtil.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/UsernameUtil.java
new file mode 100644
index 000000000..3df615652
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/UsernameUtil.java
@@ -0,0 +1,124 @@
+package com.earth2me.essentials.update.chat;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.bukkit.Bukkit;
+import org.bukkit.Server;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+
+public final class UsernameUtil
+{
+ private static final Pattern CB_PATTERN = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
+
+ private UsernameUtil()
+ {
+ }
+
+ public static String createUsername(final Player player)
+ {
+ final StringBuilder nameBuilder = new StringBuilder();
+ final Server server = Bukkit.getServer();
+ nameBuilder.append(player.getName());
+
+ addCraftBukkitVersion(server, nameBuilder);
+ addEssentialsVersion(server, nameBuilder);
+ addGroupManagerVersion(server, nameBuilder);
+ addPermissionsExVersion(server, nameBuilder);
+ addPermissionsBukkitVersion(server, nameBuilder);
+ addBPermissionsVersion(server, nameBuilder);
+ addPermissionsVersion(server, nameBuilder);
+
+ return nameBuilder.toString();
+ }
+
+ private static void addPermissionsVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin perm = server.getPluginManager().getPlugin("Permissions");
+ if (perm != null)
+ {
+ nameBuilder.append(" P");
+ if (!perm.isEnabled())
+ {
+ nameBuilder.append('!');
+ }
+ nameBuilder.append(perm.getDescription().getVersion());
+ }
+ }
+
+ private static void addBPermissionsVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin bperm = server.getPluginManager().getPlugin("bPermissions");
+ if (bperm != null)
+ {
+ nameBuilder.append(" BP");
+ if (!bperm.isEnabled())
+ {
+ nameBuilder.append('!');
+ }
+ nameBuilder.append(bperm.getDescription().getVersion());
+ }
+ }
+
+ private static void addPermissionsBukkitVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin permb = server.getPluginManager().getPlugin("PermissionsBukkit");
+ if (permb != null)
+ {
+ nameBuilder.append(" PB");
+ if (!permb.isEnabled())
+ {
+ nameBuilder.append('!');
+ }
+ nameBuilder.append(permb.getDescription().getVersion());
+ }
+ }
+
+ private static void addPermissionsExVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin pex = server.getPluginManager().getPlugin("PermissionsEx");
+ if (pex != null)
+ {
+ nameBuilder.append(" PEX");
+ if (!pex.isEnabled())
+ {
+ nameBuilder.append('!');
+ }
+ nameBuilder.append(pex.getDescription().getVersion());
+ }
+ }
+
+ private static void addGroupManagerVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin groupManager = server.getPluginManager().getPlugin("GroupManager");
+ if (groupManager != null)
+ {
+ nameBuilder.append(" GM");
+ if (!groupManager.isEnabled())
+ {
+ nameBuilder.append('!');
+ }
+ }
+ }
+
+ private static void addEssentialsVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
+ if (essentials != null)
+ {
+ nameBuilder.append(" ESS");
+ nameBuilder.append(essentials.getDescription().getVersion());
+ }
+ }
+
+ private static void addCraftBukkitVersion(final Server server, final StringBuilder nameBuilder)
+ {
+ final Matcher versionMatch = CB_PATTERN.matcher(server.getVersion());
+ if (versionMatch.matches())
+ {
+ nameBuilder.append(" CB");
+ nameBuilder.append(versionMatch.group(4));
+ }
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java
index 3f0c4c233..7478d81b7 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java
@@ -1,6 +1,6 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import org.bukkit.entity.Player;
@@ -66,19 +66,29 @@ public abstract class AbstractState
final String trimmedAnswer = answer.trim();
if (trimmedAnswer.equalsIgnoreCase("quit")
|| trimmedAnswer.equalsIgnoreCase("bye")
- || trimmedAnswer.equalsIgnoreCase("abort"))
+ || trimmedAnswer.equalsIgnoreCase("abort")
+ || trimmedAnswer.equalsIgnoreCase("cancel")
+ || trimmedAnswer.equalsIgnoreCase("exit"))
{
abort();
return null;
}
- final boolean found = reactOnAnswer(trimmedAnswer);
- if (found)
+ try
{
- return getNextState();
+ final boolean found = reactOnAnswer(trimmedAnswer);
+ if (found)
+ {
+ return getNextState();
+ }
+ else
+ {
+ sender.sendMessage("Answer not recognized.");
+ return this;
+ }
}
- else
+ catch (RuntimeException ex)
{
- sender.sendMessage("Answer not recognized.");
+ sender.sendMessage(ex.toString());
return this;
}
}
@@ -86,7 +96,7 @@ public abstract class AbstractState
/**
* Do something based on the answer, that the user gave.
*/
- public void doWork(final WorkListener listener)
+ public void doWork(final AbstractWorkListener listener)
{
listener.onWorkDone();
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java
new file mode 100644
index 000000000..10a4f33c5
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java
@@ -0,0 +1,91 @@
+package com.earth2me.essentials.update.states;
+
+import com.earth2me.essentials.update.UpdateCheck;
+import com.earth2me.essentials.update.VersionInfo;
+import java.util.List;
+import org.bukkit.entity.Player;
+
+
+public class Changelog extends AbstractState
+{
+ private static final int CHANGES_PER_PAGE = 5;
+ private transient int page = 0;
+ private transient boolean confirmed = false;
+ private transient final List<String> changes;
+ private transient final int pages;
+
+ public Changelog(final StateMap stateMap)
+ {
+ super(stateMap);
+ changes = getChanges();
+ pages = changes.size() / CHANGES_PER_PAGE + (changes.size() % CHANGES_PER_PAGE > 0 ? 1 : 0);
+ }
+
+ @Override
+ public AbstractState getNextState()
+ {
+ return confirmed ? getState(EssentialsChat.class) : this;
+ }
+
+ @Override
+ public boolean guessAnswer()
+ {
+ if (pages == 0)
+ {
+ confirmed = true;
+ }
+ return confirmed;
+ }
+
+ private List<String> getChanges()
+ {
+ final UpdateCheck updateCheck = getState(UpdateOrInstallation.class).getUpdateCheck();
+ final VersionInfo versionInfo = updateCheck.getNewVersionInfo();
+ return versionInfo.getChangelog();
+ }
+
+ @Override
+ public void askQuestion(final Player sender)
+ {
+ if (pages > 1)
+ {
+ sender.sendMessage("Changelog, page " + page + " of " + pages + ":");
+ }
+ else
+ {
+ sender.sendMessage("Changelog:");
+ }
+ for (int i = page * CHANGES_PER_PAGE; i < Math.min(page * CHANGES_PER_PAGE + CHANGES_PER_PAGE, changes.size()); i++)
+ {
+ sender.sendMessage(changes.get(i));
+ }
+ if (pages > 1)
+ {
+ sender.sendMessage("Select a page by typing the numbers 1 to " + pages + " to view all changes and then type confirm or abort.");
+ }
+ else
+ {
+ sender.sendMessage("Type confirm to update Essentials or abort to cancel the update.");
+ }
+ }
+
+ @Override
+ public boolean reactOnAnswer(final String answer)
+ {
+ if (answer.equalsIgnoreCase("confirm"))
+ {
+ confirmed = true;
+ return true;
+ }
+ if (answer.matches("[0-9]+"))
+ {
+ final int page = Integer.parseInt(answer);
+ if (page <= pages && page > 0)
+ {
+ this.page = page - 1;
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java
index ef560bdc3..6aaed634a 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java
@@ -1,6 +1,6 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import com.earth2me.essentials.update.tasks.InstallModule;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -35,7 +35,7 @@ public class EssentialsChat extends AbstractYesNoState
}
@Override
- public void doWork(final WorkListener listener)
+ public void doWork(final AbstractWorkListener listener)
{
if (getAnswer())
{
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java
index b96f17c02..a91a44787 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java
@@ -1,6 +1,6 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import com.earth2me.essentials.update.tasks.InstallModule;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -35,7 +35,7 @@ public class EssentialsGeoIP extends AbstractYesNoState
}
@Override
- public void doWork(final WorkListener listener)
+ public void doWork(final AbstractWorkListener listener)
{
if (getAnswer())
{
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java
index 7ffb61268..ca0337d30 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java
@@ -1,6 +1,6 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import com.earth2me.essentials.update.tasks.InstallModule;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -35,7 +35,7 @@ public class EssentialsProtect extends AbstractYesNoState
}
@Override
- public void doWork(final WorkListener listener)
+ public void doWork(final AbstractWorkListener listener)
{
if (getAnswer())
{
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java
index 95cc6599b..2a87638ba 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java
@@ -1,6 +1,6 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import com.earth2me.essentials.update.tasks.InstallModule;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -35,7 +35,7 @@ public class EssentialsSpawn extends AbstractYesNoState
}
@Override
- public void doWork(final WorkListener listener)
+ public void doWork(final AbstractWorkListener listener)
{
if (getAnswer())
{
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java
new file mode 100644
index 000000000..cb88cc642
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java
@@ -0,0 +1,12 @@
+package com.earth2me.essentials.update.states;
+
+import org.bukkit.event.Event;
+
+
+public class InstallationFinishedEvent extends Event
+{
+ public InstallationFinishedEvent()
+ {
+ super(Type.CUSTOM_EVENT);
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
index 77fb9ce20..6db8734e7 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
@@ -1,82 +1,113 @@
package com.earth2me.essentials.update.states;
-import com.earth2me.essentials.update.WorkListener;
-import com.earth2me.essentials.update.VersionInfo;
+import com.earth2me.essentials.update.UpdateCheck;
+import com.earth2me.essentials.update.AbstractWorkListener;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
-public class StateMachine extends WorkListener
+public class StateMachine extends AbstractWorkListener implements Runnable
{
public enum MachineResult
{
- ABORT, WAIT, DONE
+ ABORT, WAIT, DONE, NONE
}
private final transient StateMap states = new StateMap();
private transient AbstractState current;
- private final transient Player player;
+ private transient Player player;
+ private transient MachineResult result = MachineResult.NONE;
- public StateMachine(final Plugin plugin, final Player player, final VersionInfo newVersionInfo)
+ public StateMachine(final Plugin plugin, final Player player, final UpdateCheck updateCheck)
{
- super(plugin, newVersionInfo);
+ super(plugin, updateCheck.getNewVersionInfo());
this.player = player;
states.clear();
- states.add(new EssentialsChat(states));
- states.add(new EssentialsSpawn(states));
- states.add(new EssentialsProtect(states));
- states.add(new EssentialsGeoIP(states));
- current = states.values().iterator().next();
+ final UpdateOrInstallation state = new UpdateOrInstallation(states, updateCheck);
+ current = states.put(UpdateOrInstallation.class, state);
}
public MachineResult askQuestion()
{
- while (current.guessAnswer())
+ try
{
- current = current.getNextState();
- if (current == null)
+ while (current.guessAnswer())
{
- return MachineResult.DONE;
+ current = current.getNextState();
+ if (current == null)
+ {
+ result = MachineResult.DONE;
+ break;
+ }
}
+ if (current != null)
+ {
+ if (player.isOnline())
+ {
+ current.askQuestion(player);
+ }
+ result = MachineResult.WAIT;
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ player.sendMessage(ex.getMessage());
+ finish();
+ result = MachineResult.ABORT;
}
- current.askQuestion(player);
- return MachineResult.WAIT;
+ return result;
}
public MachineResult reactOnMessage(final String message)
{
+ result = MachineResult.NONE;
final AbstractState next = current.reactOnAnswer(player, message);
if (next == null)
{
if (current.isAbortion())
{
- return MachineResult.ABORT;
+ finish();
+ result = MachineResult.ABORT;
}
else
{
- return MachineResult.DONE;
+ result = MachineResult.DONE;
}
}
- current = next;
- return askQuestion();
+ else
+ {
+ current = next;
+ askQuestion();
+ }
+ return result;
}
private transient Iterator<AbstractState> iterator;
public void startWork()
{
iterator = states.values().iterator();
- callStateWork();
+ Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this);
}
- private void callStateWork()
+ @Override
+ public void run()
{
if (!iterator.hasNext())
{
- if (player.isOnline())
+ Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
- player.sendMessage("Installation done.");
- }
+ @Override
+ public void run()
+ {
+ if (StateMachine.this.player.isOnline())
+ {
+ StateMachine.this.player.sendMessage("Installation done. Reloading server.");
+ }
+ finish();
+ Bukkit.getServer().reload();
+ }
+ });
return;
}
final AbstractState state = iterator.next();
@@ -86,6 +117,7 @@ public class StateMachine extends WorkListener
@Override
public void onWorkAbort(final String message)
{
+ finish();
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
@Override
@@ -111,8 +143,41 @@ public class StateMachine extends WorkListener
{
StateMachine.this.player.sendMessage(message);
}
- StateMachine.this.callStateWork();
+ Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), StateMachine.this);
}
});
}
+
+ private void finish()
+ {
+ current = null;
+ iterator = null;
+ states.clear();
+ getPlugin().getServer().getPluginManager().callEvent(new InstallationFinishedEvent());
+ }
+
+ public void resumeInstallation(final Player player)
+ {
+ this.player = player;
+ if (result == MachineResult.WAIT)
+ {
+ if (current == null)
+ {
+ throw new RuntimeException("State is WAIT, but current state is null!");
+ }
+ current.askQuestion(player);
+ }
+ if (result == MachineResult.DONE && iterator != null)
+ {
+ player.sendMessage("Installation is still running.");
+ }
+ if (result == MachineResult.ABORT)
+ {
+ throw new RuntimeException("Player should not be able to resume an aborted installation.");
+ }
+ if (result == MachineResult.NONE)
+ {
+ throw new RuntimeException("State machine in an undefined state.");
+ }
+ }
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java
index a2cf7b719..cca4223d6 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java
@@ -7,11 +7,6 @@ public class StateMap extends LinkedHashMap<Class<? extends AbstractState>, Abst
{
public StateMap()
{
- super();
- }
-
- public AbstractState add(AbstractState state)
- {
- return put(state.getClass(), state);
+ super(50);
}
}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
new file mode 100644
index 000000000..5671275f0
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
@@ -0,0 +1,59 @@
+package com.earth2me.essentials.update.states;
+
+import com.earth2me.essentials.update.UpdateCheck;
+import org.bukkit.entity.Player;
+
+
+public class UpdateOrInstallation extends AbstractState
+{
+ private final transient UpdateCheck updateCheck;
+ private transient boolean update = false;
+
+ public UpdateOrInstallation(final StateMap stateMap, final UpdateCheck updateCheck)
+ {
+ super(stateMap);
+ this.updateCheck = updateCheck;
+ }
+
+ @Override
+ public boolean guessAnswer()
+ {
+ if (getUpdateCheck().isEssentialsInstalled()) {
+ update = true;
+ }
+ return update;
+ }
+
+ @Override
+ public AbstractState getNextState()
+ {
+ return update ? getState(Changelog.class) : getState(EssentialsChat.class);
+ }
+
+ @Override
+ public void askQuestion(final Player sender)
+ {
+ sender.sendMessage("Thank you for choosing Essentials.");
+ sender.sendMessage("The following installation wizard will guide you through the installation of Essentials.");
+ sender.sendMessage("Your answers will be saved for a later update.");
+ sender.sendMessage("Please answer the messages with yes or no, if not otherwise stated.");
+ sender.sendMessage("Write bye/exit/quit if you want to exit the wizard at anytime.");
+ sender.sendMessage("Type ok to continue...");
+ }
+
+ @Override
+ public boolean reactOnAnswer(final String answer)
+ {
+ return answer.equalsIgnoreCase("ok") || answer.equalsIgnoreCase("k") || answer.equalsIgnoreCase("continue");
+ }
+
+ public UpdateCheck getUpdateCheck()
+ {
+ return updateCheck;
+ }
+
+ public boolean isUpdate()
+ {
+ return update;
+ }
+}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java
index b97991a04..66eeb380d 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java
@@ -3,7 +3,7 @@ package com.earth2me.essentials.update.tasks;
import com.earth2me.essentials.update.GetFile;
import com.earth2me.essentials.update.ModuleInfo;
import com.earth2me.essentials.update.VersionInfo;
-import com.earth2me.essentials.update.WorkListener;
+import com.earth2me.essentials.update.AbstractWorkListener;
import java.io.File;
import java.net.URL;
import java.util.logging.Level;
@@ -12,16 +12,16 @@ import org.bukkit.Bukkit;
public class InstallModule implements Runnable, Task
{
- protected final transient WorkListener listener;
+ protected final transient AbstractWorkListener listener;
private final transient String moduleName;
private final transient String fileName;
- public InstallModule(final WorkListener listener, final String moduleName)
+ public InstallModule(final AbstractWorkListener listener, final String moduleName)
{
this(listener, moduleName, moduleName + ".jar");
}
- public InstallModule(final WorkListener listener, final String moduleName, final String fileName)
+ public InstallModule(final AbstractWorkListener listener, final String moduleName, final String fileName)
{
this.listener = listener;
this.moduleName = moduleName;
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java
new file mode 100644
index 000000000..777e42517
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java
@@ -0,0 +1,57 @@
+package com.earth2me.essentials.update.tasks;
+
+import com.earth2me.essentials.update.AbstractWorkListener;
+import org.bukkit.Bukkit;
+
+
+public class SelfUpdate extends AbstractWorkListener implements Task, Runnable
+{
+ private final transient AbstractWorkListener listener;
+
+ public SelfUpdate(final AbstractWorkListener listener)
+ {
+ super(listener.getPlugin(), listener.getNewVersionInfo());
+ this.listener = listener;
+ }
+
+ @Override
+ public void onWorkAbort(final String message)
+ {
+ listener.onWorkAbort(message);
+ }
+
+ @Override
+ public void onWorkDone(final String message)
+ {
+ listener.onWorkDone(message);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Bukkit.getServer().reload();
+ }
+ });
+ }
+
+ @Override
+ public void start()
+ {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), this);
+ }
+
+ @Override
+ public void run()
+ {
+ Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), new Runnable() {
+
+ @Override
+ public void run()
+ {
+ new InstallModule(SelfUpdate.this, "EssentialsUpdate").start();
+ }
+ });
+ }
+
+
+}
diff --git a/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java b/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
index 901a8f9dc..92faade26 100644
--- a/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
+++ b/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
@@ -49,39 +49,39 @@ public class VersionTest extends TestCase
@Test
public void testCompareTo()
{
- Version a = new Version("1.1.1");
- Version b = new Version("Dev1.1.2");
- Version c = new Version("1.1.2");
- Version d = new Version("1.2.0");
- Version e = new Version("2.0.0");
- Version f = new Version("Pre1.1.1.1");
- Version g = new Version("Dev1.2.2");
- assertTrue("Testing dev", a.compareTo(b) < 0);
- assertTrue("Testing dev", b.compareTo(a) > 0);
- assertTrue("Testing build", a.compareTo(c) < 0);
- assertTrue("Testing build", c.compareTo(a) > 0);
- assertTrue("Testing minor", a.compareTo(d) < 0);
- assertTrue("Testing minor", d.compareTo(a) > 0);
- assertTrue("Testing major", a.compareTo(e) < 0);
- assertTrue("Testing major", e.compareTo(a) > 0);
- assertTrue("Testing pre", f.compareTo(a) < 0);
- assertTrue("Testing pre", a.compareTo(f) > 0);
- assertTrue("Testing dev vs dev", b.compareTo(g) < 0);
- assertTrue("Testing dev vs dev", g.compareTo(b) > 0);
+ final Version verA = new Version("1.1.1");
+ final Version verB = new Version("Dev1.1.2");
+ final Version verC = new Version("1.1.2");
+ final Version verD = new Version("1.2.0");
+ final Version verE = new Version("2.0.0");
+ final Version verF = new Version("Pre1.1.1.1");
+ final Version verG = new Version("Dev1.2.2");
+ assertTrue("Testing dev", verA.compareTo(verB) < 0);
+ assertTrue("Testing dev", verB.compareTo(verA) > 0);
+ assertTrue("Testing build", verA.compareTo(verC) < 0);
+ assertTrue("Testing build", verC.compareTo(verA) > 0);
+ assertTrue("Testing minor", verA.compareTo(verD) < 0);
+ assertTrue("Testing minor", verD.compareTo(verA) > 0);
+ assertTrue("Testing major", verA.compareTo(verE) < 0);
+ assertTrue("Testing major", verE.compareTo(verA) > 0);
+ assertTrue("Testing pre", verF.compareTo(verA) < 0);
+ assertTrue("Testing pre", verA.compareTo(verF) > 0);
+ assertTrue("Testing dev vs dev", verB.compareTo(verG) < 0);
+ assertTrue("Testing dev vs dev", verG.compareTo(verB) > 0);
final TreeSet<Version> set = new TreeSet<Version>();
- set.add(a);
- set.add(b);
- set.add(c);
- set.add(d);
- set.add(e);
- set.add(f);
- set.add(g);
- assertEquals("Testing sorting", f, set.pollFirst());
- assertEquals("Testing sorting", a, set.pollFirst());
- assertEquals("Testing sorting", c, set.pollFirst());
- assertEquals("Testing sorting", d, set.pollFirst());
- assertEquals("Testing sorting", e, set.pollFirst());
- assertEquals("Testing sorting", b, set.pollFirst());
- assertEquals("Testing sorting", g, set.pollFirst());
+ set.add(verA);
+ set.add(verB);
+ set.add(verC);
+ set.add(verD);
+ set.add(verE);
+ set.add(verF);
+ set.add(verG);
+ assertEquals("Testing sorting", verF, set.pollFirst());
+ assertEquals("Testing sorting", verA, set.pollFirst());
+ assertEquals("Testing sorting", verC, set.pollFirst());
+ assertEquals("Testing sorting", verD, set.pollFirst());
+ assertEquals("Testing sorting", verE, set.pollFirst());
+ assertEquals("Testing sorting", verB, set.pollFirst());
+ assertEquals("Testing sorting", verG, set.pollFirst());
}
}
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
index 34f862627..631d1b21b 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
@@ -124,14 +124,17 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
}
@Override
- public void broadcastMessage(final IUser sender, final String message)
+ public void broadcastMessage(final IUser sender, final String message, final String xmppAddress)
{
ess.broadcastMessage(sender, message);
try
{
for (String address : getSpyUsers())
{
- sendMessage(address, message);
+ if (!address.equalsIgnoreCase(xmppAddress))
+ {
+ sendMessage(address, message);
+ }
}
}
catch (Exception ex)
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
index 1ed9fa732..0635ca131 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
@@ -24,5 +24,5 @@ public interface IEssentialsXMPP extends Plugin
boolean toggleSpy(final Player user);
- void broadcastMessage(final IUser sender, final String message);
+ void broadcastMessage(final IUser sender, final String message, final String xmppAddress);
}
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
index d7aedb9f4..cbe89f9d6 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
@@ -103,7 +103,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
break;
default:
final IUser sender = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant()));
- parent.broadcastMessage(sender, "="+sender.getDisplayName()+": "+ message);
+ parent.broadcastMessage(sender, "="+sender.getDisplayName()+": "+ message, StringUtils.parseBareAddress(chat.getParticipant()));
}
}
}
diff --git a/build.xml b/build.xml
index e0172132c..6d99694fb 100644
--- a/build.xml
+++ b/build.xml
@@ -5,24 +5,28 @@
<replace dir="." includes="**/src/messages*.properties" token="version: TeamCity" value="version: ${build.number}"/>
<replace dir="." includes="**/src/items.csv" token="version: TeamCity" value="version: ${build.number}"/>
</target>
- <target name="buildall" depends="setversion">
+ <target name="buildGM" depends="setversion">
+ <ant dir="EssentialsGroupManager" antfile="build.xml"/>
+ <ant dir="EssentialsGroupBridge" antfile="build.xml"/>
+ </target>
+ <target name="buildEss" depends="buildGM">
<ant dir="Essentials" antfile="build.xml"/>
+ </target>
+ <target name="buildRest" depends="buildEss">
<ant dir="EssentialsChat" antfile="build.xml"/>
<ant dir="EssentialsSpawn" antfile="build.xml"/>
<ant dir="EssentialsProtect" antfile="build.xml"/>
- <ant dir="EssentialsGroupManager" antfile="build.xml"/>
- <ant dir="EssentialsGroupBridge" antfile="build.xml"/>
<ant dir="EssentialsGeoIP" antfile="build.xml"/>
<ant dir="EssentialsXMPP" antfile="build.xml"/>
</target>
- <target name="collect" depends="buildall">
+ <target name="collect" depends="buildRest">
<mkdir dir="jars"/>
<copy todir="jars">
<fileset dir=".">
<include name="**/dist/Essentials*.jar"/>
- <include name="**/Essentials/src/config.yml" />
- <include name="**/src/messages*.properties" />
- <include name="**/src/items.csv" />
+ <include name="**/Essentials/src/config.yml" />
+ <include name="**/src/messages*.properties" />
+ <include name="**/src/items.csv" />
</fileset>
<flattenmapper/>
</copy>
diff --git a/lib/PermissionsEx-javadoc.jar b/lib/PermissionsEx-javadoc.jar
new file mode 100644
index 000000000..b379744f5
--- /dev/null
+++ b/lib/PermissionsEx-javadoc.jar
Binary files differ
diff --git a/lib/PermissionsEx.jar b/lib/PermissionsEx.jar
index d2b1ad91e..9f686b387 100644
--- a/lib/PermissionsEx.jar
+++ b/lib/PermissionsEx.jar
Binary files differ
diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties
index 9137b06bd..6c4ff50b3 100644
--- a/lib/nblibraries.properties
+++ b/lib/nblibraries.properties
@@ -10,3 +10,4 @@ libs.junit_4.javadoc=\
${base}/junit_4/junit-4.5-api.zip
libs.junit_4.src=\
${base}/junit_4/junit-4.5-src.jar
+project.EssentialsGroupManager=../EssentialsGroupManager