Merge pull request #217 from AuthMe-Team/master

more from team repo
This commit is contained in:
Alexandre Vanhecke 2015-10-05 15:04:29 +02:00
commit 81de64da6d
62 changed files with 3043 additions and 3596 deletions

View File

@ -1,33 +0,0 @@
# ForcedActions AuthMeReloaded configuration file
forcedActions:
# example1:
# at: firstlogin
# executedBy: console
# commands:
# - 'msg %p Welcome!'
# - pex user set group Player
# example2:
# at: connection
# executedBy: console
# commands:
# - 'msg %p You need to register yourself to play this server!'
#
# Avariable events:
# connection
# firstconnection
# login
# firstlogin
# wrongpassword
# disconnection
# logout
# serverstop
# serverstart
# pluginreload
# mysqlerror
# antiboton
# antibotoff
#

View File

@ -1,113 +0,0 @@
# Advanced AuthMeReloaded configuration file
sessionLogin:
# Do you want to enable session? When enabled
# the ip of a player will be bound to the nickname
# of the player on login. As long as neither of those
# two change players don't have to login on a reconnect
enabled: false
# After how many minutes a session should timeout?
# 0 for unlimitted sessions, use 0 at your own risk!
# consider that session will end only after timeout, and
# if player's ip is changed but the timeout treshould isent
# ended, player will kick out of sever for invalidSession!
timeout: 10
# Do we need to timeout the session if the player is offline
# And try to login with an another IP Address?
sessionExpireOnIpChange: true
security:
# Online players aren't kicked out for "Logged in from another location!", this option should always be set to true!
forceSingleSession: true
# Should we display all other accounts from a player when he joins?
# permission: /authme.admin.accounts
displayOtherAccounts: true
# Should the purge command can be performed only from the console?
purgeOnlyFromConsole: true
# Minimum value for the purge ingame command (if enabled), prevent the destruction of the entire database.
minIngamePurgeDays: 30
captcha:
# Do players need to write a captcha code if they use too many times a wrong password
useCaptcha: false
# Max allowed tries before request a captcha
maxLoginTry: 5
# Captcha length
captchaLength: 5
# Restricted users will be kicked if their IP aren't the same specified below.
# Usage: - username;ip
RestrictedUsers:
- playername;127.0.0.1
# User listed below will bypass every login/registration system. CASE SENSITIVE!!!
# Use this at your own risk!!! USE ONLY WITH ONLINE MODE SERVERS!!!
# This option can add compatibility with BuildCraft and some other mods.
UnrestrictedName: []
passwordEncryption:
# possible values: MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB,
# PLAINTEXT ( unhashed password),
# MYBB, IPB3, PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512,
# DOUBLEMD5, PBKDF2, WORDPRESS, ROYALAUTH, CUSTOM(for developpers only)
passwordHash: SHA256
# salt length for the SALTED2MD5 MD5(MD5(password)+salt)
doubleMD5SaltLength: 8
# If password checking return false , do we need to check with all
# other password algorithm to check an old password ?
# AuthMe will update the password to the new passwordHash !
supportOldPasswordHash: false
SQLProblem:
# Stop the server if we can't contact the sql database
# Take care with this, if you set that to false,
# AuthMe automatically disable and the server is not protected!
stopServer: true
ReloadCommand:
# /reload support
useReloadCommandSupport: true
console:
# Remove spam console
noConsoleSpam: false
# Replace passwords in the console when player type a command like /login
removePassword: true
externalBoard:
# MySQL column for the salt , needed for some forum/cms support
mySQLColumnSalt: ''
# MySQL column for the group, needed for some forum/cms support
mySQLColumnGroup: ''
# -1 mean disabled. If u want that only
# activated player can login in your server
# u can put in this options the group number
# of unactivated user, needed for some forum/cms support
nonActivedUserGroup: -1
# Other MySQL columns where we need to put the Username (case sensitive)
mySQLOtherUsernameColumns: []
# How much Log to Round needed in BCrypt(do not change it if you do not know what's your doing)
bCryptLog2Round: 10
# phpBB prefix defined during phpbb installation process
phpbbTablePrefix: 'phpbb_'
# phpBB activated group id , 2 is default registered group defined by phpbb
phpbbActivatedGroupId: 2
# WordPress prefix defined during WordPress installation process
wordpressTablePrefix: 'wp_'
hooks:
# Do we need to hook with multiverse for spawn checking?
multiverse: true
# Do we need to hook with ChestShop for prevent buy or selling ?
chestshop: true
# Do we need to hook with BungeeCord for get the real Player ip ?
bungeecord: false
# Do we need to disable Essentials SocialSpy on join ?
disableSocialSpy: true
# Do we need to cache custom Attributes ?
customAttributes: false
# Spawn Priority, Values : authme, essentials, multiverse, default
spawnPriority: authme,essentials,multiverse,default
# AuthMe will NEVER teleport players !
noTeleport: false

View File

@ -1,68 +0,0 @@
# Database AuthMeReloaded configuration file
# What type of database do you want to use? Avariable options: sqlite, mysql, redis
backend: sqlite
# Do you like to cache all the queries? (Performance Boost)
caching: true
# Database Name
databaseName: authme
# Table of the database
tableName: authme
# MySql Database connection settings
# Avariable only if the AuthMeReloaded-Mysql module is installed!
mysql:
port: '3306'
host: 127.0.0.1
username: authme
password: '12345'
# Redis Database connection settings
# Avariable only if the AuthMeReloaded-Redis module is installed!
redis:
# Get Redis from http://redis.io/
host: 127.0.0.1
port: 6379
# If your Redis server uses AUTH, set here the password.
password: ""
# Database column names
columnNames:
idColumn: id
nameColumn: username
realNameColumn: realname
passwordColumn: password
ipColumn: ip
emailColumn: email
loginStatusColumn: loginstatus
lastLoginColumn: lastlogin
lastlLocationXColumn: x
lastLocationYColumn: y
lastLocationZColumn: z
lastLocationWorldColumn: world
backup:
# Enable or disable Automatic Backup of the SQLite database, destination path: "/AuthMe/backups/%date%/%timestamp%.sql"
ActivateBackup: false
# Interval time (in minutes), set to 0 to disable periodic backup
Interval: 300
# Do you want to perform a Backup when the server starts?
OnServerStart: false
# Do you want to perform a Backup when the server stops?
OnServerStop: true
purge:
# Does AuthMe need to purge automatically old unused accounts?
useAutoPurge: false
# Number of Days required to mark an account as Unused
daysBeforeRemovePlayer: 60
# What to remove
remove:
playerInventoryFile: true
essentialsFiles: true
permissions: true
limitedCreativesInventories: true
antiXRayFiles: true
# World where players.dat are stored (necessary to remove inventory files)
defaultWorld: 'world'

View File

@ -1,40 +0,0 @@
emailSystem:
# Do you want to replace the Password registration with an Email registration method?
enableEmailRegistration: false
# Do you want to enable the double check of the email address during a player registration?
# When it's true, registration require that kind of command:
# /register <email> <confirmEmail>
doubleEmailCheck: true
# Like maxRegPerIp but with emails
maxRegPerEmail: 1
# Do you want to recall players to add an email to their accounts?
recallPlayers: true
# Delay in minute for the recall scheduler
delayRecall: 5
passwordRecovery:
# Recovery password length
RecoveryPasswordLength: 8
# Recovery Email subject
mailSubject: 'Your new AuthMe Password'
# Recovery Email text
mailText: 'Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword'
smtpOptions:
# SMTP server host
mailSMTP: smtp.gmail.com
# SMTP server port
mailPort: 465
# Email account that sends the mails
mailAccount: ''
# Email account's password
mailPassword: ''
# Custom SenderName, that replace the mailAccount name in the emails
mailSenderName: ''
emailSecurity:
# Blacklisted domains for emails
emailBlacklist:
- 10minutemail.com
# Do you like a Whitelist instead of a Blacklist?
blacklistAsWhitelist: false

View File

@ -1,100 +0,0 @@
# █████╗ ██╗ ██╗████████╗██╗ ██╗ ███╗ ███╗███████╗ ██████╗ ███████╗██╗ ██████╗ ██████╗ ███████╗██████╗
# ██╔══██╗██║ ██║╚══██╔══╝██║ ██║ ████╗ ████║██╔════╝ ██╔══██╗██╔════╝██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
# ███████║██║ ██║ ██║ ███████║ ██╔████╔██║█████╗ ██████╔╝█████╗ ██║ ██║ ██║██║ ██║█████╗ ██║ ██║
# ██╔══██║██║ ██║ ██║ ██╔══██║ ██║╚██╔╝██║██╔══╝ ██╔══██╗██╔══╝ ██║ ██║ ██║██║ ██║██╔══╝ ██║ ██║
# ██║ ██║╚██████╔╝ ██║ ██║ ██║ ██║ ╚═╝ ██║███████╗ ██║ ██║███████╗███████╗╚██████╔╝██████╔╝███████╗██████╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝
# Welcome to the AuthMeReloaded main configuration file!
# Available languages: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt
language: en
registration:
# Do you want to enable the registration on the server?
enabled: true
# Do you want to force players to register before playing?
force: true
# Maximum Registration per IP
maxRegPerIp: 1
# Maximum allowed username length
maxUsernameLength: 30
# Minimum required username length
minUsernameLength: 4
# Regex syntax allowed in player's username
allowedNicknameCharacters: '[a-zA-Z0-9_]*'
# Do you want to kick players after a successful registration?
# Do not use this option with the loginAfterRegister feature below!
kickAfterRegistration: false
# Do you want to force the player to login after a successful registration?
loginAfterRegister: false
login:
# How many players per IP can join the server concurrently?
maxInstanceForIP: 1
# Should not registered players be kicked immediately?
kickNonRegistered: false
# Should the players be kicked immediately on wrong password?
kickOnWrongPassword: false
# Send every X seconds a message to a player to remind him that he has to login/register
messageInterval: 5
# How many second a player can login or register before being kicked? Set this to 0 to disable.
timeout: 30
# Teleport the player to the world's Spawn after login
teleportToSpawnAfterLogin: true
# Teleport provisionally not logged player to world's Spawn.
# After the login, if teleportToSpawnAfterLogin is set to false the player will be teleported to his last location.
teleportToSpawnBeforeLogin: true
# ForceSurvivalMode to player when join?
forceSurvivalMode: false
# Do we need to force the survival mode ONLY after /login process?
forceSurvivalOnlyAfterLogin: false
# Reset every time the player's inventory?
resetInventory: false
# If player join with CreativeMode and ForceSurvivalMode: true inventory will be wiped.
resetInventoryIfCreative: false
# Should we protect the player inventory before logging in?
protectInventoryBeforeLogIn: true
password:
# minimum Length of password
minPasswordLength: 5
# Regex sintax for allowed Chars in passwords.
allowedPasswordCharacters: '[\x21-\x7E]*'
# Enable double check of password when you register or change password.
# When it's true, registration require that kind of command:
# /register <password> <confirmPassword>
doublePasswordCheck: true
# Deny unsafe passwords for being used, put them on lowercase!
unsafePasswords:
- '123456'
- '12345'
- 'qwerty'
- 'password'
protection:
# Enable some server protection systems (country based login, antibot)
enableProtection: false
# Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes
countries:
- US
- GB
# Countries blacklisted automatically (It works also with enableProtection set to false)
countriesBlacklist:
- A1
antiBot:
# Do you like to enable the automatic antibot system?
enableAntiBot: false
# Do you want to show AntiBot messages to every player or only to person with the "authme.antibotmessages" permission node?
broadcastMessages: true
# Max number of player allowed to join in 5 secs before the AntiBot activates
antiBotSensibility: 5
# Duration in minutes of the antibot protection
antiBotDuration: 10
# These features are only available on the VeryGames Server Provider
veryGames:
enableIpCheck: false

View File

