commit bfd16f833e2edb201745321881abc23e89de7b16 Author: joethei Date: Tue Aug 2 23:53:40 2016 +0200 first commit diff --git a/Commons.iml b/Commons.iml new file mode 100644 index 0000000..d174c78 --- /dev/null +++ b/Commons.iml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..8e4a8b4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,178 @@ + + + 4.0.0 + + eu.univento + Commons + 1.0-SNAPSHOT + + univento.eu Common Code + https://development.univento.eu/docs/Commons + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + + eu.univento.commons.Commons + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.4 + + en + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + + javadoc + + + + + + com.github.wvengen + proguard-maven-plugin + 2.0.13 + + + package + + proguard + + + + + true + ${project.build.finalName}.jar + ${project.build.finalName}-small.jar + true + + + + + ${java.home}/lib/rt.jar + ${java.home}/lib/jce.jar + + + + Commons + eu.univento.commons + + + + + + + + net.sf.proguard + proguard-base + 5.2.1 + runtime + + + + + + + + + + org.mongodb + mongo-java-driver + 3.2.2 + + + org.mongodb + mongodb-driver-async + 3.2.2 + + + io.netty + netty-all + 4.0.36.Final + + + com.google.code.gson + gson + 2.3.1 + + + com.zaxxer + HikariCP + 2.4.5 + compile + + + com.google.guava + guava + 19.0 + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + joda-time + joda-time + 2.9.4 + + + org.apache.logging.log4j + log4j-api + 2.6.2 + + + org.apache.logging.log4j + log4j-core + 2.6.2 + + + org.apache.commons + commons-lang3 + 3.1 + + + commons-io + commons-io + RELEASE + + + \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/Commons.java b/src/main/java/eu/univento/commons/Commons.java new file mode 100644 index 0000000..3734f82 --- /dev/null +++ b/src/main/java/eu/univento/commons/Commons.java @@ -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(); + } + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/configuration/ConfigurationHandler.java b/src/main/java/eu/univento/commons/configuration/ConfigurationHandler.java new file mode 100644 index 0000000..c21fd17 --- /dev/null +++ b/src/main/java/eu/univento/commons/configuration/ConfigurationHandler.java @@ -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)); + } +} diff --git a/src/main/java/eu/univento/commons/database/AsyncMongoDB.java b/src/main/java/eu/univento/commons/database/AsyncMongoDB.java new file mode 100644 index 0000000..ed63ee7 --- /dev/null +++ b/src/main/java/eu/univento/commons/database/AsyncMongoDB.java @@ -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 addressList = new ArrayList<>(); + addressList.add(new ServerAddress(host, port)); + List 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(); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/database/AsyncMySQL.java b/src/main/java/eu/univento/commons/database/AsyncMySQL.java new file mode 100644 index 0000000..5c1c9e7 --- /dev/null +++ b/src/main/java/eu/univento/commons/database/AsyncMySQL.java @@ -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 consumer) { + executor.execute(() -> { + ResultSet result = null; + result = sql.query(query); + ResultSet finalResult = result; + consumer.accept(finalResult); + }); + } + + public MySQL getMySQL() { + return sql; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/database/DatabaseManager.java b/src/main/java/eu/univento/commons/database/DatabaseManager.java new file mode 100644 index 0000000..79cf4d7 --- /dev/null +++ b/src/main/java/eu/univento/commons/database/DatabaseManager.java @@ -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; + } +} \ 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 new file mode 100644 index 0000000..3b9a4fb --- /dev/null +++ b/src/main/java/eu/univento/commons/database/MongoDB.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/database/MySQL.java b/src/main/java/eu/univento/commons/database/MySQL.java new file mode 100644 index 0000000..c87f4ee --- /dev/null +++ b/src/main/java/eu/univento/commons/database/MySQL.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/logging/LoggingHandler.java b/src/main/java/eu/univento/commons/logging/LoggingHandler.java new file mode 100644 index 0000000..0d65ad3 --- /dev/null +++ b/src/main/java/eu/univento/commons/logging/LoggingHandler.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/DatabasePlayer.java b/src/main/java/eu/univento/commons/player/DatabasePlayer.java new file mode 100644 index 0000000..b724b8a --- /dev/null +++ b/src/main/java/eu/univento/commons/player/DatabasePlayer.java @@ -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 playerCollection; + private final MongoCollection friendCollection; + private final MongoCollection onlinePlayerCollection; + private final MongoCollection banCollection; + private final MongoCollection warnCollection; + private final MongoCollection kickCollection; + private final MongoCollection muteCollection; + private final MongoCollection 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 getPlayerCollection() { + return playerCollection; + } + + public MongoCollection getFriendCollection() { + return friendCollection; + } + + public MongoCollection getOnlinePlayerCollection() { + return onlinePlayerCollection; + } + + public MongoCollection getBanCollection() { + return banCollection; + } + + public MongoCollection getWarnCollection() { + return warnCollection; + } + + public MongoCollection getKickCollection() { + return kickCollection; + } + + public MongoCollection getMuteCollection() { + return muteCollection; + } + + public MongoCollection getProfileCollection() { + return profileCollection; + } + + public Collection getProfiles() { + ArrayList 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 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 getAllBans() { + FindIterable cursor = banCollection.find(new Document("uuid", uuid.toString())); + cursor.cursorType(CursorType.NonTailable); + Iterator iterator = cursor.iterator(); + Collection 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 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 getAllWarns() { + FindIterable cursor = warnCollection.find(new Document("uuid", uuid.toString())); + cursor.cursorType(CursorType.NonTailable); + Iterator iterator = cursor.iterator(); + Collection 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 getAllKicks() { + FindIterable cursor = kickCollection.find(new Document("uuid", uuid.toString())); + cursor.cursorType(CursorType.NonTailable); + Iterator iterator = cursor.iterator(); + LinkedList 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 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 getAllMutes() { + FindIterable cursor = muteCollection.find(new Document("uuid", uuid.toString())); + cursor.cursorType(CursorType.NonTailable); + Iterator iterator = cursor.iterator(); + LinkedList 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 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 secrets) { + setInDatabase("foundSecrets", secrets); + } + + public void addSecret(String name) { + ArrayList list = getFoundSecrets(); + list.add(name); + setFoundSecrets(list); + } + + private void setFoundEggs(ArrayList eggs) { + setInDatabase("foundEggs", eggs); + } + + public void addEgg(String name) { + ArrayList 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 getFoundSecrets() { + return getArrayListFromDatabase("foundSecrets"); + } + + public int getEggs() { + return getFoundEggs().size(); + } + + private ArrayList getFoundEggs() { + return getArrayListFromDatabase("foundEggs"); + } + + private void setFriends(Collection friends) { + List 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 getFriends() { + FindIterable cursor = friendCollection.find(new Document("uuid", uuid.toString())); + cursor.cursorType(CursorType.NonTailable); + + Document doc = cursor.first(); + if (doc == null) return null; + + LinkedList list = (LinkedList) 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 list = getFriends(); + assert list != null; + list.add(new FriendData(uuid)); + setFriends(list); + } + + public void removeFriend(UUID uuid) { + Collection 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 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 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 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 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 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 getArrayListFromDatabase(String name) { + return (ArrayList) getObjectFromDatbase(name); + } + + public Map getMapFromDatabase(String name) { + return (Map) getObjectFromDatbase(name); + } +} \ 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 new file mode 100644 index 0000000..1b3feea --- /dev/null +++ b/src/main/java/eu/univento/commons/player/Rank.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/ban/BanData.java b/src/main/java/eu/univento/commons/player/ban/BanData.java new file mode 100644 index 0000000..3cfa59a --- /dev/null +++ b/src/main/java/eu/univento/commons/player/ban/BanData.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/ban/BanReason.java b/src/main/java/eu/univento/commons/player/ban/BanReason.java new file mode 100644 index 0000000..481730f --- /dev/null +++ b/src/main/java/eu/univento/commons/player/ban/BanReason.java @@ -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; + } +} \ 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 new file mode 100644 index 0000000..617e92a --- /dev/null +++ b/src/main/java/eu/univento/commons/player/friend/FriendData.java @@ -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); + } +} diff --git a/src/main/java/eu/univento/commons/player/kick/KickData.java b/src/main/java/eu/univento/commons/player/kick/KickData.java new file mode 100644 index 0000000..eac452a --- /dev/null +++ b/src/main/java/eu/univento/commons/player/kick/KickData.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/kick/KickReason.java b/src/main/java/eu/univento/commons/player/kick/KickReason.java new file mode 100644 index 0000000..0caf741 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/kick/KickReason.java @@ -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; + } + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/language/Language.java b/src/main/java/eu/univento/commons/player/language/Language.java new file mode 100644 index 0000000..d8e038f --- /dev/null +++ b/src/main/java/eu/univento/commons/player/language/Language.java @@ -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 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); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/mute/MuteData.java b/src/main/java/eu/univento/commons/player/mute/MuteData.java new file mode 100644 index 0000000..b7aa951 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/mute/MuteData.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/mute/MuteReason.java b/src/main/java/eu/univento/commons/player/mute/MuteReason.java new file mode 100644 index 0000000..8949fa1 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/mute/MuteReason.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/profiles/PlayerProfiles.java b/src/main/java/eu/univento/commons/player/profiles/PlayerProfiles.java new file mode 100644 index 0000000..5a302dc --- /dev/null +++ b/src/main/java/eu/univento/commons/player/profiles/PlayerProfiles.java @@ -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 collection; + + public PlayerProfiles(DatabasePlayer player) { + this.uuid = player.getUuid(); + this.collection = player.getProfileCollection(); + } + + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/profiles/Profile.java b/src/main/java/eu/univento/commons/player/profiles/Profile.java new file mode 100644 index 0000000..66d946f --- /dev/null +++ b/src/main/java/eu/univento/commons/player/profiles/Profile.java @@ -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 items; + + public Profile(DatabasePlayer player, String id) { + this.id = id; + FindIterable 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 list = (Collection) 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 getItems() { + return items; + } + + public String getURL() { + return "https://players.univento.eu/" + player.getUuid() + "/profile/" + id; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/profiles/Save.java b/src/main/java/eu/univento/commons/player/profiles/Save.java new file mode 100644 index 0000000..fc99087 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/profiles/Save.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/profiles/StoryItem.java b/src/main/java/eu/univento/commons/player/profiles/StoryItem.java new file mode 100644 index 0000000..c4e2201 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/profiles/StoryItem.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/settings/PlayerSettings.java b/src/main/java/eu/univento/commons/player/settings/PlayerSettings.java new file mode 100644 index 0000000..7ef3c44 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/settings/PlayerSettings.java @@ -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 getSettings() { + return player.getMapFromDatabase("Settings"); + } + + private void setSettings(Map settings) { + player.setInDatabase("Settings", settings); + } + + private void setSetting(String name, Serializable setting) { + Map list = getSettings(); + list.put(name, setting); + setSettings(list); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/uuid/NameFetcher.java b/src/main/java/eu/univento/commons/player/uuid/NameFetcher.java new file mode 100644 index 0000000..dcfe32f --- /dev/null +++ b/src/main/java/eu/univento/commons/player/uuid/NameFetcher.java @@ -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("-", ""); + } +} diff --git a/src/main/java/eu/univento/commons/player/uuid/UUIDFetcher.java b/src/main/java/eu/univento/commons/player/uuid/UUIDFetcher.java new file mode 100644 index 0000000..c94f8a0 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/uuid/UUIDFetcher.java @@ -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; + } + } +} diff --git a/src/main/java/eu/univento/commons/player/warn/WarnData.java b/src/main/java/eu/univento/commons/player/warn/WarnData.java new file mode 100644 index 0000000..de31979 --- /dev/null +++ b/src/main/java/eu/univento/commons/player/warn/WarnData.java @@ -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); + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/player/warn/WarnReason.java b/src/main/java/eu/univento/commons/player/warn/WarnReason.java new file mode 100644 index 0000000..cfa6caf --- /dev/null +++ b/src/main/java/eu/univento/commons/player/warn/WarnReason.java @@ -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; + } +} diff --git a/src/main/java/eu/univento/commons/security/SecurityHandler.java b/src/main/java/eu/univento/commons/security/SecurityHandler.java new file mode 100644 index 0000000..890844e --- /dev/null +++ b/src/main/java/eu/univento/commons/security/SecurityHandler.java @@ -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 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); + } + }); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/server/TPS.java b/src/main/java/eu/univento/commons/server/TPS.java new file mode 100644 index 0000000..5a73fcc --- /dev/null +++ b/src/main/java/eu/univento/commons/server/TPS.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/updater/CustomAuthenicator.java b/src/main/java/eu/univento/commons/updater/CustomAuthenicator.java new file mode 100644 index 0000000..2c17dad --- /dev/null +++ b/src/main/java/eu/univento/commons/updater/CustomAuthenicator.java @@ -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; + } +} \ 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 new file mode 100644 index 0000000..1f7255b --- /dev/null +++ b/src/main/java/eu/univento/commons/updater/Updater.java @@ -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; + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/commons/utils/Maths.java b/src/main/java/eu/univento/commons/utils/Maths.java new file mode 100644 index 0000000..e0a287b --- /dev/null +++ b/src/main/java/eu/univento/commons/utils/Maths.java @@ -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); + } + } +} \ 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 new file mode 100644 index 0000000..c027f81 --- /dev/null +++ b/src/main/java/eu/univento/commons/utils/Strings.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties new file mode 100644 index 0000000..c748b66 --- /dev/null +++ b/src/main/resources/config.properties @@ -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 diff --git a/src/main/resources/language.properties b/src/main/resources/language.properties new file mode 100644 index 0000000..a37adf2 --- /dev/null +++ b/src/main/resources/language.properties @@ -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 = diff --git a/src/main/resources/language_de.properties b/src/main/resources/language_de.properties new file mode 100644 index 0000000..389f41a --- /dev/null +++ b/src/main/resources/language_de.properties @@ -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 +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 \ No newline at end of file diff --git a/target/Commons-1.0-SNAPSHOT-jar-with-dependencies.jar b/target/Commons-1.0-SNAPSHOT-jar-with-dependencies.jar new file mode 100644 index 0000000..227b0b5 Binary files /dev/null and b/target/Commons-1.0-SNAPSHOT-jar-with-dependencies.jar differ diff --git a/target/Commons-1.0-SNAPSHOT-small.jar b/target/Commons-1.0-SNAPSHOT-small.jar new file mode 100644 index 0000000..1216881 Binary files /dev/null and b/target/Commons-1.0-SNAPSHOT-small.jar differ diff --git a/target/Commons-1.0-SNAPSHOT.jar b/target/Commons-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..7a03899 Binary files /dev/null and b/target/Commons-1.0-SNAPSHOT.jar differ diff --git a/target/classes/config.properties b/target/classes/config.properties new file mode 100644 index 0000000..c748b66 --- /dev/null +++ b/target/classes/config.properties @@ -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 diff --git a/target/classes/eu/univento/commons/Commons.class b/target/classes/eu/univento/commons/Commons.class new file mode 100644 index 0000000..cef2133 Binary files /dev/null and b/target/classes/eu/univento/commons/Commons.class differ diff --git a/target/classes/eu/univento/commons/configuration/ConfigurationHandler.class b/target/classes/eu/univento/commons/configuration/ConfigurationHandler.class new file mode 100644 index 0000000..f074f83 Binary files /dev/null and b/target/classes/eu/univento/commons/configuration/ConfigurationHandler.class differ diff --git a/target/classes/eu/univento/commons/database/AsyncMongoDB.class b/target/classes/eu/univento/commons/database/AsyncMongoDB.class new file mode 100644 index 0000000..d23de3e Binary files /dev/null and b/target/classes/eu/univento/commons/database/AsyncMongoDB.class differ diff --git a/target/classes/eu/univento/commons/database/AsyncMySQL.class b/target/classes/eu/univento/commons/database/AsyncMySQL.class new file mode 100644 index 0000000..602b88c Binary files /dev/null and b/target/classes/eu/univento/commons/database/AsyncMySQL.class differ diff --git a/target/classes/eu/univento/commons/database/DatabaseManager.class b/target/classes/eu/univento/commons/database/DatabaseManager.class new file mode 100644 index 0000000..7c6cab7 Binary files /dev/null and b/target/classes/eu/univento/commons/database/DatabaseManager.class differ diff --git a/target/classes/eu/univento/commons/database/MongoDB.class b/target/classes/eu/univento/commons/database/MongoDB.class new file mode 100644 index 0000000..c01098b Binary files /dev/null and b/target/classes/eu/univento/commons/database/MongoDB.class differ diff --git a/target/classes/eu/univento/commons/database/MySQL.class b/target/classes/eu/univento/commons/database/MySQL.class new file mode 100644 index 0000000..f5978d7 Binary files /dev/null and b/target/classes/eu/univento/commons/database/MySQL.class differ diff --git a/target/classes/eu/univento/commons/logging/LoggingHandler.class b/target/classes/eu/univento/commons/logging/LoggingHandler.class new file mode 100644 index 0000000..246c13d Binary files /dev/null and b/target/classes/eu/univento/commons/logging/LoggingHandler.class differ diff --git a/target/classes/eu/univento/commons/player/DatabasePlayer.class b/target/classes/eu/univento/commons/player/DatabasePlayer.class new file mode 100644 index 0000000..42cae8f Binary files /dev/null and b/target/classes/eu/univento/commons/player/DatabasePlayer.class differ diff --git a/target/classes/eu/univento/commons/player/Rank.class b/target/classes/eu/univento/commons/player/Rank.class new file mode 100644 index 0000000..a24862e Binary files /dev/null and b/target/classes/eu/univento/commons/player/Rank.class differ diff --git a/target/classes/eu/univento/commons/player/ban/BanData.class b/target/classes/eu/univento/commons/player/ban/BanData.class new file mode 100644 index 0000000..572ab77 Binary files /dev/null and b/target/classes/eu/univento/commons/player/ban/BanData.class differ diff --git a/target/classes/eu/univento/commons/player/ban/BanReason.class b/target/classes/eu/univento/commons/player/ban/BanReason.class new file mode 100644 index 0000000..90c241c Binary files /dev/null and b/target/classes/eu/univento/commons/player/ban/BanReason.class differ diff --git a/target/classes/eu/univento/commons/player/friend/FriendData.class b/target/classes/eu/univento/commons/player/friend/FriendData.class new file mode 100644 index 0000000..f5ab941 Binary files /dev/null and b/target/classes/eu/univento/commons/player/friend/FriendData.class differ diff --git a/target/classes/eu/univento/commons/player/kick/KickData.class b/target/classes/eu/univento/commons/player/kick/KickData.class new file mode 100644 index 0000000..09e5617 Binary files /dev/null and b/target/classes/eu/univento/commons/player/kick/KickData.class differ diff --git a/target/classes/eu/univento/commons/player/kick/KickReason.class b/target/classes/eu/univento/commons/player/kick/KickReason.class new file mode 100644 index 0000000..83c817e Binary files /dev/null and b/target/classes/eu/univento/commons/player/kick/KickReason.class differ diff --git a/target/classes/eu/univento/commons/player/language/Language.class b/target/classes/eu/univento/commons/player/language/Language.class new file mode 100644 index 0000000..078aa91 Binary files /dev/null and b/target/classes/eu/univento/commons/player/language/Language.class differ diff --git a/target/classes/eu/univento/commons/player/mute/MuteData.class b/target/classes/eu/univento/commons/player/mute/MuteData.class new file mode 100644 index 0000000..9df00db Binary files /dev/null and b/target/classes/eu/univento/commons/player/mute/MuteData.class differ diff --git a/target/classes/eu/univento/commons/player/mute/MuteReason.class b/target/classes/eu/univento/commons/player/mute/MuteReason.class new file mode 100644 index 0000000..36a539b Binary files /dev/null and b/target/classes/eu/univento/commons/player/mute/MuteReason.class differ diff --git a/target/classes/eu/univento/commons/player/profiles/PlayerProfiles.class b/target/classes/eu/univento/commons/player/profiles/PlayerProfiles.class new file mode 100644 index 0000000..d3a1efc Binary files /dev/null and b/target/classes/eu/univento/commons/player/profiles/PlayerProfiles.class differ diff --git a/target/classes/eu/univento/commons/player/profiles/Profile.class b/target/classes/eu/univento/commons/player/profiles/Profile.class new file mode 100644 index 0000000..8855de2 Binary files /dev/null and b/target/classes/eu/univento/commons/player/profiles/Profile.class differ diff --git a/target/classes/eu/univento/commons/player/profiles/Save.class b/target/classes/eu/univento/commons/player/profiles/Save.class new file mode 100644 index 0000000..22a7d95 Binary files /dev/null and b/target/classes/eu/univento/commons/player/profiles/Save.class differ diff --git a/target/classes/eu/univento/commons/player/profiles/StoryItem.class b/target/classes/eu/univento/commons/player/profiles/StoryItem.class new file mode 100644 index 0000000..edc6b8e Binary files /dev/null and b/target/classes/eu/univento/commons/player/profiles/StoryItem.class differ diff --git a/target/classes/eu/univento/commons/player/settings/PlayerSettings.class b/target/classes/eu/univento/commons/player/settings/PlayerSettings.class new file mode 100644 index 0000000..7335bb0 Binary files /dev/null and b/target/classes/eu/univento/commons/player/settings/PlayerSettings.class differ diff --git a/target/classes/eu/univento/commons/player/uuid/NameFetcher.class b/target/classes/eu/univento/commons/player/uuid/NameFetcher.class new file mode 100644 index 0000000..2bb938f Binary files /dev/null and b/target/classes/eu/univento/commons/player/uuid/NameFetcher.class differ diff --git a/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$PlayerProfile.class b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$PlayerProfile.class new file mode 100644 index 0000000..b912961 Binary files /dev/null and b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$PlayerProfile.class differ diff --git a/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$ProfileData.class b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$ProfileData.class new file mode 100644 index 0000000..efca232 Binary files /dev/null and b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$ProfileData.class differ diff --git a/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$SearchResult.class b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$SearchResult.class new file mode 100644 index 0000000..0192e39 Binary files /dev/null and b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher$SearchResult.class differ diff --git a/target/classes/eu/univento/commons/player/uuid/UUIDFetcher.class b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher.class new file mode 100644 index 0000000..e28e4ba Binary files /dev/null and b/target/classes/eu/univento/commons/player/uuid/UUIDFetcher.class differ diff --git a/target/classes/eu/univento/commons/player/warn/WarnData.class b/target/classes/eu/univento/commons/player/warn/WarnData.class new file mode 100644 index 0000000..00b9c66 Binary files /dev/null and b/target/classes/eu/univento/commons/player/warn/WarnData.class differ diff --git a/target/classes/eu/univento/commons/player/warn/WarnReason.class b/target/classes/eu/univento/commons/player/warn/WarnReason.class new file mode 100644 index 0000000..13fc090 Binary files /dev/null and b/target/classes/eu/univento/commons/player/warn/WarnReason.class differ diff --git a/target/classes/eu/univento/commons/security/SecurityHandler.class b/target/classes/eu/univento/commons/security/SecurityHandler.class new file mode 100644 index 0000000..2fa5009 Binary files /dev/null and b/target/classes/eu/univento/commons/security/SecurityHandler.class differ diff --git a/target/classes/eu/univento/commons/server/TPS.class b/target/classes/eu/univento/commons/server/TPS.class new file mode 100644 index 0000000..71c97ec Binary files /dev/null and b/target/classes/eu/univento/commons/server/TPS.class differ diff --git a/target/classes/eu/univento/commons/updater/CustomAuthenicator.class b/target/classes/eu/univento/commons/updater/CustomAuthenicator.class new file mode 100644 index 0000000..230d1a9 Binary files /dev/null and b/target/classes/eu/univento/commons/updater/CustomAuthenicator.class differ diff --git a/target/classes/eu/univento/commons/updater/Updater.class b/target/classes/eu/univento/commons/updater/Updater.class new file mode 100644 index 0000000..43188b4 Binary files /dev/null and b/target/classes/eu/univento/commons/updater/Updater.class differ diff --git a/target/classes/eu/univento/commons/utils/Maths$Atan2.class b/target/classes/eu/univento/commons/utils/Maths$Atan2.class new file mode 100644 index 0000000..04c4379 Binary files /dev/null and b/target/classes/eu/univento/commons/utils/Maths$Atan2.class differ diff --git a/target/classes/eu/univento/commons/utils/Maths$Sin.class b/target/classes/eu/univento/commons/utils/Maths$Sin.class new file mode 100644 index 0000000..dd38f84 Binary files /dev/null and b/target/classes/eu/univento/commons/utils/Maths$Sin.class differ diff --git a/target/classes/eu/univento/commons/utils/Maths.class b/target/classes/eu/univento/commons/utils/Maths.class new file mode 100644 index 0000000..715d310 Binary files /dev/null and b/target/classes/eu/univento/commons/utils/Maths.class differ diff --git a/target/classes/eu/univento/commons/utils/Strings.class b/target/classes/eu/univento/commons/utils/Strings.class new file mode 100644 index 0000000..92baf27 Binary files /dev/null and b/target/classes/eu/univento/commons/utils/Strings.class differ diff --git a/target/classes/language.properties b/target/classes/language.properties new file mode 100644 index 0000000..a37adf2 --- /dev/null +++ b/target/classes/language.properties @@ -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 = diff --git a/target/classes/language_de.properties b/target/classes/language_de.properties new file mode 100644 index 0000000..389f41a --- /dev/null +++ b/target/classes/language_de.properties @@ -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 +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 \ No newline at end of file diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..ba7ab01 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Aug 02 20:03:55 CEST 2016 +version=1.0-SNAPSHOT +groupId=eu.univento +artifactId=Commons diff --git a/target/proguard_map.txt b/target/proguard_map.txt new file mode 100644 index 0000000..92e76e0 --- /dev/null +++ b/target/proguard_map.txt @@ -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 () -> + void shutdown() -> shutdown +eu.univento.commons.configuration.ConfigurationHandler -> eu.univento.commons.a.a: + java.util.Properties properties -> a + void () -> + 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 (java.lang.String,int,java.lang.String,java.lang.String,java.lang.String) -> + void closeConnection() -> a +eu.univento.commons.database.AsyncMySQL -> eu.univento.commons.b.b: + eu.univento.commons.database.MySQL sql -> a + void (java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -> + 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 (eu.univento.commons.Commons) -> + void closeConnections() -> a +eu.univento.commons.database.MongoDB -> eu.univento.commons.b.d: + com.mongodb.MongoClient client -> a + void (java.lang.String,int,java.lang.String,java.lang.String,java.lang.String) -> + void closeConnection() -> a +eu.univento.commons.database.MySQL -> eu.univento.commons.b.e: + com.zaxxer.hikari.HikariDataSource dataSource -> a + void (java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -> + void close() -> a +eu.univento.commons.logging.LoggingHandler -> eu.univento.commons.c.a: + void () -> +eu.univento.commons.security.SecurityHandler -> eu.univento.commons.d.a: + void (eu.univento.commons.Commons) -> diff --git a/target/proguard_seed.txt b/target/proguard_seed.txt new file mode 100644 index 0000000..8b672f6 --- /dev/null +++ b/target/proguard_seed.txt @@ -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()