diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..ae800ac6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+# Top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+
+# Set the charset, and space indention
+[*.java]
+charset = utf-8
+indent_style = space
+indent_size = 4
diff --git a/.floo b/.floo
new file mode 100644
index 00000000..b0f2c28e
--- /dev/null
+++ b/.floo
@@ -0,0 +1,3 @@
+{
+ "url": "https://floobits.com/AuthMe-Team/AuthMeReloaded"
+}
\ No newline at end of file
diff --git a/.flooignore b/.flooignore
new file mode 100644
index 00000000..e9c355d0
--- /dev/null
+++ b/.flooignore
@@ -0,0 +1,123 @@
+### Java ###
+*.class
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+#*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+
+### Intellij ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
+
+*.iml
+
+## Directory-based project format:
+.idea/
+# if you remove the above rule, at least ignore the following:
+
+# User-specific stuff:
+# .idea/workspace.xml
+# .idea/tasks.xml
+# .idea/dictionaries
+
+# Sensitive or high-churn files:
+# .idea/dataSources.ids
+# .idea/dataSources.xml
+# .idea/sqlDataSources.xml
+# .idea/dynamic.xml
+# .idea/uiDesigner.xml
+
+# Gradle:
+# .idea/gradle.xml
+# .idea/libraries
+
+# Mongo Explorer plugin:
+# .idea/mongoSettings.xml
+
+## File-based project format:
+*.ipr
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+
+
+### Eclipse ###
+*.pydevproject
+.metadata
+.gradle
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+
+# Eclipse Core
+.project
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+# PDT-specific
+.buildpath
+
+# sbteclipse plugin
+.target
+
+# TeXlipse plugin
+.texlipse
+
+
+### Maven ###
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+
+
+### NetBeans ###
+nbproject/private/
+build/
+nbbuild/
+dist/
+nbdist/
+nbactions.xml
+nb-configuration.xml
+.nb-gradle/
diff --git a/.gitignore b/.gitignore
index a0348ece..607894b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,7 @@
-# Created by https://www.gitignore.io
-
-### Java ###
+### Java files ###
*.class
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
+# Package Files
#*.jar
*.war
*.ear
@@ -15,40 +10,27 @@
hs_err_pid*
+
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
-
+# Ignore project files
*.iml
-## Directory-based project format:
-.idea/
-# if you remove the above rule, at least ignore the following:
+# Ignore IDEA directory
+.idea/*
-# User-specific stuff:
-# .idea/workspace.xml
-# .idea/tasks.xml
-# .idea/dictionaries
+# Include the project's code style settings file
+!.idea/codeStyleSettings.xml
-# Sensitive or high-churn files:
-# .idea/dataSources.ids
-# .idea/dataSources.xml
-# .idea/sqlDataSources.xml
-# .idea/dynamic.xml
-# .idea/uiDesigner.xml
+# Include the project's dictionary
+!.idea/dictionaries/
+!.idea/dictionaries/*
-# Gradle:
-# .idea/gradle.xml
-# .idea/libraries
-
-# Mongo Explorer plugin:
-# .idea/mongoSettings.xml
-
-## File-based project format:
+# File-based project format:
*.ipr
*.iws
-## Plugin-specific files:
-
+### Plugin-specific files: ###
# IntelliJ
/out/
@@ -64,6 +46,7 @@ crashlytics.properties
crashlytics-build.properties
+
### Eclipse ###
*.pydevproject
.metadata
@@ -103,6 +86,7 @@ local.properties
.texlipse
+
### Maven ###
target/
pom.xml.tag
@@ -114,6 +98,7 @@ dependency-reduced-pom.xml
buildNumber.properties
+
### NetBeans ###
nbproject/private/
build/
@@ -123,3 +108,9 @@ nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/
+
+
+
+### Git ###
+# Don't exclude the .gitignore itself
+!.gitignore
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
new file mode 100644
index 00000000..174665cb
--- /dev/null
+++ b/.idea/codeStyleSettings.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
diff --git a/.idea/dictionaries/Tim.xml b/.idea/dictionaries/Tim.xml
new file mode 100644
index 00000000..1cd4a23c
--- /dev/null
+++ b/.idea/dictionaries/Tim.xml
@@ -0,0 +1,7 @@
+
+
+
+ authme
+
+
+
diff --git a/README.md b/README.md
index 220a2ced..64169871 100644
--- a/README.md
+++ b/README.md
@@ -47,8 +47,7 @@ McStats: http://mcstats.org/plugin/AuthMe
#####Running Requirements:
>- Java 1.7 (should work also with Java 1.8)
>- Spigot or CraftBukkit (1.7.10 or 1.8.X)
->- Vault
->- Protocollib
+>- ProtocolLib (optional, required by the protectInventory feature)
###Plugin Description:
@@ -129,7 +128,7 @@ typing commands or use the inventory. It can also kick players with uncommon lon
#####Donate
-Do you like my work? Do you want to buy me a coffee? :)
+
Do you like our work? Do you want to buy us a coffee? :)
EUR:
USD: 
diff --git a/lib/EssentialsGroupManager-2.13.1.jar b/lib/EssentialsGroupManager-2.13.1.jar
new file mode 100644
index 00000000..245bcc14
Binary files /dev/null and b/lib/EssentialsGroupManager-2.13.1.jar differ
diff --git a/lib/Permission-3.1.6.jar b/lib/Permission-3.1.6.jar
new file mode 100644
index 00000000..31c3e5d9
Binary files /dev/null and b/lib/Permission-3.1.6.jar differ
diff --git a/lib/bPermissions-2.12-DEV.jar b/lib/bPermissions-2.12-DEV.jar
new file mode 100644
index 00000000..2b63156b
Binary files /dev/null and b/lib/bPermissions-2.12-DEV.jar differ
diff --git a/lib/zPermissions-1.3beta1.jar b/lib/zPermissions-1.3beta1.jar
new file mode 100644
index 00000000..c00f8873
Binary files /dev/null and b/lib/zPermissions-1.3beta1.jar differ
diff --git a/pom.xml b/pom.xml
index 7547c90b..ceeaefca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,533 +1,702 @@
-
- 4.0.0
-
- fr.xephi
- authme
- 5.1-SNAPSHOT
- jar
-
- AuthMeReloaded
- Authentication plugin for CraftBukkit/Spigot!
- 2013
- http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
-
-
-
- AuthMe-Team
- https://github.com/AuthMe-Team
-
-
-
- scm:git:https://github.com/Xephi/AuthMeReloaded.git
- scm:git:git@github.com:Xephi/AuthMeReloaded.git
- http://github.com/Xephi/AuthMeReloaded
-
-
-
- jenkins
- http://ci.xephi.fr/job/AuthMeReloaded/
-
-
-
- GitHub
- https://github.com/Xephi/AuthMeReloaded/issues
-
-
-
-
- The GNU General Public Licence version 3 (GPLv3)
- http://www.gnu.org/licenses/gpl-3.0.html
-
-
-
-
+
+ 4.0.0
+
+ fr.xephi
+ authme
+ 5.1-SNAPSHOT
+ jar
+
+ AuthMeReloaded
+ Authentication plugin for CraftBukkit/Spigot!
+ 2013
+ http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
+
+
+
+ AuthMe-Team
+ https://github.com/AuthMe-Team
+
+
+
+ scm:git:https://github.com/Xephi/AuthMeReloaded.git
+ scm:git:git@github.com:Xephi/AuthMeReloaded.git
+ http://github.com/Xephi/AuthMeReloaded
+
+
+
+ jenkins
+ http://ci.xephi.fr/job/AuthMeReloaded/
+
+
+
+ GitHub
+ https://github.com/Xephi/AuthMeReloaded/issues
+
+
+
+
+ The GNU General Public Licence version 3 (GPLv3)
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+
+
+
+ 3.3.3
+
+
+
+ UTF-8
+
- UTF-8
+ AuthMe
fr.xephi.authme.AuthMe
- CustomBuild
- [Xephi, sgdc3, DNx5, timvisee, games647]
-
-
- 1.7
-
-
- 1.8.8-R0.1-SNAPSHOT
-
+ Xephi, sgdc3, DNx5, timvisee, games647, ljacqu
+ Unknown
-
- AuthMe-${project.version}
-
-
- .
- true
- src/main/resources/
-
- *.yml
-
-
-
- ./messages/
- false
- src/main/resources/messages/
-
- *.yml
-
-
-
-
+
+ 1.7
+
+
+ 1.8.8-R0.1-SNAPSHOT
+
+
+
+
+ jenkins
+
+
+ env.BUILD_NUMBER
+
+
+
+ ${env.BUILD_NUMBER}
+
+
+
+
+
+ AuthMe-${project.version}
+ src/main/java
+ src/test/java
+
+
+
+ .
+ true
+ src/main/resources/
+
+ plugin.yml
+
+
+
+ .
+ false
+ src/main/resources/
+
+ *.yml
+
+
+ plugin.yml
+
+
+
+ ./messages/
+ false
+ src/main/resources/messages/
+
+ *.yml
+
+
+
+
+
+ src/test/resources
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.codehaus.mojo
+ buildnumber-maven-plugin
+ [1.0,)
+
+ create-timestamp
+
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.3
+
+ 1.7
+ ${javaVersion}
+
+
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.3
-
- 1.7
- ${javaVersion}
-
+ org.codehaus.mojo
+ buildnumber-maven-plugin
+ 1.4
+
+ dd-MM-yy_HH-mm
+ build.time
+
+
+
+ generate-resources
+
+ create-timestamp
+
+
+
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.4.2
-
- false
- false
-
-
- org.mcstats
- fr.xephi.authme
-
-
- com.google.gson
- fr.xephi.authme.libs.gson
-
-
- com.zaxxer.hikari
- fr.xephi.authme.libs.hikari
-
-
- org.slf4j
- fr.xephi.authme.libs.slf4j
-
-
- com.maxmind.geoip
- fr.xephi.authme.libs.geoip
-
-
- net.ricecode.similarity
- fr.xephi.authme.libs.similarity
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
-
-
-
-
- spigot-repo
- http://hub.spigotmc.org/nexus/content/groups/public
-
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.2
+
+ false
+ false
+
+
+ org.mcstats
+ fr.xephi.authme
+
+
+ com.google.gson
+ fr.xephi.authme.libs.gson
+
+
+ com.zaxxer.hikari
+ fr.xephi.authme.libs.hikari
+
+
+ org.slf4j
+ fr.xephi.authme.libs.slf4j
+
+
+ com.maxmind.geoip
+ fr.xephi.authme.libs.geoip
+
+
+ net.ricecode.similarity
+ fr.xephi.authme.libs.similarity
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
-
-
- ess-repo
- http://ci.drtshock.net/plugin/repository/everything
-
+
+
+
+ spigot-repo
+ http://hub.spigotmc.org/nexus/content/groups/public
+
-
-
- minelink-thirdparty
- http://repo.minelink.net/content/repositories/public
-
+
+
+ ess-repo
+ http://ci.drtshock.net/plugin/repository/everything
+
-
-
- dmulloy2-repo
- http://repo.dmulloy2.net/content/groups/public/
-
+
+
+ minelink-thirdparty
+ http://repo.minelink.net/content/repositories/public
+
-
-
- onarandombox
- http://repo.onarandombox.com/content/groups/public
-
+
+
+ dmulloy2-repo
+ http://repo.dmulloy2.net/content/groups/public/
+
-
-
- vault-repo
- http://nexus.theyeticave.net/content/repositories/pub_releases
-
+
+
+ onarandombox
+ http://repo.onarandombox.com/content/groups/public
+
-
-
- luricos-releases
- http://repo.luricos.de/content/repositories/releases
-
+
+
+ vault-repo
+ http://nexus.theyeticave.net/content/repositories/pub_releases
+
-
-
- xephi-repo
- http://ci.xephi.fr/plugin/repository/everything/
-
-
+
+
+ luricos-releases
+ http://repo.luricos.de/content/repositories/releases
+
-
-
-
- com.zaxxer
- HikariCP
- 2.4.1
- compile
-
-
- slf4j-api
- org.slf4j
-
-
- true
-
-
- org.slf4j
- slf4j-jdk14
- 1.7.12
- compile
- true
-
+
+
+ xephi-repo
+ http://ci.xephi.fr/plugin/repository/everything/
+
-
-
- org.apache.logging.log4j
- log4j-core
-
- 2.0-beta9
- provided
- true
-
+
+
+ pex-repo
+ http://pex-repo.aoeu.xyz/
+
+
-
-
- com.sun.mail
- mailapi
- 1.5.4
- compile
- true
-
-
- com.sun.mail
- smtp
- 1.5.4
- compile
- true
-
-
- org.apache.commons
- commons-email
- 1.4
- compile
- true
-
+
+
+
+ com.zaxxer
+ HikariCP
+ 2.4.1
+ compile
+
+
+ slf4j-api
+ org.slf4j
+
+
+ true
+
+
+ org.slf4j
+ slf4j-jdk14
+ 1.7.12
+ compile
+ true
+
-
-
- com.google.code.gson
- gson
- 2.4
- compile
- true
-
+
+
+ org.apache.logging.log4j
+ log4j-core
+
+ 2.0-beta9
+ provided
+ true
+
-
-
- com.maxmind.geoip
- geoip-api
- 1.2.15
- compile
- true
-
+
+
+ org.apache.commons
+ commons-email
+ 1.4
+ compile
+ true
+
-
-
- org.mcstats.bukkit
- metrics
- R8-SNAPSHOT
- compile
-
-
- org.bukkit
- bukkit
-
-
- true
-
+
+
+ com.google.code.gson
+ gson
+ 2.4
+ compile
+ true
+
-
-
- org.bukkit
- bukkit
- ${bukkitVersion}
- provided
- true
-
-
- junit
- junit
-
-
- json-simple
- com.googlecode.json-simple
-
-
- gson
- com.google.code.gson
-
-
- persistence-api
- javax.persistence
-
-
-
+
+
+ com.maxmind.geoip
+ geoip-api
+ 1.2.15
+ compile
+ true
+
-
-
- com.comphenix.protocol
- ProtocolLib
- 3.6.5-SNAPSHOT
- provided
- true
-
-
- cglib-nodep
- cglib
-
-
- BukkitExecutors
- com.comphenix.executors
-
-
-
+
+
+ org.mcstats.bukkit
+ metrics
+ R8-SNAPSHOT
+ compile
+
+
+ org.bukkit
+ bukkit
+
+
+ true
+
-
-
- net.milkbowl.vault
- VaultAPI
- 1.5
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- true
-
+
+
+ org.bukkit
+ bukkit
+ ${bukkitVersion}
+ provided
+ true
+
+
+ junit
+ junit
+
+
+ json-simple
+ com.googlecode.json-simple
+
+
+ gson
+ com.google.code.gson
+
+
+ persistence-api
+ javax.persistence
+
+
+
-
-
- com.onarandombox.multiversecore
- Multiverse-Core
- 2.5
- jar
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- AllPay
- com.fernferret.allpay
-
-
- Vault
- net.milkbowl.vault
-
-
- CommandHandler
- com.pneumaticraft.commandhandler
-
-
- SerializationConfig
- me.main__.util
-
-
- Logging
- com.dumptruckman.minecraft
-
-
- metrics
- org.mcstats.bukkit
-
-
- buscript
- com.dumptruckman.minecraft
-
-
- junit
- junit
-
-
- true
-
+
+
+ com.comphenix.protocol
+ ProtocolLib
+ 3.6.5-SNAPSHOT
+ provided
+ true
+
+
+ cglib-nodep
+ cglib
+
+
+ BukkitExecutors
+ com.comphenix.executors
+
+
+
-
-
- net.ess3
- EssentialsX
- 2.0.1-SNAPSHOT
- provided
-
-
- org.spigotmc
- spigot-api
-
-
- true
-
+
+
+ ru.tehkode
+ PermissionsEx
+ 1.23.1
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ net.gravitydevelopment.updater
+ updater
+
+
+ commons-dbcp
+ commons-dbcp
+
+
+ AccountsClient
+ com.mojang
+
+
+
-
-
- net.minelink
- CombatTagPlus
- 1.2.1-SNAPSHOT
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- CombatTagPlusHook
- net.minelink
-
-
- CombatTagPlusFactions-v1_6
- net.minelink
-
-
- CombatTagPlusCompat-v1_7_R3
- net.minelink
-
-
- CombatTagPlusFactions-v1_8
- net.minelink
-
-
- CombatTagPlusCompat-v1_7_R4
- net.minelink
-
-
- CombatTagPlusWG-v5
- net.minelink
-
-
- CombatTagPlusWG-v6
- net.minelink
-
-
- CombatTagPlusCompat-API
- net.minelink
-
-
- CombatTagPlusFactions-v2_6
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R3
- net.minelink
-
-
- CombatTagPlusFactions-v2_7
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R2
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R1
- net.minelink
-
-
- metrics-lite
- org.mcstats.bukkit
-
-
- true
-
+
+
+ org.anjocaido
+ groupmanager
+ 2.13.1
+ system
+ ${basedir}/lib/EssentialsGroupManager-2.13.1.jar
+
-
-
- de.luricos.bukkit
- xAuth
- 2.6
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- updater
- net.gravitydevelopment.updater
-
-
- lombok
- org.projectlombok
-
-
- EssentialsGroupManager
- net.ess3
-
-
- PermissionsEx
- ru.tehkode
-
-
- AccountsClient
- com.mojang
-
-
- log4j-core
- org.apache.logging.log4j
-
-
- true
-
+
+
+ de.bananaco
+ bpermissions
+ 1.12-DEV
+ system
+ ${basedir}/lib/bPermissions-2.12-DEV.jar
+
+
+
+
+ org.tyrannyofheaven.bukkit
+ zPermissions
+ 1.3-SNAPSHOT
+ system
+ ${basedir}/lib/zPermissions-1.3beta1.jar
+
+
+
+
+ com.nijiko
+ permissions
+ 3.1.6
+ system
+ ${basedir}/lib/Permission-3.1.6.jar
+
+
+
+
+ net.milkbowl.vault
+ VaultAPI
+ 1.5
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ true
+
+
+
+
+ com.onarandombox.multiversecore
+ Multiverse-Core
+ 2.5
+ jar
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ AllPay
+ com.fernferret.allpay
+
+
+ VaultAPI
+ net.milkbowl.vault
+
+
+ CommandHandler
+ com.pneumaticraft.commandhandler
+
+
+ SerializationConfig
+ me.main__.util
+
+
+ Logging
+ com.dumptruckman.minecraft
+
+
+ metrics
+ org.mcstats.bukkit
+
+
+ buscript
+ com.dumptruckman.minecraft
+
+
+ junit
+ junit
+
+
+ true
+
+
+
+
+ net.ess3
+ EssentialsX
+ 2.0.1-SNAPSHOT
+ provided
+
+
+ org.spigotmc
+ spigot-api
+
+
+ true
+
+
+
+
+ net.minelink
+ CombatTagPlus
+ 1.2.1-SNAPSHOT
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ CombatTagPlusHook
+ net.minelink
+
+
+ CombatTagPlusFactions-v1_6
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_7_R3
+ net.minelink
+
+
+ CombatTagPlusFactions-v1_8
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_7_R4
+ net.minelink
+
+
+ CombatTagPlusWG-v5
+ net.minelink
+
+
+ CombatTagPlusWG-v6
+ net.minelink
+
+
+ CombatTagPlusCompat-API
+ net.minelink
+
+
+ CombatTagPlusFactions-v2_6
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R3
+ net.minelink
+
+
+ CombatTagPlusFactions-v2_7
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R2
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R1
+ net.minelink
+
+
+ metrics-lite
+ org.mcstats.bukkit
+
+
+ true
+
+
+
+
+ de.luricos.bukkit
+ xAuth
+ 2.6
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ updater
+ net.gravitydevelopment.updater
+
+
+ lombok
+ org.projectlombok
+
+
+ EssentialsGroupManager
+ net.ess3
+
+
+ PermissionsEx
+ ru.tehkode
+
+
+ AccountsClient
+ com.mojang
+
+
+ log4j-core
+ org.apache.logging.log4j
+
+
+ true
+
+
+
+
+ junit
+ junit
+ test
+ 4.12
+ true
+
+
+ org.hamcrest
+ java-hamcrest
+ test
+ 2.0.0.0
+ true
+
+
+ org.mockito
+ mockito-core
+ test
+ 2.0.5-beta
+ true
+
net.ricecode
string-similarity
1.0.0
- compile
- true
+ compile
+ true
-
+
diff --git a/src/main/java/fr/xephi/authme/AntiBot.java b/src/main/java/fr/xephi/authme/AntiBot.java
new file mode 100644
index 00000000..194e4cdf
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/AntiBot.java
@@ -0,0 +1,99 @@
+package fr.xephi.authme;
+
+import fr.xephi.authme.permission.UserPermission;
+import fr.xephi.authme.settings.MessageKey;
+import fr.xephi.authme.settings.Messages;
+import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Wrapper;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The AntiBot Service Management class.
+ */
+public class AntiBot {
+
+ private static final Wrapper wrapper = Wrapper.getInstance();
+ private static final AuthMe plugin = wrapper.getAuthMe();
+ private static final Messages messages = wrapper.getMessages();
+ private static final List antibotPlayers = new ArrayList<>();
+ private static AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
+
+ public static void setupAntiBotService() {
+ if (!Settings.enableAntiBot) {
+ return;
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ antiBotStatus = AntiBotStatus.LISTENING;
+ }
+ }, 2400);
+ }
+
+ public static void overrideAntiBotStatus(boolean activated) {
+ if (antiBotStatus == AntiBotStatus.DISABLED) {
+ return;
+ }
+ if (activated) {
+ antiBotStatus = AntiBotStatus.ACTIVE;
+ } else {
+ antiBotStatus = AntiBotStatus.LISTENING;
+ }
+ }
+
+ public static AntiBotStatus getAntiBotStatus() {
+ return antiBotStatus;
+ }
+
+ public static void activateAntiBot() {
+ antiBotStatus = AntiBotStatus.ACTIVE;
+ for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE)) {
+ Bukkit.broadcastMessage(s);
+ }
+
+ wrapper.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ if (antiBotStatus == AntiBotStatus.ACTIVE) {
+ antiBotStatus = AntiBotStatus.LISTENING;
+ antibotPlayers.clear();
+ for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) {
+ Bukkit.broadcastMessage(s.replace("%m", "" + Settings.antiBotDuration));
+ }
+ }
+ }
+ }, Settings.antiBotDuration * 1200);
+ }
+
+ public static void checkAntiBot(final Player player) {
+ if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
+ return;
+ }
+ if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
+ return;
+ }
+
+ antibotPlayers.add(player.getName().toLowerCase());
+ if (antibotPlayers.size() > Settings.antiBotSensibility) {
+ activateAntiBot();
+ return;
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ antibotPlayers.remove(player.getName().toLowerCase());
+ }
+ }, 300);
+ }
+
+ public enum AntiBotStatus {
+ LISTENING,
+ DISABLED,
+ ACTIVE
+ }
+
+}
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java
index d8d80afc..4f1886fc 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -1,34 +1,7 @@
package fr.xephi.authme;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.LogManager;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.World;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.RegisteredServiceProvider;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitTask;
-import org.mcstats.Metrics;
-import org.mcstats.Metrics.Graph;
-
import com.earth2me.essentials.Essentials;
import com.onarandombox.MultiverseCore.MultiverseCore;
-
import fr.xephi.authme.api.API;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.cache.auth.PlayerAuth;
@@ -39,131 +12,431 @@ import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.command.CommandHandler;
import fr.xephi.authme.converter.Converter;
import fr.xephi.authme.converter.ForceFlatToSqlite;
-import fr.xephi.authme.datasource.CacheDataSource;
-import fr.xephi.authme.datasource.DataSource;
-import fr.xephi.authme.datasource.DatabaseCalls;
-import fr.xephi.authme.datasource.FlatFile;
-import fr.xephi.authme.datasource.MySQL;
-import fr.xephi.authme.datasource.SQLite;
+import fr.xephi.authme.datasource.*;
import fr.xephi.authme.hooks.BungeeCordMessage;
import fr.xephi.authme.hooks.EssSpawn;
-import fr.xephi.authme.listener.AuthMeBlockListener;
-import fr.xephi.authme.listener.AuthMeEntityListener;
-import fr.xephi.authme.listener.AuthMeInventoryPacketAdapter;
-import fr.xephi.authme.listener.AuthMePlayerListener;
-import fr.xephi.authme.listener.AuthMePlayerListener16;
-import fr.xephi.authme.listener.AuthMePlayerListener18;
-import fr.xephi.authme.listener.AuthMeServerListener;
+import fr.xephi.authme.listener.*;
import fr.xephi.authme.modules.ModuleManager;
+import fr.xephi.authme.permission.PermissionsManager;
+import fr.xephi.authme.permission.UserPermission;
import fr.xephi.authme.process.Management;
-import fr.xephi.authme.settings.Messages;
-import fr.xephi.authme.settings.OtherAccounts;
-import fr.xephi.authme.settings.Settings;
-import fr.xephi.authme.settings.Spawn;
+import fr.xephi.authme.settings.*;
+import fr.xephi.authme.util.GeoLiteAPI;
+import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
-import net.milkbowl.vault.permission.Permission;
import net.minelink.ctplus.CombatTagPlus;
+import org.apache.logging.log4j.LogManager;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
+import org.mcstats.Metrics;
+import org.mcstats.Metrics.Graph;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+/**
+ * The AuthMe main class.
+ */
public class AuthMe extends JavaPlugin {
- /** Defines the name of the plugin. */
- // TODO: Create a getter method for this constant, and make it private
- public static final String PLUGIN_NAME = "AuthMeReloaded";
- /** Defines the current AuthMeReloaded version name. */
- private static final String PLUGIN_VERSION_NAME = "5.1-SNAPSHOT";
- /** Defines the current AuthMeReloaded version code. */
- private static final int PLUGIN_VERSION_CODE = 100; // Increase this number
- // by one when an update
- // is released
+ /**
+ * Defines the name of the plugin.
+ */
+ private static final String PLUGIN_NAME = "AuthMeReloaded";
+
+ private static String pluginVersion = "N/D";
+ private static String pluginBuildNumber = "Unknown";
private static AuthMe plugin;
private static Server server;
- private Logger authmeLogger;
-
- // TODO: Move this to a better place! -- timvisee
- private CommandHandler commandHandler = null;
public Management management;
public NewAPI api;
public SendMailSSL mail;
- private Settings settings;
- private Messages m;
public DataManager dataManager;
public DataSource database;
- private JsonCache playerBackup;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
- public boolean antibotMod = false;
- public boolean delayedAntiBot = true;
- // Hooks TODO: move into modules
- public Permission permission;
+ // Hooks TODO: Move into modules
public Essentials ess;
public MultiverseCore multiverse;
public CombatTagPlus combatTagPlus;
public AuthMeInventoryPacketAdapter inventoryProtector;
- // Module manager
- private ModuleManager moduleManager;
+ // Data maps and stuff
+ // TODO: Move into a manager
+ public final ConcurrentHashMap sessions = new ConcurrentHashMap<>();
+ public final ConcurrentHashMap captcha = new ConcurrentHashMap<>();
+ public final ConcurrentHashMap cap = new ConcurrentHashMap<>();
+ public final ConcurrentHashMap realIp = new ConcurrentHashMap<>();
- // TODO: Create Manager for fields below
- public ConcurrentHashMap sessions = new ConcurrentHashMap<>();
- public ConcurrentHashMap captcha = new ConcurrentHashMap<>();
- public ConcurrentHashMap cap = new ConcurrentHashMap<>();
- public ConcurrentHashMap realIp = new ConcurrentHashMap<>();
-
- // In case we need to cache PlayerAuths, prevent connection before it's done
+ // If cache is enabled, prevent any connection before the players data caching is completed.
+ // TODO: Move somewhere
private boolean canConnect = true;
- public boolean canConnect() {
- return canConnect;
- }
-
- public void setCanConnect(boolean canConnect) {
- this.canConnect = canConnect;
- }
+ private CommandHandler commandHandler = null;
+ private PermissionsManager permsMan = null;
+ private Settings settings;
+ private Messages messages;
+ private JsonCache playerBackup;
+ private ModuleManager moduleManager;
+ /**
+ * Returns the plugin's instance.
+ *
+ * @return AuthMe
+ */
public static AuthMe getInstance() {
return plugin;
}
+ /**
+ * Get the plugin's name.
+ *
+ * @return Plugin name.
+ */
+ public static String getPluginName() {
+ return PLUGIN_NAME;
+ }
+
+ /**
+ * Get the current installed AuthMeReloaded version name.
+ *
+ * @return The version name of the currently installed AuthMeReloaded instance.
+ */
+ public static String getPluginVersion() {
+ return pluginVersion;
+ }
+
+ /**
+ * Get the current installed AuthMeReloaded version code.
+ *
+ * @return The version code of the currently installed AuthMeReloaded instance.
+ */
+ public static String getPluginBuildNumber() {
+ return pluginBuildNumber;
+ }
+
+ /**
+ * Returns the plugin's Settings.
+ *
+ * @return Settings
+ */
public Settings getSettings() {
return settings;
}
- public void setMessages(Messages m) {
- this.m = m;
- }
+ /**
+ * Returns the Messages instance.
+ *
+ * @return Messages
+ */
public Messages getMessages() {
- return m;
+ return messages;
}
+ /**
+ * Set the Messages instance.
+ *
+ * @param m Messages
+ */
+ public void setMessages(Messages m) {
+ this.messages = m;
+ }
+
+ /**
+ * Returns if players are allowed to join the server.
+ *
+ * @return boolean
+ */
+ public boolean canConnect() {
+ return canConnect;
+ }
+
+ /**
+ * Define if players are allowed to join the server.
+ *
+ * @param canConnect boolean
+ */
+ public void setCanConnect(boolean canConnect) {
+ this.canConnect = canConnect;
+ }
+
+ // Get version and build number of the plugin
+ // TODO: enhance this
+ private void setupConstants() {
+ String versionRaw = this.getDescription().getVersion();
+ int index = versionRaw.lastIndexOf("-");
+ if (index != -1) {
+ pluginVersion = versionRaw.substring(0, index);
+ pluginBuildNumber = versionRaw.substring(index + 1);
+ if (pluginBuildNumber.startsWith("b")) {
+ pluginBuildNumber = pluginBuildNumber.substring(1);
+ }
+ }
+ }
+
+ /**
+ * Method called when the server enables the plugin.
+ *
+ * @see org.bukkit.plugin.Plugin#onEnable()
+ */
@Override
public void onEnable() {
- // Set the Instance
+ // Set various instances
server = getServer();
- authmeLogger = Logger.getLogger("AuthMe");
plugin = this;
+ setupConstants();
+
+ // Set up the permissions manager
+ setupPermissionsManager();
// Set up and initialize the command handler
+ setupCommandHandler();
+
+ // Set up the module manager
+ setupModuleManager();
+
+ // Load settings and custom configurations, if it fails, stop the server due to security reasons.
+ if (loadSettings()) {
+ server.shutdown();
+ setEnabled(false);
+ return;
+ }
+
+ // Setup otherAccounts file
+ this.otherAccounts = OtherAccounts.getInstance();
+
+ // Setup messages
+ this.messages = new Messages(Settings.messageFile, Settings.messagesLanguage);
+
+ // Set up Metrics
+ setupMetrics();
+
+ // Set console filter
+ setupConsoleFilter();
+
+ // AntiBot delay
+ AntiBot.setupAntiBotService();
+
+ // Download and load GeoIp.dat file if absent
+ GeoLiteAPI.isDataAvailable();
+
+ // Set up the mail API
+ setupMailApi();
+
+ // Hooks
+ // Check Combat Tag Plus Version
+ checkCombatTagPlus();
+
+ // Check Multiverse
+ checkMultiverse();
+
+ // Check Essentials
+ checkEssentials();
+
+ // Check if the ProtocolLib is available. If so we could listen for
+ // inventory protection
+ checkProtocolLib();
+ // End of Hooks
+
+ // Do a backup on start
+ new PerformBackup(plugin).doBackup(PerformBackup.BackupCause.START);
+
+ // Connect to the database and setup tables
+ try {
+ setupDatabase();
+ } catch (Exception e) {
+ ConsoleLogger.writeStackTrace(e);
+ ConsoleLogger.showError(e.getMessage());
+ ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
+ stopOrUnload();
+ return;
+ }
+
+ // Setup the inventory backup
+ playerBackup = new JsonCache();
+
+ // Set the DataManager
+ dataManager = new DataManager(this);
+
+ // Set up the new API
+ setupApi();
+
+ // Set up the management
+ management = new Management(this);
+
+ // Set up the BungeeCord hook
+ setupBungeeCordHook();
+
+ // Reload support hook
+ reloadSupportHook();
+
+ // Register event listeners
+ registerEventListeners();
+
+ // Purge on start if enabled
+ autoPurge();
+
+ // Start Email recall task if needed
+ recallEmail();
+
+ // Show settings warnings
+ showSettingsWarnings();
+
+ // Sponsor messages
+ ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
+ ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
+ ConsoleLogger.info("Do you want a good game server? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!");
+
+ // Successful message
+ ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
+ }
+
+ /**
+ * Set up the module manager.
+ */
+ private void setupModuleManager() {
+ // TODO: Clean this up!
+ // TODO: split the plugin in more modules
+ // TODO: log number of loaded modules
+
+ // Define the module manager instance
+ moduleManager = new ModuleManager(this);
+
+ // Load the modules
+ // int loaded = moduleManager.loadModules();
+ }
+
+ /**
+ * Set up the mail API, if enabled.
+ */
+ private void setupMailApi() {
+ // Make sure the mail API is enabled
+ if (Settings.getmailAccount.isEmpty() || Settings.getmailPassword.isEmpty()) {
+ return;
+ }
+
+ // Set up the mail API
+ this.mail = new SendMailSSL(this);
+ }
+
+ /**
+ * Show the settings warnings, for various risky settings.
+ */
+ private void showSettingsWarnings() {
+ // Force single session disabled
+ if (!Settings.isForceSingleSessionEnabled) {
+ ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
+ }
+
+ // Session timeout disabled
+ if (Settings.getSessionTimeout == 0 && Settings.isSessionsEnabled) {
+ ConsoleLogger.showError("WARNING!!! You set session timeout to 0, this may cause security issues!");
+ }
+ }
+
+ /**
+ * Register all event listeners.
+ */
+ private void registerEventListeners() {
+ // Get the plugin manager instance
+ PluginManager pluginManager = server.getPluginManager();
+
+ // Register event listeners
+ pluginManager.registerEvents(new AuthMePlayerListener(this), this);
+ pluginManager.registerEvents(new AuthMeBlockListener(this), this);
+ pluginManager.registerEvents(new AuthMeEntityListener(this), this);
+ pluginManager.registerEvents(new AuthMeServerListener(this), this);
+
+ // Try to register 1.6 player listeners
+ try {
+ Class.forName("org.bukkit.event.player.PlayerEditBookEvent");
+ pluginManager.registerEvents(new AuthMePlayerListener16(this), this);
+ } catch (ClassNotFoundException ignore) {
+ }
+
+ // Try to register 1.8 player listeners
+ try {
+ Class.forName("org.bukkit.event.player.PlayerInteractAtEntityEvent");
+ pluginManager.registerEvents(new AuthMePlayerListener18(this), this);
+ } catch (ClassNotFoundException ignore) {
+ }
+ }
+
+ private void reloadSupportHook() {
+ if (database != null) {
+ int playersOnline = Utils.getOnlinePlayers().size();
+ if (playersOnline < 1) {
+ database.purgeLogged();
+ } else if (Settings.reloadSupport) {
+ for (PlayerAuth auth : database.getLoggedPlayers()) {
+ if (auth == null) {
+ continue;
+ }
+ auth.setLastLogin(new Date().getTime());
+ database.updateSession(auth);
+ PlayerCache.getInstance().addPlayer(auth);
+ }
+ }
+ }
+ }
+
+ /**
+ * Set up the BungeeCord hook.
+ */
+ private void setupBungeeCordHook() {
+ if (Settings.bungee) {
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+ Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
+ }
+ }
+
+ /**
+ * Set up the API. This sets up the new and the old API.
+ */
+ @SuppressWarnings("deprecation")
+ private void setupApi() {
+ // Set up the API
+ api = new NewAPI(this);
+
+ // Setup the old deprecated API
+ new API(this);
+ }
+
+ /**
+ * Set up the command handler.
+ */
+ private void setupCommandHandler() {
this.commandHandler = new CommandHandler(false);
this.commandHandler.init();
+ }
- // TODO: split the plugin in more modules
- moduleManager = new ModuleManager(this);
- @SuppressWarnings("unused")
- int loaded = moduleManager.loadModules();
-
- // TODO: remove vault as hard dependency
- PluginManager pm = server.getPluginManager();
-
- // Setup the Logger
- if (authmeLogger == null)
- authmeLogger = this.getLogger();
- else authmeLogger.setParent(this.getLogger());
-
- // Load settings and custom configurations
+ /**
+ * Load the plugin's settings.
+ *
+ * @return True on success, false on failure.
+ */
+ private boolean loadSettings() {
// TODO: new configuration style (more files)
try {
settings = new Settings(this);
@@ -172,16 +445,34 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("Can't load the configuration file... Something went wrong, to avoid security issues the server will shutdown!");
server.shutdown();
- return;
+ return true;
}
+ return false;
+ }
- // Setup otherAccounts file
- otherAccounts = OtherAccounts.getInstance();
+ /**
+ * Set up the console filter.
+ */
+ private void setupConsoleFilter() {
+ if (Settings.removePassword) {
+ ConsoleFilter filter = new ConsoleFilter();
+ getLogger().setFilter(filter);
+ Bukkit.getLogger().setFilter(filter);
+ Logger.getLogger("Minecraft").setFilter(filter);
+ // Set Log4J Filter
+ try {
+ Class.forName("org.apache.logging.log4j.core.Filter");
+ setLog4JFilter();
+ } catch (ClassNotFoundException | NoClassDefFoundError e) {
+ ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
+ }
+ }
+ }
- // Setup messages
- m = Messages.getInstance();
-
- // Start the metrics service
+ /**
+ * Set up Metrics.
+ */
+ private void setupMetrics() {
try {
Metrics metrics = new Metrics(this);
Graph messagesLanguage = metrics.createGraph("Messages language");
@@ -212,170 +503,16 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("Can't start Metrics! The plugin will work anyway...");
}
-
- // Set Console Filter
- if (Settings.removePassword) {
- ConsoleFilter filter = new ConsoleFilter();
- this.getLogger().setFilter(filter);
- Bukkit.getLogger().setFilter(filter);
- Logger.getLogger("Minecraft").setFilter(filter);
- authmeLogger.setFilter(filter);
- // Set Log4J Filter
- try {
- Class.forName("org.apache.logging.log4j.core.Filter");
- setLog4JFilter();
- } catch (ClassNotFoundException | NoClassDefFoundError e) {
- ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
- }
- }
-
- // AntiBot delay
- if (Settings.enableAntiBot) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
-
- @Override
- public void run() {
- delayedAntiBot = false;
- }
- }, 2400);
- }
-
- // Download GeoIp.dat file
- Utils.checkGeoIP();
-
- // Load MailApi if needed
- if (!Settings.getmailAccount.isEmpty() && !Settings.getmailPassword.isEmpty()) {
- mail = new SendMailSSL(this);
- }
-
- // Find Permissions
- checkVault();
-
- // Check Combat Tag Plus Version
- checkCombatTagPlus();
-
- // Check Multiverse
- checkMultiverse();
-
- // Check Essentials
- checkEssentials();
-
- // Check if the protocollib is available. If so we could listen for
- // inventory protection
- checkProtocolLib();
-
- // Do backup on start if enabled
- if (Settings.isBackupActivated && Settings.isBackupOnStart) {
- // Do backup and check return value!
- if (new PerformBackup(this).doBackup()) {
- ConsoleLogger.info("Backup performed correctly");
- } else {
- ConsoleLogger.showError("Error while performing the backup!");
- }
- }
-
- // Connect to the database and setup tables
- try {
- setupDatabase();
- } catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
- ConsoleLogger.showError(e.getMessage());
- ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
- stopOrUnload();
- return;
- }
-
- // Setup the inventory backup
- playerBackup = new JsonCache();
-
- // Set the DataManager
- dataManager = new DataManager(this);
-
- // Setup the new API
- api = new NewAPI(this);
- // Setup the old deprecated API
- new API(this);
-
- // Setup Management
- management = new Management(this);
-
- // Bungeecord hook
- if (Settings.bungee) {
- Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
- Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
- }
-
- // Reload support hook
- if (database != null) {
- int playersOnline = Utils.getOnlinePlayers().size();
- if (playersOnline < 1) {
- database.purgeLogged();
- } else if (Settings.reloadSupport) {
- for (PlayerAuth auth : database.getLoggedPlayers()) {
- if (auth == null)
- continue;
- auth.setLastLogin(new Date().getTime());
- database.updateSession(auth);
- PlayerCache.getInstance().addPlayer(auth);
- }
- }
- }
-
- // Register events
- pm.registerEvents(new AuthMePlayerListener(this), this);
- // Try to register 1.6 player listeners
- try {
- Class.forName("org.bukkit.event.player.PlayerEditBookEvent");
- pm.registerEvents(new AuthMePlayerListener16(this), this);
- } catch (ClassNotFoundException ignore) {
- }
- // Try to register 1.8 player listeners
- try {
- Class.forName("org.bukkit.event.player.PlayerInteractAtEntityEvent");
- pm.registerEvents(new AuthMePlayerListener18(this), this);
- } catch (ClassNotFoundException ignore) {
- }
- pm.registerEvents(new AuthMeBlockListener(this), this);
- pm.registerEvents(new AuthMeEntityListener(this), this);
- pm.registerEvents(new AuthMeServerListener(this), this);
-
- // TODO: This is moved to CommandManager.registerCommands() handled by
- // AuthMe.onCommand() -- timvisee
- // Register commands
- // getCommand("authme").setExecutor(new AdminCommand(this));
- // getCommand("register").setExecutor(new RegisterCommand(this));
- // getCommand("login").setExecutor(new LoginCommand(this));
- // getCommand("changepassword").setExecutor(new
- // ChangePasswordCommand(this));
- // getCommand("logout").setExecutor(new LogoutCommand(this));
- // getCommand("unregister").setExecutor(new UnregisterCommand(this));
- // getCommand("email").setExecutor(new EmailCommand(this));
- // getCommand("captcha").setExecutor(new CaptchaCommand(this));
- // getCommand("converter").setExecutor(new ConverterCommand(this));
-
- // Purge on start if enabled
- autoPurge();
-
- // Start Email recall task if needed
- recallEmail();
-
- // Configuration Security Warnings
- if (!Settings.isForceSingleSessionEnabled) {
- ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
- }
- if (Settings.getSessionTimeout == 0 && Settings.isSessionsEnabled) {
- ConsoleLogger.showError("WARNING!!! You set session timeout to 0, this may cause security issues!");
- }
-
- // Sponsor messages
- ConsoleLogger.info("AuthMe hooks perfectly with the VERYGAMES server hosting!");
- ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
- ConsoleLogger.info("Do you want a good gameserver? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!");
-
- // Successful message
- ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
}
+ // Show the exception message and stop/unload the server/plugin as defined
+ // in the configuration
+
+ /**
+ * Method onDisable.
+ *
+ * @see org.bukkit.plugin.Plugin#onDisable()
+ */
@Override
public void onDisable() {
// Save player data
@@ -387,12 +524,7 @@ public class AuthMe extends JavaPlugin {
}
// Do backup on stop if enabled
- if (Settings.isBackupActivated && Settings.isBackupOnStop) {
- boolean Backup = new PerformBackup(this).doBackup();
- if (Backup)
- ConsoleLogger.info("Backup performed correctly.");
- else ConsoleLogger.showError("Error while performing the backup!");
- }
+ new PerformBackup(plugin).doBackup(PerformBackup.BackupCause.STOP);
// Unload modules
moduleManager.unloadModules();
@@ -406,6 +538,8 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
}
+ // Initialize and setup the database
+
// Stop/unload the server/plugin as defined in the configuration
public void stopOrUnload() {
if (Settings.isStopEnabled) {
@@ -416,14 +550,9 @@ public class AuthMe extends JavaPlugin {
}
}
- // Show the exception message and stop/unload the server/plugin as defined
- // in the configuration
- public void stopOrUnload(Exception e) {
- ConsoleLogger.showError(e.getMessage());
- stopOrUnload();
- }
-
- // Initialize and setup the database
+ /**
+ * Method setupDatabase.
+ */
public void setupDatabase() throws Exception {
if (database != null)
database.close();
@@ -468,6 +597,23 @@ public class AuthMe extends JavaPlugin {
}
}
+ /**
+ * Set up the permissions manager.
+ */
+ public void setupPermissionsManager() {
+ this.permsMan = new PermissionsManager(Bukkit.getServer(), this, getLogger());
+ this.permsMan.setup();
+ }
+
+ /**
+ * Get the permissions manager instance.
+ *
+ * @return Permissions Manager instance.
+ */
+ public PermissionsManager getPermissionsManager() {
+ return this.permsMan;
+ }
+
// Set the console filter to remove the passwords
private void setLog4JFilter() {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@@ -480,21 +626,6 @@ public class AuthMe extends JavaPlugin {
});
}
- // Check the presence of the Vault plugin and a permissions provider
- public void checkVault() {
- if (server.getPluginManager().isPluginEnabled("Vault")) {
- RegisteredServiceProvider permissionProvider = server.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
- if (permissionProvider != null) {
- permission = permissionProvider.getProvider();
- ConsoleLogger.info("Vault detected, hooking with the " + permission.getName() + " permissions system...");
- } else {
- ConsoleLogger.showError("Vault detected, but I can't find any permissions plugin to hook with!");
- }
- } else {
- permission = null;
- }
- }
-
// Get the Multiverse plugin
public void checkMultiverse() {
if (Settings.multiverse && server.getPluginManager().isPluginEnabled("Multiverse-Core")) {
@@ -515,7 +646,7 @@ public class AuthMe extends JavaPlugin {
try {
ess = (Essentials) server.getPluginManager().getPlugin("Essentials");
ConsoleLogger.info("Hooked correctly with Essentials");
- } catch (Exception | NoClassDefFoundError ingnored) {
+ } catch (Exception | NoClassDefFoundError ignored) {
ess = null;
}
} else {
@@ -540,7 +671,7 @@ public class AuthMe extends JavaPlugin {
try {
combatTagPlus = (CombatTagPlus) server.getPluginManager().getPlugin("CombatTagPlus");
ConsoleLogger.info("Hooked correctly with CombatTagPlus");
- } catch (Exception | NoClassDefFoundError ingnored) {
+ } catch (Exception | NoClassDefFoundError ignored) {
combatTagPlus = null;
}
} else {
@@ -550,36 +681,28 @@ public class AuthMe extends JavaPlugin {
// Check the presence of the ProtocolLib plugin
public void checkProtocolLib() {
- if (Settings.protectInventoryBeforeLogInEnabled) {
- if (server.getPluginManager().isPluginEnabled("ProtocolLib")) {
- inventoryProtector = new AuthMeInventoryPacketAdapter(this);
- inventoryProtector.register();
- } else {
+ if (!server.getPluginManager().isPluginEnabled("ProtocolLib")) {
+ if (Settings.protectInventoryBeforeLogInEnabled) {
ConsoleLogger.showError("WARNING!!! The protectInventory feature requires ProtocolLib! Disabling it...");
Settings.protectInventoryBeforeLogInEnabled = false;
+ getSettings().set("settings.restrictions.ProtectInventoryBeforeLogIn", false);
+ }
+ return;
+ }
+
+ if (Settings.protectInventoryBeforeLogInEnabled) {
+ if (inventoryProtector == null) {
+ inventoryProtector = new AuthMeInventoryPacketAdapter(this);
+ inventoryProtector.register();
+ }
+ } else {
+ if (inventoryProtector != null) {
+ inventoryProtector.unregister();
+ inventoryProtector = null;
}
}
}
- // Check if a player/command sender have a permission
- public boolean authmePermissible(Player player, String perm) {
- if (player.hasPermission(perm)) {
- return true;
- } else if (permission != null) {
- return permission.playerHas(player, perm);
- }
- return false;
- }
-
- public boolean authmePermissible(CommandSender sender, String perm) {
- if (sender.hasPermission(perm)) {
- return true;
- } else if (permission != null) {
- return permission.has(sender, perm);
- }
- return false;
- }
-
// Save Player Data
public void savePlayer(Player player) {
if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) {
@@ -612,7 +735,7 @@ public class AuthMe extends JavaPlugin {
public Player generateKickPlayer(Collection extends Player> collection) {
Player player = null;
for (Player p : collection) {
- if (!(authmePermissible(p, "authme.vip"))) {
+ if (!getPermissionsManager().hasPermission(p, UserPermission.IS_VIP)) {
player = p;
break;
}
@@ -637,19 +760,15 @@ public class AuthMe extends JavaPlugin {
}
ConsoleLogger.info("AutoPurging the Database: " + cleared.size() + " accounts removed!");
if (Settings.purgeEssentialsFile && this.ess != null)
- dataManager.purgeEssentials(cleared); // name to UUID convertion
- // needed with latest versions
+ dataManager.purgeEssentials(cleared);
if (Settings.purgePlayerDat)
- dataManager.purgeDat(cleared); // name to UUID convertion needed
- // with latest versions of MC
+ dataManager.purgeDat(cleared);
if (Settings.purgeLimitedCreative)
dataManager.purgeLimitedCreative(cleared);
if (Settings.purgeAntiXray)
- dataManager.purgeAntiXray(cleared); // IDK if it uses UUID or
- // names... (Actually it purges
- // only names!)
+ dataManager.purgeAntiXray(cleared);
if (Settings.purgePermissions)
- dataManager.purgePermissions(cleared, permission);
+ dataManager.purgePermissions(cleared);
}
// Return the spawn location of a player
@@ -674,12 +793,12 @@ public class AuthMe extends JavaPlugin {
return spawnLoc;
}
- // Return the default spawnpoint of a world
+ // Return the default spawn point of a world
private Location getDefaultSpawn(World world) {
return world.getSpawnLocation();
}
- // Return the multiverse spawnpoint of a world
+ // Return the multiverse spawn point of a world
private Location getMultiverseSpawn(World world) {
if (multiverse != null && Settings.multiverse) {
try {
@@ -691,7 +810,7 @@ public class AuthMe extends JavaPlugin {
return null;
}
- // Return the essentials spawnpoint
+ // Return the essentials spawn point
private Location getEssentialsSpawn() {
if (essentialsSpawn != null) {
return essentialsSpawn;
@@ -699,7 +818,7 @@ public class AuthMe extends JavaPlugin {
return null;
}
- // Return the authme soawnpoint
+ // Return the AuthMe spawn point
private Location getAuthMeSpawn(Player player) {
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) {
return Spawn.getInstance().getFirstSpawn();
@@ -710,15 +829,6 @@ public class AuthMe extends JavaPlugin {
return player.getWorld().getSpawnLocation();
}
- public void switchAntiBotMod(boolean mode) {
- this.antibotMod = mode;
- Settings.switchAntiBotMod(mode);
- }
-
- public boolean getAntiBotModMode() {
- return this.antibotMod;
- }
-
private void recallEmail() {
if (!Settings.recallEmail)
return;
@@ -733,7 +843,7 @@ public class AuthMe extends JavaPlugin {
if (PlayerCache.getInstance().isAuthenticated(name)) {
String email = database.getAuth(name).getEmail();
if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com"))
- m.send(player, "add_email");
+ messages.send(player, MessageKey.ADD_EMAIL_MESSAGE);
}
}
}
@@ -741,7 +851,7 @@ public class AuthMe extends JavaPlugin {
}, 1, 1200 * Settings.delayRecall);
}
- public String replaceAllInfos(String message, Player player) {
+ public String replaceAllInfo(String message, Player player) {
int playersOnline = Utils.getOnlinePlayers().size();
message = message.replace("&", "\u00a7");
message = message.replace("{PLAYER}", player.getName());
@@ -752,7 +862,7 @@ public class AuthMe extends JavaPlugin {
message = message.replace("{WORLD}", player.getWorld().getName());
message = message.replace("{SERVER}", server.getServerName());
message = message.replace("{VERSION}", server.getBukkitVersion());
- message = message.replace("{COUNTRY}", Utils.getCountryName(getIP(player)));
+ message = message.replace("{COUNTRY}", GeoLiteAPI.getCountryName(getIP(player)));
return message;
}
@@ -764,8 +874,8 @@ public class AuthMe extends JavaPlugin {
ip = realIp.get(name);
}
if (Settings.checkVeryGames)
- if (getVeryGamesIP(player) != null)
- ip = getVeryGamesIP(player);
+ if (getVeryGamesIp(player) != null)
+ ip = getVeryGamesIp(player);
return ip;
}
@@ -792,44 +902,38 @@ public class AuthMe extends JavaPlugin {
}
/**
- * Get Player real IP through VeryGames method
+ * Gets a player's real IP through VeryGames method.
*
- * @param player
- * player
+ * @param player The player to process.
+ *
+ * @return The real IP of the player.
*/
+ // TODO: Cache the result or run it async, it can cause trouble if verygames server isn't responding.
@Deprecated
- public String getVeryGamesIP(Player player) {
+ public String getVeryGamesIp(Player player) {
String realIP = player.getAddress().getAddress().getHostAddress();
String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
- sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", "" + player.getAddress().getPort());
+ sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress())
+ .replace("%PORT%", "" + player.getAddress().getPort());
try {
URL url = new URL(sUrl);
- URLConnection urlc = url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
- String inputLine = in.readLine();
- if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error") && !inputLine.contains("error")) {
- realIP = inputLine;
+ URLConnection urlCon = url.openConnection();
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()))) {
+ String inputLine = in.readLine();
+ if (!StringUtils.isEmpty(inputLine) && !inputLine.equalsIgnoreCase("error")
+ && !inputLine.contains("error")) {
+ realIP = inputLine;
+ }
+ } catch (IOException e) {
+ ConsoleLogger.showError("Could not read from Very Games API - " + StringUtils.formatException(e));
}
- } catch (Exception ignored) {
+ } catch (IOException e) {
+ ConsoleLogger.showError("Could not fetch Very Games API with URL '" + sUrl + "' - "
+ + StringUtils.formatException(e));
}
return realIP;
}
- @Deprecated
- public String getCountryCode(String ip) {
- return Utils.getCountryCode(ip);
- }
-
- @Deprecated
- public String getCountryName(String ip) {
- return Utils.getCountryName(ip);
- }
-
- /**
- * Get the command handler instance.
- *
- * @return Command handler.
- */
public CommandHandler getCommandHandler() {
return this.commandHandler;
}
@@ -837,20 +941,16 @@ public class AuthMe extends JavaPlugin {
/**
* Handle Bukkit commands.
*
- * @param sender
- * The command sender (Bukkit).
- * @param cmd
- * The command (Bukkit).
- * @param commandLabel
- * The command label (Bukkit).
- * @param args
- * The command arguments (Bukkit).
+ * @param sender The command sender (Bukkit).
+ * @param cmd The command (Bukkit).
+ * @param commandLabel The command label (Bukkit).
+ * @param args The command arguments (Bukkit).
*
* @return True if the command was executed, false otherwise.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd,
- String commandLabel, String[] args) {
+ String commandLabel, String[] args) {
// Get the command handler, and make sure it's valid
CommandHandler commandHandler = this.getCommandHandler();
if (commandHandler == null)
@@ -861,22 +961,10 @@ public class AuthMe extends JavaPlugin {
}
/**
- * Get the current installed AuthMeReloaded version name.
- *
- * @return The version name of the currently installed AuthMeReloaded
- * instance.
+ * Return the management instance.
*/
- public static String getVersionName() {
- return PLUGIN_VERSION_NAME;
+ public Management getManagement() {
+ return management;
}
- /**
- * Get the current installed AuthMeReloaded version code.
- *
- * @return The version code of the currently installed AuthMeReloaded
- * instance.
- */
- public static int getVersionCode() {
- return PLUGIN_VERSION_CODE;
- }
}
diff --git a/src/main/java/fr/xephi/authme/ConsoleFilter.java b/src/main/java/fr/xephi/authme/ConsoleFilter.java
index 10ac38de..7e12ef10 100644
--- a/src/main/java/fr/xephi/authme/ConsoleFilter.java
+++ b/src/main/java/fr/xephi/authme/ConsoleFilter.java
@@ -4,14 +4,23 @@ import java.util.logging.Filter;
import java.util.logging.LogRecord;
/**
+ * Console filter Class
*
* @author Xephi59
+ * @version $Revision: 1.0 $
*/
public class ConsoleFilter implements Filter {
public ConsoleFilter() {
}
+ /**
+ * Method isLoggable.
+ *
+ * @param record LogRecord
+ *
+ * @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord)
+ */
@Override
public boolean isLoggable(LogRecord record) {
try {
@@ -22,8 +31,8 @@ public class ConsoleFilter implements Filter {
return true;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
return true;
- String playername = record.getMessage().split(" ")[0];
- record.setMessage(playername + " issued an AuthMe command!");
+ String playerName = record.getMessage().split(" ")[0];
+ record.setMessage(playerName + " issued an AuthMe command!");
return true;
} catch (NullPointerException npe) {
return true;
diff --git a/src/main/java/fr/xephi/authme/ConsoleLogger.java b/src/main/java/fr/xephi/authme/ConsoleLogger.java
index e2c4ba5f..89031804 100644
--- a/src/main/java/fr/xephi/authme/ConsoleLogger.java
+++ b/src/main/java/fr/xephi/authme/ConsoleLogger.java
@@ -1,61 +1,82 @@
package fr.xephi.authme;
+import com.google.common.base.Throwables;
+import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.StringUtils;
+import fr.xephi.authme.util.Wrapper;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.logging.Logger;
-import com.google.common.base.Throwables;
+/**
+ * The plugin's static logger.
+ */
+public final class ConsoleLogger {
-import fr.xephi.authme.api.NewAPI;
-import fr.xephi.authme.settings.Settings;
-
-public class ConsoleLogger {
-
- private static final Logger log = AuthMe.getInstance().getLogger();
+ private static Wrapper wrapper = Wrapper.getInstance();
private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]");
+ private ConsoleLogger() {
+ // Service class
+ }
+
+ /**
+ * Print an info message.
+ *
+ * @param message String
+ */
public static void info(String message) {
- log.info("[AuthMe] " + message);
- if (Settings.useLogging) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
- }
- writeLog(dateTime + " " + message);
+ wrapper.getLogger().info(message);
+ if (!Settings.useLogging) {
+ return;
}
+ writeLog("" + message);
}
+ /**
+ * Print an error message.
+ *
+ * @param message String
+ */
public static void showError(String message) {
- log.warning("[AuthMe] " + message);
- if (Settings.useLogging) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
- }
- writeLog(dateTime + " ERROR: " + message);
+ wrapper.getLogger().warning(message);
+ if (!Settings.useLogging) {
+ return;
}
+ writeLog("ERROR: " + message);
}
- public static void writeLog(String message) {
+ /**
+ * Write a message into the log file with a TimeStamp.
+ *
+ * @param message String
+ */
+ private static void writeLog(String message) {
+ String dateTime;
+ synchronized (df) {
+ dateTime = df.format(new Date());
+ }
try {
- Files.write(Settings.LOG_FILE.toPath(), (message + NewAPI.newline).getBytes(),
- StandardOpenOption.APPEND,
- StandardOpenOption.CREATE);
+ Files.write(Settings.LOG_FILE.toPath(), (dateTime + ": " + message + StringUtils.newline).getBytes(),
+ StandardOpenOption.APPEND,
+ StandardOpenOption.CREATE);
} catch (IOException ignored) {
}
}
+ /**
+ * Write a StackTrace into the log.
+ *
+ * @param ex Exception
+ */
public static void writeStackTrace(Exception ex) {
- if (Settings.useLogging) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
- }
- writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex));
+ if (!Settings.useLogging) {
+ return;
}
+ writeLog("" + Throwables.getStackTraceAsString(ex));
}
}
diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java
index 95a9ab53..c3847f3b 100644
--- a/src/main/java/fr/xephi/authme/DataManager.java
+++ b/src/main/java/fr/xephi/authme/DataManager.java
@@ -1,196 +1,269 @@
-package fr.xephi.authme;
-
-import java.io.File;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import fr.xephi.authme.settings.Settings;
-import fr.xephi.authme.util.Utils;
-import net.milkbowl.vault.permission.Permission;
-
-public class DataManager {
-
- public AuthMe plugin;
-
- public DataManager(AuthMe plugin) {
- this.plugin = plugin;
- }
-
- public void run() {
- }
-
- public synchronized OfflinePlayer getOfflinePlayer(final String name) {
- ExecutorService executor = Executors.newSingleThreadExecutor();
- Future result = executor.submit(new Callable() {
-
- public synchronized OfflinePlayer call() throws Exception {
- OfflinePlayer result = null;
- try {
- for (OfflinePlayer op : Bukkit.getOfflinePlayers())
- if (op.getName().equalsIgnoreCase(name)) {
- result = op;
- break;
- }
- } catch (Exception e) {
- }
- return result;
- }
- });
- try {
- return result.get();
- } catch (Exception e) {
- return (null);
- } finally {
- executor.shutdown();
- }
- }
-
- public synchronized void purgeAntiXray(List cleared) {
- int i = 0;
- for (String name : cleared) {
- try {
- org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null)
- continue;
- String playerName = player.getName();
- File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- } catch (Exception e) {
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
- }
-
- public synchronized void purgeLimitedCreative(List cleared) {
- int i = 0;
- for (String name : cleared) {
- try {
- org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null)
- continue;
- String playerName = player.getName();
- File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- } catch (Exception e) {
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
- }
-
- public synchronized void purgeDat(List cleared) {
- int i = 0;
- for (String name : cleared) {
- try {
- org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null) {
- continue;
- }
-
- try {
- File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
- playerFile.delete();
- i++;
- } catch(Exception ignore) {
- File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- }
- } catch (Exception ignore) {
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
- }
-
- @SuppressWarnings("deprecation")
- public void purgeEssentials(List cleared) {
- int i = 0;
- for (String name : cleared) {
- try {
- File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
- playerFile.delete();
- i++;
- } catch (Exception e) {
- File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
- if (playerFile.exists()) {
- playerFile.delete();
- i++;
- }
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
- }
-
- public synchronized void purgePermissions(List cleared,
- Permission permission) {
- int i = 0;
- for (String name : cleared) {
- try {
- OfflinePlayer p = this.getOfflinePlayer(name);
- for (String group : permission.getPlayerGroups((Player) p)) {
- permission.playerRemoveGroup(null, p, group);
- }
- i++;
- } catch (Exception e) {
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");
- }
-
- public boolean isOnline(Player player, final String name) {
- if (player.isOnline())
- return true;
- ExecutorService executor = Executors.newSingleThreadExecutor();
- Future result = executor.submit(new Callable() {
-
- @Override
- public synchronized Boolean call() throws Exception {
- for (OfflinePlayer op : Utils.getOnlinePlayers())
- if (op.getName().equalsIgnoreCase(name)) {
- return true;
- }
- return false;
- }
- });
- try {
- return result.get();
- } catch (Exception e) {
- return false;
- } finally {
- executor.shutdown();
- }
- }
-
- public Player getOnlinePlayerLower(String name) {
- name = name.toLowerCase();
- for (Player player : Utils.getOnlinePlayers()) {
- if (player.getName().equalsIgnoreCase(name))
- return player;
- }
- return null;
- }
-}
+package fr.xephi.authme;
+
+import fr.xephi.authme.permission.PermissionsManager;
+import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ */
+public class DataManager {
+
+ public final AuthMe plugin;
+
+ /**
+ * Constructor for DataManager.
+ *
+ * @param plugin AuthMe
+ */
+ public DataManager(AuthMe plugin) {
+ this.plugin = plugin;
+ }
+
+ /**
+ * Method getOfflinePlayer.
+ *
+ * @param name String
+ *
+ * @return OfflinePlayer
+ */
+ public synchronized OfflinePlayer getOfflinePlayer(final String name) {
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Future result = executor.submit(new Callable() {
+
+ public synchronized OfflinePlayer call() throws Exception {
+ OfflinePlayer result = null;
+ try {
+ for (OfflinePlayer op : Bukkit.getOfflinePlayers())
+ if (op.getName().equalsIgnoreCase(name)) {
+ result = op;
+ break;
+ }
+ } catch (Exception ignored) {
+ }
+ return result;
+ }
+ });
+ try {
+ return result.get();
+ } catch (Exception e) {
+ return (null);
+ } finally {
+ executor.shutdown();
+ }
+ }
+
+ /**
+ * Method purgeAntiXray.
+ *
+ * @param cleared List
+ */
+ public synchronized void purgeAntiXray(List cleared) {
+ int i = 0;
+ for (String name : cleared) {
+ try {
+ org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
+ if (player == null)
+ continue;
+ String playerName = player.getName();
+ File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
+ }
+
+ /**
+ * Method purgeLimitedCreative.
+ *
+ * @param cleared List
+ */
+ public synchronized void purgeLimitedCreative(List cleared) {
+ int i = 0;
+ for (String name : cleared) {
+ try {
+ org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
+ if (player == null)
+ continue;
+ String playerName = player.getName();
+ File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
+ }
+
+ /**
+ * Method purgeDat.
+ *
+ * @param cleared List
+ */
+ public synchronized void purgeDat(List cleared) {
+ int i = 0;
+ for (String name : cleared) {
+ try {
+ org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
+ if (player == null) {
+ continue;
+ }
+
+ try {
+ File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ } catch (Exception ignore) {
+ File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
+ }
+
+ /**
+ * Method purgeEssentials.
+ *
+ * @param cleared List
+ */
+ @SuppressWarnings("deprecation")
+ public void purgeEssentials(List cleared) {
+ int i = 0;
+ for (String name : cleared) {
+ try {
+ File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ } catch (Exception e) {
+ File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
+ if (playerFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ playerFile.delete();
+ i++;
+ }
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
+ }
+
+ // TODO: What is this method for? Is it correct?
+
+ /**
+ * @param cleared Cleared players.
+ */
+ public synchronized void purgePermissions(List cleared) {
+ // Get the permissions manager, and make sure it's valid
+ PermissionsManager permsMan = this.plugin.getPermissionsManager();
+ if (permsMan == null)
+ ConsoleLogger.showError("Unable to access permissions manager instance!");
+ assert permsMan != null;
+
+ int i = 0;
+ for (String name : cleared) {
+ try {
+ permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
+ i++;
+ } catch (Exception ignored) {
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
+
+ /*int i = 0;
+ for (String name : cleared) {
+ try {
+ OfflinePlayer p = this.getOfflinePlayer(name);
+ for (String group : permission.getPlayerGroups((Player) p)) {
+ permission.playerRemoveGroup(null, p, group);
+ }
+ i++;
+ } catch (Exception e) {
+ }
+ }
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
+ }
+
+ /**
+ * Method isOnline.
+ *
+ * @param player Player
+ * @param name String
+ *
+ * @return boolean
+ */
+ public boolean isOnline(Player player, final String name) {
+ if (player.isOnline())
+ return true;
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Future result = executor.submit(new Callable() {
+
+ @Override
+ public synchronized Boolean call() throws Exception {
+ for (OfflinePlayer op : Utils.getOnlinePlayers())
+ if (op.getName().equalsIgnoreCase(name)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ try {
+ return result.get();
+ } catch (Exception e) {
+ return false;
+ } finally {
+ executor.shutdown();
+ }
+ }
+
+ /**
+ * Method getOnlinePlayerLower.
+ *
+ * @param name String
+ *
+ * @return Player
+ */
+ public Player getOnlinePlayerLower(String name) {
+ name = name.toLowerCase();
+ for (Player player : Utils.getOnlinePlayers()) {
+ if (player.getName().equalsIgnoreCase(name))
+ return player;
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/ImageGenerator.java b/src/main/java/fr/xephi/authme/ImageGenerator.java
index 2ca37cfa..e529efab 100644
--- a/src/main/java/fr/xephi/authme/ImageGenerator.java
+++ b/src/main/java/fr/xephi/authme/ImageGenerator.java
@@ -1,30 +1,40 @@
-package fr.xephi.authme;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-
-public class ImageGenerator {
-
- private String pass;
- public ImageGenerator(String pass) {
- this.pass = pass;
- }
-
- public BufferedImage generateImage() {
- BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
- Graphics2D graphics = image.createGraphics();
- graphics.setColor(Color.BLACK);
- graphics.fillRect(0, 0, 200, 40);
- GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
- graphics.setPaint(gradientPaint);
- Font font = new Font("Comic Sans MS", Font.BOLD, 30);
- graphics.setFont(font);
- graphics.drawString(pass, 5, 30);
- graphics.dispose();
- image.flush();
- return image;
- }
-}
+package fr.xephi.authme;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+/**
+ */
+public class ImageGenerator {
+
+ private final String pass;
+
+ /**
+ * Constructor for ImageGenerator.
+ *
+ * @param pass String
+ */
+ public ImageGenerator(String pass) {
+ this.pass = pass;
+ }
+
+ /**
+ * Method generateImage.
+ *
+ * @return BufferedImage
+ */
+ public BufferedImage generateImage() {
+ BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
+ Graphics2D graphics = image.createGraphics();
+ graphics.setColor(Color.BLACK);
+ graphics.fillRect(0, 0, 200, 40);
+ GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
+ graphics.setPaint(gradientPaint);
+ Font font = new Font("Comic Sans MS", Font.BOLD, 30);
+ graphics.setFont(font);
+ graphics.drawString(pass, 5, 30);
+ graphics.dispose();
+ image.flush();
+ return image;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/Log4JFilter.java b/src/main/java/fr/xephi/authme/Log4JFilter.java
index dccaee6f..581699f0 100644
--- a/src/main/java/fr/xephi/authme/Log4JFilter.java
+++ b/src/main/java/fr/xephi/authme/Log4JFilter.java
@@ -1,5 +1,6 @@
package fr.xephi.authme;
+import fr.xephi.authme.util.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
@@ -7,79 +8,90 @@ import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.message.Message;
/**
+ * Implements a filter for Log4j to skip sensitive AuthMe commands.
*
* @author Xephi59
+ * @version $Revision: 1.0 $
*/
public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
+ /**
+ * List of commands (lower-case) to skip.
+ */
+ private static final String[] COMMANDS_TO_SKIP = {"/login ", "/l ", "/reg ", "/changepassword ",
+ "/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ",
+ "/register "};
+
+ /**
+ * Constructor.
+ */
public Log4JFilter() {
}
+ /**
+ * Validates a Message instance and returns the {@link Result} value
+ * depending depending on whether the message contains sensitive AuthMe
+ * data.
+ *
+ * @param message the Message object to verify
+ *
+ * @return the Result value
+ */
+ private static Result validateMessage(Message message) {
+ if (message == null) {
+ return Result.NEUTRAL;
+ }
+ return validateMessage(message.getFormattedMessage());
+ }
+
+ /**
+ * Validates a message and returns the {@link Result} value depending
+ * depending on whether the message contains sensitive AuthMe data.
+ *
+ * @param message the message to verify
+ *
+ * @return the Result value
+ */
+ private static Result validateMessage(String message) {
+ if (message == null) {
+ return Result.NEUTRAL;
+ }
+
+ String lowerMessage = message.toLowerCase();
+ if (lowerMessage.contains("issued server command:")
+ && StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
+ return Result.DENY;
+ }
+ return Result.NEUTRAL;
+ }
+
@Override
public Result filter(LogEvent record) {
- try {
- if (record == null || record.getMessage() == null)
- return Result.NEUTRAL;
- String logM = record.getMessage().getFormattedMessage().toLowerCase();
- if (!logM.contains("issued server command:"))
- return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
- return Result.NEUTRAL;
- return Result.DENY;
- } catch (NullPointerException npe) {
+ if (record == null) {
return Result.NEUTRAL;
}
+ return validateMessage(record.getMessage());
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, String message,
- Object... arg4) {
- try {
- if (message == null)
- return Result.NEUTRAL;
- String logM = message.toLowerCase();
- if (!logM.contains("issued server command:"))
- return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
- return Result.NEUTRAL;
- return Result.DENY;
- } catch (NullPointerException npe) {
- return Result.NEUTRAL;
- }
+ Object... arg4) {
+ return validateMessage(message);
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message,
- Throwable arg4) {
- try {
- if (message == null)
- return Result.NEUTRAL;
- String logM = message.toString().toLowerCase();
- if (!logM.contains("issued server command:"))
- return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
- return Result.NEUTRAL;
- return Result.DENY;
- } catch (NullPointerException npe) {
+ Throwable arg4) {
+ if (message == null) {
return Result.NEUTRAL;
}
+ return validateMessage(message.toString());
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message,
- Throwable arg4) {
- try {
- if (message == null)
- return Result.NEUTRAL;
- String logM = message.getFormattedMessage().toLowerCase();
- if (!logM.contains("issued server command:"))
- return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
- return Result.NEUTRAL;
- return Result.DENY;
- } catch (NullPointerException npe) {
- return Result.NEUTRAL;
- }
+ Throwable arg4) {
+ return validateMessage(message);
}
@Override
diff --git a/src/main/java/fr/xephi/authme/PerformBackup.java b/src/main/java/fr/xephi/authme/PerformBackup.java
index 0f7e1fcc..6dbb7e4f 100644
--- a/src/main/java/fr/xephi/authme/PerformBackup.java
+++ b/src/main/java/fr/xephi/authme/PerformBackup.java
@@ -1,35 +1,71 @@
package fr.xephi.authme;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
import fr.xephi.authme.settings.Settings;
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
/**
+ * The backup management class
*
* @author stefano
+ * @version $Revision: 1.0 $
*/
public class PerformBackup {
- private String dbName = Settings.getMySQLDatabase;
- private String dbUserName = Settings.getMySQLUsername;
- private String dbPassword = Settings.getMySQLPassword;
- private String tblname = Settings.getMySQLTablename;
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
- String dateString = format.format(new Date());
- private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
+ final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
+ final String dateString = format.format(new Date());
+ private final String dbName = Settings.getMySQLDatabase;
+ private final String dbUserName = Settings.getMySQLUsername;
+ private final String dbPassword = Settings.getMySQLPassword;
+ private final String tblname = Settings.getMySQLTablename;
+ private final String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
private AuthMe instance;
+ /**
+ * Constructor for PerformBackup.
+ *
+ * @param instance AuthMe
+ */
public PerformBackup(AuthMe instance) {
this.setInstance(instance);
}
+ /**
+ * Perform a backup with the given reason.
+ *
+ * @param cause BackupCause The cause of the backup.
+ */
+ public void doBackup(BackupCause cause) {
+ if (!Settings.isBackupActivated) {
+ ConsoleLogger.showError("Can't perform a Backup: disabled in configuration. Cause of the Backup: " + cause.name());
+ }
+ // Check whether a backup should be made at the specified point in time
+ switch (cause) {
+ case START:
+ if (!Settings.isBackupOnStart)
+ return;
+ case STOP:
+ if (!Settings.isBackupOnStop)
+ return;
+ case COMMAND:
+ case OTHER:
+ }
+
+ // Do backup and check return value!
+ if (doBackup()) {
+ ConsoleLogger.info("A backup has been performed successfully. Cause of the Backup: " + cause.name());
+ } else {
+ ConsoleLogger.showError("Error while performing a backup! Cause of the Backup: " + cause.name());
+ }
+ }
+
+ /**
+ * Method doBackup.
+ *
+ * @return boolean
+ */
public boolean doBackup() {
switch (Settings.getDataSource) {
@@ -44,6 +80,11 @@ public class PerformBackup {
return false;
}
+ /**
+ * Method MySqlBackup.
+ *
+ * @return boolean
+ */
private boolean MySqlBackup() {
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
@@ -83,6 +124,13 @@ public class PerformBackup {
return false;
}
+ /**
+ * Method FileBackup.
+ *
+ * @param backend String
+ *
+ * @return boolean
+ */
private boolean FileBackup(String backend) {
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
@@ -99,13 +147,16 @@ public class PerformBackup {
return false;
}
- /*
- * Check if we are under Windows and correct location of mysqldump.exe
- * otherwise return error.
+ /**
+ * Method checkWindows.
+ *
+ * @param windowsPath String
+ *
+ * @return boolean
*/
private boolean checkWindows(String windowsPath) {
String isWin = System.getProperty("os.name").toLowerCase();
- if (isWin.indexOf("win") >= 0) {
+ if (isWin.contains("win")) {
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
return true;
} else {
@@ -116,7 +167,17 @@ public class PerformBackup {
}
/*
- * Copyr src bytefile into dst file
+ * Check if we are under Windows and correct location of mysqldump.exe
+ * otherwise return error.
+ */
+
+ /**
+ * Method copy.
+ *
+ * @param src File
+ * @param dst File
+ *
+ * @throws IOException
*/
void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
@@ -132,12 +193,36 @@ public class PerformBackup {
out.close();
}
- public void setInstance(AuthMe instance) {
- this.instance = instance;
- }
+ /*
+ * Copyr src bytefile into dst file
+ */
+ /**
+ * Method getInstance.
+ *
+ * @return AuthMe
+ */
public AuthMe getInstance() {
return instance;
}
+ /**
+ * Method setInstance.
+ *
+ * @param instance AuthMe
+ */
+ public void setInstance(AuthMe instance) {
+ this.instance = instance;
+ }
+
+ /**
+ * Possible backup causes.
+ */
+ public enum BackupCause {
+ START,
+ STOP,
+ COMMAND,
+ OTHER,
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java
index eb4c2b8e..397ddac9 100644
--- a/src/main/java/fr/xephi/authme/SendMailSSL.java
+++ b/src/main/java/fr/xephi/authme/SendMailSSL.java
@@ -1,39 +1,48 @@
package fr.xephi.authme;
-import java.io.File;
+import fr.xephi.authme.cache.auth.PlayerAuth;
+import fr.xephi.authme.settings.Settings;
+import org.apache.commons.mail.HtmlEmail;
+import org.bukkit.Bukkit;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.imageio.ImageIO;
-
-import org.apache.commons.mail.HtmlEmail;
-import org.bukkit.Bukkit;
-
-import fr.xephi.authme.cache.auth.PlayerAuth;
-import fr.xephi.authme.settings.Settings;
+import java.io.File;
/**
- *
* @author Xephi59
+ * @version $Revision: 1.0 $
*/
public class SendMailSSL {
- public AuthMe plugin;
+ public final AuthMe plugin;
+ /**
+ * Constructor for SendMailSSL.
+ *
+ * @param plugin AuthMe
+ */
public SendMailSSL(AuthMe plugin) {
this.plugin = plugin;
}
+ /**
+ * Method main.
+ *
+ * @param auth PlayerAuth
+ * @param newPass String
+ */
public void main(final PlayerAuth auth, final String newPass) {
- String sendername;
+ String senderName;
if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) {
- sendername = Settings.getmailAccount;
+ senderName = Settings.getmailAccount;
} else {
- sendername = Settings.getmailSenderName;
+ senderName = Settings.getmailSenderName;
}
- final String sender = sendername;
+ final String sender = senderName;
final int port = Settings.getMailPort;
final String acc = Settings.getmailAccount;
final String subject = Settings.getMailSubject;
@@ -81,6 +90,7 @@ public class SendMailSSL {
ConsoleLogger.showError("Fail to send a mail to " + mail);
}
if (file != null)
+ //noinspection ResultOfMethodCallIgnored
file.delete();
} catch (Exception e) {
diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java
index 96dcc2a6..e849e795 100644
--- a/src/main/java/fr/xephi/authme/api/API.java
+++ b/src/main/java/fr/xephi/authme/api/API.java
@@ -1,25 +1,31 @@
package fr.xephi.authme.api;
-import java.security.NoSuchAlgorithmException;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.plugin.Plugin;
-
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.Plugin;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ */
public class API {
public static final String newline = System.getProperty("line.separator");
public static AuthMe instance;
+ /**
+ * Constructor for API.
+ *
+ * @param instance AuthMe
+ */
@Deprecated
public API(AuthMe instance) {
API.instance = instance;
@@ -42,14 +48,9 @@ public class API {
return instance;
}
- @Deprecated
- public AuthMe getPlugin() {
- return instance;
- }
-
/**
- *
* @param player
+ *
* @return true if player is authenticate
*/
@Deprecated
@@ -58,28 +59,8 @@ public class API {
}
/**
- *
* @param player
- * @return true if player is a npc
- */
- @Deprecated
- public boolean isaNPC(Player player) {
- return Utils.isNPC(player);
- }
-
- /**
*
- * @param player
- * @return true if player is a npc
- */
- @Deprecated
- public boolean isNPC(Player player) {
- return Utils.isNPC(player);
- }
-
- /**
- *
- * @param player
* @return true if the player is unrestricted
*/
@Deprecated
@@ -87,6 +68,13 @@ public class API {
return Utils.isUnrestricted(player);
}
+ /**
+ * Method getLastLocation.
+ *
+ * @param player Player
+ *
+ * @return Location
+ */
@Deprecated
public static Location getLastLocation(Player player) {
try {
@@ -104,19 +92,26 @@ public class API {
}
}
+ /**
+ * Method setPlayerInventory.
+ *
+ * @param player Player
+ * @param content ItemStack[]
+ * @param armor ItemStack[]
+ */
@Deprecated
public static void setPlayerInventory(Player player, ItemStack[] content,
- ItemStack[] armor) {
+ ItemStack[] armor) {
try {
player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor);
- } catch (NullPointerException npe) {
+ } catch (NullPointerException ignored) {
}
}
/**
- *
* @param playerName
+ *
* @return true if player is registered
*/
@Deprecated
@@ -126,13 +121,14 @@ public class API {
}
/**
- * @param String
- * playerName, String passwordToCheck
+ * @param playerName String
+ * @param passwordToCheck String
+ *
* @return true if the password is correct , false else
*/
@Deprecated
public static boolean checkPassword(String playerName,
- String passwordToCheck) {
+ String passwordToCheck) {
if (!isRegistered(playerName))
return false;
String player = playerName.toLowerCase();
@@ -147,8 +143,9 @@ public class API {
/**
* Register a player
*
- * @param String
- * playerName, String password
+ * @param playerName String
+ * @param password String
+ *
* @return true if the player is register correctly
*/
@Deprecated
@@ -160,10 +157,7 @@ public class API {
return false;
}
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName);
- if (!instance.database.saveAuth(auth)) {
- return false;
- }
- return true;
+ return instance.database.saveAuth(auth);
} catch (NoSuchAlgorithmException ex) {
return false;
}
@@ -172,12 +166,41 @@ public class API {
/**
* Force a player to login
*
- * @param Player
- * player
+ * @param player * player
*/
@Deprecated
public static void forceLogin(Player player) {
instance.management.performLogin(player, "dontneed", true);
}
+ /**
+ * Method getPlugin.
+ *
+ * @return AuthMe
+ */
+ @Deprecated
+ public AuthMe getPlugin() {
+ return instance;
+ }
+
+ /**
+ * @param player
+ *
+ * @return true if player is a npc
+ */
+ @Deprecated
+ public boolean isaNPC(Player player) {
+ return Utils.isNPC(player);
+ }
+
+ /**
+ * @param player
+ *
+ * @return true if player is a npc
+ */
+ @Deprecated
+ public boolean isNPC(Player player) {
+ return Utils.isNPC(player);
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/api/NewAPI.java b/src/main/java/fr/xephi/authme/api/NewAPI.java
index 6c48286a..cfe4508f 100644
--- a/src/main/java/fr/xephi/authme/api/NewAPI.java
+++ b/src/main/java/fr/xephi/authme/api/NewAPI.java
@@ -1,32 +1,42 @@
package fr.xephi.authme.api;
-import java.security.NoSuchAlgorithmException;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ */
public class NewAPI {
- public static final String newline = System.getProperty("line.separator");
public static NewAPI singleton;
- public AuthMe plugin;
+ public final AuthMe plugin;
+ /**
+ * Constructor for NewAPI.
+ *
+ * @param plugin AuthMe
+ */
public NewAPI(AuthMe plugin) {
this.plugin = plugin;
}
- public NewAPI(Server serv) {
- this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
+ /**
+ * Constructor for NewAPI.
+ *
+ * @param server Server
+ */
+ public NewAPI(Server server) {
+ this.plugin = (AuthMe) server.getPluginManager().getPlugin("AuthMe");
}
/**
@@ -46,13 +56,18 @@ public class NewAPI {
return singleton;
}
+ /**
+ * Method getPlugin.
+ *
+ * @return AuthMe
+ */
public AuthMe getPlugin() {
return plugin;
}
/**
- *
* @param player
+ *
* @return true if player is authenticate
*/
public boolean isAuthenticated(Player player) {
@@ -60,8 +75,8 @@ public class NewAPI {
}
/**
- *
* @param player
+ *
* @return true if player is a npc
*/
public boolean isNPC(Player player) {
@@ -69,14 +84,21 @@ public class NewAPI {
}
/**
- *
* @param player
+ *
* @return true if the player is unrestricted
*/
public boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
+ /**
+ * Method getLastLocation.
+ *
+ * @param player Player
+ *
+ * @return Location
+ */
public Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
@@ -93,8 +115,8 @@ public class NewAPI {
}
/**
- *
* @param playerName
+ *
* @return true if player is registered
*/
public boolean isRegistered(String playerName) {
@@ -103,8 +125,9 @@ public class NewAPI {
}
/**
- * @param String
- * playerName, String passwordToCheck
+ * @param playerName String
+ * @param passwordToCheck String
+ *
* @return true if the password is correct , false else
*/
public boolean checkPassword(String playerName, String passwordToCheck) {
@@ -122,8 +145,9 @@ public class NewAPI {
/**
* Register a player
*
- * @param String
- * playerName, String password
+ * @param playerName String
+ * @param password String
+ *
* @return true if the player is register correctly
*/
public boolean registerPlayer(String playerName, String password) {
@@ -143,8 +167,7 @@ public class NewAPI {
/**
* Force a player to login
*
- * @param Player
- * player
+ * @param player * player
*/
public void forceLogin(Player player) {
plugin.management.performLogin(player, "dontneed", true);
@@ -153,35 +176,28 @@ public class NewAPI {
/**
* Force a player to logout
*
- * @param Player
- * player
+ * @param player * player
*/
- public void forceLogout(Player player)
- {
- plugin.management.performLogout(player);
+ public void forceLogout(Player player) {
+ plugin.management.performLogout(player);
}
/**
* Force a player to register
*
- * @param Player
- * player
- * @param String
- * password
+ * @param player * player
+ * @param password String
*/
- public void forceRegister(Player player, String password)
- {
- plugin.management.performRegister(player, password, null);
+ public void forceRegister(Player player, String password) {
+ plugin.management.performRegister(player, password, null);
}
/**
* Force a player to unregister
*
- * @param Player
- * player
+ * @param player * player
*/
- public void forceUnregister(Player player)
- {
- plugin.management.performUnregister(player, "", true);
+ public void forceUnregister(Player player) {
+ plugin.management.performUnregister(player, "", true);
}
}
diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
index de9224e4..5b127325 100644
--- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
+++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
@@ -3,62 +3,167 @@ package fr.xephi.authme.cache.auth;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.Settings;
+/**
+ */
public class PlayerAuth {
- private String nickname = "";
- private String hash = "";
- private String ip = "192.168.0.1";
- private long lastLogin = 0;
- private double x = 0;
- private double y = 0;
- private double z = 0;
- private String world = "world";
- private String salt = "";
- private String vBhash = null;
- private int groupId = -1;
- private String email = "your@email.com";
+ private String nickname;
+ private String hash;
+ private String ip;
+ private long lastLogin;
+ private double x;
+ private double y;
+ private double z;
+ private String world;
+ private String salt;
+ private int groupId;
+ private String email;
private String realName;
- public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
- String email, String realName) {
- this.nickname = nickname;
- this.hash = hash;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.email = email;
- this.realName = realName;
+ /**
+ *
+ */
+ public PlayerAuth(String serialized)
+ {
+ this.unserialize(serialized);
}
- public PlayerAuth(String nickname, double x, double y, double z,
- String world, String realName) {
- this.nickname = nickname;
- this.x = x;
- this.y = y;
- this.z = z;
- this.world = world;
- this.realName = realName;
- this.lastLogin = System.currentTimeMillis();
-
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param ip String
+ * @param lastLogin long
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String ip, long lastLogin, String realName) {
+ this(nickname, "", "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
}
- public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
- double x, double y, double z, String world, String email,
- String realName) {
- this.nickname = nickname;
- this.hash = hash;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.x = x;
- this.y = y;
- this.z = z;
- this.world = world;
- this.email = email;
- this.realName = realName;
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param x double
+ * @param y double
+ * @param z double
+ * @param world String
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, double x, double y, double z, String world, String realName) {
+ this(nickname, "", "", -1, "127.0.0.1", System.currentTimeMillis(), x, y, z, world, "your@email.com", realName);
}
- public PlayerAuth(String nickname, String hash, String salt, int groupId,
- String ip, long lastLogin, double x, double y, double z,
- String world, String email, String realName) {
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param ip String
+ * @param lastLogin long
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String realName) {
+ this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param ip String
+ * @param lastLogin long
+ * @param email String
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) {
+ this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", email, realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param salt String
+ * @param ip String
+ * @param lastLogin long
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
+ this(nickname, hash, salt, -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param ip String
+ * @param lastLogin long
+ * @param x double
+ * @param y double
+ * @param z double
+ * @param world String
+ * @param email String
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
+ this(nickname, hash, "", -1, ip, lastLogin, x, y, z, world, email, realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param salt String
+ * @param ip String
+ * @param lastLogin long
+ * @param x double
+ * @param y double
+ * @param z double
+ * @param world String
+ * @param email String
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
+ this(nickname, hash, salt, -1, ip, lastLogin, x, y, z, world, email, realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param salt String
+ * @param groupId int
+ * @param ip String
+ * @param lastLogin long
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, String realName) {
+ this(nickname, hash, salt, groupId, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
+ }
+
+ /**
+ * Constructor for PlayerAuth.
+ *
+ * @param nickname String
+ * @param hash String
+ * @param salt String
+ * @param groupId int
+ * @param ip String
+ * @param lastLogin long
+ * @param x double
+ * @param y double
+ * @param z double
+ * @param world String
+ * @param email String
+ * @param realName String
+ */
+ public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
this.nickname = nickname;
this.hash = hash;
this.ip = ip;
@@ -73,182 +178,11 @@ public class PlayerAuth {
this.realName = realName;
}
- public PlayerAuth(String nickname, String hash, String salt, int groupId,
- String ip, long lastLogin, String realName) {
- this.nickname = nickname;
- this.hash = hash;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.salt = salt;
- this.groupId = groupId;
- this.realName = realName;
- }
-
- public PlayerAuth(String nickname, String hash, String salt, String ip,
- long lastLogin, String realName) {
- this.nickname = nickname;
- this.hash = hash;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.salt = salt;
- this.realName = realName;
- }
-
- public PlayerAuth(String nickname, String hash, String salt, String ip,
- long lastLogin, double x, double y, double z, String world,
- String email, String realName) {
- this.nickname = nickname;
- this.hash = hash;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.x = x;
- this.y = y;
- this.z = z;
- this.world = world;
- this.salt = salt;
- this.email = email;
- this.realName = realName;
- }
-
- public PlayerAuth(String nickname, String ip, long lastLogin,
- String realName) {
- this.nickname = nickname;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.realName = realName;
- }
-
- public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
- String realName) {
- this.nickname = nickname;
- this.ip = ip;
- this.lastLogin = lastLogin;
- this.hash = hash;
- this.realName = realName;
- }
-
- public String getIp() {
- if (ip == null || ip.isEmpty())
- ip = "127.0.0.1";
- return ip;
- }
-
- public String getNickname() {
- return nickname;
- }
-
- public String getHash() {
- if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
- if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
- vBhash = "$MD5vb$" + salt + "$" + hash;
- return vBhash;
- }
- }
- return hash;
- }
-
- public String getSalt() {
- return this.salt;
- }
-
- public int getGroupId() {
- return groupId;
- }
-
- public double getQuitLocX() {
- return x;
- }
-
- public double getQuitLocY() {
- return y;
- }
-
- public double getQuitLocZ() {
- return z;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setQuitLocX(double d) {
- this.x = d;
- }
-
- public void setQuitLocY(double d) {
- this.y = d;
- }
-
- public void setQuitLocZ(double d) {
- this.z = d;
- }
-
- public long getLastLogin() {
- try {
- if (Long.valueOf(lastLogin) == null)
- lastLogin = 0L;
- } catch (NullPointerException e) {
- lastLogin = 0L;
- }
- return lastLogin;
- }
-
- public void setHash(String hash) {
- this.hash = hash;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public void setLastLogin(long lastLogin) {
- this.lastLogin = lastLogin;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public void setSalt(String salt) {
- this.salt = salt;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof PlayerAuth)) {
- return false;
- }
- PlayerAuth other = (PlayerAuth) obj;
- return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
- }
-
- @Override
- public int hashCode() {
- int hashCode = 7;
- hashCode = 71 * hashCode + (this.nickname != null ? this.nickname.hashCode() : 0);
- hashCode = 71 * hashCode + (this.ip != null ? this.ip.hashCode() : 0);
- return hashCode;
- }
-
- public void setWorld(String world) {
- this.world = world;
- }
-
- public String getWorld() {
- return world;
- }
-
- @Override
- public String toString() {
- String s = "Player : " + nickname + " | " + realName + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt;
- return s;
-
- }
-
- public void setName(String nickname) {
- this.nickname = nickname;
- }
-
+ /**
+ * Method set.
+ *
+ * @param auth PlayerAuth
+ */
public void set(PlayerAuth auth) {
this.setEmail(auth.getEmail());
this.setHash(auth.getHash());
@@ -263,12 +197,304 @@ public class PlayerAuth {
this.setRealName(auth.getRealName());
}
+ /**
+ * Method setName.
+ *
+ * @param nickname String
+ */
+ public void setName(String nickname) {
+ this.nickname = nickname;
+ }
+
+ /**
+ * Method getNickname.
+ *
+ * @return String
+ */
+ public String getNickname() {
+ return nickname;
+ }
+
+ /**
+ * Method getRealName.
+ *
+ * @return String
+ */
public String getRealName() {
return realName;
}
+ /**
+ * Method setRealName.
+ *
+ * @param realName String
+ */
public void setRealName(String realName) {
this.realName = realName;
}
+ /**
+ * Method getGroupId.
+ *
+ * @return int
+ */
+ public int getGroupId() {
+ return groupId;
+ }
+
+ /**
+ * Method getQuitLocX.
+ *
+ * @return double
+ */
+ public double getQuitLocX() {
+ return x;
+ }
+
+ /**
+ * Method setQuitLocX.
+ *
+ * @param d double
+ */
+ public void setQuitLocX(double d) {
+ this.x = d;
+ }
+
+ /**
+ * Method getQuitLocY.
+ *
+ * @return double
+ */
+ public double getQuitLocY() {
+ return y;
+ }
+
+ /**
+ * Method setQuitLocY.
+ *
+ * @param d double
+ */
+ public void setQuitLocY(double d) {
+ this.y = d;
+ }
+
+ /**
+ * Method getQuitLocZ.
+ *
+ * @return double
+ */
+ public double getQuitLocZ() {
+ return z;
+ }
+
+ /**
+ * Method setQuitLocZ.
+ *
+ * @param d double
+ */
+ public void setQuitLocZ(double d) {
+ this.z = d;
+ }
+
+ /**
+ * Method getWorld.
+ *
+ * @return String
+ */
+ public String getWorld() {
+ return world;
+ }
+
+ /**
+ * Method setWorld.
+ *
+ * @param world String
+ */
+ public void setWorld(String world) {
+ this.world = world;
+ }
+
+ /**
+ * Method getIp.
+ *
+ * @return String
+ */
+ public String getIp() {
+ return ip;
+ }
+
+ /**
+ * Method setIp.
+ *
+ * @param ip String
+ */
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ /**
+ * Method getLastLogin.
+ *
+ * @return long
+ */
+ public long getLastLogin() {
+ return lastLogin;
+ }
+
+ /**
+ * Method setLastLogin.
+ *
+ * @param lastLogin long
+ */
+ public void setLastLogin(long lastLogin) {
+ this.lastLogin = lastLogin;
+ }
+
+ /**
+ * Method getEmail.
+ *
+ * @return String
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Method setEmail.
+ *
+ * @param email String
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Method getSalt.
+ *
+ * @return String
+ */
+ public String getSalt() {
+ return this.salt;
+ }
+
+ /**
+ * Method setSalt.
+ *
+ * @param salt String
+ */
+ public void setSalt(String salt) {
+ this.salt = salt;
+ }
+
+ /**
+ * Method getHash.
+ *
+ * @return String
+ */
+ public String getHash() {
+ if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
+ if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
+ return "$MD5vb$" + salt + "$" + hash;
+ }
+ }
+ return hash;
+ }
+
+ /**
+ * Method setHash.
+ *
+ * @param hash String
+ */
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
+
+ /**
+ * Method equals.
+ *
+ * @param obj Object
+ *
+ * @return boolean
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof PlayerAuth)) {
+ return false;
+ }
+ PlayerAuth other = (PlayerAuth) obj;
+ return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
+ }
+
+ /**
+ * Method hashCode.
+ *
+ * @return int
+ */
+ @Override
+ public int hashCode() {
+ int hashCode = 7;
+ hashCode = 71 * hashCode + (this.nickname != null ? this.nickname.hashCode() : 0);
+ hashCode = 71 * hashCode + (this.ip != null ? this.ip.hashCode() : 0);
+ return hashCode;
+ }
+
+ /**
+ * Method toString.
+ *
+ * @return String
+ */
+ @Override
+ public String toString() {
+ return ("Player : " + nickname + " | " + realName
+ + " ! IP : " + ip
+ + " ! LastLogin : " + lastLogin
+ + " ! LastPosition : " + x + "," + y + "," + z + "," + world
+ + " ! Email : " + email
+ + " ! Hash : " + hash
+ + " ! Salt : " + salt);
+ }
+
+ /**
+ * Method to serialize playerauth
+ *
+ * @return String
+ */
+ public String serialize()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append(this.nickname).append(';');
+ str.append(this.realName).append(';');
+ str.append(this.ip).append(';');
+ str.append(this.email).append(';');
+ str.append(this.hash).append(';');
+ str.append(this.salt).append(';');
+ str.append(this.groupId).append(';');
+ str.append(this.lastLogin).append(';');
+ str.append(this.world).append(';');
+ str.append(this.x).append(';');
+ str.append(this.y).append(';');
+ str.append(this.z);
+ return str.toString();
+ }
+
+ /**
+ * Method to unserialize playerauth
+ *
+ */
+ public void unserialize(String str)
+ {
+ String[] args = str.split(";");
+ this.nickname = args[0];
+ this.realName = args[1];
+ this.ip = args[2];
+ this.email = args[3];
+ this.hash = args[4];
+ this.salt = args[5];
+ this.groupId = Integer.parseInt(args[6]);
+ this.lastLogin = Long.parseLong(args[7]);
+ this.world = args[8];
+ this.x = Double.parseDouble(args[9]);
+ this.y = Double.parseDouble(args[10]);
+ this.z = Double.parseDouble(args[11]);
+ }
}
diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerCache.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerCache.java
index 491c33a4..4f9d2187 100644
--- a/src/main/java/fr/xephi/authme/cache/auth/PlayerCache.java
+++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerCache.java
@@ -2,36 +2,22 @@ package fr.xephi.authme.cache.auth;
import java.util.concurrent.ConcurrentHashMap;
+/**
+ */
public class PlayerCache {
- private volatile static PlayerCache singleton = null;
- private ConcurrentHashMap cache;
+ private volatile static PlayerCache singleton;
+ private final ConcurrentHashMap cache;
private PlayerCache() {
cache = new ConcurrentHashMap<>();
}
- public void addPlayer(PlayerAuth auth) {
- cache.put(auth.getNickname().toLowerCase(), auth);
- }
-
- public void updatePlayer(PlayerAuth auth) {
- cache.remove(auth.getNickname().toLowerCase());
- cache.put(auth.getNickname().toLowerCase(), auth);
- }
-
- public void removePlayer(String user) {
- cache.remove(user.toLowerCase());
- }
-
- public boolean isAuthenticated(String user) {
- return cache.containsKey(user.toLowerCase());
- }
-
- public PlayerAuth getAuth(String user) {
- return cache.get(user.toLowerCase());
- }
-
+ /**
+ * Method getInstance.
+ *
+ * @return PlayerCache
+ */
public static PlayerCache getInstance() {
if (singleton == null) {
singleton = new PlayerCache();
@@ -39,10 +25,70 @@ public class PlayerCache {
return singleton;
}
+ /**
+ * Method addPlayer.
+ *
+ * @param auth PlayerAuth
+ */
+ public void addPlayer(PlayerAuth auth) {
+ cache.put(auth.getNickname().toLowerCase(), auth);
+ }
+
+ /**
+ * Method updatePlayer.
+ *
+ * @param auth PlayerAuth
+ */
+ public void updatePlayer(PlayerAuth auth) {
+ cache.remove(auth.getNickname().toLowerCase());
+ cache.put(auth.getNickname().toLowerCase(), auth);
+ }
+
+ /**
+ * Method removePlayer.
+ *
+ * @param user String
+ */
+ public void removePlayer(String user) {
+ cache.remove(user.toLowerCase());
+ }
+
+ /**
+ * Method isAuthenticated.
+ *
+ * @param user String
+ *
+ * @return boolean
+ */
+ public boolean isAuthenticated(String user) {
+ return cache.containsKey(user.toLowerCase());
+ }
+
+ /**
+ * Method getAuth.
+ *
+ * @param user String
+ *
+ * @return PlayerAuth
+ */
+ public PlayerAuth getAuth(String user) {
+ return cache.get(user.toLowerCase());
+ }
+
+ /**
+ * Method getLogged.
+ *
+ * @return int
+ */
public int getLogged() {
return cache.size();
}
+ /**
+ * Method getCache.
+ *
+ * @return ConcurrentHashMap
+ */
public ConcurrentHashMap getCache() {
return this.cache;
}
diff --git a/src/main/java/fr/xephi/authme/cache/backup/DataFileCache.java b/src/main/java/fr/xephi/authme/cache/backup/DataFileCache.java
index 5aa40dde..e567229d 100644
--- a/src/main/java/fr/xephi/authme/cache/backup/DataFileCache.java
+++ b/src/main/java/fr/xephi/authme/cache/backup/DataFileCache.java
@@ -1,25 +1,49 @@
package fr.xephi.authme.cache.backup;
+/**
+ */
public class DataFileCache {
- private String group;
- private boolean operator;
- private boolean flying;
+ private final String group;
+ private final boolean operator;
+ private final boolean flying;
+ /**
+ * Constructor for DataFileCache.
+ *
+ * @param group String
+ * @param operator boolean
+ * @param flying boolean
+ */
public DataFileCache(String group, boolean operator, boolean flying) {
this.group = group;
this.operator = operator;
this.flying = flying;
}
+ /**
+ * Method getGroup.
+ *
+ * @return String
+ */
public String getGroup() {
return group;
}
+ /**
+ * Method getOperator.
+ *
+ * @return boolean
+ */
public boolean getOperator() {
return operator;
}
+ /**
+ * Method isFlying.
+ *
+ * @return boolean
+ */
public boolean isFlying() {
return flying;
}
diff --git a/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java b/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
index 31c647cb..b07c74d9 100644
--- a/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
+++ b/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
@@ -1,27 +1,19 @@
package fr.xephi.authme.cache.backup;
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+import com.google.gson.*;
+import fr.xephi.authme.ConsoleLogger;
+import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
+import org.bukkit.entity.Player;
+
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
-import org.bukkit.entity.Player;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-import fr.xephi.authme.ConsoleLogger;
-import fr.xephi.authme.settings.Settings;
-import fr.xephi.authme.util.Utils;
-
+/**
+ */
public class JsonCache {
private final Gson gson;
@@ -33,12 +25,18 @@ public class JsonCache {
ConsoleLogger.showError("Failed to create cache directory.");
}
gson = new GsonBuilder()
- .registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer())
- .registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer())
- .setPrettyPrinting()
- .create();
+ .registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer())
+ .registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer())
+ .setPrettyPrinting()
+ .create();
}
+ /**
+ * Method createCache.
+ *
+ * @param player Player
+ * @param playerData DataFileCache
+ */
public void createCache(Player player, DataFileCache playerData) {
if (player == null) {
return;
@@ -68,6 +66,13 @@ public class JsonCache {
}
}
+ /**
+ * Method readCache.
+ *
+ * @param player Player
+ *
+ * @return DataFileCache
+ */
public DataFileCache readCache(Player player) {
String path;
try {
@@ -90,19 +95,57 @@ public class JsonCache {
}
}
- private class PlayerDataSerializer implements JsonSerializer {
- @Override
- public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) {
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty("group", dataFileCache.getGroup());
- jsonObject.addProperty("operator", dataFileCache.getOperator());
- jsonObject.addProperty("flying", dataFileCache.isFlying());
-
- return jsonObject;
+ /**
+ * Method removeCache.
+ *
+ * @param player Player
+ */
+ public void removeCache(Player player) {
+ String path;
+ try {
+ path = player.getUniqueId().toString();
+ } catch (Exception | Error e) {
+ path = player.getName().toLowerCase();
+ }
+ File file = new File(cacheDir, path);
+ if (file.exists()) {
+ Utils.purgeDirectory(file);
+ if (!file.delete()) {
+ ConsoleLogger.showError("Failed to remove" + player.getName() + "cache.");
+ }
}
}
+ /**
+ * Method doesCacheExist.
+ *
+ * @param player Player
+ *
+ * @return boolean
+ */
+ public boolean doesCacheExist(Player player) {
+ String path;
+ try {
+ path = player.getUniqueId().toString();
+ } catch (Exception | Error e) {
+ path = player.getName().toLowerCase();
+ }
+ File file = new File(cacheDir, path + File.separator + "cache.json");
+ return file.exists();
+ }
+
+ /**
+ */
private static class PlayerDataDeserializer implements JsonDeserializer {
+ /**
+ * Method deserialize.
+ *
+ * @param jsonElement JsonElement
+ * @param type Type
+ * @param jsonDeserializationContext JsonDeserializationContext
+ *
+ * @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)
+ */
@Override
public DataFileCache deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject jsonObject = jsonElement.getAsJsonObject();
@@ -128,31 +171,27 @@ public class JsonCache {
}
}
- public void removeCache(Player player) {
- String path;
- try {
- path = player.getUniqueId().toString();
- } catch (Exception | Error e) {
- path = player.getName().toLowerCase();
- }
- File file = new File(cacheDir, path);
- if (file.exists()) {
- Utils.purgeDirectory(file);
- if (!file.delete()) {
- ConsoleLogger.showError("Failed to remove" + player.getName() + "cache.");
- }
- }
- }
+ /**
+ */
+ private class PlayerDataSerializer implements JsonSerializer {
+ /**
+ * Method serialize.
+ *
+ * @param dataFileCache DataFileCache
+ * @param type Type
+ * @param jsonSerializationContext JsonSerializationContext
+ *
+ * @return JsonElement
+ */
+ @Override
+ public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) {
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("group", dataFileCache.getGroup());
+ jsonObject.addProperty("operator", dataFileCache.getOperator());
+ jsonObject.addProperty("flying", dataFileCache.isFlying());
- public boolean doesCacheExist(Player player) {
- String path;
- try {
- path = player.getUniqueId().toString();
- } catch (Exception | Error e) {
- path = player.getName().toLowerCase();
+ return jsonObject;
}
- File file = new File(cacheDir, path + File.separator + "cache.json");
- return file.exists();
}
}
diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
index 70614107..69774e22 100644
--- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
+++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
@@ -1,33 +1,56 @@
package fr.xephi.authme.cache.limbo;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.backup.DataFileCache;
import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.events.ResetInventoryEvent;
-import fr.xephi.authme.events.StoreInventoryEvent;
+import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ */
public class LimboCache {
private volatile static LimboCache singleton;
- public ConcurrentHashMap cache;
- private JsonCache playerData;
- public AuthMe plugin;
+ public final ConcurrentHashMap cache;
+ public final AuthMe plugin;
+ private final JsonCache playerData;
+ /**
+ * Constructor for LimboCache.
+ *
+ * @param plugin AuthMe
+ */
private LimboCache(AuthMe plugin) {
this.plugin = plugin;
this.cache = new ConcurrentHashMap<>();
this.playerData = new JsonCache();
}
+ /**
+ * Method getInstance.
+ *
+ * @return LimboCache
+ */
+ public static LimboCache getInstance() {
+ if (singleton == null) {
+ singleton = new LimboCache(AuthMe.getInstance());
+ }
+ return singleton;
+ }
+
+ /**
+ * Add a limbo player.
+ *
+ * @param player Player instance to add.
+ */
public void addLimboPlayer(Player player) {
String name = player.getName().toLowerCase();
Location loc = player.getLocation();
@@ -36,14 +59,13 @@ public class LimboCache {
String playerGroup = "";
boolean flying = false;
- if (playerData.doesCacheExist(player)) {
- final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
- Bukkit.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
- player.getInventory().setContents(event.getInventory());
- player.getInventory().setArmorContents(event.getArmor());
- }
+ // Get the permissions manager, and make sure it's valid
+ PermissionsManager permsMan = this.plugin.getPermissionsManager();
+ if (permsMan == null)
+ ConsoleLogger.showError("Unable to access permissions manager!");
+ assert permsMan != null;
+ if (playerData.doesCacheExist(player)) {
DataFileCache cache = playerData.readCache(player);
if (cache != null) {
playerGroup = cache.getGroup();
@@ -51,23 +73,12 @@ public class LimboCache {
flying = cache.isFlying();
}
} else {
- StoreInventoryEvent event = new StoreInventoryEvent(player);
- Bukkit.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
- player.getInventory().setContents(event.getInventory());
- player.getInventory().setArmorContents(event.getArmor());
- }
-
operator = player.isOp();
flying = player.isFlying();
- if (plugin.permission != null) {
- try {
- playerGroup = plugin.permission.getPrimaryGroup(player);
- } catch (UnsupportedOperationException e) {
- ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
- plugin.permission = null;
- }
- }
+
+ // Check whether groups are supported
+ if (permsMan.hasGroupSupport())
+ playerGroup = permsMan.getPrimaryGroup(player);
}
if (Settings.isForceSurvivalModeEnabled) {
@@ -90,29 +101,52 @@ public class LimboCache {
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
}
+ /**
+ * Method addLimboPlayer.
+ *
+ * @param player Player
+ * @param group String
+ */
public void addLimboPlayer(Player player, String group) {
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
}
+ /**
+ * Method deleteLimboPlayer.
+ *
+ * @param name String
+ */
public void deleteLimboPlayer(String name) {
cache.remove(name);
}
+ /**
+ * Method getLimboPlayer.
+ *
+ * @param name String
+ *
+ * @return LimboPlayer
+ */
public LimboPlayer getLimboPlayer(String name) {
return cache.get(name);
}
+ /**
+ * Method hasLimboPlayer.
+ *
+ * @param name String
+ *
+ * @return boolean
+ */
public boolean hasLimboPlayer(String name) {
return cache.containsKey(name);
}
- public static LimboCache getInstance() {
- if (singleton == null) {
- singleton = new LimboCache(AuthMe.getInstance());
- }
- return singleton;
- }
-
+ /**
+ * Method updateLimboPlayer.
+ *
+ * @param player Player
+ */
public void updateLimboPlayer(Player player) {
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
this.deleteLimboPlayer(player.getName().toLowerCase());
diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java
index f4ae0466..96c5a9ee 100644
--- a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java
+++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java
@@ -4,9 +4,11 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask;
+/**
+ */
public class LimboPlayer {
- private String name;
+ private final String name;
private Location loc = null;
private BukkitTask timeoutTaskId = null;
private BukkitTask messageTaskId = null;
@@ -15,8 +17,18 @@ public class LimboPlayer {
private String group = "";
private boolean flying = false;
+ /**
+ * Constructor for LimboPlayer.
+ *
+ * @param name String
+ * @param loc Location
+ * @param gameMode GameMode
+ * @param operator boolean
+ * @param group String
+ * @param flying boolean
+ */
public LimboPlayer(String name, Location loc, GameMode gameMode,
- boolean operator, String group, boolean flying) {
+ boolean operator, String group, boolean flying) {
this.name = name;
this.loc = loc;
this.gameMode = gameMode;
@@ -25,51 +37,107 @@ public class LimboPlayer {
this.flying = flying;
}
+ /**
+ * Constructor for LimboPlayer.
+ *
+ * @param name String
+ * @param group String
+ */
public LimboPlayer(String name, String group) {
this.name = name;
this.group = group;
}
+ /**
+ * Method getName.
+ *
+ * @return String
+ */
public String getName() {
return name;
}
+ /**
+ * Method getLoc.
+ *
+ * @return Location
+ */
public Location getLoc() {
return loc;
}
+ /**
+ * Method getGameMode.
+ *
+ * @return GameMode
+ */
public GameMode getGameMode() {
return gameMode;
}
+ /**
+ * Method getOperator.
+ *
+ * @return boolean
+ */
public boolean getOperator() {
return operator;
}
+ /**
+ * Method getGroup.
+ *
+ * @return String
+ */
public String getGroup() {
return group;
}
+ /**
+ * Method getTimeoutTaskId.
+ *
+ * @return BukkitTask
+ */
+ public BukkitTask getTimeoutTaskId() {
+ return timeoutTaskId;
+ }
+
+ /**
+ * Method setTimeoutTaskId.
+ *
+ * @param i BukkitTask
+ */
public void setTimeoutTaskId(BukkitTask i) {
if (this.timeoutTaskId != null)
this.timeoutTaskId.cancel();
this.timeoutTaskId = i;
}
- public BukkitTask getTimeoutTaskId() {
- return timeoutTaskId;
+ /**
+ * Method getMessageTaskId.
+ *
+ * @return BukkitTask
+ */
+ public BukkitTask getMessageTaskId() {
+ return messageTaskId;
}
+ /**
+ * Method setMessageTaskId.
+ *
+ * @param messageTaskId BukkitTask
+ */
public void setMessageTaskId(BukkitTask messageTaskId) {
if (this.messageTaskId != null)
this.messageTaskId.cancel();
this.messageTaskId = messageTaskId;
}
- public BukkitTask getMessageTaskId() {
- return messageTaskId;
- }
-
+ /**
+ * Method isFlying.
+ *
+ * @return boolean
+ */
public boolean isFlying() {
return flying;
}
diff --git a/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
index a5ea63d0..0440ddc0 100644
--- a/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
+++ b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
@@ -1,37 +1,35 @@
package fr.xephi.authme.command;
+/**
+ */
public class CommandArgumentDescription {
// TODO: Allow argument to consist of infinite parts.