@ -1,21 +0,0 @@
_________________________________________________________________________________
> <
> WARNING: Conversions can't be undone! DO ALWAYS A BACKUP BEFORE!!! <
> <
_________________________________________________________________________________
> AuthMe Reloaded converters description file <
_________________________________________________________________________________
Built-in converters (Into the Plugin's core module):
Old File Backend ("file") >>> SQLite ("/authme converter flatfiletosqlite") THIS CONVERTER WILL BE REMOVED FROM THE CORE IN FUTURE VERSIONS!!!
Converters in the Converters module (Into the Converters module avariable at: NEED LINK):
SQlite >>> MySql ("/authme converter sqlitetomysql")
MySql >>> Redis ("/authme converter mysqltoredis")
Rakamak >>> SQlite ("/authme converter rakamaktosqlite [databasefile.rak] [(ip-mode) (ipdatabasefle.rak)]")
CrazyLogin >>> SQlite ("/authme converter crazylogintosqlite [databasefile.db]")
xAuth (Min version 2.6) >>> SQlite ("/authme converter xauthtosqlite") NOTE: xAUTH MUST BE INSTALLED AND CONFIGURED IN THE SERVER, it works with all the xAuth backends!
Discontinued Converters (use an old AuthMe version like 3.4):
RoyalAuth >>> SQlite
vAuth >>> SQlite

View File

@ -3,6 +3,8 @@
<hr>
#####Development tools:
- DEVELOPMENT TEAM REPO (<strong>please send PRs here!</strong>): <a href="https://github.com/AuthMe-Team/AuthMeReloaded">Github Development Page</a>
- Developers ChatRoom: [![Join the chat at https://gitter.im/Xephi/AuthMeReloaded](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Xephi/AuthMeReloaded?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- Build status: [![Build Status](https://travis-ci.org/Xephi/AuthMeReloaded.svg?branch=master)](https://travis-ci.org/Xephi/AuthMeReloaded) [![Dependency Status](https://www.versioneye.com/user/projects/55bab9e8653762002000190a/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55bab9e8653762002000190a)
@ -41,6 +43,8 @@ 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
<hr>
###Plugin Description:
@ -130,6 +134,6 @@ GameHosting.it is leader in Italy as Game Server Provider. With its own DataCent
[![GameHosting](http://www.gamehosting.it/images/bn3.png)](http://www.gamehosting.it)
#####Credits
<p>Team members: Xephi(Main Developer, Author), Maxetto(Contributor) and sgdc3(Contributor)
<p>Team members: look at the <a href="https://github.com/AuthMe-Team/AuthMeReloaded/blob/master/team.txt">team.txt file</a>
<p>Credit for old version of the plugin to: d4rkwarriors, fabe1337 , Whoami2 and pomo4ka</p>
<p>Thanks also to: AS1LV3RN1NJA, Hoeze and eprimex</p>

196
pom.xml
View File

@ -6,6 +6,7 @@
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
<version>5.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AuthMeReloaded</name>
<description>Authentication plugin for CraftBukkit/Spigot!</description>
@ -56,7 +57,7 @@
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<directory>src/main/resources/</directory>
<includes>
<include>*.yml</include>
</includes>
@ -64,7 +65,7 @@
<resource>
<targetPath>./messages/</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/messages/</directory>
<directory>src/main/resources/messages/</directory>
<includes>
<include>*.yml</include>
</includes>
@ -88,9 +89,8 @@
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-simple</include>
<include>org.slf4j:slf4j-jdk14</include>
<include>org.slf4j:slf4j-api</include>
<include>com.google.code.gson:gson</include>
<include>com.maxmind.geoip:geoip-api</include>
<include>com.sun.mail:javax.mail</include>
<include>com.comphenix.attribute:AttributeStorage</include>
@ -121,13 +121,13 @@
<!-- SpigotMC Repo (Bukkit and SpigotAPI) -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
<url>http://hub.spigotmc.org/nexus/content/groups/public</url>
</repository>
<!-- EssentialsX Repo -->
<repository>
<id>ess-repo</id>
<url>https://ci.drtshock.net/plugin/repository/everything</url>
<url>http://ci.drtshock.net/plugin/repository/everything</url>
</repository>
<!-- CombatTagPlus Repo -->
@ -160,11 +160,12 @@
<url>http://repo.luricos.de/content/repositories/releases</url>
</repository>
<!-- Xephi Repo (ChestShop) -->
<!-- Xephi Repo
<repository>
<id>xephi-repo</id>
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository>
-->
<!-- Metrics Snapshots Repo -->
<repository>
@ -190,12 +191,23 @@
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.12</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Log4J Logger (for the filter) -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- SQLite Connector -->
@ -204,14 +216,7 @@
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.1</version>
<scope>compile</scope>
</dependency>
<!-- Google JSON Library -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Java Email API and Implementation -->
@ -220,6 +225,7 @@
<artifactId>javax.mail-api</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
@ -232,6 +238,7 @@
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
@ -241,6 +248,7 @@
<artifactId>geoip-api</artifactId>
<version>1.2.15</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Metrics API -->
@ -255,15 +263,31 @@
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- Spigot-Api, http://www.spigotmc.org/ Based on the Bukkit project,
<!-- Spigot-Api, http://www.spigotmc.org/ Based on the Bukkit project,
http://bukkit.org/ -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${bukkitVersion}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>json-simple</artifactId>
<groupId>com.googlecode.json-simple</groupId>
</exclusion>
<exclusion>
<artifactId>persistence-api</artifactId>
<groupId>javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Attribute -->
@ -282,6 +306,25 @@
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!--ProtocolLib http://dev.bukkit.org/bukkit-plugins/protocollib/ -->
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>3.4.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>cglib-nodep</artifactId>
<groupId>cglib</groupId>
</exclusion>
<exclusion>
<artifactId>BukkitExecutors</artifactId>
<groupId>com.comphenix.executors</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Vault, http://dev.bukkit.org/bukkit-plugins/vault/ -->
@ -300,6 +343,7 @@
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- Multi World plugin, http://www.spigotmc.org/resources/multiverse-core.390/ -->
@ -330,7 +374,28 @@
<artifactId>CommandHandler</artifactId>
<groupId>com.pneumaticraft.commandhandler</groupId>
</exclusion>
<exclusion>
<artifactId>SerializationConfig</artifactId>
<groupId>me.main__.util</groupId>
</exclusion>
<exclusion>
<artifactId>Logging</artifactId>
<groupId>com.dumptruckman.minecraft</groupId>
</exclusion>
<exclusion>
<artifactId>metrics</artifactId>
<groupId>org.mcstats.bukkit</groupId>
</exclusion>
<exclusion>
<artifactId>buscript</artifactId>
<groupId>com.dumptruckman.minecraft</groupId>
</exclusion>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- Essentials plugin -->
@ -345,6 +410,7 @@
<artifactId>spigot-api</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- Anti PvPLogging plugin, https://github.com/MinelinkNetwork/CombatTagPlus -->
@ -419,6 +485,7 @@
<groupId>org.mcstats.bukkit</groupId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- XAuth, another authentication plugin, required by the database converter -->
@ -456,101 +523,12 @@
<artifactId>AccountsClient</artifactId>
<groupId>com.mojang</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- ChestShop, on our maven repo http://dev.bukkit.org/bukkit-plugins/chestshop/ -->
<dependency>
<groupId>com.acrobot.chestshop</groupId>
<artifactId>chestshop</artifactId>
<version>3.8.12</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
<exclusion>
<artifactId>Vault</artifactId>
<groupId>net.milkbowl.vault</groupId>
</exclusion>
<exclusion>
<artifactId>odditem</artifactId>
<groupId>info.somethingodd</groupId>
</exclusion>
<exclusion>
<artifactId>scrollingmenusign</artifactId>
<groupId>me.desht</groupId>
</exclusion>
<exclusion>
<artifactId>truezip</artifactId>
<groupId>de.schlichtherle</groupId>
</exclusion>
<exclusion>
<artifactId>residence</artifactId>
<groupId>net.t00thpick1</groupId>
</exclusion>
<exclusion>
<artifactId>Heroes</artifactId>
<groupId>com.herocraftonline.heroes</groupId>
</exclusion>
<exclusion>
<artifactId>HeroChat</artifactId>
<groupId>com.dthielke.herochat</groupId>
</exclusion>
<exclusion>
<artifactId>worldguard</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>worldedit</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>lwc</artifactId>
<groupId>com.griefcraft.lwc</groupId>
</exclusion>
<exclusion>
<artifactId>js</artifactId>
<groupId>rhino</groupId>
</exclusion>
<exclusion>
<artifactId>jchronic</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>deadbolt</artifactId>
<groupId>com.daemitus.deadbolt</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit-classloader-check</artifactId>
<groupId>com.sk89q.spigot</groupId>
</exclusion>
<exclusion>
<artifactId>jsr305</artifactId>
<groupId>com.google.code.findbugs</groupId>
</exclusion>
<exclusion>
<artifactId>opencsv</artifactId>
<groupId>net.sf.opencsv</groupId>
</exclusion>
<exclusion>
<artifactId>simplechestlock</artifactId>
<groupId>com.webkonsept.bukkit.simplechestlock</groupId>
</exclusion>
<exclusion>
<artifactId>commandbook</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>lockette</artifactId>
<groupId>org.yi.acru.bukkit.lockette</groupId>
<artifactId>log4j-core</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
</dependencies>

File diff suppressed because it is too large Load Diff

View File

@ -160,7 +160,6 @@ public class Utils {
}
// TODO: remove if not needed
@SuppressWarnings("unused")
public static void hasPermOnJoin(Player player) {
if (plugin.permission == null)
return;
@ -176,20 +175,24 @@ public class Utils {
if (player == null || Utils.isUnrestricted(player)) {
return true;
}
String name = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(name)) {
return true;
}
if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) {
if (!Settings.isForcedRegistrationEnabled) {
if (!plugin.database.isAuthAvailable(name)) {
return true;
}
}
return false;
}
public static boolean isUnrestricted(Player player) {
return Settings.isAllowRestrictedIp && !(Settings.getUnrestrictedName == null || Settings.getUnrestrictedName.isEmpty()) && (Settings.getUnrestrictedName.contains(player.getName()));
return Settings.isAllowRestrictedIp && !Settings.getUnrestrictedName.isEmpty()
&& (Settings.getUnrestrictedName.contains(player.getName()));
}
private static boolean useGroupSystem() {

View File

@ -1,183 +1,183 @@
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.Utils;
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;
public class API {
public static final String newline = System.getProperty("line.separator");
public static AuthMe instance;
@Deprecated
public API(AuthMe instance) {
API.instance = instance;
}
/**
* Hook into AuthMe
*
* @return AuthMe instance
*/
@Deprecated
public static AuthMe hookAuthMe() {
if (instance != null)
return instance;
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (plugin == null || !(plugin instanceof AuthMe)) {
return null;
}
instance = (AuthMe) plugin;
return instance;
}
@Deprecated
public AuthMe getPlugin() {
return instance;
}
/**
*
* @param player
* @return true if player is authenticate
*/
@Deprecated
public static boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
/**
*
* @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
public static boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
@Deprecated
public static Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
if (auth != null) {
Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
return loc;
} else {
return null;
}
} catch (NullPointerException ex) {
return null;
}
}
@Deprecated
public static void setPlayerInventory(Player player, ItemStack[] content,
ItemStack[] armor) {
try {
player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor);
} catch (NullPointerException npe) {
}
}
/**
*
* @param playerName
* @return true if player is registered
*/
@Deprecated
public static boolean isRegistered(String playerName) {
String player = playerName.toLowerCase();
return instance.database.isAuthAvailable(player);
}
/**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else
*/
@Deprecated
public static boolean checkPassword(String playerName,
String passwordToCheck) {
if (!isRegistered(playerName))
return false;
String player = playerName.toLowerCase();
PlayerAuth auth = instance.database.getAuth(player);
try {
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) {
return false;
}
}
/**
* Register a player
*
* @param String
* playerName, String password
* @return true if the player is register correctly
*/
@Deprecated
public static boolean registerPlayer(String playerName, String password) {
try {
String name = playerName.toLowerCase();
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (isRegistered(name)) {
return false;
}
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com");
if (!instance.database.saveAuth(auth)) {
return false;
}
return true;
} catch (NoSuchAlgorithmException ex) {
return false;
}
}
/**
* Force a player to login
*
* @param Player
* player
*/
@Deprecated
public static void forceLogin(Player player) {
instance.management.performLogin(player, "dontneed", true);
}
}
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.Utils;
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;
public class API {
public static final String newline = System.getProperty("line.separator");
public static AuthMe instance;
@Deprecated
public API(AuthMe instance) {
API.instance = instance;
}
/**
* Hook into AuthMe
*
* @return AuthMe instance
*/
@Deprecated
public static AuthMe hookAuthMe() {
if (instance != null)
return instance;
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (plugin == null || !(plugin instanceof AuthMe)) {
return null;
}
instance = (AuthMe) plugin;
return instance;
}
@Deprecated
public AuthMe getPlugin() {
return instance;
}
/**
*
* @param player
* @return true if player is authenticate
*/
@Deprecated
public static boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
/**
*
* @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
public static boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
@Deprecated
public static Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
if (auth != null) {
Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
return loc;
} else {
return null;
}
} catch (NullPointerException ex) {
return null;
}
}
@Deprecated
public static void setPlayerInventory(Player player, ItemStack[] content,
ItemStack[] armor) {
try {
player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor);
} catch (NullPointerException npe) {
}
}
/**
*
* @param playerName
* @return true if player is registered
*/
@Deprecated
public static boolean isRegistered(String playerName) {
String player = playerName.toLowerCase();
return instance.database.isAuthAvailable(player);
}
/**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else
*/
@Deprecated
public static boolean checkPassword(String playerName,
String passwordToCheck) {
if (!isRegistered(playerName))
return false;
String player = playerName.toLowerCase();
PlayerAuth auth = instance.database.getAuth(player);
try {
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) {
return false;
}
}
/**
* Register a player
*
* @param String
* playerName, String password
* @return true if the player is register correctly
*/
@Deprecated
public static boolean registerPlayer(String playerName, String password) {
try {
String name = playerName.toLowerCase();
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (isRegistered(name)) {
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;
} catch (NoSuchAlgorithmException ex) {
return false;
}
}
/**
* Force a player to login
*
* @param Player
* player
*/
@Deprecated
public static void forceLogin(Player player) {
instance.management.performLogin(player, "dontneed", true);
}
}

View File

@ -1,165 +1,153 @@
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.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
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;
public class NewAPI {
public static final String newline = System.getProperty("line.separator");
public static NewAPI singleton;
public AuthMe plugin;
public NewAPI(AuthMe plugin) {
this.plugin = plugin;
}
public NewAPI(Server serv) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
}
/**
* Hook into AuthMe
*
* @return AuthMe plugin
*/
public static NewAPI getInstance() {
if (singleton != null)
return singleton;
Plugin p = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (p == null || !(p instanceof AuthMe)) {
return null;
}
AuthMe authme = (AuthMe) p;
singleton = (new NewAPI(authme));
return singleton;
}
public AuthMe getPlugin() {
return plugin;
}
/**
*
* @param player
* @return true if player is authenticate
*/
public boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
/**
*
* @param player
* @return true if player is a npc
*/
public boolean isNPC(Player player) {
return Utils.isNPC(player);
}
/**
*
* @param player
* @return true if the player is unrestricted
*/
public boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
public Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
if (auth != null) {
return new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
} else {
return null;
}
} catch (NullPointerException ex) {
return null;
}
}
public void setPlayerInventory(Player player, ItemStack[] content,
ItemStack[] armor) {
try {
player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor);
} catch (Exception npe) {
ConsoleLogger.showError("Some error appear while trying to set inventory for " + player.getName());
}
}
/**
*
* @param playerName
* @return true if player is registered
*/
public boolean isRegistered(String playerName) {
String player = playerName.toLowerCase();
return plugin.database.isAuthAvailable(player);
}
/**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else
*/
public boolean checkPassword(String playerName, String passwordToCheck) {
if (!isRegistered(playerName))
return false;
String player = playerName.toLowerCase();
PlayerAuth auth = plugin.database.getAuth(player);
try {
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) {
return false;
}
}
/**
* Register a player
*
* @param String
* playerName, String password
* @return true if the player is register correctly
*/
public boolean registerPlayer(String playerName, String password) {
try {
String name = playerName.toLowerCase();
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (isRegistered(name)) {
return false;
}
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0, "your@email.com");
return plugin.database.saveAuth(auth);
} catch (NoSuchAlgorithmException ex) {
return false;
}
}
/**
* Force a player to login
*
* @param Player
* player
*/
public void forceLogin(Player player) {
plugin.management.performLogin(player, "dontneed", true);
}
}
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.Utils;
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;
public class NewAPI {
public static final String newline = System.getProperty("line.separator");
public static NewAPI singleton;
public AuthMe plugin;
public NewAPI(AuthMe plugin) {
this.plugin = plugin;
}
public NewAPI(Server serv) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
}
/**
* Hook into AuthMe
*
* @return AuthMe plugin
*/
public static NewAPI getInstance() {
if (singleton != null)
return singleton;
Plugin p = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (p == null || !(p instanceof AuthMe)) {
return null;
}
AuthMe authme = (AuthMe) p;
singleton = (new NewAPI(authme));
return singleton;
}
public AuthMe getPlugin() {
return plugin;
}
/**
*
* @param player
* @return true if player is authenticate
*/
public boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
/**
*
* @param player
* @return true if player is a npc
*/
public boolean isNPC(Player player) {
return Utils.isNPC(player);
}
/**
*
* @param player
* @return true if the player is unrestricted
*/
public boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
public Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
if (auth != null) {
return new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
} else {
return null;
}
} catch (NullPointerException ex) {
return null;
}
}
/**
*
* @param playerName
* @return true if player is registered
*/
public boolean isRegistered(String playerName) {
String player = playerName.toLowerCase();
return plugin.database.isAuthAvailable(player);
}
/**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else
*/
public boolean checkPassword(String playerName, String passwordToCheck) {
if (!isRegistered(playerName))
return false;
String player = playerName.toLowerCase();
PlayerAuth auth = plugin.database.getAuth(player);
try {
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) {
return false;
}
}
/**
* Register a player
*
* @param String
* playerName, String password
* @return true if the player is register correctly
*/
public boolean registerPlayer(String playerName, String password) {
try {
String name = playerName.toLowerCase();
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (isRegistered(name)) {
return false;
}
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0, "your@email.com", playerName);
return plugin.database.saveAuth(auth);
} catch (NoSuchAlgorithmException ex) {
return false;
}
}
/**
* Force a player to login
*
* @param Player
* player
*/
public void forceLogin(Player player) {
plugin.management.performLogin(player, "dontneed", true);
}
}

