added Ranking System

This commit is contained in:
Johannes Theiner 2016-09-17 11:55:07 +02:00
parent 5ee9cd550b
commit 1fa03cb94a
25 changed files with 452 additions and 165 deletions

View File

@ -6,27 +6,30 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.8" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-async:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:3.2.2" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb.morphia:morphia:1.2.1" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib-nodep:2.2.2" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.proxytoys:proxytoys:1.0" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.0.36.Final" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
</component>
</module>

82
pom.xml
View File

@ -66,53 +66,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.13</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<includeDependency>true</includeDependency>
<options>
<option>-keep public class eu.univento.commons.Commons { *; }</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
</libs>
<archive>
<manifest>
<mainClass>Commons</mainClass>
<packageName>eu.univento.commons</packageName>
</manifest>
</archive>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
@ -123,6 +85,16 @@
<artifactId>mongodb-driver-async</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
@ -133,26 +105,15 @@
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
@ -172,7 +133,12 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>RELEASE</version>
<version>2.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
</dependencies>
</project>

View File

@ -40,7 +40,6 @@ public class Commons {
public void shutdown() {
getDatabaseManager().closeConnections();
//loggingHandler.shutdown();
}
}

View File

@ -17,6 +17,7 @@ public class DatabaseManager {
public DatabaseManager(Commons commons) {
ConfigurationHandler config = commons.getConfigurationHandler();
//TODO: remove hardcoded variables
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"));

View File

@ -13,20 +13,10 @@ import java.sql.SQLException;
* @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);
@ -38,8 +28,13 @@ public class MySQL {
dataSource = new HikariDataSource(config);
}
void close() {
public void close() {
try {
dataSource.getConnection().close();
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public HikariDataSource getDataSource() {

View File

@ -0,0 +1,48 @@
package eu.univento.commons.helpers;
/**
* @author joethei
* @version 0.1
*/
public class Location {
private final String world;
private final double x;
private final double y;
private final double z;
private final float pitch;
private final float yaw;
public Location(String world, double x, double y, double z, float pitch, float yaw) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.pitch = pitch;
this.yaw = yaw;
}
public String getWorld() {
return world;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public float getPitch() {
return pitch;
}
public float getYaw() {
return yaw;
}
}

View File

@ -35,8 +35,4 @@ public class LoggingHandler {
public LoggingHandler() {
}
public void shutdown() {
LogManager.shutdown();
}
}

View File

@ -8,12 +8,14 @@ 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.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.mute.MuteData;
import eu.univento.commons.player.mute.MuteReason;
import eu.univento.commons.player.profiles.Profile;
import eu.univento.commons.player.ranking.PlayerRanking;
import eu.univento.commons.player.settings.PlayerSettings;
import eu.univento.commons.player.warn.WarnData;
import eu.univento.commons.player.warn.WarnReason;
@ -29,10 +31,10 @@ import java.util.stream.Collectors;
public class DatabasePlayer {
private UUID uuid;
private Commons commons;
private final MongoDB mongoDB;
private final PlayerSettings settings;
private final PlayerRanking ranking;
private final HackData hackData;
private final MongoCollection<Document> playerCollection;
private final MongoCollection<Document> friendCollection;
@ -44,11 +46,12 @@ public class DatabasePlayer {
private final MongoCollection<Document> profileCollection;
public DatabasePlayer(Commons commons, UUID uuid) {
this.commons = commons;
this.uuid = uuid;
settings = new PlayerSettings(this);
ranking = new PlayerRanking(this);
hackData = new HackData(this);
this.mongoDB = commons.getDatabaseManager().getMongoDB();
MongoDB mongoDB = commons.getDatabaseManager().getMongoDB();
playerCollection = mongoDB.getDatabase().getCollection("players");
friendCollection = mongoDB.getDatabase().getCollection("friends");
onlinePlayerCollection = mongoDB.getDatabase().getCollection("online-players");
@ -95,6 +98,14 @@ public class DatabasePlayer {
return profileCollection;
}
public PlayerRanking getPlayerRanking() {
return ranking;
}
public HackData getHackData() {
return hackData;
}
public Collection<Profile> getProfiles() {
ArrayList<String> list = getArrayListFromDatabase("profiles");
return list.stream().map(id -> new Profile(this, id)).collect(Collectors.toCollection(LinkedList::new));
@ -118,9 +129,9 @@ public class DatabasePlayer {
}
public BanData getBan() {
if(!isBanned()) return null;
FindIterable<Document> cursor = banCollection.find(new Document("uuid", uuid.toString()));
cursor.cursorType(CursorType.NonTailable);
if(cursor.first() == null) return null;
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"));
}
@ -192,9 +203,13 @@ public class DatabasePlayer {
}
public void mute(UUID muter, MuteReason reason) {
int i = 0;
if(getAllBans().size() > 1) {
for (MuteData mute : getAllMutes()) i =+ mute.getReason().getValue();
}
Document doc = new Document("uuid", uuid.toString());
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, reason.getTime());
calendar.add(Calendar.DAY_OF_YEAR, reason.getValue() + i);
doc.put("reason", reason.name());
doc.put("muter", muter.toString());
doc.put("date", calendar.getTime());

View File

@ -6,21 +6,21 @@ package eu.univento.commons.player;
*/
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 | "),
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"),
Premium(2, 156, 6, "§6", "§6", " §8»§7 ", "o", "§6"),
Player(1, 164, 2, "§7", "§7", " §8»§7 ", "p", "§7");
private final int value;

View File

@ -54,6 +54,8 @@ public class BanData {
}
public String getBannerName() {
if(banner == null)
return "Auto Ban";
return NameFetcher.getRequest(banner);
}

View File

@ -6,26 +6,23 @@ package eu.univento.commons.player.ban;
*/
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);
HACK_CRITICALS("Ban.Reason.Hack.Criticals", 10),
HACK_AUTOCLICKER("Ban.Reason.Hack.Autoclicker", 10),
HACK_GLIDE("Ban.Reason.Hack.Glide", 10),
HACK_REACH("Ban.Reason.Hack.Reach", 10),
HACK_NOSLOWDOWN("Ban.Reason.Hack.NoSlowDown", 10),
HACK_REGEN("Ban.Reason.Hack.Regen", 10),
HACK_AUTORESPAWN("Ban.Reason.Hack.AutoRespawn", 10),
HACK_FASTPLACE("Ban.Reason.Hack.FastPlace", 10),
HACK_KILLAURA("Ban.Reason.Hack.KillAura", 10),
HACK_FLY("Ban.Reason.Hack.Fly", 10),
HACK_WDL("Ban.Reason.Hack.WDL", 10),
GRIEFING("Ban.Reason.Griefing", 10),
BUGUSING("Ban.Reason.Bugusing", 10),
HACKED_ACCOUNT("Ban.Reason.Hacked_Account", 10),
TO_MANY_WARNS("Ban.Reason.Warns", 10),
TO_MANY_MUTES("Ban.Reason.Mutes", 10),
CUSTOM("Ban.Reason.Custom", 10);
private final String name;
private final int value;

View File

@ -0,0 +1,196 @@
package eu.univento.commons.player.hacks;
import eu.univento.commons.helpers.Location;
import eu.univento.commons.player.DatabasePlayer;
/**
* @author joethei
* @version 0.1
*/
public class HackData {
private DatabasePlayer player;
private Location lastLocation;
private Location realLocation;
private boolean lastHealth;
private long lastPlacedBlock;
private long lastBow;
private long lastRegen;
private long lastAnimation;
private long lastForcefield;
private long lastY;
private long highestY;
private boolean ascending;
private boolean descending;
private Location lastBlockLocation;
private double blocksMoved;
private int fakePlayer;
private long lastTimeFakePlayerAttack;
private long lastFood;
private long lastInventory;
private long lastNotification;
public HackData(DatabasePlayer player) {
this.player = player;
}
public DatabasePlayer getPlayer() {
return player;
}
public void setPlayer(DatabasePlayer player) {
this.player = player;
}
public Location getLastLocation() {
return lastLocation;
}
public void setLastLocation(Location lastLocation) {
this.lastLocation = lastLocation;
}
public Location getRealLocation() {
return realLocation;
}
public void setRealLocation(Location realLocation) {
this.realLocation = realLocation;
}
public boolean isLastHealth() {
return lastHealth;
}
public void setLastHealth(boolean lastHealth) {
this.lastHealth = lastHealth;
}
public long getLastPlacedBlock() {
return lastPlacedBlock;
}
public void setLastPlacedBlock(long lastPlacedBlock) {
this.lastPlacedBlock = lastPlacedBlock;
}
public long getLastBow() {
return lastBow;
}
public void setLastBow(long lastBow) {
this.lastBow = lastBow;
}
public long getLastRegen() {
return lastRegen;
}
public void setLastRegen(long lastRegen) {
this.lastRegen = lastRegen;
}
public long getLastAnimation() {
return lastAnimation;
}
public void setLastAnimation(long lastAnimation) {
this.lastAnimation = lastAnimation;
}
public long getLastForcefield() {
return lastForcefield;
}
public void setLastForcefield(long lastForcefield) {
this.lastForcefield = lastForcefield;
}
public long getLastY() {
return lastY;
}
public void setLastY(long lastY) {
this.lastY = lastY;
}
public long getHighestY() {
return highestY;
}
public void setHighestY(long highestY) {
this.highestY = highestY;
}
public boolean isAscending() {
return ascending;
}
public void setAscending(boolean ascending) {
this.ascending = ascending;
}
public boolean isDescending() {
return descending;
}
public void setDescending(boolean descending) {
this.descending = descending;
}
public Location getLastBlockLocation() {
return lastBlockLocation;
}
public void setLastBlockLocation(Location lastBlockLocation) {
this.lastBlockLocation = lastBlockLocation;
}
public double getBlocksMoved() {
return blocksMoved;
}
public void setBlocksMoved(double blocksMoved) {
this.blocksMoved = blocksMoved;
}
public int getFakePlayer() {
return fakePlayer;
}
public void setFakePlayer(int fakePlayer) {
this.fakePlayer = fakePlayer;
}
public long getLastTimeFakePlayerAttack() {
return lastTimeFakePlayerAttack;
}
public void setLastTimeFakePlayerAttack(long lastTimeFakePlayerAttack) {
this.lastTimeFakePlayerAttack = lastTimeFakePlayerAttack;
}
public long getLastFood() {
return lastFood;
}
public void setLastFood(long lastFood) {
this.lastFood = lastFood;
}
public long getLastInventory() {
return lastInventory;
}
public void setLastInventory(long lastInventory) {
this.lastInventory = lastInventory;
}
public long getLastNotification() {
return lastNotification;
}
public void setLastNotification(long lastNotification) {
this.lastNotification = lastNotification;
}
}

View File

@ -34,6 +34,8 @@ public class KickData {
}
public String getKickerName() {
if(kicker == null)
return "Auto Kick";
return NameFetcher.getRequest(kicker);
}
}

View File

@ -12,6 +12,7 @@ public enum KickReason {
private int points;
KickReason(String name, int points) {
this.name = name;
this.points = points;
}

View File

@ -1,6 +1,10 @@
package eu.univento.commons.player.mute;
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;
@ -40,6 +44,29 @@ public class MuteData {
}
public String getMuterName() {
if(muter == null)
return "Auto Mute";
return NameFetcher.getRequest(muter);
}
public String getTimeTillUnmute() {
assert getDate() != null;
final DateTime end = new DateTime(getDate().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);
}
}

View File

@ -6,21 +6,28 @@ package eu.univento.commons.player.mute;
*/
public enum MuteReason {
SPAM("Spam", 30);
SPAM("Mute.Reason.Spam", 1),
ADVERTISMENT("Mute.Reason.Advertisement", 3),
RASISM("Mute.Reason.Rasim", 5),
SEXISM("Mute.Reason.Sexism", 1),
THREAT("Mute.Reason.Threat", 30),
INSULT("Mute.Reason.Insult", 1),
WORD_CHOICE("Mute.Reason.Word_Choice", 1);
private String name;
private int time;
private int value;
MuteReason(String name, int time) {
MuteReason(String name, int value) {
this.name = name;
this.time = time;
this.value = value;
}
public String getName() {
return name;
}
public int getTime() {
return time;
public int getValue() {
return value;
}
}

View File

@ -1,24 +0,0 @@
package eu.univento.commons.player.profiles;
import com.mongodb.client.MongoCollection;
import eu.univento.commons.player.DatabasePlayer;
import org.bson.Document;
import java.util.UUID;
/**
* @author joethei
* @version 0.1
*/
public class PlayerProfiles {
private UUID uuid;
private final MongoCollection<Document> collection;
public PlayerProfiles(DatabasePlayer player) {
this.uuid = player.getUuid();
this.collection = player.getProfileCollection();
}
}

View File

@ -24,6 +24,7 @@ public class Profile {
private Collection<StoryItem> items;
public Profile(DatabasePlayer player, String id) {
this.player = player;
this.id = id;
FindIterable<Document> cursor = player.getProfileCollection().find(new Document("_id", id));
cursor.cursorType(CursorType.NonTailable);

View File

@ -0,0 +1,20 @@
package eu.univento.commons.player.ranking;
import eu.univento.commons.player.DatabasePlayer;
/**
* @author joethei
* @version 0.1
*/
public class PlayerRanking {
private final DatabasePlayer player;
public PlayerRanking(DatabasePlayer player){
this.player = player;
}
public Ranking getRanking() {
return Ranking.getRanking(player.getIntegerFromDatabase("ranking"));
}
}

View File

@ -0,0 +1,41 @@
package eu.univento.commons.player.ranking;
/**
* @author joethei
* @version 0.1
*/
public enum Ranking {
SILVER_1("Silver 1", 2, 5);
private String name;
private int min;
private int max;
Ranking(String name, int min, int max) {
this.name = name;
this.min = min;
this.max = max;
}
public String getName() {
return name;
}
public int getMin() {
return min;
}
public int getMax() {
return max;
}
public static Ranking getRanking(int ranking) {
for(Ranking rank : values()) {
if(rank.getMax() > ranking && rank.getMin() < ranking) {
return rank;
}
}
return null;
}
}

View File

@ -40,10 +40,8 @@ public class WarnData {
}
public String getWarnerName() {
if(warner == null) {
if(warner == null)
return "Auto Warn";
}else {
return NameFetcher.getRequest(warner);
}
}
}

View File

@ -1,7 +1,6 @@
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;
@ -19,8 +18,7 @@ public class SecurityHandler {
}
public void isValidServer(String ip, Consumer<Boolean> consumer) {
AsyncMySQL sql = commons.getDatabaseManager().getAsyncMySQL();
sql.query("SELECT * FROM Servers WHERE ip='" + ip + "';", resultSet -> {
commons.getDatabaseManager().getAsyncMySQL().query("SELECT * FROM Servers WHERE ip='" + ip + "';", resultSet -> {
try {
consumer.accept(resultSet.next());
} catch (SQLException e) {

View File

@ -7,18 +7,17 @@ import java.net.PasswordAuthentication;
* @author joethei
* @version 0.1
*/
public class CustomAuthenicator extends Authenticator{
public class CustomAuthenticator extends Authenticator{
private static String username = "";
private static String password = "";
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication (username,
password.toCharArray());
return new PasswordAuthentication (username, password.toCharArray());
}
public static void setPasswordAuthentication(String username, String password) {
CustomAuthenicator.username = username;
CustomAuthenicator.password = password;
CustomAuthenticator.username = username;
CustomAuthenticator.password = password;
}
}

View File

@ -11,8 +11,7 @@ import java.util.regex.Pattern;
* @version 1.5
*/
final class Maths
{
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;

View File

@ -13,7 +13,7 @@ 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_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