summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-18 15:51:55 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-18 15:51:55 +0100
commite42f7e4ffa35f5772abb7a467ab18058854c1583 (patch)
treefff3c45269df14007872ddb63023ad44982a7a9d
parent8a9353fd098fdc123adc9f014a5a52e9a829a22d (diff)
downloadEssentials-e42f7e4ffa35f5772abb7a467ab18058854c1583.tar
Essentials-e42f7e4ffa35f5772abb7a467ab18058854c1583.tar.gz
Essentials-e42f7e4ffa35f5772abb7a467ab18058854c1583.tar.lz
Essentials-e42f7e4ffa35f5772abb7a467ab18058854c1583.tar.xz
Essentials-e42f7e4ffa35f5772abb7a467ab18058854c1583.zip
Removing EssentialsUpdate from 2.9 branch.
Development may be continued in 3.x branch.
-rw-r--r--EssentialsUpdate/build.xml74
-rw-r--r--EssentialsUpdate/nbproject/build-impl.xml1425
-rw-r--r--EssentialsUpdate/nbproject/genfiles.properties8
-rw-r--r--EssentialsUpdate/nbproject/pmd.settings1
-rw-r--r--EssentialsUpdate/nbproject/project.properties112
-rw-r--r--EssentialsUpdate/nbproject/project.xml18
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java39
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java171
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java61
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java113
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/ModuleInfo.java35
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java40
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/PostToUrl.java66
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java202
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java205
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java199
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/Version.java173
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/VersionInfo.java49
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java73
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java9
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java66
-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.java198
-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.java112
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractYesNoState.java57
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java20
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java91
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java47
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java29
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java47
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java47
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java47
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java19
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java183
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java12
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java60
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java61
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java55
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/tasks/Task.java7
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/Colors.java293
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/InputThread.java169
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/IrcException.java35
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/NickAlreadyInUseException.java38
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/OutputThread.java104
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/PircBot.java2809
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/Queue.java146
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/ReplyConstants.java176
-rwxr-xr-xEssentialsUpdate/src/org/jibble/pircbot/User.java163
-rw-r--r--EssentialsUpdate/src/plugin.yml21
-rw-r--r--EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java27
-rw-r--r--EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java86
55 files changed, 0 insertions, 8620 deletions
diff --git a/EssentialsUpdate/build.xml b/EssentialsUpdate/build.xml
deleted file mode 100644
index dedb62afa..000000000
--- a/EssentialsUpdate/build.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- You may freely edit this file. See commented blocks below for -->
-<!-- some examples of how to customize the build. -->
-<!-- (If you delete it and reopen the project it will be recreated.) -->
-<!-- By default, only the Clean and Build commands use this build script. -->
-<!-- Commands such as Run, Debug, and Test only use this build script if -->
-<!-- the Compile on Save feature is turned off for the project. -->
-<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
-<!-- in the project's Project Properties dialog box.-->
-<project name="EssentialsUpdate" default="default" basedir=".">
- <description>Builds, tests, and runs the project EssentialsUpdate.</description>
- <import file="nbproject/build-impl.xml"/>
- <!--
-
- There exist several targets which are by default empty and which can be
- used for execution of your tasks. These targets are usually executed
- before and after some main targets. They are:
-
- -pre-init: called before initialization of project properties
- -post-init: called after initialization of project properties
- -pre-compile: called before javac compilation
- -post-compile: called after javac compilation
- -pre-compile-single: called before javac compilation of single file
- -post-compile-single: called after javac compilation of single file
- -pre-compile-test: called before javac compilation of JUnit tests
- -post-compile-test: called after javac compilation of JUnit tests
- -pre-compile-test-single: called before javac compilation of single JUnit test
- -post-compile-test-single: called after javac compilation of single JUunit test
- -pre-jar: called before JAR building
- -post-jar: called after JAR building
- -post-clean: called after cleaning build products
-
- (Targets beginning with '-' are not intended to be called on their own.)
-
- Example of inserting an obfuscator after compilation could look like this:
-
- <target name="-post-compile">
- <obfuscate>
- <fileset dir="${build.classes.dir}"/>
- </obfuscate>
- </target>
-
- For list of available properties check the imported
- nbproject/build-impl.xml file.
-
-
- Another way to customize the build is by overriding existing main targets.
- The targets of interest are:
-
- -init-macrodef-javac: defines macro for javac compilation
- -init-macrodef-junit: defines macro for junit execution
- -init-macrodef-debug: defines macro for class debugging
- -init-macrodef-java: defines macro for class execution
- -do-jar-with-manifest: JAR building (if you are using a manifest)
- -do-jar-without-manifest: JAR building (if you are not using a manifest)
- run: execution of project
- -javadoc-build: Javadoc generation
- test-report: JUnit report generation
-
- An example of overriding the target for project execution could look like this:
-
- <target name="run" depends="EssentialsUpdate-impl.jar">
- <exec dir="bin" executable="launcher.exe">
- <arg file="${dist.jar}"/>
- </exec>
- </target>
-
- Notice that the overridden target depends on the jar target and not only on
- the compile target as the regular run target does. Again, for a list of available
- properties which you can use, check the target you are overriding in the
- nbproject/build-impl.xml file.
-
- -->
-</project>
diff --git a/EssentialsUpdate/nbproject/build-impl.xml b/EssentialsUpdate/nbproject/build-impl.xml
deleted file mode 100644
index 25ef36b98..000000000
--- a/EssentialsUpdate/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1425 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
-
-For the purpose of easier reading the script
-is divided into following sections:
-
- - initialization
- - compilation
- - jar
- - execution
- - debugging
- - javadoc
- - test compilation
- - test execution
- - test debugging
- - applet
- - cleanup
-
- -->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="EssentialsUpdate-impl">
- <fail message="Please build using Ant 1.8.0 or higher.">
- <condition>
- <not>
- <antversion atleast="1.8.0"/>
- </not>
- </condition>
- </fail>
- <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
- <!--
- ======================
- INITIALIZATION SECTION
- ======================
- -->
- <target name="-pre-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="-pre-init" name="-init-private">
- <property file="nbproject/private/config.properties"/>
- <property file="nbproject/private/configs/${config}.properties"/>
- <property file="nbproject/private/private.properties"/>
- </target>
- <target name="-pre-init-libraries">
- <property location="../lib/nblibraries.properties" name="libraries.path"/>
- <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
- <pathconvert dirsep="/" property="libraries.dir">
- <path path="${libraries.dir.nativedirsep}"/>
- </pathconvert>
- <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
- <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
- </target>
- <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
- <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
- <filterchain>
- <replacestring from="$${base}" to="${libraries.dir}"/>
- <escapeunicode/>
- </filterchain>
- </loadproperties>
- </target>
- <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
- <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
- <filterchain>
- <replacestring from="$${base}" to="${libraries.dir}"/>
- <escapeunicode/>
- </filterchain>
- </loadproperties>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
- <property file="${user.properties.file}"/>
- <!-- The two properties below are usually overridden -->
- <!-- by the active platform. Just a fallback. -->
- <property name="default.javac.source" value="1.4"/>
- <property name="default.javac.target" value="1.4"/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
- <property file="nbproject/configs/${config}.properties"/>
- <property file="nbproject/project.properties"/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
- <available file="${manifest.file}" property="manifest.available"/>
- <condition property="splashscreen.available">
- <and>
- <not>
- <equals arg1="${application.splash}" arg2="" trim="true"/>
- </not>
- <available file="${application.splash}"/>
- </and>
- </condition>
- <condition property="main.class.available">
- <and>
- <isset property="main.class"/>
- <not>
- <equals arg1="${main.class}" arg2="" trim="true"/>
- </not>
- </and>
- </condition>
- <condition property="manifest.available+main.class">
- <and>
- <isset property="manifest.available"/>
- <isset property="main.class.available"/>
- </and>
- </condition>
- <condition property="do.archive">
- <not>
- <istrue value="${jar.archive.disabled}"/>
- </not>
- </condition>
- <condition property="do.mkdist">
- <and>
- <isset property="do.archive"/>
- <isset property="libs.CopyLibs.classpath"/>
- <not>
- <istrue value="${mkdist.disabled}"/>
- </not>
- </and>
- </condition>
- <condition property="manifest.available+main.class+mkdist.available">
- <and>
- <istrue value="${manifest.available+main.class}"/>
- <isset property="do.mkdist"/>
- </and>
- </condition>
- <condition property="do.archive+manifest.available">
- <and>
- <isset property="manifest.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+main.class.available">
- <and>
- <isset property="main.class.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+splashscreen.available">
- <and>
- <isset property="splashscreen.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+manifest.available+main.class">
- <and>
- <istrue value="${manifest.available+main.class}"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="manifest.available-mkdist.available">
- <or>
- <istrue value="${manifest.available}"/>
- <isset property="do.mkdist"/>
- </or>
- </condition>
- <condition property="manifest.available+main.class-mkdist.available">
- <or>
- <istrue value="${manifest.available+main.class}"/>
- <isset property="do.mkdist"/>
- </or>
- </condition>
- <condition property="have.tests">
- <or>
- <available file="${test.src.dir}"/>
- </or>
- </condition>
- <condition property="have.sources">
- <or>
- <available file="${src.dir}"/>
- </or>
- </condition>
- <condition property="netbeans.home+have.tests">
- <and>
- <isset property="netbeans.home"/>
- <isset property="have.tests"/>
- </and>
- </condition>
- <condition property="no.javadoc.preview">
- <and>
- <isset property="javadoc.preview"/>
- <isfalse value="${javadoc.preview}"/>
- </and>
- </condition>
- <property name="run.jvmargs" value=""/>
- <property name="run.jvmargs.ide" value=""/>
- <property name="javac.compilerargs" value=""/>
- <property name="work.dir" value="${basedir}"/>
- <condition property="no.deps">
- <and>
- <istrue value="${no.dependencies}"/>
- </and>
- </condition>
- <property name="javac.debug" value="true"/>
- <property name="javadoc.preview" value="true"/>
- <property name="application.args" value=""/>
- <property name="source.encoding" value="${file.encoding}"/>
- <property name="runtime.encoding" value="${source.encoding}"/>
- <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
- <and>
- <isset property="javadoc.encoding"/>
- <not>
- <equals arg1="${javadoc.encoding}" arg2=""/>
- </not>
- </and>
- </condition>
- <property name="javadoc.encoding.used" value="${source.encoding}"/>
- <property name="includes" value="**"/>
- <property name="excludes" value=""/>
- <property name="do.depend" value="false"/>
- <condition property="do.depend.true">
- <istrue value="${do.depend}"/>
- </condition>
- <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
- <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
- <length length="0" string="${endorsed.classpath}" when="greater"/>
- </condition>
- <condition else="false" property="jdkBug6558476">
- <and>
- <matches pattern="1\.[56]" string="${java.specification.version}"/>
- <not>
- <os family="unix"/>
- </not>
- </and>
- </condition>
- <property name="javac.fork" value="${jdkBug6558476}"/>
- <property name="jar.index" value="false"/>
- <property name="jar.index.metainf" value="${jar.index}"/>
- <property name="copylibs.rebase" value="true"/>
- <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
- <condition property="junit.available">
- <or>
- <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
- <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
- </or>
- </condition>
- <condition property="testng.available">
- <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
- </condition>
- <condition property="junit+testng.available">
- <and>
- <istrue value="${junit.available}"/>
- <istrue value="${testng.available}"/>
- </and>
- </condition>
- <condition else="testng" property="testng.mode" value="mixed">
- <istrue value="${junit+testng.available}"/>
- </condition>
- <condition else="" property="testng.debug.mode" value="-mixed">
- <istrue value="${junit+testng.available}"/>
- </condition>
- </target>
- <target name="-post-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
- <fail unless="src.dir">Must set src.dir</fail>
- <fail unless="test.src.dir">Must set test.src.dir</fail>
- <fail unless="build.dir">Must set build.dir</fail>
- <fail unless="dist.dir">Must set dist.dir</fail>
- <fail unless="build.classes.dir">Must set build.classes.dir</fail>
- <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
- <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
- <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
- <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
- <fail unless="dist.jar">Must set dist.jar</fail>
- </target>
- <target name="-init-macrodef-property">
- <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
- <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <attribute default="${javac.processorpath}" name="processorpath"/>
- <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="${javac.debug}" name="debug"/>
- <attribute default="${empty.dir}" name="sourcepath"/>
- <attribute default="${empty.dir}" name="gensrcdir"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.dir}/empty" name="empty.dir"/>
- <mkdir dir="${empty.dir}"/>
- <mkdir dir="@{apgeneratedsrcdir}"/>
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
- <src>
- <dirset dir="@{gensrcdir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </src>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
- <compilerarg line="${javac.compilerargs}"/>
- <compilerarg value="-processorpath"/>
- <compilerarg path="@{processorpath}:${empty.dir}"/>
- <compilerarg line="${ap.processors.internal}"/>
- <compilerarg line="${annotation.processing.processor.options}"/>
- <compilerarg value="-s"/>
- <compilerarg path="@{apgeneratedsrcdir}"/>
- <compilerarg line="${ap.proc.none.internal}"/>
- <customize/>
- </javac>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
- <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <attribute default="${javac.processorpath}" name="processorpath"/>
- <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="${javac.debug}" name="debug"/>
- <attribute default="${empty.dir}" name="sourcepath"/>
- <attribute default="${empty.dir}" name="gensrcdir"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.dir}/empty" name="empty.dir"/>
- <mkdir dir="${empty.dir}"/>
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
- <src>
- <dirset dir="@{gensrcdir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </src>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
- <compilerarg line="${javac.compilerargs}"/>
- <customize/>
- </javac>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
- <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <sequential>
- <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- </depend>
- </sequential>
- </macrodef>
- <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${build.classes.dir}" name="destdir"/>
- <sequential>
- <fail unless="javac.includes">Must set javac.includes</fail>
- <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
- <path>
- <filelist dir="@{destdir}" files="${javac.includes}"/>
- </path>
- <globmapper from="*.java" to="*.class"/>
- </pathconvert>
- <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
- <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
- <delete>
- <files includesfile="${javac.includesfile.binary}"/>
- </delete>
- <delete>
- <fileset file="${javac.includesfile.binary}"/>
- </delete>
- </sequential>
- </macrodef>
- </target>
- <target if="${junit.available}" name="-init-macrodef-junit-init">
- <condition else="false" property="nb.junit.batch" value="true">
- <and>
- <istrue value="${junit.available}"/>
- <not>
- <isset property="test.method"/>
- </not>
- </and>
- </condition>
- <condition else="false" property="nb.junit.single" value="true">
- <and>
- <istrue value="${junit.available}"/>
- <isset property="test.method"/>
- </and>
- </condition>
- </target>
- <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
- <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property name="junit.forkmode" value="perTest"/>
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
- <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg value="-ea"/>
- <customize/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
- <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property name="junit.forkmode" value="perTest"/>
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
- <batchtest todir="${build.test.results.dir}">
- <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
- <filename name="@{testincludes}"/>
- </fileset>
- </batchtest>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg value="-ea"/>
- <customize/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
- <target if="${testng.available}" name="-init-macrodef-testng">
- <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element name="customize" optional="true"/>
- <sequential>
- <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
- <isset property="test.method"/>
- </condition>
- <union id="test.set">
- <fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
- <filename name="@{testincludes}"/>
- </fileset>
- </union>
- <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
- <testng classfilesetref="test.set" failureProperty="tests.failed" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="EssentialsUpdate" testname="TestNG tests" workingDir="${work.dir}">
- <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
- <propertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </propertyset>
- <customize/>
- </testng>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-test-impl">
- <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element implicit="true" name="customize" optional="true"/>
- <sequential>
- <echo>No tests executed.</echo>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
- <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element implicit="true" name="customize" optional="true"/>
- <sequential>
- <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
- <customize/>
- </j2seproject3:junit>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
- <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element implicit="true" name="customize" optional="true"/>
- <sequential>
- <j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
- <customize/>
- </j2seproject3:testng>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
- <macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <sequential>
- <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
- <customize>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg line="${run.jvmargs}"/>
- <jvmarg line="${run.jvmargs.ide}"/>
- </customize>
- </j2seproject3:test-impl>
- </sequential>
- </macrodef>
- </target>
- <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
- <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property name="junit.forkmode" value="perTest"/>
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
- <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg value="-ea"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
- <customize/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
- <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property name="junit.forkmode" value="perTest"/>
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
- <batchtest todir="${build.test.results.dir}">
- <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
- <filename name="@{testincludes}"/>
- </fileset>
- </batchtest>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg value="-ea"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
- <customize/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
- <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <element implicit="true" name="customize" optional="true"/>
- <sequential>
- <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
- <customize/>
- </j2seproject3:junit-debug>
- </sequential>
- </macrodef>
- </target>
- <target if="${testng.available}" name="-init-macrodef-testng-debug">
- <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${main.class}" name="testClass"/>
- <attribute default="" name="testMethod"/>
- <element name="customize2" optional="true"/>
- <sequential>
- <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
- <isset property="test.method"/>
- </condition>
- <condition else="-suitename EssentialsUpdate -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
- <matches pattern=".*\.xml" string="@{testClass}"/>
- </condition>
- <delete dir="${build.test.results.dir}" quiet="true"/>
- <mkdir dir="${build.test.results.dir}"/>
- <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">
- <customize>
- <customize2/>
- <jvmarg value="-ea"/>
- <arg line="${testng.debug.mode}"/>
- <arg line="-d ${build.test.results.dir}"/>
- <arg line="-listener org.testng.reporters.VerboseReporter"/>
- <arg line="${testng.cmd.args}"/>
- </customize>
- </j2seproject3:debug>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
- <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${main.class}" name="testClass"/>
- <attribute default="" name="testMethod"/>
- <element implicit="true" name="customize2" optional="true"/>
- <sequential>
- <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
- <customize2/>
- </j2seproject3:testng-debug>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
- <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <attribute default="${main.class}" name="testClass"/>
- <attribute default="" name="testMethod"/>
- <sequential>
- <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
- <customize>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg line="${run.jvmargs}"/>
- <jvmarg line="${run.jvmargs.ide}"/>
- </customize>
- </j2seproject3:test-debug-impl>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
- <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <attribute default="" name="testmethods"/>
- <attribute default="${main.class}" name="testClass"/>
- <attribute default="" name="testMethod"/>
- <sequential>
- <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
- <customize2>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- </customize2>
- </j2seproject3:testng-debug-impl>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
- <!--
- pre NB7.2 profiling section; consider it deprecated
- -->
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
- <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">
- <macrodef name="resolve">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${env.@{value}}"/>
- </sequential>
- </macrodef>
- <macrodef name="profile">
- <attribute default="${main.class}" name="classname"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property environment="env"/>
- <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
- <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg value="${profiler.info.jvmargs.agent}"/>
- <jvmarg line="${profiler.info.jvmargs}"/>
- <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
- <arg line="${application.args}"/>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">
- <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
- <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
- </target>
- <!--
- end of pre NB7.2 profiling section
- -->
- <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
- <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${main.class}" name="name"/>
- <attribute default="${debug.classpath}" name="classpath"/>
- <attribute default="" name="stopclassname"/>
- <sequential>
- <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- </nbjpdastart>
- </sequential>
- </macrodef>
- <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${build.classes.dir}" name="dir"/>
- <sequential>
- <nbjpdareload>
- <fileset dir="@{dir}" includes="${fix.classes}">
- <include name="${fix.includes}*.class"/>
- </fileset>
- </nbjpdareload>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-debug-args">
- <property name="version-output" value="java version &quot;${ant.java.version}"/>
- <condition property="have-jdk-older-than-1.4">
- <or>
- <contains string="${version-output}" substring="java version &quot;1.0"/>
- <contains string="${version-output}" substring="java version &quot;1.1"/>
- <contains string="${version-output}" substring="java version &quot;1.2"/>
- <contains string="${version-output}" substring="java version &quot;1.3"/>
- </or>
- </condition>
- <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
- <istrue value="${have-jdk-older-than-1.4}"/>
- </condition>
- <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
- <os family="windows"/>
- </condition>
- <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
- <isset property="debug.transport"/>
- </condition>
- </target>
- <target depends="-init-debug-args" name="-init-macrodef-debug">
- <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${main.class}" name="classname"/>
- <attribute default="${debug.classpath}" name="classpath"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
- <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
- <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
- <jvmarg line="${run.jvmargs}"/>
- <jvmarg line="${run.jvmargs.ide}"/>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-java">
- <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${main.class}" name="classname"/>
- <attribute default="${run.classpath}" name="classpath"/>
- <attribute default="jvm" name="jvm"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
- <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
- <jvmarg line="${run.jvmargs}"/>
- <jvmarg line="${run.jvmargs.ide}"/>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-copylibs">
- <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${manifest.file}" name="manifest"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
- <pathconvert property="run.classpath.without.build.classes.dir">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to=""/>
- </pathconvert>
- <pathconvert pathsep=" " property="jar.classpath">
- <path path="${run.classpath.without.build.classes.dir}"/>
- <chainedmapper>
- <flattenmapper/>
- <filtermapper>
- <replacestring from=" " to="%20"/>
- </filtermapper>
- <globmapper from="*" to="lib/*"/>
- </chainedmapper>
- </pathconvert>
- <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
- <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
- <fileset dir="${build.classes.dir}"/>
- <manifest>
- <attribute name="Class-Path" value="${jar.classpath}"/>
- <customize/>
- </manifest>
- </copylibs>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-presetdef-jar">
- <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
- <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
- <j2seproject1:fileset dir="${build.classes.dir}"/>
- </jar>
- </presetdef>
- </target>
- <target name="-init-ap-cmdline-properties">
- <property name="annotation.processing.enabled" value="true"/>
- <property name="annotation.processing.processors.list" value=""/>
- <property name="annotation.processing.processor.options" value=""/>
- <property name="annotation.processing.run.all.processors" value="true"/>
- <property name="javac.processorpath" value="${javac.classpath}"/>
- <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
- <condition property="ap.supported.internal" value="true">
- <not>
- <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
- </not>
- </condition>
- </target>
- <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
- <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
- <isfalse value="${annotation.processing.run.all.processors}"/>
- </condition>
- <condition else="" property="ap.proc.none.internal" value="-proc:none">
- <isfalse value="${annotation.processing.enabled}"/>
- </condition>
- </target>
- <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
- <property name="ap.cmd.line.internal" value=""/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
- <!--
- ===================
- COMPILATION SECTION
- ===================
- -->
- <target name="-deps-jar-init" unless="built-jar.properties">
- <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
- <delete file="${built-jar.properties}" quiet="true"/>
- </target>
- <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: EssentialsUpdate was already built"/>
- </target>
- <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
- <mkdir dir="${build.dir}"/>
- <touch file="${built-jar.properties}" verbose="false"/>
- <property file="${built-jar.properties}" prefix="already.built.jar."/>
- <antcall target="-warn-already-built-jar"/>
- <propertyfile file="${built-jar.properties}">
- <entry key="${basedir}" value=""/>
- </propertyfile>
- </target>
- <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
- <target depends="init" name="-check-automatic-build">
- <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
- </target>
- <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
- <antcall target="clean"/>
- </target>
- <target depends="init,deps-jar" name="-pre-pre-compile">
- <mkdir dir="${build.classes.dir}"/>
- </target>
- <target name="-pre-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="do.depend.true" name="-compile-depend">
- <pathconvert property="build.generated.subdirs">
- <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </pathconvert>
- <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
- </target>
- <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
- <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
- <copy todir="${build.classes.dir}">
- <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target if="has.persistence.xml" name="-copy-persistence-xml">
- <mkdir dir="${build.classes.dir}/META-INF"/>
- <copy todir="${build.classes.dir}/META-INF">
- <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
- </copy>
- </target>
- <target name="-post-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
- <target name="-pre-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:force-recompile/>
- <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
- </target>
- <target name="-post-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
- <!--
- ====================
- JAR BUILDING SECTION
- ====================
- -->
- <target depends="init" name="-pre-pre-jar">
- <dirname file="${dist.jar}" property="dist.jar.dir"/>
- <mkdir dir="${dist.jar.dir}"/>
- </target>
- <target name="-pre-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
- <j2seproject1:jar/>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
- <j2seproject1:jar manifest="${manifest.file}"/>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
- <j2seproject1:jar manifest="${manifest.file}">
- <j2seproject1:manifest>
- <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
- </j2seproject1:manifest>
- </j2seproject1:jar>
- <echo level="info">To run this application from the command line without Ant, try:</echo>
- <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
- <property location="${dist.jar}" name="dist.jar.resolved"/>
- <pathconvert property="run.classpath.with.dist.jar">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
- </pathconvert>
- <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
- </target>
- <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">
- <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
- <touch file="${tmp.manifest.file}" verbose="false"/>
- </target>
- <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest">
- <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
- <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
- </target>
- <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main">
- <manifest file="${tmp.manifest.file}" mode="update">
- <attribute name="Main-Class" value="${main.class}"/>
- </manifest>
- </target>
- <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen">
- <basename file="${application.splash}" property="splashscreen.basename"/>
- <mkdir dir="${build.classes.dir}/META-INF"/>
- <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
- <manifest file="${tmp.manifest.file}" mode="update">
- <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
- </manifest>
- </target>
- <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack">
- <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
- <echo level="info">To run this application from the command line without Ant, try:</echo>
- <property location="${dist.jar}" name="dist.jar.resolved"/>
- <echo level="info">java -jar "${dist.jar.resolved}"</echo>
- </target>
- <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">
- <delete>
- <fileset file="${tmp.manifest.file}"/>
- </delete>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/>
- <target name="-post-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
- <!--
- =================
- EXECUTION SECTION
- =================
- -->
- <target depends="init,compile" description="Run a main class." name="run">
- <j2seproject1:java>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <target name="-do-not-recompile">
- <property name="javac.includes.binary" value=""/>
- </target>
- <target depends="init,compile-single" name="run-single">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <j2seproject1:java classname="${run.class}"/>
- </target>
- <target depends="init,compile-test-single" name="run-test-with-main">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
- </target>
- <!--
- =================
- DEBUGGING SECTION
- =================
- -->
- <target depends="init" if="netbeans.home" name="-debug-start-debugger">
- <j2seproject1:nbjpdastart name="${debug.class}"/>
- </target>
- <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
- <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
- </target>
- <target depends="init,compile" name="-debug-start-debuggee">
- <j2seproject3:debug>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
- <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
- <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
- </target>
- <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
- <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
- <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
- <j2seproject3:debug classname="${debug.class}"/>
- </target>
- <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
- <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
- <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
- <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
- </target>
- <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
- <target depends="init" name="-pre-debug-fix">
- <fail unless="fix.includes">Must set fix.includes</fail>
- <property name="javac.includes" value="${fix.includes}.java"/>
- </target>
- <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
- <j2seproject1:nbjpdareload/>
- </target>
- <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
- <!--
- =================
- PROFILING SECTION
- =================
- -->
- <!--
- pre NB7.2 profiler integration
- -->
- <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
- <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile/>
- </target>
- <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">
- <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
- <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile classname="${profile.class}"/>
- </target>
- <target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">
- <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </profile>
- </target>
- <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
- <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
- <nbprofiledirect>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
- <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
- <jvmarg value="${profiler.info.jvmargs.agent}"/>
- <jvmarg line="${profiler.info.jvmargs}"/>
- <test name="${profile.class}"/>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- </junit>
- </target>
- <!--
- end of pre NB72 profiling section
- -->
- <target if="netbeans.home" name="-profile-check">
- <condition property="profiler.configured">
- <or>
- <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
- <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
- </or>
- </condition>
- </target>
- <target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
- <startprofiler/>
- <antcall target="run"/>
- </target>
- <target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <startprofiler/>
- <antcall target="run-single"/>
- </target>
- <target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>
- <target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">
- <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
- <startprofiler/>
- <antcall target="test-single"/>
- </target>
- <target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <startprofiler/>
- <antcal target="run-test-with-main"/>
- </target>
- <target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <startprofiler/>
- <antcall target="run-applet"/>
- </target>
- <!--
- ===============
- JAVADOC SECTION
- ===============
- -->
- <target depends="init" if="have.sources" name="-javadoc-build">
- <mkdir dir="${dist.javadoc.dir}"/>
- <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
- <and>
- <isset property="endorsed.classpath.cmd.line.arg"/>
- <not>
- <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
- </not>
- </and>
- </condition>
- <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
- <classpath>
- <path path="${javac.classpath}"/>
- </classpath>
- <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
- <filename name="**/*.java"/>
- </fileset>
- <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="**/*.java"/>
- <exclude name="*.java"/>
- </fileset>
- <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
- </javadoc>
- <copy todir="${dist.javadoc.dir}">
- <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
- <filename name="**/doc-files/**"/>
- </fileset>
- <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="**/doc-files/**"/>
- </fileset>
- </copy>
- </target>
- <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
- <nbbrowse file="${dist.javadoc.dir}/index.html"/>
- </target>
- <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
- <!--
- =========================
- TEST COMPILATION SECTION
- =========================
- -->
- <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
- <mkdir dir="${build.test.classes.dir}"/>
- </target>
- <target name="-pre-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="do.depend.true" name="-compile-test-depend">
- <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
- </target>
- <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target name="-post-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
- <target name="-pre-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target name="-post-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
- <!--
- =======================
- TEST EXECUTION SECTION
- =======================
- -->
- <target depends="init" if="have.tests" name="-pre-test-run">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
- <j2seproject3:test testincludes="**/*Test.java"/>
- </target>
- <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
- <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
- </target>
- <target depends="init" if="have.tests" name="test-report"/>
- <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
- <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
- <target depends="init" if="have.tests" name="-pre-test-run-single">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
- <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
- <j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
- <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
- <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
- <fail unless="test.class">Must select some files in the IDE or set test.class</fail>
- <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
- <j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
- <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
- <!--
- =======================
- TEST DEBUGGING SECTION
- =======================
- -->
- <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
- <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
- <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
- <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
- <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
- <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
- </target>
- <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
- <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
- </target>
- <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
- <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
- <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
- <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
- </target>
- <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
- <!--
- =========================
- APPLET EXECUTION SECTION
- =========================
- -->
- <target depends="init,compile-single" name="run-applet">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject1:java classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <!--
- =========================
- APPLET DEBUGGING SECTION
- =========================
- -->
- <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject3:debug classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
- <!--
- ===============
- CLEANUP SECTION
- ===============
- -->
- <target name="-deps-clean-init" unless="built-clean.properties">
- <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
- <delete file="${built-clean.properties}" quiet="true"/>
- </target>
- <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: EssentialsUpdate was already built"/>
- </target>
- <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
- <mkdir dir="${build.dir}"/>
- <touch file="${built-clean.properties}" verbose="false"/>
- <property file="${built-clean.properties}" prefix="already.built.clean."/>
- <antcall target="-warn-already-built-clean"/>
- <propertyfile file="${built-clean.properties}">
- <entry key="${basedir}" value=""/>
- </propertyfile>
- </target>
- <target depends="init" name="-do-clean">
- <delete dir="${build.dir}"/>
- <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
- </target>
- <target name="-post-clean">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
- <target name="-check-call-dep">
- <property file="${call.built.properties}" prefix="already.built."/>
- <condition property="should.call.dep">
- <and>
- <not>
- <isset property="already.built.${call.subproject}"/>
- </not>
- <available file="${call.script}"/>
- </and>
- </condition>
- </target>
- <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
- <ant antfile="${call.script}" inheritall="false" target="${call.target}">
- <propertyset>
- <propertyref prefix="transfer."/>
- <mapper from="transfer.*" to="*" type="glob"/>
- </propertyset>
- </ant>
- </target>
-</project>
diff --git a/EssentialsUpdate/nbproject/genfiles.properties b/EssentialsUpdate/nbproject/genfiles.properties
deleted file mode 100644
index 39c782bce..000000000
--- a/EssentialsUpdate/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=fd4b98a9
-build.xml.script.CRC32=334f342d
-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=fd4b98a9
-nbproject/build-impl.xml.script.CRC32=966cfa4e
-nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
diff --git a/EssentialsUpdate/nbproject/pmd.settings b/EssentialsUpdate/nbproject/pmd.settings
deleted file mode 100644
index 6a34e356c..000000000
--- a/EssentialsUpdate/nbproject/pmd.settings
+++ /dev/null
@@ -1 +0,0 @@
-DoNotUseThreads
diff --git a/EssentialsUpdate/nbproject/project.properties b/EssentialsUpdate/nbproject/project.properties
deleted file mode 100644
index 88315dfa0..000000000
--- a/EssentialsUpdate/nbproject/project.properties
+++ /dev/null
@@ -1,112 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=EssentialsUpdate
-application.vendor=essentialsteam
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/EssentialsUpdate.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-file.reference.bukkit.jar=../lib/bukkit.jar
-includes=**
-jar.compress=true
-javac.classpath=\
- ${file.reference.bukkit.jar}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.6
-javac.target=1.6
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${libs.junit_4.10.classpath}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/EssentialsUpdate/nbproject/project.xml b/EssentialsUpdate/nbproject/project.xml
deleted file mode 100644
index 6b0efd00f..000000000
--- a/EssentialsUpdate/nbproject/project.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.java.j2seproject</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>EssentialsUpdate</name>
- <source-roots>
- <root id="src.dir"/>
- </source-roots>
- <test-roots>
- <root id="test.src.dir"/>
- </test-roots>
- </data>
- <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
- <definitions>../lib/nblibraries.properties</definitions>
- </libraries>
- </configuration>
-</project>
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java b/EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java
deleted file mode 100644
index d2cbb8a64..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/AbstractWorkListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.earth2me.essentials.update;
-
-import org.bukkit.plugin.Plugin;
-
-
-public abstract class AbstractWorkListener
-{
- public AbstractWorkListener(final Plugin plugin, final VersionInfo newVersionInfo)
- {
- this.plugin = plugin;
- this.newVersionInfo = newVersionInfo;
- }
- private final transient Plugin plugin;
- private final transient VersionInfo newVersionInfo;
-
- public final void onWorkAbort()
- {
- onWorkAbort(null);
- }
-
- public abstract void onWorkAbort(String message);
-
- public final void onWorkDone()
- {
- onWorkDone(null);
- }
-
- public abstract void onWorkDone(String message);
-
- public VersionInfo getNewVersionInfo()
- {
- return newVersionInfo;
- }
-
- public Plugin getPlugin()
- {
- return plugin;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java
deleted file mode 100644
index 63cdc094a..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsHelp.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package com.earth2me.essentials.update;
-
-import com.earth2me.essentials.update.chat.*;
-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;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginManager;
-
-
-public class EssentialsHelp implements Listener
-{
- private transient Player chatUser;
- private final transient Server server;
- private final transient Plugin plugin;
- 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()
- {
- final PluginManager pluginManager = server.getPluginManager();
- pluginManager.registerEvents(this, plugin);
- }
-
- public void onCommand(final CommandSender sender)
- {
- if (sender instanceof Player && sender.hasPermission("essentials.helpchat"))
- {
- if (chatUser == null)
- {
- chatUser = (Player)sender;
- ircBot = null;
- sender.sendMessage("You will be connected to the Essentials Help Chat.");
- sender.sendMessage("All your chat messages will be forwarded to the channel. You can't chat with other players on your server while in help chat, but you can use commands.");
- sender.sendMessage("Please be patient, if noone is available, check back later.");
- sender.sendMessage("Type !help to get a list of all commands.");
- sender.sendMessage("Type !quit to leave the channel.");
- sender.sendMessage("Do you want to join the channel now? (yes/no)");
- }
- if (!chatUser.equals(sender))
- {
- sender.sendMessage("The player " + chatUser.getDisplayName() + " is already using the essentialshelp.");
- }
- }
- else
- {
- sender.sendMessage("Please run the command as op from in game.");
- }
- }
-
- public void onDisable()
- {
- closeConnection();
- }
-
- private boolean sendChatMessage(final Player player, final String message)
- {
- final String messageCleaned = message.trim();
- if (messageCleaned.isEmpty())
- {
- return false;
- }
- if (ircBot == null)
- {
- return handleAnswer(messageCleaned, player);
- }
- else
- {
- if (ircBot.isKicked())
- {
- closeConnection();
- return false;
- }
- final String lowMessage = messageCleaned.toLowerCase(Locale.ENGLISH);
- if (lowMessage.startsWith("!quit"))
- {
- closeConnection();
- player.sendMessage("Connection closed.");
- return true;
- }
- if (!ircBot.isConnected() || ircBot.getChannels().length == 0)
- {
- return false;
- }
- if (handleCommands(lowMessage, player))
- {
- return true;
- }
- ircBot.sendMessage(messageCleaned);
- chatUser.sendMessage("§6" + ircBot.getNick() + ": §7" + messageCleaned);
- return true;
- }
- }
-
- private void closeConnection()
- {
- chatUser = null;
- if (ircBot != null)
- {
- ircBot.quit();
- ircBot = null;
- }
- }
-
- private boolean handleAnswer(final String message, final Player player)
- {
- if (message.equalsIgnoreCase("yes"))
- {
- player.sendMessage("Connecting...");
- connectToIRC(player);
- return true;
- }
- if (message.equalsIgnoreCase("no") || message.equalsIgnoreCase("!quit"))
- {
- chatUser = null;
- return true;
- }
- return false;
- }
-
- private boolean handleCommands(final String lowMessage, final Player player)
- {
- final String[] parts = lowMessage.split(" ");
- if (commands.containsKey(parts[0]))
- {
- commands.get(parts[0]).run(ircBot, player);
- return true;
- }
- return false;
- }
-
- private void connectToIRC(final Player player)
- {
- ircBot = new IrcBot(player, "Ess_" + player.getName(), UsernameUtil.createUsername(player));
- }
-
- @EventHandler
- public void onPlayerChat(final AsyncPlayerChatEvent event)
- {
- if (event.getPlayer() == chatUser)
- {
- final boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
- event.setCancelled(success);
- }
- }
-
- @EventHandler
- public void onPlayerQuit(final PlayerQuitEvent event)
- {
- closeConnection();
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java b/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java
deleted file mode 100644
index be6e42ce9..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/EssentialsUpdate.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.util.logging.Level;
-import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.plugin.java.JavaPlugin;
-
-
-public class EssentialsUpdate extends JavaPlugin
-{
- private transient EssentialsHelp essentialsHelp;
- private transient UpdateProcess updateProcess;
-
- @Override
- public void onEnable()
- {
- if (!getDataFolder().exists() && !getDataFolder().mkdirs())
- {
- 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().log(Level.INFO, "EssentialsUpdate {0} loaded.", getDescription().getVersion());
-
- if (updateCheck.isEssentialsInstalled())
- {
- updateCheck.scheduleUpdateTask();
- }
- else
- {
- Bukkit.getLogger().info("Essentials is ready for installation. Join the game and follow the instructions.");
- }
- }
-
- @Override
- public void onDisable()
- {
- essentialsHelp.onDisable();
- }
-
- @Override
- public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args)
- {
- if (command.getName().equalsIgnoreCase("essentialsupdate"))
- {
- updateProcess.onCommand(sender);
- }
- if (command.getName().equalsIgnoreCase("essentialshelp"))
- {
- essentialsHelp.onCommand(sender);
- }
- return true;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java b/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java
deleted file mode 100644
index 06b414e93..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/GetFile.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.*;
-import java.math.BigInteger;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.logging.Level;
-import org.bukkit.Bukkit;
-
-
-public class GetFile
-{
- private transient URLConnection connection;
- private transient MessageDigest digest;
-
- public GetFile(final String urlString) throws MalformedURLException, IOException
- {
- this(new URL(urlString));
- }
-
- public GetFile(final URL url) throws IOException
- {
- this.connection = url.openConnection();
- this.connection.setConnectTimeout(1000);
- this.connection.setReadTimeout(5000);
- this.connection.setUseCaches(false);
- this.connection.connect();
- final int respCode = ((HttpURLConnection)this.connection).getResponseCode();
- if (respCode >= 300 && respCode < 400 && this.connection.getHeaderField("Location") != null)
- {
- connection.getInputStream().close();
- final URL redirect = new URL(this.connection.getHeaderField("Location"));
- this.connection = redirect.openConnection();
- this.connection.setConnectTimeout(1000);
- this.connection.setReadTimeout(5000);
- this.connection.setUseCaches(false);
- this.connection.connect();
- }
- }
-
- public void saveTo(final File file) throws IOException
- {
- try
- {
- saveTo(file, null);
- }
- catch (NoSuchAlgorithmException ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
- public void saveTo(final File file, final String key) throws IOException, NoSuchAlgorithmException
- {
- if (key != null)
- {
- digest = MessageDigest.getInstance("SHA256");
- }
- final byte[] buffer = new byte[1024 * 8];
- boolean brokenFile = false;
- final BufferedInputStream input = new BufferedInputStream(connection.getInputStream());
- try
- {
- final BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(file));
- try
- {
- int length;
- do
- {
- length = input.read(buffer);
- if (length >= 0)
- {
- if (key != null)
- {
- digest.update(buffer, 0, length);
- }
- output.write(buffer, 0, length);
- }
- }
- while (length >= 0);
- if (key != null)
- {
- final byte[] checksum = digest.digest();
- final String checksumString = new BigInteger(checksum).toString(36);
- if (!checksumString.equals(key))
- {
- brokenFile = true;
- }
- }
- }
- finally
- {
- output.close();
- }
- if (brokenFile && !file.delete())
- {
- Bukkit.getLogger().log(Level.SEVERE, "Could not delete file {0}", file.getPath());
- }
- }
- finally
- {
- input.close();
- }
- if (brokenFile)
- {
- throw new IOException("Checksum check failed.");
- }
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/ModuleInfo.java b/EssentialsUpdate/src/com/earth2me/essentials/update/ModuleInfo.java
deleted file mode 100644
index 722fca3e1..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/ModuleInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import org.bukkit.configuration.Configuration;
-
-
-public class ModuleInfo
-{
- private final transient String url;
- private final transient String version;
- private final transient String hash;
-
- public ModuleInfo(final Configuration updateConfig, final String path)
- {
- url = updateConfig.getString(path + ".url", null);
- version = updateConfig.getString(path + ".version", null);
- hash = updateConfig.getString(path + ".hash", null);
- }
-
- public URL getUrl() throws MalformedURLException
- {
- return new URL(url);
- }
-
- public String getVersion()
- {
- return version;
- }
-
- public String getHash()
- {
- return hash;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java b/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java
deleted file mode 100644
index 6cad44e4d..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/PastieUpload.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-public class PastieUpload
-{
- private final transient PostToUrl connection;
-
- public PastieUpload() throws MalformedURLException
- {
- connection = new PostToUrl(new URL("http://pastie.org/pastes"));
- }
-
- public String send(final String data) throws IOException
- {
- final Map<String, Object> map = new HashMap<String, Object>();
- map.put("paste[parser_id]", "19");
- map.put("paste[authorization]", "burger");
- map.put("paste[body]", data);
- map.put("paste[restricted]", "1");
- final String html = connection.send(map);
- final Matcher matcher = Pattern.compile("(?s).*\\?key=([a-z0-9]+).*").matcher(html);
- if (matcher.matches())
- {
- final String key = matcher.group(1);
- return "http://pastie.org/private/" + key;
- }
- else
- {
- throw new IOException("Failed to upload to pastie.org");
- }
- }
-} \ No newline at end of file
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/PostToUrl.java b/EssentialsUpdate/src/com/earth2me/essentials/update/PostToUrl.java
deleted file mode 100644
index c8978961b..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/PostToUrl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.math.BigInteger;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.Charset;
-import java.util.Map;
-import java.util.Random;
-
-
-public class PostToUrl
-{
- private final transient URL url;
- private final transient String boundary;
- private final transient Random random = new Random();
- private final static String CRLF = "\r\n";
- private final static Charset UTF8 = Charset.forName("utf-8");
-
- public PostToUrl(final URL url)
- {
- this.url = url;
- final byte[] bytes = new byte[32];
- random.nextBytes(bytes);
- this.boundary = "----------" + new BigInteger(bytes).toString(Character.MAX_RADIX) + "_$";
- }
-
- public String send(final Map<String, Object> data) throws IOException
- {
- final URLConnection connection = url.openConnection();
- connection.setRequestProperty("content-type", "multipart/form-data; boundary=" + boundary);
- final StringBuilder dataBuilder = new StringBuilder();
- for (Map.Entry<String, Object> entry : data.entrySet())
- {
- if (entry.getValue() instanceof String)
- {
- dataBuilder.append("--").append(boundary).append(CRLF);
- dataBuilder.append("Content-Disposition: form-data; name=\"").append(entry.getKey()).append('"').append(CRLF);
- dataBuilder.append(CRLF);
- dataBuilder.append(entry.getValue()).append(CRLF);
- }
- // TODO: Add support for file upload
- }
- dataBuilder.append("--").append(boundary).append("--").append(CRLF);
- dataBuilder.append(CRLF);
- connection.setDoOutput(true);
- final byte[] message = dataBuilder.toString().getBytes(UTF8);
- connection.setRequestProperty("content-length", Integer.toString(message.length));
- connection.connect();
- final OutputStream stream = connection.getOutputStream();
- stream.write(message);
- stream.close();
- final BufferedReader page = new BufferedReader(new InputStreamReader(connection.getInputStream(), UTF8));
- final StringBuilder input = new StringBuilder();
- String line;
- while ((line = page.readLine()) != null)
- {
- input.append(line).append("\n");
- }
- page.close();
- return input.toString();
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java
deleted file mode 100644
index 29afc4d3f..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateCheck.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.File;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginManager;
-
-
-public class UpdateCheck
-{
- private transient CheckResult result = CheckResult.UNKNOWN;
- private transient Version currentVersion;
- private transient Version newVersion = null;
- private transient int bukkitResult = 0;
- private transient UpdateFile updateFile;
- private final static int CHECK_INTERVAL = 20 * 60 * 60 * 6;
- private final transient Plugin plugin;
- private transient boolean essentialsInstalled;
-
- public UpdateCheck(final Plugin plugin)
- {
- this.plugin = plugin;
- updateFile = new UpdateFile(plugin);
- checkForEssentials();
- }
-
- private void checkForEssentials()
- {
- final PluginManager pluginManager = plugin.getServer().getPluginManager();
- final Plugin essentials = pluginManager.getPlugin("Essentials");
- essentialsInstalled = essentials != null;
- if (essentialsInstalled)
- {
- currentVersion = new Version(essentials.getDescription().getVersion());
- }
- else
- {
- if (new File(plugin.getDataFolder().getParentFile(), "Essentials.jar").exists())
- {
- Bukkit.getLogger().severe("Essentials.jar found, but not recognized by Bukkit. Broken download?");
- }
- }
- }
-
- public void scheduleUpdateTask()
- {
- plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
- {
- @Override
- public void run()
- {
- updateFile = new UpdateFile(plugin);
- checkForUpdates();
- }
- }, CHECK_INTERVAL, CHECK_INTERVAL);
- }
-
- public boolean isEssentialsInstalled()
- {
- return essentialsInstalled;
- }
-
- public CheckResult getResult()
- {
- return result;
- }
-
- public int getNewBukkitVersion()
- {
- return bukkitResult;
- }
-
- public VersionInfo getNewVersionInfo()
- {
- return updateFile.getVersions().get(newVersion);
- }
-
-
- public enum CheckResult
- {
- NEW_ESS, NEW_ESS_BUKKIT, NEW_BUKKIT, OK, UNKNOWN
- }
-
- public void checkForUpdates()
- {
- if (currentVersion == null)
- {
- return;
- }
- final Map<Version, VersionInfo> versions = updateFile.getVersions();
- final int bukkitVersion = getBukkitVersion();
- Version higher = null;
- Version found = null;
- Version lower = null;
- int bukkitHigher = 0;
- int bukkitLower = 0;
- for (Entry<Version, VersionInfo> entry : versions.entrySet())
- {
- final int minBukkit = entry.getValue().getMinBukkit();
- final int maxBukkit = entry.getValue().getMaxBukkit();
- if (minBukkit == 0 || maxBukkit == 0)
- {
- continue;
- }
- if (bukkitVersion <= maxBukkit)
- {
- if (bukkitVersion < minBukkit)
- {
- if (higher == null || higher.compareTo(entry.getKey()) < 0)
- {
-
- higher = entry.getKey();
- bukkitHigher = minBukkit;
- }
- }
- else
- {
- if (found == null || found.compareTo(entry.getKey()) < 0)
- {
- found = entry.getKey();
- }
- }
- }
- else
- {
- if (lower == null || lower.compareTo(entry.getKey()) < 0)
- {
- lower = entry.getKey();
- bukkitLower = minBukkit;
- }
- }
- }
- if (found != null)
- {
- if (found.compareTo(currentVersion) > 0)
- {
- result = CheckResult.NEW_ESS;
- newVersion = found;
- }
- else
- {
- result = CheckResult.OK;
- }
- }
- else if (higher != null)
- {
- if (higher.compareTo(currentVersion) > 0)
- {
- newVersion = higher;
- result = CheckResult.NEW_ESS_BUKKIT;
- bukkitResult = bukkitHigher;
- }
- else if (higher.compareTo(currentVersion) < 0)
- {
- result = CheckResult.UNKNOWN;
- }
- else
- {
- result = CheckResult.NEW_BUKKIT;
- bukkitResult = bukkitHigher;
- }
- }
- else if (lower != null)
- {
- if (lower.compareTo(currentVersion) > 0)
- {
- result = CheckResult.NEW_ESS_BUKKIT;
- newVersion = lower;
- bukkitResult = bukkitLower;
- }
- else if (lower.compareTo(currentVersion) < 0)
- {
- result = CheckResult.UNKNOWN;
- }
- else
- {
- result = CheckResult.NEW_BUKKIT;
- bukkitResult = bukkitLower;
- }
- }
-
- }
-
- private int getBukkitVersion()
- {
- final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(plugin.getServer().getVersion());
- if (versionMatch.matches())
- {
- return Integer.parseInt(versionMatch.group(4));
- }
- throw new NumberFormatException("Bukkit Version changed!");
- }
-
- public Version getNewVersion()
- {
- return newVersion;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java
deleted file mode 100644
index 3d465e2e8..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateFile.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.KeyFactory;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Collections;
-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.configuration.file.YamlConfiguration;
-import org.bukkit.plugin.Plugin;
-
-
-public class UpdateFile
-{
- 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;
- private transient YamlConfiguration updateConfig;
- private final transient Plugin plugin;
- private final transient TreeMap<Version, VersionInfo> versions = new TreeMap<Version, VersionInfo>();
-
- public UpdateFile(final Plugin plugin)
- {
- this.plugin = plugin;
- final long lastUpdate = Long.parseLong(plugin.getConfig().getString("lastupdate", "0"));
- file = new File(plugin.getDataFolder(), "update.yml");
- if (lastUpdate < System.currentTimeMillis() - 1000 * 60 * 60 * 6 || !file.exists())
- {
- if (file.exists() && !file.delete())
- {
- LOGGER.log(Level.SEVERE, "Could not delete file update.yml!");
- return;
- }
- if (!downloadFile() || !checkFile())
- {
- LOGGER.log(Level.SEVERE, "Could not download and verify file update.yml!");
- return;
- }
- }
- try
- {
- readVersions();
- }
- catch (Exception ex)
- {
- LOGGER.log(Level.SEVERE, "Could not load update.yml!");
- return;
- }
- }
-
- private boolean downloadFile()
- {
- GetFile getFile;
- try
- {
- getFile = new GetFile(UPDATE_URL);
- getFile.saveTo(file);
- plugin.getConfig().set("lastupdate", System.currentTimeMillis());
- plugin.getConfig().save(new File(plugin.getDataFolder(), "config.yml"));
- return true;
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, "Error while downloading update.yml", ex);
- return false;
- }
- }
-
- private boolean checkFile()
- {
- BufferedInputStream bis = null;
- try
- {
- bis = new BufferedInputStream(new FileInputStream(file));
- if (bis.read() != '#')
- {
- throw new IOException("File has to start with #");
- }
- final StringBuilder length = new StringBuilder();
- final StringBuilder signature = new StringBuilder();
- boolean isSignature = false;
- do
- {
- final int cur = bis.read();
- if (cur == -1)
- {
- break;
- }
- if (cur == ':')
- {
- isSignature = true;
- }
- else if (cur == '\n')
- {
- break;
- }
- else if ((cur >= '0' && cur <= '9')
- || (cur >= 'a' && cur <= 'z'))
- {
- if (isSignature)
- {
- signature.append((char)cur);
- }
- else
- {
- length.append((char)cur);
- }
- }
- else
- {
- throw new IOException("Illegal character in signature!");
- }
- }
- while (true);
- if (length.length() == 0 || signature.length() == 0)
- {
- throw new IOException("Broken signature!");
- }
- final int sigLength = new BigInteger(length.toString(), 36).intValue();
- if (sigLength < 0 || sigLength > 2048)
- {
- throw new IOException("Invalid signature length!");
- }
- final byte[] sigBytes = new BigInteger(signature.toString(), 36).toByteArray();
- if (sigLength < sigBytes.length)
- {
- throw new IOException("Length is less then available bytes.");
- }
- byte[] realBytes;
- if (sigLength == sigBytes.length)
- {
- realBytes = sigBytes;
- }
- else
- {
- realBytes = new byte[sigLength];
- System.arraycopy(sigBytes, 0, realBytes, sigLength - sigBytes.length, sigBytes.length);
- }
- final X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(PUBLIC_KEY.toByteArray());
- final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- final PublicKey pubKey = keyFactory.generatePublic(pubKeySpec);
- final Signature rsa = Signature.getInstance("SHA256withRSA");
- rsa.initVerify(pubKey);
- final byte[] buffer = new byte[2048];
- int readLength;
- do
- {
- readLength = bis.read(buffer);
- if (readLength >= 0)
- {
- rsa.update(buffer, 0, readLength);
- }
- }
- while (readLength >= 0);
- return rsa.verify(realBytes);
- }
- catch (Exception ex)
- {
- LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
- }
- finally
- {
- try
- {
- if (bis != null)
- {
- bis.close();
- }
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
- }
- }
- return false;
- }
-
- private void readVersions() throws Exception
- {
- updateConfig = new YamlConfiguration();
- updateConfig.load(file);
- versions.clear();
- for (String versionString : updateConfig.getKeys(false))
- {
- final Version version = new Version(versionString);
- final VersionInfo info = new VersionInfo(updateConfig, versionString);
- versions.put(version, info);
- }
- }
-
- public Map<Version, VersionInfo> getVersions()
- {
- return Collections.unmodifiableMap(versions.descendingMap());
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
deleted file mode 100644
index 29c227794..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdateProcess.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package com.earth2me.essentials.update;
-
-import com.earth2me.essentials.update.states.InstallationFinishedEvent;
-import com.earth2me.essentials.update.states.StateMachine;
-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.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.plugin.Plugin;
-
-
-public class UpdateProcess implements Listener
-{
- private transient Player currentPlayer;
- private final transient Plugin plugin;
- private final transient UpdateCheck updateCheck;
- private transient StateMachine stateMachine;
-
- public UpdateProcess(final Plugin plugin, final UpdateCheck updateCheck)
- {
- super();
- this.plugin = plugin;
- this.updateCheck = updateCheck;
- }
-
- public void registerEvents()
- {
- plugin.getServer().getPluginManager().registerEvents(this, 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;
- }
-
- @EventHandler
- public void onInstallationFinished(final InstallationFinishedEvent event)
- {
- UpdateProcess.this.currentPlayer = null;
- }
-
- @EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerChat(final AsyncPlayerChatEvent event)
- {
- if (event.getPlayer() == currentPlayer)
- {
- final StateMachine.MachineResult result = stateMachine.reactOnMessage(event.getMessage());
- if (result == StateMachine.MachineResult.ABORT)
- {
- currentPlayer.sendMessage("Installation wizard aborted. You can restart it using /essentialsupdate.");
- currentPlayer = null;
- }
- if (result == StateMachine.MachineResult.DONE)
- {
- startWork();
- }
- event.setCancelled(true);
- return;
- }
- }
-
- @EventHandler
- 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());
- player.sendMessage("Please type /essentialsupdate into the chat to start the installation of Essentials.");
- }
- if (player.hasPermission("essentials.update"))
- {
- final UpdateCheck.CheckResult result = updateCheck.getResult();
- switch (result)
- {
- case NEW_ESS:
- player.sendMessage("The new version " + updateCheck.getNewVersion().toString() + " for Essentials is available. Please type /essentialsupdate to update.");
- break;
- case NEW_BUKKIT:
- player.sendMessage("Your bukkit version is not the recommended build for Essentials, please update to version " + updateCheck.getNewBukkitVersion() + ".");
- break;
- case NEW_ESS_BUKKIT:
- player.sendMessage("There is a new version " + updateCheck.getNewVersion().toString() + " of Essentials for Bukkit " + updateCheck.getNewBukkitVersion());
- break;
- default:
- }
- }
- }
-
- public void onCommand(final CommandSender sender)
- {
- if (sender instanceof Player && sender.hasPermission("essentials.update"))
- {
- if (currentPlayer == null)
- {
- currentPlayer = (Player)sender;
- if (selfUpdate())
- {
- return;
- }
- stateMachine = new StateMachine(plugin, currentPlayer, updateCheck);
- final StateMachine.MachineResult result = stateMachine.askQuestion();
- if (result == StateMachine.MachineResult.DONE)
- {
- startWork();
- }
- }
- if (!currentPlayer.equals(sender))
- {
- sender.sendMessage("The player " + currentPlayer.getDisplayName() + " is already using the wizard.");
- }
- }
- else
- {
- sender.sendMessage("Please run the command as op from in game.");
- }
- }
-
- private void startWork()
- {
- currentPlayer.sendMessage("Installation wizard done. Starting installation.");
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
- {
- @Override
- public void run()
- {
- stateMachine.startWork();
- }
- });
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java b/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java
deleted file mode 100644
index a82f49abf..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/Version.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-public class Version implements Comparable<Version>
-{
- public enum Type
- {
- STABLE, PREVIEW, DEVELOPER
- }
-
- public int getMajor()
- {
- return major;
- }
-
- public int getMinor()
- {
- return minor;
- }
-
- public int getBuild()
- {
- return build;
- }
-
- public Type getType()
- {
- return type;
- }
- private final transient int major;
- private final transient int minor;
- private final transient int build;
- private final transient Type type;
-
- public Version(final String versionString)
- {
- final Matcher matcher = Pattern.compile("(Pre|Dev)?([0-9]+)[_\\.]([0-9]+)[_\\.]([0-9]+).*").matcher(versionString);
- if (!matcher.matches() || matcher.groupCount() < 4)
- {
- type = Type.DEVELOPER;
- major = 99;
- minor = build = 0;
- return;
- }
- if (versionString.startsWith("Pre"))
- {
- type = Type.PREVIEW;
- }
- else if (versionString.startsWith("Dev"))
- {
- type = Type.DEVELOPER;
- }
- else
- {
- type = Type.STABLE;
- }
- major = Integer.parseInt(matcher.group(2));
- minor = Integer.parseInt(matcher.group(3));
- build = Integer.parseInt(matcher.group(4));
- }
-
- @Override
- public int compareTo(final Version other)
- {
- int ret = 0;
- if (other.getType() == Type.DEVELOPER && getType() != Type.DEVELOPER)
- {
- ret = -1;
- }
- else if (getType() == Type.DEVELOPER && other.getType() != Type.DEVELOPER)
- {
- ret = 1;
- }
- else if (other.getMajor() > getMajor())
- {
- ret = -1;
- }
- else if (getMajor() > other.getMajor())
- {
- ret = 1;
- }
- else if (other.getMinor() > getMinor())
- {
- ret = -1;
- }
- else if (getMinor() > other.getMinor())
- {
- ret = 1;
- }
- else if (other.getBuild() > getBuild())
- {
- ret = -1;
- }
- else if (getBuild() > other.getBuild())
- {
- ret = 1;
- }
- else if (other.getType() == Type.STABLE && getType() == Type.PREVIEW)
- {
- ret = -1;
- }
- else if (getType() == Type.STABLE && other.getType() == Type.PREVIEW)
- {
- ret = 1;
- }
- return ret;
- }
-
- @Override
- public boolean equals(final Object obj)
- {
- if (obj == null)
- {
- return false;
- }
- if (getClass() != obj.getClass())
- {
- return false;
- }
- final Version other = (Version)obj;
- if (this.major != other.major)
- {
- return false;
- }
- if (this.minor != other.minor)
- {
- return false;
- }
- if (this.build != other.build)
- {
- return false;
- }
- if (this.type != other.type)
- {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int hash = 5;
- hash = 71 * hash + this.major;
- hash = 71 * hash + this.minor;
- hash = 71 * hash + this.build;
- hash = 71 * hash + (this.type == null ? 0 : this.type.hashCode());
- return hash;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder builder = new StringBuilder();
- if (type == Type.DEVELOPER)
- {
- builder.append("Dev");
- }
- if (type == Type.PREVIEW)
- {
- builder.append("Pre");
- }
- builder.append(major);
- builder.append('.');
- builder.append(minor);
- builder.append('.');
- builder.append(build);
- return builder.toString();
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/VersionInfo.java b/EssentialsUpdate/src/com/earth2me/essentials/update/VersionInfo.java
deleted file mode 100644
index c06aa2e64..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/VersionInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.bukkit.configuration.Configuration;
-
-
-public class VersionInfo
-{
- private final transient List<String> changelog;
- private final transient int minBukkit;
- private final transient int maxBukkit;
- private final transient Map<String, ModuleInfo> modules;
-
- public VersionInfo(final Configuration updateConfig, final String path)
- {
- changelog = updateConfig.getStringList(path + ".changelog");
- minBukkit = updateConfig.getInt(path + ".min-bukkit", 0);
- maxBukkit = updateConfig.getInt(path + ".max-bukkit", 0);
- modules = new HashMap<String, ModuleInfo>();
- final String modulesPath = path + ".modules";
- for (String module : updateConfig.getKeys(false))
- {
- modules.put(module, new ModuleInfo(updateConfig, modulesPath + module));
- }
- }
-
- public List<String> getChangelog()
- {
- return Collections.unmodifiableList(changelog);
- }
-
- public int getMinBukkit()
- {
- return minBukkit;
- }
-
- public int getMaxBukkit()
- {
- return maxBukkit;
- }
-
- public Map<String, ModuleInfo> getModules()
- {
- return Collections.unmodifiableMap(modules);
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
deleted file mode 100644
index 7c99d28f6..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.earth2me.essentials.update.chat;
-
-import com.earth2me.essentials.update.PastieUpload;
-import java.io.*;
-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
deleted file mode 100644
index ad4c75e43..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/Command.java
+++ /dev/null
@@ -1,9 +0,0 @@
-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
deleted file mode 100644
index de2c6a830..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-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
deleted file mode 100644
index 41aa551c4..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ErrorsCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index a6f76cece..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/HelpCommand.java
+++ /dev/null
@@ -1,18 +0,0 @@
-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/chat/IrcBot.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java
deleted file mode 100644
index 31e9384ee..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/IrcBot.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package com.earth2me.essentials.update.chat;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.jibble.pircbot.Colors;
-import org.jibble.pircbot.IrcException;
-import org.jibble.pircbot.PircBot;
-import org.jibble.pircbot.User;
-
-
-public class IrcBot extends PircBot
-{
- private static final String CHANNEL = "#essentials";
- private static final int PORT = 6667;
- private static final String SERVER = "irc.esper.net";
- private transient boolean reconnect = true;
- private final transient Player player;
- private transient boolean kicked = false;
-
- public IrcBot(final Player player, final String nickName, final String versionString)
- {
- super();
- this.player = player;
- setName(nickName);
- setLogin("esshelp");
- setVersion(versionString);
- connect();
- joinChannel(CHANNEL);
- }
-
- private void connect()
- {
- try
- {
- connect(SERVER, PORT);
- return;
- }
- catch (IOException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
- }
- catch (IrcException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
- }
- }
-
- public void quit()
- {
- reconnect = false;
- disconnect();
- }
-
- @Override
- protected void onConnect()
- {
- reconnect = true;
- }
-
- @Override
- protected void onDisconnect()
- {
- if (reconnect)
- {
- int tries = 10;
- while (!isConnected())
- {
- try
- {
- tries--;
- reconnect();
- }
- catch (Exception e)
- {
- Bukkit.getLogger().log(Level.WARNING, e.getMessage(), e);
- try
- {
- Thread.sleep(10000);
- }
- catch (InterruptedException ex)
- {
- Bukkit.getLogger().log(Level.WARNING, e.getMessage(), e);
- }
- }
- if (tries <= 0)
- {
- player.sendMessage("Connection lost to server.");
- kicked = true;
- break;
- }
- }
- }
- }
-
- @Override
- 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()))
- {
- player.sendMessage("You have been kicked from the channel: " + reason);
- quit();
- kicked = true;
- }
- }
-
- public boolean isKicked()
- {
- return kicked;
- }
-
- @Override
- 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(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(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(final String channel, final String topic,
- final String setBy, final long date,
- final boolean changed)
- {
- player.sendMessage(formatChatMessage(channel, topic, false));
- }
-
- public String formatChatMessage(final String nick, final String message, final boolean action)
- {
- final StringBuilder builder = new StringBuilder();
- builder.append("§6");
- if (action)
- {
- builder.append('*');
- }
- builder.append(nick);
- if (!action)
- {
- builder.append(':');
- }
- builder.append(" §7");
- builder.append(replaceColors(message));
- return builder.toString();
- }
-
- private String replaceColors(final String message)
- {
- String m = Colors.removeFormatting(message);
- m = m.replaceAll("\u000310(,(0?[0-9]|1[0-5]))?", "§b");
- m = m.replaceAll("\u000311(,(0?[0-9]|1[0-5]))?", "§f");
- m = m.replaceAll("\u000312(,(0?[0-9]|1[0-5]))?", "§9");
- m = m.replaceAll("\u000313(,(0?[0-9]|1[0-5]))?", "§d");
- m = m.replaceAll("\u000314(,(0?[0-9]|1[0-5]))?", "§8");
- m = m.replaceAll("\u000315(,(0?[0-9]|1[0-5]))?", "§7");
- m = m.replaceAll("\u00030?1(,(0?[0-9]|1[0-5]))?", "§0");
- m = m.replaceAll("\u00030?2(,(0?[0-9]|1[0-5]))?", "§1");
- m = m.replaceAll("\u00030?3(,(0?[0-9]|1[0-5]))?", "§2");
- m = m.replaceAll("\u00030?4(,(0?[0-9]|1[0-5]))?", "§c");
- m = m.replaceAll("\u00030?5(,(0?[0-9]|1[0-5]))?", "§4");
- m = m.replaceAll("\u00030?6(,(0?[0-9]|1[0-5]))?", "§5");
- m = m.replaceAll("\u00030?7(,(0?[0-9]|1[0-5]))?", "§6");
- m = m.replaceAll("\u00030?8(,(0?[0-9]|1[0-5]))?", "§e");
- m = m.replaceAll("\u00030?9(,(0?[0-9]|1[0-5]))?", "§a");
- m = m.replaceAll("\u00030?0(,(0?[0-9]|1[0-5]))?", "§f");
- m = m.replace("\u000f", "§7");
- m = Colors.removeColors(m);
- return m;
- }
-
- public void sendMessage(final String message)
- {
- sendMessage(CHANNEL, message);
- }
-
- public User[] getUsers()
- {
- return getUsers(CHANNEL);
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java
deleted file mode 100644
index 9aa932efa..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ListCommand.java
+++ /dev/null
@@ -1,32 +0,0 @@
-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
deleted file mode 100644
index f244d6e3a..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/StartupCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-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
deleted file mode 100644
index 3df615652..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/UsernameUtil.java
+++ /dev/null
@@ -1,124 +0,0 @@
-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
deleted file mode 100644
index 2c85c39fd..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import org.bukkit.entity.Player;
-
-
-public abstract class AbstractState
-{
- private transient boolean abortion = false;
- private final transient StateMap stateMap;
-
- public AbstractState(final StateMap stateMap)
- {
- this.stateMap = stateMap;
- }
-
- public <T extends AbstractState> T getState(final Class<? extends T> stateClass)
- {
- if (!stateMap.containsKey(stateClass))
- {
- try
- {
- final AbstractState state = stateClass.getConstructor(StateMap.class).newInstance(stateMap);
- stateMap.put(stateClass, state);
- }
- catch (Exception ex)
- {
- /*
- * This should never happen. All states, that are added to the map automatically, have to have a
- * Constructor that accepts the StateMap.
- */
- throw new RuntimeException(ex);
- }
- }
- return (T)stateMap.get(stateClass);
- }
-
- public abstract AbstractState getNextState();
-
- /**
- * Check if we already know the answer, so the user does not have to answer the question.
- *
- * @return true, if the answer could be guessed.
- */
- public boolean guessAnswer()
- {
- return false;
- }
-
- /**
- * Ask the user the question.
- * @param sender
- */
- public abstract void askQuestion(Player sender);
-
- /**
- * React on the answer and set internal variables
- * @param answer
- * @return true, if the answer could be recognized as a valid answer
- */
- public abstract boolean reactOnAnswer(String answer);
-
- public final AbstractState reactOnAnswer(final Player sender, final String answer)
- {
- final String trimmedAnswer = answer.trim();
- if (trimmedAnswer.equalsIgnoreCase("quit")
- || trimmedAnswer.equalsIgnoreCase("bye")
- || trimmedAnswer.equalsIgnoreCase("abort")
- || trimmedAnswer.equalsIgnoreCase("cancel")
- || trimmedAnswer.equalsIgnoreCase("exit"))
- {
- abort();
- return null;
- }
- try
- {
- final boolean found = reactOnAnswer(trimmedAnswer);
- if (found)
- {
- return getNextState();
- }
- else
- {
- sender.sendMessage("Answer not recognized.");
- return this;
- }
- }
- catch (RuntimeException ex)
- {
- sender.sendMessage(ex.toString());
- return this;
- }
- }
-
- /**
- * Do something based on the answer, that the user gave.
- */
- public void doWork(final AbstractWorkListener listener)
- {
- listener.onWorkDone();
- }
-
- public boolean isAbortion()
- {
- return abortion;
- }
-
- protected void abort()
- {
- abortion = true;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractYesNoState.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractYesNoState.java
deleted file mode 100644
index 67baf6bb6..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractYesNoState.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-
-public abstract class AbstractYesNoState extends AbstractState
-{
- private boolean answer = false;
- private final transient Class<? extends AbstractState> yesState;
- private final transient Class<? extends AbstractState> noState;
-
- public AbstractYesNoState(final StateMap states, final Class<? extends AbstractState> nextState)
- {
- this(states, nextState, nextState);
- }
-
- public AbstractYesNoState(final StateMap states, final Class<? extends AbstractState> yesState, final Class<? extends AbstractState> noState)
- {
- super(states);
- this.yesState = yesState;
- this.noState = noState;
- }
-
- @Override
- public AbstractState getNextState()
- {
- return answer
- ? (yesState == null ? null : getState(yesState))
- : (noState == null ? null : getState(noState));
- }
-
- @Override
- public boolean reactOnAnswer(final String answer)
- {
- if (answer.equalsIgnoreCase("yes")
- || answer.equalsIgnoreCase("y"))
- {
- this.answer = true;
- return true;
- }
- if (answer.equalsIgnoreCase("no")
- || answer.equalsIgnoreCase("n"))
- {
- this.answer = false;
- return true;
- }
- return false;
- }
-
- public boolean getAnswer()
- {
- return answer;
- }
-
- protected void setAnswer(final boolean answer)
- {
- this.answer = answer;
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java
deleted file mode 100644
index 88d9efc4a..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import org.bukkit.entity.Player;
-
-
-public class AdvancedMode extends AbstractYesNoState
-{
- public AdvancedMode(final StateMap states)
- {
- super(states, EssentialsChat.class);
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("This installation mode has a lot of options.");
- sender.sendMessage("Do you want use the advanced mode to see all questions?");
- sender.sendMessage("Otherwise the default values will be used.");
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java
deleted file mode 100644
index 10a4f33c5..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/Changelog.java
+++ /dev/null
@@ -1,91 +0,0 @@
-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
deleted file mode 100644
index 6aaed634a..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChat.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.tasks.InstallModule;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-
-public class EssentialsChat extends AbstractYesNoState
-{
- public EssentialsChat(final StateMap states)
- {
- super(states, EssentialsChatSettings.class, EssentialsSpawn.class);
- }
-
- @Override
- public boolean guessAnswer()
- {
- final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsChat");
- if (plugin != null)
- {
- setAnswer(true);
- return true;
- }
- return false;
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("Do you want to install EssentialsChat? (yes/no)");
- sender.sendMessage("EssentialsChat is a simple chat formatting plugin");
- sender.sendMessage("It allows you to make user prefixes and coloured text.");
- }
-
- @Override
- public void doWork(final AbstractWorkListener listener)
- {
- if (getAnswer())
- {
- new InstallModule(listener, "EssentialsChat").start();
- return;
- }
- listener.onWorkDone();
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java
deleted file mode 100644
index 6666ff371..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import org.bukkit.entity.Player;
-
-
-public class EssentialsChatSettings extends AbstractYesNoState
-{
- public EssentialsChatSettings(final StateMap states)
- {
- super(states, EssentialsSpawn.class);
- }
-
- @Override
- public boolean guessAnswer()
- {
- if (getState(AdvancedMode.class).getAnswer())
- {
- setAnswer(false);
- return true;
- }
- return false;
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("Would you like to configure EssentialsChat to prefix ingame messages with their group?");
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java
deleted file mode 100644
index a91a44787..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsGeoIP.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.tasks.InstallModule;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-
-public class EssentialsGeoIP extends AbstractYesNoState
-{
- public EssentialsGeoIP(final StateMap states)
- {
- super(states, null);
- }
-
- @Override
- public boolean guessAnswer()
- {
- final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsGeoIP");
- if (plugin != null)
- {
- setAnswer(true);
- return true;
- }
- return false;
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("Do you want to install EssentialsGeoIP? (yes/no)");
- sender.sendMessage("EssentialsGeoIP performs a IP lookup on joining players");
- sender.sendMessage("It allows you get a rough idea of where a player is from.");
- }
-
- @Override
- public void doWork(final AbstractWorkListener listener)
- {
- if (getAnswer())
- {
- new InstallModule(listener, "EssentialsGeoIP").start();
- return;
- }
- listener.onWorkDone();
- }
-} \ No newline at end of file
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java
deleted file mode 100644
index ca0337d30..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsProtect.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.tasks.InstallModule;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-
-public class EssentialsProtect extends AbstractYesNoState
-{
- public EssentialsProtect(final StateMap states)
- {
- super(states, null);
- }
-
- @Override
- public boolean guessAnswer()
- {
- final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsProtect");
- if (plugin != null)
- {
- setAnswer(true);
- return true;
- }
- return false;
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("Do you want to install EssentialsProtect? (yes/no)");
- sender.sendMessage("EssentialsProtect is a basic world protection system");
- sender.sendMessage("It allows you to set server wide rules, such as disabling creeper explosions, and preventing fire spread.");
- }
-
- @Override
- public void doWork(final AbstractWorkListener listener)
- {
- if (getAnswer())
- {
- new InstallModule(listener, "EssentialsProtect").start();
- return;
- }
- listener.onWorkDone();
- }
-} \ No newline at end of file
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java
deleted file mode 100644
index 2a87638ba..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsSpawn.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.tasks.InstallModule;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-
-public class EssentialsSpawn extends AbstractYesNoState
-{
- public EssentialsSpawn(final StateMap states)
- {
- super(states, null);
- }
-
- @Override
- public boolean guessAnswer()
- {
- final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsSpawn");
- if (plugin != null)
- {
- setAnswer(true);
- return true;
- }
- return false;
- }
-
- @Override
- public void askQuestion(final Player sender)
- {
- sender.sendMessage("Do you want to install EssentialsSpawn? (yes/no)");
- sender.sendMessage("EssentialsSpawn lets you control player spawning");
- sender.sendMessage("It allows you to set different places where players spawn on death, new players join and allows players to return to spawn.");
- }
-
- @Override
- public void doWork(final AbstractWorkListener listener)
- {
- if (getAnswer())
- {
- new InstallModule(listener, "EssentialsSpawn").start();
- return;
- }
- listener.onWorkDone();
- }
-} \ No newline at end of file
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java
deleted file mode 100644
index 82d9ee627..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/InstallationFinishedEvent.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import org.bukkit.event.Event;
-import org.bukkit.event.HandlerList;
-
-
-public class InstallationFinishedEvent extends Event
-{
- public InstallationFinishedEvent()
- {
- super();
- }
-
- @Override
- public HandlerList getHandlers()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
deleted file mode 100644
index 6ce926f92..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.UpdateCheck;
-import java.util.Iterator;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-
-public class StateMachine extends AbstractWorkListener implements Runnable
-{
- public enum MachineResult
- {
- ABORT, WAIT, DONE, NONE
- }
- private final transient StateMap states = new StateMap();
- private transient AbstractState current;
- private transient Player player;
- private transient MachineResult result = MachineResult.NONE;
-
- public StateMachine(final Plugin plugin, final Player player, final UpdateCheck updateCheck)
- {
- super(plugin, updateCheck.getNewVersionInfo());
- this.player = player;
- states.clear();
- final UpdateOrInstallation state = new UpdateOrInstallation(states, updateCheck);
- current = states.put(UpdateOrInstallation.class, state);
- }
-
- public MachineResult askQuestion()
- {
- try
- {
- while (current.guessAnswer())
- {
- 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;
- }
- return result;
- }
-
- public MachineResult reactOnMessage(final String message)
- {
- result = MachineResult.NONE;
- final AbstractState next = current.reactOnAnswer(player, message);
- if (next == null)
- {
- if (current.isAbortion())
- {
- finish();
- result = MachineResult.ABORT;
- }
- else
- {
- result = MachineResult.DONE;
- }
- }
- else
- {
- current = next;
- askQuestion();
- }
- return result;
- }
- private transient Iterator<AbstractState> iterator;
-
- public void startWork()
- {
- iterator = states.values().iterator();
- Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this);
- }
-
- @Override
- public void run()
- {
- if (!iterator.hasNext())
- {
- Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
- {
- @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();
- state.doWork(this);
- }
-
- @Override
- public void onWorkAbort(final String message)
- {
- finish();
- Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
- {
- @Override
- public void run()
- {
- if (message != null && !message.isEmpty() && StateMachine.this.player.isOnline())
- {
- StateMachine.this.player.sendMessage(message);
- }
- }
- });
- }
-
- @Override
- public void onWorkDone(final String message)
- {
- Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
- {
- @Override
- public void run()
- {
- if (message != null && !message.isEmpty() && StateMachine.this.player.isOnline())
- {
- StateMachine.this.player.sendMessage(message);
- }
- 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
deleted file mode 100644
index cca4223d6..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMap.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.earth2me.essentials.update.states;
-
-import java.util.LinkedHashMap;
-
-
-public class StateMap extends LinkedHashMap<Class<? extends AbstractState>, AbstractState>
-{
- public StateMap()
- {
- super(50);
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
deleted file mode 100644
index 6b48f90be..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index 778f5172f..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/InstallModule.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.earth2me.essentials.update.tasks;
-
-import com.earth2me.essentials.update.AbstractWorkListener;
-import com.earth2me.essentials.update.GetFile;
-import com.earth2me.essentials.update.ModuleInfo;
-import com.earth2me.essentials.update.VersionInfo;
-import java.io.File;
-import java.net.URL;
-import java.util.logging.Level;
-import org.bukkit.Bukkit;
-
-
-public class InstallModule implements Runnable, Task
-{
- protected final transient AbstractWorkListener listener;
- private final transient String moduleName;
- private final transient String fileName;
-
- public InstallModule(final AbstractWorkListener listener, final String moduleName)
- {
- this(listener, moduleName, moduleName + ".jar");
- }
-
- public InstallModule(final AbstractWorkListener listener, final String moduleName, final String fileName)
- {
- this.listener = listener;
- this.moduleName = moduleName;
- this.fileName = fileName;
- }
-
- @Override
- public void start()
- {
- Bukkit.getScheduler().scheduleAsyncDelayedTask(listener.getPlugin(), this);
- }
-
- @Override
- public void run()
- {
- final VersionInfo info = listener.getNewVersionInfo();
- final ModuleInfo module = info.getModules().get(moduleName);
- if (module == null)
- {
- listener.onWorkAbort("Module " + moduleName + " not found in VersionInfo.");
- return;
- }
- try
- {
- final URL downloadUrl = module.getUrl();
- final GetFile getFile = new GetFile(downloadUrl);
- getFile.saveTo(new File(listener.getPlugin().getServer().getUpdateFolderFile(), fileName), module.getHash());
- listener.onWorkDone("Module " + moduleName + " downloaded.");
- }
- catch (Exception ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, "Failed to download module " + moduleName + " to " + fileName, ex);
- listener.onWorkAbort("An error occured, please check your server log.");
- return;
- }
- }
-}
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java
deleted file mode 100644
index 3baf86be7..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java
+++ /dev/null
@@ -1,55 +0,0 @@
-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/src/com/earth2me/essentials/update/tasks/Task.java b/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/Task.java
deleted file mode 100644
index 3f1d572ed..000000000
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/Task.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.earth2me.essentials.update.tasks;
-
-
-public interface Task
-{
- void start();
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/Colors.java b/EssentialsUpdate/src/org/jibble/pircbot/Colors.java
deleted file mode 100755
index c763cba22..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/Colors.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-/**
- * The Colors class provides several static fields and methods that you may
- * find useful when writing an IRC Bot.
- * <p>
- * This class contains constants that are useful for formatting lines
- * sent to IRC servers. These constants allow you to apply various
- * formatting to the lines, such as colours, boldness, underlining
- * and reverse text.
- * <p>
- * The class contains static methods to remove colours and formatting
- * from lines of IRC text.
- * <p>
- * Here are some examples of how to use the contants from within a
- * class that extends PircBot and imports org.jibble.pircbot.*;
- *
- * <pre> sendMessage("#cs", Colors.BOLD + "A bold hello!");
- * <b>A bold hello!</b>
- * sendMessage("#cs", Colors.RED + "Red" + Colors.NORMAL + " text");
- * <font color="red">Red</font> text
- * sendMessage("#cs", Colors.BOLD + Colors.RED + "Bold and red");
- * <b><font color="red">Bold and red</font></b></pre>
- *
- * Please note that some IRC channels may be configured to reject any
- * messages that use colours. Also note that older IRC clients may be
- * unable to correctly display lines that contain colours and other
- * control characters.
- * <p>
- * Note that this class name has been spelt in the American style in
- * order to remain consistent with the rest of the Java API.
- *
- *
- * @since 0.9.12
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class Colors {
-
-
- /**
- * Removes all previously applied color and formatting attributes.
- */
- public static final String NORMAL = "\u000f";
-
-
- /**
- * Bold text.
- */
- public static final String BOLD = "\u0002";
-
-
- /**
- * Underlined text.
- */
- public static final String UNDERLINE = "\u001f";
-
-
- /**
- * Reversed text (may be rendered as italic text in some clients).
- */
- public static final String REVERSE = "\u0016";
-
-
- /**
- * White coloured text.
- */
- public static final String WHITE = "\u000300";
-
-
- /**
- * Black coloured text.
- */
- public static final String BLACK = "\u000301";
-
-
- /**
- * Dark blue coloured text.
- */
- public static final String DARK_BLUE = "\u000302";
-
-
- /**
- * Dark green coloured text.
- */
- public static final String DARK_GREEN = "\u000303";
-
-
- /**
- * Red coloured text.
- */
- public static final String RED = "\u000304";
-
-
- /**
- * Brown coloured text.
- */
- public static final String BROWN = "\u000305";
-
-
- /**
- * Purple coloured text.
- */
- public static final String PURPLE = "\u000306";
-
-
- /**
- * Olive coloured text.
- */
- public static final String OLIVE = "\u000307";
-
-
- /**
- * Yellow coloured text.
- */
- public static final String YELLOW = "\u000308";
-
-
- /**
- * Green coloured text.
- */
- public static final String GREEN = "\u000309";
-
-
- /**
- * Teal coloured text.
- */
- public static final String TEAL = "\u000310";
-
-
- /**
- * Cyan coloured text.
- */
- public static final String CYAN = "\u000311";
-
-
- /**
- * Blue coloured text.
- */
- public static final String BLUE = "\u000312";
-
-
- /**
- * Magenta coloured text.
- */
- public static final String MAGENTA = "\u000313";
-
-
- /**
- * Dark gray coloured text.
- */
- public static final String DARK_GRAY = "\u000314";
-
-
- /**
- * Light gray coloured text.
- */
- public static final String LIGHT_GRAY = "\u000315";
-
-
- /**
- * This class should not be constructed.
- */
- private Colors() {
-
- }
-
-
- /**
- * Removes all colours from a line of IRC text.
- *
- * @since PircBot 1.2.0
- *
- * @param line the input text.
- *
- * @return the same text, but with all colours removed.
- */
- public static String removeColors(String line) {
- int length = line.length();
- StringBuffer buffer = new StringBuffer();
- int i = 0;
- while (i < length) {
- char ch = line.charAt(i);
- if (ch == '\u0003') {
- i++;
- // Skip "x" or "xy" (foreground color).
- if (i < length) {
- ch = line.charAt(i);
- if (Character.isDigit(ch)) {
- i++;
- if (i < length) {
- ch = line.charAt(i);
- if (Character.isDigit(ch)) {
- i++;
- }
- }
- // Now skip ",x" or ",xy" (background color).
- if (i < length) {
- ch = line.charAt(i);
- if (ch == ',') {
- i++;
- if (i < length) {
- ch = line.charAt(i);
- if (Character.isDigit(ch)) {
- i++;
- if (i < length) {
- ch = line.charAt(i);
- if (Character.isDigit(ch)) {
- i++;
- }
- }
- }
- else {
- // Keep the comma.
- i--;
- }
- }
- else {
- // Keep the comma.
- i--;
- }
- }
- }
- }
- }
- }
- else if (ch == '\u000f') {
- i++;
- }
- else {
- buffer.append(ch);
- i++;
- }
- }
- return buffer.toString();
- }
-
-
- /**
- * Remove formatting from a line of IRC text.
- *
- * @since PircBot 1.2.0
- *
- * @param line the input text.
- *
- * @return the same text, but without any bold, underlining, reverse, etc.
- */
- public static String removeFormatting(String line) {
- int length = line.length();
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < length; i++) {
- char ch = line.charAt(i);
- if (ch == '\u000f' || ch == '\u0002' || ch == '\u001f' || ch == '\u0016') {
- // Don't add this character.
- }
- else {
- buffer.append(ch);
- }
- }
- return buffer.toString();
- }
-
-
- /**
- * Removes all formatting and colours from a line of IRC text.
- *
- * @since PircBot 1.2.0
- *
- * @param line the input text.
- *
- * @return the same text, but without formatting and colour characters.
- *
- */
- public static String removeFormattingAndColors(String line) {
- return removeFormatting(removeColors(line));
- }
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/InputThread.java b/EssentialsUpdate/src/org/jibble/pircbot/InputThread.java
deleted file mode 100755
index a24815210..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/InputThread.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-import java.io.*;
-import java.net.Socket;
-import java.util.StringTokenizer;
-
-/**
- * A Thread which reads lines from the IRC server. It then
- * passes these lines to the PircBot without changing them.
- * This running Thread also detects disconnection from the server
- * and is thus used by the OutputThread to send lines to the server.
- *
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class InputThread extends Thread {
-
- /**
- * The InputThread reads lines from the IRC server and allows the
- * PircBot to handle them.
- *
- * @param bot An instance of the underlying PircBot.
- * @param breader The BufferedReader that reads lines from the server.
- * @param bwriter The BufferedWriter that sends lines to the server.
- */
- InputThread(PircBot bot, Socket socket, BufferedReader breader, BufferedWriter bwriter) {
- _bot = bot;
- _socket = socket;
- _breader = breader;
- _bwriter = bwriter;
- this.setName(this.getClass() + "-Thread");
- }
-
-
- /**
- * Sends a raw line to the IRC server as soon as possible, bypassing the
- * outgoing message queue.
- *
- * @param line The raw line to send to the IRC server.
- */
- void sendRawLine(String line) {
- OutputThread.sendRawLine(_bot, _bwriter, line);
- }
-
-
- /**
- * Returns true if this InputThread is connected to an IRC server.
- * The result of this method should only act as a rough guide,
- * as the result may not be valid by the time you act upon it.
- *
- * @return True if still connected.
- */
- boolean isConnected() {
- return _isConnected;
- }
-
-
- /**
- * Called to start this Thread reading lines from the IRC server.
- * When a line is read, this method calls the handleLine method
- * in the PircBot, which may subsequently call an 'onXxx' method
- * in the PircBot subclass. If any subclass of Throwable (i.e.
- * any Exception or Error) is thrown by your method, then this
- * method will print the stack trace to the standard output. It
- * is probable that the PircBot may still be functioning normally
- * after such a problem, but the existance of any uncaught exceptions
- * in your code is something you should really fix.
- */
- public void run() {
- try {
- boolean running = true;
- while (running) {
- try {
- String line = null;
- while ((line = _breader.readLine()) != null) {
- try {
- _bot.handleLine(line);
- }
- catch (Throwable t) {
- // Stick the whole stack trace into a String so we can output it nicely.
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- t.printStackTrace(pw);
- pw.flush();
- StringTokenizer tokenizer = new StringTokenizer(sw.toString(), "\r\n");
- synchronized (_bot) {
- _bot.log("### Your implementation of PircBot is faulty and you have");
- _bot.log("### allowed an uncaught Exception or Error to propagate in your");
- _bot.log("### code. It may be possible for PircBot to continue operating");
- _bot.log("### normally. Here is the stack trace that was produced: -");
- _bot.log("### ");
- while (tokenizer.hasMoreTokens()) {
- _bot.log("### " + tokenizer.nextToken());
- }
- }
- }
- }
- if (line == null) {
- // The server must have disconnected us.
- running = false;
- }
- }
- catch (InterruptedIOException iioe) {
- // This will happen if we haven't received anything from the server for a while.
- // So we shall send it a ping to check that we are still connected.
- this.sendRawLine("PING " + (System.currentTimeMillis() / 1000));
- // Now we go back to listening for stuff from the server...
- }
- }
- }
- catch (Exception e) {
- // Do nothing.
- }
-
- // If we reach this point, then we must have disconnected.
- try {
- _socket.close();
- }
- catch (Exception e) {
- // Just assume the socket was already closed.
- }
-
- if (!_disposed) {
- _bot.log("*** Disconnected.");
- _isConnected = false;
- _bot.onDisconnect();
- }
-
- }
-
-
- /**
- * Closes the socket without onDisconnect being called subsequently.
- */
- public void dispose () {
- try {
- _disposed = true;
- _socket.close();
- }
- catch (Exception e) {
- // Do nothing.
- }
- }
-
- private PircBot _bot = null;
- private Socket _socket = null;
- private BufferedReader _breader = null;
- private BufferedWriter _bwriter = null;
- private boolean _isConnected = true;
- private boolean _disposed = false;
-
- public static final int MAX_LINE_LENGTH = 512;
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/IrcException.java b/EssentialsUpdate/src/org/jibble/pircbot/IrcException.java
deleted file mode 100755
index d07d8a956..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/IrcException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-package org.jibble.pircbot;
-
-/**
- * An IrcException class.
- *
- * @since 0.9
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class IrcException extends Exception {
-
- /**
- * Constructs a new IrcException.
- *
- * @param e The error message to report.
- */
- public IrcException(String e) {
- super(e);
- }
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/NickAlreadyInUseException.java b/EssentialsUpdate/src/org/jibble/pircbot/NickAlreadyInUseException.java
deleted file mode 100755
index 33887be34..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/NickAlreadyInUseException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-/**
- * A NickAlreadyInUseException class. This exception is
- * thrown when the PircBot attempts to join an IRC server
- * with a user name that is already in use.
- *
- * @since 0.9
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class NickAlreadyInUseException extends IrcException {
-
- /**
- * Constructs a new IrcException.
- *
- * @param e The error message to report.
- */
- public NickAlreadyInUseException(String e) {
- super(e);
- }
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/OutputThread.java b/EssentialsUpdate/src/org/jibble/pircbot/OutputThread.java
deleted file mode 100755
index 7eddee873..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/OutputThread.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-import java.io.BufferedWriter;
-
-/**
- * A Thread which is responsible for sending messages to the IRC server.
- * Messages are obtained from the outgoing message queue and sent
- * immediately if possible. If there is a flood of messages, then to
- * avoid getting kicked from a channel, we put a small delay between
- * each one.
- *
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class OutputThread extends Thread {
-
-
- /**
- * Constructs an OutputThread for the underlying PircBot. All messages
- * sent to the IRC server are sent by this OutputThread to avoid hammering
- * the server. Messages are sent immediately if possible. If there are
- * multiple messages queued, then there is a delay imposed.
- *
- * @param bot The underlying PircBot instance.
- * @param outQueue The Queue from which we will obtain our messages.
- */
- OutputThread(PircBot bot, Queue outQueue) {
- _bot = bot;
- _outQueue = outQueue;
- this.setName(this.getClass() + "-Thread");
- }
-
-
- /**
- * A static method to write a line to a BufferedOutputStream and then pass
- * the line to the log method of the supplied PircBot instance.
- *
- * @param bot The underlying PircBot instance.
- * @param out The BufferedOutputStream to write to.
- * @param line The line to be written. "\r\n" is appended to the end.
- * @param encoding The charset to use when encoing this string into a
- * byte array.
- */
- static void sendRawLine(PircBot bot, BufferedWriter bwriter, String line) {
- if (line.length() > bot.getMaxLineLength() - 2) {
- line = line.substring(0, bot.getMaxLineLength() - 2);
- }
- synchronized(bwriter) {
- try {
- bwriter.write(line + "\r\n");
- bwriter.flush();
- bot.log(">>>" + line);
- }
- catch (Exception e) {
- // Silent response - just lose the line.
- }
- }
- }
-
-
- /**
- * This method starts the Thread consuming from the outgoing message
- * Queue and sending lines to the server.
- */
- public void run() {
- try {
- boolean running = true;
- while (running) {
- // Small delay to prevent spamming of the channel
- Thread.sleep(_bot.getMessageDelay());
-
- String line = (String) _outQueue.next();
- if (line != null) {
- _bot.sendRawLine(line);
- }
- else {
- running = false;
- }
- }
- }
- catch (InterruptedException e) {
- // Just let the method return naturally...
- }
- }
-
- private PircBot _bot = null;
- private Queue _outQueue = null;
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/PircBot.java b/EssentialsUpdate/src/org/jibble/pircbot/PircBot.java
deleted file mode 100755
index 28148075f..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/PircBot.java
+++ /dev/null
@@ -1,2809 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-import java.io.*;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.*;
-
-/**
- * PircBot is a Java framework for writing IRC bots quickly and easily.
- * <p>
- * It provides an event-driven architecture to handle common IRC
- * events, flood protection, DCC support, ident support, and more.
- * The comprehensive logfile format is suitable for use with pisg to generate
- * channel statistics.
- * <p>
- * Methods of the PircBot class can be called to send events to the IRC server
- * that it connects to. For example, calling the sendMessage method will
- * send a message to a channel or user on the IRC server. Multiple servers
- * can be supported using multiple instances of PircBot.
- * <p>
- * To perform an action when the PircBot receives a normal message from the IRC
- * server, you would override the onMessage method defined in the PircBot
- * class. All on<i>XYZ</i> methods in the PircBot class are automatically called
- * when the event <i>XYZ</i> happens, so you would override these if you wish
- * to do something when it does happen.
- * <p>
- * Some event methods, such as onPing, should only really perform a specific
- * function (i.e. respond to a PING from the server). For your convenience, such
- * methods are already correctly implemented in the PircBot and should not
- * normally need to be overridden. Please read the full documentation for each
- * method to see which ones are already implemented by the PircBot class.
- * <p>
- * Please visit the PircBot homepage at
- * <a href="http://www.jibble.org/pircbot.php">http://www.jibble.org/pircbot.php</a>
- * for full revision history, a beginners guide to creating your first PircBot
- * and a list of some existing Java IRC bots and clients that use the PircBot
- * framework.
- *
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public abstract class PircBot implements ReplyConstants {
-
-
- /**
- * The definitive version number of this release of PircBot.
- * (Note: Change this before automatically building releases)
- */
- public static final String VERSION = "1.5.0";
-
-
- private static final int OP_ADD = 1;
- private static final int OP_REMOVE = 2;
- private static final int VOICE_ADD = 3;
- private static final int VOICE_REMOVE = 4;
-
-
- /**
- * Constructs a PircBot with the default settings. Your own constructors
- * in classes which extend the PircBot abstract class should be responsible
- * for changing the default settings if required.
- */
- public PircBot() {}
-
-
- /**
- * Attempt to connect to the specified IRC server.
- * The onConnect method is called upon success.
- *
- * @param hostname The hostname of the server to connect to.
- *
- * @throws IOException if it was not possible to connect to the server.
- * @throws IrcException if the server would not let us join it.
- * @throws NickAlreadyInUseException if our nick is already in use on the server.
- */
- public final synchronized void connect(String hostname) throws IOException, IrcException, NickAlreadyInUseException {
- this.connect(hostname, 6667, null);
- }
-
-
- /**
- * Attempt to connect to the specified IRC server and port number.
- * The onConnect method is called upon success.
- *
- * @param hostname The hostname of the server to connect to.
- * @param port The port number to connect to on the server.
- *
- * @throws IOException if it was not possible to connect to the server.
- * @throws IrcException if the server would not let us join it.
- * @throws NickAlreadyInUseException if our nick is already in use on the server.
- */
- public final synchronized void connect(String hostname, int port) throws IOException, IrcException, NickAlreadyInUseException {
- this.connect(hostname, port, null);
- }
-
-
- /**
- * Attempt to connect to the specified IRC server using the supplied
- * password.
- * The onConnect method is called upon success.
- *
- * @param hostname The hostname of the server to connect to.
- * @param port The port number to connect to on the server.
- * @param password The password to use to join the server.
- *
- * @throws IOException if it was not possible to connect to the server.
- * @throws IrcException if the server would not let us join it.
- * @throws NickAlreadyInUseException if our nick is already in use on the server.
- */
- public final synchronized void connect(String hostname, int port, String password) throws IOException, IrcException, NickAlreadyInUseException {
-
- _server = hostname;
- _port = port;
- _password = password;
-
- if (isConnected()) {
- throw new IOException("The PircBot is already connected to an IRC server. Disconnect first.");
- }
-
- // Don't clear the outqueue - there might be something important in it!
-
- // Clear everything we may have know about channels.
- this.removeAllChannels();
-
- // Connect to the server.
- Socket socket = new Socket(hostname, port);
- this.log("*** Connected to server.");
-
- _inetAddress = socket.getLocalAddress();
-
- InputStreamReader inputStreamReader = null;
- OutputStreamWriter outputStreamWriter = null;
- if (getEncoding() != null) {
- // Assume the specified encoding is valid for this JVM.
- inputStreamReader = new InputStreamReader(socket.getInputStream(), getEncoding());
- outputStreamWriter = new OutputStreamWriter(socket.getOutputStream(), getEncoding());
- }
- else {
- // Otherwise, just use the JVM's default encoding.
- inputStreamReader = new InputStreamReader(socket.getInputStream());
- outputStreamWriter = new OutputStreamWriter(socket.getOutputStream());
- }
-
- BufferedReader breader = new BufferedReader(inputStreamReader);
- BufferedWriter bwriter = new BufferedWriter(outputStreamWriter);
-
- // Attempt to join the server.
- if (password != null && !password.equals("")) {
- OutputThread.sendRawLine(this, bwriter, "PASS " + password);
- }
- String nick = this.getName();
- OutputThread.sendRawLine(this, bwriter, "NICK " + nick);
- OutputThread.sendRawLine(this, bwriter, "USER " + this.getLogin() + " 8 * :" + this.getVersion());
-
- _inputThread = new InputThread(this, socket, breader, bwriter);
-
- // Read stuff back from the server to see if we connected.
- String line = null;
- int tries = 1;
- while ((line = breader.readLine()) != null) {
-
- this.handleLine(line);
-
- int firstSpace = line.indexOf(" ");
- int secondSpace = line.indexOf(" ", firstSpace + 1);
- if (secondSpace >= 0) {
- String code = line.substring(firstSpace + 1, secondSpace);
-
- if (code.equals("004")) {
- // We're connected to the server.
- break;
- }
- else if (code.equals("433")) {
- if (_autoNickChange) {
- tries++;
- nick = getName() + tries;
- OutputThread.sendRawLine(this, bwriter, "NICK " + nick);
- }
- else {
- socket.close();
- _inputThread = null;
- throw new NickAlreadyInUseException(line);
- }
- }
- else if (code.equals("439")) {
- // No action required.
- }
- else if (code.startsWith("5") || code.startsWith("4")) {
- socket.close();
- _inputThread = null;
- throw new IrcException("Could not log into the IRC server: " + line);
- }
- }
- this.setNick(nick);
-
- }
-
- this.log("*** Logged onto server.");
-
- // This makes the socket timeout on read operations after 5 minutes.
- // Maybe in some future version I will let the user change this at runtime.
- socket.setSoTimeout(5 * 60 * 1000);
-
- // Now start the InputThread to read all other lines from the server.
- _inputThread.start();
-
- // Now start the outputThread that will be used to send all messages.
- if (_outputThread == null) {
- _outputThread = new OutputThread(this, _outQueue);
- _outputThread.start();
- }
-
- this.onConnect();
-
- }
-
-
- /**
- * Reconnects to the IRC server that we were previously connected to.
- * If necessary, the appropriate port number and password will be used.
- * This method will throw an IrcException if we have never connected
- * to an IRC server previously.
- *
- * @since PircBot 0.9.9
- *
- * @throws IOException if it was not possible to connect to the server.
- * @throws IrcException if the server would not let us join it.
- * @throws NickAlreadyInUseException if our nick is already in use on the server.
- */
- public final synchronized void reconnect() throws IOException, IrcException, NickAlreadyInUseException{
- if (getServer() == null) {
- throw new IrcException("Cannot reconnect to an IRC server because we were never connected to one previously!");
- }
- connect(getServer(), getPort(), getPassword());
- }
-
-
- /**
- * This method disconnects from the server cleanly by calling the
- * quitServer() method. Providing the PircBot was connected to an
- * IRC server, the onDisconnect() will be called as soon as the
- * disconnection is made by the server.
- *
- * @see #quitServer() quitServer
- * @see #quitServer(String) quitServer
- */
- public final synchronized void disconnect() {
- this.quitServer();
- }
-
-
- /**
- * When you connect to a server and your nick is already in use and
- * this is set to true, a new nick will be automatically chosen.
- * This is done by adding numbers to the end of the nick until an
- * available nick is found.
- *
- * @param autoNickChange Set to true if you want automatic nick changes
- * during connection.
- */
- public void setAutoNickChange(boolean autoNickChange) {
- _autoNickChange = autoNickChange;
- }
-
- /**
- * Joins a channel.
- *
- * @param channel The name of the channel to join (eg "#cs").
- */
- public final void joinChannel(String channel) {
- this.sendRawLine("JOIN " + channel);
- }
-
-
- /**
- * Joins a channel with a key.
- *
- * @param channel The name of the channel to join (eg "#cs").
- * @param key The key that will be used to join the channel.
- */
- public final void joinChannel(String channel, String key) {
- this.joinChannel(channel + " " + key);
- }
-
-
- /**
- * Parts a channel.
- *
- * @param channel The name of the channel to leave.
- */
- public final void partChannel(String channel) {
- this.sendRawLine("PART " + channel);
- }
-
-
- /**
- * Parts a channel, giving a reason.
- *
- * @param channel The name of the channel to leave.
- * @param reason The reason for parting the channel.
- */
- public final void partChannel(String channel, String reason) {
- this.sendRawLine("PART " + channel + " :" + reason);
- }
-
-
- /**
- * Quits from the IRC server.
- * Providing we are actually connected to an IRC server, the
- * onDisconnect() method will be called as soon as the IRC server
- * disconnects us.
- */
- public final void quitServer() {
- this.quitServer("");
- }
-
-
- /**
- * Quits from the IRC server with a reason.
- * Providing we are actually connected to an IRC server, the
- * onDisconnect() method will be called as soon as the IRC server
- * disconnects us.
- *
- * @param reason The reason for quitting the server.
- */
- public final void quitServer(String reason) {
- this.sendRawLine("QUIT :" + reason);
- }
-
-
- /**
- * Sends a raw line to the IRC server as soon as possible, bypassing the
- * outgoing message queue.
- *
- * @param line The raw line to send to the IRC server.
- */
- public final synchronized void sendRawLine(String line) {
- if (isConnected()) {
- _inputThread.sendRawLine(line);
- }
- }
-
- /**
- * Sends a raw line through the outgoing message queue.
- *
- * @param line The raw line to send to the IRC server.
- */
- public final synchronized void sendRawLineViaQueue(String line) {
- if (line == null) {
- throw new NullPointerException("Cannot send null messages to server");
- }
- if (isConnected()) {
- _outQueue.add(line);
- }
- }
-
-
- /**
- * Sends a message to a channel or a private message to a user. These
- * messages are added to the outgoing message queue and sent at the
- * earliest possible opportunity.
- * <p>
- * Some examples: -
- * <pre> // Send the message "Hello!" to the channel #cs.
- * sendMessage("#cs", "Hello!");
- *
- * // Send a private message to Paul that says "Hi".
- * sendMessage("Paul", "Hi");</pre>
- *
- * You may optionally apply colours, boldness, underlining, etc to
- * the message by using the <code>Colors</code> class.
- *
- * @param target The name of the channel or user nick to send to.
- * @param message The message to send.
- *
- * @see Colors
- */
- public final void sendMessage(String target, String message) {
- _outQueue.add("PRIVMSG " + target + " :" + message);
- }
-
-
- /**
- * Sends an action to the channel or to a user.
- *
- * @param target The name of the channel or user nick to send to.
- * @param action The action to send.
- *
- * @see Colors
- */
- public final void sendAction(String target, String action) {
- sendCTCPCommand(target, "ACTION " + action);
- }
-
-
- /**
- * Sends a notice to the channel or to a user.
- *
- * @param target The name of the channel or user nick to send to.
- * @param notice The notice to send.
- */
- public final void sendNotice(String target, String notice) {
- _outQueue.add("NOTICE " + target + " :" + notice);
- }
-
-
- /**
- * Sends a CTCP command to a channel or user. (Client to client protocol).
- * Examples of such commands are "PING <number>", "FINGER", "VERSION", etc.
- * For example, if you wish to request the version of a user called "Dave",
- * then you would call <code>sendCTCPCommand("Dave", "VERSION");</code>.
- * The type of response to such commands is largely dependant on the target
- * client software.
- *
- * @since PircBot 0.9.5
- *
- * @param target The name of the channel or user to send the CTCP message to.
- * @param command The CTCP command to send.
- */
- public final void sendCTCPCommand(String target, String command) {
- _outQueue.add("PRIVMSG " + target + " :\u0001" + command + "\u0001");
- }
-
-
- /**
- * Attempt to change the current nick (nickname) of the bot when it
- * is connected to an IRC server.
- * After confirmation of a successful nick change, the getNick method
- * will return the new nick.
- *
- * @param newNick The new nick to use.
- */
- public final void changeNick(String newNick) {
- this.sendRawLine("NICK " + newNick);
- }
-
-
- /**
- * Identify the bot with NickServ, supplying the appropriate password.
- * Some IRC Networks (such as freenode) require users to <i>register</i> and
- * <i>identify</i> with NickServ before they are able to send private messages
- * to other users, thus reducing the amount of spam. If you are using
- * an IRC network where this kind of policy is enforced, you will need
- * to make your bot <i>identify</i> itself to NickServ before you can send
- * private messages. Assuming you have already registered your bot's
- * nick with NickServ, this method can be used to <i>identify</i> with
- * the supplied password. It usually makes sense to identify with NickServ
- * immediately after connecting to a server.
- * <p>
- * This method issues a raw NICKSERV command to the server, and is therefore
- * safer than the alternative approach of sending a private message to
- * NickServ. The latter approach is considered dangerous, as it may cause
- * you to inadvertently transmit your password to an untrusted party if you
- * connect to a network which does not run a NickServ service and where the
- * untrusted party has assumed the nick "NickServ". However, if your IRC
- * network is only compatible with the private message approach, you may
- * typically identify like so:
- * <pre>sendMessage("NickServ", "identify PASSWORD");</pre>
- *
- * @param password The password which will be used to identify with NickServ.
- */
- public final void identify(String password) {
- this.sendRawLine("NICKSERV IDENTIFY " + password);
- }
-
-
- /**
- * Set the mode of a channel.
- * This method attempts to set the mode of a channel. This
- * may require the bot to have operator status on the channel.
- * For example, if the bot has operator status, we can grant
- * operator status to "Dave" on the #cs channel
- * by calling setMode("#cs", "+o Dave");
- * An alternative way of doing this would be to use the op method.
- *
- * @param channel The channel on which to perform the mode change.
- * @param mode The new mode to apply to the channel. This may include
- * zero or more arguments if necessary.
- *
- * @see #op(String,String) op
- */
- public final void setMode(String channel, String mode) {
- this.sendRawLine("MODE " + channel + " " + mode);
- }
-
-
- /**
- * Sends an invitation to join a channel. Some channels can be marked
- * as "invite-only", so it may be useful to allow a bot to invite people
- * into it.
- *
- * @param nick The nick of the user to invite
- * @param channel The channel you are inviting the user to join.
- *
- */
- public final void sendInvite(String nick, String channel) {
- this.sendRawLine("INVITE " + nick + " :" + channel);
- }
-
-
- /**
- * Bans a user from a channel. An example of a valid hostmask is
- * "*!*compu@*.18hp.net". This may be used in conjunction with the
- * kick method to permanently remove a user from a channel.
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel to ban the user from.
- * @param hostmask A hostmask representing the user we're banning.
- */
- public final void ban(String channel, String hostmask) {
- this.sendRawLine("MODE " + channel + " +b " + hostmask);
- }
-
-
- /**
- * Unbans a user from a channel. An example of a valid hostmask is
- * "*!*compu@*.18hp.net".
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel to unban the user from.
- * @param hostmask A hostmask representing the user we're unbanning.
- */
- public final void unBan(String channel, String hostmask) {
- this.sendRawLine("MODE " + channel + " -b " + hostmask);
- }
-
-
- /**
- * Grants operator privilidges to a user on a channel.
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel we're opping the user on.
- * @param nick The nick of the user we are opping.
- */
- public final void op(String channel, String nick) {
- this.setMode(channel, "+o " + nick);
- }
-
-
- /**
- * Removes operator privilidges from a user on a channel.
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel we're deopping the user on.
- * @param nick The nick of the user we are deopping.
- */
- public final void deOp(String channel, String nick) {
- this.setMode(channel, "-o " + nick);
- }
-
-
- /**
- * Grants voice privilidges to a user on a channel.
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel we're voicing the user on.
- * @param nick The nick of the user we are voicing.
- */
- public final void voice(String channel, String nick) {
- this.setMode(channel, "+v " + nick);
- }
-
-
- /**
- * Removes voice privilidges from a user on a channel.
- * Successful use of this method may require the bot to have operator
- * status itself.
- *
- * @param channel The channel we're devoicing the user on.
- * @param nick The nick of the user we are devoicing.
- */
- public final void deVoice(String channel, String nick) {
- this.setMode(channel, "-v " + nick);
- }
-
-
- /**
- * Set the topic for a channel.
- * This method attempts to set the topic of a channel. This
- * may require the bot to have operator status if the topic
- * is protected.
- *
- * @param channel The channel on which to perform the mode change.
- * @param topic The new topic for the channel.
- *
- */
- public final void setTopic(String channel, String topic) {
- this.sendRawLine("TOPIC " + channel + " :" + topic);
- }
-
-
- /**
- * Kicks a user from a channel.
- * This method attempts to kick a user from a channel and
- * may require the bot to have operator status in the channel.
- *
- * @param channel The channel to kick the user from.
- * @param nick The nick of the user to kick.
- */
- public final void kick(String channel, String nick) {
- this.kick(channel, nick, "");
- }
-
-
- /**
- * Kicks a user from a channel, giving a reason.
- * This method attempts to kick a user from a channel and
- * may require the bot to have operator status in the channel.
- *
- * @param channel The channel to kick the user from.
- * @param nick The nick of the user to kick.
- * @param reason A description of the reason for kicking a user.
- */
- public final void kick(String channel, String nick, String reason) {
- this.sendRawLine("KICK " + channel + " " + nick + " :" + reason);
- }
-
-
- /**
- * Issues a request for a list of all channels on the IRC server.
- * When the PircBot receives information for each channel, it will
- * call the onChannelInfo method, which you will need to override
- * if you want it to do anything useful.
- *
- * @see #onChannelInfo(String,int,String) onChannelInfo
- */
- public final void listChannels() {
- this.listChannels(null);
- }
-
-
- /**
- * Issues a request for a list of all channels on the IRC server.
- * When the PircBot receives information for each channel, it will
- * call the onChannelInfo method, which you will need to override
- * if you want it to do anything useful.
- * <p>
- * Some IRC servers support certain parameters for LIST requests.
- * One example is a parameter of ">10" to list only those channels
- * that have more than 10 users in them. Whether these parameters
- * are supported or not will depend on the IRC server software.
- *
- * @param parameters The parameters to supply when requesting the
- * list.
- *
- * @see #onChannelInfo(String,int,String) onChannelInfo
- */
- public final void listChannels(String parameters) {
- if (parameters == null) {
- this.sendRawLine("LIST");
- }
- else {
- this.sendRawLine("LIST " + parameters);
- }
- }
-
- /**
- * Adds a line to the log. This log is currently output to the standard
- * output and is in the correct format for use by tools such as pisg, the
- * Perl IRC Statistics Generator. You may override this method if you wish
- * to do something else with log entries.
- * Each line in the log begins with a number which
- * represents the logging time (as the number of milliseconds since the
- * epoch). This timestamp and the following log entry are separated by
- * a single space character, " ". Outgoing messages are distinguishable
- * by a log entry that has ">>>" immediately following the space character
- * after the timestamp. DCC events use "+++" and warnings about unhandled
- * Exceptions and Errors use "###".
- * <p>
- * This implementation of the method will only cause log entries to be
- * output if the PircBot has had its verbose mode turned on by calling
- * setVerbose(true);
- *
- * @param line The line to add to the log.
- */
- public void log(String line) {
- if (_verbose) {
- System.out.println(System.currentTimeMillis() + " " + line);
- }
- }
-
-
- /**
- * This method handles events when any line of text arrives from the server,
- * then calling the appropriate method in the PircBot. This method is
- * protected and only called by the InputThread for this instance.
- * <p>
- * This method may not be overridden!
- *
- * @param line The raw line of text from the server.
- */
- protected void handleLine(String line) {
- this.log(line);
-
- // Check for server pings.
- if (line.startsWith("PING ")) {
- // Respond to the ping and return immediately.
- this.onServerPing(line.substring(5));
- return;
- }
-
- String sourceNick = "";
- String sourceLogin = "";
- String sourceHostname = "";
-
- StringTokenizer tokenizer = new StringTokenizer(line);
- String senderInfo = tokenizer.nextToken();
- String command = tokenizer.nextToken();
- String target = null;
-
- int exclamation = senderInfo.indexOf("!");
- int at = senderInfo.indexOf("@");
- if (senderInfo.startsWith(":")) {
- if (exclamation > 0 && at > 0 && exclamation < at) {
- sourceNick = senderInfo.substring(1, exclamation);
- sourceLogin = senderInfo.substring(exclamation + 1, at);
- sourceHostname = senderInfo.substring(at + 1);
- }
- else {
-
- if (tokenizer.hasMoreTokens()) {
- String token = command;
-
- int code = -1;
- try {
- code = Integer.parseInt(token);
- }
- catch (NumberFormatException e) {
- // Keep the existing value.
- }
-
- if (code != -1) {
- String errorStr = token;
- String response = line.substring(line.indexOf(errorStr, senderInfo.length()) + 4, line.length());
- this.processServerResponse(code, response);
- // Return from the method.
- return;
- }
- else {
- // This is not a server response.
- // It must be a nick without login and hostname.
- // (or maybe a NOTICE or suchlike from the server)
- sourceNick = senderInfo;
- target = token;
- }
- }
- else {
- // We don't know what this line means.
- this.onUnknown(line);
- // Return from the method;
- return;
- }
-
- }
- }
-
- command = command.toUpperCase(Locale.ENGLISH);
- if (sourceNick.startsWith(":")) {
- sourceNick = sourceNick.substring(1);
- }
- if (target == null) {
- target = tokenizer.nextToken();
- }
- if (target.startsWith(":")) {
- target = target.substring(1);
- }
-
- // Check for CTCP requests.
- if (command.equals("PRIVMSG") && line.indexOf(":\u0001") > 0 && line.endsWith("\u0001")) {
- String request = line.substring(line.indexOf(":\u0001") + 2, line.length() - 1);
- if (request.equals("VERSION")) {
- // VERSION request
- this.onVersion(sourceNick, sourceLogin, sourceHostname, target);
- }
- else if (request.startsWith("ACTION ")) {
- // ACTION request
- this.onAction(sourceNick, sourceLogin, sourceHostname, target, request.substring(7));
- }
- else if (request.startsWith("PING ")) {
- // PING request
- this.onPing(sourceNick, sourceLogin, sourceHostname, target, request.substring(5));
- }
- else if (request.equals("TIME")) {
- // TIME request
- this.onTime(sourceNick, sourceLogin, sourceHostname, target);
- }
- else if (request.equals("FINGER")) {
- // FINGER request
- this.onFinger(sourceNick, sourceLogin, sourceHostname, target);
- }
- else {
- // An unknown CTCP message - ignore it.
- this.onUnknown(line);
- }
- }
- else if (command.equals("PRIVMSG") && _channelPrefixes.indexOf(target.charAt(0)) >= 0) {
- // This is a normal message to a channel.
- this.onMessage(target, sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
- }
- else if (command.equals("PRIVMSG")) {
- // This is a private message to us.
- this.onPrivateMessage(sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
- }
- else if (command.equals("JOIN")) {
- // Someone is joining a channel.
- String channel = target;
- this.addUser(channel, new User("", sourceNick));
- this.onJoin(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else if (command.equals("PART")) {
- // Someone is parting from a channel.
- this.removeUser(target, sourceNick);
- if (sourceNick.equals(this.getNick())) {
- this.removeChannel(target);
- }
- this.onPart(target, sourceNick, sourceLogin, sourceHostname);
- }
- else if (command.equals("NICK")) {
- // Somebody is changing their nick.
- String newNick = target;
- this.renameUser(sourceNick, newNick);
- if (sourceNick.equals(this.getNick())) {
- // Update our nick if it was us that changed nick.
- this.setNick(newNick);
- }
- this.onNickChange(sourceNick, sourceLogin, sourceHostname, newNick);
- }
- else if (command.equals("NOTICE")) {
- // Someone is sending a notice.
- this.onNotice(sourceNick, sourceLogin, sourceHostname, target, line.substring(line.indexOf(" :") + 2));
- }
- else if (command.equals("QUIT")) {
- // Someone has quit from the IRC server.
- if (sourceNick.equals(this.getNick())) {
- this.removeAllChannels();
- }
- else {
- this.removeUser(sourceNick);
- }
- this.onQuit(sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
- }
- else if (command.equals("KICK")) {
- // Somebody has been kicked from a channel.
- String recipient = tokenizer.nextToken();
- if (recipient.equals(this.getNick())) {
- this.removeChannel(target);
- }
- this.removeUser(target, recipient);
- this.onKick(target, sourceNick, sourceLogin, sourceHostname, recipient, line.substring(line.indexOf(" :") + 2));
- }
- else if (command.equals("MODE")) {
- // Somebody is changing the mode on a channel or user.
- String mode = line.substring(line.indexOf(target, 2) + target.length() + 1);
- if (mode.startsWith(":")) {
- mode = mode.substring(1);
- }
- this.processMode(target, sourceNick, sourceLogin, sourceHostname, mode);
- }
- else if (command.equals("TOPIC")) {
- // Someone is changing the topic.
- this.onTopic(target, line.substring(line.indexOf(" :") + 2), sourceNick, System.currentTimeMillis(), true);
- }
- else if (command.equals("INVITE")) {
- // Somebody is inviting somebody else into a channel.
- this.onInvite(target, sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
- }
- else {
- // If we reach this point, then we've found something that the PircBot
- // Doesn't currently deal with.
- this.onUnknown(line);
- }
-
- }
-
-
- /**
- * This method is called once the PircBot has successfully connected to
- * the IRC server.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.6
- */
- protected void onConnect() {}
-
-
- /**
- * This method carries out the actions to be performed when the PircBot
- * gets disconnected. This may happen if the PircBot quits from the
- * server, or if the connection is unexpectedly lost.
- * <p>
- * Disconnection from the IRC server is detected immediately if either
- * we or the server close the connection normally. If the connection to
- * the server is lost, but neither we nor the server have explicitly closed
- * the connection, then it may take a few minutes to detect (this is
- * commonly referred to as a "ping timeout").
- * <p>
- * If you wish to get your IRC bot to automatically rejoin a server after
- * the connection has been lost, then this is probably the ideal method to
- * override to implement such functionality.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- */
- protected void onDisconnect() {}
-
-
- /**
- * This method is called by the PircBot when a numeric response
- * is received from the IRC server. We use this method to
- * allow PircBot to process various responses from the server
- * before then passing them on to the onServerResponse method.
- * <p>
- * Note that this method is private and should not appear in any
- * of the javadoc generated documenation.
- *
- * @param code The three-digit numerical code for the response.
- * @param response The full response from the IRC server.
- */
- private final void processServerResponse(int code, String response) {
-
- if (code == RPL_LIST) {
- // This is a bit of information about a channel.
- int firstSpace = response.indexOf(' ');
- int secondSpace = response.indexOf(' ', firstSpace + 1);
- int thirdSpace = response.indexOf(' ', secondSpace + 1);
- int colon = response.indexOf(':');
- String channel = response.substring(firstSpace + 1, secondSpace);
- int userCount = 0;
- try {
- userCount = Integer.parseInt(response.substring(secondSpace + 1, thirdSpace));
- }
- catch (NumberFormatException e) {
- // Stick with the value of zero.
- }
- String topic = response.substring(colon + 1);
- this.onChannelInfo(channel, userCount, topic);
- }
- else if (code == RPL_TOPIC) {
- // This is topic information about a channel we've just joined.
- int firstSpace = response.indexOf(' ');
- int secondSpace = response.indexOf(' ', firstSpace + 1);
- int colon = response.indexOf(':');
- String channel = response.substring(firstSpace + 1, secondSpace);
- String topic = response.substring(colon + 1);
-
- _topics.put(channel, topic);
-
- // For backwards compatibility only - this onTopic method is deprecated.
- this.onTopic(channel, topic);
- }
- else if (code == RPL_TOPICINFO) {
- StringTokenizer tokenizer = new StringTokenizer(response);
- tokenizer.nextToken();
- String channel = tokenizer.nextToken();
- String setBy = tokenizer.nextToken();
- long date = 0;
- try {
- date = Long.parseLong(tokenizer.nextToken()) * 1000;
- }
- catch (NumberFormatException e) {
- // Stick with the default value of zero.
- }
-
- String topic = (String) _topics.get(channel);
- _topics.remove(channel);
-
- this.onTopic(channel, topic, setBy, date, false);
- }
- else if (code == RPL_NAMREPLY) {
- // This is a list of nicks in a channel that we've just joined.
- int channelEndIndex = response.indexOf(" :");
- String channel = response.substring(response.lastIndexOf(' ', channelEndIndex - 1) + 1, channelEndIndex);
-
- StringTokenizer tokenizer = new StringTokenizer(response.substring(response.indexOf(" :") + 2));
- while (tokenizer.hasMoreTokens()) {
- String nick = tokenizer.nextToken();
- String prefix = "";
- if (nick.startsWith("@")) {
- // User is an operator in this channel.
- prefix = "@";
- }
- else if (nick.startsWith("+")) {
- // User is voiced in this channel.
- prefix = "+";
- }
- else if (nick.startsWith(".")) {
- // Some wibbly status I've never seen before...
- prefix = ".";
- }
- nick = nick.substring(prefix.length());
- this.addUser(channel, new User(prefix, nick));
- }
- }
- else if (code == RPL_ENDOFNAMES) {
- // This is the end of a NAMES list, so we know that we've got
- // the full list of users in the channel that we just joined.
- String channel = response.substring(response.indexOf(' ') + 1, response.indexOf(" :"));
- User[] users = this.getUsers(channel);
- this.onUserList(channel, users);
- }
-
- this.onServerResponse(code, response);
- }
-
-
- /**
- * This method is called when we receive a numeric response from the
- * IRC server.
- * <p>
- * Numerics in the range from 001 to 099 are used for client-server
- * connections only and should never travel between servers. Replies
- * generated in response to commands are found in the range from 200
- * to 399. Error replies are found in the range from 400 to 599.
- * <p>
- * For example, we can use this method to discover the topic of a
- * channel when we join it. If we join the channel #test which
- * has a topic of &quot;I am King of Test&quot; then the response
- * will be &quot;<code>PircBot #test :I Am King of Test</code>&quot;
- * with a code of 332 to signify that this is a topic.
- * (This is just an example - note that overriding the
- * <code>onTopic</code> method is an easier way of finding the
- * topic for a channel). Check the IRC RFC for the full list of other
- * command response codes.
- * <p>
- * PircBot implements the interface ReplyConstants, which contains
- * contstants that you may find useful here.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param code The three-digit numerical code for the response.
- * @param response The full response from the IRC server.
- *
- * @see ReplyConstants
- */
- protected void onServerResponse(int code, String response) {}
-
-
- /**
- * This method is called when we receive a user list from the server
- * after joining a channel.
- * <p>
- * Shortly after joining a channel, the IRC server sends a list of all
- * users in that channel. The PircBot collects this information and
- * calls this method as soon as it has the full list.
- * <p>
- * To obtain the nick of each user in the channel, call the getNick()
- * method on each User object in the array.
- * <p>
- * At a later time, you may call the getUsers method to obtain an
- * up to date list of the users in the channel.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 1.0.0
- *
- * @param channel The name of the channel.
- * @param users An array of User objects belonging to this channel.
- *
- * @see User
- */
- protected void onUserList(String channel, User[] users) {}
-
-
- /**
- * This method is called whenever a message is sent to a channel.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel to which the message was sent.
- * @param sender The nick of the person who sent the message.
- * @param login The login of the person who sent the message.
- * @param hostname The hostname of the person who sent the message.
- * @param message The actual message sent to the channel.
- */
- protected void onMessage(String channel, String sender, String login, String hostname, String message) {}
-
-
- /**
- * This method is called whenever a private message is sent to the PircBot.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param sender The nick of the person who sent the private message.
- * @param login The login of the person who sent the private message.
- * @param hostname The hostname of the person who sent the private message.
- * @param message The actual message.
- */
- protected void onPrivateMessage(String sender, String login, String hostname, String message) {}
-
-
- /**
- * This method is called whenever an ACTION is sent from a user. E.g.
- * such events generated by typing "/me goes shopping" in most IRC clients.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param sender The nick of the user that sent the action.
- * @param login The login of the user that sent the action.
- * @param hostname The hostname of the user that sent the action.
- * @param target The target of the action, be it a channel or our nick.
- * @param action The action carried out by the user.
- */
- protected void onAction(String sender, String login, String hostname, String target, String action) {}
-
-
- /**
- * This method is called whenever we receive a notice.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param sourceNick The nick of the user that sent the notice.
- * @param sourceLogin The login of the user that sent the notice.
- * @param sourceHostname The hostname of the user that sent the notice.
- * @param target The target of the notice, be it our nick or a channel name.
- * @param notice The notice message.
- */
- protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) {}
-
-
- /**
- * This method is called whenever someone (possibly us) joins a channel
- * which we are on.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel which somebody joined.
- * @param sender The nick of the user who joined the channel.
- * @param login The login of the user who joined the channel.
- * @param hostname The hostname of the user who joined the channel.
- */
- protected void onJoin(String channel, String sender, String login, String hostname) {}
-
-
- /**
- * This method is called whenever someone (possibly us) parts a channel
- * which we are on.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel which somebody parted from.
- * @param sender The nick of the user who parted from the channel.
- * @param login The login of the user who parted from the channel.
- * @param hostname The hostname of the user who parted from the channel.
- */
- protected void onPart(String channel, String sender, String login, String hostname) {}
-
-
- /**
- * This method is called whenever someone (possibly us) changes nick on any
- * of the channels that we are on.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param oldNick The old nick.
- * @param login The login of the user.
- * @param hostname The hostname of the user.
- * @param newNick The new nick.
- */
- protected void onNickChange(String oldNick, String login, String hostname, String newNick) {}
-
-
- /**
- * This method is called whenever someone (possibly us) is kicked from
- * any of the channels that we are in.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel from which the recipient was kicked.
- * @param kickerNick The nick of the user who performed the kick.
- * @param kickerLogin The login of the user who performed the kick.
- * @param kickerHostname The hostname of the user who performed the kick.
- * @param recipientNick The unfortunate recipient of the kick.
- * @param reason The reason given by the user who performed the kick.
- */
- protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) {}
-
-
- /**
- * This method is called whenever someone (possibly us) quits from the
- * server. We will only observe this if the user was in one of the
- * channels to which we are connected.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param sourceNick The nick of the user that quit from the server.
- * @param sourceLogin The login of the user that quit from the server.
- * @param sourceHostname The hostname of the user that quit from the server.
- * @param reason The reason given for quitting the server.
- */
- protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) {}
-
-
- /**
- * This method is called whenever a user sets the topic, or when
- * PircBot joins a new channel and discovers its topic.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel that the topic belongs to.
- * @param topic The topic for the channel.
- *
- * @deprecated As of 1.2.0, replaced by {@link #onTopic(String,String,String,long,boolean)}
- */
- protected void onTopic(String channel, String topic) {}
-
-
- /**
- * This method is called whenever a user sets the topic, or when
- * PircBot joins a new channel and discovers its topic.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel that the topic belongs to.
- * @param topic The topic for the channel.
- * @param setBy The nick of the user that set the topic.
- * @param date When the topic was set (milliseconds since the epoch).
- * @param changed True if the topic has just been changed, false if
- * the topic was already there.
- *
- */
- protected void onTopic(String channel, String topic, String setBy, long date, boolean changed) {}
-
-
- /**
- * After calling the listChannels() method in PircBot, the server
- * will start to send us information about each channel on the
- * server. You may override this method in order to receive the
- * information about each channel as soon as it is received.
- * <p>
- * Note that certain channels, such as those marked as hidden,
- * may not appear in channel listings.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The name of the channel.
- * @param userCount The number of users visible in this channel.
- * @param topic The topic for this channel.
- *
- * @see #listChannels() listChannels
- */
- protected void onChannelInfo(String channel, int userCount, String topic) {}
-
-
- /**
- * Called when the mode of a channel is set. We process this in
- * order to call the appropriate onOp, onDeop, etc method before
- * finally calling the override-able onMode method.
- * <p>
- * Note that this method is private and is not intended to appear
- * in the javadoc generated documentation.
- *
- * @param target The channel or nick that the mode operation applies to.
- * @param sourceNick The nick of the user that set the mode.
- * @param sourceLogin The login of the user that set the mode.
- * @param sourceHostname The hostname of the user that set the mode.
- * @param mode The mode that has been set.
- */
- private final void processMode(String target, String sourceNick, String sourceLogin, String sourceHostname, String mode) {
-
- if (_channelPrefixes.indexOf(target.charAt(0)) >= 0) {
- // The mode of a channel is being changed.
- String channel = target;
- StringTokenizer tok = new StringTokenizer(mode);
- String[] params = new String[tok.countTokens()];
-
- int t = 0;
- while (tok.hasMoreTokens()) {
- params[t] = tok.nextToken();
- t++;
- }
-
- char pn = ' ';
- int p = 1;
-
- // All of this is very large and ugly, but it's the only way of providing
- // what the users want :-/
- for (int i = 0; i < params[0].length(); i++) {
- char atPos = params[0].charAt(i);
-
- if (atPos == '+' || atPos == '-') {
- pn = atPos;
- }
- else if (atPos == 'o') {
- if (pn == '+') {
- this.updateUser(channel, OP_ADD, params[p]);
- onOp(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- else {
- this.updateUser(channel, OP_REMOVE, params[p]);
- onDeop(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- p++;
- }
- else if (atPos == 'v') {
- if (pn == '+') {
- this.updateUser(channel, VOICE_ADD, params[p]);
- onVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- else {
- this.updateUser(channel, VOICE_REMOVE, params[p]);
- onDeVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- p++;
- }
- else if (atPos == 'k') {
- if (pn == '+') {
- onSetChannelKey(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- else {
- onRemoveChannelKey(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- p++;
- }
- else if (atPos == 'l') {
- if (pn == '+') {
- onSetChannelLimit(channel, sourceNick, sourceLogin, sourceHostname, Integer.parseInt(params[p]));
- p++;
- }
- else {
- onRemoveChannelLimit(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 'b') {
- if (pn == '+') {
- onSetChannelBan(channel, sourceNick, sourceLogin, sourceHostname,params[p]);
- }
- else {
- onRemoveChannelBan(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
- }
- p++;
- }
- else if (atPos == 't') {
- if (pn == '+') {
- onSetTopicProtection(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemoveTopicProtection(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 'n') {
- if (pn == '+') {
- onSetNoExternalMessages(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemoveNoExternalMessages(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 'i') {
- if (pn == '+') {
- onSetInviteOnly(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemoveInviteOnly(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 'm') {
- if (pn == '+') {
- onSetModerated(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemoveModerated(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 'p') {
- if (pn == '+') {
- onSetPrivate(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemovePrivate(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- else if (atPos == 's') {
- if (pn == '+') {
- onSetSecret(channel, sourceNick, sourceLogin, sourceHostname);
- }
- else {
- onRemoveSecret(channel, sourceNick, sourceLogin, sourceHostname);
- }
- }
- }
-
- this.onMode(channel, sourceNick, sourceLogin, sourceHostname, mode);
- }
- else {
- // The mode of a user is being changed.
- String nick = target;
- this.onUserMode(nick, sourceNick, sourceLogin, sourceHostname, mode);
- }
- }
-
-
- /**
- * Called when the mode of a channel is set.
- * <p>
- * You may find it more convenient to decode the meaning of the mode
- * string by overriding the onOp, onDeOp, onVoice, onDeVoice,
- * onChannelKey, onDeChannelKey, onChannelLimit, onDeChannelLimit,
- * onChannelBan or onDeChannelBan methods as appropriate.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param channel The channel that the mode operation applies to.
- * @param sourceNick The nick of the user that set the mode.
- * @param sourceLogin The login of the user that set the mode.
- * @param sourceHostname The hostname of the user that set the mode.
- * @param mode The mode that has been set.
- *
- */
- protected void onMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String mode) {}
-
-
- /**
- * Called when the mode of a user is set.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 1.2.0
- *
- * @param targetNick The nick that the mode operation applies to.
- * @param sourceNick The nick of the user that set the mode.
- * @param sourceLogin The login of the user that set the mode.
- * @param sourceHostname The hostname of the user that set the mode.
- * @param mode The mode that has been set.
- *
- */
- protected void onUserMode(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String mode) {}
-
-
-
- /**
- * Called when a user (possibly us) gets granted operator status for a channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param recipient The nick of the user that got 'opped'.
- */
- protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) {}
-
-
- /**
- * Called when a user (possibly us) gets operator status taken away.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param recipient The nick of the user that got 'deopped'.
- */
- protected void onDeop(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) {}
-
-
- /**
- * Called when a user (possibly us) gets voice status granted in a channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param recipient The nick of the user that got 'voiced'.
- */
- protected void onVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) {}
-
-
- /**
- * Called when a user (possibly us) gets voice status removed.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param recipient The nick of the user that got 'devoiced'.
- */
- protected void onDeVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) {}
-
-
- /**
- * Called when a channel key is set. When the channel key has been set,
- * other users may only join that channel if they know the key. Channel keys
- * are sometimes referred to as passwords.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param key The new key for the channel.
- */
- protected void onSetChannelKey(String channel, String sourceNick, String sourceLogin, String sourceHostname, String key) {}
-
-
- /**
- * Called when a channel key is removed.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param key The key that was in use before the channel key was removed.
- */
- protected void onRemoveChannelKey(String channel, String sourceNick, String sourceLogin, String sourceHostname, String key) {}
-
-
- /**
- * Called when a user limit is set for a channel. The number of users in
- * the channel cannot exceed this limit.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param limit The maximum number of users that may be in this channel at the same time.
- */
- protected void onSetChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname, int limit) {}
-
-
- /**
- * Called when the user limit is removed for a channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a user (possibly us) gets banned from a channel. Being
- * banned from a channel prevents any user with a matching hostmask from
- * joining the channel. For this reason, most bans are usually directly
- * followed by the user being kicked :-)
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param hostmask The hostmask of the user that has been banned.
- */
- protected void onSetChannelBan(String channel, String sourceNick, String sourceLogin, String sourceHostname, String hostmask) {}
-
-
- /**
- * Called when a hostmask ban is removed from a channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- * @param hostmask
- */
- protected void onRemoveChannelBan(String channel, String sourceNick, String sourceLogin, String sourceHostname, String hostmask) {}
-
-
- /**
- * Called when topic protection is enabled for a channel. Topic protection
- * means that only operators in a channel may change the topic.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetTopicProtection(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when topic protection is removed for a channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveTopicProtection(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is set to only allow messages from users that
- * are in the channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetNoExternalMessages(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is set to allow messages from any user, even
- * if they are not actually in the channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveNoExternalMessages(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is set to 'invite only' mode. A user may only
- * join the channel if they are invited by someone who is already in the
- * channel.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetInviteOnly(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel has 'invite only' removed.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveInviteOnly(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is set to 'moderated' mode. If a channel is
- * moderated, then only users who have been 'voiced' or 'opped' may speak
- * or change their nicks.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetModerated(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel has moderated mode removed.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveModerated(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is marked as being in private mode.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetPrivate(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is marked as not being in private mode.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemovePrivate(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel is set to be in 'secret' mode. Such channels
- * typically do not appear on a server's channel listing.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onSetSecret(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when a channel has 'secret' mode removed.
- * <p>
- * This is a type of mode change and is also passed to the onMode
- * method in the PircBot class.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param channel The channel in which the mode change took place.
- * @param sourceNick The nick of the user that performed the mode change.
- * @param sourceLogin The login of the user that performed the mode change.
- * @param sourceHostname The hostname of the user that performed the mode change.
- */
- protected void onRemoveSecret(String channel, String sourceNick, String sourceLogin, String sourceHostname) {}
-
-
- /**
- * Called when we are invited to a channel by a user.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @since PircBot 0.9.5
- *
- * @param targetNick The nick of the user being invited - should be us!
- * @param sourceNick The nick of the user that sent the invitation.
- * @param sourceLogin The login of the user that sent the invitation.
- * @param sourceHostname The hostname of the user that sent the invitation.
- * @param channel The channel that we're being invited to.
- */
- protected void onInvite(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String channel) {}
-
-
- /**
- * This method used to be called when a DCC SEND request was sent to the PircBot.
- * Please use the onIncomingFileTransfer method to receive files, as it
- * has better functionality and supports resuming.
- *
- * @deprecated As of PircBot 1.2.0, use {@link #onIncomingFileTransfer(DccFileTransfer)}
- */
- protected void onDccSendRequest(String sourceNick, String sourceLogin, String sourceHostname, String filename, long address, int port, int size) {}
-
-
- /**
- * This method used to be called when a DCC CHAT request was sent to the PircBot.
- * Please use the onIncomingChatRequest method to accept chats, as it
- * has better functionality.
- *
- * @deprecated As of PircBot 1.2.0, use {@link #onIncomingChatRequest(DccChat)}
- */
- protected void onDccChatRequest(String sourceNick, String sourceLogin, String sourceHostname, long address, int port) {}
-
-
- /**
- * This method is called whenever we receive a VERSION request.
- * This abstract implementation responds with the PircBot's _version string,
- * so if you override this method, be sure to either mimic its functionality
- * or to call super.onVersion(...);
- *
- * @param sourceNick The nick of the user that sent the VERSION request.
- * @param sourceLogin The login of the user that sent the VERSION request.
- * @param sourceHostname The hostname of the user that sent the VERSION request.
- * @param target The target of the VERSION request, be it our nick or a channel name.
- */
- protected void onVersion(String sourceNick, String sourceLogin, String sourceHostname, String target) {
- this.sendRawLine("NOTICE " + sourceNick + " :\u0001VERSION " + _version + "\u0001");
- }
-
-
- /**
- * This method is called whenever we receive a PING request from another
- * user.
- * <p>
- * This abstract implementation responds correctly, so if you override this
- * method, be sure to either mimic its functionality or to call
- * super.onPing(...);
- *
- * @param sourceNick The nick of the user that sent the PING request.
- * @param sourceLogin The login of the user that sent the PING request.
- * @param sourceHostname The hostname of the user that sent the PING request.
- * @param target The target of the PING request, be it our nick or a channel name.
- * @param pingValue The value that was supplied as an argument to the PING command.
- */
- protected void onPing(String sourceNick, String sourceLogin, String sourceHostname, String target, String pingValue) {
- this.sendRawLine("NOTICE " + sourceNick + " :\u0001PING " + pingValue + "\u0001");
- }
-
-
- /**
- * The actions to perform when a PING request comes from the server.
- * <p>
- * This sends back a correct response, so if you override this method,
- * be sure to either mimic its functionality or to call
- * super.onServerPing(response);
- *
- * @param response The response that should be given back in your PONG.
- */
- protected void onServerPing(String response) {
- this.sendRawLine("PONG " + response);
- }
-
-
- /**
- * This method is called whenever we receive a TIME request.
- * <p>
- * This abstract implementation responds correctly, so if you override this
- * method, be sure to either mimic its functionality or to call
- * super.onTime(...);
- *
- * @param sourceNick The nick of the user that sent the TIME request.
- * @param sourceLogin The login of the user that sent the TIME request.
- * @param sourceHostname The hostname of the user that sent the TIME request.
- * @param target The target of the TIME request, be it our nick or a channel name.
- */
- protected void onTime(String sourceNick, String sourceLogin, String sourceHostname, String target) {
- this.sendRawLine("NOTICE " + sourceNick + " :\u0001TIME " + new Date().toString() + "\u0001");
- }
-
-
- /**
- * This method is called whenever we receive a FINGER request.
- * <p>
- * This abstract implementation responds correctly, so if you override this
- * method, be sure to either mimic its functionality or to call
- * super.onFinger(...);
- *
- * @param sourceNick The nick of the user that sent the FINGER request.
- * @param sourceLogin The login of the user that sent the FINGER request.
- * @param sourceHostname The hostname of the user that sent the FINGER request.
- * @param target The target of the FINGER request, be it our nick or a channel name.
- */
- protected void onFinger(String sourceNick, String sourceLogin, String sourceHostname, String target) {
- this.sendRawLine("NOTICE " + sourceNick + " :\u0001FINGER " + _finger + "\u0001");
- }
-
-
- /**
- * This method is called whenever we receive a line from the server that
- * the PircBot has not been programmed to recognise.
- * <p>
- * The implementation of this method in the PircBot abstract class
- * performs no actions and may be overridden as required.
- *
- * @param line The raw line that was received from the server.
- */
- protected void onUnknown(String line) {
- // And then there were none :)
- }
-
-
- /**
- * Sets the verbose mode. If verbose mode is set to true, then log entries
- * will be printed to the standard output. The default value is false and
- * will result in no output. For general development, we strongly recommend
- * setting the verbose mode to true.
- *
- * @param verbose true if verbose mode is to be used. Default is false.
- */
- public final void setVerbose(boolean verbose) {
- _verbose = verbose;
- }
-
-
- /**
- * Sets the name of the bot, which will be used as its nick when it
- * tries to join an IRC server. This should be set before joining
- * any servers, otherwise the default nick will be used. You would
- * typically call this method from the constructor of the class that
- * extends PircBot.
- * <p>
- * The changeNick method should be used if you wish to change your nick
- * when you are connected to a server.
- *
- * @param name The new name of the Bot.
- */
- protected final void setName(String name) {
- _name = name;
- }
-
-
- /**
- * Sets the internal nick of the bot. This is only to be called by the
- * PircBot class in response to notification of nick changes that apply
- * to us.
- *
- * @param nick The new nick.
- */
- private final void setNick(String nick) {
- _nick = nick;
- }
-
-
- /**
- * Sets the internal login of the Bot. This should be set before joining
- * any servers.
- *
- * @param login The new login of the Bot.
- */
- protected final void setLogin(String login) {
- _login = login;
- }
-
-
- /**
- * Sets the internal version of the Bot. This should be set before joining
- * any servers.
- *
- * @param version The new version of the Bot.
- */
- protected final void setVersion(String version) {
- _version = version;
- }
-
-
- /**
- * Sets the interal finger message. This should be set before joining
- * any servers.
- *
- * @param finger The new finger message for the Bot.
- */
- protected final void setFinger(String finger) {
- _finger = finger;
- }
-
-
- /**
- * Gets the name of the PircBot. This is the name that will be used as
- * as a nick when we try to join servers.
- *
- * @return The name of the PircBot.
- */
- public final String getName() {
- return _name;
- }
-
-
- /**
- * Returns the current nick of the bot. Note that if you have just changed
- * your nick, this method will still return the old nick until confirmation
- * of the nick change is received from the server.
- * <p>
- * The nick returned by this method is maintained only by the PircBot
- * class and is guaranteed to be correct in the context of the IRC server.
- *
- * @since PircBot 1.0.0
- *
- * @return The current nick of the bot.
- */
- public String getNick() {
- return _nick;
- }
-
-
- /**
- * Gets the internal login of the PircBot.
- *
- * @return The login of the PircBot.
- */
- public final String getLogin() {
- return _login;
- }
-
-
- /**
- * Gets the internal version of the PircBot.
- *
- * @return The version of the PircBot.
- */
- public final String getVersion() {
- return _version;
- }
-
-
- /**
- * Gets the internal finger message of the PircBot.
- *
- * @return The finger message of the PircBot.
- */
- public final String getFinger() {
- return _finger;
- }
-
-
- /**
- * Returns whether or not the PircBot is currently connected to a server.
- * The result of this method should only act as a rough guide,
- * as the result may not be valid by the time you act upon it.
- *
- * @return True if and only if the PircBot is currently connected to a server.
- */
- public final synchronized boolean isConnected() {
- return _inputThread != null && _inputThread.isConnected();
- }
-
-
- /**
- * Sets the number of milliseconds to delay between consecutive
- * messages when there are multiple messages waiting in the
- * outgoing message queue. This has a default value of 1000ms.
- * It is a good idea to stick to this default value, as it will
- * prevent your bot from spamming servers and facing the subsequent
- * wrath! However, if you do need to change this delay value (<b>not
- * recommended</b>), then this is the method to use.
- *
- * @param delay The number of milliseconds between each outgoing message.
- *
- */
- public final void setMessageDelay(long delay) {
- if (delay < 0) {
- throw new IllegalArgumentException("Cannot have a negative time.");
- }
- _messageDelay = delay;
- }
-
-
- /**
- * Returns the number of milliseconds that will be used to separate
- * consecutive messages to the server from the outgoing message queue.
- *
- * @return Number of milliseconds.
- */
- public final long getMessageDelay() {
- return _messageDelay;
- }
-
-
- /**
- * Gets the maximum length of any line that is sent via the IRC protocol.
- * The IRC RFC specifies that line lengths, including the trailing \r\n
- * must not exceed 512 bytes. Hence, there is currently no option to
- * change this value in PircBot. All lines greater than this length
- * will be truncated before being sent to the IRC server.
- *
- * @return The maximum line length (currently fixed at 512)
- */
- public final int getMaxLineLength() {
- return InputThread.MAX_LINE_LENGTH;
- }
-
-
- /**
- * Gets the number of lines currently waiting in the outgoing message Queue.
- * If this returns 0, then the Queue is empty and any new message is likely
- * to be sent to the IRC server immediately.
- *
- * @since PircBot 0.9.9
- *
- * @return The number of lines in the outgoing message Queue.
- */
- public final int getOutgoingQueueSize() {
- return _outQueue.size();
- }
-
-
- /**
- * Returns the name of the last IRC server the PircBot tried to connect to.
- * This does not imply that the connection attempt to the server was
- * successful (we suggest you look at the onConnect method).
- * A value of null is returned if the PircBot has never tried to connect
- * to a server.
- *
- * @return The name of the last machine we tried to connect to. Returns
- * null if no connection attempts have ever been made.
- */
- public final String getServer() {
- return _server;
- }
-
-
- /**
- * Returns the port number of the last IRC server that the PircBot tried
- * to connect to.
- * This does not imply that the connection attempt to the server was
- * successful (we suggest you look at the onConnect method).
- * A value of -1 is returned if the PircBot has never tried to connect
- * to a server.
- *
- * @since PircBot 0.9.9
- *
- * @return The port number of the last IRC server we connected to.
- * Returns -1 if no connection attempts have ever been made.
- */
- public final int getPort() {
- return _port;
- }
-
-
- /**
- * Returns the last password that we used when connecting to an IRC server.
- * This does not imply that the connection attempt to the server was
- * successful (we suggest you look at the onConnect method).
- * A value of null is returned if the PircBot has never tried to connect
- * to a server using a password.
- *
- * @since PircBot 0.9.9
- *
- * @return The last password that we used when connecting to an IRC server.
- * Returns null if we have not previously connected using a password.
- */
- public final String getPassword() {
- return _password;
- }
-
-
- /**
- * A convenient method that accepts an IP address represented as a
- * long and returns an integer array of size 4 representing the same
- * IP address.
- *
- * @since PircBot 0.9.4
- *
- * @param address the long value representing the IP address.
- *
- * @return An int[] of size 4.
- */
- public int[] longToIp(long address) {
- int[] ip = new int[4];
- for (int i = 3; i >= 0; i--) {
- ip[i] = (int) (address % 256);
- address = address / 256;
- }
- return ip;
- }
-
-
- /**
- * A convenient method that accepts an IP address represented by a byte[]
- * of size 4 and returns this as a long representation of the same IP
- * address.
- *
- * @since PircBot 0.9.4
- *
- * @param address the byte[] of size 4 representing the IP address.
- *
- * @return a long representation of the IP address.
- */
- public long ipToLong(byte[] address) {
- if (address.length != 4) {
- throw new IllegalArgumentException("byte array must be of length 4");
- }
- long ipNum = 0;
- long multiplier = 1;
- for (int i = 3; i >= 0; i--) {
- int byteVal = (address[i] + 256) % 256;
- ipNum += byteVal*multiplier;
- multiplier *= 256;
- }
- return ipNum;
- }
-
-
- /**
- * Sets the encoding charset to be used when sending or receiving lines
- * from the IRC server. If set to null, then the platform's default
- * charset is used. You should only use this method if you are
- * trying to send text to an IRC server in a different charset, e.g.
- * "GB2312" for Chinese encoding. If a PircBot is currently connected
- * to a server, then it must reconnect before this change takes effect.
- *
- * @since PircBot 1.0.4
- *
- * @param charset The new encoding charset to be used by PircBot.
- *
- * @throws UnsupportedEncodingException If the named charset is not
- * supported.
- */
- public void setEncoding(String charset) throws UnsupportedEncodingException {
- // Just try to see if the charset is supported first...
- "".getBytes(charset);
-
- _charset = charset;
- }
-
-
- /**
- * Returns the encoding used to send and receive lines from
- * the IRC server, or null if not set. Use the setEncoding
- * method to change the encoding charset.
- *
- * @since PircBot 1.0.4
- *
- * @return The encoding used to send outgoing messages, or
- * null if not set.
- */
- public String getEncoding() {
- return _charset;
- }
-
- /**
- * Returns the InetAddress used by the PircBot.
- * This can be used to find the I.P. address from which the PircBot is
- * connected to a server.
- *
- * @since PircBot 1.4.4
- *
- * @return The current local InetAddress, or null if never connected.
- */
- public InetAddress getInetAddress() {
- return _inetAddress;
- }
-
-
- /**
- * Sets the InetAddress to be used when sending DCC chat or file transfers.
- * This can be very useful when you are running a bot on a machine which
- * is behind a firewall and you need to tell receiving clients to connect
- * to a NAT/router, which then forwards the connection.
- *
- * @since PircBot 1.4.4
- *
- * @param dccInetAddress The new InetAddress, or null to use the default.
- */
- public void setDccInetAddress(InetAddress dccInetAddress) {
- _dccInetAddress = dccInetAddress;
- }
-
-
- /**
- * Returns the InetAddress used when sending DCC chat or file transfers.
- * If this is null, the default InetAddress will be used.
- *
- * @since PircBot 1.4.4
- *
- * @return The current DCC InetAddress, or null if left as default.
- */
- public InetAddress getDccInetAddress() {
- return _dccInetAddress;
- }
-
-
- /**
- * Returns the set of port numbers to be used when sending a DCC chat
- * or file transfer. This is useful when you are behind a firewall and
- * need to set up port forwarding. The array of port numbers is traversed
- * in sequence until a free port is found to listen on. A DCC tranfer will
- * fail if all ports are already in use.
- * If set to null, <i>any</i> free port number will be used.
- *
- * @since PircBot 1.4.4
- *
- * @return An array of port numbers that PircBot can use to send DCC
- * transfers, or null if any port is allowed.
- */
- public int[] getDccPorts() {
- if (_dccPorts == null || _dccPorts.length == 0) {
- return null;
- }
- // Clone the array to prevent external modification.
- return (int[]) _dccPorts.clone();
- }
-
-
- /**
- * Sets the choice of port numbers that can be used when sending a DCC chat
- * or file transfer. This is useful when you are behind a firewall and
- * need to set up port forwarding. The array of port numbers is traversed
- * in sequence until a free port is found to listen on. A DCC tranfer will
- * fail if all ports are already in use.
- * If set to null, <i>any</i> free port number will be used.
- *
- * @since PircBot 1.4.4
- *
- * @param ports The set of port numbers that PircBot may use for DCC
- * transfers, or null to let it use any free port (default).
- *
- */
- public void setDccPorts(int[] ports) {
- if (ports == null || ports.length == 0) {
- _dccPorts = null;
- }
- else {
- // Clone the array to prevent external modification.
- _dccPorts = (int[]) ports.clone();
- }
- }
-
-
- /**
- * Returns true if and only if the object being compared is the exact
- * same instance as this PircBot. This may be useful if you are writing
- * a multiple server IRC bot that uses more than one instance of PircBot.
- *
- * @since PircBot 0.9.9
- *
- * @return true if and only if Object o is a PircBot and equal to this.
- */
- public boolean equals(Object o) {
- // This probably has the same effect as Object.equals, but that may change...
- if (o instanceof PircBot) {
- PircBot other = (PircBot) o;
- return other == this;
- }
- return false;
- }
-
-
- /**
- * Returns the hashCode of this PircBot. This method can be called by hashed
- * collection classes and is useful for managing multiple instances of
- * PircBots in such collections.
- *
- * @since PircBot 0.9.9
- *
- * @return the hash code for this instance of PircBot.
- */
- public int hashCode() {
- return super.hashCode();
- }
-
-
- /**
- * Returns a String representation of this object.
- * You may find this useful for debugging purposes, particularly
- * if you are using more than one PircBot instance to achieve
- * multiple server connectivity. The format of
- * this String may change between different versions of PircBot
- * but is currently something of the form
- * <code>
- * Version{PircBot x.y.z Java IRC Bot - www.jibble.org}
- * Connected{true}
- * Server{irc.dal.net}
- * Port{6667}
- * Password{}
- * </code>
- *
- * @since PircBot 0.9.10
- *
- * @return a String representation of this object.
- */
- public String toString() {
- return "Version{" + _version + "}" +
- " Connected{" + isConnected() + "}" +
- " Server{" + _server + "}" +
- " Port{" + _port + "}" +
- " Password{" + _password + "}";
- }
-
-
- /**
- * Returns an array of all users in the specified channel.
- * <p>
- * There are some important things to note about this method:-
- * <ul>
- * <li>This method may not return a full list of users if you call it
- * before the complete nick list has arrived from the IRC server.
- * </li>
- * <li>If you wish to find out which users are in a channel as soon
- * as you join it, then you should override the onUserList method
- * instead of calling this method, as the onUserList method is only
- * called as soon as the full user list has been received.
- * </li>
- * <li>This method will return immediately, as it does not require any
- * interaction with the IRC server.
- * </li>
- * <li>The bot must be in a channel to be able to know which users are
- * in it.
- * </li>
- * </ul>
- *
- * @since PircBot 1.0.0
- *
- * @param channel The name of the channel to list.
- *
- * @return An array of User objects. This array is empty if we are not
- * in the channel.
- *
- * @see #onUserList(String,User[]) onUserList
- */
- public final User[] getUsers(String channel) {
- channel = channel.toLowerCase(Locale.ENGLISH);
- User[] userArray = new User[0];
- synchronized (_channels) {
- Hashtable users = (Hashtable) _channels.get(channel);
- if (users != null) {
- userArray = new User[users.size()];
- Enumeration enumeration = users.elements();
- for (int i = 0; i < userArray.length; i++) {
- User user = (User) enumeration.nextElement();
- userArray[i] = user;
- }
- }
- }
- return userArray;
- }
-
-
- /**
- * Returns an array of all channels that we are in. Note that if you
- * call this method immediately after joining a new channel, the new
- * channel may not appear in this array as it is not possible to tell
- * if the join was successful until a response is received from the
- * IRC server.
- *
- * @since PircBot 1.0.0
- *
- * @return A String array containing the names of all channels that we
- * are in.
- */
- public final String[] getChannels() {
- String[] channels = new String[0];
- synchronized (_channels) {
- channels = new String[_channels.size()];
- Enumeration enumeration = _channels.keys();
- for (int i = 0; i < channels.length; i++) {
- channels[i] = (String) enumeration.nextElement();
- }
- }
- return channels;
- }
-
-
- /**
- * Disposes of all thread resources used by this PircBot. This may be
- * useful when writing bots or clients that use multiple servers (and
- * therefore multiple PircBot instances) or when integrating a PircBot
- * with an existing program.
- * <p>
- * Each PircBot runs its own threads for dispatching messages from its
- * outgoing message queue and receiving messages from the server.
- * Calling dispose() ensures that these threads are
- * stopped, thus freeing up system resources and allowing the PircBot
- * object to be garbage collected if there are no other references to
- * it.
- * <p>
- * Once a PircBot object has been disposed, it should not be used again.
- * Attempting to use a PircBot that has been disposed may result in
- * unpredictable behaviour.
- *
- * @since 1.2.2
- */
- public synchronized void dispose() {
- //System.out.println("disposing...");
- _outputThread.interrupt();
- _inputThread.dispose();
- }
-
-
- /**
- * Add a user to the specified channel in our memory.
- * Overwrite the existing entry if it exists.
- */
- private final void addUser(String channel, User user) {
- channel = channel.toLowerCase(Locale.ENGLISH);
- synchronized (_channels) {
- Hashtable users = (Hashtable) _channels.get(channel);
- if (users == null) {
- users = new Hashtable();
- _channels.put(channel, users);
- }
- users.put(user, user);
- }
- }
-
-
- /**
- * Remove a user from the specified channel in our memory.
- */
- private final User removeUser(String channel, String nick) {
- channel = channel.toLowerCase(Locale.ENGLISH);
- User user = new User("", nick);
- synchronized (_channels) {
- Hashtable users = (Hashtable) _channels.get(channel);
- if (users != null) {
- return (User) users.remove(user);
- }
- }
- return null;
- }
-
-
- /**
- * Remove a user from all channels in our memory.
- */
- private final void removeUser(String nick) {
- synchronized (_channels) {
- Enumeration enumeration = _channels.keys();
- while (enumeration.hasMoreElements()) {
- String channel = (String) enumeration.nextElement();
- this.removeUser(channel, nick);
- }
- }
- }
-
-
- /**
- * Rename a user if they appear in any of the channels we know about.
- */
- private final void renameUser(String oldNick, String newNick) {
- synchronized (_channels) {
- Enumeration enumeration = _channels.keys();
- while (enumeration.hasMoreElements()) {
- String channel = (String) enumeration.nextElement();
- User user = this.removeUser(channel, oldNick);
- if (user != null) {
- user = new User(user.getPrefix(), newNick);
- this.addUser(channel, user);
- }
- }
- }
- }
-
-
- /**
- * Removes an entire channel from our memory of users.
- */
- private final void removeChannel(String channel) {
- channel = channel.toLowerCase(Locale.ENGLISH);
- synchronized (_channels) {
- _channels.remove(channel);
- }
- }
-
-
- /**
- * Removes all channels from our memory of users.
- */
- private final void removeAllChannels() {
- synchronized(_channels) {
- _channels = new Hashtable();
- }
- }
-
-
- private final void updateUser(String channel, int userMode, String nick) {
- channel = channel.toLowerCase(Locale.ENGLISH);
- synchronized (_channels) {
- Hashtable users = (Hashtable) _channels.get(channel);
- User newUser = null;
- if (users != null) {
- Enumeration enumeration = users.elements();
- while(enumeration.hasMoreElements()) {
- User userObj = (User) enumeration.nextElement();
- if (userObj.getNick().equalsIgnoreCase(nick)) {
- if (userMode == OP_ADD) {
- if (userObj.hasVoice()) {
- newUser = new User("@+", nick);
- }
- else {
- newUser = new User("@", nick);
- }
- }
- else if (userMode == OP_REMOVE) {
- if(userObj.hasVoice()) {
- newUser = new User("+", nick);
- }
- else {
- newUser = new User("", nick);
- }
- }
- else if (userMode == VOICE_ADD) {
- if(userObj.isOp()) {
- newUser = new User("@+", nick);
- }
- else {
- newUser = new User("+", nick);
- }
- }
- else if (userMode == VOICE_REMOVE) {
- if(userObj.isOp()) {
- newUser = new User("@", nick);
- }
- else {
- newUser = new User("", nick);
- }
- }
- }
- }
- }
- if (newUser != null) {
- users.put(newUser, newUser);
- }
- else {
- // just in case ...
- newUser = new User("", nick);
- users.put(newUser, newUser);
- }
- }
- }
-
-
- // Connection stuff.
- private InputThread _inputThread = null;
- private OutputThread _outputThread = null;
- private String _charset = null;
- private InetAddress _inetAddress = null;
-
- // Details about the last server that we connected to.
- private String _server = null;
- private int _port = -1;
- private String _password = null;
-
- // Outgoing message stuff.
- private Queue _outQueue = new Queue();
- private long _messageDelay = 1000;
-
- // A Hashtable of channels that points to a selfreferential Hashtable of
- // User objects (used to remember which users are in which channels).
- private Hashtable _channels = new Hashtable();
-
- // A Hashtable to temporarily store channel topics when we join them
- // until we find out who set that topic.
- private Hashtable _topics = new Hashtable();
-
- private int[] _dccPorts = null;
- private InetAddress _dccInetAddress = null;
-
- // Default settings for the PircBot.
- private boolean _autoNickChange = false;
- private boolean _verbose = false;
- private String _name = "PircBot";
- private String _nick = _name;
- private String _login = "PircBot";
- private String _version = "PircBot " + VERSION + " Java IRC Bot - www.jibble.org";
- private String _finger = "You ought to be arrested for fingering a bot!";
-
- private String _channelPrefixes = "#&+!";
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/Queue.java b/EssentialsUpdate/src/org/jibble/pircbot/Queue.java
deleted file mode 100755
index fd8d47781..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/Queue.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-import java.util.Vector;
-
-/**
- * Queue is a definition of a data structure that may
- * act as a queue - that is, data can be added to one end of the
- * queue and data can be requested from the head end of the queue.
- * This class is thread safe for multiple producers and a single
- * consumer. The next() method will block until there is data in
- * the queue.
- *
- * This has now been modified so that it is compatible with
- * the earlier JDK1.1 in order to be suitable for running on
- * mobile appliances. This means replacing the LinkedList with
- * a Vector, which is hardly ideal, but this Queue is typically
- * only polled every second before dispatching messages.
- *
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class Queue {
-
-
- /**
- * Constructs a Queue object of unlimited size.
- */
- public Queue() {
-
- }
-
-
- /**
- * Adds an Object to the end of the Queue.
- *
- * @param o The Object to be added to the Queue.
- */
- public void add(Object o) {
- synchronized(_queue) {
- _queue.addElement(o);
- _queue.notify();
- }
- }
-
-
- /**
- * Adds an Object to the front of the Queue.
- *
- * @param o The Object to be added to the Queue.
- */
- public void addFront(Object o) {
- synchronized(_queue) {
- _queue.insertElementAt(o, 0);
- _queue.notify();
- }
- }
-
-
- /**
- * Returns the Object at the front of the Queue. This
- * Object is then removed from the Queue. If the Queue
- * is empty, then this method shall block until there
- * is an Object in the Queue to return.
- *
- * @return The next item from the front of the queue.
- */
- public Object next() {
-
- Object o = null;
-
- // Block if the Queue is empty.
- synchronized(_queue) {
- if (_queue.size() == 0) {
- try {
- _queue.wait();
- }
- catch (InterruptedException e) {
- return null;
- }
- }
-
- // Return the Object.
- try {
- o = _queue.firstElement();
- _queue.removeElementAt(0);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- throw new InternalError("Race hazard in Queue object.");
- }
- }
-
- return o;
- }
-
-
- /**
- * Returns true if the Queue is not empty. If another
- * Thread empties the Queue before <b>next()</b> is
- * called, then the call to <b>next()</b> shall block
- * until the Queue has been populated again.
- *
- * @return True only if the Queue not empty.
- */
- public boolean hasNext() {
- return (this.size() != 0);
- }
-
-
- /**
- * Clears the contents of the Queue.
- */
- public void clear() {
- synchronized(_queue) {
- _queue.removeAllElements();
- }
- }
-
-
- /**
- * Returns the size of the Queue.
- *
- * @return The current size of the queue.
- */
- public int size() {
- return _queue.size();
- }
-
-
- private Vector _queue = new Vector();
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/ReplyConstants.java b/EssentialsUpdate/src/org/jibble/pircbot/ReplyConstants.java
deleted file mode 100755
index 2d8e696d5..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/ReplyConstants.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-
-package org.jibble.pircbot;
-
-/**
- * This interface contains the values of all numeric replies specified
- * in section 6 of RFC 1459. Refer to RFC 1459 for further information.
- * <p>
- * If you override the onServerResponse method in the PircBot class,
- * you may find these constants useful when comparing the numeric
- * value of a given code.
- *
- * @since 1.0.0
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public interface ReplyConstants {
-
-
- // Error Replies.
- public static final int ERR_NOSUCHNICK = 401;
- public static final int ERR_NOSUCHSERVER = 402;
- public static final int ERR_NOSUCHCHANNEL = 403;
- public static final int ERR_CANNOTSENDTOCHAN = 404;
- public static final int ERR_TOOMANYCHANNELS = 405;
- public static final int ERR_WASNOSUCHNICK = 406;
- public static final int ERR_TOOMANYTARGETS = 407;
- public static final int ERR_NOORIGIN = 409;
- public static final int ERR_NORECIPIENT = 411;
- public static final int ERR_NOTEXTTOSEND = 412;
- public static final int ERR_NOTOPLEVEL = 413;
- public static final int ERR_WILDTOPLEVEL = 414;
- public static final int ERR_UNKNOWNCOMMAND = 421;
- public static final int ERR_NOMOTD = 422;
- public static final int ERR_NOADMININFO = 423;
- public static final int ERR_FILEERROR = 424;
- public static final int ERR_NONICKNAMEGIVEN = 431;
- public static final int ERR_ERRONEUSNICKNAME = 432;
- public static final int ERR_NICKNAMEINUSE = 433;
- public static final int ERR_NICKCOLLISION = 436;
- public static final int ERR_USERNOTINCHANNEL = 441;
- public static final int ERR_NOTONCHANNEL = 442;
- public static final int ERR_USERONCHANNEL = 443;
- public static final int ERR_NOLOGIN = 444;
- public static final int ERR_SUMMONDISABLED = 445;
- public static final int ERR_USERSDISABLED = 446;
- public static final int ERR_NOTREGISTERED = 451;
- public static final int ERR_NEEDMOREPARAMS = 461;
- public static final int ERR_ALREADYREGISTRED = 462;
- public static final int ERR_NOPERMFORHOST = 463;
- public static final int ERR_PASSWDMISMATCH = 464;
- public static final int ERR_YOUREBANNEDCREEP = 465;
- public static final int ERR_KEYSET = 467;
- public static final int ERR_CHANNELISFULL = 471;
- public static final int ERR_UNKNOWNMODE = 472;
- public static final int ERR_INVITEONLYCHAN = 473;
- public static final int ERR_BANNEDFROMCHAN = 474;
- public static final int ERR_BADCHANNELKEY = 475;
- public static final int ERR_NOPRIVILEGES = 481;
- public static final int ERR_CHANOPRIVSNEEDED = 482;
- public static final int ERR_CANTKILLSERVER = 483;
- public static final int ERR_NOOPERHOST = 491;
- public static final int ERR_UMODEUNKNOWNFLAG = 501;
- public static final int ERR_USERSDONTMATCH = 502;
-
-
- // Command Responses.
- public static final int RPL_TRACELINK = 200;
- public static final int RPL_TRACECONNECTING = 201;
- public static final int RPL_TRACEHANDSHAKE = 202;
- public static final int RPL_TRACEUNKNOWN = 203;
- public static final int RPL_TRACEOPERATOR = 204;
- public static final int RPL_TRACEUSER = 205;
- public static final int RPL_TRACESERVER = 206;
- public static final int RPL_TRACENEWTYPE = 208;
- public static final int RPL_STATSLINKINFO = 211;
- public static final int RPL_STATSCOMMANDS = 212;
- public static final int RPL_STATSCLINE = 213;
- public static final int RPL_STATSNLINE = 214;
- public static final int RPL_STATSILINE = 215;
- public static final int RPL_STATSKLINE = 216;
- public static final int RPL_STATSYLINE = 218;
- public static final int RPL_ENDOFSTATS = 219;
- public static final int RPL_UMODEIS = 221;
- public static final int RPL_STATSLLINE = 241;
- public static final int RPL_STATSUPTIME = 242;
- public static final int RPL_STATSOLINE = 243;
- public static final int RPL_STATSHLINE = 244;
- public static final int RPL_LUSERCLIENT = 251;
- public static final int RPL_LUSEROP = 252;
- public static final int RPL_LUSERUNKNOWN = 253;
- public static final int RPL_LUSERCHANNELS = 254;
- public static final int RPL_LUSERME = 255;
- public static final int RPL_ADMINME = 256;
- public static final int RPL_ADMINLOC1 = 257;
- public static final int RPL_ADMINLOC2 = 258;
- public static final int RPL_ADMINEMAIL = 259;
- public static final int RPL_TRACELOG = 261;
- public static final int RPL_NONE = 300;
- public static final int RPL_AWAY = 301;
- public static final int RPL_USERHOST = 302;
- public static final int RPL_ISON = 303;
- public static final int RPL_UNAWAY = 305;
- public static final int RPL_NOWAWAY = 306;
- public static final int RPL_WHOISUSER = 311;
- public static final int RPL_WHOISSERVER = 312;
- public static final int RPL_WHOISOPERATOR = 313;
- public static final int RPL_WHOWASUSER = 314;
- public static final int RPL_ENDOFWHO = 315;
- public static final int RPL_WHOISIDLE = 317;
- public static final int RPL_ENDOFWHOIS = 318;
- public static final int RPL_WHOISCHANNELS = 319;
- public static final int RPL_LISTSTART = 321;
- public static final int RPL_LIST = 322;
- public static final int RPL_LISTEND = 323;
- public static final int RPL_CHANNELMODEIS = 324;
- public static final int RPL_NOTOPIC = 331;
- public static final int RPL_TOPIC = 332;
- public static final int RPL_TOPICINFO = 333;
- public static final int RPL_INVITING = 341;
- public static final int RPL_SUMMONING = 342;
- public static final int RPL_VERSION = 351;
- public static final int RPL_WHOREPLY = 352;
- public static final int RPL_NAMREPLY = 353;
- public static final int RPL_LINKS = 364;
- public static final int RPL_ENDOFLINKS = 365;
- public static final int RPL_ENDOFNAMES = 366;
- public static final int RPL_BANLIST = 367;
- public static final int RPL_ENDOFBANLIST = 368;
- public static final int RPL_ENDOFWHOWAS = 369;
- public static final int RPL_INFO = 371;
- public static final int RPL_MOTD = 372;
- public static final int RPL_ENDOFINFO = 374;
- public static final int RPL_MOTDSTART = 375;
- public static final int RPL_ENDOFMOTD = 376;
- public static final int RPL_YOUREOPER = 381;
- public static final int RPL_REHASHING = 382;
- public static final int RPL_TIME = 391;
- public static final int RPL_USERSSTART = 392;
- public static final int RPL_USERS = 393;
- public static final int RPL_ENDOFUSERS = 394;
- public static final int RPL_NOUSERS = 395;
-
-
- // Reserved Numerics.
- public static final int RPL_TRACECLASS = 209;
- public static final int RPL_STATSQLINE = 217;
- public static final int RPL_SERVICEINFO = 231;
- public static final int RPL_ENDOFSERVICES = 232;
- public static final int RPL_SERVICE = 233;
- public static final int RPL_SERVLIST = 234;
- public static final int RPL_SERVLISTEND = 235;
- public static final int RPL_WHOISCHANOP = 316;
- public static final int RPL_KILLDONE = 361;
- public static final int RPL_CLOSING = 362;
- public static final int RPL_CLOSEEND = 363;
- public static final int RPL_INFOSTART = 373;
- public static final int RPL_MYPORTIS = 384;
- public static final int ERR_YOUWILLBEBANNED = 466;
- public static final int ERR_BADCHANMASK = 476;
- public static final int ERR_NOSERVICEHOST = 492;
-
-}
diff --git a/EssentialsUpdate/src/org/jibble/pircbot/User.java b/EssentialsUpdate/src/org/jibble/pircbot/User.java
deleted file mode 100755
index 37f981b19..000000000
--- a/EssentialsUpdate/src/org/jibble/pircbot/User.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-Copyright Paul James Mutton, 2001-2009, http://www.jibble.org/
-
-This file is part of PircBot.
-
-This software is dual-licensed, allowing you to choose between the GNU
-General Public License (GPL) and the www.jibble.org Commercial License.
-Since the GPL may be too restrictive for use in a proprietary application,
-a commercial license is also provided. Full license information can be
-found at http://www.jibble.org/licenses/
-
-*/
-
-package org.jibble.pircbot;
-
-import java.util.Locale;
-
-/**
- * This class is used to represent a user on an IRC server.
- * Instances of this class are returned by the getUsers method
- * in the PircBot class.
- * <p>
- * Note that this class no longer implements the Comparable interface
- * for Java 1.1 compatibility reasons.
- *
- * @since 1.0.0
- * @author Paul James Mutton,
- * <a href="http://www.jibble.org/">http://www.jibble.org/</a>
- * @version 1.5.0 (Build time: Mon Dec 14 20:07:17 2009)
- */
-public class User {
-
-
- /**
- * Constructs a User object with a known prefix and nick.
- *
- * @param prefix The status of the user, for example, "@".
- * @param nick The nick of the user.
- */
- User(String prefix, String nick) {
- _prefix = prefix;
- _nick = nick;
- _lowerNick = nick.toLowerCase(Locale.ENGLISH);
- }
-
-
- /**
- * Returns the prefix of the user. If the User object has been obtained
- * from a list of users in a channel, then this will reflect the user's
- * status in that channel.
- *
- * @return The prefix of the user. If there is no prefix, then an empty
- * String is returned.
- */
- public String getPrefix() {
- return _prefix;
- }
-
-
- /**
- * Returns whether or not the user represented by this object is an
- * operator. If the User object has been obtained from a list of users
- * in a channel, then this will reflect the user's operator status in
- * that channel.
- *
- * @return true if the user is an operator in the channel.
- */
- public boolean isOp() {
- return _prefix.indexOf('@') >= 0;
- }
-
-
- /**
- * Returns whether or not the user represented by this object has
- * voice. If the User object has been obtained from a list of users
- * in a channel, then this will reflect the user's voice status in
- * that channel.
- *
- * @return true if the user has voice in the channel.
- */
- public boolean hasVoice() {
- return _prefix.indexOf('+') >= 0;
- }
-
-
- /**
- * Returns the nick of the user.
- *
- * @return The user's nick.
- */
- public String getNick() {
- return _nick;
- }
-
-
- /**
- * Returns the nick of the user complete with their prefix if they
- * have one, e.g. "@Dave".
- *
- * @return The user's prefix and nick.
- */
- public String toString() {
- return this.getPrefix() + this.getNick();
- }
-
-
- /**
- * Returns true if the nick represented by this User object is the same
- * as the argument. A case insensitive comparison is made.
- *
- * @return true if the nicks are identical (case insensitive).
- */
- public boolean equals(String nick) {
- return nick.toLowerCase(Locale.ENGLISH).equals(_lowerNick);
- }
-
-
- /**
- * Returns true if the nick represented by this User object is the same
- * as the nick of the User object given as an argument.
- * A case insensitive comparison is made.
- *
- * @return true if o is a User object with a matching lowercase nick.
- */
- public boolean equals(Object o) {
- if (o instanceof User) {
- User other = (User) o;
- return other._lowerNick.equals(_lowerNick);
- }
- return false;
- }
-
-
- /**
- * Returns the hash code of this User object.
- *
- * @return the hash code of the User object.
- */
- public int hashCode() {
- return _lowerNick.hashCode();
- }
-
-
- /**
- * Returns the result of calling the compareTo method on lowercased
- * nicks. This is useful for sorting lists of User objects.
- *
- * @return the result of calling compareTo on lowercased nicks.
- */
- public int compareTo(Object o) {
- if (o instanceof User) {
- User other = (User) o;
- return other._lowerNick.compareTo(_lowerNick);
- }
- return -1;
- }
-
-
- private String _prefix;
- private String _nick;
- private String _lowerNick;
-
-}
diff --git a/EssentialsUpdate/src/plugin.yml b/EssentialsUpdate/src/plugin.yml
deleted file mode 100644
index b8dbe8e25..000000000
--- a/EssentialsUpdate/src/plugin.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
-name: EssentialsUpdate
-main: com.earth2me.essentials.update.EssentialsUpdate
-# Note to developers: This next line cannot change, or the automatic versioning system will break.
-version: TeamCity
-description: This plugin allows to install or update all Essentials plugins
-authors: [snowleo]
-commands:
- essentialsupdate:
- description: Install or update the Essentials plugins.
- usage: /<command>
- essentialshelp:
- description: Get help from the Essentials support chat.
- usage: /<command>
-permissions:
- essentials.update:
- description: Allows you to update Essentials
- default: op
- essentials.helpchat:
- description: Allows you to join Essentials help chat
- default: op \ No newline at end of file
diff --git a/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java b/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java
deleted file mode 100644
index a51f03bd7..000000000
--- a/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.earth2me.essentials.update;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import junit.framework.TestCase;
-import org.junit.Test;
-
-
-public class UploadTest extends TestCase
-{
- @Test
- public void testPastieUpload()
- {
- try
- {
- final PastieUpload pastie = new PastieUpload();
- assertNotNull(pastie);
- //final String url = pastie.send("test");
- //System.out.println(url);
- }
- catch (IOException ex)
- {
- Logger.getLogger(UploadTest.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-}
diff --git a/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java b/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
deleted file mode 100644
index 024f2248b..000000000
--- a/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.earth2me.essentials.update;
-
-import com.earth2me.essentials.update.Version.Type;
-import java.util.TreeSet;
-import junit.framework.TestCase;
-import org.junit.Test;
-
-
-public class VersionTest extends TestCase
-{
- @Test
- public void testStable()
- {
- final Version instance = new Version("1.2.3");
- assertEquals("Testing Major", 1, instance.getMajor());
- assertEquals("Testing Minor", 2, instance.getMinor());
- assertEquals("Testing Build", 3, instance.getBuild());
- assertEquals("Testing Type", Type.STABLE, instance.getType());
- }
-
- @Test
- public void testDev()
- {
- final Version instance = new Version("Dev2.3.4");
- assertEquals("Testing Major", 2, instance.getMajor());
- assertEquals("Testing Minor", 3, instance.getMinor());
- assertEquals("Testing Build", 4, instance.getBuild());
- assertEquals("Testing Type", Type.DEVELOPER, instance.getType());
- }
-
- @Test
- public void testTeamCity()
- {
- final Version instance = new Version("Teamcity");
- assertEquals("Testing Type", Type.DEVELOPER, instance.getType());
- }
-
- @Test
- public void testPre()
- {
- final Version instance = new Version("Pre5.7.400.2");
- assertEquals("Testing Major", 5, instance.getMajor());
- assertEquals("Testing Minor", 7, instance.getMinor());
- assertEquals("Testing Build", 400, instance.getBuild());
- assertEquals("Testing Type", Type.PREVIEW, instance.getType());
- }
-
- @Test
- public void testCompareTo()
- {
- 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(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());
- }
-}