View File

@ -1,36 +1,17 @@
package fr.xephi.authme.cache.backup;
import org.bukkit.inventory.ItemStack;
public class DataFileCache {
private ItemStack[] inventory;
private ItemStack[] armor;
private String group;
private boolean operator;
private boolean flying;
public DataFileCache(ItemStack[] inventory, ItemStack[] armor) {
this(inventory, armor, "", false, false);
}
public DataFileCache(ItemStack[] inventory, ItemStack[] armor,
String group, boolean operator, boolean flying) {
this.inventory = inventory;
this.armor = armor;
public DataFileCache(String group, boolean operator, boolean flying) {
this.group = group;
this.operator = operator;
this.flying = flying;
}
public ItemStack[] getInventory() {
return inventory;
}
public ItemStack[] getArmour() {
return armor;
}
public String getGroup() {
return group;
}

View File

@ -3,20 +3,13 @@ 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.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
@ -24,11 +17,9 @@ import java.lang.reflect.Type;
public class JsonCache {
private final Gson gson;
private final AuthMe plugin;
private final File cacheDir;
public JsonCache(AuthMe plugin) {
this.plugin = plugin;
public JsonCache() {
cacheDir = Settings.CACHE_FOLDER;
if (!cacheDir.exists() && !cacheDir.isDirectory() && !cacheDir.mkdir()) {
ConsoleLogger.showError("Failed to create cache directory.");
@ -99,49 +90,8 @@ public class JsonCache {
jsonObject.addProperty("operator", dataFileCache.getOperator());
jsonObject.addProperty("flying", dataFileCache.isFlying());
JsonArray arr;
ItemStack[] contents;
// inventory
contents = dataFileCache.getInventory();
arr = new JsonArray();
putItems(contents, arr);
jsonObject.add("inventory", arr);
// armour
contents = dataFileCache.getArmour();
arr = new JsonArray();
putItems(contents, arr);
jsonObject.add("armour", arr);
return jsonObject;
}
private void putItems(ItemStack[] contents, JsonArray target) {
for (ItemStack item : contents) {
if (item == null) {
item = new ItemStack(Material.AIR);
}
JsonObject val = new JsonObject();
if (item.getType() == Material.SKULL_ITEM) {
SkullMeta meta = (SkullMeta) item.getItemMeta();
if (meta.hasOwner() && (meta.getOwner() == null || meta.getOwner().isEmpty())) {
item.setItemMeta(plugin.getServer().getItemFactory().getItemMeta(Material.SKULL_ITEM));
}
}
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BukkitObjectOutputStream objectOut = new BukkitObjectOutputStream(baos);
objectOut.writeObject(item);
objectOut.close();
val.addProperty("item", Base64Coder.encodeLines(baos.toByteArray()));
} catch (IOException e) {
e.printStackTrace();
continue;
}
target.add(val);
}
}
}
private static class PlayerDataDeserializer implements JsonDeserializer<DataFileCache> {
@ -166,39 +116,7 @@ public class JsonCache {
flying = e.getAsBoolean();
}
JsonArray arr;
ItemStack[] inv = null;
ItemStack[] armour = null;
if (jsonObject.has("inventory")) {
arr = jsonObject.get("inventory").getAsJsonArray();
inv = getItems(arr);
}
if (jsonObject.has("armour")) {
arr = jsonObject.get("armour").getAsJsonArray();
armour = getItems(arr);
}
return new DataFileCache(inv, armour, group, operator, flying);
}
private ItemStack[] getItems(JsonArray arr) {
ItemStack[] contents = new ItemStack[arr.size()];
for (int i = 0; i < arr.size(); i++) {
JsonObject item = arr.get(i).getAsJsonObject();
String encoded = item.get("item").getAsString();
byte[] decoded = Base64Coder.decodeLines(encoded);
try {
ByteArrayInputStream baos = new ByteArrayInputStream(decoded);
BukkitObjectInputStream objectIn = new BukkitObjectInputStream(baos);
contents[i] = (ItemStack) objectIn.readObject();
objectIn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return contents;
return new DataFileCache(group, operator, flying);
}
}

View File

@ -11,7 +11,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ConcurrentHashMap;
@ -25,15 +24,13 @@ public class LimboCache {
private LimboCache(AuthMe plugin) {
this.plugin = plugin;
this.cache = new ConcurrentHashMap<>();
this.playerData = new JsonCache(plugin);
this.playerData = new JsonCache();
}
public void addLimboPlayer(Player player) {
String name = player.getName().toLowerCase();
Location loc = player.getLocation();
GameMode gameMode = player.getGameMode();
ItemStack[] arm;
ItemStack[] inv;
boolean operator = false;
String playerGroup = "";
boolean flying = false;
@ -42,12 +39,10 @@ public class LimboCache {
final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
inv = event.getInventory();
arm = event.getArmor();
} else {
inv = null;
arm = null;
player.getInventory().setContents(event.getInventory());
player.getInventory().setArmorContents(event.getArmor());
}
DataFileCache cache = playerData.readCache(player);
if (cache != null) {
playerGroup = cache.getGroup();
@ -58,12 +53,10 @@ public class LimboCache {
StoreInventoryEvent event = new StoreInventoryEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
inv = event.getInventory();
arm = event.getArmor();
} else {
inv = null;
arm = null;
player.getInventory().setContents(event.getInventory());
player.getInventory().setArmorContents(event.getArmor());
}
operator = player.isOp();
flying = player.isFlying();
if (plugin.permission != null) {
@ -93,7 +86,7 @@ public class LimboCache {
if (player.isDead()) {
loc = plugin.getSpawnLocation(player);
}
cache.put(name, new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
}
public void addLimboPlayer(Player player, String group) {

View File

@ -2,14 +2,11 @@ package fr.xephi.authme.cache.limbo;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
public class LimboPlayer {
private String name;
private ItemStack[] inventory;
private ItemStack[] armour;
private Location loc = null;
private BukkitTask timeoutTaskId = null;
private BukkitTask messageTaskId = null;
@ -18,19 +15,6 @@ public class LimboPlayer {
private String group = "";
private boolean flying = false;
public LimboPlayer(String name, Location loc, ItemStack[] inventory,
ItemStack[] armour, GameMode gameMode, boolean operator,
String group, boolean flying) {
this.name = name;
this.loc = loc;
this.inventory = inventory;
this.armour = armour;
this.gameMode = gameMode;
this.operator = operator;
this.group = group;
this.flying = flying;
}
public LimboPlayer(String name, Location loc, GameMode gameMode,
boolean operator, String group, boolean flying) {
this.name = name;
@ -54,22 +38,6 @@ public class LimboPlayer {
return loc;
}
public ItemStack[] getArmour() {
return armour;
}
public ItemStack[] getInventory() {
return inventory;
}
public void setArmour(ItemStack[] armour) {
this.armour = armour;
}
public void setInventory(ItemStack[] inventory) {
this.inventory = inventory;
}
public GameMode getGameMode() {
return gameMode;
}
@ -105,5 +73,4 @@ public class LimboPlayer {
public boolean isFlying() {
return flying;
}
}

View File

@ -109,7 +109,7 @@ public class AdminCommand implements CommandExecutor {
}
} else if (args[0].equalsIgnoreCase("reload")) {
try {
plugin.getSettings().reload();
Settings.reload();
m.reloadMessages();
plugin.database.close();
plugin.setupDatabase();
@ -260,7 +260,7 @@ public class AdminCommand implements CommandExecutor {
return;
}
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, lowpass, name);
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0L, "your@email.com");
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0L, "your@email.com", name);
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt("");

View File

@ -62,7 +62,7 @@ public class ChangePasswordCommand implements CommandExecutor {
return true;
}
}
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, args[0]));
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, args[0], args[1]));
return true;
}
}

View File

@ -173,12 +173,9 @@ public class EmailCommand implements CommandExecutor {
plugin.database.updatePassword(auth);
plugin.mail.main(auth, thePass);
m.send(player, "email_send");
} catch (NoSuchAlgorithmException ex) {
} catch (NoSuchAlgorithmException | NoClassDefFoundError ex) {
ConsoleLogger.showError(ex.getMessage());
m.send(sender, "error");
} catch (NoClassDefFoundError ncdfe) {
ConsoleLogger.showError(ncdfe.getMessage());
m.send(sender, "error");
}
} else {
m.send(player, "reg_email_msg");

View File

@ -18,7 +18,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
@ -34,7 +33,7 @@ public class UnregisterCommand implements CommandExecutor {
public UnregisterCommand(AuthMe plugin) {
this.plugin = plugin;
this.playerCache = new JsonCache(plugin);
this.playerCache = new JsonCache();
}
@Override
@ -79,8 +78,7 @@ public class UnregisterCommand implements CommandExecutor {
player.teleport(tpEvent.getTo());
}
}
player.getInventory().setContents(new ItemStack[36]);
player.getInventory().setArmorContents(new ItemStack[4]);
player.saveData();
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
if (!Settings.getRegisteredGroup.isEmpty())

View File

@ -1,20 +1,18 @@
package fr.xephi.authme.converter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Settings;
import org.bukkit.command.CommandSender;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
/**
*
* @author Xephi59
*/
public class CrazyLoginConverter implements Converter {
@ -33,22 +31,17 @@ public class CrazyLoginConverter implements Converter {
return this;
}
private static String fileName;
private static File source;
@Override
public void run() {
fileName = Settings.crazyloginFileName;
String fileName = Settings.crazyloginFileName;
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
File source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
if (!source.exists()) {
sender.sendMessage("Error while trying to import datas, please put " + fileName + " in AuthMe folder!");
return;
}
source.createNewFile();
BufferedReader users = null;
String line;
users = new BufferedReader(new FileReader(source));
BufferedReader users = new BufferedReader(new FileReader(source));
while ((line = users.readLine()) != null) {
if (line.contains("|")) {
String[] args = line.split("\\|");
@ -56,14 +49,11 @@ public class CrazyLoginConverter implements Converter {
continue;
if (args[0].equalsIgnoreCase("name"))
continue;
String player = args[0].toLowerCase();
String playerName = args[0].toLowerCase();
String psw = args[1];
try {
if (player != null && psw != null) {
PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis(), player);
database.saveAuth(auth);
}
} catch (Exception e) {
if (psw != null) {
PlayerAuth auth = new PlayerAuth(playerName, psw, "127.0.0.1", System.currentTimeMillis(), playerName);
database.saveAuth(auth);
}
}
}

View File

@ -1,18 +1,12 @@
package fr.xephi.authme.converter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
import java.io.*;
/**
*
* @author Xephi59
*/
public class FlatToSql implements Converter {
@ -29,8 +23,6 @@ public class FlatToSql implements Converter {
private static String columnEmail;
private static String columnLogged;
private static String columnID;
private static File source;
private static File output;
public FlatToSql() {
tableName = Settings.getMySQLTablename;
@ -50,9 +42,9 @@ public class FlatToSql implements Converter {
@Override
public void run() {
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
File source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql");
File output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql");
output.createNewFile();
BufferedReader br = new BufferedReader(new FileReader(source));
BufferedWriter sql = new BufferedWriter(new FileWriter(output));

View File

@ -1,44 +1,44 @@
package fr.xephi.authme.converter;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
import org.bukkit.command.CommandSender;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
import java.sql.*;
public class FlatToSqlite implements Converter {
public CommandSender sender;
private String tableName;
private String columnName;
private String columnPassword;
private String columnIp;
private String columnLastLogin;
private String lastlocX;
private String lastlocY;
private String lastlocZ;
private String lastlocWorld;
private String columnEmail;
private String database;
private String columnID;
private Connection con;
public FlatToSqlite(CommandSender sender) {
this.sender = sender;
}
private static String tableName;
private static String columnName;
private static String columnPassword;
private static String columnIp;
private static String columnLastLogin;
private static String lastlocX;
private static String lastlocY;
private static String lastlocZ;
private static String lastlocWorld;
private static String columnEmail;
private static File source;
private static String database;
private static String columnID;
private static Connection con;
private static void close(AutoCloseable o) {
if (o != null) {
try {
o.close();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
@Override
public void run() {
@ -55,6 +55,12 @@ public class FlatToSqlite implements Converter {
columnEmail = Settings.getMySQLColumnEmail;
columnID = Settings.getMySQLColumnId;
File source = new File(Settings.PLUGIN_FOLDER, "auths.db");
if (!source.exists()) {
sender.sendMessage("Source file for FlatFile database not found... Aborting");
return;
}
try {
connect();
setup();
@ -62,14 +68,12 @@ public class FlatToSqlite implements Converter {
sender.sendMessage("Some error appeared while trying to setup and connect to sqlite database... Aborting");
return;
}
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
BufferedReader br = new BufferedReader(new FileReader(source));
try (BufferedReader reader = new BufferedReader(new FileReader(source))) {
String line;
int i = 1;
String newline;
while ((line = br.readLine()) != null) {
while ((line = reader.readLine()) != null) {
String[] args = line.split(":");
if (args.length == 4)
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, 'world', 'your@email.com');";
@ -84,25 +88,23 @@ public class FlatToSqlite implements Converter {
saveAuth(newline);
i = i + 1;
}
br.close();
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
close();
sender.sendMessage("The FlatFile has been converted to " + database + ".db file");
return;
String resp = "The FlatFile has been converted to " + database + ".db file";
ConsoleLogger.info(resp);
sender.sendMessage(resp);
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
sender.sendMessage("Can't open the flat database file! Does it exist?");
sender.sendMessage("Can't open the flat database file!");
} finally {
close(con);
}
return;
}
private synchronized static void connect()
throws ClassNotFoundException, SQLException {
private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
}
private synchronized static void setup() throws SQLException {
private synchronized void setup() throws SQLException {
Statement st = null;
ResultSet rs = null;
try {
@ -145,7 +147,7 @@ public class FlatToSqlite implements Converter {
}
}
private static synchronized boolean saveAuth(String s) {
private synchronized boolean saveAuth(String s) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement(s);
@ -158,32 +160,4 @@ public class FlatToSqlite implements Converter {
}
return true;
}
private static void close(Statement st) {
if (st != null) {
try {
st.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
private static void close(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
public synchronized static void close() {
try {
con.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}

View File

@ -5,15 +5,13 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.settings.Settings;
public class ForceFlatToSqlite implements Converter {
private DataSource data;
private AuthMe plugin;
public ForceFlatToSqlite(DataSource data, AuthMe plugin) {
this.data = data;
this.plugin = plugin;
}
@Override
@ -25,7 +23,7 @@ public class ForceFlatToSqlite implements Converter {
auth.setRealName("Player");
sqlite.saveAuth(auth);
}
plugin.getSettings().setValue("DataSource.backend", "sqlite");
Settings.setValue("DataSource.backend", "sqlite");
ConsoleLogger.info("Database successfully converted to sqlite !");
} catch (Exception e) {
ConsoleLogger.showError("An error appeared while trying to convert flatfile to sqlite ...");

View File

@ -1,5 +1,14 @@
package fr.xephi.authme.converter;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
import org.bukkit.command.CommandSender;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@ -8,18 +17,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
/**
*
* @author Xephi59
*/
public class RakamakConverter implements Converter {
@ -38,27 +36,19 @@ public class RakamakConverter implements Converter {
return this;
}
private static Boolean useIP;
private static String fileName;
private static String ipFileName;
private static File source;
private static File ipfiles;
@Override
public void run() {
HashAlgorithm hash = Settings.getPasswordHash;
useIP = Settings.rakamakUseIp;
fileName = Settings.rakamakUsers;
ipFileName = Settings.rakamakUsersIp;
HashMap<String, String> playerIP = new HashMap<String, String>();
HashMap<String, String> playerPSW = new HashMap<String, String>();
boolean useIP = Settings.rakamakUseIp;
String fileName = Settings.rakamakUsers;
String ipFileName = Settings.rakamakUsersIp;
File source = new File(Settings.PLUGIN_FOLDER, fileName);
File ipfiles = new File(Settings.PLUGIN_FOLDER, ipFileName);
HashMap<String, String> playerIP = new HashMap<>();
HashMap<String, String> playerPSW = new HashMap<>();
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
source.createNewFile();
ipfiles.createNewFile();
BufferedReader users = null;
BufferedReader ipFile = null;
BufferedReader users;
BufferedReader ipFile;
ipFile = new BufferedReader(new FileReader(ipfiles));
String line;
if (useIP) {
@ -84,17 +74,17 @@ public class RakamakConverter implements Converter {
}
users.close();
for (Entry<String, String> m : playerPSW.entrySet()) {
String player = m.getKey();
String psw = playerPSW.get(player);
String playerName = m.getKey();
String psw = playerPSW.get(playerName);
String ip;
if (useIP) {
ip = playerIP.get(player);
ip = playerIP.get(playerName);
} else {
ip = "127.0.0.1";
}
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis(), player);
if (PasswordSecurity.userSalt.containsKey(player))
auth.setSalt(PasswordSecurity.userSalt.get(player));
PlayerAuth auth = new PlayerAuth(playerName, psw, ip, System.currentTimeMillis(), playerName);
if (PasswordSecurity.userSalt.containsKey(playerName))
auth.setSalt(PasswordSecurity.userSalt.get(playerName));
database.saveAuth(auth);
}
ConsoleLogger.info("Rakamak database has been imported correctly");

View File

@ -1,13 +1,12 @@
package fr.xephi.authme.converter;
import java.io.File;
import org.bukkit.OfflinePlayer;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import org.bukkit.OfflinePlayer;
import java.io.File;
public class RoyalAuthConverter implements Converter {
@ -24,16 +23,17 @@ public class RoyalAuthConverter implements Converter {
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
try {
String name = o.getName().toLowerCase();
String separator = File.separator;
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
String sp = File.separator;
File file = new File("." + sp + "plugins" + sp + "RoyalAuth" + sp + "userdata" + sp + name + ".yml");
if (data.isAuthAvailable(name))
continue;
if (!file.exists())
continue;
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com");
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
data.saveAuth(auth);
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
}
}

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.converter;
import java.io.File;
import fr.xephi.authme.settings.CustomConfiguration;
import java.io.File;
public class RoyalAuthYamlReader extends CustomConfiguration {
public RoyalAuthYamlReader(File file) {

View File

@ -1,15 +1,14 @@
package fr.xephi.authme.converter;
import java.util.List;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.FlatFile;
import fr.xephi.authme.settings.Messages;
import org.bukkit.command.CommandSender;
import java.util.List;
public class SqlToFlat implements Converter {
@ -38,11 +37,9 @@ public class SqlToFlat implements Converter {
}
}
sender.sendMessage("Successfully convert from SQL table to file auths.db");
return;
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
Messages.getInstance().send(sender, "error");
return;
}
}

View File

@ -1,10 +1,9 @@
package fr.xephi.authme.converter;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource;
import org.bukkit.command.CommandSender;
public class vAuthConverter implements Converter {

View File

@ -1,18 +1,18 @@
package fr.xephi.authme.converter;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
public class vAuthFileReader {
public AuthMe plugin;
@ -27,33 +27,31 @@ public class vAuthFileReader {
public void convert() throws IOException {
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
Scanner scanner = null;
Scanner scanner;
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String name = line.split(": ")[0];
String password = line.split(": ")[1];
PlayerAuth auth = null;
PlayerAuth auth;
if (isUUIDinstance(password)) {
String pname = null;
String pname;
try {
pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
} catch (Exception e) {
pname = getName(UUID.fromString(name));
} catch (NoSuchMethodError e) {
} catch (Exception | NoSuchMethodError e) {
pname = getName(UUID.fromString(name));
}
if (pname == null)
continue;
auth = new PlayerAuth(pname.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com");
auth = new PlayerAuth(pname.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", pname);
} else {
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com");
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", name);
}
if (auth != null)
database.saveAuth(auth);
database.saveAuth(auth);
}
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
}
}
@ -70,7 +68,7 @@ public class vAuthFileReader {
if (op.getUniqueId().compareTo(uuid) == 0)
return op.getName();
}
} catch (Exception e) {
} catch (Exception ignored) {
}
return null;
}

View File

@ -1,8 +1,7 @@
package fr.xephi.authme.converter;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import org.bukkit.command.CommandSender;
public class xAuthConverter implements Converter {

View File

@ -1,5 +1,13 @@
package fr.xephi.authme.converter;
import de.luricos.bukkit.xAuth.database.DatabaseTables;
import de.luricos.bukkit.xAuth.utils.xAuthLog;
import de.luricos.bukkit.xAuth.xAuth;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import org.bukkit.command.CommandSender;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -8,15 +16,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import de.luricos.bukkit.xAuth.xAuth;
import de.luricos.bukkit.xAuth.database.DatabaseTables;
import de.luricos.bukkit.xAuth.utils.xAuthLog;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
public class xAuthToFlat {
public AuthMe instance;
@ -48,7 +47,7 @@ public class xAuthToFlat {
String pl = getIdPlayer(id);
String psw = getPassword(id);
if (psw != null && !psw.isEmpty() && pl != null) {
PlayerAuth auth = new PlayerAuth(pl, psw, "192.168.0.1", 0, "your@email.com");
PlayerAuth auth = new PlayerAuth(pl, psw, "192.168.0.1", 0, "your@email.com", pl);
database.saveAuth(auth);
}
}
@ -82,7 +81,7 @@ public class xAuthToFlat {
}
public List<Integer> getXAuthPlayers() {
List<Integer> xP = new ArrayList<Integer>();
List<Integer> xP = new ArrayList<>();
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
@ -95,7 +94,7 @@ public class xAuthToFlat {
}
} catch (SQLException e) {
xAuthLog.severe("Cannot import xAuthPlayers", e);
return new ArrayList<Integer>();
return new ArrayList<>();
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
}

View File

@ -6,24 +6,29 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CacheDataSource implements DataSource {
private final DataSource source;
private final AuthMe plugin;
private ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>();
private final ExecutorService exec;
private final ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>();
public CacheDataSource(AuthMe pl, DataSource src) {
this.plugin = pl;
this.source = src;
this.exec = Executors.newCachedThreadPool();
/*
* We need to load all players in cache ... It will took more time to
* load the server, but it will be much easier to check for an
* isAuthAvailable !
*/
pl.getServer().getScheduler().runTaskAsynchronously(pl, new Runnable() {
exec.execute(new Runnable() {
@Override
public void run() {
for (PlayerAuth auth : source.getAllAuths()) {
@ -50,7 +55,7 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean saveAuth(final PlayerAuth auth) {
cache.put(auth.getNickname(), auth);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.saveAuth(auth)) {
@ -62,45 +67,95 @@ public class CacheDataSource implements DataSource {
}
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (source.updatePassword(auth)) {
if (cache.containsKey(auth.getNickname()))
cache.get(auth.getNickname()).setHash(auth.getHash());
return true;
public synchronized boolean updatePassword(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
return false;
}
return false;
final String oldHash = cache.get(auth.getNickname()).getHash();
cache.get(auth.getNickname()).setHash(auth.getHash());
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.updatePassword(auth)) {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setHash(oldHash);
}
}
}
});
return true;
}
@Override
public boolean updateSession(PlayerAuth auth) {
if (source.updateSession(auth)) {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setIp(auth.getIp());
cache.get(auth.getNickname()).setLastLogin(auth.getLastLogin());
cache.get(auth.getNickname()).setRealName(auth.getRealName());
}
return true;
public boolean updateSession(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
return false;
}
return false;
PlayerAuth cachedAuth = cache.get(auth.getNickname());
final String oldIp = cachedAuth.getIp();
final long oldLastLogin = cachedAuth.getLastLogin();
final String oldRealName = cachedAuth.getRealName();
cachedAuth.setIp(auth.getIp());
cachedAuth.setLastLogin(auth.getLastLogin());
cachedAuth.setRealName(auth.getRealName());
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.updateSession(auth)) {
if (cache.containsKey(auth.getNickname())) {
PlayerAuth cachedAuth = cache.get(auth.getNickname());
cachedAuth.setIp(oldIp);
cachedAuth.setLastLogin(oldLastLogin);
cachedAuth.setRealName(oldRealName);
}
}
}
});
return true;
}
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
if (source.updateQuitLoc(auth)) {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setQuitLocX(auth.getQuitLocX());
cache.get(auth.getNickname()).setQuitLocY(auth.getQuitLocY());
cache.get(auth.getNickname()).setQuitLocZ(auth.getQuitLocZ());
cache.get(auth.getNickname()).setWorld(auth.getWorld());
}
return true;
public boolean updateQuitLoc(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
return false;
}
return false;
final PlayerAuth cachedAuth = cache.get(auth.getNickname());
final double oldX = cachedAuth.getQuitLocX();
final double oldY = cachedAuth.getQuitLocY();
final double oldZ = cachedAuth.getQuitLocZ();
final String oldWorld = cachedAuth.getWorld();
cachedAuth.setQuitLocX(auth.getQuitLocX());
cachedAuth.setQuitLocY(auth.getQuitLocY());
cachedAuth.setQuitLocZ(auth.getQuitLocZ());
cachedAuth.setWorld(auth.getWorld());
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.updateQuitLoc(auth)) {
if (cache.containsKey(auth.getNickname())) {
PlayerAuth cachedAuth = cache.get(auth.getNickname());
cachedAuth.setQuitLocX(oldX);
cachedAuth.setQuitLocY(oldY);
cachedAuth.setQuitLocZ(oldZ);
cachedAuth.setWorld(oldWorld);
}
}
}
});
return true;
}
@Override
public int getIps(String ip) {
return source.getIps(ip);
int count = 0;
for (Map.Entry<String, PlayerAuth> p : cache.entrySet()) {
if (p.getValue().getIp().equals(ip)) {
count++;
}
}
return count;
}
@Override
@ -130,75 +185,133 @@ public class CacheDataSource implements DataSource {
}
@Override
public synchronized boolean removeAuth(String user) {
if (source.removeAuth(user)) {
cache.remove(user);
return true;
}
return false;
public synchronized boolean removeAuth(String username) {
final String user = username.toLowerCase();
final PlayerAuth auth = cache.get(user);
cache.remove(user);
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.removeAuth(user)) {
cache.put(user, auth);
}
}
});
return true;
}
@Override
public synchronized void close() {
exec.shutdown();
source.close();
}
@Override
public void reload() {
cache.clear();
source.reload();
for (Player player : Utils.getOnlinePlayers()) {
String user = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(user)) {
PlayerAuth auth = source.getAuth(user);
cache.put(user, auth);
exec.execute(new Runnable() {
@Override
public void run() {
cache.clear();
source.reload();
for (Player player : Utils.getOnlinePlayers()) {
String user = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(user)) {
PlayerAuth auth = source.getAuth(user);
cache.put(user, auth);
}
}
}
}
});
}
@Override
public synchronized boolean updateEmail(PlayerAuth auth) {
if (source.updateEmail(auth)) {
if (cache.containsKey(auth.getNickname()))
cache.get(auth.getNickname()).setEmail(auth.getEmail());
return true;
public synchronized boolean updateEmail(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
return false;
}
return false;
PlayerAuth cachedAuth = cache.get(auth.getNickname());
final String oldEmail = cachedAuth.getEmail();
cachedAuth.setEmail(auth.getEmail());
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.updateEmail(auth)) {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setEmail(oldEmail);
}
}
}
});
return true;
}
@Override
public synchronized boolean updateSalt(PlayerAuth auth) {
if (source.updateSalt(auth)) {
if (cache.containsKey(auth.getNickname()))
cache.get(auth.getNickname()).setSalt(auth.getSalt());
return true;
public synchronized boolean updateSalt(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
return false;
}
return false;
PlayerAuth cachedAuth = cache.get(auth.getNickname());
final String oldSalt = cachedAuth.getSalt();
cachedAuth.setSalt(auth.getSalt());
exec.execute(new Runnable() {
@Override
public void run() {
if (!source.updateSalt(auth)) {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setSalt(oldSalt);
}
}
}
});
return true;
}
@Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
return source.getAllAuthsByName(auth);
List<String> result = new ArrayList<>();
for (Map.Entry<String, PlayerAuth> stringPlayerAuthEntry : cache.entrySet()) {
PlayerAuth p = stringPlayerAuthEntry.getValue();
if (p.getIp().equals(auth.getIp()))
result.add(p.getNickname());
}
return result;
}
@Override
public synchronized List<String> getAllAuthsByIp(String ip) {
return source.getAllAuthsByIp(ip);
List<String> result = new ArrayList<>();
for (Map.Entry<String, PlayerAuth> stringPlayerAuthEntry : cache.entrySet()) {
PlayerAuth p = stringPlayerAuthEntry.getValue();
if (p.getIp().equals(ip))
result.add(p.getNickname());
}
return result;
}
@Override
public synchronized List<String> getAllAuthsByEmail(String email) {
return source.getAllAuthsByEmail(email);
List<String> result = new ArrayList<>();
for (Map.Entry<String, PlayerAuth> stringPlayerAuthEntry : cache.entrySet()) {
PlayerAuth p = stringPlayerAuthEntry.getValue();
if (p.getEmail().equals(email))
result.add(p.getNickname());
}
return result;
}
@Override
public synchronized void purgeBanned(List<String> banned) {
source.purgeBanned(banned);
for (PlayerAuth auth : cache.values()) {
if (banned.contains(auth.getNickname())) {
cache.remove(auth.getNickname());
public synchronized void purgeBanned(final List<String> banned) {
exec.execute(new Runnable() {
@Override
public void run() {
source.purgeBanned(banned);
for (PlayerAuth auth : cache.values()) {
if (banned.contains(auth.getNickname())) {
cache.remove(auth.getNickname());
}
}
}
}
});
}
@Override
@ -208,45 +321,66 @@ public class CacheDataSource implements DataSource {
@Override
public boolean isLogged(String user) {
return source.isLogged(user.toLowerCase());
user = user.toLowerCase();
return PlayerCache.getInstance().getCache().containsKey(user);
}
@Override
public void setLogged(String user) {
source.setLogged(user.toLowerCase());
public void setLogged(final String user) {
exec.execute(new Runnable() {
@Override
public void run() {
source.setLogged(user.toLowerCase());
}
});
}
@Override
public void setUnlogged(String user) {
source.setUnlogged(user.toLowerCase());
public void setUnlogged(final String user) {
exec.execute(new Runnable() {
@Override
public void run() {
source.setUnlogged(user.toLowerCase());
}
});
}
@Override
public void purgeLogged() {
source.purgeLogged();
exec.execute(new Runnable() {
@Override
public void run() {
source.purgeLogged();
}
});
}
@Override
public int getAccountsRegistered() {
return source.getAccountsRegistered();
return cache.size();
}
@Override
public void updateName(String oldone, String newone) {
public void updateName(final String oldone, final String newone) {
if (cache.containsKey(oldone)) {
cache.put(newone, cache.get(oldone));
cache.remove(oldone);
}
source.updateName(oldone, newone);
exec.execute(new Runnable() {
@Override
public void run() {
source.updateName(oldone, newone);
}
});
}
@Override
public List<PlayerAuth> getAllAuths() {
return source.getAllAuths();
return new ArrayList<>(cache.values());
}
@Override
public List<PlayerAuth> getLoggedPlayers() {
return source.getLoggedPlayers();
return new ArrayList<>(PlayerCache.getInstance().getCache().values());
}
}

View File

@ -4,7 +4,9 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class DatabaseCalls implements DataSource {
@ -214,13 +216,8 @@ public class DatabaseCalls implements DataSource {
@Override
public synchronized void close() {
try {
exec.shutdown();
exec.awaitTermination(10, TimeUnit.SECONDS);
database.close();
} catch (Exception e) {
e.printStackTrace();
}
exec.shutdown();
database.close();
}
@Override

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
*
*
* This event is call just after store inventory into cache and will empty the
* player inventory.
*
@ -18,12 +18,11 @@ public class ProtectInventoryEvent extends CustomEvent {
private ItemStack[] emptyArmor = null;
private Player player;
public ProtectInventoryEvent(Player player, ItemStack[] storedinventory,
ItemStack[] storedarmor) {
public ProtectInventoryEvent(Player player) {
super(true);
this.player = player;
this.storedinventory = storedinventory;
this.storedarmor = storedarmor;
this.storedinventory = player.getInventory().getContents();
this.storedarmor = player.getInventory().getArmorContents();
this.emptyInventory = new ItemStack[36];
this.emptyArmor = new ItemStack[4];
}

View File

@ -1,49 +1,23 @@
package fr.xephi.authme.events;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
*
* This event restore the inventory from cache
* This event restore the inventory.
*
* @author Xephi59
*/
public class RestoreInventoryEvent extends CustomEvent {
private ItemStack[] inventory;
private ItemStack[] armor;
private Player player;
public RestoreInventoryEvent(Player player, ItemStack[] inventory,
ItemStack[] armor) {
public RestoreInventoryEvent(Player player) {
this.player = player;
this.inventory = inventory;
this.armor = armor;
}
public RestoreInventoryEvent(Player player, ItemStack[] inventory,
ItemStack[] armor, boolean b) {
super(b);
public RestoreInventoryEvent(Player player, boolean async) {
super(async);
this.player = player;
this.inventory = inventory;
this.armor = armor;
}
public ItemStack[] getInventory() {
return this.inventory;
}
public void setInventory(ItemStack[] inventory) {
this.inventory = inventory;
}
public ItemStack[] getArmor() {
return this.armor;
}
public void setArmor(ItemStack[] armor) {
this.armor = armor;
}
public Player getPlayer() {
@ -53,5 +27,4 @@ public class RestoreInventoryEvent extends CustomEvent {
public void setPlayer(Player player) {
this.player = player;
}
}

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.events;
import fr.xephi.authme.cache.backup.DataFileCache;
import fr.xephi.authme.cache.backup.JsonCache;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -24,14 +23,8 @@ public class StoreInventoryEvent extends CustomEvent {
public StoreInventoryEvent(Player player, JsonCache jsonCache) {
this.player = player;
DataFileCache cache = jsonCache.readCache(player);
if (cache != null) {
this.inventory = cache.getInventory();
this.armor = cache.getArmour();
} else {
this.inventory = player.getInventory().getContents();
this.armor = player.getInventory().getArmorContents();
}
this.inventory = player.getInventory().getContents();
this.armor = player.getInventory().getArmorContents();
}
public ItemStack[] getInventory() {
@ -57,5 +50,4 @@ public class StoreInventoryEvent extends CustomEvent {
public void setPlayer(Player player) {
this.player = player;
}
}

View File

@ -1,25 +0,0 @@
package fr.xephi.authme.listener;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class AuthMeChestShopListener implements Listener {
public AuthMe plugin;
public AuthMeChestShopListener(AuthMe plugin) {
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPreTransaction(PreTransactionEvent event) {
if (Utils.checkAuth(event.getClient()))
return;
event.setCancelled(TransactionOutcome.OTHER);
}
}

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.projectiles.ProjectileSource;
public class AuthMeEntityListener implements Listener {
@ -121,13 +122,14 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST)
// TODO: Need to check this, player can't throw snowball but the item is taken.
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile projectile = event.getEntity();
if (projectile == null)
return;
Entity shooter = (Entity) projectile.getShooter();
ProjectileSource shooter = projectile.getShooter();
if (shooter == null || !(shooter instanceof Player)) {
return;
}
@ -139,7 +141,7 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onShoot(EntityShootBowEvent event) {
Entity entity = event.getEntity();
if (entity == null || !(entity instanceof Player)) {

View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 2015 AuthMe-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.xephi.authme.listener;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.settings.Settings;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class AuthMeInventoryListener extends PacketAdapter {
private static final int PLAYER_INVENTORY = 0;
//http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 inventory)
//+1 because an index starts with 0
private static final int PLAYER_CRAFTING_SIZE = 5;
private static final int HOTBAR_SIZE = 9;
public AuthMeInventoryListener(AuthMe plugin) {
super(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS);
}
@Override
public void onPacketSending(PacketEvent packetEvent) {
Player player = packetEvent.getPlayer();
PacketContainer packet = packetEvent.getPacket();
byte windowId = packet.getIntegers().read(0).byteValue();
if (windowId == PLAYER_INVENTORY && Settings.protectInventoryBeforeLogInEnabled
&& !PlayerCache.getInstance().isAuthenticated(player.getName())) {
packetEvent.setCancelled(true);
}
}
public void sendInventoryPacket(Player player) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
//we are sending our own inventory
inventoryPacket.getIntegers().write(0, PLAYER_INVENTORY);
ItemStack[] playerCrafting = new ItemStack[PLAYER_CRAFTING_SIZE];
ItemStack[] armorContents = player.getInventory().getArmorContents();
ItemStack[] mainInventory = player.getInventory().getContents();
//bukkit saves the armor in reversed order
Collections.reverse(Arrays.asList(armorContents));
//same main inventory. The hotbar is at the beginning but it should be at the end of the array
ItemStack[] hotbar = Arrays.copyOfRange(mainInventory, 0, HOTBAR_SIZE);
ItemStack[] storedInventory = Arrays.copyOfRange(mainInventory, HOTBAR_SIZE, mainInventory.length);
//concat all parts of the inventory together
int inventorySize = playerCrafting.length + armorContents.length + mainInventory.length;
ItemStack[] completeInventory = new ItemStack[inventorySize];
System.arraycopy(playerCrafting, 0, completeInventory, 0, playerCrafting.length);
System.arraycopy(armorContents, 0, completeInventory, playerCrafting.length, armorContents.length);
//storedInventory and hotbar
System.arraycopy(storedInventory, 0, completeInventory
, playerCrafting.length + armorContents.length, storedInventory.length);
System.arraycopy(hotbar, 0, completeInventory
, playerCrafting.length + armorContents.length + storedInventory.length, hotbar.length);
inventoryPacket.getItemArrayModifier().write(0, completeInventory);
try {
protocolManager.sendServerPacket(player, inventoryPacket, false);
} catch (InvocationTargetException invocationExc) {
plugin.getLogger().log(Level.WARNING, "Error during inventory recovery", invocationExc);
}
}
}

View File

@ -9,7 +9,6 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Bukkit;
@ -66,9 +65,6 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (Utils.checkAuth(event.getPlayer()))
return;
String msg = event.getMessage();
if (msg.equalsIgnoreCase("/worldedit cui"))
return;
@ -81,8 +77,10 @@ public class AuthMePlayerListener implements Listener {
if (Settings.allowCommands.contains(cmd))
return;
event.setMessage("/notloggedin");
event.setCancelled(true);
if (!Utils.checkAuth(event.getPlayer())) {
event.setMessage("/notloggedin");
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
@ -208,13 +206,12 @@ public class AuthMePlayerListener implements Listener {
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
final String name = event.getName().toLowerCase();
final Player player = Bukkit.getServer().getPlayer(name);
if (player == null)
return;
// Check if forceSingleSession is set to true, so kick player that has
// joined with same nick of online player
if (plugin.dataManager.isOnline(player, name) && Settings.isForceSingleSessionEnabled) {
if (Settings.isForceSingleSessionEnabled && plugin.dataManager.isOnline(player, name)) {
event.setKickMessage(m.send("same_nick")[0]);
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
if (LimboCache.getInstance().hasLimboPlayer(name))
@ -228,7 +225,6 @@ public class AuthMePlayerListener implements Listener {
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
}
}
});
}
}
@ -248,46 +244,34 @@ public class AuthMePlayerListener implements Listener {
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
return;
if (!Settings.countriesBlacklist.isEmpty()) {
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || (Settings.countriesBlacklist.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return;
}
}
if (Settings.enableProtection && !Settings.countries.isEmpty()) {
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || (!Settings.countries.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
if (((code == null) || !Settings.countries.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return;
}
}
if (Settings.isKickNonRegisteredEnabled && !Settings.antiBotInAction) {
if (!isAuthAvailable) {
event.setKickMessage(m.send("reg_only")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return;
}
}
if (Settings.antiBotInAction) {
if (!isAuthAvailable) {
// TODO: Add message to the messages file!!!
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
if (Settings.antiBotInAction) {
event.setKickMessage("AntiBot service in action! You actually need to be registered!");
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return;
}
}
if (isAuthAvailable && plugin.database.getType() != DataSource.DataSourceType.FILE) {
PlayerAuth auth = plugin.database.getAuth(name);
if (auth.getRealName() != null && !auth.getRealName().isEmpty() && !auth.getRealName().equalsIgnoreCase("Player") && !auth.getRealName().equals(player.getName())) {
event.setKickMessage(m.send("same_nick")[0]);
} else {
event.setKickMessage(m.send("reg_only")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
if (Settings.banUnsafeIp)
plugin.getServer().banIP(player.getAddress().getAddress().getHostAddress());
return;
}
}
@ -372,7 +356,7 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, false);
if (plugin.database.isAuthAvailable(name) && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
if (!PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
event.setQuitMessage(null);
}
@ -430,7 +414,6 @@ public class AuthMePlayerListener implements Listener {
public void run() {
player.closeInventory();
}
}, 1);
}

View File

@ -56,10 +56,6 @@ public class AuthMeServerListener implements Listener {
ConsoleLogger.info("Multiverse-Core has been disabled, unhook!");
return;
}
if (pluginName.equalsIgnoreCase("ChestShop")) {
plugin.legacyChestShop = false;
ConsoleLogger.info("ChestShop has been disabled, unhook!");
}
if (pluginName.equalsIgnoreCase("CombatTagPlus")) {
plugin.combatTagPlus = null;
ConsoleLogger.info("CombatTagPlus has been disabled, unhook!");
@ -68,6 +64,10 @@ public class AuthMeServerListener implements Listener {
plugin.permission = null;
ConsoleLogger.showError("Vault has been disabled, unhook permissions!");
}
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
plugin.inventoryProtector = null;
ConsoleLogger.showError("ProtocolLib has been disabled, unhook packet inventory protection!");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -77,11 +77,12 @@ public class AuthMeServerListener implements Listener {
plugin.checkEssentials();
if (pluginName.equalsIgnoreCase("Multiverse-Core"))
plugin.checkMultiverse();
if (pluginName.equalsIgnoreCase("ChestShop"))
plugin.checkChestShop();
if (pluginName.equalsIgnoreCase("CombatTagPlus"))
plugin.checkCombatTagPlus();
if (pluginName.equalsIgnoreCase("Vault"))
plugin.checkVault();
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
plugin.checkProtocolLib();
}
}
}

View File

@ -32,9 +32,7 @@ public class EssSpawn extends CustomConfiguration {
return null;
Location location = new Location(Bukkit.getWorld(this.getString("spawns.default.world")), this.getDouble("spawns.default.x"), this.getDouble("spawns.default.y"), this.getDouble("spawns.default.z"), Float.parseFloat(this.getString("spawns.default.yaw")), Float.parseFloat(this.getString("spawns.default.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
} catch (NullPointerException | NumberFormatException npe) {
return null;
}
}

View File

@ -1,315 +1,296 @@
package fr.xephi.authme.process.join;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.GroupType;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.DataFileCache;
import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
public class AsyncronousJoin {
protected Player player;
protected DataSource database;
protected AuthMe plugin;
protected String name;
private Messages m = Messages.getInstance();
private JsonCache playerBackup;
public AsyncronousJoin(Player player, AuthMe plugin, DataSource database) {
this.player = player;
this.plugin = plugin;
this.database = database;
this.playerBackup = new JsonCache(plugin);
this.name = player.getName().toLowerCase();
}
public void process() {
if (AuthMePlayerListener.gameMode.containsKey(name))
AuthMePlayerListener.gameMode.remove(name);
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
BukkitScheduler sched = plugin.getServer().getScheduler();
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
return;
}
if (plugin.ess != null && Settings.disableSocialSpy) {
plugin.ess.getUser(player).setSocialSpyEnabled(false);
}
final String ip = plugin.getIP(player);
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
player.setGameMode(gM);
player.kickPlayer("You are not the Owner of this account, please try another name!");
if (Settings.banUnsafeIp)
plugin.getServer().banIP(ip);
}
});
return;
}
if (Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
if (plugin.hasJoinedIp(player.getName(), ip)) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.kickPlayer("A player with the same IP is already in game!");
}
});
return;
}
}
final Location spawnLoc = plugin.getSpawnLocation(player);
final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
player.teleport(tpEvent.getTo());
}
}
}
});
}
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
playerBackup.createCache(player, dataFile);
// protect inventory
if (Settings.protectInventoryBeforeLogInEnabled) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
if (!Settings.noConsoleSpam)
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
} else {
final ItemStack[] inv = ev.getEmptyArmor();
final ItemStack[] armor = ev.getEmptyArmor();
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
plugin.api.setPlayerInventory(player, inv, armor);
}
});
}
}
} else {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.unRegisteredGroup.isEmpty()) {
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
}
if (!Settings.isForcedRegistrationEnabled) {
return;
}
if (!Settings.noTeleport)
if (!needFirstspawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
player.teleport(tpEvent.getTo());
}
}
}
});
}
}
String[] msg;
if (Settings.emailRegistration) {
msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_email_msg");
} else {
msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_msg");
}
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
if (isAuthAvailable) {
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
} else {
Utils.setGroup(player, GroupType.UNREGISTERED);
}
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (player.isOp())
player.setOp(false);
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
if (Settings.useEssentialsMotd)
player.performCommand("motd");
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
player.setWalkSpeed(0.0f);
player.setFlySpeed(0.0f);
}
}
});
if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
if (plugin.sessions.containsKey(name))
plugin.sessions.get(name).cancel();
plugin.sessions.remove(name);
PlayerAuth auth = database.getAuth(name);
if (auth != null && auth.getIp().equals(ip)) {
m.send(player, "valid_session");
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
plugin.management.performLogin(player, "dontneed", true);
} else if (Settings.sessionExpireOnIpChange) {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
m.send(player, "invalid_session");
}
return;
}
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
}
private boolean needFirstspawn() {
if (player.hasPlayedBefore())
return false;
if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null)
return false;
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), Spawn.getInstance().getFirstSpawn());
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
final Location fLoc = tpEvent.getTo();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(fLoc);
}
});
}
}
return true;
}
private void placePlayerSafely(final Player player,
final Location spawnLoc) {
Location loc = null;
if (spawnLoc == null)
return;
if (!Settings.noTeleport)
return;
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
return;
if (!player.hasPlayedBefore())
return;
Block b = player.getLocation().getBlock();
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null)
loc = spawnLoc;
} else {
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null)
loc = spawnLoc;
}
}
if (loc != null) {
final Location floc = loc;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(floc);
}
});
}
}
}
package fr.xephi.authme.process.join;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.GroupType;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
public class AsyncronousJoin {
protected Player player;
protected DataSource database;
protected AuthMe plugin;
protected String name;
private Messages m = Messages.getInstance();
public AsyncronousJoin(Player player, AuthMe plugin, DataSource database) {
this.player = player;
this.plugin = plugin;
this.database = database;
this.name = player.getName().toLowerCase();
}
public void process() {
if (AuthMePlayerListener.gameMode.containsKey(name))
AuthMePlayerListener.gameMode.remove(name);
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
BukkitScheduler sched = plugin.getServer().getScheduler();
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
return;
}
if (plugin.ess != null && Settings.disableSocialSpy) {
plugin.ess.getUser(player).setSocialSpyEnabled(false);
}
final String ip = plugin.getIP(player);
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
player.setGameMode(gM);
player.kickPlayer("You are not the Owner of this account, please try another name!");
if (Settings.banUnsafeIp)
plugin.getServer().banIP(ip);
}
});
return;
}
if (Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
if (plugin.hasJoinedIp(player.getName(), ip)) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.kickPlayer("A player with the same IP is already in game!");
}
});
return;
}
}
final Location spawnLoc = plugin.getSpawnLocation(player);
final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
player.teleport(tpEvent.getTo());
}
}
}
});
}
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
// protect inventory
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
plugin.inventoryProtector.sendInventoryPacket(player);
if (!Settings.noConsoleSpam)
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
}
}
} else {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.unRegisteredGroup.isEmpty()) {
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
}
if (!Settings.isForcedRegistrationEnabled) {
return;
}
if (!Settings.noTeleport)
if (!needFirstspawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null)
player.teleport(tpEvent.getTo());
}
}
}
});
}
}
String[] msg;
if (Settings.emailRegistration) {
msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_email_msg");
} else {
msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_msg");
}
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
if (isAuthAvailable) {
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
} else {
Utils.setGroup(player, GroupType.UNREGISTERED);
}
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (player.isOp())
player.setOp(false);
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
if (Settings.useEssentialsMotd)
player.performCommand("motd");
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
player.setWalkSpeed(0.0f);
player.setFlySpeed(0.0f);
}
}
});
if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
if (plugin.sessions.containsKey(name))
plugin.sessions.get(name).cancel();
plugin.sessions.remove(name);
PlayerAuth auth = database.getAuth(name);
if (auth != null && auth.getIp().equals(ip)) {
m.send(player, "valid_session");
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
plugin.management.performLogin(player, "dontneed", true);
} else if (Settings.sessionExpireOnIpChange) {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
m.send(player, "invalid_session");
}
return;
}
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
}
private boolean needFirstspawn() {
if (player.hasPlayedBefore())
return false;
if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null)
return false;
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), Spawn.getInstance().getFirstSpawn());
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
final Location fLoc = tpEvent.getTo();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(fLoc);
}
});
}
}
return true;
}
private void placePlayerSafely(final Player player,
final Location spawnLoc) {
Location loc = null;
if (spawnLoc == null)
return;
if (!Settings.noTeleport)
return;
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
return;
if (!player.hasPlayedBefore())
return;
Block b = player.getLocation().getBlock();
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null)
loc = spawnLoc;
} else {
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null)
loc = spawnLoc;
}
}
if (loc != null) {
final Location floc = loc;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(floc);
}
});
}
}
}

