mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-11 17:15:07 +02:00
Master -> 3.0
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
|
||||
</classpath>
|
70
.gitignore
vendored
70
.gitignore
vendored
@@ -1,42 +1,32 @@
|
||||
# Eclipse stuff
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
# netbeans
|
||||
nbproject
|
||||
|
||||
# we use maven!
|
||||
build.xml
|
||||
|
||||
# maven
|
||||
target
|
||||
jars
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
build
|
||||
bin
|
||||
dist
|
||||
manifest.mf
|
||||
|
||||
# Mac filesystem dust
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
17
.project
17
.project
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Essentials</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@@ -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="BuildAll" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project BuildAll.</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="BuildAll-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>
|
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.script.CRC32=7a797370
|
||||
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=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=c5170bed
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
@@ -1,129 +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=BuildAll
|
||||
application.vendor=
|
||||
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.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.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}/BuildAll.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupManager.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}
|
||||
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=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
platform.active=default_platform
|
||||
project.Essentials=../Essentials
|
||||
project.EssentialsChat=../EssentialsChat
|
||||
project.EssentialsGeoIP=../EssentialsGeoIP
|
||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
|
||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar
|
||||
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
|
@@ -1,84 +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>BuildAll</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>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>Essentials</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsChat</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsGeoIP</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsGroupBridge</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsGroupManager</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsProtect</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsSpawn</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsXMPP</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
@@ -1,84 +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="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</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="Essentials-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.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
build.xml.data.CRC32=7d758acf
|
||||
build.xml.script.CRC32=3233ee78
|
||||
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=a830bc14
|
||||
nbproject/build-impl.xml.script.CRC32=a9f8842a
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
@@ -1,3 +0,0 @@
|
||||
DoNotUseThreads
|
||||
LongVariable
|
||||
SignatureDeclareThrowsException
|
@@ -1,154 +0,0 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=lombok.core.AnnotationProcessor
|
||||
annotation.processing.run.all.processors=false
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Essentials
|
||||
application.vendor=
|
||||
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}/Essentials.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.lombok.jar=../lib/lombok-0.10.8.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.iCo6.jar}:\
|
||||
${file.reference.MultiCurrency.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}:\
|
||||
${file.reference.lombok.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.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.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=default
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
jnlp.signing=
|
||||
jnlp.signing.alias=
|
||||
jnlp.signing.keystore=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
reference.EssentialsGroupManager.jar=../EssentialsGroupManager/dist/EssentialsGroupManager.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# 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=-Djline.terminal=jline.UnsupportedTerminal
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
@@ -1,28 +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>Essentials</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>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>EssentialsGroupManager</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
95
Essentials/pom.xml
Normal file
95
Essentials/pom.xml
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>net.essentials3</groupId>
|
||||
<artifactId>BuildAll</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>Essentials</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.platymuus.bukkit</groupId>
|
||||
<artifactId>BukkitPermissions</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>${bukkit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>EssentialsGroupManager</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>0.10.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<!--
|
||||
Note: these jars are manually added to our maven repo
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>cosine</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>1.7.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
<artifactId>bPermissions2</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijiko.coelho</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>4.65</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iCo6</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ashtheking</groupId>
|
||||
<artifactId>MultiCurrency</artifactId>
|
||||
<version>0.05</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.krinsoft</groupId>
|
||||
<artifactId>Privileges</artifactId>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -1,137 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class AlternativeCommandsHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<String, String>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public AlternativeCommandsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void addPlugin(final Plugin plugin)
|
||||
{
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null)
|
||||
{
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String label : labels)
|
||||
{
|
||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
||||
if (plugincommands == null)
|
||||
{
|
||||
plugincommands = new ArrayList<PluginCommand>();
|
||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
||||
}
|
||||
boolean found = false;
|
||||
for (PluginCommand pc2 : plugincommands)
|
||||
{
|
||||
if (pc2.getPlugin().equals(plugin))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlugin(final Plugin plugin)
|
||||
{
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
||||
while (pcIterator.hasNext())
|
||||
{
|
||||
final PluginCommand pc = pcIterator.next();
|
||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
|
||||
{
|
||||
pcIterator.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PluginCommand getAlternative(final String label)
|
||||
{
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1)
|
||||
{
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (PluginCommand command : commands)
|
||||
{
|
||||
if (command.getName().equalsIgnoreCase(label))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
@@ -1,140 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("save-all".equalsIgnoreCase(command)) {
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@@ -14,13 +14,8 @@ public final class Console implements IReplyTo
|
||||
{
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(CommandSender user)
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
@@ -17,7 +17,20 @@
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.commands.EssentialsCommandHandler;
|
||||
import com.earth2me.essentials.utils.ExecuteTimer;
|
||||
import com.earth2me.essentials.economy.WorthHolder;
|
||||
import com.earth2me.essentials.economy.Economy;
|
||||
import com.earth2me.essentials.backup.Backup;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.listener.*;
|
||||
import com.earth2me.essentials.economy.register.Methods;
|
||||
import com.earth2me.essentials.ranks.RanksStorage;
|
||||
import com.earth2me.essentials.settings.SettingsHolder;
|
||||
import com.earth2me.essentials.settings.SpawnsHolder;
|
||||
import com.earth2me.essentials.user.UserMap;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
@@ -36,32 +49,25 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
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.PlayerJoinEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
@@ -70,19 +76,24 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
public static final int BUKKIT_VERSION = 2149;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
private transient Jails jails;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient ItemDb itemDb;
|
||||
private final transient TntExplodeListener tntListener = new TntExplodeListener(this);
|
||||
private transient IJails jails;
|
||||
private transient IKits kits;
|
||||
private transient IWarps warps;
|
||||
private transient IWorth worth;
|
||||
private transient List<IReload> reloadList;
|
||||
private transient IBackup backup;
|
||||
private transient IItemDb itemDb;
|
||||
private transient IRanks groups;
|
||||
private transient SpawnsHolder spawns;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient AlternativeCommandsHandler alternativeCommandsHandler;
|
||||
private transient UserMap userMap;
|
||||
//private transient PermissionsHandler permissionsHandler;
|
||||
private transient IUserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
private transient ICommandHandler commandHandler;
|
||||
private transient Economy economy;
|
||||
public transient boolean testing;
|
||||
private transient Metrics metrics;
|
||||
private transient EssentialsTimer timer;
|
||||
private transient List<String> vanishedPlayers = new ArrayList<String>();
|
||||
@@ -95,6 +106,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
|
||||
{
|
||||
testing = true;
|
||||
final File dataFolder = File.createTempFile("essentialstest", "");
|
||||
if (!dataFolder.delete())
|
||||
{
|
||||
@@ -109,11 +121,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new Settings(this);
|
||||
settings = new SettingsHolder(this);
|
||||
i18n.updateLocale("en");
|
||||
userMap = new UserMap(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
economy = new Economy(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,27 +169,37 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
execTimer.mark("BukkitCheck");
|
||||
try
|
||||
{
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
//final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
//upgrade.beforeSettings();
|
||||
//execTimer.mark("Upgrade");
|
||||
reloadList = new ArrayList<IReload>();
|
||||
settings = new SettingsHolder(this);
|
||||
reloadList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
//upgrade.afterSettings();
|
||||
//execTimer.mark("Upgrade2");
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
reloadList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
groups = new RanksStorage(this);
|
||||
reloadList.add((RanksStorage)groups);
|
||||
warps = new Warps(this);
|
||||
reloadList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
worth = new WorthHolder(this);
|
||||
reloadList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
reloadList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
kits = new Kits(this);
|
||||
reloadList.add(kits);
|
||||
commandHandler = new EssentialsCommandHandler(Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", this);
|
||||
reloadList.add(commandHandler);
|
||||
economy = new Economy(this);
|
||||
reloadList.add(economy);
|
||||
spawns = new SpawnsHolder(this);
|
||||
reloadList.add(spawns);
|
||||
reload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
@@ -207,11 +229,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return;
|
||||
}
|
||||
backup = new Backup(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvents(serverListener, this);
|
||||
confList.add(serverListener);
|
||||
reloadList.add(serverListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvents(playerListener, this);
|
||||
@@ -219,31 +240,17 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
|
||||
final SignBlockListener signBlockListener = new SignBlockListener(this);
|
||||
pm.registerEvents(signBlockListener, this);
|
||||
|
||||
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
|
||||
pm.registerEvents(signPlayerListener, this);
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvents(signEntityListener, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
//TODO: Check if this should be here, and not above before reload()
|
||||
jails = new Jails(this);
|
||||
confList.add(jails);
|
||||
reloadList.add(jails);
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
Economy.setEss(this);
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
execTimer.mark("RegListeners");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
@@ -260,7 +267,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +282,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
}
|
||||
i18n.onDisable();
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
}
|
||||
|
||||
@@ -284,10 +290,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
Trade.closeLog();
|
||||
|
||||
for (IConf iConf : confList)
|
||||
for (IReload iReload : reloadList)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
|
||||
iReload.onReload();
|
||||
execTimer.mark("Reload(" + iReload.getClass().getSimpleName() + ")");
|
||||
}
|
||||
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
@@ -296,133 +302,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix, final IEssentialsModule module)
|
||||
{
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
|
||||
{
|
||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
catch (final Exception ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
User user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = getUser(sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// New mail notification
|
||||
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IEssentialsCommand cmd;
|
||||
try
|
||||
{
|
||||
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + command.getName()).newInstance();
|
||||
cmd.setEssentials(this);
|
||||
cmd.setEssentialsModule(module);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(_("commandNotLoaded", commandLabel));
|
||||
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(_("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
cmd.run(getServer(), sender, commandLabel, command, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.run(getServer(), user, commandLabel, command, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
if (!ex.getMessage().isEmpty())
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
showError(sender, ex, commandLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
return this.getServer().getScheduler();
|
||||
return commandHandler.handleCommand(sender, command, commandLabel, args);
|
||||
//return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,19 +313,25 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warps getWarps()
|
||||
public IKits getKits()
|
||||
{
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarps getWarps()
|
||||
{
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worth getWorth()
|
||||
public IWorth getWorth()
|
||||
{
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Backup getBackup()
|
||||
public IBackup getBackup()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
@@ -460,57 +347,15 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
public IUser getUser(final Player player)
|
||||
{
|
||||
if (base instanceof Player)
|
||||
{
|
||||
return getUser((Player)base);
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
final User user = userMap.getUser((String)base);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName((String)base);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (base instanceof User)
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
User user = userMap.getUser(base.getName());
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
user = new User(base, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.update(base);
|
||||
}
|
||||
return user;
|
||||
return userMap.getUser(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
public IUser getUser(final String playerName)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
return userMap.getUser(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -528,9 +373,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReloadListener(final IConf listener)
|
||||
public void addReloadListener(final IReload listener)
|
||||
{
|
||||
confList.add(listener);
|
||||
reloadList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -554,8 +399,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
final IUser user = getUser(player);
|
||||
if (!user.isIgnoringPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -567,53 +412,44 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
return this.getServer().getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
return this.getServer().getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TNTExplodeListener getTNTListener()
|
||||
public TntExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public PermissionsHandler getPermissionsHandler() { return permissionsHandler; }
|
||||
*/
|
||||
@Override
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlternativeCommandsHandler getAlternativeCommandsHandler()
|
||||
{
|
||||
return alternativeCommandsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDb getItemDb()
|
||||
public IItemDb getItemDb()
|
||||
{
|
||||
return itemDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMap getUserMap()
|
||||
public IUserMap getUserMap()
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
@@ -625,58 +461,32 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public EssentialsTimer getTimer()
|
||||
public IRanks getRanks()
|
||||
{
|
||||
return timer;
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVanishedPlayers()
|
||||
public ICommandHandler getCommandHandler()
|
||||
{
|
||||
return vanishedPlayers;
|
||||
}
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable
|
||||
{
|
||||
private transient final IEssentials ess;
|
||||
|
||||
public EssentialsWorldListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldLoad(final WorldLoadEvent event)
|
||||
{
|
||||
ess.getJails().onReload();
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldUnload(final WorldUnloadEvent event)
|
||||
{
|
||||
ess.getJails().onReload();
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
return commandHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
public void setRanks(final IRanks groups)
|
||||
{
|
||||
ess.reload();
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeReloadListener(IReload groups)
|
||||
{
|
||||
this.reloadList.remove(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEconomy getEconomy()
|
||||
{
|
||||
return economy;
|
||||
}
|
||||
}
|
||||
|
@@ -1,448 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private static final int AIR = Material.AIR.getId();
|
||||
private static final int BED = Material.BED_BLOCK.getId();
|
||||
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(_("playerMuted"));
|
||||
LOGGER.info(_("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
}
|
||||
ess.getVanishedPlayers().remove(user.getName());
|
||||
user.setLastLocation();
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
delayedJoin(event.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delayedJoin(final Player player)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(player);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
user.updateActivity(false);
|
||||
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
{
|
||||
if (!user.isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
user.hidePlayer(ess.getUser(p));
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("noNewMail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
if (loc == null)
|
||||
{
|
||||
loc = user.getBedSpawnLocation();
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
final Location updateLoc = loc;
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
switch (event.getResult())
|
||||
{
|
||||
case ALLOWED:
|
||||
case KICK_FULL:
|
||||
case KICK_BANNED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isNPC())
|
||||
{
|
||||
user.setNPC(false);
|
||||
}
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final boolean backListener = ess.getSettings().registerBackInListener();
|
||||
final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
|
||||
if (backListener || teleportInvulnerability)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if (backListener && (event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND))
|
||||
{
|
||||
user.setLastLocation();
|
||||
}
|
||||
if (teleportInvulnerability)
|
||||
{
|
||||
user.enableInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack stack = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(stack))
|
||||
{
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
{
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
if (COMMANDS.contains(cmd))
|
||||
{
|
||||
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User spyer = ess.getUser(onlinePlayer);
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
|
||||
{
|
||||
onlinePlayer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String newWorld = event.getPlayer().getLocation().getWorld().getName();
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
|
||||
if (!event.getPlayer().getWorld().getName().equals(newWorld))
|
||||
{
|
||||
user.sendMessage(_("currentWorld", newWorld));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
switch (event.getAction())
|
||||
{
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
}
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean usePowertools(final User user, final int id)
|
||||
{
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean used = false;
|
||||
// We need to loop through each command and execute
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command.contains("{player}"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
used = true;
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
used = true;
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
if (ess.getUser(event.getPlayer()).isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClickEvent(final InventoryClickEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
final User invOwner = ess.getUser(event.getView().getPlayer());
|
||||
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
|
||||
|| invOwner.isAuthorized("essentials.invsee.preventmodify")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
|
||||
public class EssentialsPluginListener implements Listener, IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
@@ -1,5 +1,11 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@@ -11,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
private final transient Set<IUser> onlineUsers = new HashSet<IUser>();
|
||||
private transient long lastPoll = System.currentTimeMillis();
|
||||
private final transient LinkedList<Float> history = new LinkedList<Float>();
|
||||
|
||||
@@ -41,12 +47,34 @@ public class EssentialsTimer implements Runnable
|
||||
lastPoll = currentTime;
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
final IUser user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
|
||||
boolean mailDisabled = false;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
mailDisabled = settings.getData().getCommands().isDisabled("mail");
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
// New mail notification
|
||||
if (user != null && !mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -54,13 +82,13 @@ public class EssentialsTimer implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
final Iterator<IUser> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
final IUser user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getTimestamp(TimestampType.LOGOUT))
|
||||
{
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
user.setTimestamp(TimestampType.LOGOUT, user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.II18n;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -43,6 +44,7 @@ public class I18n implements II18n
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
|
@@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
/**
|
||||
* @deprecated New interface will be IReload in api package
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.List;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
I18n getI18n();
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
|
||||
Metrics getMetrics();
|
||||
|
||||
void setMetrics(Metrics metrics);
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
List<String> getVanishedPlayers();
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface IReplyTo {
|
||||
public void setReplyTo(CommandSender user);
|
||||
|
||||
public CommandSender getReplyTo();
|
||||
}
|
@@ -1,182 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
MessageFormat getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
ConfigurationSection getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
Set getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
double getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean disableSuffix();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser extends Player
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
boolean canAfford(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
Teleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
@@ -1,16 +1,22 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.storage.ManagedFile;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ItemDb implements IConf, IItemDb
|
||||
public class ItemDb implements IItemDb
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
@@ -19,12 +25,12 @@ public class ItemDb implements IConf, IItemDb
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient Map<String, Long> items = new HashMap<String, Long>();
|
||||
private final transient ManagedFile file;
|
||||
private static final Pattern SPLIT = Pattern.compile("[^a-zA-Z0-9]");
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
public void onReload()
|
||||
{
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
@@ -33,30 +39,54 @@ public class ItemDb implements IConf, IItemDb
|
||||
return;
|
||||
}
|
||||
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase(Locale.ENGLISH);
|
||||
line = line.trim();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
final String[] parts = SPLIT.split(line);
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
final long numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
|
||||
final long durability = parts.length > 2 && !(parts[2].length() == 1 && parts[2].charAt(0) == '0') ? Short.parseShort(parts[2]) : 0;
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric | (durability << 32));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack get(final String id, final IUser user) throws Exception
|
||||
{
|
||||
final ItemStack stack = get(id.toLowerCase(Locale.ENGLISH));
|
||||
|
||||
@Cleanup
|
||||
com.earth2me.essentials.api.ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
|
||||
final int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
|
||||
|
||||
if (defaultStackSize > 0)
|
||||
{
|
||||
stack.setAmount(defaultStackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
|
||||
if (oversizedStackSize > 0 && Permissions.OVERSIZEDSTACKS.isAuthorized(user))
|
||||
{
|
||||
stack.setAmount(oversizedStackSize);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
|
||||
@@ -92,10 +122,11 @@ public class ItemDb implements IConf, IItemDb
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
{
|
||||
itemid = items.get(itemname);
|
||||
if (durabilities.containsKey(itemname) && metaData == 0)
|
||||
long item = items.get(itemname);
|
||||
itemid = (int)(item & 0xffffffffL);
|
||||
if (metaData == 0)
|
||||
{
|
||||
metaData = durabilities.get(itemname);
|
||||
metaData = (short)((item >> 32) & 0xffffL);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
|
@@ -1,12 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -35,7 +38,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
onReload();
|
||||
}
|
||||
|
||||
private void registerListeners()
|
||||
@@ -81,7 +84,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getBukkitLocation();
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
@@ -141,7 +144,15 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.setJail(jail);
|
||||
user.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
user.getData().setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -157,9 +168,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, Location>());
|
||||
getData().setJails(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -186,8 +197,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -196,8 +209,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -206,8 +221,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -231,11 +248,15 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
private class JailPlayerListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -244,15 +265,17 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
event.setRespawnLocation(getJail(user.getData().getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -270,15 +293,17 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setTo(getJail(user.getJail()));
|
||||
event.setTo(getJail(user.getData().getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -297,15 +322,17 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sendToJail(user, user.getJail());
|
||||
sendToJail(user, user.getData().getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@@ -1,167 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import static com.earth2me.essentials.I18n.capitalCase;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kit
|
||||
{
|
||||
//TODO: Convert this to use one of the new text classes?
|
||||
public static String listKits(final IEssentials ess, final User user) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user == null || user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
}
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
|
||||
final long mintime = c.getTimeInMillis();
|
||||
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime)
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.getTimeInMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Calendar future = new GregorianCalendar();
|
||||
future.setTimeInMillis(lastTime);
|
||||
future.add(Calendar.SECOND, (int)delay);
|
||||
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (List<String>)kit.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"),e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split(" ");
|
||||
final String[] item = parts[0].split("[:+',;.]", 2);
|
||||
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
|
||||
|
||||
final ItemStack stack = new ItemStack(id, amount, data);
|
||||
if (parts.length > 2)
|
||||
{
|
||||
for (int i = 2; i < parts.length; i++)
|
||||
{
|
||||
final String[] split = parts[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception("Enchantment not found: " + split[0]);
|
||||
}
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
try
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spew = true;
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
if (spew)
|
||||
{
|
||||
user.sendMessage(_("kitInvFull"));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
throw new Exception(_("kitError2"), e);
|
||||
}
|
||||
}
|
||||
}
|
90
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
90
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IKits;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Kits> implements IKits
|
||||
{
|
||||
public Kits(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Kits.class);
|
||||
onReload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "kits.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kit getKit(String kitName) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null || kitName == null
|
||||
|| !getData().getKits().containsKey(kitName.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
final Kit kit = getData().getKits().get(kitName.toLowerCase(Locale.ENGLISH));
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
return kit;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, String kitName) throws Exception
|
||||
{
|
||||
final Kit kit = getKit(kitName);
|
||||
sendKit(user, kit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, Kit kit) throws Exception
|
||||
{
|
||||
final List<ItemStack> itemList = kit.getItems();
|
||||
user.giveItems(itemList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<String>(getData().getKits().keySet());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getData().getKits().isEmpty();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,38 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
@Delegate(types =
|
||||
{
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
|
||||
public PlayerExtension(final Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
}
|
@@ -1,822 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.signs.Signs;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Settings implements ISettings
|
||||
{
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private boolean metricsEnabled = true;
|
||||
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
|
||||
config.setTemplateName("/config.yml");
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRespawnAtHome()
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUpdateBedAtDaytime()
|
||||
{
|
||||
return config.getBoolean("update-bed-at-daytime", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMultipleHomes()
|
||||
{
|
||||
return config.getConfigurationSection("sethome-multiple").getKeys(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
// return getHomeLimit("default");
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
int limit = getHomeLimit("default");
|
||||
for (String set : homeList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final String set)
|
||||
{
|
||||
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportDelay()
|
||||
{
|
||||
return config.getDouble("teleport-delay", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOversizedStackSize()
|
||||
{
|
||||
return config.getInt("oversized-stacksize", 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultStackSize()
|
||||
{
|
||||
return config.getInt("default-stack-size", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandRestricted(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
for (String c : config.getStringList("overridden-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
{
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String label)
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
if (cost == 0.0)
|
||||
{
|
||||
cost = config.getDouble("cost-" + label, 0.0);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportCooldown()
|
||||
{
|
||||
return config.getDouble("teleport-cooldown", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealCooldown()
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 0);
|
||||
}
|
||||
private ConfigurationSection kits;
|
||||
|
||||
public ConfigurationSection _getKits()
|
||||
{
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String kitItem : section.getKeys(false))
|
||||
{
|
||||
if (section.isConfigurationSection(kitItem))
|
||||
{
|
||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getKits()
|
||||
{
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKit(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
final ConfigurationSection kits = getKits();
|
||||
if (kits.isConfigurationSection(name))
|
||||
{
|
||||
return kits.getConfigurationSection(name).getValues(true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor() throws Exception
|
||||
{
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.RED;
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
|
||||
return ChatColor.getByChar(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
{
|
||||
return config.getInt("protect.creeper.max-height", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return !signsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBackupInterval()
|
||||
{
|
||||
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupCommand()
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
private Map<String, MessageFormat> chatFormats = new HashMap<String, MessageFormat>();
|
||||
|
||||
@Override
|
||||
public MessageFormat getChatFormat(String group)
|
||||
{
|
||||
MessageFormat mFormat = chatFormats.get(group);
|
||||
if (mFormat == null)
|
||||
{
|
||||
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
format = Util.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
format = format.replace("{WORLDNAME}", "{1}");
|
||||
format = format.replace("{SHORTWORLDNAME}", "{2}");
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
mFormat = new MessageFormat(format);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IText getAnnounceNewPlayerFormat()
|
||||
{
|
||||
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewPlayerKit()
|
||||
{
|
||||
return config.getString("newbies.kit", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewbieSpawn()
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
return config.getBoolean("sort-list-by-groups", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
||||
enabledSigns = _getEnabledSigns();
|
||||
teleportInvulnerability = _isTeleportInvulnerability();
|
||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||
registerBackInListener = _registerBackInListener();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
loginAttackDelay = _loginAttackDelay();
|
||||
kits = _getKits();
|
||||
chatFormats.clear();
|
||||
}
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
return itemSpawnBl;
|
||||
}
|
||||
|
||||
private List<Integer> _getItemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
if (ess.getItemDb() == null)
|
||||
{
|
||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||
return epItemSpwn;
|
||||
}
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(iStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
}
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> enabledSigns()
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> _getEnabledSigns()
|
||||
{
|
||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
for (String signName : config.getStringList("enabledSigns"))
|
||||
{
|
||||
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||
if (signName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (signName.equals("COLOR") || signName.equals("COLOUR"))
|
||||
{
|
||||
signsEnabled = true;
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
newSigns.add(Signs.valueOf(signName).getSign());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
|
||||
continue;
|
||||
}
|
||||
signsEnabled = true;
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
{
|
||||
return config.getBoolean("spawn-if-no-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
private boolean debug = false;
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return debug || config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
return config.getBoolean("permission-based-item-spawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale()
|
||||
{
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeInStacks(int id)
|
||||
{
|
||||
return config.getBoolean("trade-in-stacks-" + id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled()
|
||||
{
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try
|
||||
{
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtectString(final String configName)
|
||||
{
|
||||
return config.getString(configName, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectBoolean(final String configName, boolean def)
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY)
|
||||
{
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
private final static double MINMONEY = -10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMinMoney()
|
||||
{
|
||||
double min = config.getDouble("min-money", MINMONEY);
|
||||
if (min > 0)
|
||||
{
|
||||
min = -min;
|
||||
}
|
||||
if (min < MINMONEY)
|
||||
{
|
||||
min = MINMONEY;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-update-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changePlayerListName()
|
||||
{
|
||||
return config.getBoolean("change-playerlist", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disablePrefix()
|
||||
{
|
||||
return config.getBoolean("disablePrefix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableSuffix()
|
||||
{
|
||||
return config.getBoolean("disableSuffix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
private boolean getFreezeAfkPlayers;
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return getFreezeAfkPlayers;
|
||||
}
|
||||
|
||||
private boolean _getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
private boolean cancelAfkOnMove;
|
||||
|
||||
@Override
|
||||
public boolean cancelAfkOnMove()
|
||||
{
|
||||
return cancelAfkOnMove;
|
||||
}
|
||||
|
||||
private boolean _cancelAfkOnMove()
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
private Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public Set<String> getNoGodWorlds()
|
||||
{
|
||||
return noGodWorlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(final boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRepairEnchanted()
|
||||
{
|
||||
return config.getBoolean("repair-enchanted", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldTeleportPermissions()
|
||||
{
|
||||
return config.getBoolean("world-teleport-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldHomePermissions()
|
||||
{
|
||||
return config.getBoolean("world-home-permissions", false);
|
||||
}
|
||||
private boolean registerBackInListener;
|
||||
|
||||
@Override
|
||||
public boolean registerBackInListener()
|
||||
{
|
||||
return registerBackInListener;
|
||||
}
|
||||
|
||||
private boolean _registerBackInListener()
|
||||
{
|
||||
return config.getBoolean("register-back-in-listener", false);
|
||||
}
|
||||
private boolean disableItemPickupWhileAfk;
|
||||
|
||||
@Override
|
||||
public boolean getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return disableItemPickupWhileAfk;
|
||||
}
|
||||
|
||||
private boolean _getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventPriority getRespawnPriority()
|
||||
{
|
||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
if ("lowest".equals(priority))
|
||||
{
|
||||
return EventPriority.LOWEST;
|
||||
}
|
||||
if ("low".equals(priority))
|
||||
{
|
||||
return EventPriority.LOW;
|
||||
}
|
||||
if ("normal".equals(priority))
|
||||
{
|
||||
return EventPriority.NORMAL;
|
||||
}
|
||||
if ("high".equals(priority))
|
||||
{
|
||||
return EventPriority.HIGH;
|
||||
}
|
||||
if ("highest".equals(priority))
|
||||
{
|
||||
return EventPriority.HIGHEST;
|
||||
}
|
||||
return EventPriority.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTpaAcceptCancellation()
|
||||
{
|
||||
return config.getLong("tpa-accept-cancellation", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetricsEnabled()
|
||||
{
|
||||
return metricsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetricsEnabled(boolean metricsEnabled)
|
||||
{
|
||||
this.metricsEnabled = metricsEnabled;
|
||||
}
|
||||
private boolean teleportInvulnerability;
|
||||
|
||||
@Override
|
||||
public long getTeleportInvulnerability()
|
||||
{
|
||||
return config.getLong("teleport-invulnerability", 0) * 1000;
|
||||
}
|
||||
|
||||
private boolean _isTeleportInvulnerability()
|
||||
{
|
||||
return (config.getLong("teleport-invulnerability", 0) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleportInvulnerability()
|
||||
{
|
||||
return teleportInvulnerability;
|
||||
}
|
||||
|
||||
private long loginAttackDelay;
|
||||
|
||||
private long _loginAttackDelay()
|
||||
{
|
||||
return config.getLong("login-attack-delay", 0) * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLoginAttackDelay()
|
||||
{
|
||||
return loginAttackDelay;
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,16 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@@ -111,7 +120,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
ess.getCommandHandler().showCommandError(user.getBase(), "teleport", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -138,30 +147,21 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
final Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
}
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
if (user.getLastTeleportTimestamp() > 0)
|
||||
try
|
||||
{
|
||||
double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(user.getLastTeleportTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
user.checkCooldown(TimestampType.LASTTELEPORT, ess.getRanks().getTeleportCooldown(user), !check, Permissions.TELEPORT_COOLDOWN_BYPASS);
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check)
|
||||
catch (CooldownException ex)
|
||||
{
|
||||
user.setLastTeleportTimestamp(now.getTimeInMillis());
|
||||
throw new Exception(_("timeBeforeTeleport", ex.getMessage()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,14 +207,14 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
double delay = ess.getRanks().getTeleportDelay(user);
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
|
||||
{
|
||||
cooldown(false);
|
||||
now(target, cause);
|
||||
@@ -229,7 +229,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
|
||||
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
@@ -239,7 +239,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
{
|
||||
cancel();
|
||||
user.setLastLocation();
|
||||
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
|
||||
user.getBase().teleport(LocationUtil.getSafeDestination(target.getLocation()), cause);
|
||||
}
|
||||
|
||||
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
||||
@@ -269,12 +269,28 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void home(Location loc, Trade chargeFor) throws Exception
|
||||
|
@@ -1,662 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private CommandSender replyTo = null;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient boolean vanished;
|
||||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient Location afkPosition = null;
|
||||
private boolean invSee = false;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
if (isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
|
||||
}
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isJailed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
return canAfford(cost, true);
|
||||
}
|
||||
|
||||
public boolean canAfford(final double cost, final boolean permcheck)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.getName().equalsIgnoreCase(((User)object).getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequestTime = System.currentTimeMillis();
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
}
|
||||
|
||||
public User getTeleportRequest()
|
||||
{
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
public boolean isTpRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick(final boolean longnick)
|
||||
{
|
||||
final StringBuilder prefix = new StringBuilder();
|
||||
String nickname;
|
||||
String suffix = "§f";
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
final String opPrefix = ess.getSettings().getOperatorColor().toString();
|
||||
if (opPrefix.length() > 0)
|
||||
{
|
||||
prefix.insert(0, opPrefix);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
prefix.insert(0, ptext);
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
suffix = stext + "§f";
|
||||
suffix = suffix.replace("§f§f", "§f");
|
||||
}
|
||||
}
|
||||
final String strPrefix = prefix.toString();
|
||||
String output = strPrefix + nickname + suffix;
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = strPrefix + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
|
||||
}
|
||||
if (output.charAt(output.length() - 1) == '§') {
|
||||
output = output.substring(0, output.length() - 1);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setDisplayNick()
|
||||
{
|
||||
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayName(getNick(true));
|
||||
if (ess.getSettings().changePlayerListName())
|
||||
{
|
||||
String name = getNick(false);
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
super.setMoney(value);
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
||||
}
|
||||
|
||||
public void updateMoneyCache(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
|
||||
{
|
||||
super.setMoney(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
else if (!set && isAfk())
|
||||
{
|
||||
afkPosition = null;
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
if (hidden == true)
|
||||
{
|
||||
setLastLogout(getLastOnlineActivity());
|
||||
}
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(_("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(_("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
|
||||
lastActivity = 0;
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|
||||
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabledRaw()
|
||||
{
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public long getTeleportRequestTime()
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
|
||||
public boolean isInvSee()
|
||||
{
|
||||
return invSee;
|
||||
}
|
||||
|
||||
public void setInvSee(final boolean set)
|
||||
{
|
||||
invSee = set;
|
||||
}
|
||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||
|
||||
public void enableInvulnerabilityAfterTeleport()
|
||||
{
|
||||
final long time = ess.getSettings().getTeleportInvulnerability();
|
||||
if (time > 0)
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetInvulnerabilityAfterTeleport()
|
||||
{
|
||||
if (teleportInvulnerabilityTimestamp != 0
|
||||
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasInvulnerabilityAfterTeleport()
|
||||
{
|
||||
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isVanished()
|
||||
{
|
||||
return vanished;
|
||||
}
|
||||
|
||||
public void toggleVanished()
|
||||
{
|
||||
vanished = !vanished;
|
||||
if (vanished)
|
||||
{
|
||||
ess.getVanishedPlayers().add(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getVanishedPlayers().remove(getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,812 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
}
|
||||
private double money;
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
if (config.isConfigurationSection("homes"))
|
||||
{
|
||||
return config.getConfigurationSection("homes").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList<String>(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
String search = name;
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("invalidHome", name));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
if (config.hasProperty("home"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private String nickname;
|
||||
|
||||
public String _getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nick)
|
||||
{
|
||||
nickname = nick;
|
||||
config.setProperty("nickname", nick);
|
||||
config.save();
|
||||
}
|
||||
private List<Integer> unlimited;
|
||||
|
||||
private List<Integer> _getUnlimited()
|
||||
{
|
||||
return config.getIntegerList("unlimited");
|
||||
}
|
||||
|
||||
public List<Integer> getUnlimited()
|
||||
{
|
||||
return unlimited;
|
||||
}
|
||||
|
||||
public boolean hasUnlimited(ItemStack stack)
|
||||
{
|
||||
return unlimited.contains(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setUnlimited(ItemStack stack, boolean state)
|
||||
{
|
||||
if (unlimited.contains(stack.getTypeId()))
|
||||
{
|
||||
unlimited.remove(Integer.valueOf(stack.getTypeId()));
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
unlimited.add(stack.getTypeId());
|
||||
}
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> powertools;
|
||||
|
||||
private Map<String, Object> _getPowertools()
|
||||
{
|
||||
if (config.isConfigurationSection("powertools"))
|
||||
{
|
||||
return config.getConfigurationSection("powertools").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(int id)
|
||||
{
|
||||
return (List<String>)powertools.get("" + id);
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove("" + stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put("" + stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return !powertools.isEmpty();
|
||||
}
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
{
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
private long lastTeleportTimestamp;
|
||||
|
||||
private long _getLastTeleportTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastteleport", 0);
|
||||
}
|
||||
|
||||
public long getLastTeleportTimestamp()
|
||||
{
|
||||
return lastTeleportTimestamp;
|
||||
}
|
||||
|
||||
public void setLastTeleportTimestamp(long time)
|
||||
{
|
||||
lastTeleportTimestamp = time;
|
||||
config.setProperty("timestamps.lastteleport", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastHealTimestamp;
|
||||
|
||||
private long _getLastHealTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastheal", 0);
|
||||
}
|
||||
|
||||
public long getLastHealTimestamp()
|
||||
{
|
||||
return lastHealTimestamp;
|
||||
}
|
||||
|
||||
public void setLastHealTimestamp(long time)
|
||||
{
|
||||
lastHealTimestamp = time;
|
||||
config.setProperty("timestamps.lastheal", time);
|
||||
config.save();
|
||||
}
|
||||
private String jail;
|
||||
|
||||
private String _getJail()
|
||||
{
|
||||
return config.getString("jail");
|
||||
}
|
||||
|
||||
public String getJail()
|
||||
{
|
||||
return jail;
|
||||
}
|
||||
|
||||
public void setJail(String jail)
|
||||
{
|
||||
if (jail == null || jail.isEmpty())
|
||||
{
|
||||
this.jail = null;
|
||||
config.removeProperty("jail");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.jail = jail;
|
||||
config.setProperty("jail", jail);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private List<String> mails;
|
||||
|
||||
private List<String> _getMails()
|
||||
{
|
||||
return config.getStringList("mail");
|
||||
}
|
||||
|
||||
public List<String> getMails()
|
||||
{
|
||||
return mails;
|
||||
}
|
||||
|
||||
public void setMails(List<String> mails)
|
||||
{
|
||||
if (mails == null)
|
||||
{
|
||||
config.removeProperty("mail");
|
||||
mails = _getMails();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.setProperty("mail", mails);
|
||||
}
|
||||
this.mails = mails;
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void addMail(String mail)
|
||||
{
|
||||
mails.add(mail);
|
||||
setMails(mails);
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
{
|
||||
return config.getBoolean("teleportenabled", true);
|
||||
}
|
||||
|
||||
public boolean isTeleportEnabled()
|
||||
{
|
||||
return teleportEnabled;
|
||||
}
|
||||
|
||||
public void setTeleportEnabled(boolean set)
|
||||
{
|
||||
teleportEnabled = set;
|
||||
config.setProperty("teleportenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleTeleportEnabled()
|
||||
{
|
||||
boolean ret = !isTeleportEnabled();
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
setSocialSpyEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private List<String> ignoredPlayers;
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return config.getStringList("ignore");
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
{
|
||||
if (players == null || players.isEmpty())
|
||||
{
|
||||
ignoredPlayers = new ArrayList<String>();
|
||||
config.removeProperty("ignore");
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers = players;
|
||||
config.setProperty("ignore", players);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
{
|
||||
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean _getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return godmode;
|
||||
}
|
||||
|
||||
public void setGodModeEnabled(boolean set)
|
||||
{
|
||||
godmode = set;
|
||||
config.setProperty("godmode", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
boolean ret = !isGodModeEnabled();
|
||||
setGodModeEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
private boolean getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
return muted;
|
||||
}
|
||||
|
||||
public void setMuted(boolean set)
|
||||
{
|
||||
muted = set;
|
||||
config.setProperty("muted", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleMuted()
|
||||
{
|
||||
boolean ret = !isMuted();
|
||||
setMuted(ret);
|
||||
return ret;
|
||||
}
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.mute", 0);
|
||||
}
|
||||
|
||||
public long getMuteTimeout()
|
||||
{
|
||||
return muteTimeout;
|
||||
}
|
||||
|
||||
public void setMuteTimeout(long time)
|
||||
{
|
||||
muteTimeout = time;
|
||||
config.setProperty("timestamps.mute", time);
|
||||
config.save();
|
||||
}
|
||||
private boolean jailed;
|
||||
|
||||
private boolean getJailed()
|
||||
{
|
||||
return config.getBoolean("jailed", false);
|
||||
}
|
||||
|
||||
public boolean isJailed()
|
||||
{
|
||||
return jailed;
|
||||
}
|
||||
|
||||
public void setJailed(boolean set)
|
||||
{
|
||||
jailed = set;
|
||||
config.setProperty("jailed", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleJailed()
|
||||
{
|
||||
boolean ret = !isJailed();
|
||||
setJailed(ret);
|
||||
return ret;
|
||||
}
|
||||
private long jailTimeout;
|
||||
|
||||
private long _getJailTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.jail", 0);
|
||||
}
|
||||
|
||||
public long getJailTimeout()
|
||||
{
|
||||
return jailTimeout;
|
||||
}
|
||||
|
||||
public void setJailTimeout(long time)
|
||||
{
|
||||
jailTimeout = time;
|
||||
config.setProperty("timestamps.jail", time);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getBanReason()
|
||||
{
|
||||
return config.getString("ban.reason");
|
||||
}
|
||||
|
||||
public void setBanReason(String reason)
|
||||
{
|
||||
config.setProperty("ban.reason", Util.sanitizeString(reason));
|
||||
config.save();
|
||||
}
|
||||
|
||||
public long getBanTimeout()
|
||||
{
|
||||
return config.getLong("ban.timeout", 0);
|
||||
}
|
||||
|
||||
public void setBanTimeout(long time)
|
||||
{
|
||||
config.setProperty("ban.timeout", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastLogin;
|
||||
|
||||
private long _getLastLogin()
|
||||
{
|
||||
return config.getLong("timestamps.login", 0);
|
||||
}
|
||||
|
||||
public long getLastLogin()
|
||||
{
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
private void _setLastLogin(long time)
|
||||
{
|
||||
lastLogin = time;
|
||||
config.setProperty("timestamps.login", time);
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
{
|
||||
_setLastLogin(time);
|
||||
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
|
||||
config.save();
|
||||
}
|
||||
private long lastLogout;
|
||||
|
||||
private long _getLastLogout()
|
||||
{
|
||||
return config.getLong("timestamps.logout", 0);
|
||||
}
|
||||
|
||||
public long getLastLogout()
|
||||
{
|
||||
return lastLogout;
|
||||
}
|
||||
|
||||
public void setLastLogout(long time)
|
||||
{
|
||||
lastLogout = time;
|
||||
config.setProperty("timestamps.logout", time);
|
||||
config.save();
|
||||
}
|
||||
private String lastLoginAddress;
|
||||
|
||||
private String _getLastLoginAddress()
|
||||
{
|
||||
return config.getString("ipAddress", "");
|
||||
}
|
||||
|
||||
public String getLastLoginAddress()
|
||||
{
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
private void _setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
{
|
||||
return config.getBoolean("afk", false);
|
||||
}
|
||||
|
||||
public boolean isAfk()
|
||||
{
|
||||
return afk;
|
||||
}
|
||||
|
||||
public void setAfk(boolean set)
|
||||
{
|
||||
afk = set;
|
||||
config.setProperty("afk", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean ret = !isAfk();
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean newplayer;
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
{
|
||||
return config.getString("geolocation");
|
||||
}
|
||||
|
||||
public String getGeoLocation()
|
||||
{
|
||||
return geolocation;
|
||||
}
|
||||
|
||||
public void setGeoLocation(String geolocation)
|
||||
{
|
||||
if (geolocation == null || geolocation.isEmpty())
|
||||
{
|
||||
this.geolocation = null;
|
||||
config.removeProperty("geolocation");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.geolocation = geolocation;
|
||||
config.setProperty("geolocation", geolocation);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
private boolean isNPC;
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
|
||||
return num == null ? null : num.longValue();
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
@@ -1,142 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
keys.add(Util.sanitizeFileName(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(name);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UncheckedExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User load(final String name) throws Exception
|
||||
{
|
||||
String sanitizedName = Util.sanitizeFileName(name);
|
||||
if (!sanitizedName.equals(name))
|
||||
{
|
||||
User user = getUser(sanitizedName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(Util.sanitizeFileName(name));
|
||||
users.invalidate(Util.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
{
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
return getUserFile2(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
private File getUserFile2(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
}
|
@@ -1,621 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Util
|
||||
{
|
||||
private Util()
|
||||
{
|
||||
}
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return newName;
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
}
|
||||
|
||||
public static String formatDateDiff(long date)
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.setTimeInMillis(date);
|
||||
Calendar now = new GregorianCalendar();
|
||||
return Util.formatDateDiff(now, c);
|
||||
}
|
||||
|
||||
public static String formatDateDiff(Calendar fromDate, Calendar toDate)
|
||||
{
|
||||
boolean future = false;
|
||||
if (toDate.equals(fromDate))
|
||||
{
|
||||
return _("now");
|
||||
}
|
||||
if (toDate.after(fromDate))
|
||||
{
|
||||
future = true;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int[] types = new int[]
|
||||
{
|
||||
Calendar.YEAR,
|
||||
Calendar.MONTH,
|
||||
Calendar.DAY_OF_MONTH,
|
||||
Calendar.HOUR_OF_DAY,
|
||||
Calendar.MINUTE,
|
||||
Calendar.SECOND
|
||||
};
|
||||
String[] names = new String[]
|
||||
{
|
||||
_("year"),
|
||||
_("years"),
|
||||
_("month"),
|
||||
_("months"),
|
||||
_("day"),
|
||||
_("days"),
|
||||
_("hour"),
|
||||
_("hours"),
|
||||
_("minute"),
|
||||
_("minutes"),
|
||||
_("second"),
|
||||
_("seconds")
|
||||
};
|
||||
int accuracy = 0;
|
||||
for (int i = 0; i < types.length; i++)
|
||||
{
|
||||
if (accuracy > 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int diff = dateDiff(types[i], fromDate, toDate, future);
|
||||
if (diff > 0)
|
||||
{
|
||||
accuracy++;
|
||||
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
|
||||
}
|
||||
}
|
||||
if (sb.length() == 0)
|
||||
{
|
||||
return "now";
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
|
||||
{
|
||||
int diff = 0;
|
||||
long savedDate = fromDate.getTimeInMillis();
|
||||
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate)))
|
||||
{
|
||||
savedDate = fromDate.getTimeInMillis();
|
||||
fromDate.add(type, future ? 1 : -1);
|
||||
diff++;
|
||||
}
|
||||
diff--;
|
||||
fromDate.setTimeInMillis(savedDate);
|
||||
return diff;
|
||||
}
|
||||
|
||||
public static long parseDateDiff(String time, boolean future) throws Exception
|
||||
{
|
||||
Pattern timePattern = Pattern.compile(
|
||||
"(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?"
|
||||
+ "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
|
||||
Matcher m = timePattern.matcher(time);
|
||||
int years = 0;
|
||||
int months = 0;
|
||||
int weeks = 0;
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
boolean found = false;
|
||||
while (m.find())
|
||||
{
|
||||
if (m.group() == null || m.group().isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < m.groupCount(); i++)
|
||||
{
|
||||
if (m.group(i) != null && !m.group(i).isEmpty())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
if (m.group(1) != null && !m.group(1).isEmpty())
|
||||
{
|
||||
years = Integer.parseInt(m.group(1));
|
||||
}
|
||||
if (m.group(2) != null && !m.group(2).isEmpty())
|
||||
{
|
||||
months = Integer.parseInt(m.group(2));
|
||||
}
|
||||
if (m.group(3) != null && !m.group(3).isEmpty())
|
||||
{
|
||||
weeks = Integer.parseInt(m.group(3));
|
||||
}
|
||||
if (m.group(4) != null && !m.group(4).isEmpty())
|
||||
{
|
||||
days = Integer.parseInt(m.group(4));
|
||||
}
|
||||
if (m.group(5) != null && !m.group(5).isEmpty())
|
||||
{
|
||||
hours = Integer.parseInt(m.group(5));
|
||||
}
|
||||
if (m.group(6) != null && !m.group(6).isEmpty())
|
||||
{
|
||||
minutes = Integer.parseInt(m.group(6));
|
||||
}
|
||||
if (m.group(7) != null && !m.group(7).isEmpty())
|
||||
{
|
||||
seconds = Integer.parseInt(m.group(7));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw new Exception(_("illegalDate"));
|
||||
}
|
||||
Calendar c = new GregorianCalendar();
|
||||
if (years > 0)
|
||||
{
|
||||
c.add(Calendar.YEAR, years * (future ? 1 : -1));
|
||||
}
|
||||
if (months > 0)
|
||||
{
|
||||
c.add(Calendar.MONTH, months * (future ? 1 : -1));
|
||||
}
|
||||
if (weeks > 0)
|
||||
{
|
||||
c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
|
||||
}
|
||||
if (days > 0)
|
||||
{
|
||||
c.add(Calendar.DAY_OF_MONTH, days * (future ? 1 : -1));
|
||||
}
|
||||
if (hours > 0)
|
||||
{
|
||||
c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
|
||||
}
|
||||
if (minutes > 0)
|
||||
{
|
||||
c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
|
||||
}
|
||||
if (seconds > 0)
|
||||
{
|
||||
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
|
||||
}
|
||||
|
||||
Calendar max = new GregorianCalendar();
|
||||
max.add(Calendar.YEAR, 10);
|
||||
if (c.after(max)) {
|
||||
return max.getTimeInMillis();
|
||||
}
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
// The player can stand inside these materials
|
||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
||||
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
|
||||
|
||||
static
|
||||
{
|
||||
AIR_MATERIALS.add(Material.AIR.getId());
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LEVER.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.SNOW.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.VINE.getId());
|
||||
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
|
||||
AIR_MATERIALS.add(Material.WATER_LILY.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_FENCE.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||
|
||||
for (Integer integer : AIR_MATERIALS)
|
||||
{
|
||||
AIR_MATERIALS_TARGET.add(integer.byteValue());
|
||||
}
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
|
||||
}
|
||||
|
||||
public static Location getTarget(final LivingEntity entity) throws Exception
|
||||
{
|
||||
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
|
||||
if (block == null)
|
||||
{
|
||||
throw new Exception("Not targeting a block");
|
||||
}
|
||||
return block.getLocation();
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("destinationNotSet"));
|
||||
}
|
||||
final World world = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
y -= 1;
|
||||
if (y < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1;
|
||||
if (y >= world.getHighestBlockYAt(x, z))
|
||||
{
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
x += 1;
|
||||
y = world.getHighestBlockYAt(x, z);
|
||||
if (x - 32 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(_("holeInFloor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (below.getType() == Material.FIRE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
}
|
||||
|
||||
public static ItemStack convertBlockToItem(final Block block)
|
||||
{
|
||||
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
|
||||
switch (is.getType())
|
||||
{
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
case PISTON_STICKY_BASE:
|
||||
case PISTON_BASE:
|
||||
case IRON_FENCE:
|
||||
case THIN_GLASS:
|
||||
case TRAP_DOOR:
|
||||
case FENCE:
|
||||
case FENCE_GATE:
|
||||
case NETHER_FENCE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case FIRE:
|
||||
return null;
|
||||
case PUMPKIN_STEM:
|
||||
is.setType(Material.PUMPKIN_SEEDS);
|
||||
break;
|
||||
case MELON_STEM:
|
||||
is.setType(Material.MELON_SEEDS);
|
||||
break;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
public static boolean isInt(final String sInt)
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt(sInt);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
return joinList(", ", list);
|
||||
}
|
||||
|
||||
public static String joinList(String seperator, Object... list)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(seperator);
|
||||
}
|
||||
|
||||
if (each instanceof Collection)
|
||||
{
|
||||
buf.append(joinList(seperator, ((Collection)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String lastCode(final String input) {
|
||||
int pos = input.lastIndexOf("§");
|
||||
if (pos == -1 || (pos + 1) == input.length()) {
|
||||
return "";
|
||||
}
|
||||
return input.substring(pos, pos + 2);
|
||||
}
|
||||
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
|
||||
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
|
||||
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
|
||||
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (user.isAuthorized(permBase + ".color"))
|
||||
{
|
||||
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".magic"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".format"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message = formatString(user, permBase, input);
|
||||
if (!user.isAuthorized(permBase + ".url"))
|
||||
{
|
||||
message = Util.blockURL(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
private static String replaceColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
@@ -1,121 +1,121 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWarp;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.settings.WarpHolder;
|
||||
import com.earth2me.essentials.storage.StorageObjectMap;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Warps implements IConf
|
||||
public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
|
||||
private final File warpsFolder;
|
||||
private final Server server;
|
||||
private static final Logger logger = Bukkit.getLogger();
|
||||
|
||||
public Warps(Server server, File dataFolder)
|
||||
public Warps(IEssentials ess)
|
||||
{
|
||||
this.server = server;
|
||||
warpsFolder = new File(dataFolder, "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
}
|
||||
Collections.sort(keys, String.CASE_INSENSITIVE_ORDER);
|
||||
return keys;
|
||||
}
|
||||
|
||||
public Location getWarp(String warp) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
||||
public void setWarp(String name, Location loc) throws Exception
|
||||
{
|
||||
String filename = Util.sanitizeFileName(name);
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
File confFile = new File(warpsFolder, filename + ".yml");
|
||||
if (confFile.exists())
|
||||
{
|
||||
throw new Exception(_("similarWarpExist"));
|
||||
}
|
||||
conf = new EssentialsConf(confFile);
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
conf.setProperty(null, loc);
|
||||
conf.setProperty("name", name);
|
||||
conf.save();
|
||||
}
|
||||
|
||||
public void delWarp(String name) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
if (!conf.getFile().delete())
|
||||
{
|
||||
throw new Exception(_("warpDeleteError"));
|
||||
}
|
||||
warpPoints.remove(new StringIgnoreCase(name));
|
||||
super(ess, "warps");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
public boolean isEmpty()
|
||||
{
|
||||
warpPoints.clear();
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
return getKeySize() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList()
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
final List<String> names = new ArrayList<String>();
|
||||
for (String key : getAllKeys())
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".yml"))
|
||||
IWarp warp = getObject(key);
|
||||
if (warp == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
EssentialsConf conf = new EssentialsConf(listOfFiles[i]);
|
||||
conf.load();
|
||||
String name = conf.getString("name");
|
||||
if (name != null)
|
||||
names.add(warp.getData().getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getWarp(final String name) throws Exception
|
||||
{
|
||||
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
throw new WarpNotFoundException(_("warpNotExist"));
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
return warp.getData().getLocation().getBukkitLocation();
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarp(final String name, final Location loc) throws Exception
|
||||
{
|
||||
setWarp(name, new com.earth2me.essentials.storage.Location(loc));
|
||||
}
|
||||
|
||||
public void setWarp(final String name, final com.earth2me.essentials.storage.Location loc) throws Exception
|
||||
{
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
warp = new WarpHolder(name, ess);
|
||||
}
|
||||
warp.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
warp.getData().setLocation(loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWarp(final String name) throws Exception
|
||||
{
|
||||
removeObject(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWarpFile(String name) throws InvalidNameException
|
||||
{
|
||||
return getStorageFile(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarp load(String name) throws Exception
|
||||
{
|
||||
final IWarp warp = new WarpHolder(name, ess);
|
||||
warp.onReload();
|
||||
return warp;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,61 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Worth implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
|
||||
public Worth(File dataFolder)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
public double getPrice(ItemStack itemStack)
|
||||
{
|
||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
double result;
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPrice(ItemStack itemStack, double price)
|
||||
{
|
||||
if (itemStack.getType().getData() == null)
|
||||
{
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public interface IAlternativeCommandsHandler
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
}
|
7
Essentials/src/com/earth2me/essentials/api/IBackup.java
Normal file
7
Essentials/src/com/earth2me/essentials/api/IBackup.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IBackup extends Runnable
|
||||
{
|
||||
public void startTask();
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface ICommandHandler extends IReload
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
|
||||
public void removePlugin(Plugin plugin);
|
||||
|
||||
public void addPlugin(Plugin plugin);
|
||||
|
||||
boolean handleCommand(CommandSender sender, Command command, String commandLabel, String[] args);
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
21
Essentials/src/com/earth2me/essentials/api/IEconomy.java
Normal file
21
Essentials/src/com/earth2me/essentials/api/IEconomy.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEconomy extends IReload
|
||||
{
|
||||
public double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
public void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public String format(double amount);
|
||||
|
||||
public boolean playerExists(String name);
|
||||
|
||||
public boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
public boolean createNPC(String name);
|
||||
|
||||
public void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
@@ -1,17 +1,19 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.listener.TntExplodeListener;
|
||||
import com.earth2me.essentials.economy.register.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin, IReload
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Object base);
|
||||
IUser getUser(Player player);
|
||||
|
||||
IUser getUser(String playerName);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
@@ -19,7 +21,11 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IJails getJail();
|
||||
IRanks getRanks();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
IKits getKits();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
@@ -29,7 +35,9 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IEssentialsEconomy getEconomy();
|
||||
IBackup getBackup();
|
||||
|
||||
ICommandHandler getCommandHandler();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
@@ -43,9 +51,14 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
//IPermissionsHandler getPermissionsHandler();
|
||||
void reload();
|
||||
|
||||
IAlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
TntExplodeListener getTNTListener();
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
void setRanks(IRanks groups);
|
||||
|
||||
void removeReloadListener(IReload groups);
|
||||
|
||||
IEconomy getEconomy();
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsEconomy
|
||||
{
|
||||
double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
boolean hasEnough(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasMore(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasLess(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean isNegative(String name) throws UserDoesNotExistException;
|
||||
|
||||
String format(double amount);
|
||||
|
||||
boolean playerExists(String name);
|
||||
|
||||
boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
boolean createNPC(String name);
|
||||
|
||||
void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsModule
|
@@ -3,8 +3,10 @@ package com.earth2me.essentials.api;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IItemDb
|
||||
public interface IItemDb extends IReload
|
||||
{
|
||||
ItemStack get(final String name, final IUser user) throws Exception;
|
||||
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
|
||||
ItemStack get(final String name) throws Exception;
|
||||
|
@@ -14,7 +14,7 @@ public interface IJails extends IReload
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
void sendToJail(IUser user, String jail) throws Exception;
|
||||
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
}
|
||||
|
18
Essentials/src/com/earth2me/essentials/api/IKits.java
Normal file
18
Essentials/src/com/earth2me/essentials/api/IKits.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public interface IKits extends IReload
|
||||
{
|
||||
Kit getKit(String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, Kit kit) throws Exception;
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
17
Essentials/src/com/earth2me/essentials/api/IPermission.java
Normal file
17
Essentials/src/com/earth2me/essentials/api/IPermission.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
|
||||
public interface IPermission
|
||||
{
|
||||
String getPermission();
|
||||
|
||||
boolean isAuthorized(CommandSender sender);
|
||||
|
||||
Permission getBukkitPermission();
|
||||
|
||||
PermissionDefault getPermissionDefault();
|
||||
}
|
25
Essentials/src/com/earth2me/essentials/api/IRanks.java
Normal file
25
Essentials/src/com/earth2me/essentials/api/IRanks.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
public interface IRanks
|
||||
{
|
||||
String getMainGroup(IUser player);
|
||||
|
||||
boolean inGroup(IUser player, String groupname);
|
||||
|
||||
double getHealCooldown(IUser player);
|
||||
|
||||
double getTeleportCooldown(IUser player);
|
||||
|
||||
double getTeleportDelay(IUser player);
|
||||
|
||||
String getPrefix(IUser player);
|
||||
|
||||
String getSuffix(IUser player);
|
||||
|
||||
int getHomeLimit(IUser player);
|
||||
|
||||
MessageFormat getChatFormat(IUser player);
|
||||
}
|
11
Essentials/src/com/earth2me/essentials/api/IReplyTo.java
Normal file
11
Essentials/src/com/earth2me/essentials/api/IReplyTo.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public interface IReplyTo
|
||||
{
|
||||
void setReplyTo(CommandSender user);
|
||||
|
||||
CommandSender getReplyTo();
|
||||
}
|
@@ -6,5 +6,9 @@ import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
public String getLocale();
|
||||
|
||||
public boolean isDebug();
|
||||
|
||||
public void setDebug(boolean b);
|
||||
}
|
||||
|
@@ -1,10 +1,28 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception;
|
||||
|
||||
void home(IUser player, String toLowerCase, Trade charge) throws Exception;
|
||||
|
||||
void respawn(Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void back() throws Exception;
|
||||
|
||||
public void warp(String name, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
}
|
||||
|
@@ -1,43 +1,110 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IUser extends Player, IReload
|
||||
public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, IReplyTo, Comparable<IUser>
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void takeMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
String getGroup();
|
||||
void giveMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveItems(ItemStack itemStack, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void giveItems(List<ItemStack> itemStacks, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void setMoney(double value);
|
||||
|
||||
void payUser(final IUser reciever, final double value) throws Exception;
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
Location getHome(Location loc);
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
void checkCooldown(UserData.TimestampType cooldownType, double cooldown, boolean set, IPermission bypassPermission) throws CooldownException;
|
||||
|
||||
boolean toggleAfk();
|
||||
|
||||
void updateActivity(boolean broadcast);
|
||||
|
||||
void updateDisplayName();
|
||||
|
||||
boolean checkJailTimeout(long currentTime);
|
||||
|
||||
boolean checkMuteTimeout(long currentTime);
|
||||
|
||||
boolean checkBanTimeout(long currentTime);
|
||||
|
||||
long getTimestamp(UserData.TimestampType name);
|
||||
|
||||
void setTimestamp(UserData.TimestampType name, long value);
|
||||
|
||||
void setLastOnlineActivity(long currentTime);
|
||||
|
||||
void checkActivity();
|
||||
|
||||
long getLastOnlineActivity();
|
||||
|
||||
boolean isGodModeEnabled();
|
||||
|
||||
boolean isIgnoringPlayer(String name);
|
||||
|
||||
void setIgnoredPlayer(String name, boolean set);
|
||||
|
||||
Location getAfkPosition();
|
||||
|
||||
boolean toggleGodModeEnabled();
|
||||
|
||||
void dispose();
|
||||
|
||||
void updateCompass();
|
||||
|
||||
List<String> getHomes();
|
||||
|
||||
void addMail(String string);
|
||||
|
||||
boolean toggleMuted();
|
||||
|
||||
boolean toggleSocialSpy();
|
||||
|
||||
void requestTeleport(IUser user, boolean b);
|
||||
|
||||
boolean isTeleportRequestHere();
|
||||
|
||||
IUser getTeleportRequester();
|
||||
|
||||
boolean toggleTeleportEnabled();
|
||||
|
||||
long getTeleportRequestTime();
|
||||
|
||||
boolean gotMailInfo();
|
||||
|
||||
List<String> getMails();
|
||||
|
||||
public boolean canAfford(double money);
|
||||
|
||||
public void updateMoneyCache(double userMoney);
|
||||
|
||||
public boolean canAfford(double amount, boolean b);
|
||||
}
|
||||
|
@@ -2,19 +2,22 @@ package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUserMap
|
||||
public interface IUserMap extends IReload
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final String name);
|
||||
IUser getUser(final Player player);
|
||||
|
||||
void removeUser(final String name);
|
||||
IUser getUser(final String playerName);
|
||||
|
||||
void removeUser(final String name) throws InvalidNameException;
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name);
|
||||
File getUserFile(final String name) throws InvalidNameException;
|
||||
}
|
||||
|
9
Essentials/src/com/earth2me/essentials/api/IWarp.java
Normal file
9
Essentials/src/com/earth2me/essentials/api/IWarp.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Warp;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface IWarp extends IStorageObjectHolder<Warp>
|
||||
{
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -8,9 +9,13 @@ public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getWarps();
|
||||
Collection<String> getList();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
public File getWarpFile(String name) throws InvalidNameException;
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class InvalidNameException extends Exception
|
||||
{
|
||||
public InvalidNameException(Throwable thrwbl)
|
||||
{
|
||||
super(thrwbl);
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPermission {
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPermissionsManager {
|
||||
|
||||
IPermission registerPermission();
|
||||
|
||||
boolean checkPermission(IPlayer player, IPermission perm);
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPlayer {
|
||||
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IServer {
|
||||
|
||||
}
|
153
Essentials/src/com/earth2me/essentials/backup/Backup.java
Normal file
153
Essentials/src/com/earth2me/essentials/backup/Backup.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.earth2me.essentials.backup;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Backup implements Runnable, IBackup
|
||||
{
|
||||
private static final Logger LOGGER = Bukkit.getLogger();
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient final AtomicBoolean running = new AtomicBoolean(false);
|
||||
private transient int taskId = -1;
|
||||
private transient final AtomicBoolean active = new AtomicBoolean(false);
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void startTask()
|
||||
{
|
||||
if (running.compareAndSet(false, true))
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final long interval = settings.getData().getGeneral().getBackup().getInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
running.set(false);
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!active.compareAndSet(false, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final String command = settings.getData().getGeneral().getBackup().getCommand();
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender consoleSender = server.getConsoleSender();
|
||||
server.dispatchCommand(consoleSender, "save-all");
|
||||
server.dispatchCommand(consoleSender, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(new BackupRunner(command));
|
||||
}
|
||||
|
||||
|
||||
private class BackupRunner implements Runnable
|
||||
{
|
||||
private final transient String command;
|
||||
|
||||
public BackupRunner(final String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(new EnableSavingRunner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EnableSavingRunner implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running.set(false);
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
active.set(false);
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -9,8 +9,13 @@ import java.util.regex.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
|
||||
public class Enchantments
|
||||
public final class Enchantments
|
||||
{
|
||||
|
||||
private Enchantments()
|
||||
{
|
||||
}
|
||||
|
||||
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
|
||||
@@ -87,7 +92,7 @@ public class Enchantments
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
public static Enchantment getByName(final String name) {
|
||||
Enchantment enchantment;
|
||||
if (NUMPATTERN.matcher(name).matches()) {
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
@@ -0,0 +1,7 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EssentialsPlugin extends JavaPlugin {
|
||||
//TODO
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
@@ -0,0 +1,9 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.IServer;
|
||||
import lombok.Delegate;
|
||||
|
||||
public class Server implements IServer {
|
||||
@Delegate
|
||||
private org.bukkit.Server server;
|
||||
}
|
@@ -1,23 +1,20 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
|
||||
public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
public Commandafk()
|
||||
{
|
||||
super("afk");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
if (args.length > 0 && Permissions.AFK_OTHERS.isAuthorized(user))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
IUser afkUser = ess.getUser((Player)ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
@@ -29,7 +26,7 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleAfk(User user)
|
||||
private void toggleAfk(IUser user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
if (!user.toggleAfk())
|
||||
@@ -50,4 +47,10 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDefault getPermissionDefault()
|
||||
{
|
||||
return PermissionDefault.TRUE;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,15 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
{
|
||||
public Commandantioch()
|
||||
{
|
||||
super("antioch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
@@ -23,7 +17,7 @@ public class Commandantioch extends EssentialsCommand
|
||||
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
|
||||
}
|
||||
|
||||
final Location loc = Util.getTarget(user);
|
||||
final Location loc = LocationUtil.getTarget(user);
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commandback extends EssentialsCommand
|
||||
{
|
||||
public Commandback()
|
||||
{
|
||||
super("back");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getLastLocation().getWorld().getName()))
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Backup;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbackup extends EssentialsCommand
|
||||
{
|
||||
public Commandbackup()
|
||||
{
|
||||
super("backup");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
|
@@ -1,21 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
public Commandbalance()
|
||||
{
|
||||
super("balance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -25,11 +20,10 @@ public class Commandbalance extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
|| !Permissions.BALANCE_OTHERS.isAuthorized(user)
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
|
@@ -1,24 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.utils.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.utils.textreader.TextPager;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
public static final int MINUSERS = 50;
|
||||
private static ArrayListInput cache = new ArrayListInput();
|
||||
@@ -26,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
@@ -110,7 +105,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
double totalMoney = 0d;
|
||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
final IUser user = ess.getUserMap().getUser(u);
|
||||
if (user != null)
|
||||
{
|
||||
final double userMoney = user.getMoney();
|
||||
|
@@ -2,31 +2,29 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.Ban;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
{
|
||||
public Commandban()
|
||||
{
|
||||
super("ban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
@Cleanup
|
||||
final IUser user = getPlayer(args, 0, true);
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
if (Permissions.BAN_EXEMPT.isAuthorized(user))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
@@ -34,18 +32,20 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.ban.exempt"))
|
||||
if (Permissions.BAN_OFFLINE.isAuthorized(sender))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
user.acquireWriteLock();
|
||||
String banReason;
|
||||
user.getData().setBan(new Ban());
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.setBanReason(banReason);
|
||||
user.getData().getBan().setReason(banReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -59,8 +59,8 @@ public class Commandban extends EssentialsCommand
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.ban.notify"))
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
if (Permissions.BAN_NOTIFY.isAuthorized(player))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
|
@@ -1,27 +1,24 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
{
|
||||
public Commandbanip()
|
||||
{
|
||||
super("banip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User player = ess.getUser(args[0]);
|
||||
@Cleanup
|
||||
final IUser player = ess.getUser(args[0]);
|
||||
player.acquireReadLock();
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@@ -30,12 +27,12 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
final String ipAddress = player.getLastLoginAddress();
|
||||
final String ipAddress = player.getData().getIpAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
ess.getServer().banIP(player.getLastLoginAddress());
|
||||
ess.getServer().banIP(player.getData().getIpAddress());
|
||||
sender.sendMessage(_("banIpAddress"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
|
||||
public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
public Commandbigtree()
|
||||
{
|
||||
super("bigtree");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
@@ -36,8 +30,8 @@ public class Commandbigtree extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final Location loc = Util.getTarget(user);
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final Location loc = LocationUtil.getTarget(user);
|
||||
final Location safeLocation = LocationUtil.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, tree);
|
||||
if (success)
|
||||
{
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -13,14 +13,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
public Commandbreak()
|
||||
{
|
||||
super("break");
|
||||
}
|
||||
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Block block = user.getTargetBlock(null, 20);
|
||||
if (block == null)
|
||||
@@ -31,7 +26,7 @@ public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
if (block.getType() == Material.BEDROCK && !Permissions.BREAK_BEDROCK.isAuthorized(user))
|
||||
{
|
||||
throw new Exception(_("noBreakBedrock"));
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
public Commandbroadcast()
|
||||
{
|
||||
super("broadcast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
public Commandburn()
|
||||
{
|
||||
super("burn");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -1,25 +1,20 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
{
|
||||
public Commandclearinventory()
|
||||
{
|
||||
super("clearinventory");
|
||||
}
|
||||
|
||||
//TODO: Cleanup
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
if (args.length > 0 && Permissions.CLEARINVENTORY_OTHERS.isAuthorized(user))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
@@ -59,7 +54,7 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commandcompass extends EssentialsCommand
|
||||
{
|
||||
public Commandcompass()
|
||||
{
|
||||
super("compass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
|
||||
String dir;
|
||||
|
@@ -1,28 +1,26 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
@Cleanup
|
||||
IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
|
||||
String name;
|
||||
String[] expandedArg;
|
||||
|
||||
@@ -37,9 +35,9 @@ public class Commanddelhome extends EssentialsCommand
|
||||
expandedArg = args;
|
||||
}
|
||||
|
||||
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
if (expandedArg.length > 1 && (user == null || Permissions.DELHOME_OTHERS.isAuthorized(user)))
|
||||
{
|
||||
user = getPlayer(server, expandedArg, 0, true);
|
||||
user = getPlayer(expandedArg, 0, true);
|
||||
name = expandedArg[1];
|
||||
}
|
||||
else if (user == null)
|
||||
@@ -54,7 +52,8 @@ public class Commanddelhome extends EssentialsCommand
|
||||
/*
|
||||
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
|
||||
*/
|
||||
user.delHome(name.toLowerCase(Locale.ENGLISH));
|
||||
user.acquireWriteLock();
|
||||
user.getData().removeHome(name.toLowerCase(Locale.ENGLISH));
|
||||
sender.sendMessage(_("deleteHome", name));
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddeljail extends EssentialsCommand
|
||||
{
|
||||
public Commanddeljail()
|
||||
{
|
||||
super("deljail");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,25 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
public Commanddelwarp()
|
||||
{
|
||||
super("delwarp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
ess.getWarps().removeWarp(args[0]);
|
||||
sender.sendMessage(_("deleteWarp", args[0]));
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commanddepth extends EssentialsCommand
|
||||
{
|
||||
public Commanddepth()
|
||||
{
|
||||
super("depth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int depth = user.getLocation().getBlockY() - 63;
|
||||
if (depth > 0)
|
||||
|
@@ -1,22 +1,18 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
public Commandeco()
|
||||
{
|
||||
super("eco");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -38,7 +34,7 @@ public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User player = ess.getUser(sUser);
|
||||
final IUser player = ess.getUser(sUser);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -53,7 +49,10 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +61,7 @@ public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -78,14 +77,17 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final User player = getPlayer(server, args, 1, true);
|
||||
final IUser player = getPlayer(args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -101,7 +103,9 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
@Cleanup ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,23 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import com.earth2me.essentials.bukkit.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.EnchantPermissions;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandenchant extends EssentialsCommand
|
||||
{
|
||||
public Commandenchant()
|
||||
{
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null)
|
||||
@@ -32,7 +30,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
|
||||
{
|
||||
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
if (enchantmentslist.contains(enchantmentName) || EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
{
|
||||
enchantmentslist.add(entry.getKey());
|
||||
//enchantmentslist.add(enchantmentName);
|
||||
@@ -78,7 +76,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(final String name, final User user) throws Exception
|
||||
public static Enchantment getEnchantment(final String name, final IUser user) throws Exception
|
||||
{
|
||||
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
@@ -87,7 +85,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
throw new Exception(_("enchantmentNotFound"));
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
if (user != null && !EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -10,7 +9,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@@ -19,26 +17,23 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
public Commandessentials()
|
||||
{
|
||||
super("essentials");
|
||||
}
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0) {
|
||||
run_disabled(server, sender, commandLabel, args);
|
||||
if (args.length == 0)
|
||||
{
|
||||
run_disabled(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("debug"))
|
||||
{
|
||||
run_debug(server, sender, commandLabel, args);
|
||||
run_debug(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("nya"))
|
||||
{
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
run_nya(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("moo"))
|
||||
{
|
||||
@@ -51,17 +46,22 @@ public class Commandessentials extends EssentialsCommand
|
||||
else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
run_reload(sender, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_disabled(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
sender.sendMessage(_("blockList"));
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet())
|
||||
{
|
||||
if (disabledCommands.length() > 0)
|
||||
{
|
||||
if (disabledCommands.length() > 0) {
|
||||
disabledCommands.append(", ");
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
@@ -69,19 +69,19 @@ public class Commandessentials extends EssentialsCommand
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_debug(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_reload(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.reload();
|
||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_nya(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
@@ -125,7 +125,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
if (loc.getBlock().getTypeId() == 0)
|
||||
{
|
||||
noteBlocks.put(player, loc.getBlock());
|
||||
loc.getBlock().setType(Material.NOTE_BLOCK);
|
||||
player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0);
|
||||
}
|
||||
}
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
@@ -161,7 +161,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
ess.getServer().getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
if (block.getType() == Material.NOTE_BLOCK)
|
||||
|
@@ -1,32 +1,26 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandext extends EssentialsCommand
|
||||
{
|
||||
public Commandext()
|
||||
{
|
||||
super("ext");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
extinguishPlayers(server, sender, args[0]);
|
||||
extinguishPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -35,10 +29,10 @@ public class Commandext extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
extinguishPlayers(server, user, commandLabel);
|
||||
extinguishPlayers(user, args[0]);
|
||||
}
|
||||
|
||||
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
|
||||
private void extinguishPlayers(final CommandSender sender, final String name) throws Exception
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
|
@@ -1,26 +1,21 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandfeed extends EssentialsCommand
|
||||
{
|
||||
public Commandfeed()
|
||||
{
|
||||
super("feed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
|
||||
if (args.length > 0 && Permissions.FEED_OTHERS.isAuthorized(user))
|
||||
{
|
||||
feedOtherPlayers(server,user,args[0]);
|
||||
feedOtherPlayers(user, args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,7 +25,7 @@ public class Commandfeed extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void feedOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -9,13 +8,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class Commandfireball extends EssentialsCommand
|
||||
{
|
||||
public Commandfireball()
|
||||
{
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean small = false;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
|
||||
@@ -23,7 +17,7 @@ public class Commandfireball extends EssentialsCommand
|
||||
small = true;
|
||||
}
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
final Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
fireball.setShooter(user.getBase());
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +1,33 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgamemode extends EssentialsCommand
|
||||
{
|
||||
public Commandgamemode()
|
||||
{
|
||||
super("gamemode");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
gamemodeOtherPlayers(server, sender, args);
|
||||
gamemodeOtherPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GAMEMODE_OTHERS.isAuthorized(user))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args);
|
||||
gamemodeOtherPlayers(user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,11 +35,11 @@ public class Commandgamemode extends EssentialsCommand
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
private void gamemodeOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
final IUser player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
|
@@ -9,13 +9,8 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
public Commandgc()
|
||||
{
|
||||
super("gc");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
float tps = ess.getTimer().getAverageTPS();
|
||||
ChatColor color;
|
||||
|
@@ -1,24 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandgetpos extends EssentialsCommand
|
||||
{
|
||||
public Commandgetpos()
|
||||
{
|
||||
super("getpos");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
||||
if (args.length > 0 && Permissions.GETPOS_OTHERS.isAuthorized(user))
|
||||
{
|
||||
final User otherUser = getPlayer(server, args, 0);
|
||||
final IUser otherUser = getPlayer(args, 0);
|
||||
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
@@ -30,13 +25,13 @@ public class Commandgetpos extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0);
|
||||
final IUser user = getPlayer(args, 0);
|
||||
outputPosition(sender, user.getLocation(), null);
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,12 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.GivePermissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,35 +15,24 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
public Commandgive()
|
||||
{
|
||||
super("give");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
final IUser giveTo = getPlayer(args, 0);
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1], giveTo);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (sender instanceof Player
|
||||
&& (ess.getSettings().permissionBasedItemSpawn()
|
||||
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all")
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + itemname)
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + stack.getTypeId()))
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
if (!GivePermissions.getPermission(stack.getType()).isAuthorized(sender))
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
@@ -54,14 +42,6 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 3)
|
||||
{
|
||||
@@ -72,7 +52,7 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser(sender) : null);
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser((Player)sender) : null);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
@@ -91,17 +71,11 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
giveTo.giveItems(stack, false);
|
||||
|
||||
//TODO: TL this.
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
||||
}
|
||||
giveTo.updateInventory();
|
||||
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user