added new antihack module nuker.
added a DatabaseManager. added custom two Entity. changed ranking system.
This commit is contained in:
parent
a2b3db58dd
commit
ce5072fff2
11
Core.iml
11
Core.iml
|
@ -12,23 +12,24 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.10-R0.1-SNAPSHOT" 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" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.10-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.9-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
|
||||
</component>
|
||||
</module>
|
23
pom.xml
23
pom.xml
|
@ -59,14 +59,14 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -85,17 +85,22 @@
|
|||
<artifactId>netty-all</artifactId>
|
||||
<version>4.0.36.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.4.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,10 @@
|
|||
package eu.univento.cloud.client;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 08.07.2016
|
||||
*/
|
||||
public class CloudManager {
|
||||
|
||||
}
|
|
@ -5,6 +5,8 @@ import eu.univento.core.api.player.CustomPlayer;
|
|||
|
||||
public class CloudMessenger {
|
||||
|
||||
|
||||
|
||||
public static void sendModModeMessage(ModModePrefix prefix, String message) {
|
||||
//TODO: add stuff + server
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.univento.core;
|
|||
import eu.univento.core.antihack.AntiHack;
|
||||
import eu.univento.core.api.Blackscreen;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.database.DatabaseManager;
|
||||
import eu.univento.core.api.database.MongoDB;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import eu.univento.core.api.events.MoveEventFilter;
|
||||
|
@ -45,22 +46,37 @@ public class Core extends JavaPlugin{
|
|||
/**
|
||||
* mysql stuff
|
||||
*/
|
||||
private static MySQL sql = new MySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
||||
private static MySQL sql = new MySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
||||
/**
|
||||
* @return sql
|
||||
*/
|
||||
public static MySQL returnSQL() {
|
||||
public static MySQL getMySQL() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
/*
|
||||
private static AsyncMySQL asyncMySQL = new AsyncMySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
||||
public static AsyncMySQL getAsyncMySQL() {
|
||||
return asyncMySQL;
|
||||
}
|
||||
*/
|
||||
private static MongoDB mongoDB;
|
||||
public static MongoDB getMongoDB() {
|
||||
return mongoDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* logging and stuff
|
||||
*/
|
||||
/*
|
||||
private static AsyncMongoDB asyncMongoDB;
|
||||
public static AsyncMongoDB getAsyncMongoDB() {
|
||||
return asyncMongoDB;
|
||||
}
|
||||
*/
|
||||
|
||||
private static DatabaseManager databaseManager;
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
return databaseManager;
|
||||
}
|
||||
|
||||
private static Logger log = Bukkit.getLogger();
|
||||
|
||||
public static ArrayList<CustomPlayer> getOnlinePlayers() {
|
||||
|
@ -101,7 +117,6 @@ public class Core extends JavaPlugin{
|
|||
|
||||
if(ServerSettings.isGame()) {
|
||||
new Fix(this, "fix", "fix");
|
||||
new Stats(this, "stats", "statistics");
|
||||
new Nick(this, "nick", "nick");
|
||||
}
|
||||
AntiHack.registerListeners();
|
||||
|
@ -130,8 +145,9 @@ public class Core extends JavaPlugin{
|
|||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "schematica");
|
||||
|
||||
Blackscreen.setupUtil(getInstance());
|
||||
databaseManager = new DatabaseManager(getInstance());
|
||||
mongoDB = new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
|
||||
|
||||
//asyncMongoDB = new AsyncMongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
|
||||
log(Level.INFO, "\n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
|
@ -176,6 +192,7 @@ public class Core extends JavaPlugin{
|
|||
@Override
|
||||
public void onDisable() {
|
||||
mongoDB.getClient().close();
|
||||
databaseManager.closeConnections();
|
||||
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().unregisterIncomingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, "LABYMOD");
|
||||
|
|
|
@ -12,7 +12,8 @@ public enum Hack {
|
|||
FASTPLACE(10),
|
||||
KILLAURA(10),
|
||||
FLY(10),
|
||||
WDL(10);
|
||||
WDL(10),
|
||||
NUKER(10);
|
||||
|
||||
private int id;
|
||||
private Hack(int id) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package eu.univento.core.antihack.modules;
|
||||
|
||||
import eu.univento.cloud.client.CloudMessenger;
|
||||
import eu.univento.core.antihack.Hack;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 01.07.2016
|
||||
*/
|
||||
public class Nuker implements Listener {
|
||||
|
||||
private LinkedHashMap<CustomPlayer, Long> last = new LinkedHashMap<>();
|
||||
private LinkedHashMap<CustomPlayer, Integer> blocks = new LinkedHashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
|
||||
if(last.get(p) != null && last.get(p) + 50000L >= System.currentTimeMillis()) {
|
||||
last.put(p, System.currentTimeMillis());
|
||||
blocks.put(p, blocks.get(p) + 1);
|
||||
if(blocks.get(p) > 80) {
|
||||
e.setCancelled(true);
|
||||
CloudMessenger.sendHackMessage(Hack.NUKER, p);
|
||||
p.warn(Hack.NUKER);
|
||||
}
|
||||
}else{
|
||||
blocks.put(p, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package eu.univento.core.api.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 eu.univento.core.api.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AsyncMongoDB {
|
||||
|
||||
private MongoClient client;
|
||||
private MongoDatabase database;
|
||||
|
||||
public AsyncMongoDB(String host, int port, String username, String password, String database) {
|
||||
List<ServerAddress> addressList = new ArrayList<>();
|
||||
addressList.add(new ServerAddress(host, port));
|
||||
List<MongoCredential> credentials = new ArrayList<>();
|
||||
credentials.add(MongoCredential.createCredential(username, database, password.toCharArray()));
|
||||
ClusterSettings clusterSettings = ClusterSettings.builder().hosts(addressList).build();
|
||||
MongoClientSettings settings = MongoClientSettings.builder().clusterSettings(clusterSettings).credentialList(credentials).build();
|
||||
client = MongoClients.create(settings);
|
||||
}
|
||||
|
||||
public MongoClient getClient() {
|
||||
if(client == null)
|
||||
new AsyncMongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
|
||||
return client;
|
||||
}
|
||||
|
||||
public MongoDatabase getDatabase() {
|
||||
if(database == null)
|
||||
database = getClient().getDatabase(Config.readString("MongoDB.Database"));
|
||||
return database;
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
if(client != null)
|
||||
client.close();
|
||||
}
|
||||
}
|
|
@ -17,9 +17,9 @@ public class AsyncMySQL {
|
|||
private Plugin plugin;
|
||||
private MySQL sql;
|
||||
|
||||
public AsyncMySQL(Plugin owner, String host, int port, String user, String password, String database) {
|
||||
public AsyncMySQL(Plugin owner, String host, String port, String user, String password, String database) {
|
||||
try {
|
||||
sql = new MySQL(host, port, user, password, database);
|
||||
sql = new MySQL(owner, host, port, user, password, database);
|
||||
executor = Executors.newCachedThreadPool();
|
||||
plugin = owner;
|
||||
} catch (Exception e) {
|
||||
|
@ -27,127 +27,30 @@ public class AsyncMySQL {
|
|||
}
|
||||
}
|
||||
|
||||
public void update(PreparedStatement statement) {
|
||||
executor.execute(() -> sql.queryUpdate(statement));
|
||||
}
|
||||
|
||||
public void update(String statement) {
|
||||
executor.execute(() -> sql.queryUpdate(statement));
|
||||
}
|
||||
|
||||
public void query(PreparedStatement statement, Consumer<ResultSet> consumer) {
|
||||
public void update(String update) {
|
||||
executor.execute(() -> {
|
||||
ResultSet result = sql.query(statement);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(result));
|
||||
try {
|
||||
sql.query(update);
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void query(String statement, Consumer<ResultSet> consumer) {
|
||||
public void query(String query, Consumer<ResultSet> consumer) {
|
||||
executor.execute(() -> {
|
||||
ResultSet result = sql.query(statement);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(result));
|
||||
ResultSet result = null;
|
||||
try {
|
||||
result = sql.query(query);
|
||||
ResultSet finalResult = result;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(finalResult));
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PreparedStatement prepare(String query) {
|
||||
try {
|
||||
return sql.getConnection().prepareStatement(query);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public static class MySQL {
|
||||
|
||||
private String host, user, password, database;
|
||||
private int port;
|
||||
|
||||
private Connection conn;
|
||||
|
||||
public MySQL(String host, int port, String user, String password, String database) throws Exception {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.database = database;
|
||||
|
||||
this.openConnection();
|
||||
}
|
||||
|
||||
public void queryUpdate(String query) {
|
||||
checkConnection();
|
||||
try (PreparedStatement statement = conn.prepareStatement(query)) {
|
||||
queryUpdate(statement);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void queryUpdate(PreparedStatement statement) {
|
||||
checkConnection();
|
||||
try {
|
||||
statement.executeUpdate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet query(String query) {
|
||||
checkConnection();
|
||||
try {
|
||||
return query(conn.prepareStatement(query));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResultSet query(PreparedStatement statement) {
|
||||
checkConnection();
|
||||
try {
|
||||
return statement.executeQuery();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return this.conn;
|
||||
}
|
||||
|
||||
private void checkConnection() {
|
||||
try {
|
||||
if (this.conn == null || !this.conn.isValid(10) || this.conn.isClosed()) openConnection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Connection openConnection() throws Exception {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
return this.conn = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.user, this.password);
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
try {
|
||||
this.conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
this.conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,7 @@ package eu.univento.core.api.database;
|
|||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
|
||||
public abstract class Database {
|
||||
protected Connection connection;
|
||||
|
@ -37,29 +34,25 @@ public abstract class Database {
|
|||
return true;
|
||||
}
|
||||
|
||||
public ResultSet querySQL(String query)
|
||||
public ResultSet query(String query)
|
||||
throws SQLException, ClassNotFoundException {
|
||||
if (!checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
|
||||
Statement statement = this.connection.createStatement();
|
||||
PreparedStatement statement = this.connection.prepareStatement(query);
|
||||
|
||||
ResultSet result = statement.executeQuery(query);
|
||||
|
||||
return result;
|
||||
return statement.executeQuery();
|
||||
}
|
||||
|
||||
public int updateSQL(String query)
|
||||
public int update(String query)
|
||||
throws SQLException, ClassNotFoundException {
|
||||
if (!checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
|
||||
Statement statement = this.connection.createStatement();
|
||||
PreparedStatement statement = this.connection.prepareStatement(query);
|
||||
|
||||
int result = statement.executeUpdate(query);
|
||||
|
||||
return result;
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package eu.univento.core.api.database;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 03.07.2016
|
||||
*/
|
||||
public class DatabaseManager {
|
||||
|
||||
private static AsyncMongoDB asyncMongoDB;
|
||||
private static MongoDB mongoDB;
|
||||
private static AsyncMySQL asyncMySQL;
|
||||
private static MySQL mysql;
|
||||
|
||||
public DatabaseManager(Plugin plugin) {
|
||||
asyncMongoDB = new AsyncMongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
|
||||
mongoDB = new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
|
||||
mysql = new MySQL(plugin, Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
||||
asyncMySQL = new AsyncMySQL(plugin, Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
||||
}
|
||||
|
||||
public void closeConnections() {
|
||||
asyncMongoDB.closeConnection();
|
||||
mongoDB.closeConnection();
|
||||
try {
|
||||
mysql.closeConnection();
|
||||
asyncMySQL.getMySQL().closeConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public AsyncMongoDB getAsyncMongoDB() {
|
||||
return asyncMongoDB;
|
||||
}
|
||||
|
||||
public MongoDB getMongoDB() {
|
||||
return mongoDB;
|
||||
}
|
||||
|
||||
public MySQL getMySQL() {
|
||||
return mysql;
|
||||
}
|
||||
|
||||
public AsyncMySQL getAsyncMySQL() {
|
||||
return asyncMySQL;
|
||||
}
|
||||
}
|
|
@ -6,31 +6,27 @@ import java.sql.Connection;
|
|||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MySQL extends Database
|
||||
{
|
||||
private final String user;
|
||||
private final String database;
|
||||
private final String password;
|
||||
private final String port;
|
||||
private final String hostname;
|
||||
public class MySQL extends Database {
|
||||
private final String user;
|
||||
private final String database;
|
||||
private final String password;
|
||||
private final String port;
|
||||
private final String hostname;
|
||||
|
||||
public MySQL(Plugin plugin, String hostname, String port, String database, String username, String password) {
|
||||
super(plugin);
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.database = database;
|
||||
this.user = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Connection openConnection() throws SQLException, ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
return this.connection;
|
||||
public MySQL(Plugin plugin, String hostname, String port, String database, String username, String password) {
|
||||
super(plugin);
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.database = database;
|
||||
this.user = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Connection openConnection() throws SQLException, ClassNotFoundException {
|
||||
if (checkConnection())
|
||||
return this.connection;
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
|
||||
return this.connection;
|
||||
}
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
this.connection = DriverManager.getConnection("jdbc:mysql://" +
|
||||
this.hostname + ":" + this.port + "/" + this.database,
|
||||
this.user, this.password);
|
||||
return this.connection;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package eu.univento.core.api.effects;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.PlayerSettings;
|
||||
import eu.univento.core.Core;
|
||||
import net.minecraft.server.v1_10_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles;
|
||||
import org.bukkit.Location;
|
||||
|
@ -24,9 +23,7 @@ public class Effects {
|
|||
*/
|
||||
public static void playEffect(Location loc, EnumParticle ep, float f, int count) {
|
||||
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(ep, true, (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), f, f, f, 0.0F, count, 0, 0);
|
||||
for(CustomPlayer p : PlayerSettings.getAllPlayersWithEffectsEnabled()) {
|
||||
p.getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
Core.getOnlinePlayers().stream().filter(p -> p.hasEffects()).forEach(p -> p.getHandle().playerConnection.sendPacket(packet));
|
||||
}
|
||||
|
||||
public static void playEffectToPlayer(Player p, Location loc, EnumParticle ep, float f, int count) {
|
||||
|
|
|
@ -0,0 +1,377 @@
|
|||
package eu.univento.core.api.items;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* NOTICE: This utility was developer as part of AeolusLib. While you can use it for your own projects, You are NOT allowed to delete or move this header comment.
|
||||
*
|
||||
* Utility:
|
||||
* Chainable {@link ItemStack}s
|
||||
*
|
||||
* Example Usage(s):
|
||||
* {@code ItemStack itemStack = new ItemBuilder(Material.SKULL_ITEM).amount(1).durability(3).skullOwner("MCAeolus").name(ChatColor.RED+"MCAeolus's Skull").make())}
|
||||
* {@code ItemStack itemStack = new ItemBuilder().type(Material.BEDROCK).lores(new String[]{"Lore1",ChatColor.RED+"Lore2"}).enchantment(Enchantment.DAMAGE_ALL, 99).make()}
|
||||
*
|
||||
* @author MCAeolus, joethei
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
public class ItemBuilder {
|
||||
|
||||
private final ItemStack item;
|
||||
private final ItemMeta itemM;
|
||||
|
||||
/**
|
||||
* Init item chainable via given Material parameter.
|
||||
*
|
||||
* @param itemType
|
||||
* the {@link Material} to initiate the instance with.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder(final Material itemType){
|
||||
item = new ItemStack(itemType);
|
||||
itemM = item.getItemMeta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init item chainable via given ItemStack parameter.
|
||||
*
|
||||
* @param itemStack
|
||||
* the {@link ItemStack} to initialize the instance with.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder(final ItemStack itemStack){
|
||||
item = itemStack;
|
||||
itemM = item.getItemMeta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the item chainable with no defined Material/ItemStack
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder(){
|
||||
item = new ItemStack(Material.AIR);
|
||||
itemM = item.getItemMeta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the Material type of the {@link ItemStack}
|
||||
*
|
||||
* @param material
|
||||
* the new {@link Material} to set for the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder type(final Material material){
|
||||
make().setType(material);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the {@link ItemStack}s size.
|
||||
*
|
||||
* @param itemAmt
|
||||
* the new Integer count of the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder amount(final Integer itemAmt){
|
||||
make().setAmount(itemAmt);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the {@link ItemStack}s display name.
|
||||
*
|
||||
* @param name
|
||||
* the new String for the ItemStack's display name to be set to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder name(final String name){
|
||||
meta().setDisplayName(name);
|
||||
make().setItemMeta(meta());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a line of lore to the {@link ItemStack}
|
||||
*
|
||||
* @param lore
|
||||
* String you want to add to the ItemStack's lore.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder lore(final String lore){
|
||||
List<String> lores = meta().getLore();
|
||||
if(lores == null){lores = new ArrayList<>();}
|
||||
lores.add(lore);
|
||||
meta().setLore(lores);
|
||||
make().setItemMeta(meta());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the {@link ItemStack}s lore and replaces it with the defined String array.
|
||||
*
|
||||
* @param lores
|
||||
* String array you want to set the ItemStack's lore to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder lores(final String[] lores){
|
||||
List<String> loresList = meta().getLore();
|
||||
if(loresList == null){loresList = new ArrayList<>();}
|
||||
else{loresList.clear();}
|
||||
Collections.addAll(loresList, lores);
|
||||
meta().setLore(loresList);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the durability of the current {@link ItemStack}
|
||||
*
|
||||
* @param durability
|
||||
* the new int amount to set the ItemStack's durability to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder durability(final int durability){
|
||||
make().setDurability((short) durability);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the data value of the {@link ItemStack}
|
||||
*
|
||||
* @param data
|
||||
* the new int data value (parsed as byte) to set the ItemStack's durability to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder data(final int data){
|
||||
make().setData(new MaterialData(make().getType(), (byte)data));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds and UnsafeEnchantment to the {@link ItemStack} with a defined level int value.
|
||||
*
|
||||
* @param enchantment
|
||||
* the {@link Enchantment} to add to the ItemStack.
|
||||
*
|
||||
* @param level
|
||||
* the int amount that the Enchantment's level will be set to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder enchantment(final Enchantment enchantment, final int level){
|
||||
make().addUnsafeEnchantment(enchantment, level);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds and UnsafeEnchantment to the {@Link} with a level int value of 1.
|
||||
*
|
||||
* @param enchantment
|
||||
* the {@link Enchantment} to add to the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder enchantment(final Enchantment enchantment){
|
||||
make().addUnsafeEnchantment(enchantment, 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all {@link Enchantment}s from the current {@link ItemStack} then adds the defined array of Enchantments to the ItemStack.
|
||||
*
|
||||
* @param enchantments
|
||||
* the Enchantment array to replace any current enchantments applied on the ItemStack.
|
||||
*
|
||||
* @param level
|
||||
* the int level value for all Enchantments to be set to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder enchantments(final Enchantment[] enchantments, final int level){
|
||||
make().getEnchantments().clear();
|
||||
for(Enchantment enchantment : enchantments){
|
||||
make().addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all {@link Enchantment}s from the current {@link ItemStack} then adds the defined array of Enchantments to the ItemStack with a level int value of 1.
|
||||
*
|
||||
* @param enchantments
|
||||
* the Enchantment array to replace any current enchantments applied on the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder enchantments(final Enchantment[] enchantments){
|
||||
make().getEnchantments().clear();
|
||||
for(Enchantment enchantment : enchantments){
|
||||
make().addUnsafeEnchantment(enchantment, 1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the defined {@link Enchantment} from the {@link ItemStack}
|
||||
*
|
||||
* @param enchantment
|
||||
* the Enchantment to remove from the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder clearEnchantment(final Enchantment enchantment){
|
||||
Map<Enchantment, Integer> itemEnchantments = make().getEnchantments();
|
||||
itemEnchantments.keySet().stream().filter(enchantmentC -> enchantment == enchantmentC).forEach(itemEnchantments::remove);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all {@link Enchantment}s from the {@link ItemStack}
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder clearEnchantments(){
|
||||
make().getEnchantments().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the defined {@link String} of lore from the {@link ItemStack}
|
||||
*
|
||||
* @param lore
|
||||
* the String to be removed from the ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder clearLore(final String lore){
|
||||
if(meta().getLore().contains(lore)){
|
||||
meta().getLore().remove(lore);
|
||||
}
|
||||
make().setItemMeta(meta());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all lore {@link String}s from the {@link ItemStack}
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder clearLores(){
|
||||
meta().getLore().clear();
|
||||
make().setItemMeta(meta());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Color} of any LEATHER_ARMOR {@link Material} types of the {@link ItemStack}
|
||||
*
|
||||
* @param color
|
||||
* the Color to set the LEATHER_ARMOR ItemStack to.
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder color(final Color color){
|
||||
if(make().getType() == Material.LEATHER_HELMET
|
||||
|| make().getType() == Material.LEATHER_CHESTPLATE
|
||||
|| make().getType() == Material.LEATHER_LEGGINGS
|
||||
|| make().getType() == Material.LEATHER_BOOTS ){
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) meta();
|
||||
meta.setColor(color);
|
||||
make().setItemMeta(meta);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the {@link Color} of any LEATHER_ARMOR {@link Material} types of the {@link ItemStack}
|
||||
*
|
||||
* @return the current instance for chainable application.
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder clearColor(){
|
||||
if(make().getType() == Material.LEATHER_HELMET
|
||||
|| make().getType() == Material.LEATHER_CHESTPLATE
|
||||
|| make().getType() == Material.LEATHER_LEGGINGS
|
||||
|| make().getType() == Material.LEATHER_BOOTS ){
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) meta();
|
||||
meta.setColor(null);
|
||||
make().setItemMeta(meta);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the skullOwner {@link SkullMeta} of the current SKULL_ITEM {@link Material} type {@link ItemStack}
|
||||
*
|
||||
* @param name
|
||||
* the {@link String} value to set the SkullOwner meta to for the SKULL_ITEM Material type ItemStack.
|
||||
*
|
||||
* @return the current instance for chainable application
|
||||
* @since 1.0
|
||||
*/
|
||||
public ItemBuilder skullOwner(final String name){
|
||||
if(make().getType() == Material.SKULL_ITEM && make().getDurability() == (byte) 3){
|
||||
SkullMeta skullMeta = (SkullMeta) meta();
|
||||
skullMeta.setOwner(name);
|
||||
make().setItemMeta(meta());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ItemMeta} of the {@link ItemStack}
|
||||
*
|
||||
* @return the ItemMeta of the ItemStack.
|
||||
*/
|
||||
public ItemMeta meta(){
|
||||
return itemM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ItemStack} of the {@link ItemBuilder} instance.
|
||||
*
|
||||
* @return the ItemStack of the ItemBuilder instance.
|
||||
*/
|
||||
public ItemStack make(){
|
||||
item.getItemMeta().addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_UNBREAKABLE, ItemFlag.HIDE_ENCHANTS);
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,11 +8,10 @@ import java.util.ResourceBundle;
|
|||
public class Language {
|
||||
|
||||
|
||||
private Map<String, Locale> languages;
|
||||
private ResourceBundle translation;
|
||||
|
||||
public Language(String language) {
|
||||
languages = new HashMap<>();
|
||||
Map<String, Locale> languages = new HashMap<>();
|
||||
languages.put("DE", Locale.GERMAN);
|
||||
languages.put("EN", Locale.ENGLISH);
|
||||
languages.put("IT", Locale.ITALY);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.languages;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
|
@ -141,7 +141,7 @@ class Language_DE implements Languages{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Rank rank) {
|
||||
return "§7Du hast dem Spieler " + p.getDisplayName() + " auf §e" + rank.toString() + " §7gesetzt";
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.languages;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
|
@ -140,7 +140,7 @@ public class Language_EN implements Languages{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Rank rank) {
|
||||
return "§7You gave " + p.getDisplayName() + " the rank §e" + rank.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.languages;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
|
@ -140,7 +140,7 @@ public class Language_IT implements Languages{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Rank rank) {
|
||||
return "§7Hai dato " + p.getDisplayName() + " il gruppo §e" + rank.toString();
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.languages;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
|
@ -36,7 +36,7 @@ public interface Languages{
|
|||
String Core_SETRANK_USAGE();
|
||||
String Core_SETRANK_KICK();
|
||||
String Core_SETRANK_NO_RANK();
|
||||
String Core_SETRANK_SET(CustomPlayer p, Ranks rank);
|
||||
String Core_SETRANK_SET(CustomPlayer p, Rank rank);
|
||||
String Core_TS_ALLREADY_VERIFIED();
|
||||
String Core_TS_VERIFIED();
|
||||
String Core_VANISH_ON();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.languages;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ public class Messages {
|
|||
public String Core_SETRANK_NO_RANK() {
|
||||
return lang.Core_SETRANK_NO_RANK();
|
||||
}
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
|
||||
public String Core_SETRANK_SET(CustomPlayer p, Rank rank) {
|
||||
return lang.Core_SETRANK_SET(p, rank);
|
||||
}
|
||||
public String Core_TS_ALLREADY_VERIFIED() {
|
||||
|
|
|
@ -16,8 +16,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Block> {
|
||||
|
||||
protected String worldName;
|
||||
protected final Vector minimumPoint, maximumPoint;
|
||||
private String worldName;
|
||||
private final Vector minimumPoint, maximumPoint;
|
||||
|
||||
public Cuboid(Cuboid cuboid) {
|
||||
this(cuboid.worldName, cuboid.minimumPoint.getX(), cuboid.minimumPoint.getY(), cuboid.minimumPoint.getZ(), cuboid.maximumPoint.getX(), cuboid.maximumPoint.getY(), cuboid.maximumPoint.getZ());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.univento.core.api.map;
|
||||
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -109,7 +109,7 @@ public class MapVoting implements Listener{
|
|||
}
|
||||
|
||||
public Inventory getInventory(CustomPlayer p) {
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(p.isAllowed(Rank.Admin)) {
|
||||
Inventory inv = Bukkit.createInventory(p, 45, invTitle);
|
||||
|
||||
for(Map map : allMaps) {
|
||||
|
@ -164,7 +164,7 @@ public class MapVoting implements Listener{
|
|||
if(e.getWhoClicked() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
if(e.getInventory().getName().equals(invTitle)) {
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(p.isAllowed(Rank.Admin)) {
|
||||
allMaps.stream().filter(map -> e.getCurrentItem().getType() == map.getItem()).forEach(map -> {
|
||||
forcedMap = map;
|
||||
});
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package eu.univento.core.api.pet;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
public class NMSHandler {
|
||||
|
||||
public static LivingEntity spawn(EntityType type, Location loc) {
|
||||
World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
PetType petType = PetType.valueOf(type);
|
||||
if(petType == null) return null;
|
||||
Entity entity;
|
||||
try {
|
||||
entity = (Entity) petType.getCustomClass().getConstructors()[0].newInstance(nmsWorld);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw());
|
||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
return (LivingEntity) entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static void registerEnties() {
|
||||
PetType.registerEntities();
|
||||
}
|
||||
|
||||
public static EntityType[] getRegisteredTypes() {
|
||||
return PetType.getRegisteredTypes();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.univento.core.api.pet;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.EntityTypes;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
class NMSHelper {
|
||||
|
||||
static void registerEntity(String name, int id, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass) {
|
||||
try {
|
||||
final List<Map<?, ?>> dataMaps = new ArrayList<>();
|
||||
for (final Field f : EntityTypes.class.getDeclaredFields()) {
|
||||
if (f.getType().getSimpleName().equals(Map.class.getSimpleName())) {
|
||||
f.setAccessible(true);
|
||||
dataMaps.add((Map<?, ?>) f.get(null));
|
||||
}
|
||||
}
|
||||
if (dataMaps.get(2).containsKey(id)) {
|
||||
dataMaps.get(0).remove(name);
|
||||
dataMaps.get(2).remove(id);
|
||||
}
|
||||
|
||||
final Method method = EntityTypes.class.getDeclaredMethod("a", Class.class, String.class, int.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(null, customClass, name, id);
|
||||
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.univento.core.api.pet;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
public class PetManager {
|
||||
|
||||
public static int getUpdateValue() {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package eu.univento.core.api.pet;
|
||||
|
||||
import eu.univento.core.api.pet.custom.CustomCreeper;
|
||||
import eu.univento.core.api.pet.custom.CustomPig;
|
||||
import net.minecraft.server.v1_10_R1.EntityCreeper;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.EntityPig;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* this class overrides all most of the normal minecraft entities
|
||||
*
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
public enum PetType {
|
||||
CREEPER("Creeper", 50, EntityType.CREEPER, EntityCreeper.class, CustomCreeper.class),
|
||||
PIG("Pig", 90, EntityType.PIG, EntityPig.class, CustomPig.class);
|
||||
|
||||
private String name;
|
||||
private int id;
|
||||
private EntityType type;
|
||||
private Class<? extends EntityInsentient> nmsClass;
|
||||
private Class<? extends EntityInsentient> customClass;
|
||||
|
||||
PetType(String name, int id, EntityType type, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.nmsClass = nmsClass;
|
||||
this.customClass = customClass;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Class<? extends EntityInsentient> getNmsClass() {
|
||||
return nmsClass;
|
||||
}
|
||||
|
||||
public Class<? extends EntityInsentient> getCustomClass() {
|
||||
return customClass;
|
||||
}
|
||||
|
||||
private static EntityType[] registeredTypes;
|
||||
|
||||
static void registerEntities() {
|
||||
for (PetType pet : values()) {
|
||||
NMSHelper.registerEntity(pet.getName(), pet.getID(), pet.getNmsClass(), pet.getCustomClass());
|
||||
}
|
||||
}
|
||||
|
||||
static EntityType[] getRegisteredTypes() {
|
||||
if (registeredTypes == null) {
|
||||
List<EntityType> list = new ArrayList<>();
|
||||
for (final PetType pet : values()) {
|
||||
list.add(pet.getType());
|
||||
}
|
||||
|
||||
registeredTypes = list.toArray(new EntityType[list.size()]);
|
||||
}
|
||||
|
||||
return registeredTypes;
|
||||
}
|
||||
|
||||
static PetType valueOf(EntityType type) {
|
||||
for (final PetType pet : values()) {
|
||||
if (pet.getType().equals(type)) {
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package eu.univento.core.api.pet.custom;
|
||||
|
||||
import eu.univento.core.api.pet.PetManager;
|
||||
import net.minecraft.server.v1_10_R1.*;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
public class CustomCreeper extends EntityCreeper{
|
||||
|
||||
private double rideSpeed;
|
||||
private double sideways;
|
||||
private double backwards;
|
||||
private double stepHeight;
|
||||
private int updateValue = 0;
|
||||
|
||||
public CustomCreeper(World world) {
|
||||
super(world);
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
rideSpeed = 0.2;
|
||||
sideways = 0.5;
|
||||
backwards = 0.25;
|
||||
stepHeight = 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
EntityLiving entity = (EntityLiving) bw();
|
||||
if(entity == null) {
|
||||
for(final Entity e : passengers) {
|
||||
if(e instanceof EntityHuman) {
|
||||
entity = (EntityLiving) e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(entity == null) {
|
||||
super.g(f, f1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(PetManager.getUpdateValue() > updateValue) {
|
||||
updateValue = PetManager.getUpdateValue();
|
||||
update();
|
||||
}
|
||||
|
||||
this.lastPitch = this.yaw = entity.yaw;
|
||||
this.pitch = entity.pitch = 0.5F;
|
||||
this.setYawPitch(this.yaw, this.pitch);
|
||||
this.aQ = this.aO = this.yaw;
|
||||
|
||||
f = (float) (entity.bf * sideways);
|
||||
|
||||
f1 = entity.bg;
|
||||
if(f1 <= 0.0F) {
|
||||
f1 *= backwards;
|
||||
}
|
||||
|
||||
this.l((float) rideSpeed);
|
||||
super.g(f, f1);
|
||||
|
||||
P = (float) stepHeight;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package eu.univento.core.api.pet.custom;
|
||||
|
||||
import eu.univento.core.api.pet.PetManager;
|
||||
import net.minecraft.server.v1_10_R1.*;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
* created on 26.06.2016
|
||||
*/
|
||||
public class CustomPig extends EntityPig{
|
||||
private double rideSpeed;
|
||||
private double sideways;
|
||||
private double backwards;
|
||||
private double stepHeight;
|
||||
private int updateValue = 0;
|
||||
|
||||
public CustomPig(World world) {
|
||||
super(world);
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
rideSpeed = 0.5;
|
||||
sideways = 0.5;
|
||||
backwards = 0.25;
|
||||
stepHeight = 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
EntityLiving entity = (EntityLiving) bw();
|
||||
if(entity == null) {
|
||||
for(final Entity e : passengers) {
|
||||
if(e instanceof EntityHuman) {
|
||||
entity = (EntityLiving) e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(entity == null) {
|
||||
super.g(f, f1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(PetManager.getUpdateValue() > updateValue) {
|
||||
updateValue = PetManager.getUpdateValue();
|
||||
update();
|
||||
}
|
||||
|
||||
this.lastPitch = this.yaw = entity.yaw;
|
||||
this.pitch = entity.pitch = 0.5F;
|
||||
this.setYawPitch(this.yaw, this.pitch);
|
||||
this.aQ = this.aO = this.yaw;
|
||||
|
||||
f = (float) (entity.bf * sideways);
|
||||
|
||||
f1 = entity.bg;
|
||||
if(f1 <= 0.0F) {
|
||||
f1 *= backwards;
|
||||
}
|
||||
|
||||
this.l((float) rideSpeed);
|
||||
super.g(f, f1);
|
||||
|
||||
P = (float) stepHeight;
|
||||
}
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import eu.univento.core.api.utils.UUIDFetcher;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* bans and unbans players
|
||||
* @author joethei
|
||||
* @version 1.2
|
||||
*/
|
||||
public class BanSystem{
|
||||
|
||||
/**
|
||||
* sets player banned
|
||||
* @param p player
|
||||
* @param reason reason
|
||||
* @param who who banned
|
||||
* @param time duration
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
* @throws ClassNotFoundException class couldn't be found
|
||||
*/
|
||||
static void setBanned(CustomPlayer p, String reason, CustomPlayer who, int time)throws SQLException, ClassNotFoundException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
|
||||
Date date = new Date();
|
||||
date.setTime(date.getTime() + (time * 24));
|
||||
Timestamp timestamp = new Timestamp(date.getTime());
|
||||
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("INSERT INTO bans (BID, Reason, until, BannerID) VALUES ('" + id + "', '" + reason + "', '" + 0 + "', '" + timestamp + "');");
|
||||
st.execute();
|
||||
p.kickPlayer("§cYou have been banned. §6Reason: " + reason + "\nUntil: " + timestamp);
|
||||
who.sendMessage("§cDu hast den Spieler " + p.getColor() + p.getName() + "§c für " + time + " Tage gebannt wegen " + reason);
|
||||
sql.closeConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* unbans a player
|
||||
* @param p player
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
* @throws ClassNotFoundException class couldn't be found
|
||||
*/
|
||||
static void removeAllBans(CustomPlayer p) throws SQLException, ClassNotFoundException{
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("DELETE FROM bans WHERE ID ='" + id + "';");
|
||||
st.execute();
|
||||
sql.closeConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if player is banned
|
||||
* @param p player
|
||||
* @return true /false
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
* @throws ClassNotFoundException class couldn't be found
|
||||
*/
|
||||
static boolean isBanned(CustomPlayer p) throws SQLException, ClassNotFoundException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM bans WHERE BID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
Date date = new Date();
|
||||
Timestamp time = new Timestamp(date.getTime());
|
||||
sql.closeConnection();
|
||||
return time.before(getBanTime(p));
|
||||
}else {
|
||||
sql.closeConnection();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Timestamp getBanTime(CustomPlayer p) throws SQLException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM bans WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
Timestamp time = rs.getTimestamp("until");
|
||||
sql.closeConnection();
|
||||
return time;
|
||||
}
|
||||
sql.closeConnection();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* return reason for ban
|
||||
* @param p player
|
||||
* @return String
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
* @throws ClassNotFoundException class couldn't be found
|
||||
*/
|
||||
static String getBanReason(CustomPlayer p)throws SQLException, ClassNotFoundException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM bans WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
String reason = rs.getString("Reason");
|
||||
sql.closeConnection();
|
||||
return reason;
|
||||
}else {
|
||||
sql.closeConnection();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the name of the player who banned the player
|
||||
* @param p player
|
||||
* @return String
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
* @throws ClassNotFoundException class couldn't be found
|
||||
*/
|
||||
static String getWhoBanned(CustomPlayer p)throws SQLException, ClassNotFoundException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
ResultSet rs = Core.returnSQL().getConnection().createStatement().executeQuery("SELECT * FROM bans WHERE ID='" + id + "';");
|
||||
if (!rs.next()) {
|
||||
sql.closeConnection();
|
||||
return null;
|
||||
}
|
||||
String whouuid = rs.getString("who");
|
||||
sql.closeConnection();
|
||||
return UUIDFetcher.getName(UUID.fromString(whouuid));
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* coins management
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Coins{
|
||||
|
||||
/**
|
||||
* gets coins from player
|
||||
* @param p CustomPlayer
|
||||
* @return coins as integer
|
||||
*/
|
||||
static int getCoins(CustomPlayer p) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Coins FROM users WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
int coins = rs.getInt("Coins");
|
||||
sql.closeConnection();
|
||||
return coins;
|
||||
}
|
||||
return 0;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets coins of player
|
||||
* @param p CustomPlayer
|
||||
* @param coins coins to set
|
||||
*/
|
||||
static void setCoins(CustomPlayer p, int coins) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE users SET Coins='" + coins + "' WHERE ID='" + id + "';");
|
||||
st.execute();
|
||||
sql.closeConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,6 @@ import eu.univento.core.api.database.MongoDB;
|
|||
import eu.univento.core.api.effects.Effects;
|
||||
import eu.univento.core.api.languages.Language;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.server.Game;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import eu.univento.core.api.server.Servers;
|
||||
import eu.univento.core.api.utils.GameProfileBuilder;
|
||||
|
@ -136,7 +135,7 @@ public class CustomPlayer extends CraftPlayer {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setRank(Ranks rank) {
|
||||
public void setRank(Rank rank) {
|
||||
setInDatabase("rank", rank.toString());
|
||||
}
|
||||
|
||||
|
@ -182,8 +181,8 @@ public class CustomPlayer extends CraftPlayer {
|
|||
setSettings(list);
|
||||
}
|
||||
|
||||
public Ranks getRank() {
|
||||
return Ranks.valueOf(getStringFromDatabase("rank"));
|
||||
public Rank getRank() {
|
||||
return Rank.valueOf(getStringFromDatabase("rank"));
|
||||
}
|
||||
|
||||
public Date getFirstLogin() {
|
||||
|
@ -343,8 +342,8 @@ public class CustomPlayer extends CraftPlayer {
|
|||
Servers.connectServer(PLAYER, server);
|
||||
}
|
||||
|
||||
public boolean isAllowed(Ranks rank) {
|
||||
return getRank().value >= rank.value;
|
||||
public boolean isAllowed(Rank rank) {
|
||||
return getRank().getValue() >= rank.getValue();
|
||||
}
|
||||
|
||||
|
||||
|
@ -378,34 +377,25 @@ public class CustomPlayer extends CraftPlayer {
|
|||
|
||||
public String getPrefix() {
|
||||
if (customPrefix != null) return customPrefix;
|
||||
if (isNicked()) return getPrefix(Ranks.Premium);
|
||||
return getPrefix(getRank());
|
||||
if (isNicked()) return Rank.Premium.getPrefix();
|
||||
return getRank().getPrefix();
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
if (customSuffix != null) return customSuffix;
|
||||
if (isNicked()) return getSuffix(Ranks.Premium);
|
||||
return getSuffix(getRank());
|
||||
}
|
||||
|
||||
public String getChatColor() {
|
||||
if(isNicked()) return getChatColor(Ranks.Premium);
|
||||
return getChatColor(getRank());
|
||||
if (isNicked()) return Rank.Premium.getSuffix();
|
||||
return getRank().getSuffix();
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
if (customColor != null) return customColor;
|
||||
if (isNicked()) return getColor(Ranks.Premium);
|
||||
return getColor(getRank());
|
||||
if (isNicked()) return Rank.Premium.getColor();
|
||||
return getRank().getColor();
|
||||
}
|
||||
|
||||
public Team getTeam() {
|
||||
if (isNicked()) return getTeam(Ranks.Premium);
|
||||
return getTeam(getRank());
|
||||
}
|
||||
|
||||
public Color getArmorColor() {
|
||||
return getArmorColor(getRank());
|
||||
if (isNicked()) getScoreboard().getTeam(Rank.Premium.getTeam());
|
||||
return getScoreboard().getTeam(getRank().getTeam());
|
||||
}
|
||||
|
||||
public void setCustomPrefix(String prefix) {
|
||||
|
@ -494,12 +484,7 @@ public class CustomPlayer extends CraftPlayer {
|
|||
}
|
||||
|
||||
public String getMessage(String message) {
|
||||
Language lang = new Language(getLanguage());
|
||||
return lang.getWord(message);
|
||||
}
|
||||
|
||||
public Statistics getStatistics(Game game) {
|
||||
return new Statistics(this, game);
|
||||
return new Language(getLanguage()).getWord(message);
|
||||
}
|
||||
|
||||
public boolean isNicked() {
|
||||
|
@ -643,233 +628,22 @@ public class CustomPlayer extends CraftPlayer {
|
|||
return (Map<String, Object>) getObjectFromDatbase(name);
|
||||
}
|
||||
|
||||
private String getPrefix(Ranks r) {
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return "§8[§4Admin§8]§4 ";
|
||||
case SrDeveloper:
|
||||
return "§8[§3SrDev§8]§3 ";
|
||||
case Developer:
|
||||
return "§8[§3Dev§8]§3 ";
|
||||
case SrModerator:
|
||||
return "§8[§cSrMod§8]§c ";
|
||||
case HeadBuilder:
|
||||
return "§8[§aHead-Builder§8]§a ";
|
||||
case Moderator:
|
||||
return "§8[§cMod§8]§c ";
|
||||
case Builder:
|
||||
return "§8[§2Builder§8]§2 ";
|
||||
case Supporter:
|
||||
return "§8[§9Supporter§8]§9 ";
|
||||
case Youtuber:
|
||||
return "§5";
|
||||
case Premium:
|
||||
return "§6";
|
||||
case Player:
|
||||
return "§e";
|
||||
default:
|
||||
return "§cFehler ";
|
||||
}
|
||||
}
|
||||
|
||||
private String getSuffix(Ranks r) {
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return "§8 »§7 ";
|
||||
case SrDeveloper:
|
||||
return "§8 »§7 ";
|
||||
case Developer:
|
||||
return "§8 »§7 ";
|
||||
case SrModerator:
|
||||
return "§8 »§7 ";
|
||||
case HeadBuilder:
|
||||
return "§8 »§7 ";
|
||||
case Moderator:
|
||||
return "§8 »§7 ";
|
||||
case Builder:
|
||||
return "§8 »§7 ";
|
||||
case Supporter:
|
||||
return "§8 »§7 ";
|
||||
case Youtuber:
|
||||
return "§8 »§7 ";
|
||||
case Premium:
|
||||
return "§8 »§7 ";
|
||||
case Player:
|
||||
return "§8 »§7 ";
|
||||
default:
|
||||
return "§cFehler";
|
||||
}
|
||||
}
|
||||
|
||||
private String getChatColor(Ranks r) {
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return "§4";
|
||||
case SrDeveloper:
|
||||
return "§3";
|
||||
case Developer:
|
||||
return "§3";
|
||||
case SrModerator:
|
||||
return "§c";
|
||||
case HeadBuilder:
|
||||
return "§a";
|
||||
case Moderator:
|
||||
return "§c";
|
||||
case Builder:
|
||||
return "§2";
|
||||
case Supporter:
|
||||
return "§9";
|
||||
case Youtuber:
|
||||
return "§5";
|
||||
case Premium:
|
||||
return "§6";
|
||||
case Player:
|
||||
return "§e";
|
||||
default:
|
||||
return "§cFehler";
|
||||
}
|
||||
}
|
||||
|
||||
private String getColor(Ranks r) {
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return "§4[Admin] ";
|
||||
case SrDeveloper:
|
||||
return "§3[SrDev] ";
|
||||
case Developer:
|
||||
return "§3[Dev]";
|
||||
case SrModerator:
|
||||
return "§c[SrMod]";
|
||||
case HeadBuilder:
|
||||
return "§a[HeadBuilder] ";
|
||||
case Moderator:
|
||||
return "§c[Mod] ";
|
||||
case Builder:
|
||||
return "§2[Builder] ";
|
||||
case Supporter:
|
||||
return "§9[Supp] ";
|
||||
case Youtuber:
|
||||
return "§5";
|
||||
case Premium:
|
||||
return "§6";
|
||||
case Player:
|
||||
return "§e";
|
||||
default:
|
||||
return "§cFehler";
|
||||
}
|
||||
}
|
||||
|
||||
private Color getArmorColor(Ranks r) {
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return Color.MAROON;
|
||||
case SrDeveloper:
|
||||
return Color.TEAL;
|
||||
case Developer:
|
||||
return Color.TEAL;
|
||||
case SrModerator:
|
||||
return Color.RED;
|
||||
case HeadBuilder:
|
||||
return Color.LIME;
|
||||
case Moderator:
|
||||
return Color.RED;
|
||||
case Builder:
|
||||
return Color.GREEN;
|
||||
case Supporter:
|
||||
return Color.PURPLE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Team getTeam(Ranks r) {
|
||||
Scoreboard board = getScoreboard();
|
||||
switch (r) {
|
||||
case Admin:
|
||||
return board.getTeam("a");
|
||||
case SrDeveloper:
|
||||
return board.getTeam("b");
|
||||
case Developer:
|
||||
return board.getTeam("c");
|
||||
case SrModerator:
|
||||
return board.getTeam("d");
|
||||
case HeadBuilder:
|
||||
return board.getTeam("e");
|
||||
case Moderator:
|
||||
return board.getTeam("f");
|
||||
case Builder:
|
||||
return board.getTeam("g");
|
||||
case Supporter:
|
||||
return board.getTeam("h");
|
||||
case Youtuber:
|
||||
return board.getTeam("i");
|
||||
case Premium:
|
||||
return board.getTeam("j");
|
||||
case Player:
|
||||
return board.getTeam("k");
|
||||
default:
|
||||
return board.getTeam("k");
|
||||
}
|
||||
}
|
||||
|
||||
public void initScoreboard() {
|
||||
Scoreboard board = getScoreboard();
|
||||
board.getTeams().forEach(Team::unregister);
|
||||
|
||||
Team Admin = board.registerNewTeam("a");
|
||||
Team SrDeveloper = board.registerNewTeam("b");
|
||||
Team Developer = board.registerNewTeam("c");
|
||||
Team SrModerator = board.registerNewTeam("d");
|
||||
Team HeadBuilder = board.registerNewTeam("e");
|
||||
Team Moderator = board.registerNewTeam("f");
|
||||
Team Builder = board.registerNewTeam("g");
|
||||
Team Supporter = board.registerNewTeam("h");
|
||||
Team Youtuber = board.registerNewTeam("i");
|
||||
Team Premium = board.registerNewTeam("j");
|
||||
Team Player = board.registerNewTeam("k");
|
||||
|
||||
Admin.setPrefix(getColor(Ranks.Admin));
|
||||
SrDeveloper.setPrefix(getColor(Ranks.SrDeveloper));
|
||||
Developer.setPrefix(getColor(Ranks.Developer));
|
||||
SrModerator.setPrefix(getColor(Ranks.SrModerator));
|
||||
HeadBuilder.setPrefix(getColor(Ranks.HeadBuilder));
|
||||
Moderator.setPrefix(getColor(Ranks.Moderator));
|
||||
Builder.setPrefix(getColor(Ranks.Builder));
|
||||
Supporter.setPrefix(getColor(Ranks.Supporter));
|
||||
Youtuber.setPrefix(getColor(Ranks.Youtuber));
|
||||
Premium.setPrefix(getColor(Ranks.Premium));
|
||||
Player.setPrefix(getColor(Ranks.Player));
|
||||
|
||||
Admin.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
SrDeveloper.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Developer.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
SrModerator.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
HeadBuilder.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Moderator.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Builder.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Supporter.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Youtuber.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Premium.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
Player.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
|
||||
Admin.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
SrDeveloper.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Developer.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
SrModerator.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
HeadBuilder.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Moderator.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Builder.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Supporter.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Youtuber.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Premium.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
Player.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
for(Rank rank : Rank.values()) {
|
||||
Team team = board.registerNewTeam(rank.getTeam());
|
||||
team.setPrefix(rank.getTab());
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLabyModFeatures(HashMap<LabyMod, Boolean> list) {
|
||||
HashMap<String, Boolean> temp = new HashMap<>();
|
||||
for (LabyMod feature : list.keySet()) {
|
||||
for (LabyMod feature : list.keySet())
|
||||
temp.put(feature.name(), list.get(feature));
|
||||
}
|
||||
|
||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||
|
@ -878,7 +652,6 @@ public class CustomPlayer extends CraftPlayer {
|
|||
PacketDataSerializer packetDataSerializer = new PacketDataSerializer(byteBuf);
|
||||
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload("LABYMOD", packetDataSerializer);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -914,4 +687,8 @@ public class CustomPlayer extends CraftPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
public Player.Spigot spigot() {
|
||||
return PLAYER.spigot();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* experience management
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Experience{
|
||||
|
||||
/**
|
||||
* gets experience from player
|
||||
* @param p CustomPlayer
|
||||
* @return experience as integer
|
||||
*/
|
||||
static int getExperience(CustomPlayer p) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Experience FROM users WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
int coins = rs.getInt("Experience");
|
||||
sql.closeConnection();
|
||||
return coins;
|
||||
}
|
||||
return 0;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets experience of player
|
||||
* @param p CustomPlayer
|
||||
* @param experience experience to set
|
||||
*/
|
||||
static void setExperience(CustomPlayer p, int experience) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE users SET Experience='" + experience + "' WHERE ID='" + id + "';");
|
||||
st.execute();
|
||||
sql.closeConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* api for friends
|
||||
* @author joethei
|
||||
* @version 1.1
|
||||
*/
|
||||
public class Friends {
|
||||
|
||||
/**
|
||||
* player object
|
||||
*/
|
||||
CustomPlayer player;
|
||||
|
||||
/**
|
||||
* creates the friends object
|
||||
* @param player CustomPlayer
|
||||
*/
|
||||
public Friends(CustomPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets database IDs of friends
|
||||
* @return ArrayList<Integer>
|
||||
*/
|
||||
public ArrayList<Integer> getFriends() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT * FROM Friends WHERE Player_ID = '" + 0 + "';");
|
||||
while(rs.next()) {
|
||||
list.add(rs.getInt("Friend_ID"));
|
||||
}
|
||||
sql.closeConnection();
|
||||
return list;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add player to friends
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
public void addFriend(CustomPlayer p) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement ps = sql.getConnection().prepareStatement("INSERT INTO Friends ('Player_ID', 'Friend_ID') VALUES ('" + 0 + "', '" + 0 + "');");
|
||||
ps.execute();
|
||||
sql.closeConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* removes player from friends
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
public void removeFriend(CustomPlayer p) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement ps = sql.getConnection().prepareStatement("DELETE FROM Friends WHERE Player_ID='" + 0 + "' AND Friend_ID='" + 0 + "');");
|
||||
ps.execute();
|
||||
sql.closeConnection();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if player is friend
|
||||
* @param p CustomPlayer
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isFriend(CustomPlayer p) {
|
||||
return getFriends().contains(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* counts friends
|
||||
* @return int
|
||||
*/
|
||||
public int countFriends() {
|
||||
return getFriends().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if player has friends
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean hasFriends() {
|
||||
return getFriends().size() >= 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +1,6 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
|
@ -25,72 +9,7 @@ import java.util.Random;
|
|||
* @version 1.1
|
||||
*/
|
||||
public class NickName {
|
||||
|
||||
private static HashMap<CustomPlayer, String> nicks = new HashMap<>();
|
||||
|
||||
private static Field nameField = getField(GameProfile.class, "name");
|
||||
/**
|
||||
*
|
||||
* @param p remove nickname from player
|
||||
*/
|
||||
public static void remove(CustomPlayer p) {
|
||||
if (nicks.containsKey(p))
|
||||
nicks.remove(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets nick boolean
|
||||
* @param p player
|
||||
* @param nick boolean
|
||||
* @throws ClassNotFoundException Class couldn't be found
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
*/
|
||||
static void setNick(CustomPlayer p, boolean nick) throws SQLException, ClassNotFoundException {
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
if (nick)
|
||||
sql.getConnection().createStatement().executeUpdate("UPDATE PlayerSettings SET nick = '1' WHERE ID = '" + 0 + "';");
|
||||
else
|
||||
sql.getConnection().createStatement().executeUpdate("UPDATE PlayerSettings SET nick = '0' WHERE ID = '" + 0 + "';");
|
||||
sql.closeConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* gets if player is nicked
|
||||
* @param p player
|
||||
* @return true / false
|
||||
* @throws ClassNotFoundException Class couldn't be found
|
||||
* @throws SQLException SQL server not available or throwing error
|
||||
*/
|
||||
static boolean isNicked(CustomPlayer p) throws SQLException, ClassNotFoundException {
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT nick FROM PlayerSettings WHERE ID = '" + 0 + "';");
|
||||
if (rs.next()) {
|
||||
boolean is = rs.getInt("nick") == 1;
|
||||
sql.closeConnection();
|
||||
return is;
|
||||
}
|
||||
sql.closeConnection();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets nickname of player
|
||||
* @param p player
|
||||
* @return String
|
||||
*/
|
||||
static String getNick(CustomPlayer p) {
|
||||
if (nicks.containsKey(p)) {
|
||||
return nicks.get(p);
|
||||
}else if(p.isNicked()){
|
||||
nicks.put(p, getRandomNick());
|
||||
return nicks.get(p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* gets random Nickname
|
||||
* @return String
|
||||
*/
|
||||
|
@ -322,55 +241,4 @@ public class NickName {
|
|||
return names.get(i);
|
||||
}
|
||||
|
||||
static void setName(CustomPlayer p, String name) {
|
||||
p.setDisplayName(name);
|
||||
try {
|
||||
nameField.set(p.getProfile(), name);
|
||||
PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(p.getEntityId());
|
||||
sendPacket(destroy);
|
||||
removeFromTablist(p);
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
addToTablist(p);
|
||||
PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(p.getHandle());
|
||||
Bukkit.getOnlinePlayers().stream().filter(players -> !players.equals(p)).forEach(players -> {
|
||||
((CraftPlayer) players).getHandle().playerConnection.sendPacket(spawn);
|
||||
});
|
||||
}
|
||||
|
||||
}.runTaskLater(Core.getInstance(), 4);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void addToTablist(CraftPlayer p) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, p.getHandle());
|
||||
sendPacket(packet);
|
||||
}
|
||||
|
||||
private static void removeFromTablist(CraftPlayer cp) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, cp.getHandle());
|
||||
sendPacket(packet);
|
||||
}
|
||||
|
||||
private static void sendPacket(Packet<?> packet) {
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer)players).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static Field getField(Class<?> clazz, String name) {
|
||||
try{
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* server-wide settings
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class PlayerSettings {
|
||||
|
||||
/**
|
||||
* returns if setting is set
|
||||
* @param what what setting is set
|
||||
* @param p CustomPlayer
|
||||
* @return boolean
|
||||
*/
|
||||
static boolean isSet(String what, CustomPlayer p) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM PlayerSettings WHERE ID = '" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if (rs.next()) {
|
||||
boolean is = rs.getInt(what) == 1;
|
||||
sql.closeConnection();
|
||||
return is;
|
||||
}
|
||||
sql.closeConnection();
|
||||
return false;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets setting
|
||||
* @param p CustomPlayer
|
||||
* @param bool boolean to set to
|
||||
* @param what what to set
|
||||
* @throws ClassNotFoundException class could not be found
|
||||
* @throws SQLException SQL ServerPinger not available or throwing error
|
||||
*/
|
||||
static void set(boolean bool, String what, CustomPlayer p) throws SQLException, ClassNotFoundException {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
if (bool) {
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE PlayerSettings SET " + what + " = '1' WHERE ID = '" + id + "';");
|
||||
st.execute();
|
||||
}else {
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE PlayerSettings SET " + what + " = '0' WHERE ID = '" + id + "';");
|
||||
st.execute();
|
||||
}
|
||||
sql.closeConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* gets setting from player
|
||||
* @param what what to get
|
||||
* @param p CustomPlayer
|
||||
* @return String
|
||||
*/
|
||||
static String get(String what, CustomPlayer p) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT " + what + " FROM PlayerSettings WHERE ID='" + id + "';");
|
||||
ResultSet rs = st.executeQuery();
|
||||
if(rs.next()) {
|
||||
String rt = rs.getString(what);
|
||||
sql.closeConnection();
|
||||
return rt;
|
||||
}
|
||||
return null;
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets settings for player
|
||||
* @param set value to set
|
||||
* @param what what to set
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
static void set(String set, String what, CustomPlayer p) {
|
||||
int id = 0;
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE PlayerSettings SET " + what + " = '" + set + "' WHERE ID = '" + id + "';");
|
||||
st.execute();
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* changes settings
|
||||
* @param what what to set
|
||||
* @param p CustomPlayer
|
||||
*/
|
||||
static void change(String what, CustomPlayer p) {
|
||||
if(isSet(what, p)) {
|
||||
try {
|
||||
set(false, what, p);
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
try {
|
||||
set(true, what, p);
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<CustomPlayer> getAllPlayersWithEffectsEnabled() {
|
||||
ArrayList<CustomPlayer> list = new ArrayList<>();
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(players);
|
||||
if(isSet("effects", p)) {
|
||||
list.add(p);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
public enum Rank {
|
||||
Admin(16, "§4", "§8[§4Admin§8] ", "§8» ", "a", "§4Admin | "),
|
||||
SrDeveloper(15, "§3", "§8[§3SrDev§8] ", "§8» ", "c", "§3SrDev | "),
|
||||
SrBuilder(14, "§2", "§8[§2SrBuilder§8] ", "§8» ", "f", "§2SrBuilder | "),
|
||||
SrSupporter(13, "§9", "§8[§9SrSupr§8] ", "§8» ", "i", "§9SrSup | "),
|
||||
Developer(12, "§3", "§8[§3Dev§8] ", "§8» ", "d", "§3Dev | "),
|
||||
Builder(11, "§2", "§8[§3Builder§8] ", "§8» ", "g", "§2Builder | "),
|
||||
Supporter(10, "§9", "§8[§9Sup§8] ", "§8» ", "j", "§9Sup | "),
|
||||
JrDeveloper(9, "§3", "§8[§3JrDev§8] ", "§8» ", "e", "§3JrDev | "),
|
||||
JrBuilder(8, "§2", "§8[§2JrBuilder§8] ", "§8» ", "h", "§2JrBuilder | "),
|
||||
JrSupporter(7, "§9", "§8[§9JrSup§8] ", "§8» ", "k", "§9JrSup | "),
|
||||
Manager(6, "§c", "§8[§cManager§8] ", "§8» ", "b", "§cManager | "),
|
||||
Grafik(5, "§e", "§8[§eGrafiker§8] ", "§8» ", "l", "§eGrafik | "),
|
||||
Sound(4, "§e", "§8[§eSound§8] ", "§8» ", "m", "§eSound | "),
|
||||
Partner(3, "§5", "§5", "§8» ", "n", "§5"),
|
||||
Premium(2, "§6", "§6", "§8» ", "o", "§6"),
|
||||
Player(1, "§7", "§7", "§8» ", "p", "§7");
|
||||
|
||||
private final int value;
|
||||
private final String color;
|
||||
private final String prefix;
|
||||
private final String suffix;
|
||||
private final String team;
|
||||
private final String tab;
|
||||
|
||||
Rank(int value, String color, String prefix, String suffix, String team, String tab) {
|
||||
this.value = value;
|
||||
this.color = color;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.team = team;
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
public enum Ranks {
|
||||
Admin(11),
|
||||
SrDeveloper(10),
|
||||
HeadBuilder(9),
|
||||
SrModerator(8),
|
||||
Developer(7),
|
||||
Builder(6),
|
||||
Moderator(5),
|
||||
Supporter(4),
|
||||
Youtuber(3),
|
||||
Premium(2),
|
||||
Player(1);
|
||||
|
||||
final int value;
|
||||
|
||||
Ranks(int n) {
|
||||
this.value = n;
|
||||
}
|
||||
}
|
|
@ -1,217 +0,0 @@
|
|||
package eu.univento.core.api.player;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.database.MySQL;
|
||||
import eu.univento.core.api.server.Game;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* statistics management
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Statistics {
|
||||
|
||||
CustomPlayer player;
|
||||
Game game;
|
||||
|
||||
/**
|
||||
* @param player CustomPlayer
|
||||
* @param game Game
|
||||
*/
|
||||
public Statistics(CustomPlayer player, Game game) {
|
||||
this.player = player;
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets deaths of player for game
|
||||
* @return Integer
|
||||
*/
|
||||
public int getDeaths() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Deaths FROM " + game.toString() + "Stats WHERE ID='" + 0 + "');");
|
||||
ResultSet rs = st.executeQuery();
|
||||
int deaths = rs.getInt("Deaths");
|
||||
sql.closeConnection();
|
||||
return deaths;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets deaths of player for game
|
||||
* @param deaths Integer
|
||||
*/
|
||||
public void setDeaths(int deaths) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE " + game.toString() + "Stats WHERE ID='" + 0 + "' SET Deaths='" + deaths +"');");
|
||||
st.execute();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDeath() {
|
||||
setDeaths(getDeaths() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets kills of player for game
|
||||
* @return Integer
|
||||
*/
|
||||
public int getKills() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Kills FROM " + game.toString() + "Stats WHERE ID='" + 0 + "');");
|
||||
ResultSet rs = st.executeQuery();
|
||||
int kills = rs.getInt("Kills");
|
||||
sql.closeConnection();
|
||||
return kills;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets kills of player for game
|
||||
* @param kills Integer
|
||||
*/
|
||||
public void setKills(int kills) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE " + game.toString() + "Stats WHERE ID='" + 0 + "' SET Kills='" + kills +"');");
|
||||
st.execute();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addKill() {
|
||||
setKills(getKills() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets played rounds of player for game
|
||||
* @return Integer
|
||||
*/
|
||||
public int getPlayedRounds() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT PlayedRounds FROM " + game.toString() + "Stats WHERE ID='" + 0 + "');");
|
||||
ResultSet rs = st.executeQuery();
|
||||
int rounds = rs.getInt("PlayedRounds");
|
||||
sql.closeConnection();
|
||||
return rounds;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets played rounds of player for game
|
||||
* @param rounds Integer
|
||||
*/
|
||||
public void setPlayedRounds(int rounds) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE " + game.toString() + "Stats WHERE ID='" + 0 + "' SET PlayedRounds='" + rounds +"');");
|
||||
st.execute();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayedRound() {
|
||||
setPlayedRounds(getPlayedRounds() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets playtime of player for game
|
||||
* @return Integer
|
||||
*/
|
||||
public int getPlaytime() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Playtime FROM " + game.toString() + "Stats WHERE ID='" + 0 + "');");
|
||||
ResultSet rs = st.executeQuery();
|
||||
int time = rs.getInt("Playtime");
|
||||
sql.closeConnection();
|
||||
return time;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets playtime of player for game
|
||||
* @param time Integer
|
||||
*/
|
||||
public void setPlaytime(int time) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE " + game.toString() + "Stats WHERE ID='" + 0 + "' SET Playtime='" + time +"');");
|
||||
st.execute();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets wins of player for game
|
||||
* @return Integer
|
||||
*/
|
||||
public int getWins() {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT Wins FROM " + game.toString() + "Stats WHERE ID='" + 0 + "');");
|
||||
ResultSet rs = st.executeQuery();
|
||||
int wins = rs.getInt("Wins");
|
||||
sql.closeConnection();
|
||||
return wins;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets wins of player for game
|
||||
* @param wins Integer
|
||||
*/
|
||||
public void setWins(int wins) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE " + game.toString() + "Stats WHERE ID='" + 0 + "' SET Wins='" + wins +"');");
|
||||
st.execute();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addWin() {
|
||||
setWins(getWins() + 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import java.sql.SQLException;
|
|||
public class ServerDatabase {
|
||||
|
||||
static String getIP(String name) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
MySQL sql = Core.getMySQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT ip FROM Servers WHERE name='" + name + "'");
|
||||
|
@ -32,7 +32,7 @@ public class ServerDatabase {
|
|||
}
|
||||
|
||||
static int getPort(String name) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
MySQL sql = Core.getMySQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT port FROM Servers WHERE name='" + name + "'");
|
||||
|
@ -50,7 +50,7 @@ public class ServerDatabase {
|
|||
}
|
||||
|
||||
static String getMotd(String name) {
|
||||
MySQL sql = Core.returnSQL();
|
||||
MySQL sql = Core.getMySQL();
|
||||
try {
|
||||
sql.openConnection();
|
||||
PreparedStatement st = sql.getConnection().prepareStatement("SELECT motd FROM Servers WHERE name='" + name + "'");
|
||||
|
|
|
@ -30,7 +30,8 @@ public class UUIDFetcher{
|
|||
|
||||
private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
|
||||
private static final String UUID_URL = "https://api.mojang.com/users/profiles/minecraft/%s?at=%d";
|
||||
//private static final String UUID_URL = "https://api.mojang.com/users/profiles/minecraft/%s?at=%d";
|
||||
private static final String UUID_URL = "https://mcapi.de/api/user/%s";
|
||||
private static final String NAME_URL = "https://api.mojang.com/user/profiles/%s/names";
|
||||
private static Map<String, UUID> uuidCache = new HashMap<>();
|
||||
private static Map<UUID, String> nameCache = new HashMap<>();
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -48,7 +48,7 @@ public class Build extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Builder)) {
|
||||
if(p.isAllowed(Rank.Builder)) {
|
||||
if(players.containsKey(p)) {
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Core_BUILD_OFF());
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -26,13 +26,13 @@ public class ChatClear extends AutoCommand<Core> {
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Supporter)) {
|
||||
if(p.isAllowed(Rank.Supporter)) {
|
||||
for(int i = 0; i <= 100; i++) {
|
||||
Bukkit.broadcastMessage(" ");
|
||||
}
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
CustomPlayer player = CustomPlayer.getPlayer(players);
|
||||
if (player.isAllowed(Ranks.Supporter)) {
|
||||
if (player.isAllowed(Rank.Supporter)) {
|
||||
Messages messages = new Messages(player);
|
||||
player.sendMessage(messages.Core_CHAT_CLEARED(p));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -33,11 +33,11 @@ public class GameMode extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Builder)) {
|
||||
if(p.isAllowed(Rank.Builder)) {
|
||||
if(args.length == 1) {
|
||||
String mode = args[0];
|
||||
p.setGameMode(getModeFromString(mode));
|
||||
p.sendMessage(msgs.Core_GM_CHANGED());
|
||||
p.sendMessage(msgs.Core_GM_CHANGED() + " auf " + p.getGameMode().name());
|
||||
}if(args.length == 0){
|
||||
p.sendMessage(msgs.Core_GM_USAGE());
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -33,7 +33,7 @@ public class GlobalMute extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Moderator)) {
|
||||
if(p.isAllowed(Rank.Supporter)) {
|
||||
if(ServerSettings.isMute()) {
|
||||
ServerSettings.setMute(false);
|
||||
p.sendMessage(msgs.Core_GLOBALMUTE_OFF());
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.univento.core.api.AutoCommand;
|
|||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.NickName;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class Nick extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Youtuber)) {
|
||||
if(p.isAllowed(Rank.Partner)) {
|
||||
if(p.isNicked()) {
|
||||
p.getTeam().removeEntry(p.getDisplayName());
|
||||
p.setNicked(false);
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -35,7 +35,7 @@ public class RunAs extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.SrDeveloper)) {
|
||||
if(p.isAllowed(Rank.SrDeveloper)) {
|
||||
if(args.length >= 2) {
|
||||
CustomPlayer t = CustomPlayer.getPlayer(Bukkit.getPlayer(args[0]).getName());
|
||||
if(t != null) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -33,11 +33,11 @@ public class SetRank extends AutoCommand<Core>{
|
|||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
if(p.isAllowed(Ranks.HeadBuilder)) {
|
||||
if(p.isAllowed(Rank.SrBuilder)) {
|
||||
if(args.length == 2) {
|
||||
Ranks rank;
|
||||
Rank rank;
|
||||
try{
|
||||
rank = Ranks.valueOf(args[1]);
|
||||
rank = Rank.valueOf(args[1]);
|
||||
if(Bukkit.getPlayer(args[0]) != null) {
|
||||
CustomPlayer player = CustomPlayer.getPlayer(args[0]);
|
||||
if(player.isAllowed(rank)) {
|
||||
|
@ -45,29 +45,34 @@ public class SetRank extends AutoCommand<Core>{
|
|||
p.sendMessage(p.getMessages().PREFIX() + "§cÄnderungen müssen in der Datenbank stattfinden.");
|
||||
return true;
|
||||
}
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(p.isAllowed(Rank.Admin)) {
|
||||
player.setRank(rank);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, player.getRank()));
|
||||
refreshTablist();
|
||||
}
|
||||
if(p.isAllowed(Ranks.SrDeveloper) && rank.equals(Ranks.Developer)) {
|
||||
player.setRank(Ranks.Developer);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Ranks.Developer));
|
||||
if(p.isAllowed(Rank.SrDeveloper) && rank.equals(Rank.Developer)) {
|
||||
player.setRank(Rank.Developer);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Rank.Developer));
|
||||
refreshTablist();
|
||||
}
|
||||
if(p.isAllowed(Ranks.SrModerator) && rank.equals(Ranks.Moderator)) {
|
||||
player.setRank(Ranks.Moderator);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Ranks.Moderator));
|
||||
if(p.isAllowed(Rank.SrSupporter) && rank.equals(Rank.Supporter)) {
|
||||
player.setRank(Rank.Supporter);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Rank.Supporter));
|
||||
refreshTablist();
|
||||
}
|
||||
if(p.isAllowed(Ranks.SrModerator) && rank.equals(Ranks.Supporter)) {
|
||||
player.setRank(Ranks.Supporter);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Ranks.Supporter));
|
||||
if(p.isAllowed(Rank.SrSupporter) && rank.equals(Rank.JrSupporter)) {
|
||||
player.setRank(Rank.JrSupporter);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Rank.JrSupporter));
|
||||
refreshTablist();
|
||||
}
|
||||
if(p.isAllowed(Ranks.HeadBuilder) && rank.equals(Ranks.Builder)) {
|
||||
player.setRank(Ranks.Builder);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Ranks.Builder));
|
||||
if(p.isAllowed(Rank.SrBuilder) && rank.equals(Rank.Builder)) {
|
||||
player.setRank(Rank.Builder);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Rank.Builder));
|
||||
refreshTablist();
|
||||
}
|
||||
if(p.isAllowed(Rank.SrBuilder) && rank.equals(Rank.JrBuilder)) {
|
||||
player.setRank(Rank.JrBuilder);
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().Core_SETRANK_SET(player, Rank.JrBuilder));
|
||||
refreshTablist();
|
||||
}
|
||||
}else {
|
||||
|
@ -90,24 +95,15 @@ public class SetRank extends AutoCommand<Core>{
|
|||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
List<String> list = Bukkit.getOnlinePlayers().stream().map(Player::getDisplayName).collect(Collectors.toList());
|
||||
|
||||
list.add("Admin");
|
||||
list.add("SrDeveloper");
|
||||
list.add("Developer");
|
||||
list.add("SrModerator");
|
||||
list.add("Moderator");
|
||||
list.add("HeadBuilder");
|
||||
list.add("Builder");
|
||||
list.add("Supporter");
|
||||
list.add("Youtuber");
|
||||
list.add("Premium");
|
||||
list.add("Player");
|
||||
|
||||
for(Rank rank : Rank.values())
|
||||
list.add(rank.name());
|
||||
return list;
|
||||
}
|
||||
|
||||
private void refreshTablist() {
|
||||
Core.getOnlinePlayers().forEach(CustomPlayer::refreshTablist);
|
||||
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||
Core.getOnlinePlayers().forEach(CustomPlayer::refreshTablist);
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package eu.univento.core.commands;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.server.Game;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author joethei
|
||||
* @version 0.1
|
||||
*/
|
||||
public class Stats extends AutoCommand<Core> {
|
||||
|
||||
public Stats(Core plugin, String command, String description, String... aliases) {
|
||||
super(plugin, command, description, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Game game = ServerSettings.getPlayedGame();
|
||||
if(args.length == 0) {
|
||||
p.sendMessage("§aDeine " + game.toString() + " Statistiken");
|
||||
p.sendMessage("Tötungen: " + p.getStatistics(game).getKills());
|
||||
p.sendMessage("Tode: " + p.getStatistics(game).getDeaths());
|
||||
p.sendMessage("Gewinne: " + p.getStatistics(game).getWins());
|
||||
p.sendMessage("Gespielte Runden: " + p.getStatistics(game).getPlayedRounds());
|
||||
p.sendMessage("Spielzeit: " + p.getStatistics(game).getPlaytime());
|
||||
}
|
||||
if(args.length == 1) {
|
||||
if(ServerSettings.getGameState().equals("Lobby") || ServerSettings.getGameState().equals("Restart")) {
|
||||
if(Bukkit.getPlayer(args[0]) != null) {
|
||||
CustomPlayer t = CustomPlayer.getPlayer(args[0]);
|
||||
p.sendMessage("§a" + game.toString() + " Statistiken von " + t.getDisplayName());
|
||||
p.sendMessage("Tötungen: " + t.getStatistics(game).getKills());
|
||||
p.sendMessage("Tode: " + t.getStatistics(game).getDeaths());
|
||||
p.sendMessage("Gewinne: " + t.getStatistics(game).getWins());
|
||||
p.sendMessage("Gespielte Runden: " + t.getStatistics(game).getPlayedRounds());
|
||||
p.sendMessage("Spielzeit: " + t.getStatistics(game).getPlaytime());
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + p.getMessages().NOT_ONLINE(args[0]));
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(p.getMessages().PREFIX() + " §cDu kannst dir im Moment keine Statistiken von anderen Spielern anschauen");
|
||||
}
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -35,7 +35,7 @@ public class SystemInfo extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.SrModerator)) {
|
||||
if(p.isAllowed(Rank.Developer)) {
|
||||
Runtime run = Runtime.getRuntime();
|
||||
p.sendMessage("§6§l===SystemInfo <" + Bukkit.getServerName() + ">===");
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.univento.core.Core;
|
|||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -45,7 +45,7 @@ public class Vanish extends AutoCommand<Core>{
|
|||
if(sender instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(p.isAllowed(Ranks.Moderator)) {
|
||||
if(p.isAllowed(Rank.JrSupporter)) {
|
||||
if(players.contains(p)) {
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.showPlayer(p);
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.univento.core.listeners;
|
|||
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import eu.univento.core.api.server.ServerSettings;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -24,17 +24,17 @@ public class Chat implements Listener{
|
|||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
Messages msgs = new Messages(p);
|
||||
if(ServerSettings.isMute()) {
|
||||
if(!p.isAllowed(Ranks.Supporter)) {
|
||||
if(!p.isAllowed(Rank.Sound)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(msgs.PREFIX() + msgs.Core_SERVER_MUTED());
|
||||
}
|
||||
}
|
||||
String format;
|
||||
if(p.isAllowed(Ranks.Youtuber)) {
|
||||
if(p.isAllowed(Rank.Partner)) {
|
||||
if(p.isNicked() && !ServerSettings.isLobby()) {
|
||||
format = p.getPrefix() + p.getDisplayName() + p.getSuffix() + ChatColor.translateAlternateColorCodes('&', e.getMessage());
|
||||
format = p.getPrefix() + p.getColor() + p.getDisplayName() + p.getSuffix() + ChatColor.translateAlternateColorCodes('&', e.getMessage());
|
||||
}else {
|
||||
format = p.getPrefix() + p.getDisplayName() + p.getSuffix() + ChatColor.translateAlternateColorCodes('&', e.getMessage());
|
||||
format = p.getPrefix() + p.getColor() + p.getDisplayName() + p.getSuffix() + ChatColor.translateAlternateColorCodes('&', e.getMessage());
|
||||
}
|
||||
}else {
|
||||
format = p.getPrefix() + p.getDisplayName() + p.getSuffix() + e.getMessage();
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.univento.core.listeners;
|
|||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.languages.Messages;
|
||||
import eu.univento.core.api.player.CustomPlayer;
|
||||
import eu.univento.core.api.player.Ranks;
|
||||
import eu.univento.core.api.player.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -38,7 +38,7 @@ public class Commands implements Listener{
|
|||
}
|
||||
String cmd = e.getMessage();
|
||||
if(cmd.equalsIgnoreCase("/rl") || cmd.equalsIgnoreCase("/reload")) {
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(p.isAllowed(Rank.Admin)) {
|
||||
e.setCancelled(true);
|
||||
Bukkit.broadcastMessage(msgs.PREFIX() + "§cWarning ! Server will be restarted");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), () -> {
|
||||
|
|
Loading…
Reference in New Issue