diff --git a/.classpath b/.classpath
deleted file mode 100644
index db361119a..000000000
--- a/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index eda2b5917..5846e1e28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
-*.iml
-/EssentialsGroupManager/bin
-/EssentialsGroupManager/.externalToolBuilders
\ No newline at end of file
+
+# intellij
+*.iml
+*.ipr
+*.iws
+.idea/
diff --git a/.project b/.project
deleted file mode 100644
index 2c69e0560..000000000
--- a/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Essentials
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/BuildAll/build.xml b/BuildAll/build.xml
deleted file mode 100644
index d41b561fd..000000000
--- a/BuildAll/build.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project BuildAll.
-
-
-
diff --git a/BuildAll/nbproject/build-impl.xml b/BuildAll/nbproject/build-impl.xml
deleted file mode 100644
index 1f8bcbaae..000000000
--- a/BuildAll/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1190 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/BuildAll/nbproject/genfiles.properties b/BuildAll/nbproject/genfiles.properties
deleted file mode 100644
index 8068c7fc0..000000000
--- a/BuildAll/nbproject/genfiles.properties
+++ /dev/null
@@ -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
diff --git a/BuildAll/nbproject/project.properties b/BuildAll/nbproject/project.properties
deleted file mode 100644
index 246ea1240..000000000
--- a/BuildAll/nbproject/project.properties
+++ /dev/null
@@ -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
diff --git a/BuildAll/nbproject/project.xml b/BuildAll/nbproject/project.xml
deleted file mode 100644
index 420233ac9..000000000
--- a/BuildAll/nbproject/project.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- BuildAll
-
-
-
-
-
-
-
-
- ..\lib\nblibraries.properties
-
-
-
- Essentials
- jar
-
- jar
- clean
- jar
-
-
- EssentialsChat
- jar
-
- jar
- clean
- jar
-
-
- EssentialsGeoIP
- jar
-
- jar
- clean
- jar
-
-
- EssentialsGroupBridge
- jar
-
- jar
- clean
- jar
-
-
- EssentialsGroupManager
- jar
-
- jar
- clean
- jar
-
-
- EssentialsProtect
- jar
-
- jar
- clean
- jar
-
-
- EssentialsSpawn
- jar
-
- jar
- clean
- jar
-
-
- EssentialsXMPP
- jar
-
- jar
- clean
- jar
-
-
-
-
diff --git a/Essentials/build.xml b/Essentials/build.xml
deleted file mode 100644
index a0a5a2fa2..000000000
--- a/Essentials/build.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Essentials.
-
-
-
-
diff --git a/Essentials/nbproject/build-impl.xml b/Essentials/nbproject/build-impl.xml
deleted file mode 100644
index f79ca7e26..000000000
--- a/Essentials/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1092 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Essentials/nbproject/genfiles.properties b/Essentials/nbproject/genfiles.properties
deleted file mode 100644
index 8d631fddf..000000000
--- a/Essentials/nbproject/genfiles.properties
+++ /dev/null
@@ -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
diff --git a/Essentials/nbproject/pmd.settings b/Essentials/nbproject/pmd.settings
deleted file mode 100644
index 29baf7ea1..000000000
--- a/Essentials/nbproject/pmd.settings
+++ /dev/null
@@ -1,3 +0,0 @@
-DoNotUseThreads
-LongVariable
-SignatureDeclareThrowsException
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
deleted file mode 100644
index 7a5ffe7bb..000000000
--- a/Essentials/nbproject/project.properties
+++ /dev/null
@@ -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
diff --git a/Essentials/nbproject/project.xml b/Essentials/nbproject/project.xml
deleted file mode 100644
index ac9690fc3..000000000
--- a/Essentials/nbproject/project.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Essentials
-
-
-
-
-
-
-
-
- ../lib/nblibraries.properties
-
-
-
- EssentialsGroupManager
- jar
-
- jar
- clean
- jar
-
-
-
-
diff --git a/Essentials/pom.xml b/Essentials/pom.xml
new file mode 100644
index 000000000..76d9eeb04
--- /dev/null
+++ b/Essentials/pom.xml
@@ -0,0 +1,95 @@
+
+
+ 4.0.0
+
+
+ net.essentials3
+ BuildAll
+ 3.0-SNAPSHOT
+ ../pom.xml
+
+
+ Essentials
+
+
+ com.platymuus.bukkit
+ BukkitPermissions
+ 1.2
+
+
+ org.bukkit
+ craftbukkit
+ ${bukkit.version}
+
+
+ ${project.groupId}
+ EssentialsGroupManager
+ ${project.version}
+
+
+ junit
+ junit
+ 4.10
+ test
+
+
+ org.projectlombok
+ lombok
+ 0.10.8
+
+
+ ru.tehkode
+ PermissionsEx
+ 1.15
+
+
+
+ cosine
+ BOSEconomy
+ 0.7
+
+
+ de.bananaco
+ bPermissions
+ 1.7.3
+
+
+ de.bananaco
+ bPermissions2
+ 2.8.6
+
+
+ com.nijiko.coelho
+ iConomy
+ 4.65
+
+
+ com.iConomy
+ iConomy
+ 5.0
+
+
+ com.iCo6
+ iConomy
+ 6.0
+
+
+ me.ashtheking
+ MultiCurrency
+ 0.05
+
+
+ net.krinsoft
+ Privileges
+ 1.3
+
+
+ net.milkbowl
+ Vault
+ 1.2
+
+
+
diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java
deleted file mode 100644
index e75644ad5..000000000
--- a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java
+++ /dev/null
@@ -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> altcommands = new HashMap>();
- private final transient Map disabledList = new HashMap();
- 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 commands = PluginCommandYamlParser.parse(plugin);
- final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
-
- for (Command command : commands)
- {
- final PluginCommand pc = (PluginCommand)command;
- final List labels = new ArrayList(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 plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
- if (plugincommands == null)
- {
- plugincommands = new ArrayList();
- 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>> iterator = altcommands.entrySet().iterator();
- while (iterator.hasNext())
- {
- final Map.Entry> entry = iterator.next();
- final Iterator 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 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 disabledCommands()
- {
- return disabledList;
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java
deleted file mode 100644
index baa90e561..000000000
--- a/Essentials/src/com/earth2me/essentials/Backup.java
+++ /dev/null
@@ -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"));
- }
- });
- }
- }
- });
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Console.java b/Essentials/src/com/earth2me/essentials/Console.java
index d07171c63..2e43883cf 100644
--- a/Essentials/src/com/earth2me/essentials/Console.java
+++ b/Essentials/src/com/earth2me/essentials/Console.java
@@ -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;
}
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 5b6236c30..dc63d3020 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -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 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 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 vanishedPlayers = new ArrayList();
@@ -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();
- settings = new Settings(this);
- confList.add(settings);
+ //final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
+ //upgrade.beforeSettings();
+ //execTimer.mark("Upgrade");
+ reloadList = new ArrayList();
+ 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 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("", 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 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 getVanishedPlayers()
+ public ICommandHandler getCommandHandler()
{
- return vanishedPlayers;
+ return commandHandler;
}
- private static class EssentialsWorldListener implements Listener, Runnable
+ @Override
+ public void setRanks(final IRanks groups)
{
- private transient final IEssentials ess;
+ this.groups = groups;
+ }
- public EssentialsWorldListener(final IEssentials ess)
- {
- this.ess = ess;
- }
+ @Override
+ public void removeReloadListener(IReload groups)
+ {
+ this.reloadList.remove(groups);
+ }
- @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();
- }
- }
- }
-
- @Override
- public void run()
- {
- ess.reload();
- }
+ @Override
+ public IEconomy getEconomy()
+ {
+ return economy;
}
}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
deleted file mode 100644
index 551833fc0..000000000
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ /dev/null
@@ -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 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 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 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 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);
- }
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
deleted file mode 100644
index 2ec8538ca..000000000
--- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
+++ /dev/null
@@ -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();
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index 95cf77521..34aecddc0 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -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 onlineUsers = new HashSet();
+ private final transient Set onlineUsers = new HashSet();
private transient long lastPoll = System.currentTimeMillis();
private final transient LinkedList history = new LinkedList();
@@ -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 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 iterator = onlineUsers.iterator();
+ final Iterator 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;
}
diff --git a/Essentials/src/com/earth2me/essentials/I18n.java b/Essentials/src/com/earth2me/essentials/I18n.java
index 97d500a6a..de4afec94 100644
--- a/Essentials/src/com/earth2me/essentials/I18n.java
+++ b/Essentials/src/com/earth2me/essentials/I18n.java
@@ -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;
diff --git a/Essentials/src/com/earth2me/essentials/IConf.java b/Essentials/src/com/earth2me/essentials/IConf.java
deleted file mode 100644
index 580e6232f..000000000
--- a/Essentials/src/com/earth2me/essentials/IConf.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.earth2me.essentials;
-
-/**
- * @deprecated New interface will be IReload in api package
- */
-@Deprecated
-public interface IConf {
- public void reloadConfig();
-}
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
deleted file mode 100644
index f12798db3..000000000
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ /dev/null
@@ -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 getVanishedPlayers();
-}
diff --git a/Essentials/src/com/earth2me/essentials/IReplyTo.java b/Essentials/src/com/earth2me/essentials/IReplyTo.java
deleted file mode 100644
index 5bef5fced..000000000
--- a/Essentials/src/com/earth2me/essentials/IReplyTo.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.earth2me.essentials;
-
-import org.bukkit.command.CommandSender;
-
-public interface IReplyTo {
- public void setReplyTo(CommandSender user);
-
- public CommandSender getReplyTo();
-}
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
deleted file mode 100644
index 3c6763cbe..000000000
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ /dev/null
@@ -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 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 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 itemSpawnBlacklist();
-
- List 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 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();
-}
diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java
deleted file mode 100644
index bfa9ed146..000000000
--- a/Essentials/src/com/earth2me/essentials/IUser.java
+++ /dev/null
@@ -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);
-}
diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java
index e3df50bab..cfcc00dd2 100644
--- a/Essentials/src/com/earth2me/essentials/ItemDb.java
+++ b/Essentials/src/com/earth2me/essentials/ItemDb.java
@@ -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 items = new HashMap();
- private final transient Map durabilities = new HashMap();
+ private final transient Map items = new HashMap();
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 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)
diff --git a/Essentials/src/com/earth2me/essentials/Jails.java b/Essentials/src/com/earth2me/essentials/Jails.java
index 0aa90e08c..53bef54c4 100644
--- a/Essentials/src/com/earth2me/essentials/Jails.java
+++ b/Essentials/src/com/earth2me/essentials/Jails.java
@@ -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());
+ getData().setJails(new HashMap());
}
- 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 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 getItems(final User user, final Map kit) throws Exception
- {
- if (kit == null)
- {
- throw new Exception(_("kitError2"));
- }
-
- try
- {
- return (List)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 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 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);
- }
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Kits.java b/Essentials/src/com/earth2me/essentials/Kits.java
new file mode 100644
index 000000000..3c3e61a5d
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/Kits.java
@@ -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 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 itemList = kit.getItems();
+ user.giveItems(itemList, true);
+ }
+
+ @Override
+ public Collection getList() throws Exception
+ {
+ acquireReadLock();
+ try
+ {
+ if (getData().getKits() == null)
+ {
+ return Collections.emptyList();
+ }
+ return new ArrayList(getData().getKits().keySet());
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return getData().getKits().isEmpty();
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
deleted file mode 100644
index c6230f5e0..000000000
--- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
+++ /dev/null
@@ -1,1054 +0,0 @@
-package com.earth2me.essentials;
-
-import static com.earth2me.essentials.I18n._;
-import java.net.InetSocketAddress;
-import java.util.*;
-import lombok.Delegate;
-import org.bukkit.*;
-import org.bukkit.block.Block;
-import org.bukkit.conversations.Conversation;
-import org.bukkit.conversations.ConversationAbandonedEvent;
-import org.bukkit.entity.*;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryView;
-import org.bukkit.inventory.InventoryView.Property;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
-import org.bukkit.map.MapView;
-import org.bukkit.metadata.MetadataValue;
-import org.bukkit.permissions.Permission;
-import org.bukkit.permissions.PermissionAttachment;
-import org.bukkit.permissions.PermissionAttachmentInfo;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-import org.bukkit.util.Vector;
-
-public class OfflinePlayer implements Player
-{
- private final transient IEssentials ess;
- private transient Location location = new Location(null, 0, 0, 0, 0, 0);
- private transient World world;
- private final transient UUID uniqueId = UUID.randomUUID();
- @Delegate(types = org.bukkit.OfflinePlayer.class)
- private transient org.bukkit.OfflinePlayer base;
-
- public OfflinePlayer(final String name, final IEssentials ess)
- {
- this.ess = ess;
- this.world = ess.getServer().getWorlds().get(0);
- this.base = ess.getServer().getOfflinePlayer(name);
- }
-
- @Override
- public void sendMessage(final String string)
- {
- }
-
- @Override
- public String getDisplayName()
- {
- return base.getName();
- }
-
- @Override
- public void setDisplayName(String string)
- {
- }
-
- @Override
- public void setCompassTarget(Location lctn)
- {
- }
-
- @Override
- public InetSocketAddress getAddress()
- {
- return null;
- }
-
- @Override
- public void kickPlayer(String string)
- {
- }
-
- @Override
- public PlayerInventory getInventory()
- {
- return null;
- }
-
- @Override
- public ItemStack getItemInHand()
- {
- return null;
- }
-
- @Override
- public void setItemInHand(ItemStack is)
- {
- }
-
- @Override
- public int getHealth()
- {
- return 0;
- }
-
- @Override
- public void setHealth(int i)
- {
- }
-
- @Override
- public Egg throwEgg()
- {
- return null;
- }
-
- @Override
- public Snowball throwSnowball()
- {
- return null;
- }
-
- @Override
- public Arrow shootArrow()
- {
- return null;
- }
-
- @Override
- public boolean isInsideVehicle()
- {
- return false;
- }
-
- @Override
- public boolean leaveVehicle()
- {
- return false;
- }
-
- @Override
- public Vehicle getVehicle()
- {
- return null;
- }
-
- @Override
- public Location getLocation()
- {
- return location;
- }
-
- @Override
- public World getWorld()
- {
- return world;
- }
-
- public void setLocation(Location loc)
- {
- location = loc;
- world = loc.getWorld();
- }
-
- public void teleportTo(Location lctn)
- {
- }
-
- public void teleportTo(Entity entity)
- {
- }
-
- @Override
- public int getEntityId()
- {
- return -1;
- }
-
- @Override
- public boolean performCommand(String string)
- {
- return false;
- }
-
- @Override
- public int getRemainingAir()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setRemainingAir(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getMaximumAir()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setMaximumAir(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean isSneaking()
- {
- return false;
- }
-
- @Override
- public void setSneaking(boolean bln)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void updateInventory()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void chat(String string)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public double getEyeHeight()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public double getEyeHeight(boolean bln)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public List getLineOfSight(HashSet hs, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Block getTargetBlock(HashSet hs, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public List getLastTwoTargetBlocks(HashSet hs, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getFireTicks()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getMaxFireTicks()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setFireTicks(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Server getServer()
- {
- return ess == null ? null : ess.getServer();
- }
-
- public Vector getMomentum()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- public void setMomentum(Vector vector)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setVelocity(Vector vector)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Vector getVelocity()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void damage(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void damage(int i, Entity entity)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Location getEyeLocation()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void sendRawMessage(String string)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Location getCompassTarget()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getMaximumNoDamageTicks()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setMaximumNoDamageTicks(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getLastDamage()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setLastDamage(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getNoDamageTicks()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setNoDamageTicks(int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean teleport(Location lctn)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean teleport(Entity entity)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public Entity getPassenger()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean setPassenger(Entity entity)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean isEmpty()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean eject()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void saveData()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void loadData()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean isSleeping()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public int getSleepTicks()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public List getNearbyEntities(double d, double d1, double d2)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean isDead()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public float getFallDistance()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setFallDistance(float f)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setSleepingIgnored(boolean bln)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean isSleepingIgnored()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void awardAchievement(Achievement a)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void incrementStatistic(Statistic ststc)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void incrementStatistic(Statistic ststc, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void incrementStatistic(Statistic ststc, Material mtrl)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void incrementStatistic(Statistic ststc, Material mtrl, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void playNote(Location lctn, byte b, byte b1)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void sendBlockChange(Location lctn, Material mtrl, byte b)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void sendBlockChange(Location lctn, int i, byte b)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void setLastDamageCause(EntityDamageEvent ede)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public EntityDamageEvent getLastDamageCause()
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public void playEffect(Location lctn, Effect effect, int i)
- {
- throw new UnsupportedOperationException(_("notSupportedYet"));
- }
-
- @Override
- public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
- {
- return true;
- }
-
- @Override
- public UUID getUniqueId()
- {
- return uniqueId;
- }
-
- @Override
- public void playNote(Location lctn, Instrument i, Note note)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setPlayerTime(long l, boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public long getPlayerTime()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public long getPlayerTimeOffset()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isPlayerTimeRelative()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void resetPlayerTime()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isPermissionSet(String string)
- {
- return false;
- }
-
- @Override
- public boolean isPermissionSet(Permission prmsn)
- {
- return false;
- }
-
- @Override
- public boolean hasPermission(String string)
- {
- return false;
- }
-
- @Override
- public boolean hasPermission(Permission prmsn)
- {
- return false;
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin, int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void removeAttachment(PermissionAttachment pa)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void recalculatePermissions()
- {
- }
-
- @Override
- public Set getEffectivePermissions()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void sendMap(MapView mv)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public GameMode getGameMode()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setGameMode(GameMode gm)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getLevel()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setLevel(int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getTotalExperience()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTotalExperience(int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public float getExhaustion()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setExhaustion(float f)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public float getSaturation()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSaturation(float f)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getFoodLevel()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setFoodLevel(int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isSprinting()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSprinting(boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setPlayerListName(String name)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getPlayerListName()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getTicksLived()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTicksLived(int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getMaxHealth()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void giveExp(int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public float getExp()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setExp(float f)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean teleport(Location lctn, TeleportCause tc)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean teleport(Entity entity, TeleportCause tc)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Player getKiller()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- void setName(final String name)
- {
- if (!this.base.getName().equalsIgnoreCase(name))
- {
- this.base = ess.getServer().getOfflinePlayer(name);
- }
- }
-
- @Override
- public void sendPluginMessage(Plugin plugin, String string, byte[] bytes)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Set getListeningPluginChannels()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setAllowFlight(boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean getAllowFlight()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setBedSpawnLocation(Location lctn)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void playEffect(EntityEffect ee)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void hidePlayer(Player player)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void showPlayer(Player player)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean canSee(Player player)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean addPotionEffect(PotionEffect pe)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean addPotionEffect(PotionEffect pe, boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean addPotionEffects(Collection clctn)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean hasPotionEffect(PotionEffectType pet)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void removePotionEffect(PotionEffectType pet)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Collection getActivePotionEffects()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public T launchProjectile(Class extends T> arg0)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public EntityType getType()
- {
- return EntityType.PLAYER;
- }
-
- @Override
- public void playEffect(Location lctn, Effect effect, T t)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean setWindowProperty(Property prprt, int i)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public InventoryView getOpenInventory()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public InventoryView openInventory(Inventory invntr)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public InventoryView openWorkbench(Location lctn, boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public InventoryView openEnchanting(Location lctn, boolean bln)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void openInventory(InventoryView iv)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void closeInventory()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public ItemStack getItemOnCursor()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setItemOnCursor(ItemStack is)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setMetadata(String string, MetadataValue mv)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public List getMetadata(String string)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean hasMetadata(String string)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void removeMetadata(String string, Plugin plugin)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
-
- @Override
- public boolean isConversing()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void acceptConversationInput(String string)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean beginConversation(Conversation c)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void abandonConversation(Conversation c)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void sendMessage(String[] strings)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isBlocking()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isFlying()
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setFlying(boolean arg0)
- {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/PlayerExtension.java b/Essentials/src/com/earth2me/essentials/PlayerExtension.java
deleted file mode 100644
index 7c52e40d1..000000000
--- a/Essentials/src/com/earth2me/essentials/PlayerExtension.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
deleted file mode 100644
index b1352b6c3..000000000
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ /dev/null
@@ -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 getMultipleHomes()
- {
- return config.getConfigurationSection("sethome-multiple").getKeys(false);
- }
-
- @Override
- public int getHomeLimit(final User user)
- {
- final Set 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 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 chatFormats = new HashMap();
-
- @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(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 itemSpawnBl = new ArrayList();
-
- @Override
- public List itemSpawnBlacklist()
- {
- return itemSpawnBl;
- }
-
- private List _getItemSpawnBlacklist()
- {
- final List epItemSpwn = new ArrayList();
- 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 enabledSigns = new ArrayList();
- private boolean signsEnabled = false;
-
- @Override
- public List enabledSigns()
- {
- return enabledSigns;
- }
-
- private List _getEnabledSigns()
- {
- List newSigns = new ArrayList();
-
- 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 getProtectList(final String configName)
- {
- final List list = new ArrayList();
- 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 noGodWorlds = new HashSet();
-
- @Override
- public Set 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;
- }
-
-}
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index 6569a1689..7118ed1bb 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -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
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
deleted file mode 100644
index f9206206a..000000000
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ /dev/null
@@ -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, 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());
- }
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
deleted file mode 100644
index c994eeed5..000000000
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ /dev/null
@@ -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 homes;
-
- private Map _getHomes()
- {
- if (config.isConfigurationSection("homes"))
- {
- return config.getConfigurationSection("homes").getValues(false);
- }
- return new HashMap();
- }
-
- 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 getHomes()
- {
- return new ArrayList(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 unlimited;
-
- private List _getUnlimited()
- {
- return config.getIntegerList("unlimited");
- }
-
- public List 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 powertools;
-
- private Map _getPowertools()
- {
- if (config.isConfigurationSection("powertools"))
- {
- return config.getConfigurationSection("powertools").getValues(false);
- }
- return new HashMap();
- }
-
- public void clearAllPowertools()
- {
- powertools.clear();
- config.setProperty("powertools", powertools);
- config.save();
- }
-
- @SuppressWarnings("unchecked")
- public List getPowertool(ItemStack stack)
- {
- return (List)powertools.get("" + stack.getTypeId());
- }
-
- @SuppressWarnings("unchecked")
- public List getPowertool(int id)
- {
- return (List)powertools.get("" + id);
- }
-
- public void setPowertool(ItemStack stack, List 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 mails;
-
- private List _getMails()
- {
- return config.getStringList("mail");
- }
-
- public List getMails()
- {
- return mails;
- }
-
- public void setMails(List 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 ignoredPlayers;
-
- public List getIgnoredPlayers()
- {
- return config.getStringList("ignore");
- }
-
- public void setIgnoredPlayers(List players)
- {
- if (players == null || players.isEmpty())
- {
- ignoredPlayers = new ArrayList();
- 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 kitTimestamps;
-
- private Map _getKitTimestamps()
- {
-
- if (config.isConfigurationSection("timestamps.kits"))
- {
- return config.getConfigurationSection("timestamps.kits").getValues(false);
- }
- return new HashMap();
- }
-
- 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();
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java
deleted file mode 100644
index 94b504241..000000000
--- a/Essentials/src/com/earth2me/essentials/UserMap.java
+++ /dev/null
@@ -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 implements IConf
-{
- private final transient IEssentials ess;
- private final transient Cache users = CacheBuilder.newBuilder().softValues().build(this);
- private final transient ConcurrentSkipListSet keys = new ConcurrentSkipListSet();
-
- 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 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");
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
deleted file mode 100644
index 112477ecb..000000000
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ /dev/null
@@ -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 AIR_MATERIALS = new HashSet();
- private static final HashSet AIR_MATERIALS_TARGET = new HashSet();
-
- 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");
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Warps.java b/Essentials/src/com/earth2me/essentials/Warps.java
index ece987aba..bbf01678b 100644
--- a/Essentials/src/com/earth2me/essentials/Warps.java
+++ b/Essentials/src/com/earth2me/essentials/Warps.java
@@ -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 implements IWarps
{
- private static final Logger logger = Logger.getLogger("Minecraft");
- private final Map warpPoints = new HashMap();
- 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 getWarpNames()
- {
- final List keys = new ArrayList();
- 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 getList()
+ {
+ final List names = new ArrayList();
+ for (String key : getAllKeys())
{
- for (int i = 0; i < listOfFiles.length; i++)
+ IWarp warp = getObject(key);
+ if (warp == null)
{
- String filename = listOfFiles[i].getName();
- if (listOfFiles[i].isFile() && filename.endsWith(".yml"))
- {
- try
- {
- EssentialsConf conf = new EssentialsConf(listOfFiles[i]);
- conf.load();
- String name = conf.getString("name");
- if (name != null)
- {
- warpPoints.put(new StringIgnoreCase(name), conf);
- }
- }
- catch (Exception ex)
- {
- logger.log(Level.WARNING, _("loadWarpError", filename), ex);
- }
- }
+ continue;
+ }
+ warp.acquireReadLock();
+ try
+ {
+ names.add(warp.getData().getName());
+ }
+ finally
+ {
+ warp.unlock();
}
}
+ Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
+ return names;
+ }
+
+ @Override
+ public Location getWarp(final String name) throws Exception
+ {
+ 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;
}
diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java
deleted file mode 100644
index b597bd3e8..000000000
--- a/Essentials/src/com/earth2me/essentials/Worth.java
+++ /dev/null
@@ -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();
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/ChargeException.java b/Essentials/src/com/earth2me/essentials/api/ChargeException.java
similarity index 86%
rename from Essentials/src/com/earth2me/essentials/ChargeException.java
rename to Essentials/src/com/earth2me/essentials/api/ChargeException.java
index 2fa4c7289..5b157ce63 100644
--- a/Essentials/src/com/earth2me/essentials/ChargeException.java
+++ b/Essentials/src/com/earth2me/essentials/api/ChargeException.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials;
+package com.earth2me.essentials.api;
public class ChargeException extends Exception
diff --git a/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java
deleted file mode 100644
index 11619bca4..000000000
--- a/Essentials/src/com/earth2me/essentials/api/IAlternativeCommandsHandler.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.earth2me.essentials.api;
-
-import java.util.Map;
-import org.bukkit.command.PluginCommand;
-
-
-public interface IAlternativeCommandsHandler
-{
- Map disabledCommands();
-}
diff --git a/Essentials/src/com/earth2me/essentials/api/IBackup.java b/Essentials/src/com/earth2me/essentials/api/IBackup.java
new file mode 100644
index 000000000..8af074c54
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IBackup.java
@@ -0,0 +1,7 @@
+package com.earth2me.essentials.api;
+
+
+public interface IBackup extends Runnable
+{
+ public void startTask();
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/ICommandHandler.java b/Essentials/src/com/earth2me/essentials/api/ICommandHandler.java
new file mode 100644
index 000000000..f756c16c4
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/ICommandHandler.java
@@ -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 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);
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IEconomy.java b/Essentials/src/com/earth2me/essentials/api/IEconomy.java
new file mode 100644
index 000000000..092d86c88
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IEconomy.java
@@ -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;
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentials.java b/Essentials/src/com/earth2me/essentials/api/IEssentials.java
index c04bed0bd..42c9a964d 100644
--- a/Essentials/src/com/earth2me/essentials/api/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/api/IEssentials.java
@@ -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();
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java b/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java
deleted file mode 100644
index 72fb89d26..000000000
--- a/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java
+++ /dev/null
@@ -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;
-}
diff --git a/Essentials/src/com/earth2me/essentials/IEssentialsModule.java b/Essentials/src/com/earth2me/essentials/api/IEssentialsModule.java
similarity index 52%
rename from Essentials/src/com/earth2me/essentials/IEssentialsModule.java
rename to Essentials/src/com/earth2me/essentials/api/IEssentialsModule.java
index 69a1a494c..cc185980a 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentialsModule.java
+++ b/Essentials/src/com/earth2me/essentials/api/IEssentialsModule.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials;
+package com.earth2me.essentials.api;
public interface IEssentialsModule
diff --git a/Essentials/src/com/earth2me/essentials/api/IItemDb.java b/Essentials/src/com/earth2me/essentials/api/IItemDb.java
index ee4819215..29f97488c 100644
--- a/Essentials/src/com/earth2me/essentials/api/IItemDb.java
+++ b/Essentials/src/com/earth2me/essentials/api/IItemDb.java
@@ -3,9 +3,11 @@ 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;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IJails.java b/Essentials/src/com/earth2me/essentials/api/IJails.java
index e19b76837..fb8d2f090 100644
--- a/Essentials/src/com/earth2me/essentials/api/IJails.java
+++ b/Essentials/src/com/earth2me/essentials/api/IJails.java
@@ -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;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IKits.java b/Essentials/src/com/earth2me/essentials/api/IKits.java
new file mode 100644
index 000000000..85ca4cdea
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IKits.java
@@ -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 getList() throws Exception;
+
+ boolean isEmpty();
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IPermission.java b/Essentials/src/com/earth2me/essentials/api/IPermission.java
new file mode 100644
index 000000000..d388bff47
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IPermission.java
@@ -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();
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IRanks.java b/Essentials/src/com/earth2me/essentials/api/IRanks.java
new file mode 100644
index 000000000..e29b31302
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IRanks.java
@@ -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);
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IReplyTo.java b/Essentials/src/com/earth2me/essentials/api/IReplyTo.java
new file mode 100644
index 000000000..3003ca3df
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IReplyTo.java
@@ -0,0 +1,11 @@
+package com.earth2me.essentials.api;
+
+import org.bukkit.command.CommandSender;
+
+
+public interface IReplyTo
+{
+ void setReplyTo(CommandSender user);
+
+ CommandSender getReplyTo();
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/ISettings.java b/Essentials/src/com/earth2me/essentials/api/ISettings.java
index eff65ad87..a445d21b4 100644
--- a/Essentials/src/com/earth2me/essentials/api/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/api/ISettings.java
@@ -6,5 +6,9 @@ import com.earth2me.essentials.storage.IStorageObjectHolder;
public interface ISettings extends IStorageObjectHolder
{
-
+ public String getLocale();
+
+ public boolean isDebug();
+
+ public void setDebug(boolean b);
}
diff --git a/Essentials/src/com/earth2me/essentials/api/ITeleport.java b/Essentials/src/com/earth2me/essentials/api/ITeleport.java
index 5b9a19757..3a5f25f78 100644
--- a/Essentials/src/com/earth2me/essentials/api/ITeleport.java
+++ b/Essentials/src/com/earth2me/essentials/api/ITeleport.java
@@ -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;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IUser.java b/Essentials/src/com/earth2me/essentials/api/IUser.java
index 5d2f9d4b8..091b141df 100644
--- a/Essentials/src/com/earth2me/essentials/api/IUser.java
+++ b/Essentials/src/com/earth2me/essentials/api/IUser.java
@@ -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, IReload, IReplyTo, Comparable
{
- 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 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 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 getMails();
+
+ public boolean canAfford(double money);
+
+ public void updateMoneyCache(double userMoney);
+
+ public boolean canAfford(double amount, boolean b);
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IUserMap.java b/Essentials/src/com/earth2me/essentials/api/IUserMap.java
index 9e609ab37..fbe6cfa0e 100644
--- a/Essentials/src/com/earth2me/essentials/api/IUserMap.java
+++ b/Essentials/src/com/earth2me/essentials/api/IUserMap.java
@@ -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 getAllUniqueUsers();
int getUniqueUsers();
- File getUserFile(final String name);
+ File getUserFile(final String name) throws InvalidNameException;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IWarp.java b/Essentials/src/com/earth2me/essentials/api/IWarp.java
new file mode 100644
index 000000000..f08e5757d
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/IWarp.java
@@ -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
+{
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/IWarps.java b/Essentials/src/com/earth2me/essentials/api/IWarps.java
index 14779e327..2a98ecc64 100644
--- a/Essentials/src/com/earth2me/essentials/api/IWarps.java
+++ b/Essentials/src/com/earth2me/essentials/api/IWarps.java
@@ -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 getWarps();
+ Collection 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;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/InvalidNameException.java b/Essentials/src/com/earth2me/essentials/api/InvalidNameException.java
new file mode 100644
index 000000000..951c66b17
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/InvalidNameException.java
@@ -0,0 +1,10 @@
+package com.earth2me.essentials.api;
+
+
+public class InvalidNameException extends Exception
+{
+ public InvalidNameException(Throwable thrwbl)
+ {
+ super(thrwbl);
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/server/IPermission.java b/Essentials/src/com/earth2me/essentials/api/server/IPermission.java
new file mode 100644
index 000000000..3b5cf2eb4
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/server/IPermission.java
@@ -0,0 +1,5 @@
+package com.earth2me.essentials.api.server;
+
+public interface IPermission {
+
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/server/IPermissionsManager.java b/Essentials/src/com/earth2me/essentials/api/server/IPermissionsManager.java
new file mode 100644
index 000000000..d8f017e20
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/server/IPermissionsManager.java
@@ -0,0 +1,8 @@
+package com.earth2me.essentials.api.server;
+
+public interface IPermissionsManager {
+
+ IPermission registerPermission();
+
+ boolean checkPermission(IPlayer player, IPermission perm);
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/server/IPlayer.java b/Essentials/src/com/earth2me/essentials/api/server/IPlayer.java
new file mode 100644
index 000000000..7d0899e81
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/server/IPlayer.java
@@ -0,0 +1,5 @@
+package com.earth2me.essentials.api.server;
+
+public interface IPlayer {
+
+}
diff --git a/Essentials/src/com/earth2me/essentials/api/server/IServer.java b/Essentials/src/com/earth2me/essentials/api/server/IServer.java
new file mode 100644
index 000000000..2c267b6cb
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/server/IServer.java
@@ -0,0 +1,5 @@
+package com.earth2me.essentials.api.server;
+
+public interface IServer {
+
+}
diff --git a/Essentials/src/com/earth2me/essentials/backup/Backup.java b/Essentials/src/com/earth2me/essentials/backup/Backup.java
new file mode 100644
index 000000000..2da391af9
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/backup/Backup.java
@@ -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"));
+ }
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/Enchantments.java b/Essentials/src/com/earth2me/essentials/bukkit/Enchantments.java
similarity index 96%
rename from Essentials/src/com/earth2me/essentials/Enchantments.java
rename to Essentials/src/com/earth2me/essentials/bukkit/Enchantments.java
index ed0051c46..f8e22ccb3 100644
--- a/Essentials/src/com/earth2me/essentials/Enchantments.java
+++ b/Essentials/src/com/earth2me/essentials/bukkit/Enchantments.java
@@ -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 ENCHANTMENTS = new HashMap();
@@ -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));
diff --git a/Essentials/src/com/earth2me/essentials/bukkit/EssentialsPlugin.java b/Essentials/src/com/earth2me/essentials/bukkit/EssentialsPlugin.java
new file mode 100644
index 000000000..f58f2e5b6
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/bukkit/EssentialsPlugin.java
@@ -0,0 +1,7 @@
+package com.earth2me.essentials.bukkit;
+
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class EssentialsPlugin extends JavaPlugin {
+ //TODO
+}
diff --git a/Essentials/src/com/earth2me/essentials/Mob.java b/Essentials/src/com/earth2me/essentials/bukkit/Mob.java
similarity index 98%
rename from Essentials/src/com/earth2me/essentials/Mob.java
rename to Essentials/src/com/earth2me/essentials/bukkit/Mob.java
index 38c11a81a..3d78b2a82 100644
--- a/Essentials/src/com/earth2me/essentials/Mob.java
+++ b/Essentials/src/com/earth2me/essentials/bukkit/Mob.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials;
+package com.earth2me.essentials.bukkit;
import static com.earth2me.essentials.I18n._;
import java.util.Collections;
diff --git a/Essentials/src/com/earth2me/essentials/bukkit/Server.java b/Essentials/src/com/earth2me/essentials/bukkit/Server.java
new file mode 100644
index 000000000..1c10d9a7b
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/bukkit/Server.java
@@ -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;
+}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
index c71883571..a571ec652 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
@@ -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;
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
index 968d0012c..eea30448d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
@@ -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);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java
index d2ed98e69..e2c1b266a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java
@@ -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()))
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
index 38644c680..c00a0d435 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
@@ -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)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
index 15c3c9088..4e8b8f8af 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
@@ -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)));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
index 6c5e96b9f..1508a134f 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
@@ -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();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
index ca6707088..88c605f4e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
@@ -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));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
index 5459bd8fc..c9d4caa89 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
@@ -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"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
index 5dd22503a..aa5645c85 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
@@ -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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
index 242fa9b53..6d2d7bb04 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
@@ -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"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
index 95bb967c6..572da8f67 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
@@ -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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
index 5d8d38ce7..08b8739b5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
@@ -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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
index ef2502b9b..fea6c024f 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
@@ -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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
index 25f8c34f6..7314f8b6e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
@@ -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;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
index c4d0a6946..629d00592 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
@@ -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));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
index 5c2c957e4..9daae2fad 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
@@ -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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
index 5eab72b33..482652b15 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
@@ -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]));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
index 6c4fa2647..73d3c7150 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
@@ -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)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
index dd6d6ad0d..3269d2114 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
@@ -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;
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
index 51a909d29..114f51a4d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
@@ -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 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));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
index ca746c5a8..e2668e562 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -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 noteBlocks = new HashMap();
@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,37 +46,42 @@ 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("/ ");
sender.sendMessage(_("blockList"));
final StringBuilder disabledCommands = new StringBuilder();
- for (Map.Entry entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
+ for (Map.Entry entry : ess.getCommandHandler().disabledCommands().entrySet())
{
- if (disabledCommands.length() > 0) {
+ if (disabledCommands.length() > 0)
+ {
disabledCommands.append(", ");
}
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
}
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 noteMap = new HashMap();
noteMap.put("1F#", (byte)0x0);
@@ -108,60 +108,60 @@ public class Commandessentials extends EssentialsCommand
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
- if (!noteBlocks.isEmpty())
+ if (!noteBlocks.isEmpty())
+ {
+ return;
+ }
+ final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
+ final String[] tune = tuneStr.split(",");
+ for (Player player : server.getOnlinePlayers())
+ {
+ final Location loc = player.getLocation();
+ loc.add(0, 3, 0);
+ while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
{
- return;
+ loc.add(0, 1, 0);
}
- final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
- final String[] tune = tuneStr.split(",");
- for (Player player : server.getOnlinePlayers())
+ if (loc.getBlock().getTypeId() == 0)
{
- final Location loc = player.getLocation();
- loc.add(0, 3, 0);
- while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
- {
- loc.add(0, 1, 0);
- }
- if (loc.getBlock().getTypeId() == 0)
- {
- noteBlocks.put(player, loc.getBlock());
- loc.getBlock().setType(Material.NOTE_BLOCK);
- }
+ noteBlocks.put(player, loc.getBlock());
+ player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0);
}
- taskid = ess.scheduleSyncRepeatingTask(new Runnable()
- {
- int i = 0;
+ }
+ taskid = ess.scheduleSyncRepeatingTask(new Runnable()
+ {
+ int i = 0;
- @Override
- public void run()
+ @Override
+ public void run()
+ {
+ final String note = tune[i];
+ i++;
+ if (i >= tune.length)
{
- final String note = tune[i];
- i++;
- if (i >= tune.length)
- {
- Commandessentials.this.stopTune();
- }
- if (note.isEmpty())
- {
- return;
- }
- Map noteBlocks = Commandessentials.this.noteBlocks;
- for (Player onlinePlayer : server.getOnlinePlayers())
- {
- final Block block = noteBlocks.get(onlinePlayer);
- if (block == null || block.getType() != Material.NOTE_BLOCK)
- {
- continue;
- }
- onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
- }
+ Commandessentials.this.stopTune();
}
- }, 20, 2);
+ if (note.isEmpty())
+ {
+ return;
+ }
+ Map noteBlocks = Commandessentials.this.noteBlocks;
+ for (Player onlinePlayer : server.getOnlinePlayers())
+ {
+ final Block block = noteBlocks.get(onlinePlayer);
+ if (block == null || block.getType() != Material.NOTE_BLOCK)
+ {
+ continue;
+ }
+ onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
+ }
+ }
+ }, 20, 2);
}
private void stopTune()
{
- ess.getScheduler().cancelTask(taskid);
+ ess.getServer().getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values())
{
if (block.getType() == Material.NOTE_BLOCK)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java
index 3855e7b68..8e689506a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java
@@ -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))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
index 0c1579835..e7c8f9fe4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
@@ -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
{
@@ -29,8 +24,8 @@ public class Commandfeed extends EssentialsCommand
user.sendMessage(_("feed"));
}
}
-
- private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
+
+ private void feedOtherPlayers(final CommandSender sender, final String name)
{
final List players = server.matchPlayer(name);
if (players.isEmpty())
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
index 671d0f72b..f13f3ee75 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
@@ -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());
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
index 5fdc69d68..72153265e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
@@ -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;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
index d9b08b50f..4097c5e83 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
@@ -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;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
index c985ef725..dfccdd31c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
@@ -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);
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
index 21903e98b..aea29cbf3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
@@ -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 IUser giveTo = getPlayer(args, 0);
- final ItemStack stack = ess.getItemDb().get(args[1]);
+ 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]));
@@ -53,15 +41,7 @@ public class Commandgive extends EssentialsCommand
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
{
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)
{
@@ -90,18 +70,12 @@ 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();
+
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
index 6e611d869..037c8cb50 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
@@ -1,47 +1,42 @@
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.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandgod extends EssentialsCommand
{
- public Commandgod()
- {
- super("god");
- }
-
@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();
}
- godOtherPlayers(server, sender, args[0]);
+ godOtherPlayers(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.god.others"))
+ if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GOD_OTHERS.isAuthorized(user))
{
- godOtherPlayers(server, user, args[0]);
+ godOtherPlayers(user, args[0]);
return;
}
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
}
- private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
+ private void godOtherPlayers(final CommandSender sender, final String name)
{
for (Player matchPlayer : server.matchPlayer(name))
{
- final User player = ess.getUser(matchPlayer);
+ final IUser player = ess.getUser(matchPlayer);
if (player.isHidden())
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
index 82678c96e..fe620b390 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
@@ -1,55 +1,47 @@
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 com.earth2me.essentials.user.UserData.TimestampType;
import java.util.List;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandheal extends EssentialsCommand
{
- public Commandheal()
- {
- super("heal");
- }
-
@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.heal.others"))
+ if (args.length > 0 && Permissions.HEAL_OTHERS.isAuthorized(user))
{
- if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
- {
- user.healCooldown();
- }
- healOtherPlayers(server, user, args[0]);
+ user.checkCooldown(TimestampType.LASTHEAL, ess.getRanks().getHealCooldown(user), true, Permissions.HEAL_COOLDOWN_BYPASS);
+
+ healOtherPlayers(user, args[0]);
return;
}
- if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
- {
- user.healCooldown();
- }
+ user.checkCooldown(TimestampType.LASTHEAL, ess.getRanks().getHealCooldown(user), true, Permissions.HEAL_COOLDOWN_BYPASS);
+
user.setHealth(20);
user.setFoodLevel(20);
user.sendMessage(_("heal"));
}
@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();
}
- healOtherPlayers(server, sender, args[0]);
+ healOtherPlayers(sender, args[0]);
}
- private void healOtherPlayers(final Server server, final CommandSender sender, final String name)
+ private void healOtherPlayers(final CommandSender sender, final String name)
{
final List players = server.matchPlayer(name);
if (players.isEmpty())
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
index 6339359f1..e6fb2e2eb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
@@ -1,8 +1,13 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.utils.textreader.TextInput;
+import com.earth2me.essentials.utils.textreader.IText;
+import com.earth2me.essentials.utils.textreader.TextPager;
+import com.earth2me.essentials.utils.textreader.HelpInput;
+import com.earth2me.essentials.utils.textreader.KeywordReplacer;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.textreader.*;
import java.util.Locale;
import org.bukkit.Server;
@@ -11,13 +16,8 @@ import org.bukkit.command.CommandSender;
public class Commandhelp extends EssentialsCommand
{
- public Commandhelp()
- {
- super("help");
- }
-
@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
{
IText output;
String pageStr = args.length > 0 ? args[0] : null;
@@ -52,7 +52,7 @@ public class Commandhelp 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
{
sender.sendMessage(_("helpConsole"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
index 948cfa769..42a69b4b1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
@@ -1,22 +1,17 @@
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.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.logging.Level;
-import org.bukkit.Server;
import org.bukkit.entity.Player;
public class Commandhelpop extends EssentialsCommand
{
- public Commandhelpop()
- {
- super("helpop");
- }
-
@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)
{
@@ -27,8 +22,8 @@ public class Commandhelpop extends EssentialsCommand
logger.log(Level.INFO, message);
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(onlinePlayer);
- if (!player.isAuthorized("essentials.helpop.receive"))
+ final IUser player = ess.getUser(onlinePlayer);
+ if (!Permissions.HELPOP_RECEIVE.isAuthorized(player))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
index 2c91a06c9..27e93d39e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
@@ -1,42 +1,37 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandhome extends EssentialsCommand
{
- public Commandhome()
- {
- super("home");
- }
-
@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 Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
- User player = user;
+ IUser player = user;
String homeName = "";
String[] nameParts;
if (args.length > 0)
{
nameParts = args[0].split(":");
- if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
+ if (nameParts[0].length() == args[0].length() || !Permissions.HOME_OTHERS.isAuthorized(user))
{
homeName = nameParts[0];
}
else
{
- player = getPlayer(server, nameParts, 0, true);
+ player = getPlayer(nameParts, 0, true);
if (nameParts.length > 1)
{
homeName = nameParts[1];
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
index 93dd029a8..9b3ff71cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
@@ -1,39 +1,34 @@
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 Commandignore extends EssentialsCommand
{
- public Commandignore()
- {
- super("ignore");
- }
-
@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 < 1)
{
throw new NotEnoughArgumentsException();
}
- User player;
+ IUser player;
try
{
- player = getPlayer(server, args, 0);
+ player = getPlayer(args, 0);
}
catch (NoSuchFieldException ex)
{
- player = ess.getOfflineUser(args[0]);
+ player = ess.getUser(args[0]);
}
if (player == null)
{
throw new Exception(_("playerNotFound"));
}
final String name = player.getName();
- if (user.isIgnoredPlayer(name))
+ user.acquireWriteLock();
+ if (user.isIgnoringPlayer(name))
{
user.setIgnoredPlayer(name, false);
user.sendMessage(_("unignorePlayer", player.getName()));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
index afe1add72..924e0a74a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
@@ -1,22 +1,16 @@
package com.earth2me.essentials.commands;
-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 org.bukkit.Server;
+import com.earth2me.essentials.utils.textreader.IText;
+import com.earth2me.essentials.utils.textreader.KeywordReplacer;
+import com.earth2me.essentials.utils.textreader.TextInput;
+import com.earth2me.essentials.utils.textreader.TextPager;
import org.bukkit.command.CommandSender;
public class Commandinfo extends EssentialsCommand
{
- public Commandinfo()
- {
- super("info");
- }
-
@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 IText input = new TextInput(sender, "info", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
index a4a659e97..fd6a6a167 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
@@ -1,21 +1,16 @@
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.user.Inventory;
import java.util.Arrays;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandinvsee extends EssentialsCommand
{
- public Commandinvsee()
- {
- super("invsee");
- }
-
@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 < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index 0e35dda71..1ea96ff60 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -1,44 +1,38 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.ItemPermissions;
import java.util.Locale;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
public class Commanditem extends EssentialsCommand
{
- public Commanditem()
- {
- super("item");
- }
-
@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)
{
throw new NotEnoughArgumentsException();
}
- final ItemStack stack = ess.getItemDb().get(args[0]);
+ final ItemStack stack = ess.getItemDb().get(args[0], user);
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
- if (ess.getSettings().permissionBasedItemSpawn()
- ? (!user.isAuthorized("essentials.itemspawn.item-all")
- && !user.isAuthorized("essentials.itemspawn.item-" + itemname)
- && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId()))
- : (!user.isAuthorized("essentials.itemspawn.exempt")
- && !user.canSpawnItem(stack.getTypeId())))
+ if (!ItemPermissions.getPermission(stack.getType()).isAuthorized(user))
{
throw new Exception(_("cantSpawnItem", itemname));
}
try
{
- if (args.length > 1 && Integer.parseInt(args[1]) > 0)
+ stack.setAmount(Integer.parseInt(args[1]));
+ }
+
+ if (args.length > 2)
+ {
+ for (int i = 2; i < args.length; i++)
{
stack.setAmount(Integer.parseInt(args[1]));
}
@@ -83,16 +77,9 @@ public class Commanditem extends EssentialsCommand
throw new Exception(_("cantSpawnItem", "Air"));
}
+ user.giveItems(stack, false);
+
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
- user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
- if (user.isAuthorized("essentials.oversizedstacks"))
- {
- InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
- }
- else
- {
- InventoryWorkaround.addItem(user.getInventory(), true, stack);
- }
- user.updateInventory();
+ user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
index c35656c72..6d0a17037 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
@@ -1,6 +1,5 @@
package com.earth2me.essentials.commands;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -8,13 +7,8 @@ import org.bukkit.inventory.ItemStack;
public class Commanditemdb extends EssentialsCommand
{
- public Commanditemdb()
- {
- super("itemdb");
- }
-
@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
{
ItemStack itemStack = null;
if (args.length < 1)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
index 051bcf710..7e50c78e2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
@@ -1,19 +1,13 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.Util;
-import org.bukkit.Server;
+import com.earth2me.essentials.utils.Util;
import org.bukkit.command.CommandSender;
public class Commandjails extends EssentialsCommand
{
- public Commandjails()
- {
- super("jails");
- }
-
@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
{
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
index ab73c6e01..4d4388b84 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
@@ -1,30 +1,24 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandjump extends EssentialsCommand
{
- public Commandjump()
- {
- super("jump");
- }
-
@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
{
Location loc;
final Location cloc = user.getLocation();
try
{
- loc = Util.getTarget(user);
+ loc = LocationUtil.getTarget(user);
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);
@@ -34,7 +28,7 @@ public class Commandjump extends EssentialsCommand
throw new Exception(_("jumpError"), ex);
}
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
throw new NoChargeException();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
index 3e2e08b50..fe11efcea 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
@@ -2,29 +2,24 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
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.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandkick extends EssentialsCommand
{
- public Commandkick()
- {
- super("kick");
- }
-
@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);
- if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
+ final IUser user = getPlayer(args, 0);
+ if (Permissions.KICK_EXEMPT.isAuthorized(user))
{
throw new Exception(_("kickExempt"));
}
@@ -34,8 +29,8 @@ public class Commandkick extends EssentialsCommand
for (Player onlinePlayer : server.getOnlinePlayers())
{
- User player = ess.getUser(onlinePlayer);
- if (player.isAuthorized("essentials.kick.notify"))
+ final IUser player = ess.getUser(onlinePlayer);
+ if (Permissions.KICK_NOTIFY.isAuthorized(player))
{
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
index 4722b7d68..bd22d30c9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
@@ -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 Commandkickall extends EssentialsCommand
{
- public Commandkickall()
- {
- super("kickall");
- }
-
@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
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
index 77994f156..81e998b34 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
@@ -1,7 +1,6 @@
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;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -9,13 +8,8 @@ import org.bukkit.event.entity.EntityDamageEvent;
public class Commandkill extends EssentialsCommand
{
- public Commandkill()
- {
- super("kill");
- }
-
@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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
index d918eeffb..d8868e2c4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
@@ -1,40 +1,21 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.Mob;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.bukkit.Mob;
import java.util.Collections;
import java.util.Locale;
import org.bukkit.Chunk;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Animals;
-import org.bukkit.entity.ComplexLivingEntity;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Flying;
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Monster;
-import org.bukkit.entity.NPC;
-import org.bukkit.entity.Ocelot;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Slime;
-import org.bukkit.entity.Snowman;
-import org.bukkit.entity.WaterMob;
-import org.bukkit.entity.Wolf;
+import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDeathEvent;
public class Commandkillall extends EssentialsCommand
{
- public Commandkillall()
- {
- super("killall");
- }
-
//TODO: Tidy - missed this during command cleanup
@Override
- public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
String type = "all";
int radius = -1;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
index a545adf60..bab73b196 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
@@ -1,25 +1,39 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
-import java.util.*;
-import org.bukkit.Server;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.KitPermissions;
+import com.earth2me.essentials.settings.Kit;
+import java.util.Collection;
+import java.util.Locale;
import org.bukkit.command.CommandSender;
public class Commandkit extends EssentialsCommand
{
- public Commandkit()
- {
- super("kit");
- }
-
@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)
{
- listKits(user);
+ Collection kitList = ess.getKits().getList();
+ if (kitList.isEmpty())
+ {
+ user.sendMessage(_("noKits"));
+ }
+ else
+ {
+ for (String kitName : kitList)
+ {
+ if (!KitPermissions.getPermission(kitName).isAuthorized(user))
+ {
+ kitList.remove(kitName);
+ }
+ }
+ user.sendMessage(_("kits", Util.joinList(kitList)));
+ }
throw new NoChargeException();
}
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
@@ -47,11 +61,14 @@ public class Commandkit extends EssentialsCommand
{
final User userTo = getPlayer(server, args, 1, true);
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
+ final Kit kit = ess.getKits().getKit(kitName);
- final Map kit = ess.getSettings().getKit(kitName);
- final List items = Kit.getItems(userTo, kit);
- Kit.expandItems(ess, userTo, items);
+ if (!KitPermissions.getPermission(kitName).isAuthorized(user))
+ {
+ throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
+ }
+ //TODO: Check kit delay
sender.sendMessage(_("kitGive", kitName));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java b/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
index 9db608235..602f324ad 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
@@ -1,10 +1,17 @@
package com.earth2me.essentials.commands;
+<<<<<<< HEAD
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Server;
+=======
+import com.earth2me.essentials.bukkit.Mob;
+import com.earth2me.essentials.api.IUser;
+import java.util.Random;
+import org.bukkit.Location;
+>>>>>>> 3.0
import org.bukkit.entity.Ocelot;
@@ -12,6 +19,7 @@ public class Commandkittycannon extends EssentialsCommand
{
private static Random random = new Random();
+<<<<<<< HEAD
public Commandkittycannon()
{
super("kittycannon");
@@ -19,6 +27,10 @@ public class Commandkittycannon extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+=======
+ @Override
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
+>>>>>>> 3.0
{
final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
index 810ef0b33..3eda786c9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
@@ -1,8 +1,10 @@
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.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
@@ -10,21 +12,16 @@ import org.bukkit.entity.Player;
public class Commandlightning extends EssentialsCommand
{
- public Commandlightning()
- {
- super("lightning");
- }
-
@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
{
- User user = null;
+ IUser user = null;
if (sender instanceof Player)
{
user = ess.getUser(((Player)sender));
}
- if ((args.length < 1 || !user.isAuthorized("essentials.lightning.others")) & user != null)
+ if ((args.length < 1 || !Permissions.LIGHTNING_OTHERS.isAuthorized(user)) && user != null)
{
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
return;
@@ -63,7 +60,10 @@ public class Commandlightning extends EssentialsCommand
{
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
}
- if (ess.getSettings().warnOnSmite())
+ @Cleanup
+ final ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ if (settings.getData().getCommands().getLightning().isWarnPlayer())
{
matchPlayer.sendMessage(_("lightningSmited"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
index c981f45c1..0a433ad7e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
@@ -1,33 +1,23 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.Util;
import java.util.*;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandlist extends EssentialsCommand
{
- public Commandlist()
- {
- super("list");
- }
-
@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
{
boolean showhidden = false;
- if (sender instanceof Player)
- {
- if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
- {
- showhidden = true;
- }
- }
- else
+ if (Permissions.LIST_HIDDEN.isAuthorized(sender))
{
showhidden = true;
}
@@ -51,21 +41,33 @@ public class Commandlist extends EssentialsCommand
}
sender.sendMessage(online);
- if (ess.getSettings().getSortListByGroups())
+ boolean sortListByGroups = false;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
{
- Map> sort = new HashMap>();
+ sortListByGroups = settings.getData().getCommands().getList().isSortByGroups();
+ }
+ finally
+ {
+ settings.unlock();
+ }
+
+ if (sortListByGroups)
+ {
+ Map> sort = new HashMap>();
for (Player OnlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(OnlinePlayer);
+ final IUser player = ess.getUser(OnlinePlayer);
if (player.isHidden() && !showhidden)
{
continue;
}
- final String group = player.getGroup();
- List list = sort.get(group);
+ final String group = ess.getRanks().getMainGroup(player);
+ List list = sort.get(group);
if (list == null)
{
- list = new ArrayList();
+ list = new ArrayList();
sort.put(group, list);
}
list.add(player);
@@ -75,11 +77,11 @@ public class Commandlist extends EssentialsCommand
for (String group : groups)
{
final StringBuilder groupString = new StringBuilder();
- groupString.append(_("listGroupTag", Util.replaceFormat(group)));
- final List users = sort.get(group);
+ groupString.append(_("listGroupTag",Util.replaceColor(group)));
+ final List users = sort.get(group);
Collections.sort(users);
boolean first = true;
- for (User user : users)
+ for (IUser user : users)
{
if (!first)
{
@@ -89,9 +91,17 @@ public class Commandlist extends EssentialsCommand
{
first = false;
}
- if (user.isAfk())
+ user.acquireReadLock();
+ try
{
- groupString.append(_("listAfkTag"));
+ if (user.getData().isAfk())
+ {
+ groupString.append(_("listAfkTag"));
+ }
+ }
+ finally
+ {
+ user.unlock();
}
if (user.isHidden())
{
@@ -106,10 +116,10 @@ public class Commandlist extends EssentialsCommand
}
else
{
- final List users = new ArrayList();
+ final List users = new ArrayList();
for (Player OnlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(OnlinePlayer);
+ final IUser player = ess.getUser(OnlinePlayer);
if (player.isHidden() && !showhidden)
{
continue;
@@ -121,7 +131,7 @@ public class Commandlist extends EssentialsCommand
final StringBuilder onlineUsers = new StringBuilder();
onlineUsers.append(_("connectedPlayers"));
boolean first = true;
- for (User user : users)
+ for (IUser user : users)
{
if (!first)
{
@@ -131,9 +141,17 @@ public class Commandlist extends EssentialsCommand
{
first = false;
}
- if (user.isAfk())
+ user.acquireReadLock();
+ try
{
- onlineUsers.append(_("listAfkTag"));
+ if (user.getData().isAfk())
+ {
+ onlineUsers.append(_("listAfkTag"));
+ }
+ }
+ finally
+ {
+ user.unlock();
}
if (user.isHidden())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
index 7a2dad1b1..db39d1c01 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
@@ -1,8 +1,9 @@
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.utils.Util;
+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;
@@ -11,19 +12,14 @@ import org.bukkit.entity.Player;
public class Commandmail extends EssentialsCommand
{
- public Commandmail()
- {
- super("mail");
- }
-
//TODO: Tidy this up
@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 && "read".equalsIgnoreCase(args[0]))
{
- final List mail = user.getMails();
- if (mail.isEmpty())
+ final List mail = user.getData().getMails();
+ if (mail == null || mail.isEmpty())
{
user.sendMessage(_("noMail"));
throw new NoChargeException();
@@ -37,26 +33,26 @@ public class Commandmail extends EssentialsCommand
}
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
- if (!user.isAuthorized("essentials.mail.send"))
+ if (!Permissions.MAIL_SEND.isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.mail.send"));
}
Player player = server.getPlayer(args[1]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[1]);
+ u = ess.getUser(args[1]);
}
if (u == null)
{
throw new Exception(_("playerNeverOnServer", args[1]));
}
- if (!u.isIgnoredPlayer(user.getName()))
+ if (!u.isIgnoringPlayer(user.getName()))
{
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
@@ -66,7 +62,7 @@ public class Commandmail extends EssentialsCommand
}
if (args.length > 1 && "sendall".equalsIgnoreCase(args[0]))
{
- if (!user.isAuthorized("essentials.mail.sendall"))
+ if (!Permissions.MAIL_SENDALL.isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
@@ -76,7 +72,8 @@ public class Commandmail extends EssentialsCommand
}
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
- user.setMails(null);
+ user.acquireWriteLock();
+ user.getData().setMails(null);
user.sendMessage(_("mailCleared"));
return;
}
@@ -84,27 +81,27 @@ public class Commandmail 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 && "read".equalsIgnoreCase(args[0]))
{
- throw new Exception(_("onlyPlayers", commandLabel + " read"));
+ throw new Exception(_("onlyPlayers", commandName + " read"));
}
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
- throw new Exception(_("onlyPlayers", commandLabel + " clear"));
+ throw new Exception(_("onlyPlayers", commandName + " clear"));
}
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
Player player = server.getPlayer(args[1]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[1]);
+ u = ess.getUser(args[1]);
}
if (u == null)
{
@@ -122,14 +119,14 @@ public class Commandmail extends EssentialsCommand
{
//allow sending from console without "send" argument, since it's the only thing the console can do
Player player = server.getPlayer(args[0]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[0]);
+ u = ess.getUser(args[0]);
}
if (u == null)
{
@@ -157,7 +154,7 @@ public class Commandmail extends EssentialsCommand
{
for (String username : ess.getUserMap().getAllUniqueUsers())
{
- User user = ess.getUserMap().getUser(username);
+ IUser user = ess.getUserMap().getUser(username);
if (user != null)
{
user.addMail(message);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
index 4322592d4..8477c98bc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
@@ -1,22 +1,17 @@
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;
public class Commandme extends EssentialsCommand
{
- public Commandme()
- {
- super("me");
- }
-
@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 (user.isMuted())
+ if (user.getData().isMuted())
{
throw new Exception(_("voiceSilenced"));
}
@@ -27,7 +22,14 @@ public class Commandme extends EssentialsCommand
}
String message = getFinalArg(args, 0);
- message = Util.formatMessage(user, "essentials.chat", message);
+ if (Permissions.CHAT_COLOR.isAuthorized(user))
+ {
+ message = Util.replaceColor(message);
+ }
+ else {
+ message = Util.stripColor(message);
+ }
+
user.setDisplayNick();
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
index 3fce3110c..bbf9ede4c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
@@ -1,49 +1,55 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.ItemPermissions;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.Locale;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandmore extends EssentialsCommand
{
- public Commandmore()
- {
- super("more");
- }
-
@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 ItemStack stack = user.getItemInHand();
if (stack == null)
{
throw new Exception(_("cantSpawnItem", "Air"));
}
- if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks"))
- ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize()))
+ int defaultStackSize = 0;
+ int oversizedStackSize = 0;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
+ {
+ defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
+ oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
+ }
+ finally
+ {
+ settings.unlock();
+ }
+ if (stack.getAmount() >= (Permissions.OVERSIZEDSTACKS.isAuthorized(user)
+ ? oversizedStackSize
+ : defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()))
{
throw new NoChargeException();
}
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
- if (ess.getSettings().permissionBasedItemSpawn()
- ? (!user.isAuthorized("essentials.itemspawn.item-all")
- && !user.isAuthorized("essentials.itemspawn.item-" + itemname)
- && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId()))
- : (!user.isAuthorized("essentials.itemspawn.exempt")
- && !user.canSpawnItem(stack.getTypeId())))
+ if (!ItemPermissions.getPermission(stack.getType()).isAuthorized(user))
{
throw new Exception(_("cantSpawnItem", itemname));
}
- if (user.isAuthorized("essentials.oversizedstacks"))
+ if (Permissions.OVERSIZEDSTACKS.isAuthorized(user))
{
- stack.setAmount(ess.getSettings().getOversizedStackSize());
+ stack.setAmount(oversizedStackSize);
}
else
{
- stack.setAmount(stack.getMaxStackSize());
+ stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize());
}
user.updateInventory();
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
index 0031504e8..c1d1e92bf 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
@@ -1,22 +1,16 @@
package com.earth2me.essentials.commands;
-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 org.bukkit.Server;
+import com.earth2me.essentials.utils.textreader.IText;
+import com.earth2me.essentials.utils.textreader.KeywordReplacer;
+import com.earth2me.essentials.utils.textreader.TextInput;
+import com.earth2me.essentials.utils.textreader.TextPager;
import org.bukkit.command.CommandSender;
public class Commandmotd extends EssentialsCommand
{
- public Commandmotd()
- {
- super("motd");
- }
-
@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
{
final IText input = new TextInput(sender, "motd", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
index 2e1011e3b..8cc683e55 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
@@ -2,24 +2,20 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.IReplyTo;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IReplyTo;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.List;
-import org.bukkit.Server;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandmsg extends EssentialsCommand
{
- public Commandmsg()
- {
- super("msg");
- }
-
@Override
- public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
{
@@ -29,12 +25,21 @@ public class Commandmsg extends EssentialsCommand
String message = getFinalArg(args, 1);
if (sender instanceof Player)
{
- User user = ess.getUser(sender);
- if (user.isMuted())
+ @Cleanup
+ IUser user = ess.getUser((Player)sender);
+ user.acquireReadLock();
+ if (user.getData().isMuted())
{
throw new Exception(_("voiceSilenced"));
}
- message = Util.formatMessage(user, "essentials.msg", message);
+ if (Permissions.MSG_COLOR.isAuthorized(user))
+ {
+ message = Util.replaceColor(message);
+ }
+ else
+ {
+ message = Util.stripColor(message);
+ }
}
else
{
@@ -49,7 +54,7 @@ public class Commandmsg extends EssentialsCommand
if (args[0].equalsIgnoreCase(Console.NAME))
{
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
- CommandSender cs = Console.getCommandSender(server);
+ CommandSender cs = server.getConsoleSender();
cs.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(cs);
Console.getConsoleReplyTo().setReplyTo(sender);
@@ -66,7 +71,7 @@ public class Commandmsg extends EssentialsCommand
int i = 0;
for (Player matchedPlayer : matchedPlayers)
{
- final User u = ess.getUser(matchedPlayer);
+ final IUser u = ess.getUser(matchedPlayer);
if (u.isHidden())
{
i++;
@@ -80,8 +85,8 @@ public class Commandmsg extends EssentialsCommand
for (Player matchedPlayer : matchedPlayers)
{
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
- final User matchedUser = ess.getUser(matchedPlayer);
- if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
+ final IUser matchedUser = ess.getUser(matchedPlayer);
+ if (sender instanceof Player && (matchedUser.isIgnoringPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
index 3e70cc507..b537c5a96 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
@@ -1,29 +1,29 @@
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 com.earth2me.essentials.user.UserData.TimestampType;
+import com.earth2me.essentials.utils.DateUtil;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
public class Commandmute extends EssentialsCommand
{
- public Commandmute()
- {
- super("mute");
- }
-
@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 = getPlayer(server, args, 0, true);
- if (!player.isMuted() && player.isAuthorized("essentials.mute.exempt"))
+ @Cleanup
+ final IUser player = getPlayer(args, 0, true);
+ player.acquireReadLock();
+ if (!player.getData().isMuted() && Permissions.MUTE_EXEMPT.isAuthorized(player))
{
throw new Exception(_("muteExempt"));
}
@@ -31,20 +31,20 @@ public class Commandmute extends EssentialsCommand
if (args.length > 1)
{
String time = getFinalArg(args, 1);
- muteTimestamp = Util.parseDateDiff(time, true);
+ muteTimestamp = DateUtil.parseDateDiff(time, true);
}
- player.setMuteTimeout(muteTimestamp);
+ player.setTimestamp(TimestampType.MUTE, muteTimestamp);
final boolean muted = player.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
- ? _("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
+ ? _("mutedPlayerFor", player.getDisplayName(), DateUtil.formatDateDiff(muteTimestamp))
: _("mutedPlayer", player.getDisplayName()))
: _("unmutedPlayer", player.getDisplayName()));
player.sendMessage(
muted
? (muteTimestamp > 0
- ? _("playerMutedFor", Util.formatDateDiff(muteTimestamp))
+ ? _("playerMutedFor", DateUtil.formatDateDiff(muteTimestamp))
: _("playerMuted"))
: _("playerUnmuted"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
index c13c1489d..fc1450445 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
@@ -1,9 +1,9 @@
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 org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -11,30 +11,26 @@ import org.bukkit.entity.Player;
public class Commandnear extends EssentialsCommand
{
- public Commandnear()
- {
- super("near");
- }
-
@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
{
long radius = 200;
- User otherUser = null;
+
+ IUser otherUser = null;
if (args.length > 0)
{
try
{
- radius = Long.parseLong(args[0]);
+ otherUser = getPlayer(args, 0);
}
- catch (NumberFormatException e)
+ catch (Exception ex)
{
try
{
- otherUser = getPlayer(server, args, 0);
+ radius = Long.parseLong(args[0]);
}
- catch (Exception ex)
+ catch (NumberFormatException e)
{
}
}
@@ -49,9 +45,9 @@ public class Commandnear extends EssentialsCommand
}
}
}
- if (otherUser == null || user.isAuthorized("essentials.near.others"))
+ if (otherUser == null || Permissions.NEAR_OTHERS.isAuthorized(user))
{
- user.sendMessage(_("nearbyPlayers", getLocal(server, otherUser == null ? user : otherUser, radius)));
+ user.sendMessage(_("nearbyPlayers", getLocal(otherUser == null ? user : otherUser, radius)));
}
else
{
@@ -60,13 +56,13 @@ public class Commandnear 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 == 0)
{
throw new NotEnoughArgumentsException();
}
- final User otherUser = getPlayer(server, args, 0);
+ final IUser otherUser = getPlayer(args, 0);
long radius = 200;
if (args.length > 1)
{
@@ -78,10 +74,10 @@ public class Commandnear extends EssentialsCommand
{
}
}
- sender.sendMessage(_("nearbyPlayers", getLocal(server, otherUser, radius)));
+ sender.sendMessage(_("nearbyPlayers", getLocal(otherUser, radius)));
}
- private String getLocal(final Server server, final User user, final long radius)
+ private String getLocal(final IUser user, final long radius)
{
final Location loc = user.getLocation();
final World world = loc.getWorld();
@@ -90,7 +86,7 @@ public class Commandnear extends EssentialsCommand
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(onlinePlayer);
+ final IUser player = ess.getUser(onlinePlayer);
if (!player.equals(user) && !player.isHidden())
{
final Location playerLoc = player.getLocation();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
index 808e0be70..edbefafaf 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
@@ -1,9 +1,12 @@
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.utils.Util;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.Locale;
+import lombok.Cleanup;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -11,43 +14,44 @@ import org.bukkit.entity.Player;
public class Commandnick extends EssentialsCommand
{
- public Commandnick()
- {
- super("nick");
- }
-
@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)
{
throw new NotEnoughArgumentsException();
}
- if (!ess.getSettings().changeDisplayName())
+ @Cleanup
+ final ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ if (!settings.getData().getChat().getChangeDisplayname())
{
throw new Exception(_("nickDisplayName"));
}
if (args.length > 1)
{
- if (!user.isAuthorized("essentials.nick.others"))
+ if (!Permissions.NICK_OTHERS.isAuthorized(user))
{
throw new Exception(_("nickOthersPermission"));
}
- setNickname(server, getPlayer(server, args, 0), formatNickname(user, args[1]));
+ setNickname(getPlayer(args, 0), formatNickname(user, args[1]));
user.sendMessage(_("nickChanged"));
return;
}
- setNickname(server, user, formatNickname(user, args[0]));
+ setNickname(user, formatNickname(user, args[0]));
}
@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();
}
- if (!ess.getSettings().changeDisplayName())
+ @Cleanup
+ final ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ if (!settings.getData().getChat().getChangeDisplayname())
{
throw new Exception(_("nickDisplayName"));
}
@@ -57,14 +61,14 @@ public class Commandnick extends EssentialsCommand
}
else
{
- setNickname(server, getPlayer(server, args, 0), formatNickname(null, args[1]));
+ setNickname(getPlayer(args, 0), formatNickname(null, args[1]));
}
sender.sendMessage(_("nickChanged"));
}
- private String formatNickname(final User user, final String nick)
+ private String formatNickname(final IUser user, final String nick)
{
- if (user == null)
+ if (user == null || Permissions.NICK_COLOR.isAuthorized(user))
{
return Util.replaceFormat(nick);
}
@@ -80,7 +84,7 @@ public class Commandnick extends EssentialsCommand
{
try
{
- setNickname(server, ess.getUser(player), "off");
+ setNickname(ess.getUser(player), "off");
}
catch (Exception ex)
{
@@ -88,7 +92,7 @@ public class Commandnick extends EssentialsCommand
}
}
- private void setNickname(final Server server, final User target, final String nick) throws Exception
+ private void setNickname(final IUser target, final String nick) throws Exception
{
if (!nick.matches("^[a-zA-Z_0-9\u00a7]+$"))
{
@@ -96,8 +100,8 @@ public class Commandnick extends EssentialsCommand
}
else if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
{
- target.setNickname(null);
- target.setDisplayNick();
+ target.getData().setNickname(null);
+ target.updateDisplayName();
target.sendMessage(_("nickNoMore"));
}
else
@@ -117,8 +121,8 @@ public class Commandnick extends EssentialsCommand
}
}
- target.setNickname(nick);
- target.setDisplayNick();
+ target.getData().setNickname(nick);
+ target.updateDisplayName();
target.sendMessage(_("nickSet", target.getDisplayName() + "§7."));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
index 60b1e3111..4f6e3933a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -14,13 +13,8 @@ import org.bukkit.entity.TNTPrimed;
public class Commandnuke extends EssentialsCommand
{
- public Commandnuke()
- {
- super("nuke");
- }
-
@Override
- protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
{
List targets;
if (args.length > 0)
@@ -29,7 +23,7 @@ public class Commandnuke extends EssentialsCommand
int pos = 0;
for (String arg : args)
{
- targets.add(getPlayer(server, args, pos));
+ targets.add(getPlayer(args, pos));
pos++;
}
}
@@ -51,7 +45,7 @@ public class Commandnuke extends EssentialsCommand
{
for (int z = -10; z <= 10; z += 5)
{
- final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
+ final Location tntloc = new Location(world, loc.getBlockX() + x, world.getMaxHeight(), loc.getBlockZ() + z);
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
index 01e1fcffb..f79f0150b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
@@ -1,27 +1,21 @@
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;
import org.bukkit.entity.Player;
public class Commandpay extends EssentialsCommand
{
- public Commandpay()
- {
- super("pay");
- }
-
@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 < 2)
{
throw new NotEnoughArgumentsException();
}
-
+
if (args[0] == "")
{
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
@@ -32,7 +26,7 @@ public class Commandpay extends EssentialsCommand
Boolean foundUser = false;
for (Player p : server.matchPlayer(args[0]))
{
- User u = ess.getUser(p);
+ IUser u = ess.getUser(p);
if (u.isHidden())
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandping.java b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
index 43aa18d5f..5da879907 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandping.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
@@ -1,25 +1,18 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Util;
-import org.bukkit.Server;
-import org.bukkit.command.CommandSender;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
public class Commandping extends EssentialsCommand
{
- public Commandping()
- {
- super("ping");
- }
-
@Override
- public void run(final Server server, final CommandSender sender, 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)
{
-
- sender.sendMessage(_("pong"));
+ user.sendMessage(_("pong"));
}
else
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
index d1d0fb582..9f0cf006a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
@@ -1,32 +1,28 @@
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.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandpowertool extends EssentialsCommand
{
- public Commandpowertool()
- {
- super("powertool");
- }
-
@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
{
String command = getFinalArg(args, 0);
// check to see if this is a clear all command
if (command != null && command.equalsIgnoreCase("d:"))
{
- user.clearAllPowertools();
+ user.acquireWriteLock();
+ user.getData().clearAllPowertools();
user.sendMessage(_("powerToolClearAll"));
return;
}
@@ -38,7 +34,7 @@ public class Commandpowertool extends EssentialsCommand
}
final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
- List powertools = user.getPowertool(itemStack);
+ List powertools = user.getData().getPowertool(itemStack.getType());
if (command != null && !command.isEmpty())
{
if (command.equalsIgnoreCase("l:"))
@@ -68,7 +64,7 @@ public class Commandpowertool extends EssentialsCommand
{
if (command.startsWith("a:"))
{
- if (!user.isAuthorized("essentials.powertool.append"))
+ if (!Permissions.POWERTOOL_APPEND.isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.powertool.append"));
}
@@ -106,6 +102,7 @@ public class Commandpowertool extends EssentialsCommand
user.setPowerToolsEnabled(true);
user.sendMessage(_("powerToolsEnabled"));
}
- user.setPowertool(itemStack, powertools);
+ user.acquireWriteLock();
+ user.getData().setPowertool(itemStack.getType(), powertools);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
index c8b737dfa..24481bcec 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
@@ -1,26 +1,22 @@
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 Commandpowertooltoggle extends EssentialsCommand
{
- public Commandpowertooltoggle()
- {
- super("powertooltoggle");
- }
-
@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.hasPowerTools())
+ if (!user.getData().hasPowerTools())
{
user.sendMessage(_("noPowerTools"));
return;
}
- user.sendMessage(user.togglePowerToolsEnabled()
+ user.acquireWriteLock();
+ user.getData().setPowerToolsEnabled(!user.getData().isPowerToolsEnabled());
+ user.sendMessage(user.getData().isPowerToolsEnabled()
? _("powerToolsEnabled")
: _("powerToolsDisabled"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
index 738b8db1a..c4c6e21a3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
@@ -1,10 +1,10 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.DescParseTickFormat;
+import com.earth2me.essentials.utils.DescParseTickFormat;
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.*;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -22,13 +22,8 @@ public class Commandptime extends EssentialsCommand
getAliases.add("display");
}
- public Commandptime()
- {
- super("ptime");
- }
-
@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
{
// Which Players(s) / Users(s) are we interested in?
String userSelector = null;
@@ -36,7 +31,7 @@ public class Commandptime extends EssentialsCommand
{
userSelector = args[1];
}
- Set users = getUsers(server, sender, userSelector);
+ Set users = getUsers(sender, userSelector);
// If no arguments we are reading the time
if (args.length == 0)
@@ -45,8 +40,8 @@ public class Commandptime extends EssentialsCommand
return;
}
- User user = ess.getUser(sender);
- if ((!users.contains(user) || users.size() > 1) && user != null && !user.isAuthorized("essentials.ptime.others"))
+ IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
+ if ((!users.contains(user) || users.size() > 1) && user != null && !Permissions.PTIME_OTHERS.isAuthorized(user))
{
user.sendMessage(_("pTimeOthersPermission"));
return;
@@ -89,14 +84,14 @@ public class Commandptime extends EssentialsCommand
/**
* Used to get the time and inform
*/
- private void getUsersTime(final CommandSender sender, final Collection users)
+ private void getUsersTime(final CommandSender sender, final Collection users)
{
if (users.size() > 1)
{
sender.sendMessage(_("pTimePlayers"));
}
- for (User user : users)
+ for (IUser user : users)
{
if (user.getPlayerTimeOffset() == 0)
{
@@ -120,13 +115,13 @@ public class Commandptime extends EssentialsCommand
/**
* Used to set the time and inform of the change
*/
- private void setUsersTime(final CommandSender sender, final Collection users, final Long ticks, Boolean relative)
+ private void setUsersTime(final CommandSender sender, final Collection users, final Long ticks, Boolean relative)
{
// Update the time
if (ticks == null)
{
// Reset
- for (User user : users)
+ for (IUser user : users)
{
user.resetPlayerTime();
}
@@ -134,7 +129,7 @@ public class Commandptime extends EssentialsCommand
else
{
// Set
- for (User user : users)
+ for (IUser user : users)
{
final World world = user.getWorld();
long time = user.getPlayerTime();
@@ -149,7 +144,7 @@ public class Commandptime extends EssentialsCommand
}
final StringBuilder msg = new StringBuilder();
- for (User user : users)
+ for (IUser user : users)
{
if (msg.length() > 0)
{
@@ -181,13 +176,13 @@ public class Commandptime extends EssentialsCommand
/**
* Used to parse an argument of the type "users(s) selector"
*/
- private Set getUsers(final Server server, final CommandSender sender, final String selector) throws Exception
+ private Set getUsers(final CommandSender sender, final String selector) throws Exception
{
- final Set users = new TreeSet(new UserNameComparator());
+ final Set users = new TreeSet();
// If there is no selector we want the sender itself. Or all users if sender isn't a user.
if (selector == null)
{
- final User user = ess.getUser(sender);
+ final IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
if (user == null)
{
for (Player player : server.getOnlinePlayers())
@@ -203,7 +198,7 @@ public class Commandptime extends EssentialsCommand
}
// Try to find the user with name = selector
- User user = null;
+ IUser user = null;
final List matchedPlayers = server.matchPlayer(selector);
if (!matchedPlayers.isEmpty())
{
@@ -231,13 +226,3 @@ public class Commandptime extends EssentialsCommand
return users;
}
}
-
-
-class UserNameComparator implements Comparator
-{
- @Override
- public int compare(User a, User b)
- {
- return a.getName().compareTo(b.getName());
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java
index 9b585509d..feb183b23 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java
@@ -2,23 +2,18 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.IReplyTo;
-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.IReplyTo;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandr extends EssentialsCommand
{
- public Commandr()
- {
- super("r");
- }
-
@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)
{
@@ -31,8 +26,15 @@ public class Commandr extends EssentialsCommand
if (sender instanceof Player)
{
- User user = ess.getUser(sender);
- message = Util.formatMessage(user, "essentials.msg", message);
+ IUser user = ess.getUser((Player)sender);
+ if (Permissions.MSG_COLOR.isAuthorized(user))
+ {
+ message = Util.replaceFormat(message);
+ }
+ else
+ {
+ message = Util.replaceFormat(message);
+ }
replyTo = user;
senderName = user.getDisplayName();
}
@@ -54,8 +56,8 @@ public class Commandr extends EssentialsCommand
sender.sendMessage(_("msgFormat", _("me"), targetName, message));
if (target instanceof Player)
{
- User player = ess.getUser(target);
- if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
+ IUser player = ess.getUser((Player)target);
+ if (player.isIgnoringPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
{
return;
}
@@ -74,4 +76,10 @@ public class Commandr extends EssentialsCommand
}
}
}
+
+ @Override
+ public String getPermission()
+ {
+ return "essentials.msg";
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
index c99018211..9d69d2ad6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
@@ -1,40 +1,39 @@
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.utils.Util;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
import java.util.Locale;
-import org.bukkit.Server;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandrealname extends EssentialsCommand
{
- public Commandrealname()
- {
- super("realname");
- }
-
@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();
}
+ @Cleanup
+ final ISettings settings = ess.getSettings();
final String whois = args[0].toLowerCase(Locale.ENGLISH);
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User u = ess.getUser(onlinePlayer);
+ final IUser u = ess.getUser(onlinePlayer);
if (u.isHidden())
{
continue;
}
u.setDisplayNick();
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
+ settings.acquireReadLock();
if (!whois.equals(displayName)
- && !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
+ && !displayName.equals(Util.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
index 912434f08..05d27a3bc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
@@ -1,10 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.api.IUser;
import java.util.Locale;
import org.bukkit.Chunk;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
@@ -12,12 +11,6 @@ import org.bukkit.entity.*;
public class Commandremove extends EssentialsCommand
{
- public Commandremove()
- {
- super("remove");
- }
-
-
private enum ToRemove
{
DROPS,
@@ -29,7 +22,7 @@ public class Commandremove extends EssentialsCommand
}
@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 < 1)
{
@@ -64,7 +57,7 @@ public class Commandremove 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 < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
index d621109f7..05715b515 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
@@ -1,24 +1,22 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.api.ChargeException;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.*;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandrepair extends EssentialsCommand
{
- public Commandrepair()
- {
- super("repair");
- }
-
@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)
{
@@ -34,8 +32,7 @@ public class Commandrepair extends EssentialsCommand
}
if (!item.getEnchantments().isEmpty()
- && !ess.getSettings().getRepairEnchanted()
- && !user.isAuthorized("essentials.repair.enchanted"))
+ && !Permissions.REPAIR_ENCHANTED.isAuthorized(user))
{
throw new Exception(_("repairEnchanted"));
}
@@ -58,7 +55,7 @@ public class Commandrepair extends EssentialsCommand
final List repaired = new ArrayList();
repairItems(user.getInventory().getContents(), user, repaired);
- if (user.isAuthorized("essentials.repair.armor"))
+ if (Permissions.REPAIR_ARMOR.isAuthorized(user))
{
repairItems(user.getInventory().getArmorContents(), user, repaired);
}
@@ -116,8 +113,7 @@ public class Commandrepair extends EssentialsCommand
continue;
}
if (!item.getEnchantments().isEmpty()
- && !ess.getSettings().getRepairEnchanted()
- && !user.isAuthorized("essentials.repair.enchanted"))
+ && !Permissions.REPAIR_ENCHANTED.isAuthorized(user))
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
index d87c4f41b..da0a3eaec 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
@@ -1,22 +1,16 @@
package com.earth2me.essentials.commands;
-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 org.bukkit.Server;
+import com.earth2me.essentials.utils.textreader.IText;
+import com.earth2me.essentials.utils.textreader.KeywordReplacer;
+import com.earth2me.essentials.utils.textreader.TextInput;
+import com.earth2me.essentials.utils.textreader.TextPager;
import org.bukkit.command.CommandSender;
public class Commandrules extends EssentialsCommand
{
- public Commandrules()
- {
- super("rules");
- }
-
@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
{
final IText input = new TextInput(sender, "rules", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
index 24f1f9c41..5dcaa0f2a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
@@ -1,33 +1,30 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
-import org.bukkit.Location;
-import org.bukkit.Server;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.user.UserData.TimestampType;
+import com.earth2me.essentials.utils.DateUtil;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
public class Commandseen extends EssentialsCommand
{
- public Commandseen()
- {
- super("seen");
- }
-
@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
{
- seen(server, sender, args, true, true);
+ seen(sender,args,true);
}
-
+
@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
{
- seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"));
+ seen(user,args,Permissions.SEEN_BANREASON.isAuthorized(user));
}
-
- protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception
+
+ protected void seen (final CommandSender sender, final String[] args, final boolean show) throws Exception
{
if (args.length < 1)
{
@@ -35,26 +32,24 @@ public class Commandseen extends EssentialsCommand
}
try
{
- User player = getPlayer(server, args, 0);
+ IUser u = getPlayer(args, 0);
player.setDisplayNick();
- sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
- if (extra)
- {
- sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
- }
+ sender.sendMessage(_("seenOnline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGIN))));
}
catch (NoSuchFieldException e)
{
- User player = ess.getOfflineUser(args[0]);
- if (player == null)
+ @Cleanup
+ IUser u = ess.getUser(args[0]);
+ u.acquireReadLock();
+ if (u == null)
{
throw new Exception(_("playerNotFound"));
}
player.setDisplayNick();
- sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
- if (player.isBanned())
+ sender.sendMessage(_("seenOffline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGOUT))));
+ if (u.isBanned())
{
- sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
+ sender.sendMessage(_("whoisBanned", show ? u.getData().getBan().getReason() : _("true")));
}
if (extra)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index 5958a5c0f..0b56843cd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -1,26 +1,20 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
import java.util.Locale;
import java.util.logging.Level;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandsell extends EssentialsCommand
{
- public Commandsell()
- {
- super("sell");
- }
-
@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)
{
@@ -74,7 +68,7 @@ public class Commandsell extends EssentialsCommand
sellItem(user, is, args, false);
}
- private void sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
+ private void sellItem(IUser user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
{
if (is == null || is.getType() == Material.AIR)
{
@@ -92,16 +86,11 @@ public class Commandsell extends EssentialsCommand
}
double worth = ess.getWorth().getPrice(is);
boolean stack = args.length > 1 && args[1].endsWith("s");
- boolean requireStack = ess.getSettings().isTradeInStacks(id);
if (Double.isNaN(worth))
{
throw new Exception(_("itemCannotBeSold"));
}
- if (requireStack && !stack)
- {
- throw new Exception(_("itemMustBeStacked"));
- }
int max = 0;
@@ -135,10 +124,6 @@ public class Commandsell extends EssentialsCommand
amount += max;
}
- if (requireStack)
- {
- amount -= amount % is.getType().getMaxStackSize();
- }
if (amount > max || amount < 1)
{
if (!isBulkSell)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
index f622094d2..5ef850264 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
@@ -1,20 +1,17 @@
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.HashMap;
import java.util.Locale;
-import org.bukkit.Server;
+import lombok.Cleanup;
public class Commandsethome extends EssentialsCommand
{
- public Commandsethome()
- {
- super("sethome");
- }
-
@Override
- public void run(final Server server, final User user, final String commandLabel, String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, String[] args) throws Exception
{
if (args.length > 0)
{
@@ -27,20 +24,25 @@ public class Commandsethome extends EssentialsCommand
if (args.length < 2)
{
- if (user.isAuthorized("essentials.sethome.multiple"))
+ if (Permissions.SETHOME_MULTIPLE.isAuthorized(user))
{
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
{
throw new NotEnoughArgumentsException();
}
- if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
+ if ((user.getHomes().size() < ess.getRanks().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
{
- user.setHome(args[0].toLowerCase(Locale.ENGLISH));
+ user.acquireWriteLock();
+ if (user.getData().getHomes() == null)
+ {
+ user.getData().setHomes(new HashMap());
+ }
+ user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(user.getLocation()));
}
else
{
- throw new Exception(_("maxHomes", ess.getSettings().getHomeLimit(user)));
+ throw new Exception(_("maxHomes", ess.getRanks().getHomeLimit(user)));
}
}
@@ -51,19 +53,16 @@ public class Commandsethome extends EssentialsCommand
}
else
{
- if (user.isAuthorized("essentials.sethome.others"))
+ if (Permissions.SETHOME_OTHERS.isAuthorized(user))
{
- User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
- if (usersHome == null)
- {
- usersHome = ess.getOfflineUser(args[0]);
- }
+ @Cleanup
+ IUser usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
if (usersHome == null)
{
throw new Exception(_("playerNotFound"));
}
String name = args[1].toLowerCase(Locale.ENGLISH);
- if (!user.isAuthorized("essentials.sethome.multiple"))
+ if (!Permissions.SETHOME_MULTIPLE.isAuthorized(user))
{
name = "home";
}
@@ -71,13 +70,24 @@ public class Commandsethome extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- usersHome.setHome(name, user.getLocation());
+
+ usersHome.acquireWriteLock();
+ if (usersHome.getData().getHomes() == null)
+ {
+ usersHome.getData().setHomes(new HashMap());
+ }
+ usersHome.getData().getHomes().put(name, new com.earth2me.essentials.storage.Location(user.getLocation()));
}
}
}
else
{
- user.setHome();
+ user.acquireWriteLock();
+ if (user.getData().getHomes() == null)
+ {
+ user.getData().setHomes(new HashMap());
+ }
+ user.getData().getHomes().put("home", new com.earth2me.essentials.storage.Location(user.getLocation()));
}
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
index 877da4d26..fea08f7a0 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
@@ -1,20 +1,13 @@
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.api.IUser;
public class Commandsetjail extends EssentialsCommand
{
- public Commandsetjail()
- {
- super("setjail");
- }
-
@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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java
new file mode 100644
index 000000000..3af7e711f
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java
@@ -0,0 +1,17 @@
+package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.settings.SpawnsHolder;
+
+
+public class Commandsetspawn extends EssentialsCommand
+{
+ @Override
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
+ {
+ final String group = args.length > 0 ? getFinalArg(args, 0) : "default";
+ ((SpawnsHolder)module).setSpawn(user.getLocation(), group);
+ user.sendMessage(_("spawnSet", group));
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
index 42da62b85..72b42fe7c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
@@ -1,45 +1,41 @@
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.api.IWarps;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.Warps;
import org.bukkit.Location;
-import org.bukkit.Server;
public class Commandsetwarp extends EssentialsCommand
{
- public Commandsetwarp()
- {
- super("setwarp");
- }
-
@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)
{
throw new NotEnoughArgumentsException();
}
-
- if (args[0].matches("[0-9]+")) {
+
+ if (args[0].matches("[0-9]+"))
+ {
throw new NotEnoughArgumentsException();
}
final Location loc = user.getLocation();
- final Warps warps = ess.getWarps();
+ final IWarps warps = ess.getWarps();
Location warpLoc = null;
try
{
warpLoc = warps.getWarp(args[0]);
}
- catch (Exception ex)
+ catch (WarpNotFoundException ex)
{
}
- if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
+ if (warpLoc == null || user.hasPermission("essentials.warp.overwrite." + args[0]))
{
warps.setWarp(args[0], loc);
}
@@ -47,6 +43,7 @@ public class Commandsetwarp extends EssentialsCommand
{
throw new Exception(_("warpOverwrite"));
}
+
user.sendMessage(_("warpSet", args[0]));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
index 91a1dd657..e42c11651 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
@@ -1,21 +1,42 @@
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.command.CommandSender;
import org.bukkit.inventory.ItemStack;
public class Commandsetworth extends EssentialsCommand
{
- public Commandsetworth()
+ @Override
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
- super("setworth");
+ if (args.length < 2)
+ {
+ throw new NotEnoughArgumentsException();
+ }
+
+ ItemStack stack;
+ String price;
+
+ if (args.length == 1)
+ {
+ stack = user.getInventory().getItemInHand();
+ price = args[0];
+ }
+ else
+ {
+ stack = ess.getItemDb().get(args[0]);
+ price = args[1];
+ }
+
+ ess.getWorth().setPrice(stack, Double.parseDouble(price));
+ user.sendMessage(_("worthSet"));
}
@Override
- public void run(final Server server, final User user, 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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
index 6080642a1..86ae15fc8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
@@ -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 Commandsocialspy extends EssentialsCommand
{
- public Commandsocialspy()
- {
- super("socialspy");
- }
-
@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
{
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled")));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java
new file mode 100644
index 000000000..0edcf870c
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java
@@ -0,0 +1,55 @@
+package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.settings.SpawnsHolder;
+import org.bukkit.Location;
+import org.bukkit.command.CommandSender;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+
+
+public class Commandspawn extends EssentialsCommand
+{
+ @Override
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
+ {
+ final Trade charge = new Trade(commandName, ess);
+ charge.isAffordableFor(user);
+ if (args.length > 0 && Permissions.SPAWN_OTHERS.isAuthorized(user))
+ {
+ final IUser otherUser = getPlayer(args, 0);
+ respawn(otherUser, null);
+ if (!otherUser.equals(user))
+ {
+ otherUser.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn"));
+ user.sendMessage(_("teleporting"));
+ }
+ }
+ else
+ {
+ respawn(user, null);
+ }
+ }
+
+ @Override
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ if (args.length < 1)
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ final IUser user = getPlayer(args, 0);
+ respawn(user, null);
+ user.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn"));
+ sender.sendMessage(_("teleporting"));
+ }
+
+ private void respawn(final IUser user, final Trade charge) throws Exception
+ {
+ final SpawnsHolder spawns = (SpawnsHolder)this.module;
+ final Location spawn = spawns.getSpawn(ess.getRanks().getMainGroup(user));
+ user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND);
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
index d2b50137d..c68290c65 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
@@ -2,30 +2,30 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.bukkit.Mob;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.SpawnerPermissions;
+import com.earth2me.essentials.utils.LocationUtil;
+import com.earth2me.essentials.utils.Util;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
public class Commandspawner extends EssentialsCommand
{
- public Commandspawner()
- {
- super("spawner");
- }
-
@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 < 1 || args[0].length() < 2)
{
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
}
- final Location target = Util.getTarget(user);
+ final Location target = LocationUtil.getTarget(user);
if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
{
throw new Exception(_("mobSpawnTarget"));
@@ -51,7 +51,24 @@ public class Commandspawner extends EssentialsCommand
charge.isAffordableFor(user);
try
{
+ String name = args[0];
+
+ Mob mob = null;
+ mob = Mob.fromName(name);
+ if (mob == null)
+ {
+ user.sendMessage(_("invalidMob"));
+ return;
+ }
+ if (!SpawnerPermissions.getPermission(mob.name).isAuthorized(user))
+ {
+ throw new Exception(_("unableToSpawnMob"));
+ }
+ final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
+ charge.isAffordableFor(user);
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
+ charge.charge(user);
+ user.sendMessage(_("setSpawner", mob.name));
}
catch (Throwable ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 2546a76dd..c9c8a2a4b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -1,14 +1,17 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Mob;
-import com.earth2me.essentials.Mob.MobException;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.bukkit.Mob;
+import com.earth2me.essentials.bukkit.Mob.MobException;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.SpawnmobPermissions;
+import com.earth2me.essentials.utils.LocationUtil;
+import com.earth2me.essentials.utils.Util;
+import java.util.HashSet;
import java.util.*;
import org.bukkit.DyeColor;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.entity.Villager.Profession;
@@ -17,13 +20,8 @@ import org.bukkit.material.Colorable;
public class Commandspawnmob extends EssentialsCommand
{
- public Commandspawnmob()
- {
- super("spawnmob");
- }
-
@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)
{
@@ -31,7 +29,7 @@ public class Commandspawnmob extends EssentialsCommand
final Set availableList = new HashSet();
for (String mob : mobList)
{
- if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
+ if (SpawnmobPermissions.getPermission(mob).isAuthorized(user))
{
availableList.add(mob);
}
@@ -76,27 +74,23 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("invalidMob"));
}
- if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("disabledToSpawnMob"));
- }
- if (!user.isAuthorized("essentials.spawnmob." + mob.name.toLowerCase()))
+ if (!SpawnmobPermissions.getPermission(mob.name).isAuthorized(user))
{
throw new Exception(_("noPermToSpawnMob"));
}
- final Block block = Util.getTarget(user).getBlock();
+ final Block block = LocationUtil.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));
}
- User otherUser = null;
+ IUser otherUser = null;
if (args.length >= 3)
{
- otherUser = getPlayer(ess.getServer(), args, 2);
+ otherUser = getPlayer(args, 2);
}
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
- final Location sloc = Util.getSafeDestination(loc);
+ final Location sloc = LocationUtil.getSafeDestination(loc);
try
{
spawnedMob = mob.spawn(user, server, sloc);
@@ -115,11 +109,7 @@ public class Commandspawnmob extends EssentialsCommand
return;
}
- if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("disabledToSpawnMob"));
- }
- if (!user.isAuthorized("essentials.spawnmob." + mobMount.name.toLowerCase()))
+ if (!SpawnmobPermissions.getPermission(mobMount.name).isAuthorized(user))
{
throw new Exception(_("noPermToSpawnMob"));
}
@@ -144,7 +134,17 @@ public class Commandspawnmob extends EssentialsCommand
if (args.length >= 2)
{
int mobCount = Integer.parseInt(args[1]);
- int serverLimit = ess.getSettings().getSpawnMobLimit();
+ int serverLimit = 1;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
+ {
+ serverLimit = settings.getData().getCommands().getSpawnmob().getLimit();
+ }
+ finally
+ {
+ settings.unlock();
+ }
if (mobCount > serverLimit)
{
mobCount = serverLimit;
@@ -198,7 +198,7 @@ public class Commandspawnmob extends EssentialsCommand
}
}
- private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
+ private void changeMobData(final EntityType type, final Entity spawned, String data, final IUser user) throws Exception
{
data = data.toLowerCase(Locale.ENGLISH);
@@ -278,5 +278,20 @@ public class Commandspawnmob extends EssentialsCommand
}
}
}
+ if (type == EntityType.OCELOT)
+ {
+ if (data.contains("siamese"))
+ {
+ ((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
+ }
+ if (data.contains("red"))
+ {
+ ((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
+ }
+ if (data.contains("black"))
+ {
+ ((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
+ }
+ }
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
index 23083fa3d..9d94bef89 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
@@ -1,29 +1,24 @@
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 com.earth2me.essentials.Util;
-import org.bukkit.Server;
+import com.earth2me.essentials.utils.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
public class Commandsudo extends EssentialsCommand
{
- public Commandsudo()
- {
- super("sudo");
- }
-
@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 User user = getPlayer(server, args, 0, false);
+ final IUser user = getPlayer(args, 0, false);
final String command = args[1];
final String[] arguments = new String[args.length - 2];
if (arguments.length > 0)
@@ -31,7 +26,7 @@ public class Commandsudo extends EssentialsCommand
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
- if (user.isAuthorized("essentials.sudo.exempt"))
+ if (Permissions.SUDO_EXEMPT.isAuthorized(user))
{
throw new Exception(_("sudoExempt"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
index 84c9fc489..1c6b99c32 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
@@ -1,22 +1,16 @@
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.event.entity.EntityDamageEvent;
public class Commandsuicide extends EssentialsCommand
{
- public Commandsuicide()
- {
- super("suicide");
- }
-
@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
{
- EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
+ EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, 1000);
server.getPluginManager().callEvent(ede);
user.damage(Short.MAX_VALUE);
user.sendMessage(_("suicideMessage"));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index 25c457a20..4068f8d18 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -2,32 +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.Util;
-import org.bukkit.Server;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.user.Ban;
+import com.earth2me.essentials.utils.DateUtil;
+import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandtempban extends EssentialsCommand
{
- public Commandtempban()
- {
- super("tempban");
- }
-
@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 User user = getPlayer(server, args, 0, true);
+ final IUser user = getPlayer(args, 0, true);
if (!user.isOnline())
{
- if (sender instanceof Player
- && !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
+ if (Permissions.TEMPBAN_OFFLINE.isAuthorized(sender))
{
sender.sendMessage(_("tempbanExempt"));
return;
@@ -35,26 +32,28 @@ public class Commandtempban extends EssentialsCommand
}
else
{
- if (user.isAuthorized("essentials.tempban.exempt"))
+ if (Permissions.TEMPBAN_EXEMPT.isAuthorized(user))
{
sender.sendMessage(_("tempbanExempt"));
return;
}
}
final String time = getFinalArg(args, 1);
- final long banTimestamp = Util.parseDateDiff(time, true);
+ final long banTimestamp = DateUtil.parseDateDiff(time, true);
- final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
- user.setBanReason(banReason);
- user.setBanTimeout(banTimestamp);
+ final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp));
+ user.acquireWriteLock();
+ user.getData().setBan(new Ban());
+ user.getData().getBan().setReason(banReason);
+ user.getData().getBan().setTimeout(banTimestamp);
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
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));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
index 3cb60e6e3..23c2e13b9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
@@ -1,20 +1,14 @@
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.World;
public class Commandthunder extends EssentialsCommand
{
- public Commandthunder()
- {
- super("thunder");
- }
-
@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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 8e5b7c017..9b28f5d6c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -1,24 +1,20 @@
package com.earth2me.essentials.commands;
-import com.earth2me.essentials.DescParseTickFormat;
+import com.earth2me.essentials.utils.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.Util;
import java.util.*;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
public class Commandtime extends EssentialsCommand
{
- public Commandtime()
- {
- super("time");
- }
-
@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
{
final List argList = new ArrayList(Arrays.asList(args));
if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
@@ -33,7 +29,7 @@ public class Commandtime extends EssentialsCommand
{
worldSelector = validArgs[1];
}
- final Set worlds = getWorlds(server, sender, worldSelector);
+ final Set worlds = getWorlds(sender, worldSelector);
// If no arguments we are reading the time
if (validArgs.length == 0)
@@ -42,10 +38,9 @@ public class Commandtime extends EssentialsCommand
return;
}
- final User user = ess.getUser(sender);
- if (user != null && !user.isAuthorized("essentials.time.set"))
+ if (Permissions.TIME_SET.isAuthorized(sender))
{
- user.sendMessage(_("timeSetPermission"));
+ sender.sendMessage(_("timeSetPermission"));
return;
}
@@ -111,14 +106,14 @@ public class Commandtime extends EssentialsCommand
/**
* Used to parse an argument of the type "world(s) selector"
*/
- private Set getWorlds(final Server server, final CommandSender sender, final String selector) throws Exception
+ private Set getWorlds(final CommandSender sender, final String selector) throws Exception
{
final Set worlds = new TreeSet(new WorldNameComparator());
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
if (selector == null)
{
- final User user = ess.getUser(sender);
+ final IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
if (user == null)
{
worlds.addAll(server.getWorlds());
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
index 3240b73a9..856a32153 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
@@ -1,36 +1,35 @@
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 com.earth2me.essentials.user.UserData.TimestampType;
+import com.earth2me.essentials.utils.DateUtil;
+import lombok.Cleanup;
+import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
public class Commandtogglejail extends EssentialsCommand
{
- public Commandtogglejail()
- {
- super("togglejail");
- }
-
@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 = getPlayer(server, args, 0, true);
+ @Cleanup
+ final IUser player = getPlayer(args, 0, true);
+ player.acquireReadLock();
- if (args.length >= 2 && !player.isJailed())
+ if (args.length >= 2 && !player.getData().isJailed())
{
if (!player.isOnline())
{
- if (sender instanceof Player
- && !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
+ if (Permissions.TOGGLEJAIL_OFFLINE.isAuthorized(sender))
{
sender.sendMessage(_("mayNotJail"));
return;
@@ -38,7 +37,7 @@ public class Commandtogglejail extends EssentialsCommand
}
else
{
- if (player.isAuthorized("essentials.jail.exempt"))
+ if (Permissions.JAIL_EXEMPT.isAuthorized(player))
{
sender.sendMessage(_("mayNotJail"));
return;
@@ -53,48 +52,50 @@ public class Commandtogglejail extends EssentialsCommand
// Check if jail exists
ess.getJails().getJail(args[1]);
}
- player.setJailed(true);
+ player.acquireWriteLock();
+ player.getData().setJailed(true);
player.sendMessage(_("userJailed"));
- player.setJail(null);
- player.setJail(args[1]);
+ player.getData().setJail(args[1]);
long timeDiff = 0;
if (args.length > 2)
{
final String time = getFinalArg(args, 2);
- timeDiff = Util.parseDateDiff(time, true);
- player.setJailTimeout(timeDiff);
+ timeDiff = DateUtil.parseDateDiff(time, true);
+ player.setTimestamp(TimestampType.JAIL, timeDiff);
}
sender.sendMessage((timeDiff > 0
- ? _("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
+ ? _("playerJailedFor", player.getName(), DateUtil.formatDateDiff(timeDiff))
: _("playerJailed", player.getName())));
return;
}
- if (args.length >= 2 && player.isJailed() && !args[1].equalsIgnoreCase(player.getJail()))
+ if (args.length >= 2 && player.getData().isJailed() && !args[1].equalsIgnoreCase(player.getData().getJail()))
{
- sender.sendMessage(_("jailAlreadyIncarcerated", player.getJail()));
+ sender.sendMessage(_("jailAlreadyIncarcerated", player.getData().getJail()));
return;
}
- if (args.length >= 2 && player.isJailed() && args[1].equalsIgnoreCase(player.getJail()))
+ if (args.length >= 2 && player.getData().isJailed() && args[1].equalsIgnoreCase(player.getData().getJail()))
{
final String time = getFinalArg(args, 2);
- final long timeDiff = Util.parseDateDiff(time, true);
- player.setJailTimeout(timeDiff);
- sender.sendMessage(_("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
+ final long timeDiff = DateUtil.parseDateDiff(time, true);
+ player.acquireWriteLock();
+ player.setTimestamp(TimestampType.JAIL, timeDiff);
+ sender.sendMessage(_("jailSentenceExtended", DateUtil.formatDateDiff(timeDiff)));
return;
}
- if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(player.getJail())))
+ if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(player.getData().getJail())))
{
- if (!player.isJailed())
+ if (!player.getData().isJailed())
{
throw new NotEnoughArgumentsException();
}
- player.setJailed(false);
- player.setJailTimeout(0);
+ player.acquireWriteLock();
+ player.getData().setJailed(false);
+ player.setTimestamp(TimestampType.JAIL, 0);
player.sendMessage(_("jailReleasedPlayerNotify"));
- player.setJail(null);
+ player.getData().setJail(null);
if (player.isOnline())
{
player.getTeleport().back();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
index e91d0984a..1e9926ecd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
@@ -1,27 +1,21 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtop extends EssentialsCommand
{
- public Commandtop()
- {
- super("top");
- }
-
@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 topX = user.getLocation().getBlockX();
final int topZ = user.getLocation().getBlockZ();
final int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
- user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess), TeleportCause.COMMAND);
+ user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(commandName, ess), TeleportCause.COMMAND);
user.sendMessage(_("teleportTop"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
index d6d6b76f9..f508c872c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
@@ -2,22 +2,18 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
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;
+import com.earth2me.essentials.permissions.Permissions;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtp extends EssentialsCommand
{
- public Commandtp()
- {
- super("tp");
- }
-
@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
{
switch (args.length)
{
@@ -25,8 +21,10 @@ public class Commandtp extends EssentialsCommand
throw new NotEnoughArgumentsException();
case 1:
- final User player = getPlayer(server, args, 0);
- if (!player.isTeleportEnabled())
+ @Cleanup
+ final IUser player = getPlayer(args, 0);
+ player.acquireReadLock();
+ if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
@@ -36,19 +34,19 @@ public class Commandtp extends EssentialsCommand
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
user.sendMessage(_("teleporting"));
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(player, charge, TeleportCause.COMMAND);
throw new NoChargeException();
default:
- if (!user.isAuthorized("essentials.tp.others"))
+ if (!Permissions.TPOHERE.isAuthorized(user))
{
- throw new Exception(_("noPerm", "essentials.tp.others"));
+ throw new Exception(_("needTpohere"));
}
user.sendMessage(_("teleporting"));
- final User target = getPlayer(server, args, 0);
- final User toPlayer = getPlayer(server, args, 1);
+ final IUser target = getPlayer(args, 0);
+ final IUser toPlayer = getPlayer(args, 1);
if (!target.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", target.getDisplayName()));
@@ -69,7 +67,7 @@ public class Commandtp extends EssentialsCommand
}
@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)
{
@@ -77,8 +75,8 @@ public class Commandtp extends EssentialsCommand
}
sender.sendMessage(_("teleporting"));
- final User target = getPlayer(server, args, 0);
- final User toPlayer = getPlayer(server, args, 1);
+ final IUser target = getPlayer(args, 0);
+ final IUser toPlayer = getPlayer(args, 1);
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
index 95cbc58cd..6ce71b3ba 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
@@ -1,27 +1,25 @@
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.ISettings;
+import com.earth2me.essentials.api.IUser;
+import lombok.Cleanup;
public class Commandtpa extends EssentialsCommand
{
- public Commandtpa()
- {
- super("tpa");
- }
-
@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 < 1)
{
throw new NotEnoughArgumentsException();
}
- User player = getPlayer(server, args, 0);
- if (!player.isTeleportEnabled())
+ @Cleanup
+ IUser player = getPlayer(args, 0);
+ player.acquireReadLock();
+ if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
@@ -36,9 +34,17 @@ public class Commandtpa extends EssentialsCommand
player.sendMessage(_("teleportRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
player.sendMessage(_("typeTpdeny"));
- if (ess.getSettings().getTpaAcceptCancellation() != 0)
+ int tpaAcceptCancellation = 0;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try {
+ tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
+ } finally {
+ settings.unlock();
+ }
+ if (tpaAcceptCancellation != 0)
{
- player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()));
+ player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation));
}
}
user.sendMessage(_("requestSent", player.getDisplayName()));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
index 7af445c51..7f7d36413 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
@@ -1,47 +1,45 @@
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.ISettings;
+import com.earth2me.essentials.api.IUser;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandtpaall extends EssentialsCommand
{
- public Commandtpaall()
- {
- super("tpaall");
- }
-
@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)
{
if (sender instanceof Player)
{
- teleportAAllPlayers(server, sender, ess.getUser(sender));
+ teleportAAllPlayers(sender, ess.getUser((Player)sender));
return;
}
throw new NotEnoughArgumentsException();
}
- final User player = getPlayer(server, args, 0);
- teleportAAllPlayers(server, sender, player);
+ final IUser player = getPlayer(args, 0);
+ teleportAAllPlayers(sender, player);
}
- private void teleportAAllPlayers(final Server server, final CommandSender sender, final User user)
+ private void teleportAAllPlayers(final CommandSender sender, final IUser user)
{
sender.sendMessage(_("teleportAAll"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(onlinePlayer);
+ @Cleanup
+ final IUser player = ess.getUser(onlinePlayer);
+ player.acquireReadLock();
if (user == player)
{
continue;
}
- if (!player.isTeleportEnabled())
+ if (!player.getData().isTeleportEnabled())
{
continue;
}
@@ -55,14 +53,25 @@ public class Commandtpaall extends EssentialsCommand
player.requestTeleport(user, true);
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
- if (ess.getSettings().getTpaAcceptCancellation() != 0)
+ int tpaAcceptCancellation = 0;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
{
- player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()));
+ tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
+ }
+ finally
+ {
+ settings.unlock();
+ }
+ if (tpaAcceptCancellation != 0)
+ {
+ player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation));
}
}
catch (Exception ex)
{
- ess.showError(sender, ex, getName());
+ ess.getCommandHandler().showCommandError(sender, commandName, ex);
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
index 9203f9015..8b7cb7b1b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
@@ -1,26 +1,29 @@
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.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import org.bukkit.OfflinePlayer;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpaccept extends EssentialsCommand
{
- public Commandtpaccept()
- {
- super("tpaccept");
- }
-
@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 (user.getTeleportRequester() == null)
+ {
+ throw new Exception(_("noPendingRequest"));
+ }
- final User target = user.getTeleportRequest();
-
- if (target == null || !target.isOnline())
+ final IUser target = user.getTeleportRequester();
+ if (target == null
+ || !target.isOnline()
+ || (user.isTeleportRequestHere() && !Permissions.TPAHERE.isAuthorized(target))
+ || (!user.isTeleportRequestHere() && !Permissions.TPA.isAuthorized(target) && !Permissions.TPAALL.isAuthorized(target)))
{
throw new Exception(_("noPendingRequest"));
}
@@ -44,14 +47,25 @@ public class Commandtpaccept extends EssentialsCommand
throw new Exception(_("noPendingRequest"));
}
- long timeout = ess.getSettings().getTpaAcceptCancellation();
- if (timeout != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > timeout)
+ int tpaAcceptCancellation = 0;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
+ {
+ tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
+ }
+ finally
+ {
+ settings.unlock();
+ }
+
+ if (tpaAcceptCancellation != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > tpaAcceptCancellation)
{
user.requestTeleport(null, false);
throw new Exception(_("requestTimedOut"));
}
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
if (user.isTpRequestHere())
{
charge.isAffordableFor(user);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
index 9d389ecac..c32a14470 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
@@ -1,27 +1,25 @@
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.ISettings;
+import com.earth2me.essentials.api.IUser;
+import lombok.Cleanup;
public class Commandtpahere extends EssentialsCommand
{
- public Commandtpahere()
- {
- super("tpahere");
- }
-
@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)
{
throw new NotEnoughArgumentsException();
}
- final User player = getPlayer(server, args, 0);
- if (!player.isTeleportEnabled())
+ @Cleanup
+ final IUser player = getPlayer(args, 0);
+ player.acquireReadLock();
+ if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
@@ -33,9 +31,20 @@ public class Commandtpahere extends EssentialsCommand
player.requestTeleport(user, true);
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
- if (ess.getSettings().getTpaAcceptCancellation() != 0)
+ int tpaAcceptCancellation = 0;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
{
- player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()));
+ tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
+ }
+ finally
+ {
+ settings.unlock();
+ }
+ if (tpaAcceptCancellation != 0)
+ {
+ player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation));
}
user.sendMessage(_("requestSent", player.getDisplayName()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index 6335a4a54..fb7efcdcb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -1,8 +1,7 @@
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;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -10,34 +9,29 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpall extends EssentialsCommand
{
- public Commandtpall()
- {
- super("tpall");
- }
-
@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)
{
if (sender instanceof Player)
{
- teleportAllPlayers(server, sender, ess.getUser(sender));
+ teleportAllPlayers(sender, ess.getUser((Player)sender));
return;
}
throw new NotEnoughArgumentsException();
}
- final User player = getPlayer(server, args, 0);
- teleportAllPlayers(server, sender, player);
+ final IUser player = getPlayer(args, 0);
+ teleportAllPlayers(sender, player);
}
- private void teleportAllPlayers(Server server, CommandSender sender, User user)
+ private void teleportAllPlayers(CommandSender sender, IUser user)
{
sender.sendMessage(_("teleportAll"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User player = ess.getUser(onlinePlayer);
+ final IUser player = ess.getUser(onlinePlayer);
if (user == player)
{
continue;
@@ -53,7 +47,7 @@ public class Commandtpall extends EssentialsCommand
}
catch (Exception ex)
{
- ess.showError(sender, ex, getName());
+ ess.getCommandHandler().showCommandError(sender, commandName, ex);
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
index 92bba1054..15d3f7728 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
@@ -1,21 +1,15 @@
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 Commandtpdeny extends EssentialsCommand
{
- public Commandtpdeny()
- {
- super("tpdeny");
- }
-
@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 User player = user.getTeleportRequest();
+ final IUser player = user.getTeleportRequester();
if (player == null)
{
throw new Exception(_("noPendingRequest"));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
index 92eb87226..a995e31f4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
@@ -1,24 +1,21 @@
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;
+import lombok.Cleanup;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtphere extends EssentialsCommand
{
- public Commandtphere()
- {
- super("tphere");
- }
-
@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 User player = getPlayer(server, args, 0);
- if (!player.isTeleportEnabled())
+ @Cleanup
+ final IUser player = getPlayer(args, 0);
+ player.acquireReadLock();
+ if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 4d7ced478..56041fc3e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -1,20 +1,15 @@
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.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpo extends EssentialsCommand
{
- public Commandtpo()
- {
- super("tpo");
- }
-
@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
{
switch (args.length)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 880c4e362..e27613b20 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -1,20 +1,15 @@
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.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpohere extends EssentialsCommand
{
- public Commandtpohere()
- {
- super("tpohere");
- }
-
@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)
{
@@ -22,7 +17,7 @@ public class Commandtpohere extends EssentialsCommand
}
//Just basically the old tphere command
- final User player = getPlayer(server, args, 0, true);
+ final IUser player = getPlayer(args, 0, true);
// Check if user is offline
if (!player.isOnline())
@@ -37,7 +32,7 @@ public class Commandtpohere extends EssentialsCommand
}
// Verify permission
- if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ if (!player.isHidden() || Permissions.TELEPORT_HIDDEN.isAuthorized(user))
{
player.getTeleport().now(user, false, TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
index 75910cd85..ca50a068d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
@@ -1,23 +1,17 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtppos extends EssentialsCommand
{
- public Commandtppos()
- {
- super("tppos");
- }
-
@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 < 3)
{
@@ -36,7 +30,7 @@ public class Commandtppos extends EssentialsCommand
{
location.setPitch(Float.parseFloat(args[4]));
}
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
user.sendMessage(_("teleporting"));
user.getTeleport().teleport(location, charge, TeleportCause.COMMAND);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
index 1fc4c2aa4..2c39271ac 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
@@ -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 Commandtptoggle extends EssentialsCommand
{
- public Commandtptoggle()
- {
- super("tptoggle");
- }
-
@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
{
user.sendMessage(user.toggleTeleportEnabled()
? _("teleportationEnabled")
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
index 6c2c15983..79bbecd29 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
@@ -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 Commandtree extends EssentialsCommand
{
- public Commandtree()
- {
- super("tree");
- }
-
@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 < 1)
@@ -60,8 +54,8 @@ public class Commandtree 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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
index dda1475d0..101e09691 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
@@ -1,20 +1,15 @@
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 Commandunban extends EssentialsCommand
{
- public Commandunban()
- {
- super("unban");
- }
-
@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)
{
@@ -23,7 +18,10 @@ public class Commandunban extends EssentialsCommand
try
{
- final User player = getPlayer(server, args, 0, true);
+ @Cleanup
+ final IUser player = getPlayer(args, 0, true);
+ player.acquireWriteLock();
+ player.getData().setBan(null);
player.setBanned(false);
sender.sendMessage(_("unbannedPlayer"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
index c539a596c..14d2c8ae6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
@@ -1,20 +1,15 @@
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 Commandunbanip extends EssentialsCommand
{
- public Commandunbanip()
- {
- super("unbanip");
- }
-
@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)
{
@@ -22,8 +17,10 @@ public class Commandunbanip extends EssentialsCommand
}
try
{
- final User user = getPlayer(server, args, 0, true);
- ess.getServer().unbanIP(user.getLastLoginAddress());
+ @Cleanup
+ final IUser user = getPlayer(args, 0, true);
+ user.acquireReadLock();
+ ess.getServer().unbanIP(user.getData().getIpAddress());
}
catch (Exception ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
index beff6a77b..a6f6ae477 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
@@ -1,35 +1,34 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
-import com.earth2me.essentials.User;
-import java.util.List;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.permissions.UnlimitedItemPermissions;
import java.util.Locale;
+import java.util.Set;
+import lombok.Cleanup;
import org.bukkit.Material;
-import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandunlimited extends EssentialsCommand
{
- public Commandunlimited()
- {
- super("unlimited");
- }
-
@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)
{
throw new NotEnoughArgumentsException();
}
- User target = user;
+ @Cleanup
+ IUser target = user;
- if (args.length > 1 && user.isAuthorized("essentials.unlimited.others"))
+ if (args.length > 1 && Permissions.UNLIMITED_OTHERS.isAuthorized(user))
{
- target = getPlayer(server, args, 1);
+ target = getPlayer(args, 1);
+ target.acquireReadLock();
}
if (args[0].equalsIgnoreCase("list"))
@@ -39,16 +38,12 @@ public class Commandunlimited extends EssentialsCommand
}
else if (args[0].equalsIgnoreCase("clear"))
{
- final List itemList = target.getUnlimited();
-
- int index = 0;
- while (itemList.size() > index)
+ //TODO: Fix this, the clear should always work, even when the player does not have permission.
+ final Set itemList = target.getData().getUnlimited();
+ for(Material mat : itemList)
{
- final Integer item = itemList.get(index);
- if (toggleUnlimited(user, target, item.toString()) == false)
- {
- index++;
- }
+ toggleUnlimited(user, target, mat.name());
+
}
}
else
@@ -57,49 +52,44 @@ public class Commandunlimited extends EssentialsCommand
}
}
- private String getList(final User target)
+ private String getList(final IUser target)
{
final StringBuilder output = new StringBuilder();
output.append(_("unlimitedItems")).append(" ");
boolean first = true;
- final List items = target.getUnlimited();
+ final Set items = target.getData().getUnlimited();
if (items.isEmpty())
{
output.append(_("none"));
}
- for (Integer integer : items)
+ for (Material mater : items)
{
if (!first)
{
output.append(", ");
}
first = false;
- final String matname = Material.getMaterial(integer).toString().toLowerCase(Locale.ENGLISH).replace("_", "");
+ final String matname = mater.name().toLowerCase(Locale.ENGLISH).replace("_", "");
output.append(matname);
}
return output.toString();
}
- private Boolean toggleUnlimited(final User user, final User target, final String item) throws Exception
+ private Boolean toggleUnlimited(final IUser user, final IUser target, final String item) throws Exception
{
final ItemStack stack = ess.getItemDb().get(item, 1);
stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2));
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
- if (ess.getSettings().permissionBasedItemSpawn()
- && (!user.isAuthorized("essentials.unlimited.item-all")
- && !user.isAuthorized("essentials.unlimited.item-" + itemname)
- && !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId())
- && !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
- && user.isAuthorized("essentials.unlimited.item-bucket"))))
+ if (!UnlimitedItemPermissions.getPermission(stack.getType()).isAuthorized(user))
{
throw new Exception(_("unlimitedItemPermission", itemname));
}
String message = "disableUnlimited";
Boolean enableUnlimited = false;
- if (!target.hasUnlimited(stack))
+ if (!target.getData().hasUnlimited(stack.getType()))
{
message = "enableUnlimited";
enableUnlimited = true;
@@ -114,7 +104,8 @@ public class Commandunlimited extends EssentialsCommand
user.sendMessage(_(message, itemname, target.getDisplayName()));
}
target.sendMessage(_(message, itemname, target.getDisplayName()));
- target.setUnlimited(stack, enableUnlimited);
+ target.acquireWriteLock();
+ target.getData().setUnlimited(stack.getType(), enableUnlimited);
return true;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
index 84df12900..a809c3c8d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
@@ -1,15 +1,16 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
-import com.earth2me.essentials.Warps;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.api.IWarps;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.permissions.WarpPermissions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -18,17 +19,12 @@ public class Commandwarp extends EssentialsCommand
{
private final static int WARPS_PER_PAGE = 20;
- public Commandwarp()
- {
- super("warp");
- }
-
@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 || args[0].matches("[0-9]+"))
{
- if (!user.isAuthorized("essentials.warp.list"))
+ if (!Permissions.WARP_LIST.isAuthorized(user))
{
throw new Exception(_("warpListPermission"));
}
@@ -37,31 +33,31 @@ public class Commandwarp extends EssentialsCommand
}
if (args.length > 0)
{
- User otherUser = null;
- if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers"))
+ IUser otherUser = null;
+ if (args.length == 2 && Permissions.WARP_OTHERS.isAuthorized(user))
{
otherUser = ess.getUser(server.getPlayer(args[1]));
if (otherUser == null)
{
throw new Exception(_("playerNotFound"));
}
- warpUser(user, otherUser, args[0]);
+ warpUser(otherUser, args[0]);
throw new NoChargeException();
}
- warpUser(user, user, args[0]);
+ warpUser(user, args[0]);
throw new NoChargeException();
}
}
@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 || args[0].matches("[0-9]+"))
{
warpList(sender, args);
throw new NoChargeException();
}
- User otherUser = ess.getUser(server.getPlayer(args[1]));
+ IUser otherUser = ess.getUser(server.getPlayer(args[1]));
if (otherUser == null)
{
throw new Exception(_("playerNotFound"));
@@ -74,20 +70,20 @@ public class Commandwarp extends EssentialsCommand
//TODO: Use one of the new text classes, like /help ?
private void warpList(final CommandSender sender, final String[] args) throws Exception
{
- final Warps warps = ess.getWarps();
+ final IWarps warps = ess.getWarps();
if (warps.isEmpty())
{
throw new Exception(_("noWarpsDefined"));
}
- final List warpNameList = new ArrayList(warps.getWarpNames());
+ final List warpNameList = new ArrayList(warps.getList());
- if (sender instanceof User)
+ if (sender instanceof IUser)
{
final Iterator iterator = warpNameList.iterator();
while (iterator.hasNext())
{
final String warpName = iterator.next();
- if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warp." + warpName))
+ if (!WarpPermissions.getPermission(warpName).isAuthorized(sender))
{
iterator.remove();
}
@@ -113,17 +109,18 @@ public class Commandwarp extends EssentialsCommand
}
}
- private void warpUser(final User owner, final User user, final String name) throws Exception
+ private void warpUser(final IUser user, final String name) throws Exception
{
final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
final Trade chargeCmd = new Trade(this.getName(), ess);
final double fullCharge = chargeWarp.getCommandCost(user) + chargeCmd.getCommandCost(user);
final Trade charge = new Trade(fullCharge, ess);
- charge.isAffordableFor(owner);
- if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warp." + name))
+ charge.isAffordableFor(user);
+ if (WarpPermissions.getPermission(name).isAuthorized(user))
{
- throw new Exception(_("warpUsePermission"));
+ user.getTeleport().warp(name, charge, TeleportCause.COMMAND);
+ return;
}
- user.getTeleport().warp(name, charge, TeleportCause.COMMAND);
+ throw new Exception(_("warpUsePermission"));
}
}
\ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
index 1229c9ee4..2df5b1eac 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
@@ -1,22 +1,16 @@
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.World;
import org.bukkit.command.CommandSender;
public class Commandweather extends EssentialsCommand
{
- public Commandweather()
- {
- super("weather");
- }
-
//TODO: Remove duplication
@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)
{
@@ -45,11 +39,11 @@ public class Commandweather extends EssentialsCommand
//TODO: Translate these
@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) //running from console means inserting a world arg before other args
{
- throw new Exception("When running from console, usage is: /" + commandLabel + " [duration]");
+ throw new Exception("When running from console, usage is: /" + commandName + " [duration]");
}
final boolean isStorm = args[1].equalsIgnoreCase("storm");
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
index 6c7919163..cc3a876ec 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
@@ -1,24 +1,23 @@
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.utils.Util;
+import com.earth2me.essentials.api.ISettings;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.user.UserData;
+import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import java.util.Locale;
-import org.bukkit.Server;
+import lombok.Cleanup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandwhois extends EssentialsCommand
{
- public Commandwhois()
- {
- super("whois");
- }
-
@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)
{
@@ -27,7 +26,7 @@ public class Commandwhois extends EssentialsCommand
boolean showhidden = false;
if (sender instanceof Player)
{
- if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
+ if (Permissions.LIST_HIDDEN.isAuthorized(sender))
{
showhidden = true;
}
@@ -37,15 +36,21 @@ public class Commandwhois extends EssentialsCommand
showhidden = true;
}
final String whois = args[0].toLowerCase(Locale.ENGLISH);
- final int prefixLength = Util.stripFormat(ess.getSettings().getNicknamePrefix()).length();
+ @Cleanup
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ final int prefixLength = Util.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
for (Player onlinePlayer : server.getOnlinePlayers())
{
- final User user = ess.getUser(onlinePlayer);
+ @Cleanup
+ final IUser user = ess.getUser(onlinePlayer);
+
if (user.isHidden() && !showhidden)
{
continue;
}
- final String nickName = Util.stripFormat(user.getNickname());
+ user.acquireReadLock();
+ final String nickName = Util.stripFormat(user.getData().getNickname());
if (!whois.equalsIgnoreCase(nickName)
&& !whois.substring(prefixLength).equalsIgnoreCase(nickName)
&& !whois.equalsIgnoreCase(user.getName()))
@@ -61,22 +66,19 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage(_("whoisGod", (user.isGodModeEnabled() ? _("true") : _("false"))));
sender.sendMessage(_("whoisGamemode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH))));
sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
- if (!ess.getSettings().isEcoDisabled())
- {
- sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
- }
- sender.sendMessage(_("whoisJail", (user.isJailed()
- ? user.getJailTimeout() > 0
- ? Util.formatDateDiff(user.getJailTimeout())
+ sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
+ sender.sendMessage(_("whoisJail", (user.getData().isJailed()
+ ? user.getTimestamp(UserData.TimestampType.JAIL) > 0
+ ? DateUtil.formatDateDiff(user.getTimestamp(UserData.TimestampType.JAIL))
: _("true")
: _("false"))));
- sender.sendMessage(user.isAfk()
+ sender.sendMessage(user.getData().isAfk()
? _("whoisStatusAway")
: _("whoisStatusAvailable"));
sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString()));
- final String location = user.getGeoLocation();
+ final String location = user.getData().getGeolocation();
if (location != null
- && (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
+ && Permissions.GEOIP_SHOW.isAuthorized(sender))
{
sender.sendMessage(_("whoisGeoLocation", location));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
index 647115d66..9e2c1b08d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
@@ -1,24 +1,19 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.WorldPermissions;
import java.util.List;
import org.bukkit.Location;
-import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandworld extends EssentialsCommand
{
- public Commandworld()
- {
- super("world");
- }
-
@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
{
World world;
@@ -54,9 +49,11 @@ public class Commandworld extends EssentialsCommand
}
}
- if (ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + world.getName()))
+
+ if (!WorldPermissions.getPermission(world.getName()).isAuthorized(user))
{
- throw new Exception(_("noPerm", "essentials.world." + world.getName()));
+ user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation
+ throw new NoChargeException();
}
double factor;
@@ -76,7 +73,7 @@ public class Commandworld extends EssentialsCommand
final Location loc = user.getLocation();
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
throw new NoChargeException();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
index c8573ba25..0e1ec1dc1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
@@ -1,24 +1,18 @@
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.utils.Util;
+import com.earth2me.essentials.api.IUser;
import java.util.Locale;
-import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
public class Commandworth extends EssentialsCommand
{
- public Commandworth()
- {
- super("worth");
- }
-
//TODO: Remove duplication
@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
{
ItemStack iStack = user.getInventory().getItemInHand();
int amount = iStack.getAmount();
@@ -62,7 +56,7 @@ public class Commandworth 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)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index 6bc0649e9..e3b25177a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -1,34 +1,37 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.IEssentialsModule;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
+import com.earth2me.essentials.economy.Trade;
+import com.earth2me.essentials.api.IEssentials;
+import com.earth2me.essentials.api.IEssentialsModule;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.AbstractSuperpermsPermission;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.permissions.Permission;
-public abstract class EssentialsCommand implements IEssentialsCommand
+public abstract class EssentialsCommand extends AbstractSuperpermsPermission implements IEssentialsCommand
{
- private final transient String name;
+ protected transient String commandName;
protected transient IEssentials ess;
protected transient IEssentialsModule module;
- protected final static Logger logger = Logger.getLogger("Minecraft");
+ protected transient Server server;
+ protected transient Logger logger;
+ private transient String permission;
+ private transient Permission bukkitPerm;
- protected EssentialsCommand(final String name)
- {
- this.name = name;
- }
-
- @Override
- public void setEssentials(final IEssentials ess)
+ public void init(final IEssentials ess, final String commandName)
{
this.ess = ess;
+ this.logger = ess.getLogger();
+ this.server = ess.getServer();
+ this.commandName = commandName;
+ this.permission = "essentials." + commandName;
}
@Override
@@ -37,18 +40,12 @@ public abstract class EssentialsCommand implements IEssentialsCommand
this.module = module;
}
- @Override
- public String getName()
+ protected IUser getPlayer(final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException
{
- return name;
+ return getPlayer(args, pos, false);
}
- protected User getPlayer(final Server server, final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException
- {
- return getPlayer(server, args, pos, false);
- }
-
- protected User getPlayer(final Server server, final String[] args, final int pos, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
+ protected IUser getPlayer(final String[] args, final int pos, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
{
if (args.length <= pos)
{
@@ -58,7 +55,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
{
throw new NoSuchFieldException(_("playerNotFound"));
}
- final User user = ess.getUser(args[pos]);
+ final IUser user = ess.getUser(args[pos]);
if (user != null)
{
if (!getOffline && (!user.isOnline() || user.isHidden()))
@@ -73,13 +70,13 @@ public abstract class EssentialsCommand implements IEssentialsCommand
{
for (Player player : matches)
{
- final User userMatch = ess.getUser(player);
+ final IUser userMatch = ess.getUser(player);
if (userMatch.getDisplayName().startsWith(args[pos]) && (getOffline || !userMatch.isHidden()))
{
return userMatch;
}
}
- final User userMatch = ess.getUser(matches.get(0));
+ final IUser userMatch = ess.getUser(matches.get(0));
if (getOffline || !userMatch.isHidden())
{
return userMatch;
@@ -89,28 +86,28 @@ public abstract class EssentialsCommand implements IEssentialsCommand
}
@Override
- public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception
+ public final void run(final IUser user, final Command cmd, final String commandLabel, final String[] args) throws Exception
{
- final Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
- run(server, user, commandLabel, args);
+ run(user, commandLabel, args);
charge.charge(user);
}
- 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
{
- run(server, (CommandSender)user.getBase(), commandLabel, args);
+ run((CommandSender)user.getBase(), commandLabel, args);
}
@Override
- public final void run(final Server server, final CommandSender sender, final String commandLabel, final Command cmd, final String[] args) throws Exception
+ public final void run(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) throws Exception
{
- run(server, sender, commandLabel, args);
+ run(sender, commandLabel, args);
}
- 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
{
- throw new Exception(_("onlyPlayers", commandLabel));
+ throw new Exception(_("onlyPlayers", commandName));
}
public static String getFinalArg(final String[] args, final int start)
@@ -126,4 +123,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand
}
return bldr.toString();
}
+
+ @Override
+ public String getPermission()
+ {
+ return permission;
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommandHandler.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommandHandler.java
new file mode 100644
index 000000000..f45a55a3f
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommandHandler.java
@@ -0,0 +1,316 @@
+package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.api.*;
+import com.earth2me.essentials.commands.EssentialsCommand;
+import com.earth2me.essentials.commands.IEssentialsCommand;
+import com.earth2me.essentials.commands.NoChargeException;
+import com.earth2me.essentials.commands.NotEnoughArgumentsException;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.PluginCommand;
+import org.bukkit.command.PluginCommandYamlParser;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+
+public class EssentialsCommandHandler implements ICommandHandler
+{
+ private final transient ClassLoader classLoader;
+ private final transient String commandPath;
+ private final transient String permissionPrefix;
+ private final transient IEssentialsModule module;
+ private static final transient Logger LOGGER = Bukkit.getLogger();
+ private final transient Map> altcommands = new HashMap>();
+ private final transient Map disabledList = new HashMap();
+ private final transient Map commands = new HashMap();
+ private final transient IEssentials ess;
+
+ public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentials ess)
+ {
+ this(classLoader, commandPath, permissionPrefix, null, ess);
+ }
+
+ public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module, IEssentials ess)
+ {
+ this.classLoader = classLoader;
+ this.commandPath = commandPath;
+ this.permissionPrefix = permissionPrefix;
+ this.module = module;
+ this.ess = ess;
+ for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
+ {
+ if (plugin.isEnabled())
+ {
+ addPlugin(plugin);
+ }
+ }
+ }
+
+ @Override
+ public boolean handleCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
+ {
+ boolean disabled = false;
+ boolean overridden = false;
+ ISettings settings = ess.getSettings();
+ settings.acquireReadLock();
+ try
+ {
+ disabled = settings.getData().getCommands().isDisabled(command.getName());
+ overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName());
+ }
+ finally
+ {
+ settings.unlock();
+ }
+ // Allow plugins to override the command via onCommand
+ if (!overridden && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
+ {
+ final PluginCommand pc = getAlternative(commandLabel);
+ if (pc != null)
+ {
+
+ executed(commandLabel, pc.getLabel());
+ try
+ {
+ return pc.execute(sender, commandLabel, args);
+ }
+ catch (final Exception ex)
+ {
+ final ArrayList elements = new ArrayList(Arrays.asList(ex.getStackTrace()));
+ elements.remove(0);
+ final ArrayList toRemove = new ArrayList();
+ for (final StackTraceElement e : elements)
+ {
+ if (e.getClassName().equals("com.earth2me.essentials.Essentials"))
+ {
+ toRemove.add(e);
+ }
+ }
+ elements.removeAll(toRemove);
+ final StackTraceElement[] trace = elements.toArray(new StackTraceElement[elements.size()]);
+ ex.setStackTrace(trace);
+ ex.printStackTrace();
+ sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
+ return true;
+ }
+ }
+ }
+
+ try
+ {
+ IUser user = null;
+ if (sender instanceof Player)
+ {
+ user = ess.getUser((Player)sender);
+ LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
+ }
+
+ // Check for disabled commands
+ if (disabled)
+ {
+ return true;
+ }
+
+ final String commandName = command.getName().toLowerCase(Locale.ENGLISH);
+ IEssentialsCommand cmd = commands.get(commandName);
+ if (cmd == null)
+ {
+ try
+ {
+ cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + commandName).newInstance();
+ cmd.init(ess, commandName);
+ cmd.setEssentialsModule(module);
+ commands.put(commandName, cmd);
+ }
+ catch (Exception ex)
+ {
+ sender.sendMessage(_("commandNotLoaded", commandName));
+ LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandName), ex);
+ return true;
+ }
+ }
+
+ // Check authorization
+ if (sender != null && !cmd.isAuthorized(sender))
+ {
+ LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
+ user.sendMessage(_("noAccessCommand"));
+ return true;
+ }
+
+ // Run the command
+ try
+ {
+ if (user == null)
+ {
+ cmd.run(sender, command, commandLabel, args);
+ }
+ else
+ {
+ user.acquireReadLock();
+ try
+ {
+ cmd.run(user, command, commandLabel, args);
+ }
+ finally
+ {
+ user.unlock();
+ }
+ }
+ return true;
+ }
+ catch (NoChargeException ex)
+ {
+ return true;
+ }
+ catch (NotEnoughArgumentsException ex)
+ {
+ sender.sendMessage(command.getDescription());
+ sender.sendMessage(command.getUsage().replaceAll("", commandLabel));
+ if (!ex.getMessage().isEmpty())
+ {
+ sender.sendMessage(ex.getMessage());
+ }
+ return true;
+ }
+ catch (Throwable ex)
+ {
+ showCommandError(sender, commandLabel, ex);
+ return true;
+ }
+ }
+ catch (Throwable ex)
+ {
+ LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
+ return true;
+ }
+ }
+
+ @Override
+ public void showCommandError(final CommandSender sender, final String commandLabel, final Throwable exception)
+ {
+ sender.sendMessage(_("errorWithMessage", exception.getMessage()));
+ if (ess.getSettings().isDebug())
+ {
+ LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
+ }
+ }
+
+ @Override
+ public void onReload()
+ {
+ }
+
+ public final void addPlugin(final Plugin plugin)
+ {
+ if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
+ {
+ return;
+ }
+ final List commands = PluginCommandYamlParser.parse(plugin);
+ final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
+
+ for (Command command : commands)
+ {
+ final PluginCommand pc = (PluginCommand)command;
+ final List labels = new ArrayList(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 plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
+ if (plugincommands == null)
+ {
+ plugincommands = new ArrayList();
+ 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>> iterator = altcommands.entrySet().iterator();
+ while (iterator.hasNext())
+ {
+ final Map.Entry