mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-02 05:58:08 +01:00
Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 411-forced-commands
This commit is contained in:
commit
1370352679
@ -1,5 +1,5 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
||||||
<!-- File auto-generated on Sun Oct 23 18:25:14 CEST 2016. See docs/translations/translations.tpl.md -->
|
<!-- File auto-generated on Sat Nov 19 11:44:25 CET 2016. See docs/translations/translations.tpl.md -->
|
||||||
|
|
||||||
# AuthMe Translations
|
# AuthMe Translations
|
||||||
The following translations are available in AuthMe. Set `messagesLanguage` to the language code
|
The following translations are available in AuthMe. Set `messagesLanguage` to the language code
|
||||||
@ -9,7 +9,7 @@ Code | Language | Translated |
|
|||||||
---- | -------- | ---------: | ------
|
---- | -------- | ---------: | ------
|
||||||
[en](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_en.yml) | English | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
[en](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_en.yml) | English | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
||||||
[bg](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_bg.yml) | Bulgarian | 71% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=71&h=5&txtpad=1" alt="bar" />
|
[bg](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_bg.yml) | Bulgarian | 71% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=71&h=5&txtpad=1" alt="bar" />
|
||||||
[br](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_br.yml) | Brazilian | 97% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ee55&w=97&h=5&txtpad=1" alt="bar" />
|
[br](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_br.yml) | Brazilian | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
||||||
[cz](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_cz.yml) | Czech | 88% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=88cc33&w=88&h=5&txtpad=1" alt="bar" />
|
[cz](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_cz.yml) | Czech | 88% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=88cc33&w=88&h=5&txtpad=1" alt="bar" />
|
||||||
[de](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_de.yml) | German | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
[de](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_de.yml) | German | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
||||||
[es](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_es.yml) | Spanish | 97% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ee55&w=97&h=5&txtpad=1" alt="bar" />
|
[es](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_es.yml) | Spanish | 97% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ee55&w=97&h=5&txtpad=1" alt="bar" />
|
||||||
@ -17,15 +17,15 @@ Code | Language | Translated |
|
|||||||
[fi](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fi.yml) | Finnish | 68% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=68&h=5&txtpad=1" alt="bar" />
|
[fi](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fi.yml) | Finnish | 68% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=68&h=5&txtpad=1" alt="bar" />
|
||||||
[fr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fr.yml) | French | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
[fr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_fr.yml) | French | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
||||||
[gl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_gl.yml) | Galician | 72% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=72&h=5&txtpad=1" alt="bar" />
|
[gl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_gl.yml) | Galician | 72% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=72&h=5&txtpad=1" alt="bar" />
|
||||||
[hu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_hu.yml) | Hungarian | 97% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ee55&w=97&h=5&txtpad=1" alt="bar" />
|
[hu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_hu.yml) | Hungarian | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
||||||
[id](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_id.yml) | Indonesian | 72% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=72&h=5&txtpad=1" alt="bar" />
|
[id](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_id.yml) | Indonesian | 72% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=72&h=5&txtpad=1" alt="bar" />
|
||||||
[it](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_it.yml) | Italian | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
[it](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_it.yml) | Italian | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
||||||
[ko](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ko.yml) | Korean | 74% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=74&h=5&txtpad=1" alt="bar" />
|
[ko](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ko.yml) | Korean | 74% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb8800&w=74&h=5&txtpad=1" alt="bar" />
|
||||||
[lt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_lt.yml) | Latvian | 55% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb6600&w=55&h=5&txtpad=1" alt="bar" />
|
[lt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_lt.yml) | Latvian | 55% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb6600&w=55&h=5&txtpad=1" alt="bar" />
|
||||||
[nl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_nl.yml) | Dutch | 78% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb9900&w=78&h=5&txtpad=1" alt="bar" />
|
[nl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_nl.yml) | Dutch | 78% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=bb9900&w=78&h=5&txtpad=1" alt="bar" />
|
||||||
[pl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pl.yml) | Polish | 92% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=92&h=5&txtpad=1" alt="bar" />
|
[pl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pl.yml) | Polish | 99% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ee55&w=99&h=5&txtpad=1" alt="bar" />
|
||||||
[pt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pt.yml) | Portuguese | 88% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=88cc33&w=88&h=5&txtpad=1" alt="bar" />
|
[pt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pt.yml) | Portuguese | 88% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=88cc33&w=88&h=5&txtpad=1" alt="bar" />
|
||||||
[ru](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ru.yml) | Russian | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
[ru](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ru.yml) | Russian | 100% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=66ff66&w=100&h=5&txtpad=1" alt="bar" />
|
||||||
[sk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_sk.yml) | Slovakian | 49% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aa5500&w=49&h=5&txtpad=1" alt="bar" />
|
[sk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_sk.yml) | Slovakian | 49% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aa5500&w=49&h=5&txtpad=1" alt="bar" />
|
||||||
[tr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_tr.yml) | Turkish | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
[tr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_tr.yml) | Turkish | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
||||||
[uk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_uk.yml) | Ukrainian | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
[uk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_uk.yml) | Ukrainian | 95% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=77dd44&w=95&h=5&txtpad=1" alt="bar" />
|
||||||
@ -34,6 +34,7 @@ Code | Language | Translated |
|
|||||||
[zhhk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhhk.yml) | Chinese (Hong Kong) | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
[zhhk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhhk.yml) | Chinese (Hong Kong) | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
||||||
[zhtw](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhtw.yml) | Chinese (Taiwan) | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
[zhtw](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhtw.yml) | Chinese (Taiwan) | 83% | <img src="https://placeholdit.imgix.net/~text?txtsize=5&bg=aaaa11&w=83&h=5&txtpad=1" alt="bar" />
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 18:25:14 CEST 2016
|
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Nov 19 11:44:25 CET 2016
|
||||||
|
2
pom.xml
2
pom.xml
@ -62,7 +62,7 @@
|
|||||||
<bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu, Gnat008</bukkitplugin.authors>
|
<bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu, Gnat008</bukkitplugin.authors>
|
||||||
|
|
||||||
<!-- Change Bukkit Version HERE! -->
|
<!-- Change Bukkit Version HERE! -->
|
||||||
<bukkit.version>1.10.2-R0.1-SNAPSHOT</bukkit.version>
|
<bukkit.version>1.11-R0.1-SNAPSHOT</bukkit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- Jenkins profile -->
|
<!-- Jenkins profile -->
|
||||||
|
@ -17,6 +17,7 @@ import fr.xephi.authme.initialization.TaskCloser;
|
|||||||
import fr.xephi.authme.listener.BlockListener;
|
import fr.xephi.authme.listener.BlockListener;
|
||||||
import fr.xephi.authme.listener.EntityListener;
|
import fr.xephi.authme.listener.EntityListener;
|
||||||
import fr.xephi.authme.listener.PlayerListener;
|
import fr.xephi.authme.listener.PlayerListener;
|
||||||
|
import fr.xephi.authme.listener.PlayerListener111;
|
||||||
import fr.xephi.authme.listener.PlayerListener16;
|
import fr.xephi.authme.listener.PlayerListener16;
|
||||||
import fr.xephi.authme.listener.PlayerListener18;
|
import fr.xephi.authme.listener.PlayerListener18;
|
||||||
import fr.xephi.authme.listener.PlayerListener19;
|
import fr.xephi.authme.listener.PlayerListener19;
|
||||||
@ -40,9 +41,9 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -60,7 +61,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private static final String LOG_FILENAME = "authme.log";
|
private static final String LOG_FILENAME = "authme.log";
|
||||||
private static final int CLEANUP_INTERVAL = 5 * TICKS_PER_MINUTE;
|
private static final int CLEANUP_INTERVAL = 5 * TICKS_PER_MINUTE;
|
||||||
|
|
||||||
// Default version and build number values;
|
// Default version and build number values
|
||||||
private static String pluginVersion = "N/D";
|
private static String pluginVersion = "N/D";
|
||||||
private static String pluginBuildNumber = "Unknown";
|
private static String pluginBuildNumber = "Unknown";
|
||||||
|
|
||||||
@ -85,9 +86,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@SuppressWarnings("deprecation") // the super constructor is deprecated to mark it for unit testing only
|
@SuppressWarnings("deprecation") // the super constructor is deprecated to mark it for unit testing only
|
||||||
protected AuthMe(final PluginLoader loader, final Server server, final PluginDescriptionFile description,
|
protected AuthMe(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
|
||||||
final File dataFolder, final File file) {
|
super(loader, description, dataFolder, file);
|
||||||
super(loader, server, description, dataFolder, file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +132,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Load the plugin version data from the plugin description file
|
// Load the plugin version data from the plugin description file
|
||||||
loadPluginInfo();
|
loadPluginInfo(getDescription().getVersion());
|
||||||
|
|
||||||
// Initialize the plugin
|
// Initialize the plugin
|
||||||
try {
|
try {
|
||||||
@ -175,9 +175,10 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the version and build number of the plugin from the description file.
|
* Load the version and build number of the plugin from the description file.
|
||||||
|
*
|
||||||
|
* @param versionRaw the version as given by the plugin description file
|
||||||
*/
|
*/
|
||||||
private void loadPluginInfo() {
|
private static void loadPluginInfo(String versionRaw) {
|
||||||
String versionRaw = this.getDescription().getVersion();
|
|
||||||
int index = versionRaw.lastIndexOf("-");
|
int index = versionRaw.lastIndexOf("-");
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
pluginVersion = versionRaw.substring(0, index);
|
pluginVersion = versionRaw.substring(0, index);
|
||||||
@ -190,10 +191,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the plugin and all the services.
|
* Initialize the plugin and all the services.
|
||||||
*
|
|
||||||
* @throws Exception if the initialization fails
|
|
||||||
*/
|
*/
|
||||||
private void initialize() throws Exception {
|
private void initialize() {
|
||||||
// Set the Logger instance and log file path
|
// Set the Logger instance and log file path
|
||||||
ConsoleLogger.setLogger(getLogger());
|
ConsoleLogger.setLogger(getLogger());
|
||||||
ConsoleLogger.setLogFile(new File(getDataFolder(), LOG_FILENAME));
|
ConsoleLogger.setLogFile(new File(getDataFolder(), LOG_FILENAME));
|
||||||
@ -224,7 +223,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// TODO: does this still make sense? -sgdc3
|
// TODO: does this still make sense? -sgdc3
|
||||||
// If the server is empty (fresh start) just set all the players as unlogged
|
// If the server is empty (fresh start) just set all the players as unlogged
|
||||||
if (bukkitService.getOnlinePlayers().size() == 0) {
|
if (bukkitService.getOnlinePlayers().isEmpty()) {
|
||||||
database.purgeLogged();
|
database.purgeLogged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +301,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
|
if (isClassLoaded("org.bukkit.event.player.PlayerSwapHandItemsEvent")) {
|
||||||
pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
|
pluginManager.registerEvents(injector.getSingleton(PlayerListener19.class), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register listener for 1.11 events if available
|
||||||
|
if (isClassLoaded("org.bukkit.event.entity.EntityAirChangeEvent")) {
|
||||||
|
pluginManager.registerEvents(injector.getSingleton(PlayerListener111.class), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,12 +19,13 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated API of AuthMe. Please use {@link NewAPI} instead.
|
* Deprecated API of AuthMe. Please use {@link NewAPI} instead.
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link NewAPI}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class API {
|
public class API {
|
||||||
|
|
||||||
public static final String newline = System.getProperty("line.separator");
|
private static AuthMe instance;
|
||||||
public static AuthMe instance;
|
|
||||||
private static DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
private static PasswordSecurity passwordSecurity;
|
private static PasswordSecurity passwordSecurity;
|
||||||
private static Management management;
|
private static Management management;
|
||||||
@ -83,28 +84,17 @@ public class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLastLocation(Player player) {
|
public static Location getLastLocation(Player player) {
|
||||||
try {
|
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
|
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
|
||||||
|
|
||||||
if (auth != null) {
|
if (auth != null) {
|
||||||
Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
|
return new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
|
||||||
return loc;
|
}
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NullPointerException ex) {
|
public static void setPlayerInventory(Player player, ItemStack[] content, ItemStack[] armor) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPlayerInventory(Player player, ItemStack[] content,
|
|
||||||
ItemStack[] armor) {
|
|
||||||
try {
|
|
||||||
player.getInventory().setContents(content);
|
player.getInventory().setContents(content);
|
||||||
player.getInventory().setArmorContents(armor);
|
player.getInventory().setArmorContents(armor);
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +25,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class NewAPI {
|
public class NewAPI {
|
||||||
|
|
||||||
public static NewAPI singleton;
|
private static NewAPI singleton;
|
||||||
public final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final PluginHookService pluginHookService;
|
private final PluginHookService pluginHookService;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PasswordSecurity passwordSecurity;
|
private final PasswordSecurity passwordSecurity;
|
||||||
|
@ -87,10 +87,10 @@ public class CommandMapper {
|
|||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FoundCommandResult getCommandWithSmallestDifference(CommandDescription base, List<String> parts) {
|
private static FoundCommandResult getCommandWithSmallestDifference(CommandDescription base, List<String> parts) {
|
||||||
// Return the base command with incorrect arg count error if we only have one part
|
// Return the base command with incorrect arg count error if we only have one part
|
||||||
if (parts.size() <= 1) {
|
if (parts.size() <= 1) {
|
||||||
return new FoundCommandResult(base, parts, new ArrayList<String>(), 0.0, INCORRECT_ARGUMENTS);
|
return new FoundCommandResult(base, parts, new ArrayList<>(), 0.0, INCORRECT_ARGUMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String childLabel = parts.get(1);
|
final String childLabel = parts.get(1);
|
||||||
@ -115,7 +115,7 @@ public class CommandMapper {
|
|||||||
final int partsSize = parts.size();
|
final int partsSize = parts.size();
|
||||||
List<String> labels = parts.subList(0, Math.min(closestCommand.getLabelCount(), partsSize));
|
List<String> labels = parts.subList(0, Math.min(closestCommand.getLabelCount(), partsSize));
|
||||||
List<String> arguments = (labels.size() == partsSize)
|
List<String> arguments = (labels.size() == partsSize)
|
||||||
? new ArrayList<String>()
|
? new ArrayList<>()
|
||||||
: parts.subList(labels.size(), partsSize);
|
: parts.subList(labels.size(), partsSize);
|
||||||
|
|
||||||
return new FoundCommandResult(closestCommand, labels, arguments, minDifference, status);
|
return new FoundCommandResult(closestCommand, labels, arguments, minDifference, status);
|
||||||
@ -141,7 +141,7 @@ public class CommandMapper {
|
|||||||
*
|
*
|
||||||
* @return A command if there was a complete match (including proper argument count), null otherwise
|
* @return A command if there was a complete match (including proper argument count), null otherwise
|
||||||
*/
|
*/
|
||||||
private CommandDescription getSuitableChild(CommandDescription baseCommand, List<String> parts) {
|
private static CommandDescription getSuitableChild(CommandDescription baseCommand, List<String> parts) {
|
||||||
if (CollectionUtils.isEmpty(parts)) {
|
if (CollectionUtils.isEmpty(parts)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -54,33 +54,40 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
final String playerNameLowerCase = playerName.toLowerCase();
|
bukkitService.runTaskOptionallyAsync(() -> changePassword(playerName.toLowerCase(), playerPass, sender));
|
||||||
bukkitService.runTaskOptionallyAsync(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlayerAuth auth = null;
|
|
||||||
if (playerCache.isAuthenticated(playerNameLowerCase)) {
|
|
||||||
auth = playerCache.getAuth(playerNameLowerCase);
|
|
||||||
} else if (dataSource.isAuthAvailable(playerNameLowerCase)) {
|
|
||||||
auth = dataSource.getAuth(playerNameLowerCase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the password of the given player to the given password.
|
||||||
|
*
|
||||||
|
* @param nameLowercase the name of the player
|
||||||
|
* @param password the password to set
|
||||||
|
* @param sender the sender initiating the password change
|
||||||
|
*/
|
||||||
|
private void changePassword(String nameLowercase, String password, CommandSender sender) {
|
||||||
|
PlayerAuth auth = getAuth(nameLowercase);
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
commandService.send(sender, MessageKey.UNKNOWN_USER);
|
commandService.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedPassword hashedPassword = passwordSecurity.computeHash(playerPass, playerNameLowerCase);
|
HashedPassword hashedPassword = passwordSecurity.computeHash(password, nameLowercase);
|
||||||
auth.setPassword(hashedPassword);
|
auth.setPassword(hashedPassword);
|
||||||
|
|
||||||
if (dataSource.updatePassword(auth)) {
|
if (dataSource.updatePassword(auth)) {
|
||||||
commandService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
commandService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
ConsoleLogger.info(sender.getName() + " changed password of " + playerNameLowerCase);
|
ConsoleLogger.info(sender.getName() + " changed password of " + nameLowercase);
|
||||||
} else {
|
} else {
|
||||||
commandService.send(sender, MessageKey.ERROR);
|
commandService.send(sender, MessageKey.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
private PlayerAuth getAuth(String nameLowercase) {
|
||||||
|
if (playerCache.isAuthenticated(nameLowercase)) {
|
||||||
|
return playerCache.getAuth(nameLowercase);
|
||||||
|
} else if (dataSource.isAuthAvailable(nameLowercase)) {
|
||||||
|
return dataSource.getAuth(nameLowercase);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class LastLoginCommand implements ExecutableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Get the player
|
// Get the player
|
||||||
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||||
|
|
||||||
PlayerAuth auth = dataSource.getAuth(playerName);
|
PlayerAuth auth = dataSource.getAuth(playerName);
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
|
@ -23,7 +23,7 @@ public class ShowEmailCommand extends PlayerCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(Player player, List<String> arguments) {
|
public void runCommand(Player player, List<String> arguments) {
|
||||||
PlayerAuth auth = playerCache.getAuth(player.getName());
|
PlayerAuth auth = playerCache.getAuth(player.getName());
|
||||||
if (auth.getEmail() != null && !auth.getEmail().equalsIgnoreCase("your@email.com")) {
|
if (auth.getEmail() != null && !"your@email.com".equalsIgnoreCase(auth.getEmail())) {
|
||||||
commandService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
|
commandService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
|
||||||
} else {
|
} else {
|
||||||
commandService.send(player, MessageKey.SHOW_NO_EMAIL);
|
commandService.send(player, MessageKey.SHOW_NO_EMAIL);
|
||||||
|
@ -189,7 +189,7 @@ public class PlayerAuth {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String serialize() {
|
public String serialize() {
|
||||||
StringBuffer str = new StringBuffer();
|
StringBuilder str = new StringBuilder();
|
||||||
char d = ';';
|
char d = ';';
|
||||||
str.append(this.nickname).append(d);
|
str.append(this.nickname).append(d);
|
||||||
str.append(this.realName).append(d);
|
str.append(this.realName).append(d);
|
||||||
|
@ -9,7 +9,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -295,19 +294,11 @@ public class FlatFile implements DataSource {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
ConsoleLogger.warning(ex.getMessage());
|
|
||||||
return false;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.warning(ex.getMessage());
|
ConsoleLogger.warning(ex.getMessage());
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (br != null) {
|
silentClose(br);
|
||||||
try {
|
|
||||||
br.close();
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (newAuth != null) {
|
if (newAuth != null) {
|
||||||
removeAuth(auth.getNickname());
|
removeAuth(auth.getNickname());
|
||||||
@ -330,19 +321,11 @@ public class FlatFile implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return countIp;
|
return countIp;
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
ConsoleLogger.warning(ex.getMessage());
|
|
||||||
return new ArrayList<>();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.warning(ex.getMessage());
|
ConsoleLogger.warning(ex.getMessage());
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
} finally {
|
} finally {
|
||||||
if (br != null) {
|
silentClose(br);
|
||||||
try {
|
|
||||||
br.close();
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,12 +346,7 @@ public class FlatFile implements DataSource {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.warning(ex.getMessage());
|
ConsoleLogger.warning(ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (br != null) {
|
silentClose(br);
|
||||||
try {
|
|
||||||
br.close();
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class MySQL implements DataSource {
|
|||||||
private int phpBbGroup;
|
private int phpBbGroup;
|
||||||
private String wordpressPrefix;
|
private String wordpressPrefix;
|
||||||
|
|
||||||
public MySQL(Settings settings) throws ClassNotFoundException, SQLException, PoolInitializationException {
|
public MySQL(Settings settings) throws ClassNotFoundException, SQLException {
|
||||||
setParameters(settings);
|
setParameters(settings);
|
||||||
|
|
||||||
// Set the connection arguments (and check if connection is ok)
|
// Set the connection arguments (and check if connection is ok)
|
||||||
@ -102,7 +102,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConnectionArguments() throws RuntimeException {
|
private void setConnectionArguments() {
|
||||||
ds = new HikariDataSource();
|
ds = new HikariDataSource();
|
||||||
ds.setPoolName("AuthMeMYSQLPool");
|
ds.setPoolName("AuthMeMYSQLPool");
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() throws RuntimeException {
|
public void reload() {
|
||||||
if (ds != null) {
|
if (ds != null) {
|
||||||
ds.close();
|
ds.close();
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,6 @@ package fr.xephi.authme.datasource;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.Columns;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
@ -397,7 +394,7 @@ public class SQLite implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close(Statement st) {
|
private static void close(Statement st) {
|
||||||
if (st != null) {
|
if (st != null) {
|
||||||
try {
|
try {
|
||||||
st.close();
|
st.close();
|
||||||
@ -407,7 +404,7 @@ public class SQLite implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close(Connection con) {
|
private static void close(Connection con) {
|
||||||
if (con != null) {
|
if (con != null) {
|
||||||
try {
|
try {
|
||||||
con.close();
|
con.close();
|
||||||
@ -417,7 +414,7 @@ public class SQLite implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close(ResultSet rs) {
|
private static void close(ResultSet rs) {
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
try {
|
try {
|
||||||
rs.close();
|
rs.close();
|
||||||
@ -479,7 +476,7 @@ public class SQLite implements DataSource {
|
|||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
return (rs.getInt(col.IS_LOGGED) == 1);
|
return rs.getInt(col.IS_LOGGED) == 1;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -43,9 +43,25 @@ public class CrazyLoginConverter implements Converter {
|
|||||||
try (BufferedReader users = new BufferedReader(new FileReader(source))) {
|
try (BufferedReader users = new BufferedReader(new FileReader(source))) {
|
||||||
while ((line = users.readLine()) != null) {
|
while ((line = users.readLine()) != null) {
|
||||||
if (line.contains("|")) {
|
if (line.contains("|")) {
|
||||||
|
migrateAccount(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("CrazyLogin database has been imported correctly");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ConsoleLogger.warning("Can't open the crazylogin database file! Does it exist?");
|
||||||
|
ConsoleLogger.logException("Encountered", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves an account from CrazyLogin to the AuthMe database.
|
||||||
|
*
|
||||||
|
* @param line line read from the CrazyLogin file (one account)
|
||||||
|
*/
|
||||||
|
private void migrateAccount(String line) {
|
||||||
String[] args = line.split("\\|");
|
String[] args = line.split("\\|");
|
||||||
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
|
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
String playerName = args[0];
|
String playerName = args[0];
|
||||||
String password = args[1];
|
String password = args[1];
|
||||||
@ -58,12 +74,5 @@ public class CrazyLoginConverter implements Converter {
|
|||||||
database.saveAuth(auth);
|
database.saveAuth(auth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ConsoleLogger.info("CrazyLogin database has been imported correctly");
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ConsoleLogger.warning("Can't open the crazylogin database file! Does it exist?");
|
|
||||||
ConsoleLogger.logException("Encountered", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,8 @@ public class OnShutdownPlayerSaver {
|
|||||||
dataSource.updateQuitLoc(auth);
|
dataSource.updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
||||||
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT) && !limboPlayerStorage.hasData(player)) {
|
||||||
if (!limboPlayerStorage.hasData(player)) {
|
|
||||||
limboPlayerStorage.saveData(player);
|
limboPlayerStorage.saveData(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -170,12 +170,11 @@ class OnJoinVerifier implements Reloadable {
|
|||||||
public void checkPlayerCountry(boolean isAuthAvailable,
|
public void checkPlayerCountry(boolean isAuthAvailable,
|
||||||
String playerIp) throws FailedVerificationException {
|
String playerIp) throws FailedVerificationException {
|
||||||
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED))
|
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED))
|
||||||
&& settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)) {
|
&& settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)
|
||||||
if (!validationService.isCountryAdmitted(playerIp)) {
|
&& !validationService.isCountryAdmitted(playerIp)) {
|
||||||
throw new FailedVerificationException(MessageKey.COUNTRY_BANNED_ERROR);
|
throw new FailedVerificationException(MessageKey.COUNTRY_BANNED_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player with the same name (case-insensitive) is already playing and refuses the
|
* Checks if a player with the same name (case-insensitive) is already playing and refuses the
|
||||||
|
@ -42,6 +42,7 @@ import org.bukkit.event.player.PlayerShearEntityEvent;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOW_UNAU
|
|||||||
*/
|
*/
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static final Map<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
@ -81,7 +82,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
||||||
if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && cmd.equals("/motd")) {
|
if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && "/motd".equals(cmd)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settings.getProperty(RestrictionSettings.ALLOW_COMMANDS).contains(cmd)) {
|
if (settings.getProperty(RestrictionSettings.ALLOW_COMMANDS).contains(cmd)) {
|
||||||
@ -113,7 +114,7 @@ public class PlayerListener implements Listener {
|
|||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recipients.size() == 0) {
|
if (recipients.isEmpty()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +225,7 @@ public class PlayerListener implements Listener {
|
|||||||
// Get the auth later as this may cause the single session check to fail
|
// Get the auth later as this may cause the single session check to fail
|
||||||
// Slow stuff
|
// Slow stuff
|
||||||
final PlayerAuth auth = dataSource.getAuth(name);
|
final PlayerAuth auth = dataSource.getAuth(name);
|
||||||
final boolean isAuthAvailable = (auth != null);
|
final boolean isAuthAvailable = auth != null;
|
||||||
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
||||||
onJoinVerifier.checkAntibot(player, isAuthAvailable);
|
onJoinVerifier.checkAntibot(player, isAuthAvailable);
|
||||||
onJoinVerifier.checkNameCasing(player, auth);
|
onJoinVerifier.checkNameCasing(player, auth);
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityAirChangeEvent;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener of player events for events introduced in Minecraft 1.11.
|
||||||
|
*/
|
||||||
|
public class PlayerListener111 implements Listener {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ListenerService listenerService;
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerAirChange(EntityAirChangeEvent event) {
|
||||||
|
if (listenerService.shouldCancelEvent(event)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,14 +12,9 @@ import org.apache.logging.log4j.message.Message;
|
|||||||
*
|
*
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class Log4JFilter extends AbstractFilter {
|
public class Log4JFilter extends AbstractFilter {
|
||||||
|
|
||||||
/**
|
private static final long serialVersionUID = -5594073755007974254L;
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public Log4JFilter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates a Message instance and returns the {@link Result} value
|
* Validates a Message instance and returns the {@link Result} value
|
||||||
|
@ -31,7 +31,8 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
private String unregisteredGroup;
|
private String unregisteredGroup;
|
||||||
private String registeredGroup;
|
private String registeredGroup;
|
||||||
|
|
||||||
AuthGroupHandler() { }
|
AuthGroupHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the group of a player, by its AuthMe group type.
|
* Set the group of a player, by its AuthMe group type.
|
||||||
|
@ -78,12 +78,12 @@ public class PermissionsManager implements Reloadable {
|
|||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
// Show a success message and return
|
// Show a success message and return
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
ConsoleLogger.info("Hooked into " + type.getName() + "!");
|
ConsoleLogger.info("Hooked into " + type.getDisplayName() + "!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// An error occurred, show a warning message
|
// An error occurred, show a warning message
|
||||||
ConsoleLogger.logException("Error while hooking into " + type.getName(), ex);
|
ConsoleLogger.logException("Error while hooking into " + type.getDisplayName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public class PermissionsManager implements Reloadable {
|
|||||||
|
|
||||||
// Make sure the plugin is enabled before hooking
|
// Make sure the plugin is enabled before hooking
|
||||||
if (!plugin.isEnabled()) {
|
if (!plugin.isEnabled()) {
|
||||||
ConsoleLogger.info("Not hooking into " + type.getName() + " because it's disabled!");
|
ConsoleLogger.info("Not hooking into " + type.getDisplayName() + " because it's disabled!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ public class PermissionsManager implements Reloadable {
|
|||||||
*/
|
*/
|
||||||
public boolean setGroups(Player player, List<String> groupNames) {
|
public boolean setGroups(Player player, List<String> groupNames) {
|
||||||
// If no permissions system is used or if there's no group supplied, return false
|
// If no permissions system is used or if there's no group supplied, return false
|
||||||
if (!isEnabled() || groupNames.size() <= 0)
|
if (!isEnabled() || groupNames.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set the main group
|
// Set the main group
|
||||||
|
@ -33,21 +33,21 @@ public enum PermissionsSystemType {
|
|||||||
/**
|
/**
|
||||||
* The display name of the permissions system.
|
* The display name of the permissions system.
|
||||||
*/
|
*/
|
||||||
public String name;
|
private String displayName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the permissions system plugin.
|
* The name of the permissions system plugin.
|
||||||
*/
|
*/
|
||||||
public String pluginName;
|
private String pluginName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for PermissionsSystemType.
|
* Constructor for PermissionsSystemType.
|
||||||
*
|
*
|
||||||
* @param name Display name of the permissions system.
|
* @param displayName Display name of the permissions system.
|
||||||
* @param pluginName Name of the plugin.
|
* @param pluginName Name of the plugin.
|
||||||
*/
|
*/
|
||||||
PermissionsSystemType(String name, String pluginName) {
|
PermissionsSystemType(String displayName, String pluginName) {
|
||||||
this.name = name;
|
this.displayName = displayName;
|
||||||
this.pluginName = pluginName;
|
this.pluginName = pluginName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ public enum PermissionsSystemType {
|
|||||||
*
|
*
|
||||||
* @return Display name.
|
* @return Display name.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getDisplayName() {
|
||||||
return this.name;
|
return this.displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ public enum PermissionsSystemType {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
return getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class BPermissionsHandler implements PermissionHandler {
|
|||||||
List<String> groups = getGroups(player);
|
List<String> groups = getGroups(player);
|
||||||
|
|
||||||
// Make sure there is any group available, or return null
|
// Make sure there is any group available, or return null
|
||||||
if (groups.size() == 0)
|
if (groups.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Return the first group
|
// Return the first group
|
||||||
|
@ -54,7 +54,7 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
|||||||
List<String> groups = getGroups(player);
|
List<String> groups = getGroups(player);
|
||||||
|
|
||||||
// Make sure there is any group available, or return null
|
// Make sure there is any group available, or return null
|
||||||
if (groups.size() == 0)
|
if (groups.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Return the first group
|
// Return the first group
|
||||||
|
@ -77,7 +77,7 @@ public class PermissionsExHandler implements PermissionHandler {
|
|||||||
PermissionUser user = permissionManager.getUser(player);
|
PermissionUser user = permissionManager.getUser(player);
|
||||||
|
|
||||||
List<String> groups = user.getParentIdentifiers(null);
|
List<String> groups = user.getParentIdentifiers(null);
|
||||||
if (groups.size() == 0)
|
if (groups.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return groups.get(0);
|
return groups.get(0);
|
||||||
|
@ -27,7 +27,8 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
AsyncChangePassword() { }
|
AsyncChangePassword() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void changePassword(final Player player, String oldPassword, String newPassword) {
|
public void changePassword(final Player player, String oldPassword, String newPassword) {
|
||||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.settings.commandconfig.CommandManager;
|
|||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.service.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -84,17 +85,14 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
|||||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||||
|
|
||||||
// We can now display the join message (if delayed)
|
// We can now display the join message (if delayed)
|
||||||
String jm = PlayerListener.joinMessage.get(name);
|
String joinMessage = PlayerListener.joinMessage.remove(name);
|
||||||
if (jm != null) {
|
if (!StringUtils.isEmpty(joinMessage)) {
|
||||||
if (!jm.isEmpty()) {
|
|
||||||
for (Player p : bukkitService.getOnlinePlayers()) {
|
for (Player p : bukkitService.getOnlinePlayers()) {
|
||||||
if (p.isOnline()) {
|
if (p.isOnline()) {
|
||||||
p.sendMessage(jm);
|
p.sendMessage(joinMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerListener.joinMessage.remove(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||||
|
@ -21,8 +21,8 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
ProcessSyncEmailRegister() { }
|
ProcessSyncEmailRegister() {
|
||||||
|
}
|
||||||
|
|
||||||
public void processEmailRegister(Player player) {
|
public void processEmailRegister(Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
|
|||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
import fr.xephi.authme.settings.EnumSetProperty;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -41,7 +42,8 @@ public class PasswordSecurity implements Reloadable {
|
|||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
this.algorithm = settings.getProperty(SecuritySettings.PASSWORD_HASH);
|
this.algorithm = settings.getProperty(SecuritySettings.PASSWORD_HASH);
|
||||||
this.legacyAlgorithms = settings.getProperty(SecuritySettings.LEGACY_HASHES);
|
// TODO #1014: Need to cast to specific type because ConfigMe ignores fields of child Property types
|
||||||
|
this.legacyAlgorithms = ((EnumSetProperty<HashAlgorithm>) SecuritySettings.LEGACY_HASHES).asEnumSet(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
package fr.xephi.authme.security.crypts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plaintext password storage.
|
||||||
|
*
|
||||||
|
* @deprecated Using this is no longer supported. AuthMe will migrate to SHA256 on startup.
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class PLAINTEXT extends UnsaltedMethod {
|
public class PLAINTEXT extends UnsaltedMethod {
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ public class XAUTH extends HexSaltedMethod {
|
|||||||
@Override
|
@Override
|
||||||
public String computeHash(String password, String salt, String name) {
|
public String computeHash(String password, String salt, String name) {
|
||||||
String hash = getWhirlpool(salt + password).toLowerCase();
|
String hash = getWhirlpool(salt + password).toLowerCase();
|
||||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
int saltPos = password.length() >= hash.length() ? hash.length() - 1 : password.length();
|
||||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String password, HashedPassword hashedPassword, String playerName) {
|
public boolean comparePassword(String password, HashedPassword hashedPassword, String playerName) {
|
||||||
String hash = hashedPassword.getHash();
|
String hash = hashedPassword.getHash();
|
||||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
int saltPos = password.length() >= hash.length() ? hash.length() - 1 : password.length();
|
||||||
if (saltPos + 12 > hash.length()) {
|
if (saltPos + 12 > hash.length()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -104,36 +104,22 @@ public class BackupService {
|
|||||||
dirBackup.mkdir();
|
dirBackup.mkdir();
|
||||||
}
|
}
|
||||||
String backupWindowsPath = settings.getProperty(BackupSettings.MYSQL_WINDOWS_PATH);
|
String backupWindowsPath = settings.getProperty(BackupSettings.MYSQL_WINDOWS_PATH);
|
||||||
if (checkWindows(backupWindowsPath)) {
|
boolean isUsingWindows = checkWindows(backupWindowsPath);
|
||||||
String executeCmd = backupWindowsPath + "\\bin\\mysqldump.exe -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path + ".sql";
|
String backupCommand = isUsingWindows
|
||||||
Process runtimeProcess;
|
? backupWindowsPath + "\\bin\\mysqldump.exe" + buildMysqlDumpArguments()
|
||||||
|
: "mysqldump" + buildMysqlDumpArguments();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
|
Process runtimeProcess = Runtime.getRuntime().exec(backupCommand);
|
||||||
int processComplete = runtimeProcess.waitFor();
|
int processComplete = runtimeProcess.waitFor();
|
||||||
if (processComplete == 0) {
|
if (processComplete == 0) {
|
||||||
ConsoleLogger.info("Backup created successfully.");
|
ConsoleLogger.info("Backup created successfully. (Using Windows = " + isUsingWindows + ")");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ConsoleLogger.warning("Could not create the backup! (Windows)");
|
ConsoleLogger.warning("Could not create the backup! (Using Windows = " + isUsingWindows + ")");
|
||||||
}
|
}
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
ConsoleLogger.logException("Error during Windows backup:", e);
|
ConsoleLogger.logException("Error during backup (using Windows = " + isUsingWindows + "):", e);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String executeCmd = "mysqldump -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path + ".sql";
|
|
||||||
Process runtimeProcess;
|
|
||||||
try {
|
|
||||||
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
|
|
||||||
int processComplete = runtimeProcess.waitFor();
|
|
||||||
if (processComplete == 0) {
|
|
||||||
ConsoleLogger.info("Backup created successfully.");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
ConsoleLogger.warning("Could not create the backup!");
|
|
||||||
}
|
|
||||||
} catch (IOException | InterruptedException e) {
|
|
||||||
ConsoleLogger.logException("Error during backup:", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -173,6 +159,16 @@ public class BackupService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the command line arguments to pass along when running the {@code mysqldump} command.
|
||||||
|
*
|
||||||
|
* @return the mysqldump command line arguments
|
||||||
|
*/
|
||||||
|
private String buildMysqlDumpArguments() {
|
||||||
|
return " -u " + dbUserName + " -p" + dbPassword + " " + dbName
|
||||||
|
+ " --tables " + tblname + " -r " + path + ".sql";
|
||||||
|
}
|
||||||
|
|
||||||
private static void copy(String src, String dst) throws IOException {
|
private static void copy(String src, String dst) throws IOException {
|
||||||
InputStream in = new FileInputStream(src);
|
InputStream in = new FileInputStream(src);
|
||||||
OutputStream out = new FileOutputStream(dst);
|
OutputStream out = new FileOutputStream(dst);
|
||||||
|
@ -40,7 +40,8 @@ public class ValidationService implements Reloadable {
|
|||||||
private Pattern passwordRegex;
|
private Pattern passwordRegex;
|
||||||
private Set<String> unrestrictedNames;
|
private Set<String> unrestrictedNames;
|
||||||
|
|
||||||
ValidationService() { }
|
ValidationService() {
|
||||||
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,35 +1,38 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.settings;
|
||||||
|
|
||||||
import com.github.authme.configme.properties.Property;
|
import com.github.authme.configme.SettingsManager;
|
||||||
import com.github.authme.configme.resource.PropertyResource;
|
import com.github.authme.configme.properties.StringListProperty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property whose value is a set of entries of a given enum.
|
* Property whose value is a set of entries of a given enum.
|
||||||
*/
|
*/
|
||||||
// TODO https://github.com/AuthMe/ConfigMe/issues/27: Should be a Property of Set<E> type
|
// TODO #1014: This property type currently extends StringListProperty with a dedicated method to convert the values
|
||||||
public class EnumSetProperty<E extends Enum<E>> extends Property<List<E>> {
|
// into a Set of the selected enum due to multiple issues on ConfigMe's side.
|
||||||
|
public class EnumSetProperty<E extends Enum<E>> extends StringListProperty {
|
||||||
|
|
||||||
private final Class<E> enumClass;
|
private final Class<E> enumClass;
|
||||||
|
|
||||||
public EnumSetProperty(Class<E> enumClass, String path, List<E> defaultValue) {
|
public EnumSetProperty(Class<E> enumClass, String path, String... values) {
|
||||||
super(path, defaultValue);
|
super(path, values);
|
||||||
this.enumClass = enumClass;
|
this.enumClass = enumClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
protected List<E> getFromResource(PropertyResource resource) {
|
* Returns the value as a set of enum entries.
|
||||||
List<?> elements = resource.getList(getPath());
|
*
|
||||||
if (elements != null) {
|
* @param settings the settings manager to look up the raw value with
|
||||||
return elements.stream()
|
* @return the property's value as mapped enum entries
|
||||||
.map(val -> toEnum(String.valueOf(val)))
|
*/
|
||||||
|
public Set<E> asEnumSet(SettingsManager settings) {
|
||||||
|
List<String> entries = settings.getProperty(this);
|
||||||
|
return entries.stream()
|
||||||
|
.map(str -> toEnum(str))
|
||||||
.filter(e -> e != null)
|
.filter(e -> e != null)
|
||||||
.distinct()
|
.collect(Collectors.toSet());
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private E toEnum(String str) {
|
private E toEnum(String str) {
|
||||||
|
@ -48,10 +48,10 @@ public class SpawnLoader implements Reloadable {
|
|||||||
@Inject
|
@Inject
|
||||||
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHookService pluginHookService,
|
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHookService pluginHookService,
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
File spawnFile = new File(pluginFolder, "spawn.yml");
|
|
||||||
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
||||||
|
File spawnFile = new File(pluginFolder, "spawn.yml");
|
||||||
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
||||||
this.authMeConfigurationFile = new File(pluginFolder, "spawn.yml");
|
this.authMeConfigurationFile = spawnFile;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.pluginHookService = pluginHookService;
|
this.pluginHookService = pluginHookService;
|
||||||
reload();
|
reload();
|
||||||
|
@ -6,7 +6,6 @@ import com.github.authme.configme.properties.Property;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.EnumSetProperty;
|
import fr.xephi.authme.settings.EnumSetProperty;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.github.authme.configme.properties.PropertyInitializer.newLowercaseListProperty;
|
import static com.github.authme.configme.properties.PropertyInitializer.newLowercaseListProperty;
|
||||||
@ -83,8 +82,8 @@ public class SecuritySettings implements SettingsHolder {
|
|||||||
"legacyHashes:",
|
"legacyHashes:",
|
||||||
"- 'SHA1'"
|
"- 'SHA1'"
|
||||||
})
|
})
|
||||||
public static final Property<List<HashAlgorithm>> LEGACY_HASHES =
|
public static final Property<List<String>> LEGACY_HASHES =
|
||||||
new EnumSetProperty<>(HashAlgorithm.class, "settings.security.legacyHashes", Collections.emptyList());
|
new EnumSetProperty<>(HashAlgorithm.class, "settings.security.legacyHashes");
|
||||||
|
|
||||||
@Comment({"Prevent unsafe passwords from being used; put them in lowercase!",
|
@Comment({"Prevent unsafe passwords from being used; put them in lowercase!",
|
||||||
"You should always set 'help' as unsafePassword due to possible conflicts.",
|
"You should always set 'help' as unsafePassword due to possible conflicts.",
|
||||||
|
@ -72,7 +72,7 @@ class PurgeTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
|
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
|
||||||
if (toPurge.remove(offlinePlayer.getName().toLowerCase())) {
|
if (offlinePlayer.getName() != null && toPurge.remove(offlinePlayer.getName().toLowerCase())) {
|
||||||
if (!permissionsManager.hasPermissionOffline(offlinePlayer, PlayerStatePermission.BYPASS_PURGE)) {
|
if (!permissionsManager.hasPermissionOffline(offlinePlayer, PlayerStatePermission.BYPASS_PURGE)) {
|
||||||
playerPortion.add(offlinePlayer);
|
playerPortion.add(offlinePlayer);
|
||||||
namePortion.add(offlinePlayer.getName());
|
namePortion.add(offlinePlayer.getName());
|
||||||
|
45
src/main/resources/messages/help_pl.yml
Normal file
45
src/main/resources/messages/help_pl.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Tlumaczenie configu dla AuthMe pomoc, kiedy wpiszesz /authme help lub /authme help register podana wiadomosc zostanie wyslana
|
||||||
|
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Lista tekstu uzyta w pomocy.
|
||||||
|
common:
|
||||||
|
header: '==========[ AuthMeReloaded - Pomoc ]=========='
|
||||||
|
optional: 'Opcjonalnie'
|
||||||
|
hasPermission: 'Nie posidasz permisji'
|
||||||
|
noPermission: 'Brak permisji'
|
||||||
|
default: 'Domyslnie'
|
||||||
|
result: 'Wynik'
|
||||||
|
defaultPermissions:
|
||||||
|
notAllowed: 'Nie posiadasz permisji'
|
||||||
|
opOnly: 'Tylko OP'
|
||||||
|
allowed: 'Dozwolone dla wszyskich'
|
||||||
|
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Tytuly z inwidualnych stref w pomoc.
|
||||||
|
# Zostaw tlumaczenie puste aby wylaczyc dana komende. Np.:
|
||||||
|
# alternatives: ''
|
||||||
|
section:
|
||||||
|
command: 'Komenda'
|
||||||
|
description: 'Krotki opis'
|
||||||
|
detailedDescription: 'Dlugi opis'
|
||||||
|
arguments: 'Argumenty'
|
||||||
|
permissions: 'Permisje'
|
||||||
|
alternatives: 'Alternatywy'
|
||||||
|
children: 'Komendy'
|
||||||
|
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Mozesz przetlumaczyc wszystkie komendy uzywajac tego wzoru.
|
||||||
|
# Na przyklad jesli chcesz przetlumaczyc /authme reload, utworz selekcje "authme.reload", lub "login" dla /login
|
||||||
|
# Jesli komenda posiada argumenty, mozesz uzyc arg1 aby przetlumaczyc pierwszy argument, i nastepne
|
||||||
|
# Tlumaczenia nie musza byc kompletne; kazde braki beda uzupelniane domyslnymi wiadomosciami z pluginu.
|
||||||
|
# Uwaga: Postaw glowna klase (np. "authme") przed ich dziecmi (np. "authme.reload")
|
||||||
|
commands:
|
||||||
|
authme.register:
|
||||||
|
description: 'Rejestracja gracza'
|
||||||
|
detailedDescription: 'Rerejestracja gracza z okreslonym haslem'
|
||||||
|
arg1:
|
||||||
|
label: 'player'
|
||||||
|
description: 'Nazwa gracza'
|
||||||
|
arg2:
|
||||||
|
label: 'password'
|
||||||
|
description: 'Haslo'
|
@ -74,5 +74,5 @@ accounts_owned_other: 'El jugador %name tiene %count cuentas:'
|
|||||||
incomplete_email_settings: 'Error: no todos los ajustes necesario se han configurado para enviar correos. Por favor, contacta con un administrador.'
|
incomplete_email_settings: 'Error: no todos los ajustes necesario se han configurado para enviar correos. Por favor, contacta con un administrador.'
|
||||||
recovery_code_sent: 'El código de recuperación para recuperar tu contraseña se ha enviado a tu correo.'
|
recovery_code_sent: 'El código de recuperación para recuperar tu contraseña se ha enviado a tu correo.'
|
||||||
invalid_name_case: 'Solo puedes unirte mediante el nombre de usuario %valid, no %invalid.'
|
invalid_name_case: 'Solo puedes unirte mediante el nombre de usuario %valid, no %invalid.'
|
||||||
# TODO email_show: '&2Your current email address is: &f%email'
|
email_show: '&2Tu dirección de E-Mail actual es: &f%email'
|
||||||
# TODO show_no_email: '&2You currently don''t have email address associated with this account.'
|
show_no_email: '&2No tienes ningun E-Mail asociado en esta cuenta.'
|
||||||
|
@ -69,9 +69,9 @@ antibot_auto_enabled: '&4[AntiBotService] AntyBot wlaczony z powodu duzej liczby
|
|||||||
accounts_owned_self: 'Posiadasz %count kont:'
|
accounts_owned_self: 'Posiadasz %count kont:'
|
||||||
two_factor_create: '&2Twoj sekretny kod to %code. Mozesz zeskanowac go tutaj %url'
|
two_factor_create: '&2Twoj sekretny kod to %code. Mozesz zeskanowac go tutaj %url'
|
||||||
not_owner_error: 'Nie jestes wlascicielem tego konta, wybierz inny nick!'
|
not_owner_error: 'Nie jestes wlascicielem tego konta, wybierz inny nick!'
|
||||||
# TODO email_show: '&2Your current email address is: &f%email'
|
email_show: '&2Twoj aktualny adres email to: &f%email'
|
||||||
# TODO show_no_email: '&2You currently don''t have email address associated with this account.'
|
show_no_email: '&2Nie posiadasz adresu email przypisanego do tego konta.'
|
||||||
# TODO kicked_admin_registered: 'An admin just registered you; please log in again'
|
kicked_admin_registered: 'Administrator zarejestrowal Ciebie, mozesz sie zalogowac.'
|
||||||
# TODO incomplete_email_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.'
|
incomplete_email_settings: 'Error: Nie wszystkie opcje odpowiedzialne za wysylanie emaili zostaly ustawione. Skontaktuj sie z administracja.'
|
||||||
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
|
recovery_code_sent: 'Kod odzyskiwania hasla zostal wyslany na adres email przypisany do konta.'
|
||||||
# TODO recovery_code_incorrect: 'The recovery code is not correct! Use /email recovery [email] to generate a new one'
|
recovery_code_incorrect: 'Kod odzyskiwania hasla jest bledny! Uzyj /email recovery [email] aby wygenerowac nowy.'
|
||||||
|
@ -19,8 +19,8 @@ import fr.xephi.authme.task.purge.PurgeService;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginLoader;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@ -34,7 +34,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.TestSettingsMigrationServices.alwaysFulfilled;
|
|
||||||
import static fr.xephi.authme.settings.properties.AuthMeSettingsRetriever.buildConfigurationData;
|
import static fr.xephi.authme.settings.properties.AuthMeSettingsRetriever.buildConfigurationData;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
@ -49,9 +48,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class AuthMeInitializationTest {
|
public class AuthMeInitializationTest {
|
||||||
|
|
||||||
@Mock
|
|
||||||
private PluginLoader pluginLoader;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Server server;
|
private Server server;
|
||||||
|
|
||||||
@ -60,7 +56,6 @@ public class AuthMeInitializationTest {
|
|||||||
|
|
||||||
private AuthMe authMe;
|
private AuthMe authMe;
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private File settingsFile;
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
@ -73,7 +68,8 @@ public class AuthMeInitializationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void initAuthMe() throws IOException {
|
public void initAuthMe() throws IOException {
|
||||||
dataFolder = temporaryFolder.newFolder();
|
dataFolder = temporaryFolder.newFolder();
|
||||||
settingsFile = new File(dataFolder, "config.yml");
|
File settingsFile = new File(dataFolder, "config.yml");
|
||||||
|
JavaPluginLoader pluginLoader = new JavaPluginLoader(server);
|
||||||
Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "config.test.yml"), settingsFile);
|
Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "config.test.yml"), settingsFile);
|
||||||
|
|
||||||
// Mock / wire various Bukkit components
|
// Mock / wire various Bukkit components
|
||||||
@ -86,14 +82,14 @@ public class AuthMeInitializationTest {
|
|||||||
"AuthMe", "N/A", AuthMe.class.getCanonicalName());
|
"AuthMe", "N/A", AuthMe.class.getCanonicalName());
|
||||||
|
|
||||||
// Initialize AuthMe
|
// Initialize AuthMe
|
||||||
authMe = new AuthMe(pluginLoader, server, descriptionFile, dataFolder, null);
|
authMe = new AuthMe(pluginLoader, descriptionFile, dataFolder, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldInitializeAllServices() {
|
public void shouldInitializeAllServices() {
|
||||||
// given
|
// given
|
||||||
Settings settings =
|
Settings settings =
|
||||||
new Settings(dataFolder, mock(PropertyResource.class), alwaysFulfilled(), buildConfigurationData());
|
new Settings(dataFolder, mock(PropertyResource.class), null, buildConfigurationData());
|
||||||
|
|
||||||
Injector injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
Injector injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
||||||
injector.provide(DataFolder.class, dataFolder);
|
injector.provide(DataFolder.class, dataFolder);
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import org.bukkit.event.entity.EntityAirChangeEvent;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.listener.EventCancelVerifier.withServiceMock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link PlayerListener111}.
|
||||||
|
*/
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class PlayerListener111Test {
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private PlayerListener111 listener;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ListenerService listenerService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldCancelEvent() {
|
||||||
|
withServiceMock(listenerService)
|
||||||
|
.check(listener::onPlayerAirChange, EntityAirChangeEvent.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,15 +23,15 @@ public class PermissionsSystemTypeTest {
|
|||||||
List<String> pluginNames = new ArrayList<>(PermissionsSystemType.values().length);
|
List<String> pluginNames = new ArrayList<>(PermissionsSystemType.values().length);
|
||||||
|
|
||||||
for (PermissionsSystemType system : PermissionsSystemType.values()) {
|
for (PermissionsSystemType system : PermissionsSystemType.values()) {
|
||||||
assertThat("Name for enum entry '" + system + "' is not null",
|
assertThat("Display name for enum entry '" + system + "' is not null",
|
||||||
system.getName(), not(nullValue()));
|
system.getDisplayName(), not(nullValue()));
|
||||||
assertThat("Plugin name for enum entry '" + system + "' is not null",
|
assertThat("Plugin name for enum entry '" + system + "' is not null",
|
||||||
system.getPluginName(), not(nullValue()));
|
system.getPluginName(), not(nullValue()));
|
||||||
assertThat("Only one enum entry has name '" + system.getName() + "'",
|
assertThat("Only one enum entry has display name '" + system.getDisplayName() + "'",
|
||||||
names, not(hasItem(system.getName())));
|
names, not(hasItem(system.getDisplayName())));
|
||||||
assertThat("Only one enum entry has plugin name '" + system.getPluginName() + "'",
|
assertThat("Only one enum entry has plugin name '" + system.getPluginName() + "'",
|
||||||
pluginNames, not(hasItem(system.getPluginName())));
|
pluginNames, not(hasItem(system.getPluginName())));
|
||||||
names.add(system.getName());
|
names.add(system.getDisplayName());
|
||||||
pluginNames.add(system.getPluginName());
|
pluginNames.add(system.getPluginName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,10 @@ import org.mockito.stubbing.Answer;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.google.common.collect.Lists.newArrayList;
|
import static com.google.common.collect.Lists.newArrayList;
|
||||||
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
@ -173,7 +175,7 @@ public class PasswordSecurityTest {
|
|||||||
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(false);
|
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(false);
|
||||||
given(method.computeHash(clearTextPass, playerLowerCase)).willReturn(newPassword);
|
given(method.computeHash(clearTextPass, playerLowerCase)).willReturn(newPassword);
|
||||||
initSettings(HashAlgorithm.MD5);
|
initSettings(HashAlgorithm.MD5);
|
||||||
given(settings.getProperty(SecuritySettings.LEGACY_HASHES)).willReturn(newArrayList(HashAlgorithm.BCRYPT));
|
given(settings.getProperty(SecuritySettings.LEGACY_HASHES)).willReturn(newArrayList(HashAlgorithm.BCRYPT.name()));
|
||||||
PasswordSecurity security = newPasswordSecurity();
|
PasswordSecurity security = newPasswordSecurity();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -258,7 +260,7 @@ public class PasswordSecurityTest {
|
|||||||
initSettings(HashAlgorithm.BCRYPT);
|
initSettings(HashAlgorithm.BCRYPT);
|
||||||
PasswordSecurity passwordSecurity = newPasswordSecurity();
|
PasswordSecurity passwordSecurity = newPasswordSecurity();
|
||||||
given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5);
|
given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5);
|
||||||
List<HashAlgorithm> legacyHashes = newArrayList(HashAlgorithm.CUSTOM, HashAlgorithm.BCRYPT);
|
List<String> legacyHashes = newArrayList(HashAlgorithm.CUSTOM.name(), HashAlgorithm.BCRYPT.name());
|
||||||
given(settings.getProperty(SecuritySettings.LEGACY_HASHES)).willReturn(legacyHashes);
|
given(settings.getProperty(SecuritySettings.LEGACY_HASHES)).willReturn(legacyHashes);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -267,8 +269,9 @@ public class PasswordSecurityTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(ReflectionTestUtils.getFieldValue(PasswordSecurity.class, passwordSecurity, "algorithm"),
|
assertThat(ReflectionTestUtils.getFieldValue(PasswordSecurity.class, passwordSecurity, "algorithm"),
|
||||||
equalTo(HashAlgorithm.MD5));
|
equalTo(HashAlgorithm.MD5));
|
||||||
|
Set<HashAlgorithm> legacyHashesSet = newHashSet(HashAlgorithm.CUSTOM, HashAlgorithm.BCRYPT);
|
||||||
assertThat(ReflectionTestUtils.getFieldValue(PasswordSecurity.class, passwordSecurity, "legacyAlgorithms"),
|
assertThat(ReflectionTestUtils.getFieldValue(PasswordSecurity.class, passwordSecurity, "legacyAlgorithms"),
|
||||||
equalTo(legacyHashes));
|
equalTo(legacyHashesSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PasswordSecurity newPasswordSecurity() {
|
private PasswordSecurity newPasswordSecurity() {
|
||||||
|
@ -121,8 +121,7 @@ public class SettingsIntegrationTest {
|
|||||||
// given
|
// given
|
||||||
File configFile = temporaryFolder.newFile();
|
File configFile = temporaryFolder.newFile();
|
||||||
PropertyResource resource = new YamlFileResource(configFile);
|
PropertyResource resource = new YamlFileResource(configFile);
|
||||||
Settings settings = new Settings(testPluginFolder, resource,
|
Settings settings = new Settings(testPluginFolder, resource, null, CONFIG_DATA);
|
||||||
TestSettingsMigrationServices.alwaysFulfilled(), CONFIG_DATA);
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
assertThat(settings.getProperty(TestConfiguration.RATIO_ORDER), equalTo(TestEnum.SECOND)); // default value
|
assertThat(settings.getProperty(TestConfiguration.RATIO_ORDER), equalTo(TestEnum.SECOND)); // default value
|
||||||
|
@ -55,8 +55,7 @@ public class SettingsTest {
|
|||||||
|
|
||||||
PropertyResource resource = mock(PropertyResource.class);
|
PropertyResource resource = mock(PropertyResource.class);
|
||||||
given(resource.getBoolean(RegistrationSettings.USE_WELCOME_MESSAGE.getPath())).willReturn(true);
|
given(resource.getBoolean(RegistrationSettings.USE_WELCOME_MESSAGE.getPath())).willReturn(true);
|
||||||
Settings settings = new Settings(testPluginFolder, resource,
|
Settings settings = new Settings(testPluginFolder, resource, null, CONFIG_DATA);
|
||||||
TestSettingsMigrationServices.alwaysFulfilled(), CONFIG_DATA);
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String[] result = settings.getWelcomeMessage();
|
String[] result = settings.getWelcomeMessage();
|
||||||
@ -75,8 +74,7 @@ public class SettingsTest {
|
|||||||
Files.write(emailFile.toPath(), emailMessage.getBytes());
|
Files.write(emailFile.toPath(), emailMessage.getBytes());
|
||||||
|
|
||||||
PropertyResource resource = mock(PropertyResource.class);
|
PropertyResource resource = mock(PropertyResource.class);
|
||||||
Settings settings = new Settings(testPluginFolder, resource,
|
Settings settings = new Settings(testPluginFolder, resource, null, CONFIG_DATA);
|
||||||
TestSettingsMigrationServices.alwaysFulfilled(), CONFIG_DATA);
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String result = settings.getPasswordEmailMessage();
|
String result = settings.getPasswordEmailMessage();
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package fr.xephi.authme.settings;
|
|
||||||
|
|
||||||
import com.github.authme.configme.migration.MigrationService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides {@link MigrationService} implementations for testing.
|
|
||||||
*/
|
|
||||||
public final class TestSettingsMigrationServices {
|
|
||||||
|
|
||||||
private TestSettingsMigrationServices() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a settings migration service which always answers that all data is up-to-date.
|
|
||||||
*
|
|
||||||
* @return test settings migration service
|
|
||||||
*/
|
|
||||||
public static MigrationService alwaysFulfilled() {
|
|
||||||
return (propertyResource, knownProperties) -> false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -124,6 +124,27 @@ public class PurgeTaskTest {
|
|||||||
assertRanPurgeWithNames("foxtrot");
|
assertRanPurgeWithNames("foxtrot");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #1008: OfflinePlayer#getName may return null.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldHandleOfflinePlayerWithNullName() {
|
||||||
|
// given
|
||||||
|
Set<String> names = newHashSet("name1", "name2");
|
||||||
|
OfflinePlayer[] players = asArray(
|
||||||
|
mockOfflinePlayer(null, false), mockOfflinePlayer("charlie", false), mockOfflinePlayer("name1", false));
|
||||||
|
reset(purgeService, permissionsManager);
|
||||||
|
setPermissionsBehavior();
|
||||||
|
|
||||||
|
PurgeTask task = new PurgeTask(purgeService, permissionsManager, null, names, players);
|
||||||
|
|
||||||
|
// when
|
||||||
|
task.run();
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertRanPurgeWithPlayers(players[2]);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldStopTaskAndInformSenderUponCompletion() {
|
public void shouldStopTaskAndInformSenderUponCompletion() {
|
||||||
// given
|
// given
|
||||||
|
Loading…
Reference in New Issue
Block a user