diff --git a/docs/commands.md b/docs/commands.md index 163399c0e..41851ac04 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1,5 +1,5 @@ - + ## AuthMe Commands You can use the following commands to use the features of AuthMe. Mandatory arguments are marked with `< >` @@ -38,8 +38,6 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`).
Requires `authme.admin.purgeplayer` - **/authme backup**: Creates a backup of the registered users.
Requires `authme.admin.backup` -- **/authme resetpos** <player/*>: Purge the last know position of the specified player or all of them. -
Requires `authme.admin.purgelastpos` - **/authme purgebannedplayers**: Purge all AuthMeReloaded data for banned players.
Requires `authme.admin.purgebannedplayers` - **/authme switchantibot** [mode]: Switch or toggle the AntiBot mode to the specified state. @@ -104,4 +102,4 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`). --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Apr 22 11:00:10 CEST 2018 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jan 28 23:57:12 CET 2019 diff --git a/docs/config.md b/docs/config.md index 9444bb83e..36e56290f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -10,63 +10,63 @@ the generated config.yml file. DataSource: # What type of database do you want to use? - # Valid values: SQLITE, MYSQL - backend: 'SQLITE' + # Valid values: SQLITE, MYSQL, POSTGRESQL + backend: SQLITE # Enable the database caching system, should be disabled on bungeecord environments # or when a website integration is being used. caching: true # Database host address - mySQLHost: '127.0.0.1' + mySQLHost: 127.0.0.1 # Database port mySQLPort: '3306' # Connect to MySQL database over SSL mySQLUseSSL: true # Username to connect to the MySQL database - mySQLUsername: 'authme' + mySQLUsername: authme # Password to connect to the MySQL database mySQLPassword: '12345' # Database Name, use with converters or as SQLITE database name - mySQLDatabase: 'authme' + mySQLDatabase: authme # Table of the database - mySQLTablename: 'authme' + mySQLTablename: authme # Column of IDs to sort data - mySQLColumnId: 'id' + mySQLColumnId: id # Column for storing or checking players nickname - mySQLColumnName: 'username' + mySQLColumnName: username # Column for storing or checking players RealName - mySQLRealName: 'realname' + mySQLRealName: realname # Column for storing players passwords - mySQLColumnPassword: 'password' + mySQLColumnPassword: password # Column for storing players passwords salts mySQLColumnSalt: '' # Column for storing players emails - mySQLColumnEmail: 'email' + mySQLColumnEmail: email # Column for storing if a player is logged in or not - mySQLColumnLogged: 'isLogged' + mySQLColumnLogged: isLogged # Column for storing if a player has a valid session or not - mySQLColumnHasSession: 'hasSession' + mySQLColumnHasSession: hasSession # Column for storing a player's TOTP key (for two-factor authentication) - mySQLtotpKey: 'totp' + mySQLtotpKey: totp # Column for storing the player's last IP - mySQLColumnIp: 'ip' + mySQLColumnIp: ip # Column for storing players lastlogins - mySQLColumnLastLogin: 'lastlogin' + mySQLColumnLastLogin: lastlogin # Column storing the registration date - mySQLColumnRegisterDate: 'regdate' + mySQLColumnRegisterDate: regdate # Column for storing the IP address at the time of registration - mySQLColumnRegisterIp: 'regip' + mySQLColumnRegisterIp: regip # Column for storing player LastLocation - X - mySQLlastlocX: 'x' + mySQLlastlocX: x # Column for storing player LastLocation - Y - mySQLlastlocY: 'y' + mySQLlastlocY: y # Column for storing player LastLocation - Z - mySQLlastlocZ: 'z' + mySQLlastlocZ: z # Column for storing player LastLocation - World Name - mySQLlastlocWorld: 'world' + mySQLlastlocWorld: world # Column for storing player LastLocation - Yaw - mySQLlastlocYaw: 'yaw' + mySQLlastlocYaw: yaw # Column for storing player LastLocation - Pitch - mySQLlastlocPitch: 'pitch' + mySQLlastlocPitch: pitch # Overrides the size of the DB Connection Pool, default = 10 poolSize: 10 # The maximum lifetime of a connection in the pool, default = 1800 seconds @@ -84,19 +84,19 @@ ExternalBoardOptions: # How much log2 rounds needed in BCrypt (do not change if you do not know what it does) bCryptLog2Round: 10 # phpBB table prefix defined during the phpBB installation process - phpbbTablePrefix: 'phpbb_' + phpbbTablePrefix: phpbb_ # phpBB activated group ID; 2 is the default registered group defined by phpBB phpbbActivatedGroupId: 2 # IP Board table prefix defined during the IP Board installation process - IPBTablePrefix: 'ipb_' + IPBTablePrefix: ipb_ # IP Board default group ID; 3 is the default registered group defined by IP Board IPBActivatedGroupId: 3 # Xenforo table prefix defined during the Xenforo installation process - XFTablePrefix: 'xf_' + XFTablePrefix: xf_ # XenForo default group ID; 2 is the default registered group defined by Xenforo XFActivatedGroupId: 2 # Wordpress prefix defined during WordPress installation - wordpressTablePrefix: 'wp_' + wordpressTablePrefix: wp_ settings: sessions: # Do you want to enable the session feature? @@ -111,13 +111,13 @@ settings: timeout: 10 # Message language, available languages: # https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md - messagesLanguage: 'en' + messagesLanguage: en # Forces authme to hook into Vault instead of a specific permission handler system. forceVaultHook: false # Log level: INFO, FINE, DEBUG. Use INFO for general messages, # FINE for some additional detailed ones (like password failed), # and DEBUG for debugging - logLevel: 'FINE' + logLevel: FINE # By default we schedule async tasks when talking to the database. If you want # typical communication with the database to happen synchronously, set this to false useAsyncTasks: true @@ -134,14 +134,14 @@ settings: hideChat: false # Allowed commands for unauthenticated players allowCommands: - - '/login' - - '/register' - - '/l' - - '/reg' - - '/email' - - '/captcha' - - '/2fa' - - '/totp' + - /login + - /register + - /l + - /reg + - /email + - /captcha + - /2fa + - /totp # Max number of allowed registrations per IP # The value 0 means an unlimited number of registrations! maxRegPerIp: 1 @@ -163,11 +163,9 @@ settings: # WorldNames where we need to force the spawn location # Case-sensitive! worlds: - - 'world' - - 'world_nether' - - 'world_the_end' - # This option will save the quit location of the players. - SaveQuitLocation: false + - world + - world_nether + - world_the_end # To activate the restricted user feature you need # to enable this option and configure the AllowedRestrictedUser field. AllowRestrictedUser: false @@ -207,7 +205,7 @@ settings: # permission: /authme.admin.accounts displayOtherAccounts: true # Spawn priority; values: authme, essentials, cmi, multiverse, default - spawnPriority: 'authme,essentials,cmi,multiverse,default' + spawnPriority: authme,essentials,cmi,multiverse,default # Maximum Login authorized by IP maxLoginPerIp: 0 # Maximum Join authorized by IP @@ -230,6 +228,14 @@ settings: # - 'npcPlayer' # - 'npcPlayer2' UnrestrictedName: [] + # Below you can list all inventories names that AuthMe will ignore + # for registration or login. Configure it at your own risk!! + # This option adds compatibility with some mods. + # It is case-insensitive! Example: + # UnrestrictedInventories: + # - 'myCustomInventory1' + # - 'myCustomInventory2' + UnrestrictedInventories: [] security: # Minimum length of password minPasswordLength: 5 @@ -240,7 +246,7 @@ settings: # PBKDF2DJANGO, WORDPRESS, ROYALAUTH, ARGON2, CUSTOM (for developers only). See full list at # https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/hash_algorithms.md # If you use ARGON2, check that you have the argon2 c library on your system - passwordHash: 'SHA256' + passwordHash: SHA256 # If a password check fails, AuthMe will also try to check with the following hash methods. # Use this setting when you change from one hash method to another. # AuthMe will update the password to the new hash. Example: @@ -259,12 +265,12 @@ settings: # - 'help' unsafePasswords: - '123456' - - 'password' - - 'qwerty' + - password + - qwerty - '12345' - '54321' - '123456789' - - 'help' + - help registration: # Enable registration on the server? enabled: true @@ -278,12 +284,12 @@ settings: # PASSWORD = account is registered with a password supplied by the user; # EMAIL = password is generated and sent to the email provided by the user. # More info at https://github.com/AuthMe/AuthMeReloaded/wiki/Registration - type: 'PASSWORD' + type: PASSWORD # Second argument the /register command should take: NONE = no 2nd argument # CONFIRMATION = must repeat first argument (pass or email) # EMAIL_OPTIONAL = for password register: 2nd argument can be empty or have email address # EMAIL_MANDATORY = for password register: 2nd argument MUST be an email address - secondArg: 'CONFIRMATION' + secondArg: CONFIRMATION # Do we force kick a player after a successful registration? # Do not use with login feature below forceKickAfterRegister: false @@ -339,7 +345,7 @@ GroupOptions: unregisteredPlayerGroup: '' Email: # Email SMTP server host - mailSMTP: 'smtp.gmail.com' + mailSMTP: smtp.gmail.com # Email SMTP server port mailPort: 465 # Only affects port 25: enable TLS/STARTTLS? @@ -355,7 +361,7 @@ Email: # Recovery password length RecoveryPasswordLength: 8 # Mail Subject - mailSubject: 'Your new AuthMe password' + mailSubject: Your new AuthMe password # Like maxRegPerIP but with email maxRegPerEmail: 1 # Recall players to add an email? @@ -364,7 +370,7 @@ Email: delayRecall: 5 # Blacklist these domains for emails emailBlacklisted: - - '10minutemail.com' + - 10minutemail.com # Whitelist ONLY these domains for emails emailWhitelisted: [] # Send the new password drawn in an image? @@ -389,14 +395,16 @@ Protection: enableProtectionRegistered: true # Countries allowed to join the server and register. For country codes, see # https://dev.maxmind.com/geoip/legacy/codes/iso3166/ + # Use "LOCALHOST" for local addresses. # PLEASE USE QUOTES! countries: - - 'US' - - 'GB' + - US + - GB + - LOCALHOST # Countries not allowed to join the server and register # PLEASE USE QUOTES! countriesBlacklist: - - 'A1' + - A1 # Do we need to enable automatic antibot system? enableAntiBot: true # The interval in seconds @@ -421,7 +429,7 @@ Purge: # Do we need to remove the Essentials/userdata/player.yml file during purge process? removeEssentialsFile: false # World in which the players.dat are stored - defaultWorld: 'world' + defaultWorld: world # Remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge? removeLimitedCreativesInventories: false # Do we need to remove the AntiXRayData/PlayerData/player file during purge process? @@ -498,7 +506,7 @@ limbo: # DISABLED: no disk storage, # INDIVIDUAL_FILES: each player data in its own file, # DISTRIBUTED_FILES: distributes players into different files based on their UUID, see below - type: 'INDIVIDUAL_FILES' + type: INDIVIDUAL_FILES # This setting only affects DISTRIBUTED_FILES persistence. The distributed file # persistence attempts to reduce the number of files by distributing players into various # buckets based on their UUID. This setting defines into how many files the players should @@ -508,20 +516,20 @@ limbo: # 6.25 players per file (100 / 16). # Note: if you change this setting all data will be migrated. If you have a lot of data, # change this setting only on server restart, not with /authme reload. - distributionSize: 'SIXTEEN' + distributionSize: SIXTEEN # Whether the player is allowed to fly: RESTORE, ENABLE, DISABLE, NOTHING. # RESTORE sets back the old property from the player. NOTHING will prevent AuthMe # from modifying the 'allow flight' property on the player. - restoreAllowFlight: 'RESTORE' + restoreAllowFlight: RESTORE # Restore fly speed: RESTORE, DEFAULT, MAX_RESTORE, RESTORE_NO_ZERO. # RESTORE: restore the speed the player had; # DEFAULT: always set to default speed; # MAX_RESTORE: take the maximum of the player's current speed and the previous one # RESTORE_NO_ZERO: Like 'restore' but sets speed to default if the player's speed was 0 - restoreFlySpeed: 'RESTORE_NO_ZERO' + restoreFlySpeed: RESTORE_NO_ZERO # Restore walk speed: RESTORE, DEFAULT, MAX_RESTORE, RESTORE_NO_ZERO. # See above for a description of the values. - restoreWalkSpeed: 'RESTORE_NO_ZERO' + restoreWalkSpeed: RESTORE_NO_ZERO BackupSystem: # General configuration for backups: if false, no backups are possible ActivateBackup: false @@ -530,19 +538,19 @@ BackupSystem: # Create backup at every stop of server OnServerStop: true # Windows only: MySQL installation path - MysqlWindowsPath: 'C:\Program Files\MySQL\MySQL Server 5.1\' + MysqlWindowsPath: C:\Program Files\MySQL\MySQL Server 5.1\ # Converter settings: see https://github.com/AuthMe/AuthMeReloaded/wiki/Converters Converter: Rakamak: # Rakamak file name - fileName: 'users.rak' + fileName: users.rak # Rakamak use IP? useIP: false # Rakamak IP file name - ipFileName: 'UsersIp.rak' + ipFileName: UsersIp.rak CrazyLogin: # CrazyLogin database file name - fileName: 'accounts.db' + fileName: accounts.db loginSecurity: # LoginSecurity: convert from SQLite; if false we use MySQL useSqlite: true @@ -562,4 +570,4 @@ To change settings on a running server, save your changes to config.yml and use --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon May 21 09:08:25 CEST 2018 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jan 28 23:57:12 CET 2019 diff --git a/docs/hash_algorithms.md b/docs/hash_algorithms.md index f22948cee..7773e8e64 100644 --- a/docs/hash_algorithms.md +++ b/docs/hash_algorithms.md @@ -1,5 +1,5 @@ - + ## Hash Algorithms AuthMe supports the following hash algorithms for storing your passwords safely. @@ -80,4 +80,4 @@ or bad. --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Sep 02 20:38:48 CEST 2018 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jan 28 23:57:13 CET 2019 diff --git a/docs/permission_nodes.md b/docs/permission_nodes.md index 3f0df2206..5494368e6 100644 --- a/docs/permission_nodes.md +++ b/docs/permission_nodes.md @@ -1,5 +1,5 @@ - + ## AuthMe Permission Nodes The following are the permission nodes that are currently supported by the latest dev builds. @@ -18,7 +18,6 @@ The following are the permission nodes that are currently supported by the lates - **authme.admin.lastlogin** – Administrator command to see the last login date and time of a user. - **authme.admin.purge** – Administrator command to purge old user data. - **authme.admin.purgebannedplayers** – Administrator command to purge all data associated with banned players. -- **authme.admin.purgelastpos** – Administrator command to purge the last position of a user. - **authme.admin.purgeplayer** – Administrator command to purge a given player. - **authme.admin.register** – Administrator command to register a new user. - **authme.admin.reload** – Administrator command to reload the plugin configuration. @@ -32,8 +31,8 @@ The following are the permission nodes that are currently supported by the lates - **authme.admin.updatemessages** – Permission to use the update messages command. - **authme.allowchatbeforelogin** – Permission to send chat messages before being logged in. - **authme.allowmultipleaccounts** – Permission to be able to register multiple accounts. -- **authme.bypassbungeesend** – Permission node to bypass BungeeCord server teleportation. - **authme.bypassantibot** – Permission node to bypass AntiBot protection. +- **authme.bypassbungeesend** – Permission node to bypass BungeeCord server teleportation. - **authme.bypasscountrycheck** – Permission to bypass the GeoIp country code check. - **authme.bypassforcesurvival** – Permission for users to bypass force-survival mode. - **authme.bypasspurge** – Permission to bypass the purging process. @@ -71,4 +70,4 @@ The following are the permission nodes that are currently supported by the lates --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon May 21 08:43:08 CEST 2018 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jan 28 23:57:13 CET 2019 diff --git a/docs/translations.md b/docs/translations.md index aac58a65f..238ef5bd3 100644 --- a/docs/translations.md +++ b/docs/translations.md @@ -1,5 +1,5 @@ - + # AuthMe Translations The following translations are available in AuthMe. Set `messagesLanguage` to the language code @@ -8,37 +8,37 @@ in your config.yml to use the language, or use another language code to start a Code | Language | Translated |   ---- | -------- | ---------: | ------ [en](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_en.yml) | English | 100% | bar -[bg](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_bg.yml) | Bulgarian | 76% | bar -[br](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_br.yml) | Brazilian | 80% | bar +[bg](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_bg.yml) | Bulgarian | 100% | bar +[br](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_br.yml) | Brazilian | 97% | bar [cz](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_cz.yml) | Czech | 80% | bar [de](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_de.yml) | German | 80% | bar [eo](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_eo.yml) | Esperanto | 80% | bar [es](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_es.yml) | Spanish | 100% | bar -[et](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_et.yml) | Estonian | 80% | bar +[et](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_et.yml) | Estonian | 100% | bar [eu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_eu.yml) | Basque | 42% | bar [fi](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fi.yml) | Finnish | 45% | bar -[fr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fr.yml) | French | 89% | bar +[fr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fr.yml) | French | 100% | bar [gl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_gl.yml) | Galician | 48% | bar -[hu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_hu.yml) | Hungarian | 87% | bar -[id](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_id.yml) | Indonesian | 47% | bar +[hu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_hu.yml) | Hungarian | 100% | bar +[id](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_id.yml) | Indonesian | 93% | bar [it](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_it.yml) | Italian | 100% | bar -[ko](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ko.yml) | Korean | 89% | bar +[ko](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ko.yml) | Korean | 100% | bar [lt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_lt.yml) | Lithuanian | 36% | bar [nl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_nl.yml) | Dutch | 80% | bar [pl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pl.yml) | Polish | 100% | bar [pt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pt.yml) | Portuguese | 100% | bar [ro](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ro.yml) | Romanian | 80% | bar -[ru](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ru.yml) | Russian | 93% | bar +[ru](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ru.yml) | Russian | 100% | bar [sk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_sk.yml) | Slovakian | 80% | bar [tr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_tr.yml) | Turkish | 100% | bar [uk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_uk.yml) | Ukrainian | 63% | bar [vn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_vn.yml) | Vietnamese | 77% | bar -[zhcn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhcn.yml) | Chinese (China) | 89% | bar -[zhhk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhhk.yml) | Chinese (Hong Kong) | 80% | bar +[zhcn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhcn.yml) | Chinese (China) | 98% | bar +[zhhk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhhk.yml) | Chinese (Hong Kong) | 100% | bar [zhmc](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhmc.yml) | Chinese (Macau) | 65% | bar [zhtw](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhtw.yml) | Chinese (Taiwan) | 87% | bar --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Thu Aug 02 21:12:10 CEST 2018 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jan 28 23:57:13 CET 2019 diff --git a/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java b/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java index 7dcf137c3..6024cf52f 100644 --- a/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java +++ b/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java @@ -12,6 +12,7 @@ import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.service.GeoIpService; import fr.xephi.authme.service.ValidationService; import fr.xephi.authme.util.PlayerUtils; +import org.apache.commons.lang.NotImplementedException; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -122,14 +123,11 @@ public class AuthMeApi { * * @param player The player to process * @return The location of the player + * @deprecated No longer implemented */ + @Deprecated public Location getLastLocation(Player player) { - PlayerAuth auth = playerCache.getAuth(player.getName()); - if (auth != null) { - return new Location(Bukkit.getWorld(auth.getWorld()), - auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getYaw(), auth.getPitch()); - } - return null; + throw new NotImplementedException(); } /** diff --git a/src/main/java/fr/xephi/authme/command/CommandInitializer.java b/src/main/java/fr/xephi/authme/command/CommandInitializer.java index ba48e0112..4387c565d 100644 --- a/src/main/java/fr/xephi/authme/command/CommandInitializer.java +++ b/src/main/java/fr/xephi/authme/command/CommandInitializer.java @@ -14,7 +14,6 @@ import fr.xephi.authme.command.executable.authme.GetIpCommand; import fr.xephi.authme.command.executable.authme.LastLoginCommand; import fr.xephi.authme.command.executable.authme.PurgeBannedPlayersCommand; import fr.xephi.authme.command.executable.authme.PurgeCommand; -import fr.xephi.authme.command.executable.authme.PurgeLastPositionCommand; import fr.xephi.authme.command.executable.authme.PurgePlayerCommand; import fr.xephi.authme.command.executable.authme.RecentPlayersCommand; import fr.xephi.authme.command.executable.authme.RegisterAdminCommand; @@ -363,18 +362,6 @@ public class CommandInitializer { .executableCommand(BackupCommand.class) .register(); - // Register the purgelastposition command - CommandDescription.builder() - .parent(authmeBase) - .labels("resetpos", "purgelastposition", "purgelastpos", "resetposition", - "resetlastposition", "resetlastpos") - .description("Purge player's last position") - .detailedDescription("Purge the last know position of the specified player or all of them.") - .withArgument("player/*", "Player name or * for all players", MANDATORY) - .permission(AdminPermission.PURGE_LAST_POSITION) - .executableCommand(PurgeLastPositionCommand.class) - .register(); - // Register the purgebannedplayers command CommandDescription.builder() .parent(authmeBase) diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java deleted file mode 100644 index 39af8ef64..000000000 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package fr.xephi.authme.command.executable.authme; - -import fr.xephi.authme.command.ExecutableCommand; -import fr.xephi.authme.data.auth.PlayerAuth; -import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.message.MessageKey; -import fr.xephi.authme.service.CommonService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; -import org.bukkit.command.CommandSender; - -import javax.inject.Inject; -import java.util.List; - -/** - * Removes the stored last position of a user or of all. - */ -public class PurgeLastPositionCommand implements ExecutableCommand { - - @Inject - private DataSource dataSource; - - @Inject - private CommonService commonService; - - @Inject - private BungeeSender bungeeSender; - - @Override - public void executeCommand(final CommandSender sender, List arguments) { - String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0); - - if ("*".equals(playerName)) { - for (PlayerAuth auth : dataSource.getAllAuths()) { - resetLastPosition(auth); - dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName); - } - sender.sendMessage("All players last position locations are now reset"); - } else { - // Get the user auth and make sure the user exists - PlayerAuth auth = dataSource.getAuth(playerName); - if (auth == null) { - commonService.send(sender, MessageKey.UNKNOWN_USER); - return; - } - - resetLastPosition(auth); - dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName); - sender.sendMessage(playerName + "'s last position location is now reset"); - } - } - - private static void resetLastPosition(PlayerAuth auth) { - auth.setQuitLocX(0d); - auth.setQuitLocY(0d); - auth.setQuitLocZ(0d); - auth.setWorld("world"); - } -} diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java index ae314e098..bb16506e4 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java @@ -68,8 +68,6 @@ class PlayerAuthViewer implements DebugSection { private void displayAuthToSender(PlayerAuth auth, CommandSender sender) { sender.sendMessage(ChatColor.BLUE + "[AuthMe] Player " + auth.getNickname() + " / " + auth.getRealName()); sender.sendMessage("Email: " + auth.getEmail() + ". IP: " + auth.getLastIp() + ". Group: " + auth.getGroupId()); - sender.sendMessage("Quit location: " - + formatLocation(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld())); sender.sendMessage("Last login: " + formatDate(auth.getLastLogin())); sender.sendMessage("Registration: " + formatDate(auth.getRegistrationDate()) + " with IP " + auth.getRegistrationIp()); diff --git a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java index 32bdc01b0..05534e81e 100644 --- a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java @@ -33,13 +33,6 @@ public class PlayerAuth { private Long lastLogin; private String registrationIp; private long registrationDate; - // Fields storing the player's quit location - private double x; - private double y; - private double z; - private String world; - private float yaw; - private float pitch; /** * Hidden constructor. @@ -70,53 +63,6 @@ public class PlayerAuth { return groupId; } - public void setQuitLocation(Location location) { - x = location.getBlockX(); - y = location.getBlockY(); - z = location.getBlockZ(); - world = location.getWorld().getName(); - } - - public double getQuitLocX() { - return x; - } - - public void setQuitLocX(double d) { - this.x = d; - } - - public double getQuitLocY() { - return y; - } - - public void setQuitLocY(double d) { - this.y = d; - } - - public double getQuitLocZ() { - return z; - } - - public void setQuitLocZ(double d) { - this.z = d; - } - - public String getWorld() { - return world; - } - - public void setWorld(String world) { - this.world = world; - } - - public float getYaw() { - return yaw; - } - - public float getPitch() { - return pitch; - } - public String getLastIp() { return lastIp; } @@ -191,7 +137,6 @@ public class PlayerAuth { return "Player : " + nickname + " | " + realName + " ! IP : " + lastIp + " ! LastLogin : " + lastLogin - + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Password : {" + password.getHash() + ", " + password.getSalt() + "}"; } @@ -236,13 +181,6 @@ public class PlayerAuth { auth.lastLogin = isEqualTo(lastLogin, DB_LAST_LOGIN_DEFAULT) ? null : lastLogin; auth.registrationIp = registrationIp; auth.registrationDate = registrationDate == null ? System.currentTimeMillis() : registrationDate; - - auth.x = x; - auth.y = y; - auth.z = z; - auth.world = Optional.ofNullable(world).orElse("world"); - auth.yaw = yaw; - auth.pitch = pitch; return auth; } diff --git a/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java b/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java index 0c40c479d..e331533a5 100644 --- a/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java @@ -84,13 +84,6 @@ public abstract class AbstractSqlDataSource implements DataSource { .and(AuthMeColumns.SALT, password.getSalt()).build()); } - @Override - public boolean updateQuitLoc(PlayerAuth auth) { - return columnsHandler.update(auth, - AuthMeColumns.LOCATION_X, AuthMeColumns.LOCATION_Y, AuthMeColumns.LOCATION_Z, - AuthMeColumns.LOCATION_WORLD, AuthMeColumns.LOCATION_YAW, AuthMeColumns.LOCATION_PITCH); - } - @Override public List getAllAuthsByIp(String ip) { try { diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java index ec57cd57f..36ebf5c8c 100644 --- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java @@ -134,15 +134,6 @@ public class CacheDataSource implements DataSource { return result; } - @Override - public boolean updateQuitLoc(final PlayerAuth auth) { - boolean result = source.updateQuitLoc(auth); - if (result) { - cachedAuths.refresh(auth.getNickname()); - } - return result; - } - @Override public Set getRecordsToPurge(long until) { return source.getRecordsToPurge(until); diff --git a/src/main/java/fr/xephi/authme/datasource/Columns.java b/src/main/java/fr/xephi/authme/datasource/Columns.java index 0d372a239..113dc4142 100644 --- a/src/main/java/fr/xephi/authme/datasource/Columns.java +++ b/src/main/java/fr/xephi/authme/datasource/Columns.java @@ -18,12 +18,6 @@ public final class Columns { public final String LAST_IP; public final String LAST_LOGIN; public final String GROUP; - public final String LASTLOC_X; - public final String LASTLOC_Y; - public final String LASTLOC_Z; - public final String LASTLOC_WORLD; - public final String LASTLOC_YAW; - public final String LASTLOC_PITCH; public final String EMAIL; public final String ID; public final String IS_LOGGED; @@ -40,12 +34,6 @@ public final class Columns { LAST_IP = settings.getProperty(DatabaseSettings.MYSQL_COL_LAST_IP); LAST_LOGIN = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOGIN); GROUP = settings.getProperty(DatabaseSettings.MYSQL_COL_GROUP); - LASTLOC_X = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_X); - LASTLOC_Y = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_Y); - LASTLOC_Z = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_Z); - LASTLOC_WORLD = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_WORLD); - LASTLOC_YAW = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_YAW); - LASTLOC_PITCH = settings.getProperty(DatabaseSettings.MYSQL_COL_LASTLOC_PITCH); EMAIL = settings.getProperty(DatabaseSettings.MYSQL_COL_EMAIL); ID = settings.getProperty(DatabaseSettings.MYSQL_COL_ID); IS_LOGGED = settings.getProperty(DatabaseSettings.MYSQL_COL_ISLOGGED); diff --git a/src/main/java/fr/xephi/authme/datasource/DataSource.java b/src/main/java/fr/xephi/authme/datasource/DataSource.java index 3152eb17e..c0fe4d850 100644 --- a/src/main/java/fr/xephi/authme/datasource/DataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/DataSource.java @@ -103,14 +103,6 @@ public interface DataSource extends Reloadable { */ boolean removeAuth(String user); - /** - * Update the quit location of a PlayerAuth. - * - * @param auth The entry whose quit location should be updated - * @return True upon success, false upon failure - */ - boolean updateQuitLoc(PlayerAuth auth); - /** * Return all usernames associated with the given IP address. * diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 3bb187ff1..62854360c 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -211,33 +211,6 @@ public class MySQL extends AbstractSqlDataSource { + " ADD COLUMN " + col.REGISTRATION_IP + " VARCHAR(40) CHARACTER SET ascii COLLATE ascii_bin;"); } - if (isColumnMissing(md, col.LASTLOC_X)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_X + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + col.LAST_LOGIN + " , ADD " - + col.LASTLOC_Y + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + col.LASTLOC_X + " , ADD " - + col.LASTLOC_Z + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + col.LASTLOC_Y); - } else { - st.executeUpdate("ALTER TABLE " + tableName + " MODIFY " - + col.LASTLOC_X + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " - + col.LASTLOC_Y + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " - + col.LASTLOC_Z + " DOUBLE NOT NULL DEFAULT '0.0';"); - } - - if (isColumnMissing(md, col.LASTLOC_WORLD)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + col.LASTLOC_Z); - } - - if (isColumnMissing(md, col.LASTLOC_YAW)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_YAW + " FLOAT;"); - } - - if (isColumnMissing(md, col.LASTLOC_PITCH)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_PITCH + " FLOAT;"); - } - if (isColumnMissing(md, col.EMAIL)) { st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.EMAIL + " VARCHAR(255);"); @@ -458,12 +431,6 @@ public class MySQL extends AbstractSqlDataSource { .registrationDate(row.getLong(col.REGISTRATION_DATE)) .registrationIp(row.getString(col.REGISTRATION_IP)) .groupId(group) - .locWorld(row.getString(col.LASTLOC_WORLD)) - .locX(row.getDouble(col.LASTLOC_X)) - .locY(row.getDouble(col.LASTLOC_Y)) - .locZ(row.getDouble(col.LASTLOC_Z)) - .locYaw(row.getFloat(col.LASTLOC_YAW)) - .locPitch(row.getFloat(col.LASTLOC_PITCH)) .build(); } } diff --git a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java index eaf869b8a..f94022f53 100644 --- a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java @@ -200,28 +200,6 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { + " ADD COLUMN " + col.REGISTRATION_IP + " VARCHAR(40);"); } - if (isColumnMissing(md, col.LASTLOC_X)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_X + " DOUBLE PRECISION NOT NULL DEFAULT '0.0' , ADD " - + col.LASTLOC_Y + " DOUBLE PRECISION NOT NULL DEFAULT '0.0' , ADD " - + col.LASTLOC_Z + " DOUBLE PRECISION NOT NULL DEFAULT '0.0';"); - } - - if (isColumnMissing(md, col.LASTLOC_WORLD)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world';"); - } - - if (isColumnMissing(md, col.LASTLOC_YAW)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_YAW + " FLOAT;"); - } - - if (isColumnMissing(md, col.LASTLOC_PITCH)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_PITCH + " FLOAT;"); - } - if (isColumnMissing(md, col.EMAIL)) { st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.EMAIL + " VARCHAR(255);"); @@ -444,12 +422,6 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { .registrationDate(row.getLong(col.REGISTRATION_DATE)) .registrationIp(row.getString(col.REGISTRATION_IP)) .groupId(group) - .locWorld(row.getString(col.LASTLOC_WORLD)) - .locX(row.getDouble(col.LASTLOC_X)) - .locY(row.getDouble(col.LASTLOC_Y)) - .locZ(row.getDouble(col.LASTLOC_Z)) - .locYaw(row.getFloat(col.LASTLOC_YAW)) - .locPitch(row.getFloat(col.LASTLOC_PITCH)) .build(); } } diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index fe7260ec6..28ff47924 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -139,30 +139,6 @@ public class SQLite extends AbstractSqlDataSource { addRegistrationDateColumn(st); } - if (isColumnMissing(md, col.LASTLOC_X)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_X - + " DOUBLE NOT NULL DEFAULT '0.0';"); - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Y - + " DOUBLE NOT NULL DEFAULT '0.0';"); - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Z - + " DOUBLE NOT NULL DEFAULT '0.0';"); - } - - if (isColumnMissing(md, col.LASTLOC_WORLD)) { - st.executeUpdate("ALTER TABLE " + tableName - + " ADD COLUMN " + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world';"); - } - - if (isColumnMissing(md, col.LASTLOC_YAW)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_YAW + " FLOAT;"); - } - - if (isColumnMissing(md, col.LASTLOC_PITCH)) { - st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " - + col.LASTLOC_PITCH + " FLOAT;"); - } - if (isColumnMissing(md, col.EMAIL)) { st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.EMAIL + " VARCHAR(255);"); @@ -369,12 +345,6 @@ public class SQLite extends AbstractSqlDataSource { .lastIp(row.getString(col.LAST_IP)) .registrationDate(row.getLong(col.REGISTRATION_DATE)) .registrationIp(row.getString(col.REGISTRATION_IP)) - .locX(row.getDouble(col.LASTLOC_X)) - .locY(row.getDouble(col.LASTLOC_Y)) - .locZ(row.getDouble(col.LASTLOC_Z)) - .locWorld(row.getString(col.LASTLOC_WORLD)) - .locYaw(row.getFloat(col.LASTLOC_YAW)) - .locPitch(row.getFloat(col.LASTLOC_PITCH)) .build(); } diff --git a/src/main/java/fr/xephi/authme/datasource/SqLiteMigrater.java b/src/main/java/fr/xephi/authme/datasource/SqLiteMigrater.java index aab79f187..d54e2c4a6 100644 --- a/src/main/java/fr/xephi/authme/datasource/SqLiteMigrater.java +++ b/src/main/java/fr/xephi/authme/datasource/SqLiteMigrater.java @@ -97,10 +97,10 @@ class SqLiteMigrater { try (Statement st = connection.createStatement()) { String copySql = "INSERT INTO $table ($id, $name, $realName, $password, $lastIp, $lastLogin, $regIp, " - + "$regDate, $locX, $locY, $locZ, $locWorld, $locPitch, $locYaw, $email, $isLogged)" + + "$regDate, $email, $isLogged)" + "SELECT $id, $name, $realName," + " $password, CASE WHEN $lastIp = '127.0.0.1' OR $lastIp = '' THEN NULL else $lastIp END," - + " $lastLogin, $regIp, $regDate, $locX, $locY, $locZ, $locWorld, $locPitch, $locYaw," + + " $lastLogin, $regIp, $regDate," + " CASE WHEN $email = 'your@email.com' THEN NULL ELSE $email END, $isLogged" + " FROM " + tempTable + ";"; int insertedEntries = st.executeUpdate(replaceColumnVariables(copySql)); @@ -115,10 +115,7 @@ class SqLiteMigrater { .replace("$name", col.NAME).replace("$realName", col.REAL_NAME) .replace("$password", col.PASSWORD).replace("$lastIp", col.LAST_IP) .replace("$lastLogin", col.LAST_LOGIN).replace("$regIp", col.REGISTRATION_IP) - .replace("$regDate", col.REGISTRATION_DATE).replace("$locX", col.LASTLOC_X) - .replace("$locY", col.LASTLOC_Y).replace("$locZ", col.LASTLOC_Z) - .replace("$locWorld", col.LASTLOC_WORLD).replace("$locPitch", col.LASTLOC_PITCH) - .replace("$locYaw", col.LASTLOC_YAW).replace("$email", col.EMAIL) + .replace("$regDate", col.REGISTRATION_DATE).replace("$email", col.EMAIL) .replace("$isLogged", col.IS_LOGGED); if (replacedSql.contains("$")) { throw new IllegalStateException("SQL still statement still has '$' in it - was a tag not replaced?" diff --git a/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumns.java b/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumns.java index 5c235095f..e3036e0e1 100644 --- a/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumns.java +++ b/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumns.java @@ -46,27 +46,6 @@ public final class AuthMeColumns { public static final PlayerAuthColumn REGISTRATION_DATE = createLong( DatabaseSettings.MYSQL_COL_REGISTER_DATE, PlayerAuth::getRegistrationDate); - // -------- - // Location columns - // -------- - public static final PlayerAuthColumn LOCATION_X = createDouble( - DatabaseSettings.MYSQL_COL_LASTLOC_X, PlayerAuth::getQuitLocX); - - public static final PlayerAuthColumn LOCATION_Y = createDouble( - DatabaseSettings.MYSQL_COL_LASTLOC_Y, PlayerAuth::getQuitLocY); - - public static final PlayerAuthColumn LOCATION_Z = createDouble( - DatabaseSettings.MYSQL_COL_LASTLOC_Z, PlayerAuth::getQuitLocZ); - - public static final PlayerAuthColumn LOCATION_WORLD = createString( - DatabaseSettings.MYSQL_COL_LASTLOC_WORLD, PlayerAuth::getWorld); - - public static final PlayerAuthColumn LOCATION_YAW = createFloat( - DatabaseSettings.MYSQL_COL_LASTLOC_YAW, PlayerAuth::getYaw); - - public static final PlayerAuthColumn LOCATION_PITCH = createFloat( - DatabaseSettings.MYSQL_COL_LASTLOC_PITCH, PlayerAuth::getPitch); - // -------- // Columns not on PlayerAuth // -------- @@ -76,7 +55,6 @@ public final class AuthMeColumns { public static final DataSourceColumn HAS_SESSION = createInteger( DatabaseSettings.MYSQL_COL_HASSESSION); - private AuthMeColumns() { } } diff --git a/src/main/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverter.java b/src/main/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverter.java index 3ae721906..7f94740c3 100644 --- a/src/main/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverter.java +++ b/src/main/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverter.java @@ -63,7 +63,6 @@ public abstract class AbstractDataSourceConverter implemen adaptPlayerAuth(auth); destination.saveAuth(auth); destination.updateSession(auth); - destination.updateQuitLoc(auth); } } diff --git a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java index 063948008..39563fe21 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java +++ b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java @@ -58,21 +58,7 @@ public class OnShutdownPlayerSaver { } if (limboService.hasLimboPlayer(name)) { limboService.restoreData(player); - } else { - saveLoggedinPlayer(player); } playerCache.removePlayer(name); } - - private void saveLoggedinPlayer(Player player) { - if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { - Location loc = spawnLoader.getPlayerLocationOrSpawn(player); - final PlayerAuth auth = PlayerAuth.builder() - .name(player.getName().toLowerCase()) - .realName(player.getName()) - .location(loc).build(); - dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, player.getName()); - } - } } diff --git a/src/main/java/fr/xephi/authme/listener/PlayerListener.java b/src/main/java/fr/xephi/authme/listener/PlayerListener.java index 9c75ea963..925d36370 100644 --- a/src/main/java/fr/xephi/authme/listener/PlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/PlayerListener.java @@ -471,15 +471,6 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); Location spawn = spawnLoader.getSpawnLocation(player); - if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION) && dataSource.isAuthAvailable(name)) { - PlayerAuth auth = PlayerAuth.builder() - .name(name) - .realName(player.getName()) - .location(spawn) - .build(); - dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name); - } if (spawn != null && spawn.getWorld() != null) { event.setRespawnLocation(spawn); } diff --git a/src/main/java/fr/xephi/authme/permission/AdminPermission.java b/src/main/java/fr/xephi/authme/permission/AdminPermission.java index 7664e1436..8cd1c967a 100644 --- a/src/main/java/fr/xephi/authme/permission/AdminPermission.java +++ b/src/main/java/fr/xephi/authme/permission/AdminPermission.java @@ -80,11 +80,6 @@ public enum AdminPermission implements PermissionNode { */ PURGE("authme.admin.purge"), - /** - * Administrator command to purge the last position of a user. - */ - PURGE_LAST_POSITION("authme.admin.purgelastpos"), - /** * Administrator command to purge all data associated with banned players. */ diff --git a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java index 41cedf4bc..47dca9a69 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java @@ -60,11 +60,6 @@ public class AsynchronousLogout implements AsynchronousProcess { PlayerAuth auth = playerCache.getAuth(name); database.updateSession(auth); bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, name); - if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { - auth.setQuitLocation(player.getLocation()); - database.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name); - } playerCache.removePlayer(name); codeManager.unverify(name); diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index b5643217f..5dbf48565 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -72,14 +72,6 @@ public class AsynchronousQuit implements AsynchronousProcess { final boolean wasLoggedIn = playerCache.isAuthenticated(name); if (wasLoggedIn) { - if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { - Location loc = spawnLoader.getPlayerLocationOrSpawn(player); - PlayerAuth auth = PlayerAuth.builder() - .name(name).location(loc) - .realName(player.getName()).build(); - database.updateQuitLoc(auth); - } - final String ip = PlayerUtils.getPlayerIp(player); PlayerAuth auth = PlayerAuth.builder() .name(name) @@ -88,7 +80,6 @@ public class AsynchronousQuit implements AsynchronousProcess { .lastLogin(System.currentTimeMillis()) .build(); database.updateSession(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name); } //always unauthenticate the player - use session only for auto logins on the same ip diff --git a/src/main/java/fr/xephi/authme/service/TeleportationService.java b/src/main/java/fr/xephi/authme/service/TeleportationService.java index 1588c4404..0fd6c6cb6 100644 --- a/src/main/java/fr/xephi/authme/service/TeleportationService.java +++ b/src/main/java/fr/xephi/authme/service/TeleportationService.java @@ -137,11 +137,7 @@ public class TeleportationService implements Reloadable { ConsoleLogger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName()); teleportToSpawn(player, true); } else if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) { - if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION) && auth.getQuitLocY() != 0) { - Location location = buildLocationFromAuth(player, auth); - ConsoleLogger.debug("Teleporting `{0}` after login, based on the player auth", player.getName()); - teleportBackFromSpawn(player, location); - } else if (limbo != null && limbo.getLocation() != null) { + if (limbo != null && limbo.getLocation() != null) { ConsoleLogger.debug("Teleporting `{0}` after login, based on the limbo player", player.getName()); teleportBackFromSpawn(player, limbo.getLocation()); } @@ -153,15 +149,6 @@ public class TeleportationService implements Reloadable { && spawnOnLoginWorlds.contains(worldName); } - private Location buildLocationFromAuth(Player player, PlayerAuth auth) { - World world = bukkitService.getWorld(auth.getWorld()); - if (world == null) { - world = player.getWorld(); - } - return new Location(world, auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), - auth.getYaw(), auth.getPitch()); - } - private void teleportBackFromSpawn(final Player player, final Location location) { performTeleportation(player, new AuthMeTeleportEvent(player, location)); } diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java index 7c832a336..978d58e9c 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java @@ -78,7 +78,6 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent dataSource.invalidateCache(argument); break; case REFRESH_PASSWORD: - case REFRESH_QUITLOC: case REFRESH_EMAIL: case REFRESH: dataSource.refreshCache(argument); diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java b/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java index f90edd725..272c5f30d 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java @@ -5,7 +5,6 @@ import java.util.Optional; public enum MessageType { REFRESH_PASSWORD("refresh.password", true, true), REFRESH_SESSION("refresh.session", true, true), - REFRESH_QUITLOC("refresh.quitloc", true, true), REFRESH_EMAIL("refresh.email", true, true), REFRESH("refresh", true, true), REGISTER("register", true), diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index e3ec8a03e..c47a1a5a1 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -66,10 +66,6 @@ public final class RestrictionSettings implements SettingsHolder { newListProperty("settings.restrictions.ForceSpawnLocOnJoin.worlds", "world", "world_nether", "world_the_end"); - @Comment("This option will save the quit location of the players.") - public static final Property SAVE_QUIT_LOCATION = - newProperty("settings.restrictions.SaveQuitLocation", false); - @Comment({ "To activate the restricted user feature you need", "to enable this option and configure the AllowedRestrictedUser field."}) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 027da3dc0..361b86159 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -18,7 +18,7 @@ softdepend: commands: authme: description: AuthMe op commands - usage: /authme register|unregister|forcelogin|password|lastlogin|accounts|email|setemail|getip|spawn|setspawn|firstspawn|setfirstspawn|purge|purgeplayer|backup|resetpos|purgebannedplayers|switchantibot|reload|version|converter|messages|recent|debug + usage: /authme register|unregister|forcelogin|password|lastlogin|accounts|email|setemail|getip|spawn|setspawn|firstspawn|setfirstspawn|purge|purgeplayer|backup|purgebannedplayers|switchantibot|reload|version|converter|messages|recent|debug email: description: Add email or recover password usage: /email show|add|change|recover|code|setpassword @@ -75,7 +75,6 @@ permissions: authme.admin.lastlogin: true authme.admin.purge: true authme.admin.purgebannedplayers: true - authme.admin.purgelastpos: true authme.admin.purgeplayer: true authme.admin.register: true authme.admin.reload: true @@ -126,9 +125,6 @@ permissions: authme.admin.purgebannedplayers: description: Administrator command to purge all data associated with banned players. default: op - authme.admin.purgelastpos: - description: Administrator command to purge the last position of a user. - default: op authme.admin.purgeplayer: description: Administrator command to purge a given player. default: op diff --git a/src/test/java/fr/xephi/authme/AuthMeMatchers.java b/src/test/java/fr/xephi/authme/AuthMeMatchers.java index 653fb04c9..53bd1098a 100644 --- a/src/test/java/fr/xephi/authme/AuthMeMatchers.java +++ b/src/test/java/fr/xephi/authme/AuthMeMatchers.java @@ -91,33 +91,6 @@ public final class AuthMeMatchers { }; } - public static Matcher hasAuthLocation(PlayerAuth auth) { - return hasAuthLocation(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), - auth.getYaw(), auth.getPitch()); - } - - public static Matcher hasAuthLocation(double x, double y, double z, - String world, float yaw, float pitch) { - return new TypeSafeMatcher() { - @Override - public boolean matchesSafely(PlayerAuth item) { - return Objects.equals(x, item.getQuitLocX()) - && Objects.equals(y, item.getQuitLocY()) - && Objects.equals(z, item.getQuitLocZ()) - && Objects.equals(world, item.getWorld()) - && Objects.equals(yaw, item.getYaw()) - && Objects.equals(pitch, item.getPitch()); - } - - @Override - public void describeTo(Description description) { - description.appendValue( - String.format("PlayerAuth with quit location (x: %f, y: %f, z: %f, world: %s, yaw: %f, pitch: %f)", - x, y, z, world, yaw, pitch)); - } - }; - } - public static Matcher stringWithLength(int length) { return new TypeSafeMatcher() { @Override diff --git a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java index 6021b3a92..2fcc288a7 100644 --- a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java +++ b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java @@ -123,38 +123,6 @@ public class AuthMeApiTest { assertThat(result, equalTo(true)); } - @Test - public void shouldGetLastLocation() { - // given - String name = "Gary"; - Player player = mockPlayerWithName(name); - PlayerAuth auth = PlayerAuth.builder().name(name) - .locWorld("world") - .locX(12.4) - .locY(24.6) - .locZ(-438.2) - .locYaw(3.41f) - .locPitch(0.29f) - .build(); - given(playerCache.getAuth(name)).willReturn(auth); - Server server = mock(Server.class); - ReflectionTestUtils.setField(Bukkit.class, null, "server", server); - World world = mock(World.class); - given(server.getWorld(auth.getWorld())).willReturn(world); - - // when - Location result = api.getLastLocation(player); - - // then - assertThat(result, not(nullValue())); - assertThat(result.getX(), equalTo(auth.getQuitLocX())); - assertThat(result.getY(), equalTo(auth.getQuitLocY())); - assertThat(result.getZ(), equalTo(auth.getQuitLocZ())); - assertThat(result.getWorld(), equalTo(world)); - assertThat(result.getYaw(), equalTo(auth.getYaw())); - assertThat(result.getPitch(), equalTo(auth.getPitch())); - } - @Test public void shouldGetLastIp() { // given @@ -257,20 +225,6 @@ public class AuthMeApiTest { verify(dataSource).getAuth(name); } - @Test - public void shouldReturnNullForUnavailablePlayer() { - // given - String name = "Numan"; - Player player = mockPlayerWithName(name); - given(playerCache.getAuth(name)).willReturn(null); - - // when - Location result = api.getLastLocation(player); - - // then - assertThat(result, nullValue()); - } - @Test public void shouldCheckForRegisteredName() { // given diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java deleted file mode 100644 index 57bb21e26..000000000 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package fr.xephi.authme.command.executable.authme; - -import fr.xephi.authme.data.auth.PlayerAuth; -import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.message.MessageKey; -import fr.xephi.authme.service.CommonService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import org.bukkit.command.CommandSender; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import java.util.Arrays; -import java.util.Collections; - -import static org.hamcrest.Matchers.containsString; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.hamcrest.MockitoHamcrest.argThat; - -/** - * Test for {@link PurgeLastPositionCommand}. - */ -@RunWith(MockitoJUnitRunner.class) -public class PurgeLastPositionCommandTest { - - @InjectMocks - private PurgeLastPositionCommand command; - - @Mock - private DataSource dataSource; - - @Mock - private CommonService service; - - @Mock - private BungeeSender bungeeSender; - - @Test - public void shouldPurgeLastPosOfUser() { - // given - String player = "_Bobby"; - PlayerAuth auth = mock(PlayerAuth.class); - given(dataSource.getAuth(player)).willReturn(auth); - CommandSender sender = mock(CommandSender.class); - - // when - command.executeCommand(sender, Collections.singletonList(player)); - - // then - verify(dataSource).getAuth(player); - verifyPositionWasReset(auth); - verify(sender).sendMessage(argThat(containsString("last position location is now reset"))); - } - - @Test - public void shouldPurgePositionOfCommandSender() { - // given - String player = "_Bobby"; - CommandSender sender = mock(CommandSender.class); - given(sender.getName()).willReturn(player); - PlayerAuth auth = mock(PlayerAuth.class); - given(dataSource.getAuth(player)).willReturn(auth); - - // when - command.executeCommand(sender, Collections.emptyList()); - - // then - verify(dataSource).getAuth(player); - verifyPositionWasReset(auth); - verify(sender).sendMessage(argThat(containsString("position location is now reset"))); - } - - @Test - public void shouldHandleNonExistentUser() { - // given - String name = "invalidPlayer"; - CommandSender sender = mock(CommandSender.class); - - // when - command.executeCommand(sender, Collections.singletonList(name)); - - // then - verify(dataSource).getAuth(name); - verify(service).send(sender, MessageKey.UNKNOWN_USER); - } - - @Test - public void shouldResetAllLastPositions() { - // given - PlayerAuth auth1 = mock(PlayerAuth.class); - PlayerAuth auth2 = mock(PlayerAuth.class); - PlayerAuth auth3 = mock(PlayerAuth.class); - given(dataSource.getAllAuths()).willReturn(Arrays.asList(auth1, auth2, auth3)); - CommandSender sender = mock(CommandSender.class); - - // when - command.executeCommand(sender, Collections.singletonList("*")); - - // then - verify(dataSource).getAllAuths(); - verifyPositionWasReset(auth1); - verifyPositionWasReset(auth2); - verifyPositionWasReset(auth3); - verify(sender).sendMessage(argThat(containsString("last position locations are now reset"))); - } - - - private static void verifyPositionWasReset(PlayerAuth auth) { - verify(auth).setQuitLocX(0); - verify(auth).setQuitLocY(0); - verify(auth).setQuitLocZ(0); - verify(auth).setWorld("world"); - } -} diff --git a/src/test/java/fr/xephi/authme/data/auth/PlayerAuthTest.java b/src/test/java/fr/xephi/authme/data/auth/PlayerAuthTest.java index 360abdc98..8bc49eadb 100644 --- a/src/test/java/fr/xephi/authme/data/auth/PlayerAuthTest.java +++ b/src/test/java/fr/xephi/authme/data/auth/PlayerAuthTest.java @@ -64,6 +64,5 @@ public class PlayerAuthTest { assertThat(auth.getLastLogin(), nullValue()); assertThat(auth.getLastIp(), nullValue()); assertThat(auth.getGroupId(), equalTo(19)); - assertThat(auth.getPitch(), equalTo(123.004f)); } } diff --git a/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java index a5e50cb96..9b70bd167 100644 --- a/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java @@ -15,7 +15,6 @@ import java.util.stream.Stream; import static fr.xephi.authme.AuthMeMatchers.equalToHash; import static fr.xephi.authme.AuthMeMatchers.hasAuthBasicData; -import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation; import static fr.xephi.authme.AuthMeMatchers.hasRegistrationInfo; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -101,14 +100,12 @@ public abstract class AbstractDataSourceIntegrationTest { assertThat(invalidAuth, nullValue()); assertThat(bobbyAuth, hasAuthBasicData("bobby", "Bobby", null, "123.45.67.89")); - assertThat(bobbyAuth, hasAuthLocation(1.05, 2.1, 4.2, "world", -0.44f, 2.77f)); assertThat(bobbyAuth, hasRegistrationInfo("127.0.4.22", 1436778723L)); assertThat(bobbyAuth.getLastLogin(), equalTo(1449136800L)); assertThat(bobbyAuth.getPassword(), equalToHash("$SHA$11aa0706173d7272$dbba966")); assertThat(bobbyAuth.getTotpKey(), equalTo("JBSWY3DPEHPK3PXP")); assertThat(userAuth, hasAuthBasicData("user", "user", "user@example.org", "34.56.78.90")); - assertThat(userAuth, hasAuthLocation(124.1, 76.3, -127.8, "nether", 0.23f, 4.88f)); assertThat(userAuth, hasRegistrationInfo(null, 0)); assertThat(userAuth.getLastLogin(), equalTo(1453242857L)); assertThat(userAuth.getPassword(), equalToHash("b28c32f624a4eb161d6adc9acb5bfc5b", "f750ba32")); @@ -235,22 +232,6 @@ public abstract class AbstractDataSourceIntegrationTest { assertThat(result.getLastLogin(), equalTo(123L)); } - @Test - public void shouldUpdateLastLoc() { - // given - DataSource dataSource = getDataSource(); - PlayerAuth user = PlayerAuth.builder() - .name("user").locX(143).locY(-42.12).locZ(29.47) - .locWorld("the_end").locYaw(2.2f).locPitch(0.45f).build(); - - // when - boolean response = dataSource.updateQuitLoc(user); - - // then - assertThat(response, equalTo(true)); - assertThat(dataSource.getAuth("user"), hasAuthLocation(user)); - } - @Test public void shouldDeletePlayers() { // given diff --git a/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java index b95a0b814..9bd52cd37 100644 --- a/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java @@ -18,7 +18,6 @@ import java.sql.SQLException; import java.util.List; import static fr.xephi.authme.AuthMeMatchers.hasAuthBasicData; -import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation; import static fr.xephi.authme.datasource.SqlDataSourceTestUtil.createSqlite; import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -67,27 +66,21 @@ public class SqLiteMigraterIntegrationTest { containsInAnyOrder("mysql1", "mysql2", "mysql3", "mysql4", "mysql5", "mysql6")); PlayerAuth auth1 = getByNameOrFail("mysql1", auths); assertThat(auth1, hasAuthBasicData("mysql1", "mysql1", "user1@example.com", "192.168.4.41")); - assertThat(auth1, hasAuthLocation(0, 0, 0, "world1", 0, 0)); assertThat(auth1.getLastLogin(), equalTo(1472992664137L)); PlayerAuth auth2 = getByNameOrFail("mysql2", auths); assertThat(auth2, hasAuthBasicData("mysql2", "Player", "user2@example.com", null)); - assertThat(auth2, hasAuthLocation(0, 0, 0, "world2", 0, 0)); assertThat(auth2.getLastLogin(), equalTo(1472992668391L)); PlayerAuth auth3 = getByNameOrFail("mysql3", auths); assertThat(auth3, hasAuthBasicData("mysql3", "mysql3", null, "132.54.76.98")); - assertThat(auth3, hasAuthLocation(0, 0, 0, "world3", 0, 0)); assertThat(auth3.getLastLogin(), equalTo(1472992672790L)); PlayerAuth auth4 = getByNameOrFail("mysql4", auths); assertThat(auth4, hasAuthBasicData("mysql4", "MySQL4", null, null)); - assertThat(auth4, hasAuthLocation(25, 4, 17, "world4", 0, 0)); assertThat(auth4.getLastLogin(), equalTo(1472992676790L)); PlayerAuth auth5 = getByNameOrFail("mysql5", auths); assertThat(auth5, hasAuthBasicData("mysql5", "mysql5", null, null)); - assertThat(auth5, hasAuthLocation(0, 0, 0, "world5", 0, 0)); assertThat(auth5.getLastLogin(), equalTo(1472992680922L)); PlayerAuth auth6 = getByNameOrFail("mysql6", auths); assertThat(auth6, hasAuthBasicData("mysql6", "MySql6", "user6@example.com", "44.45.67.188")); - assertThat(auth6, hasAuthLocation(28.5, 53.43, -147.23, "world6", 0, 0)); assertThat(auth6.getLastLogin(), equalTo(1472992686300L)); // Check that backup was made diff --git a/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java index f4c70280c..ddd5de41b 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java @@ -99,7 +99,6 @@ public class AbstractDataSourceConverterTest { verify(destination, times(3)).isAuthAvailable(anyString()); verify(destination, times(2)).saveAuth(any(PlayerAuth.class)); verify(destination, times(2)).updateSession(any(PlayerAuth.class)); - verify(destination, times(2)).updateQuitLoc(any(PlayerAuth.class)); verifyNoMoreInteractions(destination); verify(sender).sendMessage(argThat(containsString(auths.get(0).getNickname()))); verify(sender).sendMessage(argThat(containsString("successfully converted"))); diff --git a/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java index 54201fb71..0836500b1 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java @@ -25,7 +25,6 @@ import java.sql.SQLException; import java.sql.Statement; import static fr.xephi.authme.AuthMeMatchers.equalToHash; -import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; @@ -84,7 +83,6 @@ public class LoginSecurityConverterTest { assertThat(captor.getAllValues().get(2).getRealName(), equalTo("Player3")); assertThat(captor.getAllValues().get(2).getPassword(), equalToHash("$2a$10$WFui8KSXMLDOVXKFpCLyPukPi4M82w1cv/rNojsAnwJjba3pp8sba")); - assertThat(captor.getAllValues().get(2), hasAuthLocation(14.24, 67.99, -12.83, "hubb", -10f, 185f)); assertThat(captor.getAllValues().get(2).getLastIp(), nullValue()); assertIsCloseTo(captor.getAllValues().get(2).getRegistrationDate(), System.currentTimeMillis(), 500L); } @@ -118,7 +116,6 @@ public class LoginSecurityConverterTest { assertThat(captor.getAllValues().get(2).getRealName(), equalTo("Player3")); assertThat(captor.getAllValues().get(2).getPassword(), equalToHash("$2a$10$WFui8KSXMLDOVXKFpCLyPukPi4M82w1cv/rNojsAnwJjba3pp8sba")); - assertThat(captor.getAllValues().get(2), hasAuthLocation(14.24, 67.99, -12.83, "hubb", -10f, 185f)); } private Connection initializeMySqlTable() throws IOException, SQLException { diff --git a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index bf44ca0e9..91c4b5643 100644 --- a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -274,69 +274,11 @@ public class TeleportationServiceTest { } @Test - public void shouldTeleportBackToPlayerAuthLocation() { + public void shouldTeleportWithLimboPlayer() { // given given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true); - given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true); PlayerAuth auth = createAuthWithLocation(); - auth.setWorld("myWorld"); - World world = mock(World.class); - given(bukkitService.getWorld("myWorld")).willReturn(world); - - Player player = mock(Player.class); - given(player.isOnline()).willReturn(true); - LimboPlayer limbo = mock(LimboPlayer.class); - Location limboLocation = mockLocation(); - given(limbo.getLocation()).willReturn(limboLocation); - setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); - - // when - teleportationService.teleportOnLogin(player, auth, limbo); - - // then - ArgumentCaptor locationCaptor = ArgumentCaptor.forClass(Location.class); - verify(player).teleport(locationCaptor.capture()); - assertCorrectLocation(locationCaptor.getValue(), auth, world); - } - - @Test - public void shouldTeleportAccordingToPlayerAuthAndPlayerWorldAsFallback() { - // given - given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true); - given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true); - - PlayerAuth auth = createAuthWithLocation(); - auth.setWorld("myWorld"); - given(bukkitService.getWorld("myWorld")).willReturn(null); - - Player player = mock(Player.class); - given(player.isOnline()).willReturn(true); - World world = mock(World.class); - given(player.getWorld()).willReturn(world); - LimboPlayer limbo = mock(LimboPlayer.class); - Location limboLocation = mockLocation(); - given(limbo.getLocation()).willReturn(limboLocation); - setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); - - // when - teleportationService.teleportOnLogin(player, auth, limbo); - - // then - ArgumentCaptor locationCaptor = ArgumentCaptor.forClass(Location.class); - verify(player).teleport(locationCaptor.capture()); - assertCorrectLocation(locationCaptor.getValue(), auth, world); - } - - @Test - public void shouldTeleportWithLimboPlayerIfAuthYCoordIsNotSet() { - // given - given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true); - given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true); - - PlayerAuth auth = createAuthWithLocation(); - auth.setQuitLocY(0.0); - auth.setWorld("authWorld"); Player player = mock(Player.class); given(player.isOnline()).willReturn(true); LimboPlayer limbo = mock(LimboPlayer.class); @@ -352,31 +294,9 @@ public class TeleportationServiceTest { verify(bukkitService, never()).getWorld(anyString()); } - @Test - public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() { - // given - given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true); - given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(false); - - PlayerAuth auth = createAuthWithLocation(); - Player player = mock(Player.class); - given(player.isOnline()).willReturn(true); - LimboPlayer limbo = mock(LimboPlayer.class); - Location location = mockLocation(); - given(limbo.getLocation()).willReturn(location); - setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); - - // when - teleportationService.teleportOnLogin(player, auth, limbo); - - // then - verify(player).teleport(location); - } - @Test public void shouldNotTeleportForNullLocationInLimboPlayer() { // given - given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(false); given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true); PlayerAuth auth = PlayerAuth.builder().name("bobby").build(); @@ -391,13 +311,6 @@ public class TeleportationServiceTest { verify(limbo, times(2)).getLocation(); } - private static void assertCorrectLocation(Location location, PlayerAuth auth, World world) { - assertThat(location.getX(), equalTo(auth.getQuitLocX())); - assertThat(location.getY(), equalTo(auth.getQuitLocY())); - assertThat(location.getZ(), equalTo(auth.getQuitLocZ())); - assertThat(location.getWorld(), equalTo(world)); - } - // We check that the World in Location is set, this method creates a mock World in Location for us private static Location mockLocation() { Location location = mock(Location.class);