diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 49e0631c..788900a7 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -13,9 +13,9 @@ The actions that cause the issue This can be found by running `/pl` ### Environment description -Standalone server/Bungeecord network, SQLite/MySql, ... +Standalone server/Bungeecord network, SQLite/MySQL, ... -### Plugin version: +### Plugin version or build number (don't write latest): This can be found by running `/version plugin-name` ### Error Log: diff --git a/README.md b/README.md index 64982943..1089c1ab 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ So they don't need to enter passwords. This is also called auto login (auto-logi * fastlogin.command.import ### Requirements: -* Plugin: [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) or [ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/) +* Plugin: [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) or +[ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/) * [Spigot](https://www.spigotmc.org) 1.7+ * Java 8+ * Run Spigot and/or BungeeCord/Waterfall in offline mode (see server.properties or config.yml) @@ -77,5 +78,6 @@ Put your stats id from the BungeeCord config into this file 5. Download and Install FastLogin on BungeeCord AND Spigot 6. Check your database settings in the config of FastLogin on BungeeCord 7. Set your proxy (BungeeCord) in offline mode by setting the value onlinemode in your config.yml to false -8. You should *always* firewall your spigot server that it's only accessible through BungeeCord https://www.spigotmc.org/wiki/bungeecord-installation/#post-installation +8. You should *always* firewall your Spigot server that it's only accessible through BungeeCord +https://www.spigotmc.org/wiki/bungeecord-installation/#post-installation 9. (BungeeCord doesn't support SQLite per default, so you should change the configuration to MySQL or MariaDB) diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index d85b07c3..73e43581 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -2,8 +2,8 @@ package com.github.games647.fastlogin.bukkit; import com.github.games647.fastlogin.bukkit.commands.CrackedCommand; import com.github.games647.fastlogin.bukkit.commands.PremiumCommand; -import com.github.games647.fastlogin.bukkit.listener.JoinListener; import com.github.games647.fastlogin.bukkit.listener.BungeeListener; +import com.github.games647.fastlogin.bukkit.listener.JoinListener; import com.github.games647.fastlogin.bukkit.listener.protocollib.LoginSkinApplyListener; import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener; import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener; @@ -17,11 +17,11 @@ import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import com.google.common.net.HostAndPort; +import java.nio.file.Path; import java.security.KeyPair; import java.util.List; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ThreadFactory; -import java.util.logging.Level; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -188,6 +188,11 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin addresses, int requests, List proxies) { - return new MojangApiBukkit(getLog(), addresses, requests, proxies); + return new MojangApiBukkit(logger, addresses, requests, proxies); } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java index bef6f511..a104d6d6 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java @@ -12,7 +12,6 @@ import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.URLEncoder; import java.util.Collection; -import java.util.List; import org.slf4j.Logger; @@ -23,7 +22,7 @@ public class MojangApiBukkit extends MojangApiConnector { "username=%s&serverId=%s&ip=%s"; public MojangApiBukkit(Logger logger, Collection localAddresses, int rateLimit - , List proxies) { + , Iterable proxies) { super(logger, localAddresses, rateLimit, proxies); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java index c8ffd066..5e227f6b 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java @@ -93,9 +93,7 @@ public class CrazyLoginHook implements AuthPlugin { //create a fake account - this will be saved to the database with the password=FAILEDLOADING //user cannot login with that password unless the admin uses plain text //this automatically marks the player as logged in - playerData = new LoginPlayerData(player); - crazyDatabase.save(playerData); - + crazyDatabase.save(new LoginPlayerData(player)); return forceLogin(player); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java index ad0c0183..fb915044 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java @@ -6,6 +6,9 @@ import io.github.lucaseasedup.logit.CancelledState; import io.github.lucaseasedup.logit.LogItCore; import io.github.lucaseasedup.logit.account.Account; import io.github.lucaseasedup.logit.session.SessionManager; + +import java.time.Instant; + import org.bukkit.entity.Player; /** @@ -22,7 +25,6 @@ public class LogItHook implements AuthPlugin { SessionManager sessionManager = LogItCore.getInstance().getSessionManager(); return sessionManager.isSessionAlive(player) || sessionManager.startSession(player) == CancelledState.NOT_CANCELLED; - } @Override @@ -34,8 +36,10 @@ public class LogItHook implements AuthPlugin { public boolean forceRegister(Player player, String password) { Account account = new Account(player.getName()); account.changePassword(password); - account.setLastActiveDate(System.currentTimeMillis() / 1000); - account.setRegistrationDate(System.currentTimeMillis() / 1000); + + Instant now = Instant.now(); + account.setLastActiveDate(now.getEpochSecond()); + account.setRegistrationDate(now.getEpochSecond()); return LogItCore.getInstance().getAccountManager().insertAccount(account) == CancelledState.NOT_CANCELLED; } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java index 9978461c..bd747e3d 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java @@ -95,7 +95,7 @@ public class BungeeListener implements PluginMessageListener { } public Set loadBungeeCordIds() { - Path whitelistFile = plugin.getDataFolder().toPath().resolve(FILE_NAME); + Path whitelistFile = plugin.getPluginFolder().resolve(FILE_NAME); try { if (Files.notExists(whitelistFile)) { Files.createFile(whitelistFile); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index d207444b..a21e7f80 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -23,7 +23,8 @@ public class NameCheckTask extends JoinManagement addresses, int requests, List proxies) { - return new MojangApiConnector(getLog(), addresses, requests, proxies); + return new MojangApiConnector(logger, addresses, requests, proxies); } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java index 4bc6fee7..632e7d32 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java @@ -33,6 +33,7 @@ import net.md_5.bungee.event.EventPriority; public class ConnectListener implements Listener { private final FastLoginBungee plugin; + private final Property[] emptyProperties = {}; public ConnectListener(FastLoginBungee plugin) { this.plugin = plugin; @@ -89,7 +90,7 @@ public class ConnectListener implements Listener { //this is null on offline mode LoginResult loginProfile = initialHandler.getLoginProfile(); if (loginProfile != null) { - loginProfile.setProperties(new Property[]{}); + loginProfile.setProperties(emptyProperties); } } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java index 3f4f8c97..608b002b 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java @@ -42,7 +42,8 @@ public class AsyncPremiumCheck extends JoinManagement { +public class ForceLoginTask + extends ForceLoginManagement { private final Server server; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java index fcd08560..525019d9 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java @@ -1,7 +1,6 @@ package com.github.games647.fastlogin.core; import com.github.games647.fastlogin.core.shared.FastLoginCore; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; @@ -10,14 +9,24 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.time.Instant; import java.util.Properties; import java.util.UUID; import java.util.concurrent.ThreadFactory; +import static java.sql.Statement.RETURN_GENERATED_KEYS; + public class AuthStorage { private static final String PREMIUM_TABLE = "premium"; + private static final String LOAD_BY_NAME = "SELECT * FROM " + PREMIUM_TABLE + " WHERE Name=? LIMIT 1"; + private static final String LOAD_BY_UUID = "SELECT * FROM " + PREMIUM_TABLE + " WHERE UUID=? LIMIT 1"; + private static final String INSERT_PROFILE = "INSERT INTO " + PREMIUM_TABLE + " (UUID, Name, Premium, LastIp) " + + "VALUES (?, ?, ?, ?) "; + private static final String UPDATE_PROFILE = "UPDATE " + PREMIUM_TABLE + + " SET UUID=?, Name=?, Premium=?, LastIp=?, LastLogin=CURRENT_TIMESTAMP WHERE UserID=?"; + private final FastLoginCore core; private final HikariDataSource dataSource; @@ -38,22 +47,18 @@ public class AuthStorage { ThreadFactory platformThreadFactory = core.getPlugin().getThreadFactory(); if (platformThreadFactory != null) { - config.setThreadFactory(new ThreadFactoryBuilder() - .setNameFormat(core.getPlugin().getName() + " Database Pool Thread #%1$d") - //Hikari create daemons by default - .setDaemon(true) - .setThreadFactory(platformThreadFactory) - .build()); + config.setThreadFactory(platformThreadFactory); } - databasePath = databasePath.replace("{pluginDir}", core.getPlugin().getDataFolder().getAbsolutePath()); + String pluginFolder = core.getPlugin().getPluginFolder().toAbsolutePath().toString(); + databasePath = databasePath.replace("{pluginDir}", pluginFolder); String jdbcUrl = "jdbc:"; if (driver.contains("sqlite")) { - jdbcUrl += "sqlite" + "://" + databasePath; + jdbcUrl += "sqlite://" + databasePath; config.setConnectionTestQuery("SELECT 1"); } else { - jdbcUrl += "mysql" + "://" + host + ':' + port + '/' + databasePath; + jdbcUrl += "mysql://" + host + ':' + port + '/' + databasePath; } config.setJdbcUrl(jdbcUrl); @@ -84,8 +89,7 @@ public class AuthStorage { public PlayerProfile loadProfile(String name) { try (Connection con = dataSource.getConnection(); - PreparedStatement loadStmt = con.prepareStatement("SELECT * FROM " - + PREMIUM_TABLE + " WHERE Name=? LIMIT 1")) { + PreparedStatement loadStmt = con.prepareStatement(LOAD_BY_NAME)) { loadStmt.setString(1, name); try (ResultSet resultSet = loadStmt.executeQuery()) { @@ -96,7 +100,7 @@ public class AuthStorage { boolean premium = resultSet.getBoolean(4); String lastIp = resultSet.getString(5); - long lastLogin = resultSet.getTimestamp(6).getTime(); + Instant lastLogin = resultSet.getTimestamp(6).toInstant(); return new PlayerProfile(userId, uuid, name, premium, lastIp, lastLogin); } else { return new PlayerProfile(null, name, false, ""); @@ -111,8 +115,7 @@ public class AuthStorage { public PlayerProfile loadProfile(UUID uuid) { try (Connection con = dataSource.getConnection(); - PreparedStatement loadStmt = con.prepareStatement("SELECT * FROM " - + PREMIUM_TABLE + " WHERE UUID=? LIMIT 1")) { + PreparedStatement loadStmt = con.prepareStatement(LOAD_BY_UUID)) { loadStmt.setString(1, uuid.toString().replace("-", "")); try (ResultSet resultSet = loadStmt.executeQuery()) { @@ -122,7 +125,7 @@ public class AuthStorage { String name = resultSet.getString(3); boolean premium = resultSet.getBoolean(4); String lastIp = resultSet.getString(5); - long lastLogin = resultSet.getTimestamp(6).getTime(); + Instant lastLogin = resultSet.getTimestamp(6).toInstant(); return new PlayerProfile(userId, uuid, name, premium, lastIp, lastLogin); } } @@ -138,8 +141,7 @@ public class AuthStorage { UUID uuid = playerProfile.getUuid(); if (playerProfile.getUserId() == -1) { - try (PreparedStatement saveStmt = con.prepareStatement("INSERT INTO " + PREMIUM_TABLE - + " (UUID, Name, Premium, LastIp) VALUES (?, ?, ?, ?) ", Statement.RETURN_GENERATED_KEYS)) { + try (PreparedStatement saveStmt = con.prepareStatement(INSERT_PROFILE, RETURN_GENERATED_KEYS)) { if (uuid == null) { saveStmt.setString(1, null); } else { @@ -159,8 +161,7 @@ public class AuthStorage { } } } else { - try (PreparedStatement saveStmt = con.prepareStatement("UPDATE " + PREMIUM_TABLE - + " SET UUID=?, Name=?, Premium=?, LastIp=?, LastLogin=CURRENT_TIMESTAMP WHERE UserID=?")) { + try (PreparedStatement saveStmt = con.prepareStatement(UPDATE_PROFILE)) { if (uuid == null) { saveStmt.setString(1, null); } else { diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CompatibleCacheBuilder.java b/core/src/main/java/com/github/games647/fastlogin/core/CompatibleCacheBuilder.java index c093c88b..c3b2ae46 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/CompatibleCacheBuilder.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/CompatibleCacheBuilder.java @@ -136,8 +136,9 @@ public class CompatibleCacheBuilder { *

