mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-16 20:01:46 +01:00
Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into configme-integration
Conflicts: pom.xml
This commit is contained in:
commit
09f403f357
@ -1,7 +1,7 @@
|
||||
sudo: false
|
||||
|
||||
language: java
|
||||
jdk: oraclejdk7
|
||||
jdk: oraclejdk8
|
||||
|
||||
script: mvn clean verify -B
|
||||
|
||||
|
@ -45,7 +45,7 @@ Outdated!
|
||||
<hr>
|
||||
|
||||
#####Compiling Requirements:
|
||||
>- JDK 1.7
|
||||
>- JDK 1.8
|
||||
>- Maven
|
||||
>- Git/Github (Optional)
|
||||
|
||||
@ -54,7 +54,7 @@ Outdated!
|
||||
>- Execute command "mvn clean install"
|
||||
|
||||
#####Running Requirements:
|
||||
>- Java 1.7 or 1.8
|
||||
>- Java 1.8
|
||||
>- PaperSpigot, Spigot or CraftBukkit (1.7.10, 1.8.X, 1.9.X, 1.10.X)
|
||||
>- ProtocolLib (optional, required by the protectInventory feature)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
machine:
|
||||
java:
|
||||
version: oraclejdk7
|
||||
version: oraclejdk8
|
||||
general:
|
||||
artifacts:
|
||||
- "target/AuthMe-*.jar"
|
||||
|
296
pom.xml
296
pom.xml
@ -46,7 +46,7 @@
|
||||
<properties>
|
||||
<!-- Project properties -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.jdkVersion>1.7</project.jdkVersion>
|
||||
<project.jdkVersion>1.8</project.jdkVersion>
|
||||
|
||||
<!-- Output properties -->
|
||||
<project.outputName>AuthMe</project.outputName>
|
||||
@ -98,38 +98,38 @@
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${bukkit.version}</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<groupId>javax.persistence</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${bukkit.version}</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<groupId>javax.persistence</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<!-- Bukkit -->
|
||||
@ -244,31 +244,35 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.maxmind.geoip</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.ricecode.similarity</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.inject</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
|
||||
</relocation>
|
||||
<!-- MCStats.org metrics -->
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>fr.xephi.authme</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>ch.jalu.injector</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.jalu.injector</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.maxmind.geoip</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.ricecode.similarity</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.inject</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
|
||||
</relocation>
|
||||
<!-- MCStats.org metrics -->
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>fr.xephi.authme</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<outputFile>target/${project.finalName}-spigot.jar</outputFile>
|
||||
</configuration>
|
||||
@ -287,6 +291,10 @@
|
||||
<pattern>com.google</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.google</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>ch.jalu.injector</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.jalu.injector</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
|
||||
@ -421,42 +429,22 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- Database Connection Pool -->
|
||||
<!-- Java Libraries -->
|
||||
|
||||
<!-- Jalu Injector -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.4.7</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- HikariCP Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<groupId>ch.jalu</groupId>
|
||||
<artifactId>injector</artifactId>
|
||||
<version>0.3</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Log4J Logger (required by the console filter) -->
|
||||
<!-- String comparison library. Used for dynamic help system. -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Email Library -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-email</artifactId>
|
||||
<version>1.4</version>
|
||||
<groupId>net.ricecode</groupId>
|
||||
<artifactId>string-similarity</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
@ -479,15 +467,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Inject API -->
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Maxmind GeoIp API -->
|
||||
<dependency>
|
||||
<groupId>com.maxmind.geoip</groupId>
|
||||
@ -497,6 +476,51 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Email Library -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-email</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Log4J Logger (required by the console filter) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Database Connection Pool -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- HikariCP Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Spigot API, http://www.spigotmc.org/ or http://bukkit.org/ -->
|
||||
<!-- Moved in profiles! -->
|
||||
|
||||
<!-- Bukkit Libraries -->
|
||||
|
||||
<!-- Metrics API -->
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
@ -512,14 +536,11 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Spigot API, http://www.spigotmc.org/ or http://bukkit.org/ -->
|
||||
<!-- Moved in profiles! -->
|
||||
|
||||
<!-- ProtocolLib, http://dev.bukkit.org/bukkit-plugins/protocollib/ -->
|
||||
<!-- ProtocolLib -->
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>3.6.5-SNAPSHOT</version>
|
||||
<artifactId>ProtocolLib-API</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -537,7 +558,7 @@
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.23.1</version>
|
||||
<version>1.23.4</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -559,20 +580,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- GroupManager plugin -->
|
||||
<dependency>
|
||||
<groupId>org.anjocaido</groupId>
|
||||
<artifactId>groupmanagerx</artifactId>
|
||||
<version>2.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- bPermissions plugin -->
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
@ -591,7 +598,7 @@
|
||||
<dependency>
|
||||
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||
<artifactId>zPermissions</artifactId>
|
||||
<version>1.3-SNAPSHOT</version>
|
||||
<version>1.3.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -625,7 +632,7 @@
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -692,12 +699,12 @@
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jettison</artifactId>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
@ -724,7 +731,7 @@
|
||||
<dependency>
|
||||
<groupId>net.minelink</groupId>
|
||||
<artifactId>CombatTagPlus</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -791,6 +798,24 @@
|
||||
<artifactId>metrics-lite</artifactId>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.minelink</groupId>
|
||||
<artifactId>CombatTagPlusCompat-v1_9_R1</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.minelink</groupId>
|
||||
<artifactId>CombatTagPlusCompat-v1_9_R2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.minelink</groupId>
|
||||
<artifactId>
|
||||
CombatTagPlusCompat-v1_10_R1
|
||||
</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
@ -836,22 +861,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Injector -->
|
||||
<dependency>
|
||||
<groupId>ch.jalu</groupId>
|
||||
<artifactId>injector</artifactId>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- String comparison library. Used for dynamic help system. -->
|
||||
<dependency>
|
||||
<groupId>net.ricecode</groupId>
|
||||
<artifactId>string-similarity</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- ConfigMe -->
|
||||
<dependency>
|
||||
<groupId>com.github.authme</groupId>
|
||||
@ -860,18 +869,21 @@
|
||||
</dependency>
|
||||
|
||||
<!-- Unit Testing Libraries -->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.0.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
@ -884,6 +896,7 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- JDBC drivers for datasource integration tests -->
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
@ -897,5 +910,6 @@
|
||||
<version>1.4.192</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -151,7 +151,7 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.info("Do you want a good game server? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!");
|
||||
|
||||
// Successful message
|
||||
ConsoleLogger.info("AuthMe " + getPluginVersion() + " build n°" + getPluginBuildNumber() + " correctly enabled!");
|
||||
ConsoleLogger.info("AuthMe " + getPluginVersion() + " build n." + getPluginBuildNumber() + " correctly enabled!");
|
||||
|
||||
// Purge on start if enabled
|
||||
PurgeService purgeService = injector.getSingleton(PurgeService.class);
|
||||
|
@ -282,7 +282,7 @@ public class CommandInitializer {
|
||||
.description("Converter command")
|
||||
.detailedDescription("Converter command for AuthMeReloaded.")
|
||||
.withArgument("job", "Conversion job: xauth / crazylogin / rakamak / " +
|
||||
"royalauth / vauth / sqlitetosql", false)
|
||||
"royalauth / vauth / sqliteToSql / mysqlToSqlite", false)
|
||||
.permission(AdminPermission.CONVERTER)
|
||||
.executableCommand(ConverterCommand.class)
|
||||
.build();
|
||||
|
@ -2,11 +2,13 @@ package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import ch.jalu.injector.Injector;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.converter.CrazyLoginConverter;
|
||||
import fr.xephi.authme.converter.MySqlToSqlite;
|
||||
import fr.xephi.authme.converter.RakamakConverter;
|
||||
import fr.xephi.authme.converter.RoyalAuthConverter;
|
||||
import fr.xephi.authme.converter.SqliteToSql;
|
||||
@ -18,12 +20,16 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Converter command: launches conversion based on its parameters.
|
||||
*/
|
||||
public class ConverterCommand implements ExecutableCommand {
|
||||
|
||||
@VisibleForTesting
|
||||
static final Map<String, Class<? extends Converter>> CONVERTERS = getConverters();
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@ -39,14 +45,14 @@ public class ConverterCommand implements ExecutableCommand {
|
||||
String job = arguments.get(0);
|
||||
|
||||
// Determine the job type
|
||||
ConvertType jobType = ConvertType.fromName(job);
|
||||
if (jobType == null) {
|
||||
commandService.send(sender, MessageKey.ERROR);
|
||||
Class<? extends Converter> converterClass = CONVERTERS.get(job.toLowerCase());
|
||||
if (converterClass == null) {
|
||||
sender.sendMessage("[AuthMe] Converter does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the proper converter instance
|
||||
final Converter converter = injector.newInstance(jobType.getConverterClass());
|
||||
final Converter converter = injector.newInstance(converterClass);
|
||||
|
||||
// Run the convert job
|
||||
bukkitService.runTaskAsynchronously(new Runnable() {
|
||||
@ -55,47 +61,31 @@ public class ConverterCommand implements ExecutableCommand {
|
||||
try {
|
||||
converter.execute(sender);
|
||||
} catch (Exception e) {
|
||||
commandService.send(sender, MessageKey.ERROR);
|
||||
ConsoleLogger.logException("Error during conversion:", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage("[AuthMe] Successfully converted from " + jobType.getName());
|
||||
sender.sendMessage("[AuthMe] Successfully started " + job);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
enum ConvertType {
|
||||
XAUTH("xauth", xAuthConverter.class),
|
||||
CRAZYLOGIN("crazylogin", CrazyLoginConverter.class),
|
||||
RAKAMAK("rakamak", RakamakConverter.class),
|
||||
ROYALAUTH("royalauth", RoyalAuthConverter.class),
|
||||
VAUTH("vauth", vAuthConverter.class),
|
||||
SQLITETOSQL("sqlitetosql", SqliteToSql.class);
|
||||
|
||||
private final String name;
|
||||
private final Class<? extends Converter> converterClass;
|
||||
|
||||
ConvertType(String name, Class<? extends Converter> converterClass) {
|
||||
this.name = name;
|
||||
this.converterClass = converterClass;
|
||||
}
|
||||
|
||||
public static ConvertType fromName(String name) {
|
||||
for (ConvertType type : ConvertType.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Class<? extends Converter> getConverterClass() {
|
||||
return converterClass;
|
||||
}
|
||||
/**
|
||||
* Initializes a map with all available converters.
|
||||
*
|
||||
* @return map with all available converters
|
||||
*/
|
||||
private static Map<String, Class<? extends Converter>> getConverters() {
|
||||
return ImmutableMap.<String, Class<? extends Converter>>builder()
|
||||
.put("xauth", xAuthConverter.class)
|
||||
.put("crazylogin", CrazyLoginConverter.class)
|
||||
.put("rakamak", RakamakConverter.class)
|
||||
.put("royalauth", RoyalAuthConverter.class)
|
||||
.put("vauth", vAuthConverter.class)
|
||||
.put("sqlitetosql", SqliteToSql.class)
|
||||
.put("mysqltosqlite", MySqlToSqlite.class)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Converts from one AuthMe data source type to another.
|
||||
*
|
||||
* @param <S> the source type to convert from
|
||||
*/
|
||||
public abstract class AbstractDataSourceConverter<S extends DataSource> implements Converter {
|
||||
|
||||
private DataSource destination;
|
||||
private DataSourceType destinationType;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param destination the data source to convert to
|
||||
* @param destinationType the data source type of the destination. The given data source is checked that its
|
||||
* type corresponds to this type before the conversion is started, enabling us to just pass
|
||||
* the current data source and letting this class check that the types correspond.
|
||||
*/
|
||||
public AbstractDataSourceConverter(DataSource destination, DataSourceType destinationType) {
|
||||
this.destination = destination;
|
||||
this.destinationType = destinationType;
|
||||
}
|
||||
|
||||
// Implementation note: Because of ForceFlatToSqlite it is possible that the CommandSender is null,
|
||||
// which is never the case when a converter is launched from the /authme converter command.
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
if (!destinationType.equals(destination.getType())) {
|
||||
if (sender != null) {
|
||||
sender.sendMessage("Please configure your connection to "
|
||||
+ destinationType + " and re-run this command");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
S source;
|
||||
try {
|
||||
source = getSource();
|
||||
} catch (Exception e) {
|
||||
logAndSendMessage(sender, "The data source to convert from could not be initialized");
|
||||
ConsoleLogger.logException("Could not initialize source:", e);
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> skippedPlayers = new ArrayList<>();
|
||||
for (PlayerAuth auth : source.getAllAuths()) {
|
||||
if (destination.isAuthAvailable(auth.getNickname())) {
|
||||
skippedPlayers.add(auth.getNickname());
|
||||
} else {
|
||||
destination.saveAuth(auth);
|
||||
destination.updateQuitLoc(auth);
|
||||
}
|
||||
}
|
||||
|
||||
if (!skippedPlayers.isEmpty()) {
|
||||
logAndSendMessage(sender, "Skipped conversion for players which were already in "
|
||||
+ destinationType + ": " + StringUtils.join(", ", skippedPlayers));
|
||||
}
|
||||
logAndSendMessage(sender, "Database successfully converted from " + source.getType()
|
||||
+ " to " + destinationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data source to convert from
|
||||
* @throws Exception during initialization of source
|
||||
*/
|
||||
protected abstract S getSource() throws Exception;
|
||||
|
||||
private static void logAndSendMessage(CommandSender sender, String message) {
|
||||
ConsoleLogger.info(message);
|
||||
// Make sure sender is not console user, which will see the message from ConsoleLogger already
|
||||
if (sender != null && !(sender instanceof ConsoleCommandSender)) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +1,14 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.FlatFile;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mandatory migration from the deprecated flat file datasource to SQLite.
|
||||
*/
|
||||
public class ForceFlatToSqlite {
|
||||
public class ForceFlatToSqlite extends AbstractDataSourceConverter<FlatFile> {
|
||||
|
||||
private final DataSource source;
|
||||
private final DataSource destination;
|
||||
private final FlatFile source;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -24,29 +17,12 @@ public class ForceFlatToSqlite {
|
||||
* @param destination The datasource to copy the data to (sqlite)
|
||||
*/
|
||||
public ForceFlatToSqlite(FlatFile source, DataSource destination) {
|
||||
super(destination, destination.getType());
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the conversion.
|
||||
*/
|
||||
public void run() {
|
||||
List<String> skippedPlayers = new ArrayList<>();
|
||||
for (PlayerAuth auth : source.getAllAuths()) {
|
||||
if (destination.isAuthAvailable(auth.getNickname())) {
|
||||
skippedPlayers.add(auth.getNickname());
|
||||
} else {
|
||||
destination.saveAuth(auth);
|
||||
destination.updateQuitLoc(auth);
|
||||
}
|
||||
}
|
||||
|
||||
if (!skippedPlayers.isEmpty()) {
|
||||
ConsoleLogger.warning("Warning: skipped conversion for players which were already in SQLite: "
|
||||
+ StringUtils.join(", ", skippedPlayers));
|
||||
}
|
||||
ConsoleLogger.info("Database successfully converted from " + source.getClass().getSimpleName()
|
||||
+ " to " + destination.getClass().getSimpleName());
|
||||
@Override
|
||||
public FlatFile getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
28
src/main/java/fr/xephi/authme/converter/MySqlToSqlite.java
Normal file
28
src/main/java/fr/xephi/authme/converter/MySqlToSqlite.java
Normal file
@ -0,0 +1,28 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.datasource.MySQL;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Converts from MySQL to SQLite.
|
||||
*/
|
||||
public class MySqlToSqlite extends AbstractDataSourceConverter<MySQL> {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
@Inject
|
||||
MySqlToSqlite(DataSource dataSource, Settings settings) {
|
||||
super(dataSource, DataSourceType.SQLITE);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MySQL getSource() throws SQLException, ClassNotFoundException {
|
||||
return new MySQL(settings);
|
||||
}
|
||||
}
|
@ -1,45 +1,28 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.datasource.SQLite;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SqliteToSql implements Converter {
|
||||
/**
|
||||
* Converts from SQLite to MySQL.
|
||||
*/
|
||||
public class SqliteToSql extends AbstractDataSourceConverter<SQLite> {
|
||||
|
||||
private final Settings settings;
|
||||
private final DataSource dataSource;
|
||||
private final Messages messages;
|
||||
|
||||
@Inject
|
||||
SqliteToSql(Settings settings, DataSource dataSource, Messages messages) {
|
||||
SqliteToSql(Settings settings, DataSource dataSource) {
|
||||
super(dataSource, DataSourceType.MYSQL);
|
||||
this.settings = settings;
|
||||
this.dataSource = dataSource;
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
if (dataSource.getType() != DataSourceType.MYSQL) {
|
||||
sender.sendMessage("Please configure your mySQL connection and re-run this command");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
SQLite data = new SQLite(settings);
|
||||
for (PlayerAuth auth : data.getAllAuths()) {
|
||||
dataSource.saveAuth(auth);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
messages.send(sender, MessageKey.ERROR);
|
||||
ConsoleLogger.logException("Problem during SQLite to SQL conversion:", e);
|
||||
}
|
||||
protected SQLite getSource() throws SQLException, ClassNotFoundException {
|
||||
return new SQLite(settings);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package fr.xephi.authme.permission;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.initialization.Reloadable;
|
||||
import fr.xephi.authme.permission.handlers.BPermissionsHandler;
|
||||
import fr.xephi.authme.permission.handlers.GroupManagerHandler;
|
||||
import fr.xephi.authme.permission.handlers.PermissionHandler;
|
||||
import fr.xephi.authme.permission.handlers.PermissionHandlerException;
|
||||
import fr.xephi.authme.permission.handlers.PermissionsBukkitHandler;
|
||||
@ -11,7 +10,6 @@ import fr.xephi.authme.permission.handlers.PermissionsExHandler;
|
||||
import fr.xephi.authme.permission.handlers.VaultHandler;
|
||||
import fr.xephi.authme.permission.handlers.ZPermissionsHandler;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -110,8 +108,6 @@ public class PermissionsManager implements Reloadable {
|
||||
switch (type) {
|
||||
case PERMISSIONS_EX:
|
||||
return new PermissionsExHandler();
|
||||
case ESSENTIALS_GROUP_MANAGER:
|
||||
return new GroupManagerHandler((GroupManager) plugin);
|
||||
case Z_PERMISSIONS:
|
||||
return new ZPermissionsHandler();
|
||||
case VAULT:
|
||||
|
@ -20,11 +20,6 @@ public enum PermissionsSystemType {
|
||||
*/
|
||||
B_PERMISSIONS("bPermissions", "bPermissions"),
|
||||
|
||||
/**
|
||||
* Essentials Group Manager.
|
||||
*/
|
||||
ESSENTIALS_GROUP_MANAGER("Essentials Group Manager", "GroupManager"),
|
||||
|
||||
/**
|
||||
* zPermissions.
|
||||
*/
|
||||
|
@ -1,84 +0,0 @@
|
||||
package fr.xephi.authme.permission.handlers;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupManagerHandler implements PermissionHandler {
|
||||
|
||||
private GroupManager groupManager;
|
||||
|
||||
public GroupManagerHandler(GroupManager groupManager) {
|
||||
this.groupManager = groupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addToGroup(Player player, String group) {
|
||||
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddsub " + player.getName() + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissionOffline(String name, PermissionNode node) {
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(name);
|
||||
if(handler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<String> perms = handler.getAllPlayersPermissions(name);
|
||||
return perms.contains(node.getNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGroup(Player player, String group) {
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player);
|
||||
return handler != null && handler.inGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFromGroup(Player player, String group) {
|
||||
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manudelsub " + player.getName() + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setGroup(Player player, String group) {
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player);
|
||||
for (String groupName : handler.getGroups(player.getName())) {
|
||||
removeFromGroup(player, groupName);
|
||||
}
|
||||
|
||||
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuadd " + player.getName() + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(Player player) {
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player);
|
||||
if (handler == null)
|
||||
return new ArrayList<>();
|
||||
return Arrays.asList(handler.getGroups(player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(Player player) {
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player);
|
||||
if (handler == null)
|
||||
return null;
|
||||
return handler.getGroup(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionsSystemType getPermissionSystem() {
|
||||
return PermissionsSystemType.ESSENTIALS_GROUP_MANAGER;
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ public class SecuritySettings implements SettingsHolder {
|
||||
"- '123456'",
|
||||
"- 'password'"})
|
||||
public static final Property<List<String>> UNSAFE_PASSWORDS =
|
||||
newLowercaseListProperty("settings.security.unsafePasswords", "123456", "password", "qwerty", "12345", "54321");
|
||||
newLowercaseListProperty("settings.security.unsafePasswords", "123456", "password", "qwerty", "12345", "54321", "123456789");
|
||||
|
||||
@Comment("Tempban a user's IP address if they enter the wrong password too many times")
|
||||
public static final Property<Boolean> TEMPBAN_ON_MAX_LOGINS =
|
||||
|
@ -69,7 +69,7 @@ public final class MigrationService {
|
||||
try {
|
||||
SQLite sqlite = new SQLite(settings);
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(flatFile, sqlite);
|
||||
converter.run();
|
||||
converter.execute(null);
|
||||
settings.setProperty(DatabaseSettings.BACKEND, DataSourceType.SQLITE);
|
||||
settings.save();
|
||||
return sqlite;
|
||||
|
@ -206,6 +206,7 @@ settings:
|
||||
- 'qwerty'
|
||||
- '12345'
|
||||
- '54321'
|
||||
- '123456789'
|
||||
registration:
|
||||
# enable registration on the server?
|
||||
enabled: true
|
||||
|
@ -7,12 +7,11 @@ wrong_pwd: '&cPassword errada!'
|
||||
unregistered: '&cRegisto eliminado com sucesso!'
|
||||
reg_disabled: '&cRegito de novos utilizadores desactivado'
|
||||
valid_session: '&cSessão válida'
|
||||
login: '&cAutenticado com sucesso!'
|
||||
login: '&bAutenticado com sucesso!'
|
||||
vb_nonActiv: '&fA sua conta não foi ainda activada, verifique o seu email onde irá receber indicações para activação de conta. '
|
||||
user_regged: '&cUtilizador já registado'
|
||||
usage_reg: '&cUse: /register seu@email.com seu@email.com'
|
||||
# TODO max_reg: Missing tags %reg_count, %reg_names, %max_acc
|
||||
max_reg: '&cAtingiu o numero máximo de registos permitidos'
|
||||
max_reg: '&cAtingiu o numero máximo de %reg_count contas registas, maximo de contas %max_acc'
|
||||
no_perm: '&cSem Permissões'
|
||||
error: '&fOcorreu um erro; Por favor contacte um admin'
|
||||
login_msg: '&cIdentifique-se com "/login password"'
|
||||
@ -36,7 +35,7 @@ name_len: '&cO seu nick é demasiado curto ou muito longo.'
|
||||
regex: '&cO seu nickname contém caracteres não permitidos. Permitido: REG_EX'
|
||||
add_email: '&cPor favor adicione o seu email com : /email add seuEmail confirmarSeuEmail'
|
||||
recovery_email: '&cPerdeu a sua password? Para a recuperar escreva /email recovery <seuEmail>'
|
||||
usage_captcha: '&cVocê precisa digitar um captcha, escreva: /captcha <theCaptcha>'
|
||||
usage_captcha: '&cPrecisa digitar um captcha, escreva: /captcha <theCaptcha>'
|
||||
wrong_captcha: '&cCaptcha errado, por favor escreva: /captcha THE_CAPTCHA'
|
||||
valid_captcha: '&cO seu captcha é válido!'
|
||||
kick_forvip: '&cUm jogador VIP entrou no servidor cheio!'
|
||||
@ -55,20 +54,20 @@ email_send: 'Nova palavra-passe enviada para o seu email!'
|
||||
country_banned: 'O seu país está banido deste servidor'
|
||||
antibot_auto_enabled: '[AuthMe] AntiBotMod activado automaticamente devido a um aumento anormal de tentativas de ligação!'
|
||||
antibot_auto_disabled: '[AuthMe] AntiBotMod desactivado automaticamente após %m minutos, esperamos que a invasão tenha parado'
|
||||
# TODO password_error_nick: '&cYou can''t use your name as password, please choose another one...'
|
||||
# TODO email_already_used: '&4The email address is already being used'
|
||||
# TODO password_error_unsafe: '&cThe chosen password isn''t safe, please choose another one...'
|
||||
# TODO kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
|
||||
# TODO invalid_name_case: 'You should join using username %valid, not %invalid.'
|
||||
password_error_nick: '&cNão pode o usar seu nome como senha, por favor, escolha outra ...'
|
||||
not_owner_error: 'Não é o proprietário da conta. Por favor, escolha outro nome!'
|
||||
two_factor_create: '&2O seu código secreto é o %code. Você pode verificá-lo a partir daqui %url'
|
||||
email_already_used: '&4O endereço de e-mail já está sendo usado'
|
||||
denied_command: '&cPara utilizar este comando é necessário estar logado!'
|
||||
same_ip_online: 'Um jogador com o mesmo IP já está em jogo!'
|
||||
password_error_chars: '&4Sua senha contém caracteres ilegais. caracteres permitidos: REG_EX'
|
||||
denied_chat: '&cPara usar o chat deve estar logado!'
|
||||
password_error_unsafe: '&cA senha escolhida não é segura, por favor, escolha outra ...'
|
||||
kick_antibot: 'Modo de protecção anti-Bot está habilitado! Tem que espere alguns minutos antes de entrar no servidor.'
|
||||
email_exists: '&cUm e-mail de recuperação já foi enviado! Pode descartá-lo e enviar um novo usando o comando abaixo:'
|
||||
invalid_name_case: 'Deve se juntar usando nome de usuário %valid, não %invalid.'
|
||||
# TODO accounts_owned_other: 'The player %name has %count accounts:'
|
||||
# TODO kicked_admin_registered: 'An admin just registered you; please log in again'
|
||||
# TODO tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.'
|
||||
# TODO password_error_chars: '&4Your password contains illegal characters. Allowed chars: REG_EX'
|
||||
# TODO incomplete_email_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.'
|
||||
# TODO denied_chat: '&cIn order to chat you must be authenticated!'
|
||||
# TODO denied_command: '&cIn order to use this command you must be authenticated!'
|
||||
# TODO same_ip_online: 'A player with the same IP is already in game!'
|
||||
# TODO email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
|
||||
# TODO accounts_owned_self: 'You own %count accounts:'
|
||||
# TODO two_factor_create: '&2Your secret code is %code. You can scan it from here %url'
|
||||
# TODO not_owner_error: 'You are not the owner of this account. Please choose another name!'
|
@ -8,7 +8,8 @@ softdepend:
|
||||
- Vault
|
||||
- PermissionsBukkit
|
||||
- PermissionsEX
|
||||
- EssentialsGroupManager
|
||||
- bPermissions
|
||||
- zPermissions
|
||||
- Multiverse-Core
|
||||
- Essentials
|
||||
- EssentialsSpawn
|
||||
|
@ -3,25 +3,30 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import ch.jalu.injector.Injector;
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.converter.RakamakConverter;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
@ -45,6 +50,11 @@ public class ConverterCommandTest {
|
||||
@Mock
|
||||
private Injector injector;
|
||||
|
||||
@BeforeClass
|
||||
public static void initLogger() {
|
||||
TestHelper.setupLogger();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleUnknownConversionType() {
|
||||
// given
|
||||
@ -54,51 +64,71 @@ public class ConverterCommandTest {
|
||||
command.executeCommand(sender, Collections.singletonList("invalid"));
|
||||
|
||||
// then
|
||||
verify(commandService).send(sender, MessageKey.ERROR);
|
||||
verify(sender).sendMessage(argThat(containsString("Converter does not exist")));
|
||||
verifyNoMoreInteractions(commandService);
|
||||
verifyZeroInteractions(injector);
|
||||
verifyZeroInteractions(bukkitService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveUniqueNameAndClassForEachType() {
|
||||
public void shouldHaveUniqueClassForEachConverter() {
|
||||
// given
|
||||
ConverterCommand.ConvertType[] types = ConverterCommand.ConvertType.values();
|
||||
List<String> names = new ArrayList<>(types.length);
|
||||
List<Class<?>> classes = new ArrayList<>(types.length);
|
||||
Set<Class<? extends Converter>> classes = new HashSet<>();
|
||||
|
||||
// when / then
|
||||
for (ConverterCommand.ConvertType type : types) {
|
||||
assertThat("Name for '" + type + "' is not null",
|
||||
type.getName(), not(nullValue()));
|
||||
assertThat("Class for '" + type + "' is not null",
|
||||
type.getConverterClass(), not(nullValue()));
|
||||
assertThat("Name '" + type.getName() + "' is unique",
|
||||
names, not(hasItem(type.getName())));
|
||||
assertThat("Class '" + type.getConverterClass() + "' is unique",
|
||||
classes, not(hasItem(type.getConverterClass())));
|
||||
names.add(type.getName());
|
||||
classes.add(type.getConverterClass());
|
||||
for (Map.Entry<String, Class<? extends Converter>> entry : ConverterCommand.CONVERTERS.entrySet()) {
|
||||
assertThat("Name is not null or empty",
|
||||
StringUtils.isEmpty(entry.getKey()), equalTo(false));
|
||||
|
||||
assertThat("Converter class is unique for each entry",
|
||||
classes.add(entry.getValue()), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldLaunchConverterForAllTypes() {
|
||||
// given
|
||||
ConverterCommand.ConvertType type = ConverterCommand.ConvertType.RAKAMAK;
|
||||
RakamakConverter converter = mock(RakamakConverter.class);
|
||||
given(injector.newInstance(RakamakConverter.class)).willReturn(converter);
|
||||
String converterName = "rakamak";
|
||||
Class<? extends Converter> converterClass = ConverterCommand.CONVERTERS.get(converterName);
|
||||
Converter converter = createMockReturnedByInjector(converterClass);
|
||||
CommandSender sender = mock(CommandSender.class);
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Collections.singletonList(type.getName()));
|
||||
command.executeCommand(sender, Collections.singletonList(converterName));
|
||||
TestHelper.runInnerRunnable(bukkitService);
|
||||
|
||||
// then
|
||||
verify(converter).execute(sender);
|
||||
verifyNoMoreInteractions(converter);
|
||||
verify(injector).newInstance(type.getConverterClass());
|
||||
verify(injector).newInstance(converterClass);
|
||||
verifyNoMoreInteractions(injector);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCatchExceptionInConverterAndInformSender() {
|
||||
// given
|
||||
String converterName = "vauth";
|
||||
Class<? extends Converter> converterClass = ConverterCommand.CONVERTERS.get(converterName);
|
||||
Converter converter = createMockReturnedByInjector(converterClass);
|
||||
doThrow(IllegalStateException.class).when(converter).execute(any(CommandSender.class));
|
||||
CommandSender sender = mock(CommandSender.class);
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Collections.singletonList(converterName.toUpperCase()));
|
||||
TestHelper.runInnerRunnable(bukkitService);
|
||||
|
||||
// then
|
||||
verify(converter).execute(sender);
|
||||
verifyNoMoreInteractions(converter);
|
||||
verify(injector).newInstance(converterClass);
|
||||
verifyNoMoreInteractions(injector);
|
||||
verify(commandService).send(sender, MessageKey.ERROR);
|
||||
}
|
||||
|
||||
private <T extends Converter> T createMockReturnedByInjector(Class<T> clazz) {
|
||||
T converter = mock(clazz);
|
||||
given(injector.newInstance(clazz)).willReturn(converter);
|
||||
return converter;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,126 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.only;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* Test for {@link AbstractDataSourceConverter}.
|
||||
*/
|
||||
public class AbstractDataSourceConverterTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void initLogger() {
|
||||
TestHelper.setupLogger();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldThrowForDestinationTypeMismatch() {
|
||||
// given
|
||||
DataSource destination = mock(DataSource.class);
|
||||
given(destination.getType()).willReturn(DataSourceType.MYSQL);
|
||||
DataSourceType destinationType = DataSourceType.SQLITE;
|
||||
DataSource source = mock(DataSource.class);
|
||||
Converter converter = new DataSourceConverterTestImpl<>(source, destination, destinationType);
|
||||
CommandSender sender = mock(CommandSender.class);
|
||||
|
||||
// when
|
||||
converter.execute(sender);
|
||||
|
||||
// then
|
||||
verify(sender).sendMessage(argThat(containsString("Please configure your connection to SQLITE")));
|
||||
verify(destination, only()).getType();
|
||||
verifyZeroInteractions(source);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleSourceThrowingException() {
|
||||
// given
|
||||
DataSource source = mock(DataSource.class);
|
||||
DataSource destination = mock(DataSource.class);
|
||||
DataSourceType destinationType = DataSourceType.SQLITE;
|
||||
given(destination.getType()).willReturn(destinationType);
|
||||
DataSourceConverterTestImpl converter =
|
||||
Mockito.spy(new DataSourceConverterTestImpl<>(source, destination, destinationType));
|
||||
doThrow(IllegalStateException.class).when(converter).getSource();
|
||||
CommandSender sender = mock(CommandSender.class);
|
||||
|
||||
// when
|
||||
converter.execute(sender);
|
||||
|
||||
// then
|
||||
verify(sender).sendMessage("The data source to convert from could not be initialized");
|
||||
verify(destination, only()).getType();
|
||||
verifyZeroInteractions(source);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldConvertAndSkipExistingPlayers() {
|
||||
// given
|
||||
DataSource source = mock(DataSource.class);
|
||||
DataSource destination = mock(DataSource.class);
|
||||
DataSourceType destinationType = DataSourceType.MYSQL;
|
||||
given(destination.getType()).willReturn(destinationType);
|
||||
|
||||
List<PlayerAuth> auths =
|
||||
Arrays.asList(mockAuthWithName("Steven"), mockAuthWithName("bobby"), mockAuthWithName("Jack"));
|
||||
given(source.getAllAuths()).willReturn(auths);
|
||||
given(destination.isAuthAvailable(auths.get(0).getNickname())).willReturn(true);
|
||||
|
||||
Converter converter = new DataSourceConverterTestImpl<>(source, destination, destinationType);
|
||||
CommandSender sender = mock(CommandSender.class);
|
||||
|
||||
// when
|
||||
converter.execute(sender);
|
||||
|
||||
// then
|
||||
verify(destination).getType();
|
||||
verify(destination, times(3)).isAuthAvailable(anyString());
|
||||
verify(destination, times(2)).saveAuth(any(PlayerAuth.class));
|
||||
verify(destination, times(2)).updateQuitLoc(any(PlayerAuth.class));
|
||||
verifyNoMoreInteractions(destination);
|
||||
verify(sender).sendMessage(argThat(containsString(auths.get(0).getNickname())));
|
||||
verify(sender).sendMessage(argThat(containsString("successfully converted")));
|
||||
}
|
||||
|
||||
private static PlayerAuth mockAuthWithName(String name) {
|
||||
PlayerAuth auth = mock(PlayerAuth.class);
|
||||
given(auth.getNickname()).willReturn(name);
|
||||
return auth;
|
||||
}
|
||||
|
||||
private static class DataSourceConverterTestImpl<S extends DataSource> extends AbstractDataSourceConverter<S> {
|
||||
private final S source;
|
||||
|
||||
DataSourceConverterTestImpl(S source, DataSource destination, DataSourceType destinationType) {
|
||||
super(destination, destinationType);
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected S getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import com.google.common.io.Files;
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.datasource.FlatFile;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@ -20,6 +21,7 @@ import static fr.xephi.authme.AuthMeMatchers.hasAuthBasicData;
|
||||
import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -51,10 +53,11 @@ public class ForceFlatToSqliteTest {
|
||||
public void shouldConvertToSqlite() {
|
||||
// given
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
given(dataSource.getType()).willReturn(DataSourceType.MYSQL);
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(flatFile, dataSource);
|
||||
|
||||
// when
|
||||
converter.run();
|
||||
converter.execute(null);
|
||||
|
||||
// then
|
||||
ArgumentCaptor<PlayerAuth> authCaptor = ArgumentCaptor.forClass(PlayerAuth.class);
|
||||
|
Loading…
Reference in New Issue
Block a user