View File

@ -42,7 +42,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
this.name = player.getName().toLowerCase();
this.limbo = LimboCache.getInstance().getLimboPlayer(name);
this.auth = database.getAuth(name);
this.playerCache = new JsonCache(plugin);
this.playerCache = new JsonCache();
}
public LimboPlayer getLimbo() {
@ -92,10 +92,10 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
protected void restoreInventory() {
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
plugin.api.setPlayerInventory(player, event.getInventory(), event.getArmor());
plugin.inventoryProtector.sendInventoryPacket(player);
}
}
@ -128,7 +128,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// Inventory - Make it after restore GameMode , cause we need to
// restore the
// right inventory in the right gamemode
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
restoreInventory();
}
if (Settings.forceOnlyAfterLogin) {

View File

@ -1,91 +1,81 @@
package fr.xephi.authme.process.logout;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.GroupType;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.DataFileCache;
import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
public class AsyncronousLogout {
protected Player player;
protected String name;
protected AuthMe plugin;
protected DataSource database;
protected boolean canLogout = true;
private Messages m = Messages.getInstance();
private JsonCache playerBackup;
public AsyncronousLogout(Player player, AuthMe plugin,
DataSource database) {
this.player = player;
this.plugin = plugin;
this.database = database;
this.name = player.getName().toLowerCase();
this.playerBackup = new JsonCache(plugin);
}
private void preLogout() {
if (!PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "not_logged_in");
canLogout = false;
}
}
public void process() {
preLogout();
if (!canLogout)
return;
final Player p = player;
BukkitScheduler sched = p.getServer().getScheduler();
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
database.updateSession(auth);
auth.setQuitLocX(p.getLocation().getX());
auth.setQuitLocY(p.getLocation().getY());
auth.setQuitLocZ(p.getLocation().getZ());
auth.setWorld(p.getWorld().getName());
database.updateQuitLoc(auth);
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(p);
final AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(p, spawnLoc);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (tpEvent.getTo() != null)
p.teleport(tpEvent.getTo());
}
}
});
}
if (LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().deleteLimboPlayer(name);
LimboCache.getInstance().addLimboPlayer(player);
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
if (Settings.protectInventoryBeforeLogInEnabled) {
player.getInventory().clear();
// create cache file for handling lost of inventories on unlogged in
// status
DataFileCache playerData = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
playerBackup.createCache(player, playerData);
}
sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
}
}
package fr.xephi.authme.process.logout;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.GroupType;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
public class AsyncronousLogout {
protected Player player;
protected String name;
protected AuthMe plugin;
protected DataSource database;
protected boolean canLogout = true;
private Messages m = Messages.getInstance();
public AsyncronousLogout(Player player, AuthMe plugin,
DataSource database) {
this.player = player;
this.plugin = plugin;
this.database = database;
this.name = player.getName().toLowerCase();
}
private void preLogout() {
if (!PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "not_logged_in");
canLogout = false;
}
}
public void process() {
preLogout();
if (!canLogout)
return;
final Player p = player;
BukkitScheduler sched = p.getServer().getScheduler();
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
database.updateSession(auth);
auth.setQuitLocX(p.getLocation().getX());
auth.setQuitLocY(p.getLocation().getY());
auth.setQuitLocZ(p.getLocation().getZ());
auth.setWorld(p.getWorld().getName());
database.updateQuitLoc(auth);
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(p);
final AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(p, spawnLoc);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (tpEvent.getTo() != null)
p.teleport(tpEvent.getTo());
}
}
});
}
if (LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().deleteLimboPlayer(name);
LimboCache.getInstance().addLimboPlayer(player);
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
}
}

