first commit
This commit is contained in:
commit
bfd16f833e
32
Commons.iml
Normal file
32
Commons.iml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
|
||||
</component>
|
||||
</module>
|
178
pom.xml
Normal file
178
pom.xml
Normal file
@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>eu.univento</groupId>
|
||||
<artifactId>Commons</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>univento.eu Common Code</name>
|
||||
<url>https://development.univento.eu/docs/Commons</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>eu.univento.commons.Commons</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.4</version>
|
||||
<configuration>
|
||||
<locales>en</locales>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.wvengen</groupId>
|
||||
<artifactId>proguard-maven-plugin</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>proguard</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<obfuscate>true</obfuscate>
|
||||
<injar>${project.build.finalName}.jar</injar>
|
||||
<outjar>${project.build.finalName}-small.jar</outjar>
|
||||
<includeDependency>true</includeDependency>
|
||||
<options>
|
||||
<option>-keep public class eu.univento.commons.Commons { *; }</option>
|
||||
</options>
|
||||
<libs>
|
||||
<lib>${java.home}/lib/rt.jar</lib>
|
||||
<lib>${java.home}/lib/jce.jar</lib>
|
||||
</libs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>Commons</mainClass>
|
||||
<packageName>eu.univento.commons</packageName>
|
||||
</manifest>
|
||||
</archive>
|
||||
|
||||
</configuration>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.proguard</groupId>
|
||||
<artifactId>proguard-base</artifactId>
|
||||
<version>5.2.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-async</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.0.36.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.4.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
46
src/main/java/eu/univento/commons/Commons.java
Normal file
46
src/main/java/eu/univento/commons/Commons.java
Normal file
@ -0,0 +1,46 @@
|
||||
package eu.univento.commons;
|
||||
|
||||
import eu.univento.commons.configuration.ConfigurationHandler;
|
||||
import eu.univento.commons.database.DatabaseManager;
|
||||
import eu.univento.commons.logging.LoggingHandler;
|
||||
import eu.univento.commons.security.SecurityHandler;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Commons {
|
||||
|
||||
private DatabaseManager databaseManager;
|
||||
public DatabaseManager getDatabaseManager() {
|
||||
return databaseManager;
|
||||
}
|
||||
|
||||
private ConfigurationHandler configurationHandler;
|
||||
public ConfigurationHandler getConfigurationHandler() {
|
||||
return configurationHandler;
|
||||
}
|
||||
|
||||
private SecurityHandler securityHandler;
|
||||
public SecurityHandler getSecurityHandler() {
|
||||
return securityHandler;
|
||||
}
|
||||
|
||||
private LoggingHandler loggingHandler;
|
||||
public LoggingHandler getLoggingHandler() {
|
||||
return loggingHandler;
|
||||
}
|
||||
|
||||
public Commons() {
|
||||
configurationHandler = new ConfigurationHandler();
|
||||
databaseManager = new DatabaseManager(this);
|
||||
securityHandler = new SecurityHandler(this);
|
||||
loggingHandler = new LoggingHandler();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
getDatabaseManager().closeConnections();
|
||||
//loggingHandler.shutdown();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package eu.univento.commons.configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class ConfigurationHandler {
|
||||
|
||||
private Properties properties;
|
||||
|
||||
public ConfigurationHandler() {
|
||||
properties = new Properties();
|
||||
InputStream in;
|
||||
try {
|
||||
in = getClass().getResourceAsStream("/config.properties");
|
||||
properties.load(in);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getProperty(String key) {
|
||||
return properties.getProperty(key);
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
return String.valueOf(getProperty(key));
|
||||
}
|
||||
|
||||
public int getInteger(String key) {
|
||||
return Integer.valueOf(getString(key));
|
||||
}
|
||||
}
|
61
src/main/java/eu/univento/commons/database/AsyncMongoDB.java
Normal file
61
src/main/java/eu/univento/commons/database/AsyncMongoDB.java
Normal file
@ -0,0 +1,61 @@
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.async.client.MongoClient;
|
||||
import com.mongodb.async.client.MongoClientSettings;
|
||||
import com.mongodb.async.client.MongoClients;
|
||||
import com.mongodb.async.client.MongoDatabase;
|
||||
import com.mongodb.connection.ClusterSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class AsyncMongoDB {
|
||||
|
||||
private final MongoClient client;
|
||||
private MongoDatabase database;
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final String databaseName;
|
||||
|
||||
public AsyncMongoDB(String host, int port, String username, String password, String databaseName) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.databaseName = databaseName;
|
||||
|
||||
List<ServerAddress> addressList = new ArrayList<>();
|
||||
addressList.add(new ServerAddress(host, port));
|
||||
List<MongoCredential> credentials = new ArrayList<>();
|
||||
credentials.add(MongoCredential.createCredential(username, databaseName, password.toCharArray()));
|
||||
ClusterSettings clusterSettings = ClusterSettings.builder().hosts(addressList).build();
|
||||
MongoClientSettings settings = MongoClientSettings.builder().clusterSettings(clusterSettings).credentialList(credentials).build();
|
||||
client = MongoClients.create(settings);
|
||||
}
|
||||
|
||||
private MongoClient getClient() {
|
||||
if(client == null)
|
||||
new AsyncMongoDB(host, port, username, password, databaseName);
|
||||
return client;
|
||||
}
|
||||
|
||||
public MongoDatabase getDatabase() {
|
||||
if(database == null)
|
||||
database = getClient().getDatabase(databaseName);
|
||||
return database;
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
if(client != null)
|
||||
client.close();
|
||||
}
|
||||
}
|
42
src/main/java/eu/univento/commons/database/AsyncMySQL.java
Normal file
42
src/main/java/eu/univento/commons/database/AsyncMySQL.java
Normal file
@ -0,0 +1,42 @@
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class AsyncMySQL {
|
||||
|
||||
private ExecutorService executor;
|
||||
private MySQL sql;
|
||||
|
||||
public AsyncMySQL(String host, String port, String user, String password, String database) {
|
||||
try {
|
||||
sql = new MySQL(host, port, user, password, database);
|
||||
executor = Executors.newCachedThreadPool();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String update) {
|
||||
executor.execute(() -> sql.query(update));
|
||||
}
|
||||
|
||||
public void query(String query, Consumer<ResultSet> consumer) {
|
||||
executor.execute(() -> {
|
||||
ResultSet result = null;
|
||||
result = sql.query(query);
|
||||
ResultSet finalResult = result;
|
||||
consumer.accept(finalResult);
|
||||
});
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return sql;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import eu.univento.commons.Commons;
|
||||
import eu.univento.commons.configuration.ConfigurationHandler;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class DatabaseManager {
|
||||
|
||||
private MongoDB mongoDB;
|
||||
private AsyncMongoDB asyncMongoDB;
|
||||
private MySQL mySQL;
|
||||
private AsyncMySQL asyncMySQL;
|
||||
private AsyncMySQL boardSQL;
|
||||
|
||||
public DatabaseManager(Commons commons) {
|
||||
ConfigurationHandler config = commons.getConfigurationHandler();
|
||||
mongoDB = new MongoDB(config.getString("MongoDB.Host"), config.getInteger("MongoDB.Port"), config.getString("MongoDB.Username"), config.getString("MongoDB.Password"), config.getString("MongoDB.Database"));
|
||||
asyncMongoDB = new AsyncMongoDB(config.getString("MongoDB.Host"), config.getInteger("MongoDB.Port"), config.getString("MongoDB.Username"), config.getString("MongoDB.Password"), config.getString("MongoDB.Database"));
|
||||
mySQL = new MySQL(config.getString("MySQL.Host"), config.getString("MySQL.Port"), config.getString("MySQL.Database"), config.getString("MySQL.Username"), config.getString("MySQL.Password"));
|
||||
asyncMySQL = new AsyncMySQL(config.getString("MySQL.Host"), config.getString("MySQL.Port"), config.getString("MySQL.Database"), config.getString("MySQL.Username"), config.getString("MySQL.Password"));
|
||||
boardSQL = new AsyncMySQL("univento.eu", "3306", "forum", "forum", "2Ogxk6$5Yvsr4*24");
|
||||
|
||||
}
|
||||
|
||||
public void closeConnections() {
|
||||
mongoDB.closeConnection();
|
||||
asyncMongoDB.closeConnection();
|
||||
mySQL.close();
|
||||
asyncMySQL.getMySQL().close();
|
||||
boardSQL.getMySQL().close();
|
||||
}
|
||||
|
||||
public MongoDB getMongoDB() {
|
||||
return mongoDB;
|
||||
}
|
||||
|
||||
public AsyncMongoDB getAsyncMongoDB() {
|
||||
return asyncMongoDB;
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return mySQL;
|
||||
}
|
||||
|
||||
public AsyncMySQL getAsyncMySQL() {
|
||||
return asyncMySQL;
|
||||
}
|
||||
|
||||
public AsyncMySQL getBoardSQL() {
|
||||
return boardSQL;
|
||||
}
|
||||
}
|
56
src/main/java/eu/univento/commons/database/MongoDB.java
Normal file
56
src/main/java/eu/univento/commons/database/MongoDB.java
Normal file
@ -0,0 +1,56 @@
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MongoDB {
|
||||
|
||||
private final MongoClient client;
|
||||
private MongoDatabase database;
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final String databaseName;
|
||||
|
||||
public MongoDB(String host, int port, String username, String password, String databaseName) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.databaseName = databaseName;
|
||||
|
||||
MongoCredential credential = MongoCredential.createCredential(username, databaseName, password.toCharArray());
|
||||
client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential));
|
||||
}
|
||||
|
||||
private MongoClient getClient() {
|
||||
if(client == null)
|
||||
new MongoDB(host, port, username, password, databaseName);
|
||||
return client;
|
||||
}
|
||||
|
||||
public MongoDatabase getDatabase() {
|
||||
if(database == null)
|
||||
database = getClient().getDatabase(databaseName);
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = getClient().getDatabase(database);
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
if(client != null)
|
||||
client.close();
|
||||
}
|
||||
}
|
79
src/main/java/eu/univento/commons/database/MySQL.java
Normal file
79
src/main/java/eu/univento/commons/database/MySQL.java
Normal file
@ -0,0 +1,79 @@
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MySQL {
|
||||
private final String username;
|
||||
private final String database;
|
||||
private final String password;
|
||||
private final String port;
|
||||
private final String hostname;
|
||||
|
||||
private final HikariDataSource dataSource;
|
||||
|
||||
public MySQL(String hostname, String port, String database, String username, String password) {
|
||||
this.username = username;
|
||||
this.database = database;
|
||||
this.password = password;
|
||||
this.port = port;
|
||||
this.hostname = hostname;
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database);
|
||||
config.setUsername(username);
|
||||
config.setPassword(password);
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
|
||||
dataSource = new HikariDataSource(config);
|
||||
}
|
||||
|
||||
void close() {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
public HikariDataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
try {
|
||||
if (dataSource.getConnection() != null)
|
||||
return dataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int update(String sql) {
|
||||
try {
|
||||
PreparedStatement statement = getConnection().prepareStatement(sql);
|
||||
return statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ResultSet query(String sql) {
|
||||
PreparedStatement statement;
|
||||
try {
|
||||
statement = getConnection().prepareStatement(sql);
|
||||
return statement.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package eu.univento.commons.logging;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class LoggingHandler {
|
||||
|
||||
public Logger getCommons() {
|
||||
return LogManager.getLogger("univento Commons");
|
||||
}
|
||||
|
||||
public Logger getCore() {
|
||||
return LogManager.getLogger("univento Core");
|
||||
}
|
||||
|
||||
public Logger getBungeeCore() {
|
||||
return LogManager.getLogger("univento BungeeCore");
|
||||
}
|
||||
|
||||
public Logger getLobby() {
|
||||
return LogManager.getLogger("univento Lobby");
|
||||
}
|
||||
|
||||
public Logger getTrashGames() {
|
||||
return LogManager.getLogger("univento TrashGames");
|
||||
}
|
||||
|
||||
public Logger getTeamVento() {
|
||||
return LogManager.getLogger("univento TeamVento");
|
||||
}
|
||||
|
||||
public LoggingHandler() {
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
LogManager.shutdown();
|
||||
}
|
||||
}
|
454
src/main/java/eu/univento/commons/player/DatabasePlayer.java
Normal file
454
src/main/java/eu/univento/commons/player/DatabasePlayer.java
Normal file
@ -0,0 +1,454 @@
|
||||
package eu.univento.commons.player;
|
||||
|
||||
import com.mongodb.CursorType;
|
||||
import com.mongodb.client.FindIterable;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import eu.univento.commons.Commons;
|
||||
import eu.univento.commons.database.MongoDB;
|
||||
import eu.univento.commons.player.ban.BanData;
|
||||
import eu.univento.commons.player.ban.BanReason;
|
||||
import eu.univento.commons.player.friend.FriendData;
|
||||
import eu.univento.commons.player.kick.KickData;
|
||||
import eu.univento.commons.player.kick.KickReason;
|
||||
import eu.univento.commons.player.language.Language;
|
||||
import eu.univento.commons.player.mute.MuteData;
|
||||
import eu.univento.commons.player.mute.MuteReason;
|
||||
import eu.univento.commons.player.profiles.Profile;
|
||||
import eu.univento.commons.player.settings.PlayerSettings;
|
||||
import eu.univento.commons.player.warn.WarnData;
|
||||
import eu.univento.commons.player.warn.WarnReason;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class DatabasePlayer {
|
||||
|
||||
private UUID uuid;
|
||||
private Commons commons;
|
||||
|
||||
private final MongoDB mongoDB;
|
||||
private final PlayerSettings settings;
|
||||
|
||||
private final MongoCollection<Document> playerCollection;
|
||||
private final MongoCollection<Document> friendCollection;
|
||||
private final MongoCollection<Document> onlinePlayerCollection;
|
||||
private final MongoCollection<Document> banCollection;
|
||||
private final MongoCollection<Document> warnCollection;
|
||||
private final MongoCollection<Document> kickCollection;
|
||||
private final MongoCollection<Document> muteCollection;
|
||||
private final MongoCollection<Document> profileCollection;
|
||||
|
||||
public DatabasePlayer(Commons commons, UUID uuid) {
|
||||
this.commons = commons;
|
||||
this.uuid = uuid;
|
||||
settings = new PlayerSettings(this);
|
||||
|
||||
this.mongoDB = commons.getDatabaseManager().getMongoDB();
|
||||
playerCollection = mongoDB.getDatabase().getCollection("players");
|
||||
friendCollection = mongoDB.getDatabase().getCollection("friends");
|
||||
onlinePlayerCollection = mongoDB.getDatabase().getCollection("online-players");
|
||||
banCollection = mongoDB.getDatabase().getCollection("bans");
|
||||
warnCollection = mongoDB.getDatabase().getCollection("warns");
|
||||
kickCollection = mongoDB.getDatabase().getCollection("kicks");
|
||||
muteCollection = mongoDB.getDatabase().getCollection("mutes");
|
||||
profileCollection = mongoDB.getDatabase().getCollection("profiles");
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getPlayerCollection() {
|
||||
return playerCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getFriendCollection() {
|
||||
return friendCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getOnlinePlayerCollection() {
|
||||
return onlinePlayerCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getBanCollection() {
|
||||
return banCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getWarnCollection() {
|
||||
return warnCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getKickCollection() {
|
||||
return kickCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getMuteCollection() {
|
||||
return muteCollection;
|
||||
}
|
||||
|
||||
public MongoCollection<Document> getProfileCollection() {
|
||||
return profileCollection;
|
||||
}
|
||||
|
||||
public Collection<Profile> getProfiles() {
|
||||
ArrayList<String> list = getArrayListFromDatabase("profiles");
|
||||
return list.stream().map(id -> new Profile(this, id)).collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
public void ban(BanReason reason, UUID banner, String customMessage, String proof) {
|
||||
Document doc = new Document("uuid", uuid.toString());
|
||||
int i = 0;
|
||||
if(getAllBans().size() > 1) {
|
||||
for (BanData ban : getAllBans()) i =+ ban.getReason().getValue();
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, reason.getValue() + i);
|
||||
doc.put("date", calendar.getTime());
|
||||
doc.put("reason", reason.name());
|
||||
doc.put("banner", banner.toString());
|
||||
doc.put("customMessage", customMessage);
|
||||
doc.put("proof", proof);
|
||||
|
||||
banCollection.insertOne(doc);
|
||||
}
|
||||
|
||||
public BanData getBan() {
|
||||
if(!isBanned()) return null;
|
||||
FindIterable<Document> cursor = banCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Document doc = cursor.first();
|
||||
return new BanData(BanReason.valueOf(doc.getString("reason")), UUID.fromString(doc.getString("banner")), doc.getString("customMessage"), doc.getDate("date"), doc.getString("proof"));
|
||||
}
|
||||
|
||||
public boolean isBanned() {
|
||||
return getBan() != null && !new Date().after(getBan().getUnbanDate());
|
||||
}
|
||||
|
||||
public Collection<BanData> getAllBans() {
|
||||
FindIterable<Document> cursor = banCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Iterator<Document> iterator = cursor.iterator();
|
||||
Collection<BanData> collection = new LinkedList<>();
|
||||
while(iterator.hasNext()) {
|
||||
Document doc = iterator.next();
|
||||
collection.add(new BanData(BanReason.valueOf(doc.getString("reason")), UUID.fromString(doc.getString("banner")), doc.getString("customMessage"), doc.getDate("date"), doc.getString("proof")));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public void warn(WarnReason reason, UUID warner, String proof) {
|
||||
Document doc = new Document("uuid", uuid.toString());
|
||||
doc.put("reason", reason.name());
|
||||
doc.put("warner", warner.toString());
|
||||
doc.put("date", new Date());
|
||||
doc.put("proof", proof);
|
||||
|
||||
warnCollection.insertOne(doc);
|
||||
}
|
||||
|
||||
public boolean isWarned() {
|
||||
FindIterable<Document> cursor = warnCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Document doc = cursor.first();
|
||||
return doc != null && !new Date().after(doc.getDate("date"));
|
||||
}
|
||||
|
||||
public Collection<WarnData> getAllWarns() {
|
||||
FindIterable<Document> cursor = warnCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Iterator<Document> iterator = cursor.iterator();
|
||||
Collection<WarnData> collection = new LinkedList<>();
|
||||
while(iterator.hasNext()) {
|
||||
Document doc = iterator.next();
|
||||
collection.add(new WarnData(WarnReason.valueOf(doc.getString("reason")), UUID.fromString(doc.getString("warner")), doc.getDate("date"), doc.getString("proof")));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public void kick(UUID kicker, KickReason reason) {
|
||||
Document doc = new Document("uuid", uuid.toString());
|
||||
doc.put("reason", reason.name());
|
||||
doc.put("kicker", kicker.toString());
|
||||
doc.put("date", new Date());
|
||||
|
||||
kickCollection.insertOne(doc);
|
||||
}
|
||||
|
||||
public Collection<KickData> getAllKicks() {
|
||||
FindIterable<Document> cursor = kickCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Iterator<Document> iterator = cursor.iterator();
|
||||
LinkedList<KickData> collection = new LinkedList<>();
|
||||
while(iterator.hasNext()) {
|
||||
Document doc = iterator.next();
|
||||
collection.add(new KickData(KickReason.valueOf(doc.getString("reason")), doc.getDate("date"), UUID.fromString(doc.getString("kicker"))));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public void mute(UUID muter, MuteReason reason) {
|
||||
Document doc = new Document("uuid", uuid.toString());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, reason.getTime());
|
||||
doc.put("reason", reason.name());
|
||||
doc.put("muter", muter.toString());
|
||||
doc.put("date", calendar.getTime());
|
||||
|
||||
muteCollection.insertOne(doc);
|
||||
}
|
||||
|
||||
public boolean isMuted() {
|
||||
FindIterable<Document> cursor = muteCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Document doc = cursor.first();
|
||||
return doc != null && !new Date().after(doc.getDate("date"));
|
||||
}
|
||||
|
||||
public MuteData getMute() {
|
||||
for(MuteData mute : getAllMutes()) {
|
||||
if(new Date().before(mute.getDate())) {
|
||||
return mute;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<MuteData> getAllMutes() {
|
||||
FindIterable<Document> cursor = muteCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Iterator<Document> iterator = cursor.iterator();
|
||||
LinkedList<MuteData> collection = new LinkedList<>();
|
||||
while(iterator.hasNext()) {
|
||||
Document doc = iterator.next();
|
||||
collection.add(new MuteData(MuteReason.valueOf(doc.getString("reason")), UUID.fromString(doc.getString("uuid")), UUID.fromString(doc.getString("muter")), doc.getDate("date")));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public PlayerSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public Rank getRank() {
|
||||
return Rank.valueOf(getStringFromDatabase("rank"));
|
||||
}
|
||||
|
||||
public void setRank(Rank rank) {
|
||||
setInDatabase("rank", rank.name());
|
||||
}
|
||||
|
||||
public boolean isAllowed(Rank rank) {
|
||||
return getRank().getValue() >= rank.getValue();
|
||||
}
|
||||
|
||||
public boolean hasPlayedBefore() {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document obj = cursor.first();
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
public void setTSID(String id) {
|
||||
setInDatabase("tsid", id);
|
||||
}
|
||||
|
||||
public void setCoins(int coins) {
|
||||
setInDatabase("coins", coins);
|
||||
}
|
||||
|
||||
public void setExperience(int experience) {
|
||||
setInDatabase("experience", experience);
|
||||
}
|
||||
|
||||
private void setFoundSecrets(ArrayList<String> secrets) {
|
||||
setInDatabase("foundSecrets", secrets);
|
||||
}
|
||||
|
||||
public void addSecret(String name) {
|
||||
ArrayList<String> list = getFoundSecrets();
|
||||
list.add(name);
|
||||
setFoundSecrets(list);
|
||||
}
|
||||
|
||||
private void setFoundEggs(ArrayList<String> eggs) {
|
||||
setInDatabase("foundEggs", eggs);
|
||||
}
|
||||
|
||||
public void addEgg(String name) {
|
||||
ArrayList<String> list = getFoundEggs();
|
||||
list.add(name);
|
||||
setFoundEggs(list);
|
||||
}
|
||||
|
||||
public Date getFirstLogin() {
|
||||
return getDateFromDatabase("firstLogin");
|
||||
}
|
||||
|
||||
public Date getLastLogin() {
|
||||
return getDateFromDatabase("lastLogin");
|
||||
}
|
||||
|
||||
public Date getLastOnline() {
|
||||
return getDateFromDatabase("lastOnline");
|
||||
}
|
||||
|
||||
public String getLastIP() {
|
||||
return getStringFromDatabase("lastIP");
|
||||
}
|
||||
|
||||
public String getTSID() {
|
||||
return getStringFromDatabase("tsid");
|
||||
}
|
||||
|
||||
public int getTimesJoined() {
|
||||
return getIntegerFromDatabase("timesJoined");
|
||||
}
|
||||
|
||||
public int getCoins() {
|
||||
return getIntegerFromDatabase("coins");
|
||||
}
|
||||
|
||||
public int getExperience() {
|
||||
return getIntegerFromDatabase("experience");
|
||||
}
|
||||
|
||||
public int getSecrets() {
|
||||
return getFoundSecrets().size();
|
||||
}
|
||||
|
||||
private ArrayList<String> getFoundSecrets() {
|
||||
return getArrayListFromDatabase("foundSecrets");
|
||||
}
|
||||
|
||||
public int getEggs() {
|
||||
return getFoundEggs().size();
|
||||
}
|
||||
|
||||
private ArrayList<String> getFoundEggs() {
|
||||
return getArrayListFromDatabase("foundEggs");
|
||||
}
|
||||
|
||||
private void setFriends(Collection<FriendData> friends) {
|
||||
List<UUID> list = friends.stream().map(FriendData::getUuid).collect(Collectors.toCollection(LinkedList::new));
|
||||
friendCollection.updateOne(new Document("uuid", uuid.toString()), new Document("$set", new Document("friends", list)));
|
||||
}
|
||||
|
||||
public Collection<FriendData> getFriends() {
|
||||
FindIterable<Document> cursor = friendCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
LinkedList<UUID> list = (LinkedList<UUID>) doc.get("friends");
|
||||
|
||||
return list.stream().map(FriendData::new).collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
public boolean isFriend(UUID uuid) {
|
||||
for(FriendData friend : getFriends()) {
|
||||
if(friend.getUuid() == uuid) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addFriend(UUID uuid) {
|
||||
Collection<FriendData> list = getFriends();
|
||||
assert list != null;
|
||||
list.add(new FriendData(uuid));
|
||||
setFriends(list);
|
||||
}
|
||||
|
||||
public void removeFriend(UUID uuid) {
|
||||
Collection<FriendData> list = getFriends();
|
||||
assert list != null;
|
||||
list.remove(new FriendData(uuid));
|
||||
setFriends(list);
|
||||
}
|
||||
|
||||
public void addCoins(int coins) {
|
||||
setCoins(getCoins() + coins);
|
||||
}
|
||||
|
||||
public void substractCoins(int coins) {
|
||||
setCoins(getCoins() - coins);
|
||||
}
|
||||
|
||||
public String getMessage(String message) {
|
||||
return new Language(getSettings().getLanguage()).getWord(message);
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
FindIterable<Document> cursor = onlinePlayerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Document doc = cursor.first();
|
||||
return doc != null;
|
||||
}
|
||||
|
||||
public int getBoardID() {
|
||||
return getIntegerFromDatabase("boardID");
|
||||
}
|
||||
|
||||
public void setBoardID(int id) {
|
||||
setInDatabase("boardID", id);
|
||||
}
|
||||
|
||||
//database handling methods
|
||||
public void setInDatabase(String name, Object obj) {
|
||||
playerCollection.updateOne(new Document("uuid", uuid.toString()), new Document("$set", new Document(name, obj)));
|
||||
}
|
||||
|
||||
public Object getObjectFromDatbase(String name) {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.get(name);
|
||||
}
|
||||
|
||||
public int getIntegerFromDatabase(String name) {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return 0;
|
||||
|
||||
return doc.getInteger(name);
|
||||
}
|
||||
|
||||
public String getStringFromDatabase(String name) {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.getString(name);
|
||||
}
|
||||
|
||||
public Date getDateFromDatabase(String name) {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
||||
Document doc = cursor.first();
|
||||
if (doc == null) return null;
|
||||
|
||||
return doc.getDate(name);
|
||||
}
|
||||
|
||||
public ArrayList<String> getArrayListFromDatabase(String name) {
|
||||
return (ArrayList<String>) getObjectFromDatbase(name);
|
||||
}
|
||||
|
||||
public Map<String, Object> getMapFromDatabase(String name) {
|
||||
return (Map<String, Object>) getObjectFromDatbase(name);
|
||||
}
|
||||
}
|
77
src/main/java/eu/univento/commons/player/Rank.java
Normal file
77
src/main/java/eu/univento/commons/player/Rank.java
Normal file
@ -0,0 +1,77 @@
|
||||
package eu.univento.commons.player;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum Rank {
|
||||
|
||||
Admin(16, 107, 5, "§4", "§8[§4Admin§8] ", " §8»§7 ", "a", "§4Admin | "),
|
||||
SrDeveloper(15, 141, 18, "§3", "§8[§3SrDev§8] ", " §8»§7 ", "c", "§3SrDev | "),
|
||||
SrBuilder(14, 142, 15, "§2", "§8[§2SrBuilder§8] ", " §8»§7 ", "f", "§2SrBuilder | "),
|
||||
SrSupporter(13, 149, 12, "§9", "§8[§9SrSupr§8] ", " §8»§7 ", "i", "§9SrSup | "),
|
||||
Developer(12, 144, 17, "§3", "§8[§3Dev§8] ", " §8»§7 ", "d", "§3Dev | "),
|
||||
Builder(11, 145, 14, "§2", "§8[§2Builder§8] ", " §8»§7 ", "g", "§2Builder | "),
|
||||
Supporter(10, 146, 11, "§9", "§8[§9Sup§8] ", " §8»§7 ", "j", "§9Sup | "),
|
||||
JrDeveloper(9, 147, 16, "§3", "§8[§3JrDev§8] ", " §8»§7 ", "e", "§3JrDev | "),
|
||||
JrBuilder(8, 148, 13, "§2", "§8[§2JrBuilder§8] ", " §8»§7 ", "h", "§2JrBuilder | "),
|
||||
JrSupporter(7, 149, 10, "§9", "§8[§9JrSup§8] ", " §8»§7 ", "k", "§9JrSup | "),
|
||||
Manager(6, 150, 19, "§c", "§8[§cManager§8] ", " §8»§7 ", "b", "§cManager | "),
|
||||
Grafik(5, 151, 8, "§e", "§8[§eGrafiker§8] ", " §8»§7 ", "l", "§eGrafik | "),
|
||||
Sound(4, 152, 9, "§e", "§8[§eSound§8] ", " §8»§7 ", "m", "§eSound | "),
|
||||
Partner(3, 155, 7, "§5", "§5", " §8»§7 ", "n", "§5"),
|
||||
Premium(2, 156, 6, "§6", "§6", " §8§7» ", "o", "§6"),
|
||||
Player(1, 164, 2, "§7", "§7", " §8»§7 ", "p", "§7");
|
||||
|
||||
private final int value;
|
||||
private final int ts;
|
||||
private final int board;
|
||||
private final String color;
|
||||
private final String prefix;
|
||||
private final String suffix;
|
||||
private final String team;
|
||||
private final String tab;
|
||||
|
||||
Rank(int value, int ts, int board, String color, String prefix, String suffix, String team, String tab) {
|
||||
this.value = value;
|
||||
this.ts = ts;
|
||||
this.board = board;
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.team = team;
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getTS() {
|
||||
return ts;
|
||||
}
|
||||
|
||||
public int getBoard() {
|
||||
return board;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public String getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public String getTab() {
|
||||
return tab;
|
||||
}
|
||||
}
|
79
src/main/java/eu/univento/commons/player/ban/BanData.java
Normal file
79
src/main/java/eu/univento/commons/player/ban/BanData.java
Normal file
@ -0,0 +1,79 @@
|
||||
package eu.univento.commons.player.ban;
|
||||
|
||||
import eu.univento.commons.player.uuid.NameFetcher;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Period;
|
||||
import org.joda.time.format.PeriodFormatter;
|
||||
import org.joda.time.format.PeriodFormatterBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class BanData {
|
||||
|
||||
private BanReason reason;
|
||||
private UUID banner;
|
||||
private String customMessage;
|
||||
private Date unbanDate;
|
||||
private String proof;
|
||||
|
||||
public BanData(BanReason reason, UUID banner, String customMessage, Date unbanDate, String proof) {
|
||||
this.reason = reason;
|
||||
this.banner = banner;
|
||||
this.customMessage = customMessage;
|
||||
this.unbanDate = unbanDate;
|
||||
this.proof = proof;
|
||||
}
|
||||
|
||||
public BanReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public UUID getBanner() {
|
||||
return banner;
|
||||
}
|
||||
|
||||
public boolean hasCustomReason() {
|
||||
return getReason() == BanReason.CUSTOM;
|
||||
}
|
||||
|
||||
public String getCustomMessage() {
|
||||
return customMessage;
|
||||
}
|
||||
|
||||
public Date getUnbanDate() {
|
||||
return unbanDate;
|
||||
}
|
||||
|
||||
public String getProof() {
|
||||
return proof;
|
||||
}
|
||||
|
||||
public String getBannerName() {
|
||||
return NameFetcher.getRequest(banner);
|
||||
}
|
||||
|
||||
public String getTimeTillUnban() {
|
||||
assert getUnbanDate() != null;
|
||||
final DateTime end = new DateTime(getUnbanDate().getTime());
|
||||
final DateTime now = new DateTime(new Date().getTime());
|
||||
Period period = new Period(now, end);
|
||||
PeriodFormatter formatter = new PeriodFormatterBuilder().printZeroAlways().minimumPrintedDigits(2)
|
||||
.appendYears().appendSuffix(" Jahr", " Jahre")
|
||||
.appendSeparator(", ")
|
||||
.appendMonths().appendSuffix(" Monat", " Monate")
|
||||
.appendSeparator(", ")
|
||||
.appendDays().appendSuffix(" Tag", " Tage")
|
||||
.appendSeparator(" und ")
|
||||
.appendHours().appendSuffix(" Stunde", " Stunden")
|
||||
.appendMinutes().appendSuffix(" Minute", " Minuten")
|
||||
.appendSeconds().appendSuffix(" Sekunde", " Sekunden")
|
||||
.toFormatter();
|
||||
|
||||
return period.toString(formatter);
|
||||
}
|
||||
}
|
45
src/main/java/eu/univento/commons/player/ban/BanReason.java
Normal file
45
src/main/java/eu/univento/commons/player/ban/BanReason.java
Normal file
@ -0,0 +1,45 @@
|
||||
package eu.univento.commons.player.ban;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum BanReason {
|
||||
|
||||
//int represents ban points, ban points represent ban time
|
||||
HACK_CRITICALS("Criticals Hack", 10),
|
||||
HACK_AUTOCLICKER("AutoClicker Hack", 10),
|
||||
HACK_GLIDE("Glide Hack", 10),
|
||||
HACK_REACH("Reach Hack", 10),
|
||||
HACK_NOSLOWDOWN("NoSlowDown Hack", 10),
|
||||
HACK_REGEN("Regen Hack", 10),
|
||||
HACK_AUTORESPAWN("AutoRespawn Hack", 10),
|
||||
HACK_FASTPLACE("FastPlace Hack", 10),
|
||||
HACK_KILLAURA("KillAura Hack", 10),
|
||||
HACK_FLY("Fly Hack", 10),
|
||||
HACK_WDL("Massive use of WorldDownloader", 10),
|
||||
ADVERTISING("Advertising", 10),
|
||||
GRIEFING("Griefing", 10),
|
||||
INSULT("Insut", 10),
|
||||
RACISM("Racism", 10),
|
||||
BUGUSING("Bugusing", 10),
|
||||
HACKED_ACCOUNT("using hacked account", 10),
|
||||
TO_MANY_WARNS("To many warns", 10),
|
||||
CUSTOM("Custom", 10);
|
||||
|
||||
private final String name;
|
||||
private final int value;
|
||||
|
||||
BanReason(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package eu.univento.commons.player.friend;
|
||||
|
||||
import eu.univento.commons.player.uuid.NameFetcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class FriendData {
|
||||
|
||||
private UUID uuid;
|
||||
|
||||
public FriendData(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return NameFetcher.getRequest(uuid);
|
||||
}
|
||||
}
|
39
src/main/java/eu/univento/commons/player/kick/KickData.java
Normal file
39
src/main/java/eu/univento/commons/player/kick/KickData.java
Normal file
@ -0,0 +1,39 @@
|
||||
package eu.univento.commons.player.kick;
|
||||
|
||||
import eu.univento.commons.player.uuid.NameFetcher;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class KickData {
|
||||
|
||||
private KickReason reason;
|
||||
private Date date;
|
||||
private UUID kicker;
|
||||
|
||||
public KickData(KickReason reason, Date date, UUID kicker) {
|
||||
this.reason = reason;
|
||||
this.date = date;
|
||||
this.kicker = kicker;
|
||||
}
|
||||
|
||||
public KickReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public UUID getKicker() {
|
||||
return kicker;
|
||||
}
|
||||
|
||||
public String getKickerName() {
|
||||
return NameFetcher.getRequest(kicker);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package eu.univento.commons.player.kick;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum KickReason {
|
||||
|
||||
INSULT("Insult", 10);
|
||||
|
||||
private String name;
|
||||
private int points;
|
||||
|
||||
KickReason(String name, int points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package eu.univento.commons.player.language;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Language {
|
||||
|
||||
private final ResourceBundle translation;
|
||||
|
||||
public Language(String language) {
|
||||
Map<String, Locale> languages = new HashMap<>();
|
||||
languages.put("DE", Locale.GERMAN);
|
||||
languages.put("EN", Locale.ENGLISH);
|
||||
languages.put("IT", Locale.ITALIAN);
|
||||
translation = ResourceBundle.getBundle("language", languages.get(language));
|
||||
}
|
||||
|
||||
public String getWord(String keyword) {
|
||||
return translation.getString(keyword);
|
||||
}
|
||||
}
|
45
src/main/java/eu/univento/commons/player/mute/MuteData.java
Normal file
45
src/main/java/eu/univento/commons/player/mute/MuteData.java
Normal file
@ -0,0 +1,45 @@
|
||||
package eu.univento.commons.player.mute;
|
||||
|
||||
import eu.univento.commons.player.uuid.NameFetcher;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MuteData {
|
||||
|
||||
private MuteReason reason;
|
||||
private UUID player;
|
||||
private UUID muter;
|
||||
private Date date;
|
||||
|
||||
public MuteData(MuteReason reason, UUID player, UUID muter, Date date) {
|
||||
this.reason = reason;
|
||||
this.player = player;
|
||||
this.muter = muter;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public MuteReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public UUID getMuter() {
|
||||
return muter;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getMuterName() {
|
||||
return NameFetcher.getRequest(muter);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package eu.univento.commons.player.mute;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum MuteReason {
|
||||
|
||||
SPAM("Spam", 30);
|
||||
|
||||
private String name;
|
||||
private int time;
|
||||
|
||||
MuteReason(String name, int time) {
|
||||
this.name = name;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package eu.univento.commons.player.profiles;
|
||||
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import eu.univento.commons.player.DatabasePlayer;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlayerProfiles {
|
||||
|
||||
private UUID uuid;
|
||||
private final MongoCollection<Document> collection;
|
||||
|
||||
public PlayerProfiles(DatabasePlayer player) {
|
||||
this.uuid = player.getUuid();
|
||||
this.collection = player.getProfileCollection();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package eu.univento.commons.player.profiles;
|
||||
|
||||
import com.mongodb.CursorType;
|
||||
import com.mongodb.client.FindIterable;
|
||||
import eu.univento.commons.player.DatabasePlayer;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Profile {
|
||||
|
||||
private DatabasePlayer player;
|
||||
private String id;
|
||||
private String name;
|
||||
private Date date;
|
||||
private Save save;
|
||||
private Collection<StoryItem> items;
|
||||
|
||||
public Profile(DatabasePlayer player, String id) {
|
||||
this.id = id;
|
||||
FindIterable<Document> cursor = player.getProfileCollection().find(new Document("_id", id));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
Document doc = cursor.first();
|
||||
|
||||
this.name = doc.getString("name");
|
||||
this.save = Save.valueOf(doc.getString("save"));
|
||||
this.date = doc.getDate("date");
|
||||
Collection<String> list = (Collection<String>) doc.get("items");
|
||||
items = new LinkedList<>();
|
||||
items.addAll(list.stream().map(StoryItem::valueOf).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public DatabasePlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Save getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Collection<StoryItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return "https://players.univento.eu/" + player.getUuid() + "/profile/" + id;
|
||||
}
|
||||
}
|
38
src/main/java/eu/univento/commons/player/profiles/Save.java
Normal file
38
src/main/java/eu/univento/commons/player/profiles/Save.java
Normal file
@ -0,0 +1,38 @@
|
||||
package eu.univento.commons.player.profiles;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum Save {
|
||||
|
||||
START("Starting", 2.0D, 0.0D, 6.0D);
|
||||
|
||||
private String name;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
Save(String name, double x, double y, double z) {
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package eu.univento.commons.player.profiles;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum StoryItem {
|
||||
|
||||
|
||||
START("Item.Stone", "STONE", 3);
|
||||
|
||||
private String name;
|
||||
private String material;
|
||||
private int durability;
|
||||
|
||||
StoryItem(String name, String material, int durability) {
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public int getDurability() {
|
||||
return durability;
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package eu.univento.commons.player.settings;
|
||||
|
||||
import eu.univento.commons.player.DatabasePlayer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class PlayerSettings {
|
||||
|
||||
private DatabasePlayer player;
|
||||
|
||||
public PlayerSettings(DatabasePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getPlayerVisibility() {
|
||||
return (String) getSettings().get("playerVisibility");
|
||||
}
|
||||
|
||||
public boolean hasInventoryAnimationEnabled() {
|
||||
return (boolean) getSettings().get("inventoryAnimation");
|
||||
}
|
||||
|
||||
public boolean hasTeleportAnimationEnabled() {
|
||||
return (boolean) getSettings().get("teleportAnimation");
|
||||
}
|
||||
|
||||
public boolean hasPartyRequestsEnabled() {
|
||||
return (boolean) getSettings().get("partyRequests");
|
||||
}
|
||||
|
||||
public boolean hasFriendRequestsEnabled() {
|
||||
return (boolean) getSettings().get("friendRequests");
|
||||
}
|
||||
|
||||
public boolean hasFriendJumpEnabled() {
|
||||
return (boolean) getSettings().get("friendJump");
|
||||
}
|
||||
|
||||
public boolean hasChatSoundsEnabled() {
|
||||
return (boolean) getSettings().get("chatSounds");
|
||||
}
|
||||
|
||||
public boolean hasEffectsEnabled() {
|
||||
return (boolean) getSettings().get("effects");
|
||||
}
|
||||
|
||||
public boolean hasStoryModeEnabled() {
|
||||
return (boolean) getSettings().get("storyMode");
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return (String) getSettings().get("language");
|
||||
}
|
||||
|
||||
public boolean hasTsMoveEnabled() {
|
||||
return (boolean) getSettings().get("tsMove");
|
||||
}
|
||||
|
||||
public boolean hasScoreboardEnabled() {
|
||||
return (boolean) getSettings().get("scoreboard");
|
||||
}
|
||||
|
||||
public void setPlayerVisibility(String visibility) {
|
||||
setSetting("playerVisibility", visibility);
|
||||
}
|
||||
|
||||
public void setInventoryAnimation(boolean animation) {
|
||||
setSetting("inventoryAnimation", animation);
|
||||
}
|
||||
|
||||
public void setTeleportAnimation(boolean animation) {
|
||||
setSetting("teleportAnimation", animation);
|
||||
}
|
||||
|
||||
public void setPartyRequests(boolean requests) {
|
||||
setSetting("partyRequests", requests);
|
||||
}
|
||||
|
||||
public void setFriendRequests(boolean requests) {
|
||||
setSetting("friendRequests", requests);
|
||||
}
|
||||
|
||||
public void setFriendJump(boolean jump) {
|
||||
setSetting("friendJump", jump);
|
||||
}
|
||||
|
||||
public void setChatSounds(boolean sounds) {
|
||||
setSetting("chatSounds", sounds);
|
||||
}
|
||||
|
||||
public void setEffects(boolean effects) {
|
||||
setSetting("effects", effects);
|
||||
}
|
||||
|
||||
public void setStoryMode(boolean storyMode) {
|
||||
setSetting("storyMode", storyMode);
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
setSetting("language", language);
|
||||
}
|
||||
|
||||
public void setTsMove(boolean tsMove) {
|
||||
setSetting("tsMove", tsMove);
|
||||
}
|
||||
|
||||
public void setScoreboard(boolean scoreboard) {
|
||||
setSetting("scoreboard", scoreboard);
|
||||
}
|
||||
|
||||
public boolean isNicked() {
|
||||
return (boolean) getSettings().get("nicked");
|
||||
}
|
||||
|
||||
public void setNickStatus(boolean nicked) {
|
||||
setSetting("nicked", nicked);
|
||||
}
|
||||
|
||||
private Map<String, Object> getSettings() {
|
||||
return player.getMapFromDatabase("Settings");
|
||||
}
|
||||
|
||||
private void setSettings(Map<String, Object> settings) {
|
||||
player.setInDatabase("Settings", settings);
|
||||
}
|
||||
|
||||
private void setSetting(String name, Serializable setting) {
|
||||
Map<String, Object> list = getSettings();
|
||||
list.put(name, setting);
|
||||
setSettings(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package eu.univento.commons.player.uuid;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author codebucketdev
|
||||
*/
|
||||
|
||||
public class NameFetcher {
|
||||
private static final JSONParser jsonParser = new JSONParser();
|
||||
private static final String REQUEST_URL = "https://mcapi.de/api/user/";
|
||||
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
|
||||
public static String getRequest(UUID uuid) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(REQUEST_URL + fromUniqueId(uuid)).openConnection();
|
||||
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
|
||||
String uniqueId = (String) response.get("uuid");
|
||||
if (uniqueId.length() == 0) {
|
||||
throw new IllegalArgumentException("A Username for UUID '" + uuid.toString() + "' was not found in the Mojang database! Is the account not premium?");
|
||||
}
|
||||
|
||||
return (String) response.get("username");
|
||||
} catch (Exception e) {
|
||||
return callMojang(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
private static String callMojang(UUID uuid) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL + fromUniqueId(uuid)).openConnection();
|
||||
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
|
||||
String name = (String) response.get("name");
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("A Username for UUID '" + uuid.toString() + "' was not found in the Mojang database! Is the account not premium?");
|
||||
}
|
||||
|
||||
String cause = (String) response.get("cause");
|
||||
String errorMessage = (String) response.get("errorMessage");
|
||||
if (cause != null && cause.length() > 0) {
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
return name;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("A Username for UUID '" + uuid.toString() + "' was not found in the Mojang database! Is the account not premium?");
|
||||
}
|
||||
}
|
||||
|
||||
private static String fromUniqueId(UUID uuid) {
|
||||
return uuid.toString().replaceAll("-", "");
|
||||
}
|
||||
}
|
113
src/main/java/eu/univento/commons/player/uuid/UUIDFetcher.java
Normal file
113
src/main/java/eu/univento/commons/player/uuid/UUIDFetcher.java
Normal file
@ -0,0 +1,113 @@
|
||||
package eu.univento.commons.player.uuid;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author codebucketdev
|
||||
*/
|
||||
|
||||
public class UUIDFetcher {
|
||||
private static final double MAX_REQUEST = 100;
|
||||
private static final String REQUEST_URL = "https://mcapi.de/api/user/";
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/page/";
|
||||
|
||||
public static UUID getRequest(String username) {
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(REQUEST_URL + username).openConnection();
|
||||
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
|
||||
String name = (String) response.get("username");
|
||||
if (name.length() == 0) {
|
||||
throw new IllegalArgumentException("A UUID for Username '" + username + "' was not found in the Mojang database! Is the account not premium?");
|
||||
}
|
||||
|
||||
return fromString((String) response.get("uuid"));
|
||||
} catch (Exception e) {
|
||||
return callMojang(username);
|
||||
}
|
||||
}
|
||||
|
||||
private static UUID callMojang(String username) {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
ProfileData data = new ProfileData(username);
|
||||
String uuid = null;
|
||||
for (int i = 1; i < MAX_REQUEST; i++) {
|
||||
PlayerProfile[] result = post(new URL(PROFILE_URL + i), Proxy.NO_PROXY, gson.toJson(data).getBytes());
|
||||
if (result.length == 0) {
|
||||
break;
|
||||
}
|
||||
uuid = result[0].getId();
|
||||
}
|
||||
return fromString(uuid);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("A UUID for Username '" + username + "' was not found in the Mojang database! Is the account not premium?");
|
||||
}
|
||||
}
|
||||
|
||||
private static UUID fromString(String uuid) {
|
||||
return UUID.fromString(uuid.substring(0, 8) + "-" + uuid.substring(8, 12) + "-"
|
||||
+ uuid.substring(12, 16) + "-" + uuid.substring(16, 20) + "-" + uuid.substring(20, 32));
|
||||
}
|
||||
|
||||
private static PlayerProfile[] post(URL url, Proxy proxy, byte[] bytes) throws IOException {
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
|
||||
out.write(bytes);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder response = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
response.append('\r');
|
||||
}
|
||||
reader.close();
|
||||
|
||||
return new Gson().fromJson(response.toString(), SearchResult.class).getProfiles();
|
||||
}
|
||||
|
||||
private static class PlayerProfile {
|
||||
private String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SearchResult {
|
||||
private PlayerProfile[] profiles;
|
||||
|
||||
public PlayerProfile[] getProfiles() {
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ProfileData {
|
||||
private String name;
|
||||
private String agent = "minecraft";
|
||||
|
||||
public ProfileData(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
49
src/main/java/eu/univento/commons/player/warn/WarnData.java
Normal file
49
src/main/java/eu/univento/commons/player/warn/WarnData.java
Normal file
@ -0,0 +1,49 @@
|
||||
package eu.univento.commons.player.warn;
|
||||
|
||||
import eu.univento.commons.player.uuid.NameFetcher;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class WarnData {
|
||||
|
||||
private WarnReason reason;
|
||||
private UUID warner;
|
||||
private Date date;
|
||||
private String proof;
|
||||
|
||||
public WarnData(WarnReason reason, UUID warner, Date date, String proof) {
|
||||
this.reason = reason;
|
||||
this.warner = warner;
|
||||
this.date = date;
|
||||
this.proof = proof;
|
||||
}
|
||||
|
||||
public WarnReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public UUID getWarner() {
|
||||
return warner;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getProof() {
|
||||
return proof;
|
||||
}
|
||||
|
||||
public String getWarnerName() {
|
||||
if(warner == null) {
|
||||
return "Auto Warn";
|
||||
}else {
|
||||
return NameFetcher.getRequest(warner);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package eu.univento.commons.player.warn;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public enum WarnReason {
|
||||
COPYRIGHT("Copyright", 100),
|
||||
ADVERTISEMENT("Advertisement", 10),
|
||||
SPAM("Spamming", 10);
|
||||
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
WarnReason(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package eu.univento.commons.security;
|
||||
|
||||
import eu.univento.commons.Commons;
|
||||
import eu.univento.commons.database.AsyncMySQL;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class SecurityHandler {
|
||||
|
||||
private Commons commons;
|
||||
|
||||
public SecurityHandler(Commons commons) {
|
||||
this.commons = commons;
|
||||
}
|
||||
|
||||
public void isValidServer(String ip, Consumer<Boolean> consumer) {
|
||||
AsyncMySQL sql = commons.getDatabaseManager().getAsyncMySQL();
|
||||
sql.query("SELECT * FROM Servers WHERE ip='" + ip + "';", resultSet -> {
|
||||
try {
|
||||
consumer.accept(resultSet.next());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
consumer.accept(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
35
src/main/java/eu/univento/commons/server/TPS.java
Normal file
35
src/main/java/eu/univento/commons/server/TPS.java
Normal file
@ -0,0 +1,35 @@
|
||||
package eu.univento.commons.server;
|
||||
|
||||
public class TPS implements Runnable {
|
||||
private static int TICK_COUNT = 0;
|
||||
private static long[] TICKS = new long[600];
|
||||
private static long LAST_TICK = 0L;
|
||||
|
||||
public static double getTPS() {
|
||||
return getTPS(100);
|
||||
}
|
||||
|
||||
private static double getTPS(int ticks) {
|
||||
if (TICK_COUNT < ticks) {
|
||||
return 20.0D;
|
||||
}
|
||||
int target = (TICK_COUNT - 1 - ticks) % TICKS.length;
|
||||
long elapsed = System.currentTimeMillis() - TICKS[target];
|
||||
|
||||
return ticks / (elapsed / 1000.0D);
|
||||
}
|
||||
|
||||
private static long getElapsed(int tickID) {
|
||||
if (TICK_COUNT - tickID >= TICKS.length) {
|
||||
}
|
||||
|
||||
long time = TICKS[(tickID % TICKS.length)];
|
||||
return System.currentTimeMillis() - time;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
TICKS[(TICK_COUNT % TICKS.length)] = System.currentTimeMillis();
|
||||
|
||||
TICK_COUNT += 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package eu.univento.commons.updater;
|
||||
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class CustomAuthenicator extends Authenticator{
|
||||
|
||||
private static String username = "";
|
||||
private static String password = "";
|
||||
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication (username,
|
||||
password.toCharArray());
|
||||
}
|
||||
|
||||
public static void setPasswordAuthentication(String username, String password) {
|
||||
CustomAuthenicator.username = username;
|
||||
CustomAuthenicator.password = password;
|
||||
}
|
||||
}
|
70
src/main/java/eu/univento/commons/updater/Updater.java
Normal file
70
src/main/java/eu/univento/commons/updater/Updater.java
Normal file
@ -0,0 +1,70 @@
|
||||
package eu.univento.commons.updater;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import eu.univento.commons.utils.Strings;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Updater {
|
||||
|
||||
private String check;
|
||||
private String download;
|
||||
private String name;
|
||||
private String version;
|
||||
|
||||
public Updater(String check, String name, String version) {
|
||||
this.check = check;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean needsUpdate() {
|
||||
JsonObject object;
|
||||
try {
|
||||
object = new JsonParser().parse(IOUtils.toString(new URL(check).openStream(), "UTF-8")).getAsJsonObject();
|
||||
JsonArray array = object.get("versions").getAsJsonArray();
|
||||
for (JsonElement element : array.getAsJsonArray()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
if (obj.get("version").getAsString() != null) {
|
||||
download = obj.get("link").getAsString();
|
||||
return Strings.versionCompare(obj.get("version").getAsString(), version) > 0;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean delete() {
|
||||
try {
|
||||
FileUtils.forceDelete(new File("/plugins", name + ".jar"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean download() {
|
||||
try {
|
||||
FileUtils.copyURLToFile(new URL(download), new File("/plugins", name + ".jar"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
286
src/main/java/eu/univento/commons/utils/Maths.java
Normal file
286
src/main/java/eu/univento/commons/utils/Maths.java
Normal file
@ -0,0 +1,286 @@
|
||||
package eu.univento.commons.utils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.5
|
||||
*/
|
||||
|
||||
final class Maths
|
||||
{
|
||||
public static final float nanoToSec = 1.0E-009F;
|
||||
public static final float FLOAT_ROUNDING_ERROR = 1.0E-006F;
|
||||
public static final float PI = 3.141593F;
|
||||
public static final float PI2 = 6.283186F;
|
||||
public static final float SQRT_3 = 1.73205F;
|
||||
public static final float E = 2.718282F;
|
||||
public static final float radiansToDegrees = 57.295776F;
|
||||
public static final float radDeg = 57.295776F;
|
||||
public static final float degreesToRadians = 0.01745329F;
|
||||
public static final float degRad = 0.01745329F;
|
||||
private static final int ATAN2_DIM = (int)Math.sqrt(16384.0D);
|
||||
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0F / (ATAN2_DIM - 1);
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static float sin(float radians) {
|
||||
return Sin.table[((int)(radians * 2607.5945F) & 0x3FFF)];
|
||||
}
|
||||
|
||||
public static float cos(float radians)
|
||||
{
|
||||
return Sin.table[((int)((radians + 1.570796F) * 2607.5945F) & 0x3FFF)];
|
||||
}
|
||||
|
||||
public static float sinDeg(float degrees)
|
||||
{
|
||||
return Sin.table[((int)(degrees * 45.511112F) & 0x3FFF)];
|
||||
}
|
||||
|
||||
public static float cosDeg(float degrees)
|
||||
{
|
||||
return Sin.table[((int)((degrees + 90.0F) * 45.511112F) & 0x3FFF)];
|
||||
}
|
||||
|
||||
public static float atan2(float y, float x)
|
||||
{
|
||||
float mul;
|
||||
float add;
|
||||
if (x < 0.0F)
|
||||
{
|
||||
if (y < 0.0F) {
|
||||
y = -y;
|
||||
mul = 1.0F;
|
||||
} else {
|
||||
mul = -1.0F;
|
||||
}x = -x;
|
||||
add = -3.141593F;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y < 0.0F) {
|
||||
y = -y;
|
||||
mul = -1.0F;
|
||||
} else {
|
||||
mul = 1.0F;
|
||||
}add = 0.0F;
|
||||
}
|
||||
float invDiv = 1.0F / ((x < y ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||
|
||||
if (invDiv == 1.0F) return ((float)Math.atan2(y, x) + add) * mul;
|
||||
|
||||
int xi = (int)(x * invDiv);
|
||||
int yi = (int)(y * invDiv);
|
||||
return (Atan2.table[(yi * ATAN2_DIM + xi)] + add) * mul;
|
||||
}
|
||||
|
||||
public static int random(int range)
|
||||
{
|
||||
return random.nextInt(range + 1);
|
||||
}
|
||||
|
||||
public static int random(int start, int end)
|
||||
{
|
||||
return start + random.nextInt(end - start + 1);
|
||||
}
|
||||
|
||||
public static boolean randomBoolean()
|
||||
{
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
public static boolean randomBoolean(float chance)
|
||||
{
|
||||
return random() < chance;
|
||||
}
|
||||
|
||||
private static float random()
|
||||
{
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
public static float random(float range)
|
||||
{
|
||||
return random.nextFloat() * range;
|
||||
}
|
||||
|
||||
public static float random(float start, float end)
|
||||
{
|
||||
return start + random.nextFloat() * (end - start);
|
||||
}
|
||||
|
||||
public static int nextPowerOfTwo(int value)
|
||||
{
|
||||
if (value == 0) return 1;
|
||||
value--;
|
||||
value |= value >> 1;
|
||||
value |= value >> 2;
|
||||
value |= value >> 4;
|
||||
value |= value >> 8;
|
||||
value |= value >> 16;
|
||||
return value + 1;
|
||||
}
|
||||
|
||||
public static boolean isPowerOfTwo(int value) {
|
||||
return (value != 0) && ((value & value - 1) == 0);
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max)
|
||||
{
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static short clamp(short value, short min, short max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float clamp(float value, float min, float max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int floor(float x)
|
||||
{
|
||||
return (int)(x + 16384.0D) - 16384;
|
||||
}
|
||||
|
||||
public static int floorPositive(float x)
|
||||
{
|
||||
return (int)x;
|
||||
}
|
||||
|
||||
public static int ceil(float x)
|
||||
{
|
||||
return (int)(x + 16384.999999999996D) - 16384;
|
||||
}
|
||||
|
||||
public static int ceilPositive(float x)
|
||||
{
|
||||
return (int)(x + 0.9999999000000001D);
|
||||
}
|
||||
|
||||
public static int round(float x)
|
||||
{
|
||||
return (int)(x + 16384.5D) - 16384;
|
||||
}
|
||||
|
||||
public static int roundPositive(float x)
|
||||
{
|
||||
return (int)(x + 0.5F);
|
||||
}
|
||||
|
||||
public static boolean isZero(float value)
|
||||
{
|
||||
return Math.abs(value) <= 1.0E-006F;
|
||||
}
|
||||
|
||||
public static boolean isZero(float value, float tolerance)
|
||||
{
|
||||
return Math.abs(value) <= tolerance;
|
||||
}
|
||||
|
||||
public static boolean isEqual(float a, float b)
|
||||
{
|
||||
return Math.abs(a - b) <= 1.0E-006F;
|
||||
}
|
||||
|
||||
public static boolean isEqual(float a, float b, float tolerance)
|
||||
{
|
||||
return Math.abs(a - b) <= tolerance;
|
||||
}
|
||||
|
||||
public static long parseDateDiff(String time, boolean future)
|
||||
throws Exception
|
||||
{
|
||||
Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2);
|
||||
Matcher m = timePattern.matcher(time);
|
||||
int years = 0;
|
||||
int months = 0;
|
||||
int weeks = 0;
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
boolean found = false;
|
||||
while (m.find()) {
|
||||
if ((m.group() == null) || (m.group().isEmpty())) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < m.groupCount(); i++) {
|
||||
if ((m.group(i) != null) && (!m.group(i).isEmpty())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if ((m.group(1) != null) && (!m.group(1).isEmpty()))
|
||||
years = Integer.parseInt(m.group(1));
|
||||
if ((m.group(2) != null) && (!m.group(2).isEmpty()))
|
||||
months = Integer.parseInt(m.group(2));
|
||||
if ((m.group(3) != null) && (!m.group(3).isEmpty()))
|
||||
weeks = Integer.parseInt(m.group(3));
|
||||
if ((m.group(4) != null) && (!m.group(4).isEmpty()))
|
||||
days = Integer.parseInt(m.group(4));
|
||||
if ((m.group(5) != null) && (!m.group(5).isEmpty()))
|
||||
hours = Integer.parseInt(m.group(5));
|
||||
if ((m.group(6) != null) && (!m.group(6).isEmpty()))
|
||||
minutes = Integer.parseInt(m.group(6));
|
||||
if ((m.group(7) == null) || (m.group(7).isEmpty())) break;
|
||||
seconds = Integer.parseInt(m.group(7));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
throw new Exception("Illegal Date");
|
||||
Calendar c = new GregorianCalendar();
|
||||
if (years > 0)
|
||||
c.add(1, years * (future ? 1 : -1));
|
||||
if (months > 0)
|
||||
c.add(2, months * (future ? 1 : -1));
|
||||
if (weeks > 0)
|
||||
c.add(3, weeks * (future ? 1 : -1));
|
||||
if (days > 0)
|
||||
c.add(5, days * (future ? 1 : -1));
|
||||
if (hours > 0)
|
||||
c.add(11, hours * (future ? 1 : -1));
|
||||
if (minutes > 0)
|
||||
c.add(12, minutes * (future ? 1 : -1));
|
||||
if (seconds > 0)
|
||||
c.add(13, seconds * (future ? 1 : -1));
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
|
||||
private static class Atan2
|
||||
{
|
||||
static final float[] table = new float[16384];
|
||||
|
||||
static { for (int i = 0; i < Maths.ATAN2_DIM; i++)
|
||||
for (int j = 0; j < Maths.ATAN2_DIM; j++) {
|
||||
float x0 = i / Maths.ATAN2_DIM;
|
||||
float y0 = j / Maths.ATAN2_DIM;
|
||||
table[(j * Maths.ATAN2_DIM + i)] = (float)Math.atan2(y0, x0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Sin
|
||||
{
|
||||
static final float[] table = new float[16384];
|
||||
|
||||
static { for (int i = 0; i < 16384; i++)
|
||||
table[i] = (float)Math.sin((i + 0.5F) / 16384.0F * 6.283186F);
|
||||
for (int i = 0; i < 360; i += 90)
|
||||
table[((int)(i * 45.511112F) & 0x3FFF)] = (float)Math.sin(i * 0.01745329F);
|
||||
}
|
||||
}
|
||||
}
|
40
src/main/java/eu/univento/commons/utils/Strings.java
Normal file
40
src/main/java/eu/univento/commons/utils/Strings.java
Normal file
@ -0,0 +1,40 @@
|
||||
package eu.univento.commons.utils;
|
||||
|
||||
/**
|
||||
* @author joethei, Alex Gitelman
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Strings {
|
||||
|
||||
/**
|
||||
* Compares two version strings.
|
||||
*
|
||||
* Use this instead of String.compareTo() for a non-lexicographical
|
||||
* comparison that works for version strings. e.g. "1.10".compareTo("1.6").
|
||||
*
|
||||
* @note It does not work if "1.10" is supposed to be equal to "1.10.0".
|
||||
*
|
||||
* @param str1 a string of ordinal numbers separated by decimal points.
|
||||
* @param str2 a string of ordinal numbers separated by decimal points.
|
||||
* @return The result is a negative integer if str1 is numerically less than str2.
|
||||
* The result is a positive integer if str1 is numerically greater than str2.
|
||||
* The result is zero if the strings are _numerically_ equals
|
||||
*/
|
||||
public static int versionCompare(String str1, String str2) {
|
||||
String[] vals1 = str1.split("\\.");
|
||||
String[] vals2 = str2.split("\\.");
|
||||
int i = 0;
|
||||
// set index to first non-equal ordinal or length of shortest version string
|
||||
while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
|
||||
i++;
|
||||
}
|
||||
// compare first non-equal ordinal number
|
||||
if (i < vals1.length && i < vals2.length) {
|
||||
int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
|
||||
return Integer.signum(diff);
|
||||
}
|
||||
// the strings are equal or one string is a substring of the other
|
||||
// e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
|
||||
return Integer.signum(vals1.length - vals2.length);
|
||||
}
|
||||
}
|
10
src/main/resources/config.properties
Normal file
10
src/main/resources/config.properties
Normal file
@ -0,0 +1,10 @@
|
||||
MySQL.Host = univento.eu
|
||||
MySQL.Port = 3306
|
||||
MySQL.Username = core
|
||||
MySQL.Database = core
|
||||
MySQL.Password = dWez!530Erwz7&44
|
||||
MongoDB.Host = univento.eu
|
||||
MongoDB.Port = 27017
|
||||
MongoDB.Username = admin
|
||||
MongoDB.Password = ++JT1415++
|
||||
MongoDB.Database = admin
|
4
src/main/resources/language.properties
Normal file
4
src/main/resources/language.properties
Normal file
@ -0,0 +1,4 @@
|
||||
Prefix = undefined
|
||||
Tab_Prefix = §8• §6U N I V E N T O §8•
|
||||
Not_a_player = You are not a valid player
|
||||
No_perms =
|
40
src/main/resources/language_de.properties
Normal file
40
src/main/resources/language_de.properties
Normal file
@ -0,0 +1,40 @@
|
||||
Pack.failed_download = Das Pack konnte nicht geladen werden
|
||||
Pack.declined = Du hast das Pack abgelehnt, du wirst nicht das volle Spielerlebnis erhalten
|
||||
|
||||
System.unknown_error = Es ist ein unbekannter Fehler aufgetreten
|
||||
System.critical_error = Es ist leider ein kritischer Fehler aufgetreten
|
||||
|
||||
Server.restart = Der Server wurde neugestartet
|
||||
Server.stop = Der Server wurde ausgeschaltet
|
||||
Server.reconnect = Bitte verbinde dich neu
|
||||
Server.full = Dieser Server ist bereits voll
|
||||
Server.ip = IP: play.univento.eu
|
||||
Server.ts_ip = TeamSpeak IP: ts.univento.eu
|
||||
Server.board_ip = Foren Adresse: forum.univento.eu
|
||||
|
||||
Command.prefix = univento.eu Default Command Prefix
|
||||
Command.command_not_found = Dieser Befehl konnte nicht gefunden werden
|
||||
Command.not_online = Der Spieler $player ist nicht online
|
||||
Command.no_perms = Um diesen Befehl zu benutzen hast du keine Rechte
|
||||
|
||||
Command.Build.usage = Nutze /build
|
||||
Command.Build.toogle_on = Du hast den Build Modus aktiviert
|
||||
Command.Build.toogle_off = Du hast den Build Modus deaktiviert
|
||||
|
||||
Command.TS.usage = Nutze /ts
|
||||
Command.TS.already_verified = Du wurdest bereits verifiziert
|
||||
Command.TS.not_online = Du bist nicht mit dem TeamSpeak Server verbunden
|
||||
Command.TS.verified = Du wurdest verifiziert
|
||||
|
||||
Command.Fix.usage = Nutze /fix <Spieler>
|
||||
Command.Fix.own = Du hast dich selbst gefixt
|
||||
Command.Fix.other = Du hast $player gefixt
|
||||
Command.Fix.by_other = Du wurdest von $player gefixt
|
||||
|
||||
Shop.Lobby.Main = Lobby Shop
|
||||
Shop.Game.Maya.Main = Maya Game Shop
|
||||
|
||||
Lobby.Menu.Profile = Dein Profil
|
||||
Lobby.Menu.other_Profile = Profil von $player
|
||||
Lobby.Menu.Settings = Einstellungen
|
||||
Lobby.Menu.Language = Sprache einstellen
|
BIN
target/Commons-1.0-SNAPSHOT-jar-with-dependencies.jar
Normal file
BIN
target/Commons-1.0-SNAPSHOT-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
target/Commons-1.0-SNAPSHOT-small.jar
Normal file
BIN
target/Commons-1.0-SNAPSHOT-small.jar
Normal file
Binary file not shown.
BIN
target/Commons-1.0-SNAPSHOT.jar
Normal file
BIN
target/Commons-1.0-SNAPSHOT.jar
Normal file
Binary file not shown.
10
target/classes/config.properties
Normal file
10
target/classes/config.properties
Normal file
@ -0,0 +1,10 @@
|
||||
MySQL.Host = univento.eu
|
||||
MySQL.Port = 3306
|
||||
MySQL.Username = core
|
||||
MySQL.Database = core
|
||||
MySQL.Password = dWez!530Erwz7&44
|
||||
MongoDB.Host = univento.eu
|
||||
MongoDB.Port = 27017
|
||||
MongoDB.Username = admin
|
||||
MongoDB.Password = ++JT1415++
|
||||
MongoDB.Database = admin
|
BIN
target/classes/eu/univento/commons/Commons.class
Normal file
BIN
target/classes/eu/univento/commons/Commons.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/database/AsyncMongoDB.class
Normal file
BIN
target/classes/eu/univento/commons/database/AsyncMongoDB.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/database/AsyncMySQL.class
Normal file
BIN
target/classes/eu/univento/commons/database/AsyncMySQL.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/database/MongoDB.class
Normal file
BIN
target/classes/eu/univento/commons/database/MongoDB.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/database/MySQL.class
Normal file
BIN
target/classes/eu/univento/commons/database/MySQL.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/logging/LoggingHandler.class
Normal file
BIN
target/classes/eu/univento/commons/logging/LoggingHandler.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/DatabasePlayer.class
Normal file
BIN
target/classes/eu/univento/commons/player/DatabasePlayer.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/Rank.class
Normal file
BIN
target/classes/eu/univento/commons/player/Rank.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/ban/BanData.class
Normal file
BIN
target/classes/eu/univento/commons/player/ban/BanData.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/ban/BanReason.class
Normal file
BIN
target/classes/eu/univento/commons/player/ban/BanReason.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/kick/KickData.class
Normal file
BIN
target/classes/eu/univento/commons/player/kick/KickData.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/kick/KickReason.class
Normal file
BIN
target/classes/eu/univento/commons/player/kick/KickReason.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/mute/MuteData.class
Normal file
BIN
target/classes/eu/univento/commons/player/mute/MuteData.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/mute/MuteReason.class
Normal file
BIN
target/classes/eu/univento/commons/player/mute/MuteReason.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/profiles/Profile.class
Normal file
BIN
target/classes/eu/univento/commons/player/profiles/Profile.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/profiles/Save.class
Normal file
BIN
target/classes/eu/univento/commons/player/profiles/Save.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/uuid/NameFetcher.class
Normal file
BIN
target/classes/eu/univento/commons/player/uuid/NameFetcher.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/uuid/UUIDFetcher.class
Normal file
BIN
target/classes/eu/univento/commons/player/uuid/UUIDFetcher.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/warn/WarnData.class
Normal file
BIN
target/classes/eu/univento/commons/player/warn/WarnData.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/player/warn/WarnReason.class
Normal file
BIN
target/classes/eu/univento/commons/player/warn/WarnReason.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/server/TPS.class
Normal file
BIN
target/classes/eu/univento/commons/server/TPS.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
target/classes/eu/univento/commons/updater/Updater.class
Normal file
BIN
target/classes/eu/univento/commons/updater/Updater.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/utils/Maths$Atan2.class
Normal file
BIN
target/classes/eu/univento/commons/utils/Maths$Atan2.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/utils/Maths$Sin.class
Normal file
BIN
target/classes/eu/univento/commons/utils/Maths$Sin.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/utils/Maths.class
Normal file
BIN
target/classes/eu/univento/commons/utils/Maths.class
Normal file
Binary file not shown.
BIN
target/classes/eu/univento/commons/utils/Strings.class
Normal file
BIN
target/classes/eu/univento/commons/utils/Strings.class
Normal file
Binary file not shown.
4
target/classes/language.properties
Normal file
4
target/classes/language.properties
Normal file
@ -0,0 +1,4 @@
|
||||
Prefix = undefined
|
||||
Tab_Prefix = §8• §6U N I V E N T O §8•
|
||||
Not_a_player = You are not a valid player
|
||||
No_perms =
|
40
target/classes/language_de.properties
Normal file
40
target/classes/language_de.properties
Normal file
@ -0,0 +1,40 @@
|
||||
Pack.failed_download = Das Pack konnte nicht geladen werden
|
||||
Pack.declined = Du hast das Pack abgelehnt, du wirst nicht das volle Spielerlebnis erhalten
|
||||
|
||||
System.unknown_error = Es ist ein unbekannter Fehler aufgetreten
|
||||
System.critical_error = Es ist leider ein kritischer Fehler aufgetreten
|
||||
|
||||
Server.restart = Der Server wurde neugestartet
|
||||
Server.stop = Der Server wurde ausgeschaltet
|
||||
Server.reconnect = Bitte verbinde dich neu
|
||||
Server.full = Dieser Server ist bereits voll
|
||||
Server.ip = IP: play.univento.eu
|
||||
Server.ts_ip = TeamSpeak IP: ts.univento.eu
|
||||
Server.board_ip = Foren Adresse: forum.univento.eu
|
||||
|
||||
Command.prefix = univento.eu Default Command Prefix
|
||||
Command.command_not_found = Dieser Befehl konnte nicht gefunden werden
|
||||
Command.not_online = Der Spieler $player ist nicht online
|
||||
Command.no_perms = Um diesen Befehl zu benutzen hast du keine Rechte
|
||||
|
||||
Command.Build.usage = Nutze /build
|
||||
Command.Build.toogle_on = Du hast den Build Modus aktiviert
|
||||
Command.Build.toogle_off = Du hast den Build Modus deaktiviert
|
||||
|
||||
Command.TS.usage = Nutze /ts
|
||||
Command.TS.already_verified = Du wurdest bereits verifiziert
|
||||
Command.TS.not_online = Du bist nicht mit dem TeamSpeak Server verbunden
|
||||
Command.TS.verified = Du wurdest verifiziert
|
||||
|
||||
Command.Fix.usage = Nutze /fix <Spieler>
|
||||
Command.Fix.own = Du hast dich selbst gefixt
|
||||
Command.Fix.other = Du hast $player gefixt
|
||||
Command.Fix.by_other = Du wurdest von $player gefixt
|
||||
|
||||
Shop.Lobby.Main = Lobby Shop
|
||||
Shop.Game.Maya.Main = Maya Game Shop
|
||||
|
||||
Lobby.Menu.Profile = Dein Profil
|
||||
Lobby.Menu.other_Profile = Profil von $player
|
||||
Lobby.Menu.Settings = Einstellungen
|
||||
Lobby.Menu.Language = Sprache einstellen
|
5
target/maven-archiver/pom.properties
Normal file
5
target/maven-archiver/pom.properties
Normal file
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Tue Aug 02 20:03:55 CEST 2016
|
||||
version=1.0-SNAPSHOT
|
||||
groupId=eu.univento
|
||||
artifactId=Commons
|
44
target/proguard_map.txt
Normal file
44
target/proguard_map.txt
Normal file
@ -0,0 +1,44 @@
|
||||
eu.univento.commons.Commons -> eu.univento.commons.Commons:
|
||||
eu.univento.commons.database.DatabaseManager databaseManager -> databaseManager
|
||||
eu.univento.commons.configuration.ConfigurationHandler configurationHandler -> configurationHandler
|
||||
eu.univento.commons.security.SecurityHandler securityHandler -> securityHandler
|
||||
eu.univento.commons.logging.LoggingHandler loggingHandler -> loggingHandler
|
||||
eu.univento.commons.database.DatabaseManager getDatabaseManager() -> getDatabaseManager
|
||||
eu.univento.commons.configuration.ConfigurationHandler getConfigurationHandler() -> getConfigurationHandler
|
||||
eu.univento.commons.security.SecurityHandler getSecurityHandler() -> getSecurityHandler
|
||||
eu.univento.commons.logging.LoggingHandler getLoggingHandler() -> getLoggingHandler
|
||||
void <init>() -> <init>
|
||||
void shutdown() -> shutdown
|
||||
eu.univento.commons.configuration.ConfigurationHandler -> eu.univento.commons.a.a:
|
||||
java.util.Properties properties -> a
|
||||
void <init>() -> <init>
|
||||
java.lang.String getString(java.lang.String) -> a
|
||||
int getInteger(java.lang.String) -> b
|
||||
eu.univento.commons.database.AsyncMongoDB -> eu.univento.commons.b.a:
|
||||
com.mongodb.async.client.MongoClient client -> a
|
||||
void <init>(java.lang.String,int,java.lang.String,java.lang.String,java.lang.String) -> <init>
|
||||
void closeConnection() -> a
|
||||
eu.univento.commons.database.AsyncMySQL -> eu.univento.commons.b.b:
|
||||
eu.univento.commons.database.MySQL sql -> a
|
||||
void <init>(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -> <init>
|
||||
eu.univento.commons.database.MySQL getMySQL() -> a
|
||||
eu.univento.commons.database.DatabaseManager -> eu.univento.commons.b.c:
|
||||
eu.univento.commons.database.MongoDB mongoDB -> a
|
||||
eu.univento.commons.database.AsyncMongoDB asyncMongoDB -> b
|
||||
eu.univento.commons.database.MySQL mySQL -> c
|
||||
eu.univento.commons.database.AsyncMySQL asyncMySQL -> d
|
||||
eu.univento.commons.database.AsyncMySQL boardSQL -> e
|
||||
void <init>(eu.univento.commons.Commons) -> <init>
|
||||
void closeConnections() -> a
|
||||
eu.univento.commons.database.MongoDB -> eu.univento.commons.b.d:
|
||||
com.mongodb.MongoClient client -> a
|
||||
void <init>(java.lang.String,int,java.lang.String,java.lang.String,java.lang.String) -> <init>
|
||||
void closeConnection() -> a
|
||||
eu.univento.commons.database.MySQL -> eu.univento.commons.b.e:
|
||||
com.zaxxer.hikari.HikariDataSource dataSource -> a
|
||||
void <init>(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -> <init>
|
||||
void close() -> a
|
||||
eu.univento.commons.logging.LoggingHandler -> eu.univento.commons.c.a:
|
||||
void <init>() -> <init>
|
||||
eu.univento.commons.security.SecurityHandler -> eu.univento.commons.d.a:
|
||||
void <init>(eu.univento.commons.Commons) -> <init>
|
11
target/proguard_seed.txt
Normal file
11
target/proguard_seed.txt
Normal file
@ -0,0 +1,11 @@
|
||||
eu.univento.commons.Commons
|
||||
eu.univento.commons.Commons: eu.univento.commons.database.DatabaseManager databaseManager
|
||||
eu.univento.commons.Commons: eu.univento.commons.configuration.ConfigurationHandler configurationHandler
|
||||
eu.univento.commons.Commons: eu.univento.commons.security.SecurityHandler securityHandler
|
||||
eu.univento.commons.Commons: eu.univento.commons.logging.LoggingHandler loggingHandler
|
||||
eu.univento.commons.Commons: eu.univento.commons.database.DatabaseManager getDatabaseManager()
|
||||
eu.univento.commons.Commons: eu.univento.commons.configuration.ConfigurationHandler getConfigurationHandler()
|
||||
eu.univento.commons.Commons: eu.univento.commons.security.SecurityHandler getSecurityHandler()
|
||||
eu.univento.commons.Commons: eu.univento.commons.logging.LoggingHandler getLoggingHandler()
|
||||
eu.univento.commons.Commons: Commons()
|
||||
eu.univento.commons.Commons: void shutdown()
|
Loading…
Reference in New Issue
Block a user