*

* When {@code size} is zero, elements will be evicted immediately after being loaded into the cache. This has the - * same effect as invoking {@link #expireAfterWrite expireAfterWrite}{@code (0, unit)} or {@link #expireAfterAccess expireAfterAccess}{@code (0, - * unit)}. It can be useful in testing, or to disable caching temporarily without a code change. + * same effect as invoking {@link #expireAfterWrite expireAfterWrite}{@code (0, unit)} or + * {@link #expireAfterAccess expireAfterAccess}{@code (0,unit)}. + * It can be useful in testing, or to disable caching temporarily without a code change. * * @param size the maximum size of the cache * @return This for chaining @@ -180,7 +181,8 @@ public class CompatibleCacheBuilder { * @throws IllegalStateException if a removal listener was already set */ @SuppressWarnings("unchecked") - public CompatibleCacheBuilder removalListener(RemovalListener listener) { + public CompatibleCacheBuilder removalListener( + RemovalListener listener) { builder.removalListener(listener); return (CompatibleCacheBuilder) this; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java index 160e5e55..410f4d41 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java @@ -1,5 +1,6 @@ package com.github.games647.fastlogin.core; +import java.time.Instant; import java.util.UUID; public class PlayerProfile { @@ -11,9 +12,9 @@ public class PlayerProfile { private UUID uuid; private boolean premium; private String lastIp; - private long lastLogin; + private Instant lastLogin; - public PlayerProfile(long userId, UUID uuid, String playerName, boolean premium, String lastIp, long lastLogin) { + public PlayerProfile(long userId, UUID uuid, String playerName, boolean premium, String lastIp, Instant lastLogin) { this.userId = userId; this.uuid = uuid; this.playerName = playerName; @@ -23,7 +24,7 @@ public class PlayerProfile { } public PlayerProfile(UUID uuid, String playerName, boolean premium, String lastIp) { - this(-1, uuid, playerName, premium, lastIp, System.currentTimeMillis()); + this(-1, uuid, playerName, premium, lastIp, Instant.now()); } public synchronized String getPlayerName() { @@ -66,11 +67,11 @@ public class PlayerProfile { this.lastIp = lastIp; } - public synchronized long getLastLogin() { + public synchronized Instant getLastLogin() { return lastLogin; } - public synchronized void setLastLogin(long lastLogin) { + public synchronized void setLastLogin(Instant lastLogin) { this.lastLogin = lastLogin; } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java index 9e30c38f..84f30580 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java @@ -3,7 +3,8 @@ package com.github.games647.fastlogin.core.hooks; /** * Represents a supporting authentication plugin in BungeeCord and Bukkit/Spigot/... servers * - * @param

either org.bukkit.entity.GameProfile for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer for BungeeCord + * @param

either org.bukkit.entity.GameProfile for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer + * for BungeeCord */ public interface AuthPlugin

{ diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java index 5b87e259..890828e7 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java @@ -20,6 +20,8 @@ import java.net.Proxy; import java.net.Proxy.Type; import java.net.URL; import java.net.UnknownHostException; +import java.time.Duration; +import java.time.Instant; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -53,7 +55,7 @@ public class MojangApiConnector { private final SSLSocketFactory sslFactory; private final int rateLimit; - private long lastRateLimit; + private Instant lastRateLimit; protected final Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); protected final Logger logger; @@ -72,9 +74,6 @@ public class MojangApiConnector { this.proxies = Iterables.cycle(proxyBuilder).iterator(); } - /** - * @return null on non-premium - */ public Optional getPremiumUUID(String playerName) { if (!validNameMatcher.matcher(playerName).matches()) { //check if it's a valid player name @@ -83,7 +82,7 @@ public class MojangApiConnector { try { HttpsURLConnection connection; - if (requests.size() >= rateLimit || System.currentTimeMillis() - lastRateLimit < 1_000 * 60 * 10) { + if (requests.size() >= rateLimit || Duration.between(lastRateLimit, Instant.now()).getSeconds() < 60 * 10) { synchronized (proxies) { if (proxies.hasNext()) { connection = getConnection(UUID_LINK + playerName, proxies.next()); @@ -103,7 +102,7 @@ public class MojangApiConnector { } } else if (connection.getResponseCode() == RATE_LIMIT_CODE) { logger.info("RATE_LIMIT REACHED"); - lastRateLimit = System.currentTimeMillis(); + lastRateLimit = Instant.now(); if (!connection.usingProxy()) { return getPremiumUUID(playerName); } @@ -153,25 +152,25 @@ public class MojangApiConnector { } private SSLSocketFactory buildAddresses(Logger logger, Collection localAddresses) { - if (localAddresses.isEmpty()) { + if (!localAddresses.isEmpty()) { return HttpsURLConnection.getDefaultSSLSocketFactory(); - } else { - Set addresses = Sets.newHashSet(); - for (String localAddress : localAddresses) { - try { - InetAddress address = InetAddress.getByName(localAddress); - if (!address.isAnyLocalAddress()) { - logger.warn("Submitted IP-Address is not local {0}", address); - continue; - } - - addresses.add(address); - } catch (UnknownHostException ex) { - logger.error("IP-Address is unknown to us", ex); - } - } - - return new BalancedSSLFactory(HttpsURLConnection.getDefaultSSLSocketFactory(), addresses); } + + Set addresses = Sets.newHashSet(); + for (String localAddress : localAddresses) { + try { + InetAddress address = InetAddress.getByName(localAddress); + if (!address.isAnyLocalAddress()) { + logger.warn("Submitted IP-Address is not local {}", address); + continue; + } + + addresses.add(address); + } catch (UnknownHostException ex) { + logger.error("IP-Address is unknown to us", ex); + } + } + + return new BalancedSSLFactory(HttpsURLConnection.getDefaultSSLSocketFactory(), addresses); } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java index e10752ee..4fe6c766 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java @@ -2,13 +2,11 @@ package com.github.games647.fastlogin.core.mojang; public class SkinProperties { + private final String name = "textures"; + private String value; private String signature; - public String getName() { - return "textures"; - } - public String getValue() { return value; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java index 562ae223..8be2581a 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java @@ -11,18 +11,10 @@ import java.util.UUID; public class UUIDTypeAdapter extends TypeAdapter { public void write(JsonWriter out, UUID value) throws IOException { - out.value(fromUUID(value)); + out.value(value.toString().replace("-", "")); } public UUID read(JsonReader in) throws IOException { - return fromString(in.nextString()); - } - - public static String fromUUID(UUID value) { - return value.toString().replace("-", ""); - } - - public static UUID fromString(String input) { - return CommonUtil.parseId(input); + return CommonUtil.parseId(in.nextString()); } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index 253dd19d..23855c5b 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -90,7 +90,7 @@ public class FastLoginCore

> { defaults = configProvider.load(defaultStream); } - File file = new File(plugin.getDataFolder(), fileName); + File file = plugin.getPluginFolder().resolve(fileName).toFile(); return configProvider.load(file, defaults); } @@ -167,7 +167,7 @@ public class FastLoginCore

> { } public void saveDefaultFile(String fileName) { - Path dataFolder = plugin.getDataFolder().toPath(); + Path dataFolder = plugin.getPluginFolder(); try { Files.createDirectories(dataFolder); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java index 8e90bd8a..76ebf32d 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java @@ -3,7 +3,7 @@ package com.github.games647.fastlogin.core.shared; import com.github.games647.fastlogin.core.mojang.MojangApiConnector; import com.google.common.net.HostAndPort; -import java.io.File; +import java.nio.file.Path; import java.util.List; import java.util.concurrent.ThreadFactory; @@ -13,7 +13,7 @@ public interface PlatformPlugin { String getName(); - File getDataFolder(); + Path getPluginFolder(); Logger getLog(); diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index f73e6f52..ab305d39 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -62,8 +62,8 @@ premiumUuid: false # #### Case 1 # nameChangeCheck = false ----- autoRegister = false # -# GameProfile logins as cracked until the player invoked the command /premium. Then we could override the existing database -# record. +# GameProfile logins as cracked until the player invoked the command /premium. Then we could override the existing +# database record. # # #### Case 2 # @@ -128,8 +128,8 @@ premium-warning: true # Once the limit is reached, new players are always logged in as cracked until the rate-limit is expired. # (to the next ten minutes) # -# The limit is IP-wide. If you have multiple IPv4-addresses you specify them here. FastLogin will then use it in rotating -# order --> 5 different IP-addresses 5 * 600 per 10 minutes +# The limit is IP-wide. If you have multiple IPv4-addresses you specify them here. FastLogin will then use it in +# rotating order --> 5 different IP-addresses 5 * 600 per 10 minutes # If this list is empty only the default one will be used # # Lists are created like this: diff --git a/core/src/main/resources/messages.yml b/core/src/main/resources/messages.yml index 34643086..ba4b95df 100644 --- a/core/src/main/resources/messages.yml +++ b/core/src/main/resources/messages.yml @@ -86,7 +86,7 @@ invalid-session: '&4Invalid session' # The client sent a malicious packet without a login request packet invalid-requst: '&4Invalid request' -# Message if the bukkit isn't fully started to inject the packets +# Message if the Bukkit isn't fully started to inject the packets not-started: '&cServer is not fully started yet. Please retry' # Warning message if a user invoked /premium command