View File

@ -1,110 +1,93 @@
package fr.xephi.authme.process.quit;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings;
public class AsyncronousQuit {
protected AuthMe plugin;
protected DataSource database;
protected Player player;
private String name;
private ItemStack[] armor = null;
private ItemStack[] inv = null;
private boolean isOp = false;
private boolean isFlying = false;
private boolean needToChange = false;
private boolean isKick = false;
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database,
boolean isKick) {
this.player = p;
this.plugin = plugin;
this.database = database;
this.name = p.getName().toLowerCase();
this.isKick = isKick;
}
public void process() {
if (player == null)
return;
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
return;
}
String ip = plugin.getIP(player);
if (PlayerCache.getInstance().isAuthenticated(name)) {
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
Location loc = player.getLocation();
PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
database.updateQuitLoc(auth);
}
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
database.updateSession(auth);
}
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
inv = limbo.getInventory();
armor = limbo.getArmour();
}
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
Utils.addNormal(player, limbo.getGroup());
needToChange = true;
isOp = limbo.getOperator();
isFlying = limbo.isFlying();
if (limbo.getTimeoutTaskId() != null)
limbo.getTimeoutTaskId().cancel();
if (limbo.getMessageTaskId() != null)
limbo.getMessageTaskId().cancel();
LimboCache.getInstance().deleteLimboPlayer(name);
}
if (Settings.isSessionsEnabled && !isKick) {
if (Settings.getSessionTimeout != 0) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
PlayerCache.getInstance().removePlayer(name);
if (database.isLogged(name))
database.setUnlogged(name);
plugin.sessions.remove(name);
}
}, Settings.getSessionTimeout * 20 * 60);
plugin.sessions.put(name, task);
}
} else {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
}
AuthMePlayerListener.gameMode.remove(name);
final Player p = player;
RestoreInventoryEvent ev = new RestoreInventoryEvent(player, inv, armor, true);
Bukkit.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
inv = null;
armor = null;
} else {
inv = ev.getInventory();
armor = ev.getArmor();
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, p, inv, armor, isOp, isFlying, needToChange));
}
}
package fr.xephi.authme.process.quit;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings;
public class AsyncronousQuit {
protected AuthMe plugin;
protected DataSource database;
protected Player player;
private String name;
private boolean isOp = false;
private boolean isFlying = false;
private boolean needToChange = false;
private boolean isKick = false;
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database,
boolean isKick) {
this.player = p;
this.plugin = plugin;
this.database = database;
this.name = p.getName().toLowerCase();
this.isKick = isKick;
}
public void process() {
if (player == null)
return;
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
return;
}
String ip = plugin.getIP(player);
if (PlayerCache.getInstance().isAuthenticated(name)) {
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
Location loc = player.getLocation();
PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
database.updateQuitLoc(auth);
}
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
database.updateSession(auth);
}
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
Utils.addNormal(player, limbo.getGroup());
needToChange = true;
isOp = limbo.getOperator();
isFlying = limbo.isFlying();
if (limbo.getTimeoutTaskId() != null)
limbo.getTimeoutTaskId().cancel();
if (limbo.getMessageTaskId() != null)
limbo.getMessageTaskId().cancel();
LimboCache.getInstance().deleteLimboPlayer(name);
}
if (Settings.isSessionsEnabled && !isKick) {
if (Settings.getSessionTimeout != 0) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
PlayerCache.getInstance().removePlayer(name);
if (database.isLogged(name))
database.setUnlogged(name);
plugin.sessions.remove(name);
}
}, Settings.getSessionTimeout * 20 * 60);
plugin.sessions.put(name, task);
}
} else {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
}
AuthMePlayerListener.gameMode.remove(name);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
}
}

