Drop support for deprecated AuthMe API

This commit is contained in:
games647
2017-09-12 17:05:18 +02:00
parent ca58c55eca
commit 7839804a4c
13 changed files with 63 additions and 107 deletions

View File

@@ -46,9 +46,9 @@ So they don't need to enter passwords. This is also called auto login (auto-logi
#### Bukkit/Spigot/Paper #### Bukkit/Spigot/Paper
* [AuthMe (both 5.X)](https://dev.bukkit.org/bukkit-plugins/authme-reloaded/) * [AuthMe (5.X)](https://dev.bukkit.org/bukkit-plugins/authme-reloaded/)
* [xAuth](https://dev.bukkit.org/bukkit-plugins/xauth/) * [xAuth](https://dev.bukkit.org/bukkit-plugins/xauth/)
* [LogIt](https://github.com/XziomekX/LogIt) * [LogIt](https://github.com/games647/LogIt)
* [AdvancedLogin (Paid)](https://www.spigotmc.org/resources/advancedlogin.10510/) * [AdvancedLogin (Paid)](https://www.spigotmc.org/resources/advancedlogin.10510/)
* [CrazyLogin](https://dev.bukkit.org/bukkit-plugins/crazylogin/) * [CrazyLogin](https://dev.bukkit.org/bukkit-plugins/crazylogin/)
* [LoginSecurity](https://dev.bukkit.org/bukkit-plugins/loginsecurity/) * [LoginSecurity](https://dev.bukkit.org/bukkit-plugins/loginsecurity/)

View File

@@ -2,72 +2,42 @@ package com.github.games647.fastlogin.bukkit.hooks;
import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
* Github: https://github.com/Xephi/AuthMeReloaded/ * Github: https://github.com/Xephi/AuthMeReloaded/
* * <p>
* Project page: * Project page:
* * <p>
* Bukkit: https://dev.bukkit.org/bukkit-plugins/authme-reloaded/ * Bukkit: https://dev.bukkit.org/bukkit-plugins/authme-reloaded/
* * <p>
* Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/ * Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/
*/ */
public class AuthMeHook implements AuthPlugin<Player> { public class AuthMeHook implements AuthPlugin<Player> {
private final boolean v3APIAvailable;
public AuthMeHook() {
boolean apiAvailable = true;
try {
Class.forName("fr.xephi.authme.api.v3.AuthMeApi");
} catch (ClassNotFoundException classNotFoundEx) {
apiAvailable = false;
}
this.v3APIAvailable = apiAvailable;
}
@Override @Override
public boolean forceLogin(Player player) { public boolean forceLogin(Player player) {
if (v3APIAvailable) {
//skips registration and login //skips registration and login
if (AuthMeApi.getInstance().isAuthenticated(player)) { if (AuthMeApi.getInstance().isAuthenticated(player)) {
return false; return false;
} else { } else {
AuthMeApi.getInstance().forceLogin(player); AuthMeApi.getInstance().forceLogin(player);
} }
} else {
//skips registration and login
if (NewAPI.getInstance().isAuthenticated(player)) {
return false;
} else {
NewAPI.getInstance().forceLogin(player);
}
}
return true; return true;
} }
@Override @Override
public boolean isRegistered(String playerName) throws Exception { public boolean isRegistered(String playerName) throws Exception {
if (v3APIAvailable) {
return AuthMeApi.getInstance().isRegistered(playerName); return AuthMeApi.getInstance().isRegistered(playerName);
} }
return NewAPI.getInstance().isRegistered(playerName);
}
@Override @Override
public boolean forceRegister(Player player, String password) { public boolean forceRegister(Player player, String password) {
//this automatically registers the player too //this automatically registers the player too
if (v3APIAvailable) {
AuthMeApi.getInstance().forceRegister(player, password); AuthMeApi.getInstance().forceRegister(player, password);
} else {
NewAPI.getInstance().forceRegister(player, password);
}
return true; return true;
} }

View File

@@ -21,7 +21,7 @@ import org.bukkit.entity.Player;
* *
* Project page: * Project page:
* *
* Bukkits: http://dev.bukkit.org/server-mods/crazylogin/ * Bukkit: https://dev.bukkit.org/server-mods/crazylogin/
*/ */
public class CrazyLoginHook implements AuthPlugin<Player> { public class CrazyLoginHook implements AuthPlugin<Player> {

View File

@@ -8,8 +8,8 @@ import com.lenis0012.bukkit.loginsecurity.session.PlayerSession;
import com.lenis0012.bukkit.loginsecurity.session.action.LoginAction; import com.lenis0012.bukkit.loginsecurity.session.action.LoginAction;
import com.lenis0012.bukkit.loginsecurity.session.action.RegisterAction; import com.lenis0012.bukkit.loginsecurity.session.action.RegisterAction;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
/** /**
* Github: https://github.com/lenis0012/LoginSecurity-2 Project page: * Github: https://github.com/lenis0012/LoginSecurity-2 Project page:
@@ -19,7 +19,7 @@ import org.bukkit.entity.Player;
*/ */
public class LoginSecurityHook implements AuthPlugin<Player> { public class LoginSecurityHook implements AuthPlugin<Player> {
private final FastLoginBukkit plugin = (FastLoginBukkit) Bukkit.getPluginManager().getPlugin("FastLogin"); private final FastLoginBukkit plugin = JavaPlugin.getPlugin(FastLoginBukkit.class);
@Override @Override
public boolean forceLogin(Player player) { public boolean forceLogin(Player player) {

View File

@@ -16,7 +16,7 @@ import ultraauth.managers.PlayerManager;
/** /**
* Project page: * Project page:
* *
* Bukkit: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/ * Bukkit: https://dev.bukkit.org/bukkit-plugins/ultraauth-aa/
* *
* Spigot: https://www.spigotmc.org/resources/ultraauth.17044/ * Spigot: https://www.spigotmc.org/resources/ultraauth.17044/
*/ */

View File

@@ -41,7 +41,7 @@ public class ProtocolLibLoginSource implements LoginSource {
@Override @Override
public void setOnlineMode() throws Exception { public void setOnlineMode() throws Exception {
//randomized server id to make sure the request is for our server //randomized server id to make sure the request is for our server
//this could be relevant http://www.sk89q.com/2011/09/minecraft-name-spoofing-exploit/ //this could be relevant https://www.sk89q.com/2011/09/minecraft-name-spoofing-exploit/
serverId = Long.toString(random.nextLong(), 16); serverId = Long.toString(random.nextLong(), 16);
verifyToken = EncryptionUtil.generateVerifyToken(random); verifyToken = EncryptionUtil.generateVerifyToken(random);
@@ -72,7 +72,7 @@ public class ProtocolLibLoginSource implements LoginSource {
private void sentEncryptionRequest() throws InvocationTargetException { private void sentEncryptionRequest() throws InvocationTargetException {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
/** /*
* Packet Information: http://wiki.vg/Protocol#Encryption_Request * Packet Information: http://wiki.vg/Protocol#Encryption_Request
* *
* ServerID="" (String) key=public server key verifyToken=random 4 byte array * ServerID="" (String) key=public server key verifyToken=random 4 byte array

View File

@@ -91,7 +91,7 @@ public class VerifyResponseTask implements Runnable {
} }
//this makes sure the request from the client is for us //this makes sure the request from the client is for us
//this might be r https://www.sk89q.com/2011/09/minecraft-name-spoofing-exploit/ //this might be relevant https://www.sk89q.com/2011/09/minecraft-name-spoofing-exploit/
String generatedId = session.getServerId(); String generatedId = session.getServerId();
String serverId = EncryptionUtil.getServerIdHashString(generatedId, loginKey, publicKey); String serverId = EncryptionUtil.getServerIdHashString(generatedId, loginKey, publicKey);
@@ -141,7 +141,7 @@ public class VerifyResponseTask implements Runnable {
} }
//try to get the networkManager from ProtocolLib //try to get the networkManager from ProtocolLib
private Object getNetworkManager() throws IllegalAccessException, NoSuchFieldException, ClassNotFoundException { private Object getNetworkManager() throws IllegalAccessException, ClassNotFoundException {
Object injectorContainer = TemporaryPlayerFactory.getInjectorFromPlayer(player); Object injectorContainer = TemporaryPlayerFactory.getInjectorFromPlayer(player);
//ChannelInjector //ChannelInjector

View File

@@ -53,7 +53,7 @@ public class DelayedAuthHook implements Runnable {
for (Class<? extends AuthPlugin<Player>> clazz : supportedHooks) { for (Class<? extends AuthPlugin<Player>> clazz : supportedHooks) {
String pluginName = clazz.getSimpleName().replace("Hook", ""); String pluginName = clazz.getSimpleName().replace("Hook", "");
//uses only member classes which uses AuthPlugin interface (skip interfaces) //uses only member classes which uses AuthPlugin interface (skip interfaces)
if (Bukkit.getServer().getPluginManager().getPlugin(pluginName) != null) { if (Bukkit.getServer().getPluginManager().isPluginEnabled(pluginName)) {
//check only for enabled plugins. A single plugin could be disabled by plugin managers //check only for enabled plugins. A single plugin could be disabled by plugin managers
authPluginHook = clazz.newInstance(); authPluginHook = clazz.newInstance();
plugin.getLogger().log(Level.INFO, "Hooking into auth plugin: {0}", pluginName); plugin.getLogger().log(Level.INFO, "Hooking into auth plugin: {0}", pluginName);

View File

@@ -1,7 +1,7 @@
# project data for Bukkit in order to register our plugin with all it components # project data for Bukkit in order to register our plugin with all it components
# ${-} are variables from Maven (pom.xml) which will be replaced after the build # ${-} are variables from Maven (pom.xml) which will be replaced after the build
name: ${project.parent.name} name: ${project.parent.name}
version: ${project.version}-git${git.commit.id} version: ${project.version}-${git.commit.id.abbrev}
main: ${project.groupId}.${project.artifactId}.${project.name} main: ${project.groupId}.${project.artifactId}.${project.name}
# meta data for plugin managers # meta data for plugin managers

View File

@@ -5,7 +5,7 @@ name: ${project.parent.name}
# ${-} will be automatically replaced by Maven # ${-} will be automatically replaced by Maven
main: ${project.groupId}.${project.artifactId}.${project.name} main: ${project.groupId}.${project.artifactId}.${project.name}
version: ${project.version}-git${git.commit.id} version: ${project.version}-${git.commit.id.abbrev}
author: games647, https://github.com/games647/FastLogin/graphs/contributors author: games647, https://github.com/games647/FastLogin/graphs/contributors
softDepends: softDepends:

View File

@@ -22,7 +22,6 @@ public class CompatibleCacheBuilder<K, V> {
* *
* @param <K> Key type * @param <K> Key type
* @param <V> Value type * @param <V> Value type
*
* @return A new cache builder. * @return A new cache builder.
*/ */
public static <K, V> CompatibleCacheBuilder<K, V> newBuilder() { public static <K, V> CompatibleCacheBuilder<K, V> newBuilder() {
@@ -46,14 +45,13 @@ public class CompatibleCacheBuilder<K, V> {
* much noticeable impact. A value of one permits only one thread to modify the cache at a time, but since read * much noticeable impact. A value of one permits only one thread to modify the cache at a time, but since read
* operations can proceed concurrently, this still yields higher concurrency than full synchronization. Defaults to * operations can proceed concurrently, this still yields higher concurrency than full synchronization. Defaults to
* 4. * 4.
* * <p>
* <p> * <p>
* <b>Note:</b>The default may change in the future. If you care about this value, you should always choose it * <b>Note:</b>The default may change in the future. If you care about this value, you should always choose it
* explicitly. * explicitly.
* *
* @param concurrencyLevel New concurrency level * @param concurrencyLevel New concurrency level
* @return This for chaining * @return This for chaining
*
* @throws IllegalArgumentException if {@code concurrencyLevel} is non-positive * @throws IllegalArgumentException if {@code concurrencyLevel} is non-positive
* @throws IllegalStateException if a concurrency level was already set * @throws IllegalStateException if a concurrency level was already set
*/ */
@@ -67,12 +65,12 @@ public class CompatibleCacheBuilder<K, V> {
* the entry's creation, or last access. Access time is reset by * the entry's creation, or last access. Access time is reset by
* {@link com.google.common.cache.Cache#get Cache.get()}, but not by operations on the view returned by * {@link com.google.common.cache.Cache#get Cache.get()}, but not by operations on the view returned by
* {@link com.google.common.cache.Cache#asMap() Cache.asMap()}. * {@link com.google.common.cache.Cache#asMap() Cache.asMap()}.
* * <p>
* <p> * <p>
* When {@code duration} is zero, elements will be evicted immediately after being loaded into the cache. This has * When {@code duration} is zero, elements will be evicted immediately after being loaded into the cache. This has
* the same effect as invoking {@link #maximumSize maximumSize}{@code (0)}. It can be useful in testing, or to * the same effect as invoking {@link #maximumSize maximumSize}{@code (0)}. It can be useful in testing, or to
* disable caching temporarily without a code change. * disable caching temporarily without a code change.
* * <p>
* <p> * <p>
* Expired entries may be counted by {@link com.google.common.cache.Cache#size Cache.size()}, but will never be * Expired entries may be counted by {@link com.google.common.cache.Cache#size Cache.size()}, but will never be
* visible to read or write operations. Expired entries are currently cleaned up during write operations, or during * visible to read or write operations. Expired entries are currently cleaned up during write operations, or during
@@ -81,7 +79,6 @@ public class CompatibleCacheBuilder<K, V> {
* @param duration the length of time after an entry is last accessed that it should be automatically removed * @param duration the length of time after an entry is last accessed that it should be automatically removed
* @param unit the unit that {@code duration} is expressed in * @param unit the unit that {@code duration} is expressed in
* @return This for chaining * @return This for chaining
*
* @throws IllegalArgumentException if {@code duration} is negative * @throws IllegalArgumentException if {@code duration} is negative
* @throws IllegalStateException if the time to idle or time to live was already set * @throws IllegalStateException if the time to idle or time to live was already set
*/ */
@@ -93,12 +90,12 @@ public class CompatibleCacheBuilder<K, V> {
/** /**
* Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after * Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after
* the entry's creation, or the most recent replacement of its value. * the entry's creation, or the most recent replacement of its value.
* * <p>
* <p> * <p>
* When {@code duration} is zero, elements will be evicted immediately after being loaded into the cache. This has * When {@code duration} is zero, elements will be evicted immediately after being loaded into the cache. This has
* the same effect as invoking {@link #maximumSize maximumSize}{@code (0)}. It can be useful in testing, or to * the same effect as invoking {@link #maximumSize maximumSize}{@code (0)}. It can be useful in testing, or to
* disable caching temporarily without a code change. * disable caching temporarily without a code change.
* * <p>
* <p> * <p>
* Expired entries may be counted by {@link com.google.common.cache.Cache#size Cache.size()}, but will never be * Expired entries may be counted by {@link com.google.common.cache.Cache#size Cache.size()}, but will never be
* visible to read or write operations. Expired entries are currently cleaned up during write operations, or during * visible to read or write operations. Expired entries are currently cleaned up during write operations, or during
@@ -107,7 +104,6 @@ public class CompatibleCacheBuilder<K, V> {
* @param duration the length of time after an entry is created that it should be automatically removed * @param duration the length of time after an entry is created that it should be automatically removed
* @param unit the unit that {@code duration} is expressed in * @param unit the unit that {@code duration} is expressed in
* @return This for chaining * @return This for chaining
*
* @throws IllegalArgumentException if {@code duration} is negative * @throws IllegalArgumentException if {@code duration} is negative
* @throws IllegalStateException if the time to live or time to idle was already set * @throws IllegalStateException if the time to live or time to idle was already set
*/ */
@@ -124,7 +120,6 @@ public class CompatibleCacheBuilder<K, V> {
* *
* @param initialCapacity - initial capacity * @param initialCapacity - initial capacity
* @return This for chaining * @return This for chaining
*
* @throws IllegalArgumentException if {@code initialCapacity} is negative * @throws IllegalArgumentException if {@code initialCapacity} is negative
* @throws IllegalStateException if an initial capacity was already set * @throws IllegalStateException if an initial capacity was already set
*/ */
@@ -138,7 +133,7 @@ public class CompatibleCacheBuilder<K, V> {
* this limit is exceeded</b>. As the cache size grows close to the maximum, the cache evicts entries that are less * this limit is exceeded</b>. As the cache size grows close to the maximum, the cache evicts entries that are less
* likely to be used again. For example, the cache may evict an entry because it hasn't been used recently or very * likely to be used again. For example, the cache may evict an entry because it hasn't been used recently or very
* often. * often.
* * <p>
* <p> * <p>
* When {@code size} is zero, elements will be evicted immediately after being loaded into the cache. This has the * 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, * same effect as invoking {@link #expireAfterWrite expireAfterWrite}{@code (0, unit)} or {@link #expireAfterAccess expireAfterAccess}{@code (0,
@@ -146,7 +141,6 @@ public class CompatibleCacheBuilder<K, V> {
* *
* @param size the maximum size of the cache * @param size the maximum size of the cache
* @return This for chaining * @return This for chaining
*
* @throws IllegalArgumentException if {@code size} is negative * @throws IllegalArgumentException if {@code size} is negative
* @throws IllegalStateException if a maximum size was already set * @throws IllegalStateException if a maximum size was already set
*/ */
@@ -158,13 +152,13 @@ public class CompatibleCacheBuilder<K, V> {
/** /**
* Specifies a listener instance, which all caches built using this {@code CacheBuilder} will notify each time an * Specifies a listener instance, which all caches built using this {@code CacheBuilder} will notify each time an
* entry is removed from the cache by any means. * entry is removed from the cache by any means.
* * <p>
* <p> * <p>
* Each cache built by this {@code CacheBuilder} after this method is called invokes the supplied listener after * Each cache built by this {@code CacheBuilder} after this method is called invokes the supplied listener after
* removing an element for any reason (see removal causes in * removing an element for any reason (see removal causes in
* {@link com.google.common.cache.RemovalCause RemovalCause}). It will invoke the listener during invocations of any * {@link com.google.common.cache.RemovalCause RemovalCause}). It will invoke the listener during invocations of any
* of that cache's public methods (even read-only methods). * of that cache's public methods (even read-only methods).
* * <p>
* <p> * <p>
* <b>Important note:</b> Instead of returning <em>this</em> as a {@code CacheBuilder} instance, this method returns * <b>Important note:</b> Instead of returning <em>this</em> as a {@code CacheBuilder} instance, this method returns
* {@code CacheBuilder<K1, V1>}. From this point on, either the original reference or the returned reference may be * {@code CacheBuilder<K1, V1>}. From this point on, either the original reference or the returned reference may be
@@ -173,7 +167,7 @@ public class CompatibleCacheBuilder<K, V> {
* the listener already provided; the {@code CacheBuilder} type cannot do this. For best results, simply use the * the listener already provided; the {@code CacheBuilder} type cannot do this. For best results, simply use the
* standard method-chaining idiom, as illustrated in the documentation at top, configuring a {@code CacheBuilder} * standard method-chaining idiom, as illustrated in the documentation at top, configuring a {@code CacheBuilder}
* and building your {@link com.google.common.cache.Cache Cache} all in a single statement. * and building your {@link com.google.common.cache.Cache Cache} all in a single statement.
* * <p>
* <p> * <p>
* <b>Warning:</b> if you ignore the above advice, and use this {@code CacheBuilder} to build a cache whose key or * <b>Warning:</b> if you ignore the above advice, and use this {@code CacheBuilder} to build a cache whose key or
* value type is incompatible with the listener, you will likely experience a {@link ClassCastException} at some * value type is incompatible with the listener, you will likely experience a {@link ClassCastException} at some
@@ -183,7 +177,6 @@ public class CompatibleCacheBuilder<K, V> {
* @param <V1> Value type * @param <V1> Value type
* @param listener - removal listener * @param listener - removal listener
* @return This for chaining * @return This for chaining
*
* @throws IllegalStateException if a removal listener was already set * @throws IllegalStateException if a removal listener was already set
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -195,14 +188,13 @@ public class CompatibleCacheBuilder<K, V> {
/** /**
* Specifies a nanosecond-precision time source for use in determining when entries should be expired. By default, * Specifies a nanosecond-precision time source for use in determining when entries should be expired. By default,
* {@link System#nanoTime} is used. * {@link System#nanoTime} is used.
* * <p>
* <p> * <p>
* The primary intent of this method is to facilitate testing of caches which have been configured with * The primary intent of this method is to facilitate testing of caches which have been configured with
* {@link #expireAfterWrite} or {@link #expireAfterAccess}. * {@link #expireAfterWrite} or {@link #expireAfterAccess}.
* *
* @param ticker - ticker * @param ticker - ticker
* @return This for chaining * @return This for chaining
*
* @throws IllegalStateException if a ticker was already set * @throws IllegalStateException if a ticker was already set
*/ */
public CompatibleCacheBuilder<K, V> ticker(Ticker ticker) { public CompatibleCacheBuilder<K, V> ticker(Ticker ticker) {
@@ -215,18 +207,17 @@ public class CompatibleCacheBuilder<K, V> {
* {@link java.lang.ref.SoftReference SoftReference} (by default, strong references are used). Softly-referenced * {@link java.lang.ref.SoftReference SoftReference} (by default, strong references are used). Softly-referenced
* objects will be garbage-collected in a <i>globally</i> * objects will be garbage-collected in a <i>globally</i>
* least-recently-used manner, in response to memory demand. * least-recently-used manner, in response to memory demand.
* * <p>
* <p> * <p>
* <b>Warning:</b> in most circumstances it is better to set a per-cache {@linkplain #maximumSize maximum size} * <b>Warning:</b> in most circumstances it is better to set a per-cache {@linkplain #maximumSize maximum size}
* instead of using soft references. You should only use this method if you are well familiar with the practical * instead of using soft references. You should only use this method if you are well familiar with the practical
* consequences of soft references. * consequences of soft references.
* * <p>
* <p> * <p>
* <b>Note:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to determine * <b>Note:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to determine
* equality of values. * equality of values.
* *
* @return This for chaining * @return This for chaining
*
* @throws IllegalStateException if the value strength was already set * @throws IllegalStateException if the value strength was already set
*/ */
public CompatibleCacheBuilder<K, V> softValues() { public CompatibleCacheBuilder<K, V> softValues() {
@@ -237,13 +228,12 @@ public class CompatibleCacheBuilder<K, V> {
/** /**
* Specifies that each key (not value) stored in the cache should be wrapped in a * Specifies that each key (not value) stored in the cache should be wrapped in a
* {@link java.lang.ref.WeakReference WeakReference} (by default, strong references are used). * {@link java.lang.ref.WeakReference WeakReference} (by default, strong references are used).
* * <p>
* <p> * <p>
* <b>Warning:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to * <b>Warning:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to
* determine equality of keys. * determine equality of keys.
* *
* @return This for chaining * @return This for chaining
*
* @throws IllegalStateException if the key strength was already set * @throws IllegalStateException if the key strength was already set
*/ */
public CompatibleCacheBuilder<K, V> weakKeys() { public CompatibleCacheBuilder<K, V> weakKeys() {
@@ -254,17 +244,16 @@ public class CompatibleCacheBuilder<K, V> {
/** /**
* Specifies that each value (not key) stored in the cache should be wrapped in a * Specifies that each value (not key) stored in the cache should be wrapped in a
* {@link java.lang.ref.WeakReference WeakReference} (by default, strong references are used). * {@link java.lang.ref.WeakReference WeakReference} (by default, strong references are used).
* * <p>
* <p> * <p>
* Weak values will be garbage collected once they are weakly reachable. This makes them a poor candidate for * Weak values will be garbage collected once they are weakly reachable. This makes them a poor candidate for
* caching; consider {@link #softValues} instead. * caching; consider {@link #softValues} instead.
* * <p>
* <p> * <p>
* <b>Note:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to determine * <b>Note:</b> when this method is used, the resulting cache will use identity ({@code ==}) comparison to determine
* equality of values. * equality of values.
* *
* @return This for chaining * @return This for chaining
*
* @throws IllegalStateException if the value strength was already set * @throws IllegalStateException if the value strength was already set
*/ */
public CompatibleCacheBuilder<K, V> weakValues() { public CompatibleCacheBuilder<K, V> weakValues() {

View File

@@ -203,11 +203,15 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
} }
public void saveDefaultFile(String fileName) { public void saveDefaultFile(String fileName) {
if (!plugin.getDataFolder().exists()) { Path dataFolder = plugin.getDataFolder().toPath();
plugin.getDataFolder().mkdir();
try {
Files.createDirectories(dataFolder);
} catch (IOException ioExc) {
plugin.getLogger().log(Level.SEVERE, "Cannot create plugin folder " + dataFolder, ioExc);
} }
Path configFile = plugin.getDataFolder().toPath().resolve(fileName); Path configFile = dataFolder.resolve(fileName);
if (Files.notExists(configFile)) { if (Files.notExists(configFile)) {
InputStream in = getClass().getClassLoader().getResourceAsStream(fileName); InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
try { try {

17
pom.xml
View File

@@ -17,9 +17,12 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--Possibility to deploy directly to the plugins folder-->
<outputDir>${basedir}/target</outputDir> <!-- Set default for non-git clones -->
<git.commit.id>Unknown</git.commit.id> <git.commit.id>Unknown</git.commit.id>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<modules> <modules>
@@ -35,16 +38,6 @@
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>pl.project13.maven</groupId> <groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId> <artifactId>git-commit-id-plugin</artifactId>