+ added Redis as database
+ started working on the new database system + started working on the new translation system + started working on chat logging
This commit is contained in:
parent
ce1b3a25bf
commit
7af33ddffd
|
@ -1,10 +1,4 @@
|
|||
<!--
|
||||
~ Copyright (c) 2017 univento.eu - All rights reserved
|
||||
~ You are not allowed to use, distribute or modify this code
|
||||
-->
|
||||
|
||||
<settings>
|
||||
|
||||
<servers>
|
||||
<server>
|
||||
<id>univentoEU</id>
|
||||
|
@ -17,9 +11,8 @@
|
|||
<mirror>
|
||||
<id>univentoEU</id>
|
||||
<name>univentoEU Mirror Repo</name>
|
||||
<url>http://dev.joethei.de:8081/repository/public/</url>
|
||||
<url>http://play.univento.eu:8081/repository/public/</url>
|
||||
<mirrorOf>*</mirrorOf>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
|
||||
</settings>
|
10
Commons.iml
10
Commons.iml
|
@ -1,6 +1,6 @@
|
|||
<?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">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
@ -12,9 +12,14 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.14.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb.morphia:morphia:1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: cglib:cglib-nodep:2.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.proxytoys:proxytoys:1.0" 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.zaxxer:SansOrm:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
|
||||
|
@ -30,7 +35,6 @@
|
|||
<orderEntry type="library" name="Maven: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" 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: net.gpedro.integrations.slack:slack-webhook:1.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
|
|
25
pom.xml
25
pom.xml
|
@ -48,27 +48,43 @@
|
|||
<distributionManagement>
|
||||
<repository>
|
||||
<id>univentoEU</id>
|
||||
<url>http://dev.joethei.de:8081/repository/univento-repo/</url>
|
||||
<url>http://dev.joethei.de:8081/repository/univento/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.14.8</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.mongodb.morphia</groupId>
|
||||
<artifactId>morphia</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.4.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>SansOrm</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
|
@ -124,11 +140,6 @@
|
|||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.gpedro.integrations.slack</groupId>
|
||||
<artifactId>slack-webhook</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.nsp</groupId>
|
||||
<artifactId>JSkills</artifactId>
|
||||
|
|
|
@ -3,13 +3,13 @@ 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.player.language.Languages;
|
||||
import eu.univento.commons.security.SecurityHandler;
|
||||
import eu.univento.commons.web.slack.SlackHandler;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Getter
|
||||
|
@ -21,7 +21,6 @@ public class Commons {
|
|||
private ConfigurationHandler configurationHandler;
|
||||
private SecurityHandler securityHandler;
|
||||
private LoggingHandler loggingHandler;
|
||||
private SlackHandler slackHandler;
|
||||
|
||||
public Commons() {
|
||||
commons = this;
|
||||
|
@ -29,7 +28,7 @@ public class Commons {
|
|||
databaseManager = new DatabaseManager(this);
|
||||
securityHandler = new SecurityHandler(this);
|
||||
loggingHandler = new LoggingHandler();
|
||||
slackHandler = new SlackHandler(configurationHandler.getString("Slack.hook_url"));
|
||||
Languages.init();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AsyncMySQL {
|
|||
}
|
||||
|
||||
public void update(String update) {
|
||||
executor.execute(() -> mySQL.query(update));
|
||||
executor.execute(() -> mySQL.update(update));
|
||||
}
|
||||
|
||||
public void query(String query, Consumer<ResultSet> consumer) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
@ -19,21 +19,24 @@ public class DatabaseManager {
|
|||
private MySQL mySQL;
|
||||
private AsyncMySQL asyncMySQL;
|
||||
private AsyncMySQL boardSQL;
|
||||
private Redis redis;
|
||||
|
||||
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"));
|
||||
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(config.getString("BoardSQL.Host"), config.getString("BoardSQL.Port"), config.getString("BoardSQL.Database"), config.getString("BoardSQL.Username"), config.getString("BoardSQL.Password"));
|
||||
redis = new Redis(config.getString("Redis.Hostname"), config.getInteger("Redis.Port"), config.getString("Redis.Password"));
|
||||
}
|
||||
|
||||
public void closeConnections() {
|
||||
mongoDB.closeConnection();
|
||||
asyncMongoDB.getMongoDB().closeConnection();
|
||||
//mySQL.close();
|
||||
//asyncMySQL.getMySQL().close();
|
||||
mySQL.close();
|
||||
asyncMySQL.getMySQL().close();
|
||||
//boardSQL.getMySQL().close();
|
||||
redis.close();
|
||||
}
|
||||
}
|
|
@ -4,6 +4,9 @@ import com.mongodb.MongoClient;
|
|||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import lombok.Getter;
|
||||
import org.mongodb.morphia.Datastore;
|
||||
import org.mongodb.morphia.Morphia;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -14,6 +17,7 @@ import java.util.Collections;
|
|||
public class MongoDB {
|
||||
|
||||
private final MongoClient client;
|
||||
@Getter private final Datastore datastore;
|
||||
private MongoDatabase database;
|
||||
|
||||
private final String host;
|
||||
|
@ -31,6 +35,12 @@ public class MongoDB {
|
|||
|
||||
MongoCredential credential = MongoCredential.createCredential(username, databaseName, password.toCharArray());
|
||||
client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential));
|
||||
|
||||
Morphia morphia = new Morphia();
|
||||
morphia.mapPackage("eu.univento.commons.player");
|
||||
|
||||
datastore = morphia.createDatastore(client, "univento");
|
||||
datastore.ensureIndexes();
|
||||
}
|
||||
|
||||
private MongoClient getClient() {
|
||||
|
@ -44,12 +54,11 @@ public class MongoDB {
|
|||
database = getClient().getDatabase(databaseName);
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = getClient().getDatabase(database);
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
void closeConnection() {
|
||||
if(client != null)
|
||||
client.close();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.database;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Redis {
|
||||
|
||||
private JedisPool jedisPool;
|
||||
|
||||
public Redis(String hostname, int port, String password) {
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMinIdle(8);
|
||||
poolConfig.setMaxTotal(32);
|
||||
|
||||
jedisPool = new JedisPool(poolConfig, hostname, port, 5000, password);
|
||||
}
|
||||
|
||||
public Jedis getJedis() {
|
||||
return jedisPool.getResource();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
jedisPool.close();
|
||||
jedisPool.destroy();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package eu.univento.commons.helpers;
|
|||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class Location {
|
||||
|
|
|
@ -12,9 +12,12 @@ import eu.univento.commons.player.hacks.HackData;
|
|||
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.language.Languages;
|
||||
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.rank.Group;
|
||||
import eu.univento.commons.player.rank.Rank;
|
||||
import eu.univento.commons.player.ranking.Ranking;
|
||||
import eu.univento.commons.player.settings.PlayerSettings;
|
||||
import eu.univento.commons.player.warn.WarnData;
|
||||
|
@ -56,7 +59,7 @@ public class DatabasePlayer {
|
|||
MongoDB mongoDB = commons.getDatabaseManager().getMongoDB();
|
||||
playerCollection = mongoDB.getDatabase().getCollection("players");
|
||||
friendCollection = mongoDB.getDatabase().getCollection("friends");
|
||||
onlinePlayerCollection = mongoDB.getDatabase().getCollection("online-players");
|
||||
onlinePlayerCollection = mongoDB.getDatabase().getCollection("onlinePlayers");
|
||||
banCollection = mongoDB.getDatabase().getCollection("bans");
|
||||
warnCollection = mongoDB.getDatabase().getCollection("warns");
|
||||
kickCollection = mongoDB.getDatabase().getCollection("kicks");
|
||||
|
@ -65,13 +68,17 @@ public class DatabasePlayer {
|
|||
|
||||
settings = new PlayerSettings(this);
|
||||
hackData = new HackData(this);
|
||||
language = new Language(getSettings().getLanguage());
|
||||
language = Languages.getLanguage(getSettings().getLanguage());
|
||||
}
|
||||
|
||||
public Collection<Profile> getProfiles() {
|
||||
return getArrayListFromDatabase("profiles").stream().map(id -> new Profile(this, id)).collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
public MongoPlayer query() {
|
||||
return Commons.getCommons().getDatabaseManager().getMongoDB().getDatastore().createQuery(MongoPlayer.class).field("uuid").equal(uuid).get();
|
||||
}
|
||||
|
||||
public Ranking getRanking() {
|
||||
return Ranking.getFromInt(getIntegerFromDatabase("ranking"));
|
||||
}
|
||||
|
@ -222,6 +229,11 @@ public class DatabasePlayer {
|
|||
return getRank().getValue() >= rank.getValue();
|
||||
}
|
||||
|
||||
public boolean isAllowed(Group group) throws Exception {
|
||||
if(getRank().getGroup() == Group.None) throw new Exception("The group None is not supported");
|
||||
return getRank().getGroup() == group;
|
||||
}
|
||||
|
||||
public boolean hasPlayedBefore() {
|
||||
FindIterable<Document> cursor = playerCollection.find(new Document("uuid", uuid.toString()));
|
||||
cursor.cursorType(CursorType.NonTailable);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.mongodb.morphia.annotations.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Entity("players")
|
||||
@Indexes(@Index(value = "lastName", fields = @Field("lastName")))
|
||||
public class MongoPlayer {
|
||||
@Id private ObjectId id;
|
||||
private UUID uuid;
|
||||
private String lastName;
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package eu.univento.commons.player;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum Rank {
|
||||
|
||||
Admin(16, 107, 5, "§4", "§8[§4Admin§8] §4", " §8»§7 ", "a", "§4Admin | "),
|
||||
SrDeveloper(15, 141, 18, "§3", "§8[§3SrDev§8] §3", " §8»§7 ", "c", "§3SrDev | "),
|
||||
SrBuilder(14, 142, 15, "§2", "§8[§2SrBuilder§8] §2", " §8»§7 ", "f", "§2SrBuilder | "),
|
||||
SrSupporter(13, 149, 12, "§9", "§8[§9SrSupr§8] §9", " §8»§7 ", "i", "§9SrSup | "),
|
||||
Developer(12, 144, 17, "§3", "§8[§3Dev§8] §3", " §8»§7 ", "d", "§3Dev | "),
|
||||
Builder(11, 145, 14, "§2", "§8[§2Builder§8] §2", " §8»§7 ", "g", "§2Builder | "),
|
||||
Supporter(10, 146, 11, "§9", "§8[§9Sup§8] §9", " §8»§7 ", "j", "§9Sup | "),
|
||||
JrDeveloper(9, 147, 16, "§3", "§8[§3JrDev§8] §3", " §8»§7 ", "e", "§3JrDev | "),
|
||||
JrBuilder(8, 148, 13, "§2", "§8[§2JrBuilder§8] §2", " §8»§7 ", "h", "§2JrBuilder | "),
|
||||
JrSupporter(7, 149, 10, "§9", "§8[§9JrSup§8] §9", " §8»§7 ", "k", "§9JrSup | "),
|
||||
Manager(6, 150, 19, "§c", "§8[§cManager§8] §c", " §8»§7 ", "b", "§cManager | "),
|
||||
Grafik(5, 151, 8, "§e", "§8[§eGrafiker§8] §e", " §8»§7 ", "l", "§eGrafik | "),
|
||||
Sound(4, 152, 9, "§e", "§8[§eSound§8] §e", " §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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player.chat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ChatData {
|
||||
|
||||
private final UUID sender;
|
||||
private final ChatMessageType type;
|
||||
private final Date date;
|
||||
private final String message;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player.chat;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum ChatMessageType {
|
||||
Public,
|
||||
Private,
|
||||
Party,
|
||||
Team
|
||||
}
|
|
@ -6,7 +6,7 @@ import java.util.UUID;
|
|||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
public class FriendData {
|
||||
|
||||
|
|
|
@ -1,31 +1,49 @@
|
|||
package eu.univento.commons.player.language;
|
||||
|
||||
import com.zaxxer.sansorm.OrmElf;
|
||||
import com.zaxxer.sansorm.SqlClosure;
|
||||
import eu.univento.commons.Commons;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
//TODO: optimize
|
||||
public class Language {
|
||||
|
||||
private final ResourceBundle translation;
|
||||
private HashMap<String, String> translations;
|
||||
|
||||
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 Language(Locale locale) {
|
||||
translations = new HashMap<>();
|
||||
try {
|
||||
List<Translation> translationList = new SqlClosure<List<Translation>>() {
|
||||
public List<Translation> execute(Connection connection) throws SQLException {
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM translations;");
|
||||
return OrmElf.statementToList(statement, Translation.class);
|
||||
}
|
||||
}.execute(Commons.getCommons().getDatabaseManager().getMySQL().getConnection());
|
||||
|
||||
for(Translation translation : translationList) {
|
||||
translations.put(translation.getIdentifier(), translation.getTranslation(locale));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getWord(String keyword) {
|
||||
return translation.getString(keyword);
|
||||
return translations.get(keyword);
|
||||
}
|
||||
|
||||
public String getMessage(MessageConstant constant) {
|
||||
return translation.getString(constant.getName());
|
||||
return translations.get(constant.getName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player.language;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Languages {
|
||||
|
||||
private static Language german;
|
||||
private static Language english;
|
||||
|
||||
public static void init() {
|
||||
german = new Language(Locale.GERMAN);
|
||||
english = new Language(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
//TODO: optimize
|
||||
public static Language getLanguage(String language) {
|
||||
if(language.equals("DE")) return german;
|
||||
if(language.equals("EN")) return english;
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import lombok.Getter;
|
|||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
public enum MessageConstant {
|
||||
|
||||
|
@ -31,8 +31,7 @@ public enum MessageConstant {
|
|||
|
||||
GAME_SPECTATE_MENU("Game.Menu.SpectatorMenu");
|
||||
|
||||
@Getter
|
||||
private String name;
|
||||
@Getter private final String name;
|
||||
|
||||
MessageConstant(String name) {
|
||||
this.name = name;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
package eu.univento.commons.player.language;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Table(name="translations")
|
||||
class Translation {
|
||||
@Id private int id;
|
||||
private String identifier;
|
||||
private String german;
|
||||
private String english;
|
||||
|
||||
//TODO: optimize
|
||||
String getTranslation(Locale locale) {
|
||||
if(locale == Locale.GERMAN) return german;
|
||||
if(locale == Locale.ENGLISH) return english;
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player.rank;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum Group {
|
||||
|
||||
None("", "", "", ""),
|
||||
Developer("§3", "§8[§3Dev§8] §3", " §8»§7 ", "§3Dev | "),
|
||||
Moderator("§c", "§8[§cMod§8] §3", "§8»§7", "§cMod | "),
|
||||
Supporter("§9", "§8[§9Sup§8] §9", " §8»§7 ", "§9Sup | "),
|
||||
Builder("§2", "§8[§2Builder§8] §2", " §8»§7 ", "§2Builder | "),
|
||||
Design("§e", "§8[§eDesign§8] §e", " §8»§7 ", "§eDesign | ");
|
||||
|
||||
private final String color;
|
||||
private final String prefix;
|
||||
private final String suffix;
|
||||
private final String tab;
|
||||
|
||||
Group(String color, String prefix, String suffix, String tab) {
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.tab = tab;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2017 univento.eu - All rights reserved
|
||||
* You are not allowed to use, distribute or modify this code
|
||||
*/
|
||||
|
||||
package eu.univento.commons.player.rank;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
public enum Rank {
|
||||
|
||||
Admin(18, 0, 0, Group.None, "a", "§4", "§8[§4Admin§8] §4", " §8»§7 ", "§4Admin | "),
|
||||
|
||||
SrDeveloper(17, 0, 0, Group.Developer, "b"),
|
||||
Developer(16, 0, 0, Group.Developer, "c"),
|
||||
JrDeveloper(15, 0, 0, Group.Developer, "d"),
|
||||
|
||||
SrBuilder(8, 0, 0, Group.Builder, "e"),
|
||||
Builder(7, 0, 0, Group.Builder, "f"),
|
||||
JrBuilder(6, 0, 0, Group.Builder, "g"),
|
||||
|
||||
SrModerator(14, 0, 0, Group.Moderator, "h"),
|
||||
Moderator(13, 0, 0, Group.Moderator, "i"),
|
||||
JrModerator(12, 0, 0, Group.Moderator, "j"),
|
||||
|
||||
SrSupporter(11, 0, 0, Group.Supporter, "k"),
|
||||
Supporter(10, 0, 0, Group.Supporter, "l"),
|
||||
JrSupporter(9, 0, 0, Group.Supporter, "m"),
|
||||
|
||||
Graphic(5, 0, 0, Group.Design, "n"),
|
||||
Sound(4, 0, 0, Group.Design, "o"),
|
||||
|
||||
VIP(3, 0, 0, Group.None, "p", "§5", "§5", " §8»§7 ", "§5"),
|
||||
Premium(2, 0, 0, Group.None, "q", "§6", "§6", " §8»§7 ", "§6"),
|
||||
Player(1, 0, 0, Group.None, "r","§7", "§7", " §8»§7 ", "§7");
|
||||
|
||||
@Getter private final int value;
|
||||
@Getter private final int ts;
|
||||
@Getter private final int board;
|
||||
@Getter private final Group group;
|
||||
@Getter private final String team;
|
||||
|
||||
private String color;
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
private String tab;
|
||||
|
||||
Rank(int value, int ts, int board, Group group, String team) {
|
||||
this.value = value;
|
||||
this.ts = ts;
|
||||
this.board = board;
|
||||
this.group = group;
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
Rank(int value, int ts, int board, Group group, String team, String color, String prefix, String suffix, String tab) {
|
||||
this.value = value;
|
||||
this.ts = ts;
|
||||
this.board = board;
|
||||
this.group = group;
|
||||
this.team = team;
|
||||
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
if(group == Group.None) return color;
|
||||
return group.getColor();
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
if(group == Group.None) return prefix;
|
||||
return group.getPrefix();
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
if(group == Group.None) return suffix;
|
||||
return group.getSuffix();
|
||||
}
|
||||
|
||||
public String getTab() {
|
||||
if(group == Group.None) return tab;
|
||||
return group.getTab();
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import java.util.Map;
|
|||
|
||||
public class GameStats {
|
||||
|
||||
|
||||
public ServerType type;
|
||||
private DatabasePlayer player;
|
||||
private Map<String, Object> stats = new HashMap<>();
|
||||
|
@ -22,7 +21,6 @@ public class GameStats {
|
|||
this.type = type;
|
||||
this.player = player;
|
||||
stats = player.getMapFromDatabase(type.getName());
|
||||
|
||||
}
|
||||
|
||||
public Long getStat(String name) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
|||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
public class WarnData {
|
||||
|
||||
|
|
|
@ -31,12 +31,13 @@ public class SecurityHandler {
|
|||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
*/
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public boolean isValidServer(String ip) {
|
||||
return true;
|
||||
//return cache.contains(ip);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void load(Consumer<ResultSet> consumer) {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package eu.univento.commons.updater;
|
||||
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class CustomAuthenticator 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) {
|
||||
CustomAuthenticator.username = username;
|
||||
CustomAuthenticator.password = password;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package eu.univento.commons.utils;
|
|||
|
||||
/**
|
||||
* @author joethei, Alex Gitelman
|
||||
* @version 0.1
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Strings {
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package eu.univento.commons.web.slack;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.gpedro.integrations.slack.SlackApi;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class SlackHandler {
|
||||
|
||||
@Getter
|
||||
private SlackApi slackAPI;
|
||||
|
||||
public SlackHandler(String hook) {
|
||||
slackAPI = new SlackApi(hook);
|
||||
}
|
||||
}
|
|
@ -1,20 +1,23 @@
|
|||
MySQL.Host = vps.joethei.de
|
||||
MySQL.Host = univento.eu
|
||||
MySQL.Port = 3306
|
||||
MySQL.Username = univento
|
||||
MySQL.Database = univento
|
||||
MySQL.Password = dWez!530Erwz7&44
|
||||
MySQL.Username = custo_univento
|
||||
MySQL.Database = customer1479_univento
|
||||
MySQL.Password = zlp7E0#2
|
||||
MongoDB.Host = vps.joethei.de
|
||||
MongoDB.Port = 27017
|
||||
MongoDB.Username = admin
|
||||
MongoDB.Password = ++JT1415++
|
||||
MongoDB.Username = univento
|
||||
MongoDB.Password = 8UWUpJt5*v2np&SaR^c&4JjX4@K9WtH3w*#Wb*n3zwQdxA6NR&gV628NuSsJ%y8kwg*r*Ep5VfdZ3dR@Kp7j^@2d4mGdcz!3WtyD
|
||||
MongoDB.Database = univento
|
||||
Redis.Hostname = vps.joethei.de
|
||||
Redis.Port = 6379
|
||||
Redis.Password = wVDfDSqay8xyYrMq#QSFnE9Zd@TK7#BT3g&GrE#3vXVa!wG4mEWFguP!b#2@QJPDZHU5Ywdfxwc5sK3Gp35ZZ3AWPUGw@m85FPWU
|
||||
BoardSQL.Host = univento.eu
|
||||
BoardSQL.Port = 3306
|
||||
BoardSQL.Username = forum
|
||||
BoardSQL.Password = 2Ogxk6$5Yvsr4*24
|
||||
BoardSQL.Database = forum
|
||||
TS3.Hostname = dev.joethei.de
|
||||
TS3.ID = 9
|
||||
TS3.Hostname = vps.joethei.de
|
||||
TS3.ID = 1
|
||||
TS3.Username = serveradmin
|
||||
TS3.Password = Wb69cypb499CTP4vtaJPKpKZELUbPD
|
||||
Slack.hook_url = https://hooks.slack.com/services/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
|
Loading…
Reference in New Issue