2014-04-06 19:51:30 +02:00
package com.Acrobot.ChestShop.UUIDs ;
2017-06-30 21:28:18 +02:00
import com.Acrobot.Breeze.Utils.Encoding.Base62 ;
2014-04-06 19:51:47 +02:00
import com.Acrobot.Breeze.Utils.NameUtil ;
2018-03-12 21:01:03 +01:00
import com.Acrobot.Breeze.Collection.SimpleCache ;
2017-06-30 22:00:30 +02:00
import com.Acrobot.ChestShop.ChestShop ;
2014-04-12 16:52:21 +02:00
import com.Acrobot.ChestShop.Configuration.Properties ;
2014-04-10 21:52:05 +02:00
import com.Acrobot.ChestShop.Database.Account ;
2015-05-22 13:26:07 +02:00
import com.Acrobot.ChestShop.Database.DaoCreator ;
2019-05-07 00:49:16 +02:00
import com.Acrobot.ChestShop.Events.AccountQueryEvent ;
2014-04-12 13:57:39 +02:00
import com.Acrobot.ChestShop.Permission ;
2014-08-13 17:22:52 +02:00
import com.Acrobot.ChestShop.Signs.ChestShopSign ;
2014-04-10 21:52:05 +02:00
import com.j256.ormlite.dao.Dao ;
2016-09-20 21:45:18 +02:00
2019-07-29 19:50:26 +02:00
import com.j256.ormlite.stmt.SelectArg ;
2016-09-20 21:45:18 +02:00
import org.apache.commons.lang.Validate ;
2014-04-12 16:52:21 +02:00
import org.bukkit.Bukkit ;
2016-07-07 18:15:43 +02:00
import org.bukkit.OfflinePlayer ;
2014-04-06 19:51:47 +02:00
import org.bukkit.entity.Player ;
2019-05-07 00:49:16 +02:00
import org.bukkit.event.EventHandler ;
import org.bukkit.event.Listener ;
2014-04-06 19:51:47 +02:00
2014-04-10 21:52:05 +02:00
import java.sql.SQLException ;
2017-07-01 18:14:41 +02:00
import java.util.Date ;
2020-01-29 16:35:04 +01:00
import java.util.Locale ;
2014-04-06 19:51:47 +02:00
import java.util.UUID ;
2017-06-30 21:28:18 +02:00
import java.util.concurrent.ExecutionException ;
2016-07-07 18:15:43 +02:00
import java.util.logging.Level ;
2014-04-06 19:51:47 +02:00
2018-11-19 21:10:48 +01:00
import static com.Acrobot.ChestShop.Permission.OTHER_NAME ;
2014-04-06 19:51:30 +02:00
/ * *
2014-04-06 19:51:47 +02:00
* Lets you save / cache username and UUID relations
2014-04-11 17:23:04 +02:00
*
2014-04-06 19:51:30 +02:00
* @author Andrzej Pomirski ( Acrobot )
* /
2016-07-07 18:15:43 +02:00
@SuppressWarnings ( " UnusedAssignment " ) // I deliberately set the variables to null while initializing
2019-05-07 00:49:16 +02:00
public class NameManager implements Listener {
2014-04-10 21:52:05 +02:00
private static Dao < Account , String > accounts ;
2018-03-12 21:01:03 +01:00
private static SimpleCache < String , Account > usernameToAccount = new SimpleCache < > ( Properties . CACHE_SIZE ) ;
private static SimpleCache < UUID , Account > uuidToAccount = new SimpleCache < > ( Properties . CACHE_SIZE ) ;
private static SimpleCache < String , Account > shortToAccount = new SimpleCache < > ( Properties . CACHE_SIZE ) ;
2018-08-29 22:29:27 +02:00
private static SimpleCache < String , Boolean > invalidPlayers = new SimpleCache < > ( Properties . CACHE_SIZE ) ;
2015-03-11 18:02:30 +01:00
2017-10-29 23:50:24 +01:00
private static Account adminAccount ;
private static Account serverEconomyAccount ;
2018-08-29 22:29:27 +02:00
private static int uuidVersion = - 1 ;
2017-10-29 23:50:24 +01:00
2019-05-05 20:21:16 +02:00
/ * *
* Get or create an account for a player
*
* @param player The Player to get or create the account for ( only if the player has both an UUID and a name ! )
* @return The account info
* @throws IllegalArgumentException when an invalid player object was passed
* /
public static Account getOrCreateAccount ( OfflinePlayer player ) {
2020-04-27 22:00:46 +02:00
return getOrCreateAccount ( player . getUniqueId ( ) , player . getName ( ) ) ;
}
/ * *
* Get or create an account for a player
*
* @param id The UUID of the player to get or create the account for
* @param name The name of the player to get or create the account fo
* @return The account info
* @throws IllegalArgumentException when id or name are null
* /
public static Account getOrCreateAccount ( UUID id , String name ) {
Validate . notNull ( id , " UUID of player is null? " ) ;
Validate . notNull ( name , " Name of player " + id + " is null? " ) ;
2020-04-27 22:39:46 +02:00
Validate . isTrue ( uuidVersion < 0 | | id . version ( ) = = uuidVersion , " Invalid OfflinePlayer! " + id + " is not of server version " + uuidVersion ) ;
2019-05-05 20:21:16 +02:00
2020-04-27 22:00:46 +02:00
Account account = getAccount ( id ) ;
2019-05-05 20:21:16 +02:00
if ( account = = null ) {
2020-04-27 22:00:46 +02:00
account = storeUsername ( new PlayerDTO ( id , name ) ) ;
2019-05-05 20:21:16 +02:00
}
return account ;
}
2017-06-30 21:28:18 +02:00
/ * *
2017-07-01 18:14:41 +02:00
* Get account info from a UUID
2018-05-07 16:32:51 +02:00
*
* @param uuid The UUID of the player to get the account info
* @return The account info or < tt > null < / tt > if none was found
2017-06-30 21:28:18 +02:00
* /
2017-07-01 18:14:41 +02:00
public static Account getAccount ( UUID uuid ) {
2014-04-10 21:52:05 +02:00
try {
2017-07-01 18:14:41 +02:00
return uuidToAccount . get ( uuid , ( ) - > {
try {
2019-07-29 19:50:26 +02:00
Account account = accounts . queryBuilder ( ) . orderBy ( " lastSeen " , false ) . where ( ) . eq ( " uuid " , new SelectArg ( uuid ) ) . queryForFirst ( ) ;
2017-07-01 18:14:41 +02:00
if ( account ! = null ) {
2018-05-07 16:32:51 +02:00
account . setUuid ( uuid ) ; // HOW IS IT EVEN POSSIBLE THAT UUID IS NOT SET EVEN IF WE HAVE FOUND THE PLAYER?!
2017-07-01 18:14:41 +02:00
shortToAccount . put ( account . getShortName ( ) , account ) ;
usernameToAccount . put ( account . getName ( ) , account ) ;
return account ;
2017-06-30 21:28:18 +02:00
}
2017-07-01 18:14:41 +02:00
} catch ( SQLException e ) {
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Error while getting account for " + uuid + " : " , e ) ;
2017-06-30 21:28:18 +02:00
}
2017-07-01 18:14:41 +02:00
throw new Exception ( " Could not find account for " + uuid ) ;
2017-06-30 21:28:18 +02:00
} ) ;
2017-07-01 18:14:41 +02:00
} catch ( ExecutionException ignored ) {
2014-04-10 21:52:05 +02:00
return null ;
}
2014-04-06 19:51:47 +02:00
}
2017-06-30 21:28:18 +02:00
/ * *
2017-07-01 18:14:41 +02:00
* Get account info from a non - shortened username
2018-05-07 16:32:51 +02:00
*
* @param fullName The full name of the player to get the account info
* @return The account info or < tt > null < / tt > if none was found
2017-07-01 18:14:41 +02:00
* @throws IllegalArgumentException if the username is empty or null
2017-06-30 21:28:18 +02:00
* /
2017-07-01 18:14:41 +02:00
public static Account getAccount ( String fullName ) {
Validate . notEmpty ( fullName , " fullName cannot be null or empty! " ) ;
2014-04-10 21:52:05 +02:00
try {
2017-07-01 18:14:41 +02:00
return usernameToAccount . get ( fullName , ( ) - > {
try {
2019-07-29 19:50:26 +02:00
Account account = accounts . queryBuilder ( ) . orderBy ( " lastSeen " , false ) . where ( ) . eq ( " name " , new SelectArg ( fullName ) ) . queryForFirst ( ) ;
2017-07-01 18:14:41 +02:00
if ( account ! = null ) {
2018-05-07 16:32:51 +02:00
account . setName ( fullName ) ; // HOW IS IT EVEN POSSIBLE THAT THE NAME IS NOT SET EVEN IF WE HAVE FOUND THE PLAYER?!
2017-07-01 18:14:41 +02:00
shortToAccount . put ( account . getShortName ( ) , account ) ;
return account ;
2017-06-30 21:28:18 +02:00
}
2017-07-01 18:14:41 +02:00
} catch ( SQLException e ) {
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Error while getting account for " + fullName + " : " , e ) ;
2017-06-30 21:28:18 +02:00
}
2017-07-01 18:14:41 +02:00
throw new Exception ( " Could not find account for " + fullName ) ;
2017-06-30 21:28:18 +02:00
} ) ;
2017-07-01 18:14:41 +02:00
} catch ( ExecutionException ignored ) {
return null ;
2014-04-11 17:17:20 +02:00
}
2014-04-06 19:51:47 +02:00
}
2019-05-07 00:49:16 +02:00
@EventHandler
public static void onAccountQuery ( AccountQueryEvent event ) {
if ( event . getAccount ( ) = = null ) {
event . setAccount ( getLastAccountFromShortName ( event . getName ( ) ) ) ;
}
}
2017-06-30 21:28:18 +02:00
/ * *
2019-05-05 20:21:16 +02:00
* Get account info from a username that might be shortened .
* If no account was found it will try to search all known players and create an account .
2018-05-07 16:32:51 +02:00
*
2017-07-01 18:14:41 +02:00
* @param shortName The name of the player to get the account info
2018-05-07 16:32:51 +02:00
* @return The account info or < tt > null < / tt > if none was found
2017-07-09 18:30:26 +02:00
* @throws IllegalArgumentException if the username is empty
2019-05-07 00:49:16 +02:00
* @deprecated Use the { @link AccountQueryEvent } instead !
2017-06-30 21:28:18 +02:00
* /
2017-07-01 18:14:41 +02:00
public static Account getAccountFromShortName ( String shortName ) {
2018-08-31 14:55:36 +02:00
return getAccountFromShortName ( shortName , true ) ;
}
private static Account getAccountFromShortName ( String shortName , boolean searchOfflinePlayer ) {
2017-07-01 18:14:41 +02:00
Validate . notEmpty ( shortName , " shortName cannot be null or empty! " ) ;
2018-08-29 22:29:27 +02:00
Account account = null ;
2017-07-09 18:30:26 +02:00
if ( shortName . length ( ) > 15 ) {
2018-08-29 22:29:27 +02:00
account = getAccount ( shortName ) ;
} else {
try {
account = shortToAccount . get ( shortName , ( ) - > {
try {
2019-07-29 19:50:26 +02:00
Account a = accounts . queryBuilder ( ) . where ( ) . eq ( " shortName " , new SelectArg ( shortName ) ) . queryForFirst ( ) ;
2018-08-29 22:29:27 +02:00
if ( a ! = null ) {
a . setShortName ( shortName ) ; // HOW IS IT EVEN POSSIBLE THAT THE NAME IS NOT SET EVEN IF WE HAVE FOUND THE PLAYER?!
return a ;
}
} catch ( SQLException e ) {
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Error while getting account for " + shortName + " : " , e ) ;
}
throw new Exception ( " Could not find account for " + shortName ) ;
} ) ;
} catch ( ExecutionException ignored ) { }
2017-07-09 18:30:26 +02:00
}
2014-08-13 17:22:52 +02:00
2020-01-29 16:35:04 +01:00
if ( account = = null & & searchOfflinePlayer & & ! invalidPlayers . contains ( shortName . toLowerCase ( Locale . ROOT ) ) ) {
2018-08-29 22:29:27 +02:00
// no account with that shortname was found, try to get an offline player with that name
OfflinePlayer offlinePlayer = ChestShop . getBukkitServer ( ) . getOfflinePlayer ( shortName ) ;
if ( offlinePlayer ! = null & & offlinePlayer . getName ( ) ! = null & & offlinePlayer . getUniqueId ( ) ! = null
& & offlinePlayer . getUniqueId ( ) . version ( ) = = uuidVersion ) {
account = storeUsername ( new PlayerDTO ( offlinePlayer . getUniqueId ( ) , offlinePlayer . getName ( ) ) ) ;
} else {
2020-01-29 16:35:04 +01:00
invalidPlayers . put ( shortName . toLowerCase ( Locale . ROOT ) , true ) ;
2018-08-29 22:29:27 +02:00
}
2017-07-01 18:14:41 +02:00
}
2018-08-29 22:29:27 +02:00
return account ;
2017-07-01 18:14:41 +02:00
}
2018-05-07 16:32:51 +02:00
2017-11-17 22:08:06 +01:00
/ * *
* Get the information from the last time a player logged in that previously used the shortened name
2018-05-07 16:32:51 +02:00
*
2017-11-17 22:08:06 +01:00
* @param shortName The name of the player to get the last account for
2018-05-07 16:32:51 +02:00
* @return The last account or < tt > null < / tt > if none was found
2019-05-07 00:49:16 +02:00
* @throws IllegalArgumentException if the username is empty
* @deprecated Use the { @link AccountQueryEvent } instead !
2017-11-17 22:08:06 +01:00
* /
2019-05-07 00:49:16 +02:00
@Deprecated
2017-11-17 22:08:06 +01:00
public static Account getLastAccountFromShortName ( String shortName ) {
Account account = getAccountFromShortName ( shortName ) ; // first get the account associated with the short name
if ( account ! = null ) {
return getAccount ( account . getUuid ( ) ) ; // then get the last account that was online with that UUID
}
return null ;
}
2017-07-01 18:14:41 +02:00
/ * *
* Get the UUID from a player ' s ( non - shortened ) username
2018-05-07 16:32:51 +02:00
*
* @param username The player ' s username
* @return The UUID or < tt > null < / tt > if the UUID can ' t be found or an error occurred
* @deprecated Use { @link NameManager # getAccount ( String ) }
2017-07-01 18:14:41 +02:00
* /
@Deprecated
public static UUID getUUID ( String username ) {
Validate . notEmpty ( username , " username cannot be null or empty! " ) ;
Player player = Bukkit . getPlayer ( username ) ;
if ( player ! = null ) {
return player . getUniqueId ( ) ;
}
Account account = getAccount ( username ) ;
if ( account ! = null ) {
return account . getUuid ( ) ;
}
OfflinePlayer offlinePlayer = Bukkit . getOfflinePlayer ( username ) ;
if ( offlinePlayer ! = null & & offlinePlayer . hasPlayedBefore ( ) & & offlinePlayer . getUniqueId ( ) ! = null ) {
return offlinePlayer . getUniqueId ( ) ;
}
return null ;
}
/ * *
* Get the username from a player ' s UUID
2018-05-07 16:32:51 +02:00
*
* @param uuid The UUID of the player
* @return The username that is stored or < tt > null < / tt > if none was found
* @deprecated Use { @link NameManager # getAccount ( UUID ) }
2017-07-01 18:14:41 +02:00
* /
@Deprecated
public static String getUsername ( UUID uuid ) {
Player player = Bukkit . getPlayer ( uuid ) ;
if ( player ! = null ) {
return player . getName ( ) ;
}
Account account = getAccount ( uuid ) ;
if ( account ! = null ) {
return account . getName ( ) ;
}
OfflinePlayer offlinePlayer = Bukkit . getOfflinePlayer ( uuid ) ;
if ( offlinePlayer ! = null & & offlinePlayer . hasPlayedBefore ( ) & & offlinePlayer . getName ( ) ! = null ) {
return offlinePlayer . getName ( ) ;
}
return null ;
}
/ * *
* Get the full username from another username that might be shortened
2018-05-07 16:32:51 +02:00
*
2017-07-01 18:14:41 +02:00
* @param shortName The name of the player to get the full username for
2018-05-07 16:32:51 +02:00
* @return The full username or < tt > null < / tt > if none was found
2017-07-01 18:14:41 +02:00
* @throws IllegalArgumentException if the username is not a shortened name and longer than 15 chars
2018-05-07 16:32:51 +02:00
* @deprecated Use { @link NameManager # getAccountFromShortName ( String ) }
2017-07-01 18:14:41 +02:00
* /
@Deprecated
public static String getFullUsername ( String shortName ) {
2019-05-07 00:49:16 +02:00
AccountQueryEvent accountQueryEvent = new AccountQueryEvent ( shortName ) ;
Bukkit . getPluginManager ( ) . callEvent ( accountQueryEvent ) ;
Account account = accountQueryEvent . getAccount ( ) ;
2017-07-01 18:14:41 +02:00
if ( account ! = null ) {
2017-11-17 22:08:06 +01:00
return account . getName ( ) ;
2014-04-06 19:51:47 +02:00
}
2017-07-01 18:14:41 +02:00
return null ;
}
/ * *
* Get the short username from a full username
2018-05-07 16:32:51 +02:00
*
* @param fullName The name of the player to get the short username for
* @return The short username or < tt > null < / tt > if none was found
* @deprecated Use { @link NameManager # getAccount ( String ) }
2017-07-01 18:14:41 +02:00
* /
@Deprecated
public static String getShortUsername ( String fullName ) {
Account account = getAccount ( fullName ) ;
return account ! = null ? account . getShortName ( ) : null ;
2014-05-06 11:55:33 +02:00
}
2014-04-06 19:51:47 +02:00
2017-06-30 21:28:18 +02:00
/ * *
* Store the username of a player into the database and the username - uuid cache
2018-05-07 16:32:51 +02:00
*
* @param player The data transfer object of the player to store
2018-08-29 22:29:27 +02:00
* @return The stored / updated account . < tt > null < / tt > if there was an error updating it
2017-06-30 21:28:18 +02:00
* /
2018-08-29 22:29:27 +02:00
public static Account storeUsername ( final PlayerDTO player ) {
2014-05-06 11:55:33 +02:00
final UUID uuid = player . getUniqueId ( ) ;
2014-04-06 19:51:47 +02:00
2017-06-30 21:28:18 +02:00
Account latestAccount = null ;
try {
2019-07-29 19:50:26 +02:00
latestAccount = accounts . queryBuilder ( ) . where ( ) . eq ( " uuid " , new SelectArg ( uuid ) ) . and ( ) . eq ( " name " , new SelectArg ( player . getName ( ) ) ) . queryForFirst ( ) ;
2017-06-30 21:28:18 +02:00
} catch ( SQLException e ) {
2017-06-30 22:00:30 +02:00
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Error while searching for latest account of " + player . getName ( ) + " / " + uuid + " : " , e ) ;
2017-06-30 21:28:18 +02:00
}
2015-07-05 21:56:42 +02:00
2017-06-30 21:28:18 +02:00
if ( latestAccount = = null ) {
2019-05-07 00:49:16 +02:00
latestAccount = new Account ( player . getName ( ) , getNewShortenedName ( player ) , player . getUniqueId ( ) ) ;
2015-03-11 18:02:30 +01:00
}
2014-05-06 11:55:33 +02:00
2017-07-01 18:14:41 +02:00
latestAccount . setLastSeen ( new Date ( ) ) ;
try {
accounts . createOrUpdate ( latestAccount ) ;
} catch ( SQLException e ) {
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Error while updating account " + latestAccount + " : " , e ) ;
2018-08-29 22:29:27 +02:00
return null ;
2017-07-01 18:14:41 +02:00
}
2015-03-11 18:02:30 +01:00
2017-07-01 18:14:41 +02:00
usernameToAccount . put ( latestAccount . getName ( ) , latestAccount ) ;
uuidToAccount . put ( uuid , latestAccount ) ;
shortToAccount . put ( latestAccount . getShortName ( ) , latestAccount ) ;
2018-08-29 22:29:27 +02:00
return latestAccount ;
2014-04-06 19:51:47 +02:00
}
2017-06-30 21:28:18 +02:00
/ * *
* Get a new unique shortened name that hasn ' t been used by another player yet
2018-05-07 16:32:51 +02:00
*
* @param player The player data to get the shortened name for
* @return A new shortened name that hasn ' t been used before and is a maximum of 15 chars long
2017-06-30 21:28:18 +02:00
* /
private static String getNewShortenedName ( PlayerDTO player ) {
String shortenedName = NameUtil . stripUsername ( player . getName ( ) ) ;
2014-07-03 18:49:12 +02:00
2018-08-31 14:55:36 +02:00
Account account = getAccountFromShortName ( shortenedName , false ) ;
2017-07-01 18:14:41 +02:00
if ( account = = null ) {
2017-06-30 21:28:18 +02:00
return shortenedName ;
2014-07-03 18:49:12 +02:00
}
2017-07-01 18:14:41 +02:00
for ( int id = 0 ; account ! = null ; id + + ) {
2017-06-30 21:28:18 +02:00
String baseId = Base62 . encode ( id ) ;
shortenedName = NameUtil . stripUsername ( player . getName ( ) , 15 - 1 - baseId . length ( ) ) + " : " + baseId ;
2018-08-31 14:55:36 +02:00
account = getAccountFromShortName ( shortenedName , false ) ;
2014-07-03 18:49:12 +02:00
}
2017-06-30 21:28:18 +02:00
return shortenedName ;
2014-07-03 18:49:12 +02:00
}
2018-11-19 21:10:48 +01:00
/ * *
* @deprecated Use { @link # canUseName ( Player , Permission , String ) } to provide specific information about how the player wants to use the name
* /
@Deprecated
2014-04-12 13:57:39 +02:00
public static boolean canUseName ( Player player , String name ) {
2018-11-19 21:10:48 +01:00
return canUseName ( player , OTHER_NAME , name ) ;
}
public static boolean canUseName ( Player player , Permission base , String name ) {
2015-03-21 16:11:33 +01:00
if ( ChestShopSign . isAdminShop ( name ) ) {
2018-11-19 21:10:48 +01:00
return Permission . has ( player , Permission . ADMIN_SHOP ) ;
2015-03-21 16:11:33 +01:00
}
2018-11-19 21:10:48 +01:00
if ( Permission . otherName ( player , base , name ) ) {
2017-07-01 18:14:41 +02:00
return true ;
}
2018-08-31 14:55:36 +02:00
Account account = getAccountFromShortName ( name , false ) ;
2017-09-26 16:39:08 +02:00
return account ! = null & & ( account . getUuid ( ) . equals ( player . getUniqueId ( ) )
2018-11-19 21:10:48 +01:00
| | ( ! account . getName ( ) . equalsIgnoreCase ( name ) & & Permission . otherName ( player , base , account . getName ( ) ) ) ) ;
2014-04-12 13:57:39 +02:00
}
2014-06-14 20:46:59 +02:00
public static boolean isAdminShop ( UUID uuid ) {
2017-10-29 23:50:24 +01:00
return adminAccount ! = null & & uuid . equals ( adminAccount . getUuid ( ) ) ;
}
public static boolean isServerEconomyAccount ( UUID uuid ) {
return serverEconomyAccount ! = null & & uuid . equals ( serverEconomyAccount . getUuid ( ) ) ;
2014-06-14 20:46:59 +02:00
}
2014-04-06 19:51:47 +02:00
public static void load ( ) {
2019-08-20 14:15:41 +02:00
if ( getUuidVersion ( ) < 0 & & ! Bukkit . getOnlinePlayers ( ) . isEmpty ( ) ) {
setUuidVersion ( Bukkit . getOnlinePlayers ( ) . iterator ( ) . next ( ) . getUniqueId ( ) . version ( ) ) ;
}
2014-04-06 19:51:47 +02:00
try {
2015-05-22 13:26:07 +02:00
accounts = DaoCreator . getDaoAndCreateTable ( Account . class ) ;
2014-04-12 16:52:21 +02:00
2017-10-29 23:50:24 +01:00
adminAccount = new Account ( Properties . ADMIN_SHOP_NAME , Bukkit . getOfflinePlayer ( Properties . ADMIN_SHOP_NAME ) . getUniqueId ( ) ) ;
2014-07-28 20:51:04 +02:00
accounts . createOrUpdate ( adminAccount ) ;
2017-07-09 18:00:31 +02:00
if ( ! Properties . SERVER_ECONOMY_ACCOUNT . isEmpty ( ) ) {
2017-10-29 23:50:24 +01:00
serverEconomyAccount = getAccount ( Properties . SERVER_ECONOMY_ACCOUNT ) ;
2020-04-27 22:00:46 +02:00
}
if ( serverEconomyAccount = = null & & ! Properties . SERVER_ECONOMY_ACCOUNT . isEmpty ( ) & & ! Properties . SERVER_ECONOMY_ACCOUNT_UUID . equals ( new UUID ( 0 , 0 ) ) ) {
serverEconomyAccount = getOrCreateAccount ( Properties . SERVER_ECONOMY_ACCOUNT_UUID , Properties . SERVER_ECONOMY_ACCOUNT ) ;
}
if ( serverEconomyAccount = = null | | serverEconomyAccount . getUuid ( ) = = null ) {
serverEconomyAccount = null ;
ChestShop . getBukkitLogger ( ) . log ( Level . WARNING , " Server economy account setting ' " + Properties . SERVER_ECONOMY_ACCOUNT + " ' doesn't seem to be the name of a known player! Please log in at least once in order for the server economy account to work. " ) ;
2017-07-09 18:00:31 +02:00
}
2014-04-10 21:52:05 +02:00
} catch ( SQLException e ) {
2014-04-06 19:51:47 +02:00
e . printStackTrace ( ) ;
}
}
2018-05-07 16:32:51 +02:00
2017-11-15 21:13:07 +01:00
public static Account getServerEconomyAccount ( ) {
return serverEconomyAccount ;
}
2018-05-07 16:32:51 +02:00
2018-08-29 22:29:27 +02:00
public static void setUuidVersion ( int uuidVersion ) {
NameManager . uuidVersion = uuidVersion ;
}
public static int getUuidVersion ( ) {
return uuidVersion ;
}
2014-04-06 19:51:30 +02:00
}