diff --git a/.ci/settings.xml b/.ci/settings.xml
index 9c09dd4..1d1636c 100644
--- a/.ci/settings.xml
+++ b/.ci/settings.xml
@@ -1,10 +1,4 @@
-
-
-
univentoEU
@@ -17,9 +11,8 @@
univentoEU
univentoEU Mirror Repo
- http://dev.joethei.de:8081/repository/public/
+ http://play.univento.eu:8081/repository/public/
*
-
\ No newline at end of file
diff --git a/Commons.iml b/Commons.iml
index b9ba292..641cdf9 100644
--- a/Commons.iml
+++ b/Commons.iml
@@ -1,6 +1,6 @@
-
+
@@ -12,9 +12,14 @@
-
+
+
+
+
+
+
@@ -30,7 +35,6 @@
-
diff --git a/pom.xml b/pom.xml
index 512989a..24df0db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,27 +48,43 @@
univentoEU
- http://dev.joethei.de:8081/repository/univento-repo/
+ http://dev.joethei.de:8081/repository/univento/
-
org.projectlombok
lombok
1.14.8
+
+
+ org.mongodb.morphia
+ morphia
+ 1.3.1
+
com.zaxxer
HikariCP
2.4.5
+
+ com.zaxxer
+ SansOrm
+ 1.0
+
+
+ javax.persistence
+ persistence-api
+ 1.0.2
+
redis.clients
jedis
@@ -124,11 +140,6 @@
log4j-core
2.6.2
-
- net.gpedro.integrations.slack
- slack-webhook
- 1.2.1
-
com.github.nsp
JSkills
diff --git a/src/main/java/eu/univento/commons/Commons.java b/src/main/java/eu/univento/commons/Commons.java
index 30abf3f..2f620d5 100644
--- a/src/main/java/eu/univento/commons/Commons.java
+++ b/src/main/java/eu/univento/commons/Commons.java
@@ -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() {
diff --git a/src/main/java/eu/univento/commons/database/AsyncMySQL.java b/src/main/java/eu/univento/commons/database/AsyncMySQL.java
index 492767a..bc6164f 100644
--- a/src/main/java/eu/univento/commons/database/AsyncMySQL.java
+++ b/src/main/java/eu/univento/commons/database/AsyncMySQL.java
@@ -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 consumer) {
diff --git a/src/main/java/eu/univento/commons/database/DatabaseManager.java b/src/main/java/eu/univento/commons/database/DatabaseManager.java
index abd47c5..92d3c76 100644
--- a/src/main/java/eu/univento/commons/database/DatabaseManager.java
+++ b/src/main/java/eu/univento/commons/database/DatabaseManager.java
@@ -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();
}
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/database/MongoDB.java b/src/main/java/eu/univento/commons/database/MongoDB.java
index 1b63e83..b4300c1 100644
--- a/src/main/java/eu/univento/commons/database/MongoDB.java
+++ b/src/main/java/eu/univento/commons/database/MongoDB.java
@@ -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();
}
diff --git a/src/main/java/eu/univento/commons/database/Redis.java b/src/main/java/eu/univento/commons/database/Redis.java
new file mode 100644
index 0000000..2d23d01
--- /dev/null
+++ b/src/main/java/eu/univento/commons/database/Redis.java
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/helpers/Location.java b/src/main/java/eu/univento/commons/helpers/Location.java
index 65bea0a..5d57ec4 100644
--- a/src/main/java/eu/univento/commons/helpers/Location.java
+++ b/src/main/java/eu/univento/commons/helpers/Location.java
@@ -2,7 +2,7 @@ package eu.univento.commons.helpers;
/**
* @author joethei
- * @version 0.1
+ * @version 1.0
*/
public class Location {
diff --git a/src/main/java/eu/univento/commons/player/DatabasePlayer.java b/src/main/java/eu/univento/commons/player/DatabasePlayer.java
index afb4485..104e747 100644
--- a/src/main/java/eu/univento/commons/player/DatabasePlayer.java
+++ b/src/main/java/eu/univento/commons/player/DatabasePlayer.java
@@ -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 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 cursor = playerCollection.find(new Document("uuid", uuid.toString()));
cursor.cursorType(CursorType.NonTailable);
diff --git a/src/main/java/eu/univento/commons/player/MongoPlayer.java b/src/main/java/eu/univento/commons/player/MongoPlayer.java
new file mode 100644
index 0000000..b4810cc
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/MongoPlayer.java
@@ -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;
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/Rank.java b/src/main/java/eu/univento/commons/player/Rank.java
deleted file mode 100644
index c5fbcb6..0000000
--- a/src/main/java/eu/univento/commons/player/Rank.java
+++ /dev/null
@@ -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;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/chat/ChatData.java b/src/main/java/eu/univento/commons/player/chat/ChatData.java
new file mode 100644
index 0000000..a061555
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/chat/ChatData.java
@@ -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;
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/chat/ChatMessageType.java b/src/main/java/eu/univento/commons/player/chat/ChatMessageType.java
new file mode 100644
index 0000000..8e96fce
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/chat/ChatMessageType.java
@@ -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
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/friend/FriendData.java b/src/main/java/eu/univento/commons/player/friend/FriendData.java
index 617e92a..c32c742 100644
--- a/src/main/java/eu/univento/commons/player/friend/FriendData.java
+++ b/src/main/java/eu/univento/commons/player/friend/FriendData.java
@@ -6,7 +6,7 @@ import java.util.UUID;
/**
* @author joethei
- * @version 0.1
+ * @version 1.0
*/
public class FriendData {
diff --git a/src/main/java/eu/univento/commons/player/language/Language.java b/src/main/java/eu/univento/commons/player/language/Language.java
index 015eaf8..7096fd9 100644
--- a/src/main/java/eu/univento/commons/player/language/Language.java
+++ b/src/main/java/eu/univento/commons/player/language/Language.java
@@ -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 translations;
- public Language(String language) {
- Map 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 translationList = new SqlClosure>() {
+ public List 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());
}
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/language/Languages.java b/src/main/java/eu/univento/commons/player/language/Languages.java
new file mode 100644
index 0000000..c029063
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/language/Languages.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/language/MessageConstant.java b/src/main/java/eu/univento/commons/player/language/MessageConstant.java
index 1c5b5b8..2ed611f 100644
--- a/src/main/java/eu/univento/commons/player/language/MessageConstant.java
+++ b/src/main/java/eu/univento/commons/player/language/MessageConstant.java
@@ -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;
diff --git a/src/main/java/eu/univento/commons/player/language/Translation.java b/src/main/java/eu/univento/commons/player/language/Translation.java
new file mode 100644
index 0000000..d3072ab
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/language/Translation.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/rank/Group.java b/src/main/java/eu/univento/commons/player/rank/Group.java
new file mode 100644
index 0000000..fd6d8d7
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/rank/Group.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/rank/Rank.java b/src/main/java/eu/univento/commons/player/rank/Rank.java
new file mode 100644
index 0000000..14e028e
--- /dev/null
+++ b/src/main/java/eu/univento/commons/player/rank/Rank.java
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/player/statistics/GameStats.java b/src/main/java/eu/univento/commons/player/statistics/GameStats.java
index e09eadd..4436dbc 100644
--- a/src/main/java/eu/univento/commons/player/statistics/GameStats.java
+++ b/src/main/java/eu/univento/commons/player/statistics/GameStats.java
@@ -13,7 +13,6 @@ import java.util.Map;
public class GameStats {
-
public ServerType type;
private DatabasePlayer player;
private Map 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) {
diff --git a/src/main/java/eu/univento/commons/player/warn/WarnData.java b/src/main/java/eu/univento/commons/player/warn/WarnData.java
index ba524a6..c853f6a 100644
--- a/src/main/java/eu/univento/commons/player/warn/WarnData.java
+++ b/src/main/java/eu/univento/commons/player/warn/WarnData.java
@@ -7,7 +7,7 @@ import java.util.UUID;
/**
* @author joethei
- * @version 0.1
+ * @version 1.0
*/
public class WarnData {
diff --git a/src/main/java/eu/univento/commons/security/SecurityHandler.java b/src/main/java/eu/univento/commons/security/SecurityHandler.java
index c06158e..48307dc 100644
--- a/src/main/java/eu/univento/commons/security/SecurityHandler.java
+++ b/src/main/java/eu/univento/commons/security/SecurityHandler.java
@@ -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 consumer) {
diff --git a/src/main/java/eu/univento/commons/updater/CustomAuthenticator.java b/src/main/java/eu/univento/commons/updater/CustomAuthenticator.java
deleted file mode 100644
index ce5ef73..0000000
--- a/src/main/java/eu/univento/commons/updater/CustomAuthenticator.java
+++ /dev/null
@@ -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;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/updater/Updater.java b/src/main/java/eu/univento/commons/updater/Updater.java
deleted file mode 100644
index 1f7255b..0000000
--- a/src/main/java/eu/univento/commons/updater/Updater.java
+++ /dev/null
@@ -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;
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/commons/utils/Strings.java b/src/main/java/eu/univento/commons/utils/Strings.java
index c027f81..19ddd48 100644
--- a/src/main/java/eu/univento/commons/utils/Strings.java
+++ b/src/main/java/eu/univento/commons/utils/Strings.java
@@ -2,7 +2,7 @@ package eu.univento.commons.utils;
/**
* @author joethei, Alex Gitelman
- * @version 0.1
+ * @version 1.0
*/
public class Strings {
diff --git a/src/main/java/eu/univento/commons/web/slack/SlackHandler.java b/src/main/java/eu/univento/commons/web/slack/SlackHandler.java
deleted file mode 100644
index 55edceb..0000000
--- a/src/main/java/eu/univento/commons/web/slack/SlackHandler.java
+++ /dev/null
@@ -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);
- }
-}
\ No newline at end of file
diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties
index 479fbb7..44bb3b8 100644
--- a/src/main/resources/config.properties
+++ b/src/main/resources/config.properties
@@ -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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
\ No newline at end of file