View File

@ -1,48 +1,42 @@
package fr.xephi.authme.process.quit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.settings.Settings;
public class ProcessSyncronousPlayerQuit implements Runnable {
protected AuthMe plugin;
protected Player player;
protected boolean isOp;
protected boolean isFlying;
protected ItemStack[] inv;
protected ItemStack[] armor;
protected boolean needToChange;
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player,
ItemStack[] inv, ItemStack[] armor, boolean isOp, boolean isFlying,
boolean needToChange) {
this.plugin = plugin;
this.player = player;
this.isOp = isOp;
this.isFlying = isFlying;
this.armor = armor;
this.inv = inv;
this.needToChange = needToChange;
}
@Override
public void run() {
if (inv != null && armor != null)
plugin.api.setPlayerInventory(player, inv, armor);
if (needToChange) {
player.setOp(isOp);
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(isFlying);
player.setFlying(isFlying);
}
}
try {
player.getVehicle().eject();
} catch (Exception e) {
}
}
}
package fr.xephi.authme.process.quit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.settings.Settings;
public class ProcessSyncronousPlayerQuit implements Runnable {
protected AuthMe plugin;
protected Player player;
protected boolean isOp;
protected boolean isFlying;
protected boolean needToChange;
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
, boolean isOp, boolean isFlying
, boolean needToChange) {
this.plugin = plugin;
this.player = player;
this.isOp = isOp;
this.isFlying = isFlying;
this.needToChange = needToChange;
}
@Override
public void run() {
if (needToChange) {
player.setOp(isOp);
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(isFlying);
player.setFlying(isFlying);
}
}
try {
player.getVehicle().eject();
} catch (Exception e) {
}
}
}

View File

@ -67,14 +67,10 @@ public class AsyncronousRegister {
allowRegister = false;
}
else if (!Settings.unsafePasswords.isEmpty()) {
if (Settings.unsafePasswords.contains(password.toLowerCase())) {
m.send(player, "password_error_unsafe");
allowRegister = false;
}
}
else if (database.isAuthAvailable(name)) {
else if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(password.toLowerCase())) {
m.send(player, "password_error_unsafe");
allowRegister = false;
} else if (database.isAuthAvailable(name)) {
m.send(player, "user_regged");
allowRegister = false;
}

View File

@ -91,14 +91,15 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.teleport(tpEvent.getTo());
}
}
if (Settings.protectInventoryBeforeLogInEnabled && limbo.getInventory() != null && limbo.getArmour() != null) {
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getArmor() != null && event.getInventory() != null) {
player.getInventory().setContents(event.getInventory());
player.getInventory().setArmorContents(event.getArmor());
if (!event.isCancelled()) {
plugin.inventoryProtector.sendInventoryPacket(player);
}
}
limbo.getTimeoutTaskId().cancel();
limbo.getMessageTaskId().cancel();
LimboCache.getInstance().deleteLimboPlayer(name);
@ -153,6 +154,5 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
// Register is now finish , we can force all commands
forceCommands();
}
}

View File

@ -33,10 +33,10 @@ public class PHPFUSION implements EncryptionMethod {
hash.append(hex);
}
digest = hash.toString();
} catch (UnsupportedEncodingException e) {
} catch (InvalidKeyException e) {
} catch (NoSuchAlgorithmException e) {
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
//ingore
}
return digest;
}

View File

@ -44,7 +44,7 @@ public class XF implements EncryptionMethod {
}
public String regmatch(String pattern, String line) {
List<String> allMatches = new ArrayList<String>();
List<String> allMatches = new ArrayList<>();
Matcher m = Pattern.compile(pattern).matcher(line);
while (m.find()) {
allMatches.add(m.group(1));

View File

@ -9,7 +9,7 @@ import javax.crypto.spec.SecretKeySpec;
/**
* Default PRF implementation based on standard javax.crypt.Mac mechanisms.
*
*
* <hr />
* <p>
* A free Java implementation of Password Based Key Derivation Function 2 as
@ -37,7 +37,7 @@ import javax.crypto.spec.SecretKeySpec;
* href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html"
* >http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</a>.
* </p>
*
*
* @author Matthias G&auml;rtner
* @version 1.0
*/
@ -51,7 +51,7 @@ public class MacBasedPRF implements PRF {
/**
* Create Mac-based Pseudo Random Function.
*
*
* @param macAlgorithm
* Mac algorithm to use, i.e. HMacSHA1 or HMacMD5.
*/
@ -70,9 +70,7 @@ public class MacBasedPRF implements PRF {
try {
mac = Mac.getInstance(macAlgorithm, provider);
hLen = mac.getMacLength();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (NoSuchProviderException e) {
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
throw new RuntimeException(e);
}
}

View File

@ -44,8 +44,8 @@ public class OtherAccounts extends CustomConfiguration {
this.getStringList(uuid.toString()).add(player.getName());
save();
}
} catch (NoSuchMethodError e) {
} catch (Exception e) {
} catch (NoSuchMethodError | Exception e) {
//ingore
}
}
@ -58,10 +58,9 @@ public class OtherAccounts extends CustomConfiguration {
this.getStringList(uuid.toString()).remove(player.getName());
save();
}
} catch (NoSuchMethodError e) {
} catch (Exception e) {
} catch (NoSuchMethodError | Exception e) {
//ignore
}
}
public List<String> getAllPlayersByUUID(UUID uuid) {

View File

@ -14,10 +14,11 @@ import java.util.List;
public final class Settings extends YamlConfiguration {
private AuthMe plugin;
private static AuthMe plugin;
private static Settings instance;
// This is not an option!
public static Boolean antiBotInAction = false;
public static boolean antiBotInAction = false;
public static final File PLUGIN_FOLDER = AuthMe.getInstance().getDataFolder();
public static final File MODULE_FOLDER = new File(PLUGIN_FOLDER, "modules");
@ -59,7 +60,7 @@ public final class Settings extends YamlConfiguration {
protectInventoryBeforeLogInEnabled, isBackupActivated,
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
useCaptcha, emailRegistration, multiverse, legacyChestShop, bungee,
useCaptcha, emailRegistration, multiverse, bungee,
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge,
purgePlayerDat, purgeEssentialsFile, supportOldPassword,
@ -94,30 +95,30 @@ public final class Settings extends YamlConfiguration {
protected static YamlConfiguration configFile;
public Settings(AuthMe plugin) {
public Settings(AuthMe pl) {
instance = this;
plugin = pl;
configFile = (YamlConfiguration) plugin.getConfig();
this.plugin = plugin;
}
public final void reload() throws Exception {
public static void reload() throws Exception {
plugin.getLogger().info("Loading Configuration File...");
boolean exist = SETTINGS_FILE.exists();
if (!exist) {
plugin.saveDefaultConfig();
}
load(SETTINGS_FILE);
instance.load(SETTINGS_FILE);
if (exist) {
mergeConfig();
instance.mergeConfig();
}
loadVariables();
if (exist) {
saveDefaults();
instance.saveDefaults();
}
messageFile = new File(PLUGIN_FOLDER, "messages" + File.separator + "messages_" + messagesLanguage + ".yml");
}
@SuppressWarnings("unchecked")
public static void loadVariables() {
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en").toLowerCase());
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
@ -183,7 +184,7 @@ public final class Settings extends YamlConfiguration {
backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
allowCommands = (List<String>) configFile.getList("settings.restrictions.allowCommands");
allowCommands = configFile.getStringList("settings.restrictions.allowCommands");
if (configFile.contains("allowCommands")) {
if (!allowCommands.contains("/login"))
allowCommands.add("/login");
@ -208,7 +209,7 @@ public final class Settings extends YamlConfiguration {
getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
getMailPort = configFile.getInt("Email.mailPort", 465);
getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
getMySQLOtherUsernameColumn = (List<String>) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>());
getMySQLOtherUsernameColumn = configFile.getStringList("ExternalBoardOptions.mySQLOtherUsernameColumns");
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
getmailSenderName = configFile.getString("Email.mailSenderName", "");
@ -221,7 +222,6 @@ public final class Settings extends YamlConfiguration {
saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
multiverse = configFile.getBoolean("Hooks.multiverse", true);
legacyChestShop = configFile.getBoolean("Hooks.legacyChestshop", false);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
getForcedWorlds = configFile.getStringList("settings.restrictions.ForceSpawnOnTheseWorlds");
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
@ -272,7 +272,7 @@ public final class Settings extends YamlConfiguration {
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true);
@ -287,7 +287,8 @@ public final class Settings extends YamlConfiguration {
set("Xenoforo.predefinedSalt", null);
changes = true;
}
if (configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA256")) {
if (configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA1") ||
configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA256")) {
set("settings.security.passwordHash", "XENFORO");
changes = true;
}
@ -460,12 +461,13 @@ public final class Settings extends YamlConfiguration {
changes = true;
}
if (contains("Hooks.chestshop")) {
if(getBoolean("Hooks.chestshop")) {
set("Hooks.legacyChestshop", true);
}
set("Hooks.chestshop", null);
changes = true;
}
if (contains("Hooks.legacyChestshop")) {
set("Hooks.legacyChestshop", null);
changes = true;
}
if (!contains("Email.generateImage")) {
set("Email.generateImage", true);
changes = true;
@ -481,9 +483,9 @@ public final class Settings extends YamlConfiguration {
}
}
public void setValue(String key, Object value) {
this.set(key, value);
this.save();
public static void setValue(String key, Object value) {
instance.set(key, value);
save();
}
private static HashAlgorithm getPasswordHash() {
@ -511,11 +513,11 @@ public final class Settings extends YamlConfiguration {
* return false if ip and name doesnt amtch with player that join the
* server, so player has a restricted access
*/
public static Boolean getRestrictedIp(String name, String ip) {
public static boolean getRestrictedIp(String name, String ip) {
Iterator<String> iter = getRestrictedIp.iterator();
Boolean trueonce = false;
Boolean namefound = false;
boolean trueonce = false;
boolean namefound = false;
while (iter.hasNext()) {
String[] args = iter.next().split(";");
String testname = args[0];
@ -527,11 +529,7 @@ public final class Settings extends YamlConfiguration {
}
}
}
if (!namefound) {
return true;
} else {
return trueonce;
}
return !namefound || trueonce;
}
/**
@ -539,9 +537,9 @@ public final class Settings extends YamlConfiguration {
*
* @return True if saved successfully
*/
public final boolean save() {
public static boolean save() {
try {
save(SETTINGS_FILE);
instance.save(SETTINGS_FILE);
return true;
} catch (Exception ex) {
return false;

View File

@ -90,9 +90,7 @@ public class Spawn extends CustomConfiguration {
return null;
Location location = new Location(Bukkit.getWorld(this.getString("spawn.world")), this.getDouble("spawn.x"), this.getDouble("spawn.y"), this.getDouble("spawn.z"), Float.parseFloat(this.getString("spawn.yaw")), Float.parseFloat(this.getString("spawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
} catch (NullPointerException | NumberFormatException npe) {
return null;
}
}
@ -103,9 +101,7 @@ public class Spawn extends CustomConfiguration {
return null;
Location location = new Location(Bukkit.getWorld(this.getString("firstspawn.world")), this.getDouble("firstspawn.x"), this.getDouble("firstspawn.y"), this.getDouble("firstspawn.z"), Float.parseFloat(this.getString("firstspawn.yaw")), Float.parseFloat(this.getString("firstspawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
} catch (NullPointerException | NumberFormatException npe) {
return null;
}
}

View File

@ -15,12 +15,14 @@ public class ChangePasswordTask implements Runnable {
private final AuthMe plugin;
private final Player player;
private String password;
private final String oldPassword;
private final String newPassword;
public ChangePasswordTask(AuthMe plugin, Player player, String password) {
public ChangePasswordTask(AuthMe plugin, Player player, String oldPassword, String newPassword) {
this.plugin = plugin;
this.player = player;
this.password = password;
this.oldPassword = oldPassword;
this.newPassword = newPassword;
}
@Override
@ -28,13 +30,15 @@ public class ChangePasswordTask implements Runnable {
Messages m = Messages.getInstance();
try {
String name = player.getName().toLowerCase();
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (PasswordSecurity.comparePasswordWithHash(password, PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
auth.setHash(hashnew);
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) {
auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt("");
} else {
auth.setSalt("");
}
if (!plugin.database.updatePassword(auth)) {
m.send(player, "error");
return;

View File

@ -353,8 +353,6 @@ Email:
Hooks:
# Do we need to hook with multiverse for spawn checking?
multiverse: true
# Do we need to hook with legacy ChestShop < 3.8.13 for prevent buy or selling ?
legacyChestshop: false
# Do we need to hook with BungeeCord for get the real Player ip ?
bungeecord: false
# Do we need to disable Essentials SocialSpy on join ?

View File

@ -1,47 +1,48 @@
# Translator: uSoc_lifehome (http://lifeho.me) #
# Translator: lifehome<m@lifeho.me> #
# Last modif: 1443428389 UTC #
# -------------------------------------------- #
unknown_user: '&8[&6用戶系統&8] &f用戶資料並不存在於資料庫中。'
unknown_user: '&8[&6用戶系統&8] &f用戶資料並不存在。'
unsafe_spawn: '&8[&6用戶系統&8] &f你的登出位置不安全現在將傳送你到重生點。'
not_logged_in: '&8[&6用戶系統&8] &c你還沒有登入 '
reg_voluntarily: '&8[&6用戶系統&8] &f你可以使用這個指令來註冊: 《 /register <密碼> <重覆密碼> 》'
usage_log: '&8[&6用戶系統&8] &c用法: 《 /login <密碼> 》'
reg_voluntarily: '&8[&6用戶系統&8] &f你可以使用這個指令來註冊: 《 /register <密碼> <重覆密碼> 》'
usage_log: '&8[&6用戶系統&8] &f用法: 《 /login <密碼> 》'
wrong_pwd: '&8[&6用戶系統&8] &c你輸入了錯誤的密碼。'
unregistered: '&8[&6用戶系統&8] &c你已成功取消會員註冊記錄。'
unregistered: '&8[&6用戶系統&8] &c你已成功刪除會員註冊記錄。'
reg_disabled: '&8[&6用戶系統&8] &c本伺服器已停止新玩家註冊。'
valid_session: '&8[&6用戶系統&8] &b嗨 我記得你,歡迎回來~'
login: '&8[&6用戶系統&8] &c你成功登入了。'
password_error_nick: '&fYou can''t use your name as password'
password_error_unsafe: '&fYou can''t use unsafe passwords'
valid_session: '&8[&6用戶系統&8] &b嗨 歡迎回來'
login: '&8[&6用戶系統&8] &c你成功登入了。'
password_error_nick: '&8[&6用戶系統&8] &c這個密碼太不安全了'
password_error_unsafe: '&8[&6用戶系統&8] &c這個密碼太不安全了'
vb_nonActiv: '&8[&6用戶系統&8] &f你的帳戶還沒有經過電郵驗證 '
user_regged: '&8[&6用戶系統&8] &c此用戶名已經註冊過了。'
usage_reg: '&8[&6用戶系統&8] &c用法: 《 /register <密碼> <重覆密碼> 》'
usage_reg: '&8[&6用戶系統&8] &f用法: 《 /register <密碼> <重覆密碼> 》'
max_reg: '&8[&6用戶系統&8] &f你的IP地址已達到註冊數上限。'
no_perm: '&8[&6用戶系統&8] &b你可以到 CraftingHK 玩家百科中查看說明文件。'
error: '&8[&6用戶系統&8] &f發生錯誤請與管理員聯絡。'
login_msg: '&8[&6用戶系統&8] &c請使用這個指令來登入 《 /login <密碼> 》'
reg_msg: '&8[&6用戶系統&8] &c請使用這個指令來註冊: 《 /register <密碼> <重覆密碼> 》'
reg_email_msg: '&8[&6用戶系統&8] &c請使用這個指令來註冊: 《 /register <電郵> <重覆電郵> 》'
usage_unreg: '&8[&6用戶系統&8] &c用法: 《 /unregister <密碼> 》'
pwd_changed: '&8[&6用戶系統&8] &c你成功更換了你的密碼 '
reg_msg: '&8[&6用戶系統&8] &c請使用這個指令來註冊: 《 /register <密碼> <重覆密碼> 》'
reg_email_msg: '&8[&6用戶系統&8] &c請使用這個指令來註冊: 《 /register <電郵> <重覆電郵> 》'
usage_unreg: '&8[&6用戶系統&8] &f用法: 《 /unregister <密碼> 》'
pwd_changed: '&8[&6用戶系統&8] &c你成功更換了你的密碼 '
user_unknown: '&8[&6用戶系統&8] &c此用戶名沒有已登記資料。'
password_error: '&8[&6用戶系統&8] &f密碼不符合。'
invalid_session: '&8[&6用戶系統&8] &f登入階段資料已損壞請等待登入階段結束。'
reg_only: '&8[&6用戶系統&8] &f限已註冊會員請先到 https://www.example.com/ 註冊。'
reg_only: '&8[&6用戶系統&8] &f限已註冊會員請先到 https://crafting.hk/ 註冊。'
logged_in: '&8[&6用戶系統&8] &c你已經登入過了。'
logout: '&8[&6用戶系統&8] &b你成功登出了。'
logout: '&8[&6用戶系統&8] &b你成功登出了。'
same_nick: '&8[&6用戶系統&8] &f同名玩家已在遊玩。'
registered: '&8[&6用戶系統&8] &b你成功註冊了。'
registered: '&8[&6用戶系統&8] &b你成功註冊了。'
pass_len: '&8[&6用戶系統&8] &f你的密碼並不符合規定長度。'
reload: '&8[&6用戶系統&8] &b登入系統設定及資料庫重新載入完畢。'
timeout: '&8[&6用戶系統&8] &f登入逾時。'
usage_changepassword: '&8[&6用戶系統&8] &f用法 《 /changepassword <舊密碼> <新密碼> 》'
name_len: '&8[&6用戶系統&8] &c你的用戶名不符合規定長度。'
regex: '&8[&6用戶系統&8] &c你的用戶名含有不容許之字符。以下為准許之字母 REG_EX'
regex: '&8[&6用戶系統&8] &c用戶名稱錯誤! 登入系統只接受以下字符 REG_EX'
add_email: '&8[&6用戶系統&8] &b請為你的帳戶立即添加電郵地址 《 /email add <電郵地址> <重覆電郵地址> 》'
recovery_email: '&8[&6用戶系統&8] &c忘記密碼 請使用這個指令來更新密碼: 《 /email recovery <電郵地址> 》'
usage_captcha: '&8[&6用戶系統&8] &c用法: 《 /captcha <驗證碼> 》'
wrong_captcha: '&8[&6用戶系統&8] &c你輸入了錯誤的驗證碼,請使用 《 /captcha <驗證碼> 》 再次輸入。'
valid_captcha: '&8[&6用戶系統&8] &c你所輸入的驗證碼無效 '
recovery_email: '&8[&6用戶系統&8] &c忘記密碼 請使用這個指令來更新密碼: 《 /email recovery <電郵地址> 》'
usage_captcha: '&8[&6用戶系統&8] &f用法: 《 /captcha <驗證碼> 》'
wrong_captcha: '&8[&6用戶系統&8] &c你輸入的驗證碼無效,請使用 《 /captcha <驗證碼> 》 再次輸入。'
valid_captcha: '&8[&6用戶系統&8] &c你所輸入的驗證碼無效 '
kick_forvip: '&c因為有VIP玩家登入了伺服器。'
kick_fullserver: '&c抱歉 因為伺服器滿人了,所以你目前未能登入伺服器。'
usage_email_add: '&8[&6用戶系統&8] &f用法 《 /email add <電郵> <重覆電郵> 》'
@ -50,10 +51,10 @@ usage_email_recovery: '&8[&6用戶系統&8] &f用法 《 /email recovery <電
new_email_invalid: '&8[&6用戶系統&8] 你所填寫的新電郵地址並不正確。'
old_email_invalid: '&8[&6用戶系統&8] 你所填寫的舊電郵地址並不正確。'
email_invalid: '&8[&6用戶系統&8] 你所填寫的電郵地址並不正確。'
email_added: '&8[&6用戶系統&8] 已加入你的電郵地址記錄。'
email_added: '&8[&6用戶系統&8] 已新增你的電郵地址。'
email_confirm: '&8[&6用戶系統&8] 請重覆輸入你的電郵地址。'
email_changed: '&8[&6用戶系統&8] 你的電郵地址記錄已更改。'
email_changed: '&8[&6用戶系統&8] 你的電郵地址已更改。'
email_send: '&8[&6用戶系統&8] 忘記密碼信件已寄出,請查收。'
country_banned: '&8[&6用戶系統&8] 本伺服器已停止對你的國家提供遊戲服務。'
antibot_auto_enabled: '&8[&6用戶系統&8] 防止機械人程序已因應現時大量不尋常連線而啟用。'
antibot_auto_disabled: '&8[&6用戶系統&8] 防止機械人程序檢查到不正常連接數已減少,並於 %m 分鐘後停止運作。'
antibot_auto_enabled: '&8[&6用戶系統&8] 防止機械人程序已因應現時大量不尋常連線而啟用。'
antibot_auto_disabled: '&8[&6用戶系統&8] 不正常連接數已減少,防止機械人程序將於 %m 分鐘後停止。'

View File

@ -4,7 +4,7 @@ website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the player.
main: fr.xephi.authme.AuthMe
version: ${project.version}
softdepend: [Vault, ChestShop, Multiverse-Core, Citizens, CombatTag, Essentials, EssentialsSpawn, PerWorldInventories]
softdepend: [Vault, ChestShop, Multiverse-Core, Citizens, CombatTag, Essentials, EssentialsSpawn, PerWorldInventories, ProtocolLib]
commands:
register:
description: Register an account
@ -22,7 +22,7 @@ commands:
usage: /logout
unregister:
description: unregister your account
usage: /unregister password
usage: /unregister password
authme:
description: AuthMe op commands
usage: '/authme reload|register playername password|changepassword playername password|unregister playername|version'

View File

@ -1,9 +1,12 @@
AuthMe-Team:
Active staff:
Xephi (Xephi59) - Leader, Main developer
Gabriele C. (sgdc3) - Ticket Manager, Project Page and Structure Manager, Contributor
Xephi (Xephi59) - Leader, Main developer (temporary inactive)
DNx5 - Developer
games647 - Developer
Gabriele C. (sgdc3) - Project Manager, Contributor
Staff to contact:
CryLegend - Contributor, AuthMeBridge Developer (Need activation)
External Contributors: