diff --git a/Core.iml b/Core.iml
index 49ab2d7..0db5ae1 100644
--- a/Core.iml
+++ b/Core.iml
@@ -12,25 +12,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8291814..a32cdad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,7 @@
org.apache.maven.plugins
maven-compiler-plugin
+ 3.5.1
1.8
@@ -82,19 +83,19 @@
org.bukkit
craftbukkit
- 1.9-R0.1-SNAPSHOT
+ 1.9.2-R0.1-SNAPSHOT
+ provided
org.bukkit
bukkit
- 1.9-R0.1-SNAPSHOT
+ 1.9.2-R0.1-SNAPSHOT
provided
org.spigotmc
spigot-api
- 1.9-R0.1-SNAPSHOT
- provided
+ 1.9.2-R0.1-SNAPSHOT
diff --git a/src/main/java/eu/univento/core/Core.java b/src/main/java/eu/univento/core/Core.java
index 582c97e..0dd6b4b 100644
--- a/src/main/java/eu/univento/core/Core.java
+++ b/src/main/java/eu/univento/core/Core.java
@@ -101,7 +101,8 @@ public class Core extends JavaPlugin{
new Fix(this, "fix", "fix");
new Stats(this, "stats", "statistics");
new Nick(this, "nick", "nick");
- }else{
+ }
+ if(!ServerSettings.isBuild()) {
new Build(this, "build", "build", "b");
pm.registerEvents(new Blocks(), this);
}
@@ -119,16 +120,17 @@ public class Core extends JavaPlugin{
log(Level.INFO, "registered all commands");
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, "LABYMOD");
Blackscreen.setupUtil(getInstance());
- //mongoDB = new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.Username"), 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"));
log(Level.INFO, "Plugin ver. " + getDescription().getVersion() + " started");
}
@Override
public void onDisable() {
+ mongoDB.getClient().close();
log(Level.INFO, "Plugin stoped");
}
diff --git a/src/main/java/eu/univento/core/api/Config.java b/src/main/java/eu/univento/core/api/Config.java
index ae6574b..7ded2c1 100644
--- a/src/main/java/eu/univento/core/api/Config.java
+++ b/src/main/java/eu/univento/core/api/Config.java
@@ -31,15 +31,16 @@ public class Config {
//editable messages will be set here, but do not edit this messages.
//seting the default MySQL config.
- cfg.addDefault("MySQL.Host", "192.168.0.101");
+ cfg.addDefault("MySQL.Host", "hostname");
cfg.addDefault("MySQL.Port", "3306");
cfg.addDefault("MySQL.DB", "core");
- cfg.addDefault("MySQL.User", "root");//best user name
- cfg.addDefault("MySQL.Pass", "");//best password
- cfg.addDefault("TS.IP", "ts.univento.eu");
- cfg.addDefault("TS.QueryPort", 0);
- cfg.addDefault("TS.QueryUser", "ServerQuery");
- cfg.addDefault("TS.QueryPass", "password");
+ cfg.addDefault("MySQL.User", "root");
+ cfg.addDefault("MySQL.Pass", "");
+ cfg.addDefault("MongoDB.Host", "Hostname");
+ cfg.addDefault("MongoDB.Port", 27017);
+ cfg.addDefault("MongoDB.User", "univento");
+ cfg.addDefault("MongoDB.Password", "1234");
+ cfg.addDefault("MongoDB.Database", "univento");
cfg.options().copyDefaults(true);
cfg.save(file);
diff --git a/src/main/java/eu/univento/core/api/Utils.java b/src/main/java/eu/univento/core/api/Utils.java
index a6885fe..f3e1146 100644
--- a/src/main/java/eu/univento/core/api/Utils.java
+++ b/src/main/java/eu/univento/core/api/Utils.java
@@ -1,5 +1,6 @@
package eu.univento.core.api;
+
import eu.univento.core.Core;
import org.bukkit.*;
import org.bukkit.entity.Entity;
@@ -154,14 +155,7 @@ public class Utils {
* restarts server
*/
public static void restart() {
- Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), new Runnable() {
-
- @Override
- public void run() {
- Bukkit.getServer().spigot().restart();
- }
-
- }, 10 * 20L);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "/restart"), 10 * 20L);
}
/**
diff --git a/src/main/java/eu/univento/core/api/database/AsyncMySQL.java b/src/main/java/eu/univento/core/api/database/AsyncMySQL.java
new file mode 100644
index 0000000..fbd800d
--- /dev/null
+++ b/src/main/java/eu/univento/core/api/database/AsyncMySQL.java
@@ -0,0 +1,153 @@
+package eu.univento.core.api.database;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+
+import java.sql.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.function.Consumer;
+
+/**
+ * @author joethei
+ * @version 0.1
+ */
+public class AsyncMySQL {
+ private ExecutorService executor;
+ private Plugin plugin;
+ private MySQL sql;
+
+ public AsyncMySQL(Plugin owner, String host, int port, String user, String password, String database) {
+ try {
+ sql = new MySQL(host, port, user, password, database);
+ executor = Executors.newCachedThreadPool();
+ plugin = owner;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ 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 consumer) {
+ executor.execute(() -> {
+ ResultSet result = sql.query(statement);
+ Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(result));
+ });
+ }
+
+ public void query(String statement, Consumer consumer) {
+ executor.execute(() -> {
+ ResultSet result = sql.query(statement);
+ Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(result));
+ });
+ }
+
+ 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;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/database/Database.java b/src/main/java/eu/univento/core/api/database/Database.java
index 76fa156..1cc711a 100644
--- a/src/main/java/eu/univento/core/api/database/Database.java
+++ b/src/main/java/eu/univento/core/api/database/Database.java
@@ -7,66 +7,59 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-public abstract class Database
-{
- protected Connection connection;
- protected Plugin plugin;
+public abstract class Database {
+ protected Connection connection;
+ protected Plugin plugin;
- protected Database(Plugin plugin)
- {
- this.plugin = plugin;
- this.connection = null;
- }
-
- public abstract Connection openConnection()
- throws SQLException, ClassNotFoundException;
-
- public boolean checkConnection()
- throws SQLException
- {
- return (this.connection != null) && (!this.connection.isClosed());
- }
-
- public Connection getConnection()
- {
- return this.connection;
- }
-
- public boolean closeConnection()
- throws SQLException
- {
- if (this.connection == null) {
- return false;
- }
- this.connection.close();
- return true;
- }
-
- public ResultSet querySQL(String query)
- throws SQLException, ClassNotFoundException
- {
- if (!checkConnection()) {
- openConnection();
+ protected Database(Plugin plugin) {
+ this.plugin = plugin;
+ this.connection = null;
}
- Statement statement = this.connection.createStatement();
+ public abstract Connection openConnection()
+ throws SQLException, ClassNotFoundException;
- ResultSet result = statement.executeQuery(query);
-
- return result;
- }
-
- public int updateSQL(String query)
- throws SQLException, ClassNotFoundException
- {
- if (!checkConnection()) {
- openConnection();
+ public boolean checkConnection()
+ throws SQLException {
+ return (this.connection != null) && (!this.connection.isClosed());
}
- Statement statement = this.connection.createStatement();
+ public Connection getConnection() {
+ return this.connection;
+ }
- int result = statement.executeUpdate(query);
+ public boolean closeConnection()
+ throws SQLException {
+ if (this.connection == null) {
+ return false;
+ }
+ this.connection.close();
+ return true;
+ }
- return result;
- }
+ public ResultSet querySQL(String query)
+ throws SQLException, ClassNotFoundException {
+ if (!checkConnection()) {
+ openConnection();
+ }
+
+ Statement statement = this.connection.createStatement();
+
+ ResultSet result = statement.executeQuery(query);
+
+ return result;
+ }
+
+ public int updateSQL(String query)
+ throws SQLException, ClassNotFoundException {
+ if (!checkConnection()) {
+ openConnection();
+ }
+
+ Statement statement = this.connection.createStatement();
+
+ int result = statement.executeUpdate(query);
+
+ return result;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/database/MongoDB.java b/src/main/java/eu/univento/core/api/database/MongoDB.java
index 59d755a..3077702 100644
--- a/src/main/java/eu/univento/core/api/database/MongoDB.java
+++ b/src/main/java/eu/univento/core/api/database/MongoDB.java
@@ -6,7 +6,7 @@ import com.mongodb.ServerAddress;
import com.mongodb.client.MongoDatabase;
import eu.univento.core.api.Config;
-import java.util.Arrays;
+import java.util.Collections;
public class MongoDB {
@@ -15,19 +15,19 @@ public class MongoDB {
public MongoClient getClient() {
if(client == null)
- new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.Username"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
+ new MongoDB(Config.readString("MongoDB.Host"), Config.readInt("MongoDB.Port"), Config.readString("MongoDB.User"), Config.readString("MongoDB.Password"), Config.readString("MongoDB.Database"));
return client;
}
public MongoDB(String host, int port, String username, String password, String database) {
MongoCredential credential = MongoCredential.createCredential(username, database, password.toCharArray());
- client = new MongoClient(new ServerAddress(host, port), Arrays.asList(credential));
+ client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential));
}
public MongoDatabase getDatabase() {
- if(database == null) {
+ if(database == null)
database = getClient().getDatabase(Config.readString("MongoDB.Database"));
- }return database;
+ return database;
}
public void setDatabase(String database) {
@@ -35,9 +35,8 @@ public class MongoDB {
}
public void closeConnection() {
- if(client != null) {
+ if(client != null)
client.close();
- }
}
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/entity/EntityModifier.java b/src/main/java/eu/univento/core/api/entity/EntityModifier.java
index 3804106..a2beed0 100644
--- a/src/main/java/eu/univento/core/api/entity/EntityModifier.java
+++ b/src/main/java/eu/univento/core/api/entity/EntityModifier.java
@@ -13,227 +13,197 @@ import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
/**
- *
* @author GerVorbis
* @version 1.0
*/
-public class EntityModifier
-{
- static org.bukkit.entity.Entity entity;
- static CraftEntity craftentity;
- static net.minecraft.server.v1_9_R1.Entity entityS;
- static int scheduler;
- static Plugin plugin;
- static Player player = null;
- static float Speed;
+public class EntityModifier {
+ static org.bukkit.entity.Entity entity;
+ static CraftEntity craftentity;
+ static net.minecraft.server.v1_9_R1.Entity entityS;
+ static int scheduler;
+ static Plugin plugin;
+ static Player player = null;
+ static float Speed;
- public EntityModifier(org.bukkit.entity.Entity entity, Plugin plugin)
- {
- EntityModifier.entity = entity;
- craftentity = (CraftEntity)entity;
- entityS = craftentity.getHandle();
- EntityModifier.plugin = plugin;
- }
-
- public static Builder modify()
- {
- return new Builder();
- }
-
- public static final class Builder
- {
- public Builder setDisplayName(String display)
- {
- EntityModifier.entity.setCustomName(display);
- EntityModifier.entity.setCustomNameVisible(true);
- return this;
+ public EntityModifier(org.bukkit.entity.Entity entity, Plugin plugin) {
+ EntityModifier.entity = entity;
+ craftentity = (CraftEntity) entity;
+ entityS = craftentity.getHandle();
+ EntityModifier.plugin = plugin;
}
- public Builder setDisplayNameVisible(Boolean visible)
- {
- EntityModifier.entity.setCustomNameVisible(visible.booleanValue());
- return this;
+ public static Builder modify() {
+ return new Builder();
}
- public Builder playEffekt(EntityEffect entityeffect)
- {
- EntityModifier.entity.playEffect(entityeffect);
- return this;
- }
-
- public Builder remove()
- {
- EntityModifier.entity.remove();
- return this;
- }
-
- public Builder setPassenger(org.bukkit.entity.Entity passenger)
- {
- EntityModifier.entity.setPassenger(passenger);
- return this;
- }
-
- public Builder setFireTicks(int ticks)
- {
- EntityModifier.entity.setFireTicks(ticks);
- return this;
- }
-
- public Builder setLocation(Location location)
- {
- teleport(location);
- return this;
- }
-
- public Builder setYawPitch(float yaw, float pitch)
- {
- Location loc = EntityModifier.entity.getLocation().clone();
- teleport(
- new Location(loc.getWorld(), loc.getX(), loc.getY(),
- loc.getZ(), yaw, pitch));
- return this;
- }
-
- public Builder teleport(Location location)
- {
- EntityModifier.entity.teleport(location);
- return this;
- }
-
- public Builder die()
- {
- EntityModifier.entityS.die();
- return this;
- }
-
- public Builder setInvisible(boolean invisible)
- {
- EntityModifier.entityS.setInvisible(invisible);
- return this;
- }
-
- public Builder noClip(boolean noClip)
- {
- EntityModifier.entityS.noclip = noClip;
- return this;
- }
-
- public Builder setInvulnerable(boolean invulnerable)
- {
- try
- {
- Field invulnerableField = net.minecraft.server.v1_9_R1.Entity.class
- .getDeclaredField("invulnerable");
- invulnerableField.setAccessible(true);
- invulnerableField.setBoolean(EntityModifier.entityS, invulnerable);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return this;
- }
-
- public Builder setNoAI(boolean noAI)
- {
- NBTTagCompound tag = new NBTTagCompound();
- EntityModifier.entityS.c(tag);
- tag.setBoolean("NoAI", noAI);
- EntityLiving el = (EntityLiving)EntityModifier.entityS;
- el.a(tag);
- return this;
- }
-
- public Builder setSilent(boolean silent)
- {
- NBTTagCompound tag = new NBTTagCompound();
- EntityModifier.entityS.c(tag);
- tag.setBoolean("Silent", silent);
- EntityLiving el = (EntityLiving)EntityModifier.entityS;
- el.a(tag);
- return this;
- }
-
- public Builder setCanPickUpLoot(boolean canpickuploot)
- {
- NBTTagCompound tag = new NBTTagCompound();
- EntityModifier.entityS.c(tag);
- tag.setBoolean("CanPickUpLoot", canpickuploot);
- EntityLiving el = (EntityLiving)EntityModifier.entityS;
- el.a(tag);
- return this;
- }
-
- public Builder setHealth(float health)
- {
- NBTTagCompound tag = new NBTTagCompound();
- EntityModifier.entityS.c(tag);
- tag.setFloat("HealF", health);
- EntityLiving el = (EntityLiving)EntityModifier.entityS;
- el.a(tag);
- return this;
- }
-
- public Builder setCanDespawn(boolean candespawn)
- {
- candespawn = !candespawn;
- NBTTagCompound tag = new NBTTagCompound();
- EntityModifier.entityS.c(tag);
- tag.setBoolean("PersistenceRequired", candespawn);
- EntityLiving el = (EntityLiving)EntityModifier.entityS;
- el.a(tag);
- return this;
- }
-
- public Builder walkToLocation(Location location, float speed)
- {
- ((CraftCreature)EntityModifier.entity)
- .getHandle()
- .getNavigation()
- .a(location.getX(), location.getY(), location.getZ(), speed);
- return this;
- }
-
- public Builder followPlayer(Player target, float speed)
- {
- EntityModifier.player = target;
- EntityModifier.Speed = speed;
- EntityModifier.scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(EntityModifier.plugin,
- new Runnable()
- {
- @SuppressWarnings("deprecation")
- public void run() {
- double distance = EntityModifier.entity.getLocation().distance(
- EntityModifier.player.getLocation());
- if (distance < 11.0D) {
- float speed = EntityModifier.Speed;
- if (distance < 3.0D) {
- speed = 0.0F;
- }
- ((CraftCreature)EntityModifier.entity)
- .getHandle()
- .getNavigation()
- .a(EntityModifier.player.getLocation().getX(),
- EntityModifier.player.getLocation().getY(),
- EntityModifier.player.getLocation().getZ(),
- speed);
- }
- else if (EntityModifier.player.isOnGround()) {
- EntityModifier.entity.teleport(EntityModifier.player);
- }
+ public static final class Builder {
+ public Builder setDisplayName(String display) {
+ EntityModifier.entity.setCustomName(display);
+ EntityModifier.entity.setCustomNameVisible(true);
+ return this;
}
- }
- , 0L, 1L);
- return this;
- }
- public Builder stopFollowingPlayer()
- {
- Bukkit.getScheduler().cancelTask(EntityModifier.scheduler);
- return this;
- }
+ public Builder setDisplayNameVisible(Boolean visible) {
+ EntityModifier.entity.setCustomNameVisible(visible.booleanValue());
+ return this;
+ }
- public org.bukkit.entity.Entity build()
- {
- return EntityModifier.entity;
+ public Builder playEffekt(EntityEffect entityeffect) {
+ EntityModifier.entity.playEffect(entityeffect);
+ return this;
+ }
+
+ public Builder remove() {
+ EntityModifier.entity.remove();
+ return this;
+ }
+
+ public Builder setPassenger(org.bukkit.entity.Entity passenger) {
+ EntityModifier.entity.setPassenger(passenger);
+ return this;
+ }
+
+ public Builder setFireTicks(int ticks) {
+ EntityModifier.entity.setFireTicks(ticks);
+ return this;
+ }
+
+ public Builder setLocation(Location location) {
+ teleport(location);
+ return this;
+ }
+
+ public Builder setYawPitch(float yaw, float pitch) {
+ Location loc = EntityModifier.entity.getLocation().clone();
+ teleport(
+ new Location(loc.getWorld(), loc.getX(), loc.getY(),
+ loc.getZ(), yaw, pitch));
+ return this;
+ }
+
+ public Builder teleport(Location location) {
+ EntityModifier.entity.teleport(location);
+ return this;
+ }
+
+ public Builder die() {
+ EntityModifier.entityS.die();
+ return this;
+ }
+
+ public Builder setInvisible(boolean invisible) {
+ EntityModifier.entityS.setInvisible(invisible);
+ return this;
+ }
+
+ public Builder noClip(boolean noClip) {
+ EntityModifier.entityS.noclip = noClip;
+ return this;
+ }
+
+ public Builder setInvulnerable(boolean invulnerable) {
+ try {
+ Field invulnerableField = net.minecraft.server.v1_9_R1.Entity.class
+ .getDeclaredField("invulnerable");
+ invulnerableField.setAccessible(true);
+ invulnerableField.setBoolean(EntityModifier.entityS, invulnerable);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return this;
+ }
+
+ public Builder setNoAI(boolean noAI) {
+ NBTTagCompound tag = new NBTTagCompound();
+ EntityModifier.entityS.c(tag);
+ tag.setBoolean("NoAI", noAI);
+ EntityLiving el = (EntityLiving) EntityModifier.entityS;
+ el.a(tag);
+ return this;
+ }
+
+ public Builder setSilent(boolean silent) {
+ NBTTagCompound tag = new NBTTagCompound();
+ EntityModifier.entityS.c(tag);
+ tag.setBoolean("Silent", silent);
+ EntityLiving el = (EntityLiving) EntityModifier.entityS;
+ el.a(tag);
+ return this;
+ }
+
+ public Builder setCanPickUpLoot(boolean canpickuploot) {
+ NBTTagCompound tag = new NBTTagCompound();
+ EntityModifier.entityS.c(tag);
+ tag.setBoolean("CanPickUpLoot", canpickuploot);
+ EntityLiving el = (EntityLiving) EntityModifier.entityS;
+ el.a(tag);
+ return this;
+ }
+
+ public Builder setHealth(float health) {
+ NBTTagCompound tag = new NBTTagCompound();
+ EntityModifier.entityS.c(tag);
+ tag.setFloat("HealF", health);
+ EntityLiving el = (EntityLiving) EntityModifier.entityS;
+ el.a(tag);
+ return this;
+ }
+
+ public Builder setCanDespawn(boolean candespawn) {
+ candespawn = !candespawn;
+ NBTTagCompound tag = new NBTTagCompound();
+ EntityModifier.entityS.c(tag);
+ tag.setBoolean("PersistenceRequired", candespawn);
+ EntityLiving el = (EntityLiving) EntityModifier.entityS;
+ el.a(tag);
+ return this;
+ }
+
+ public Builder walkToLocation(Location location, float speed) {
+ ((CraftCreature) EntityModifier.entity)
+ .getHandle()
+ .getNavigation()
+ .a(location.getX(), location.getY(), location.getZ(), speed);
+ return this;
+ }
+
+ public Builder followPlayer(Player target, float speed) {
+ EntityModifier.player = target;
+ EntityModifier.Speed = speed;
+ EntityModifier.scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(EntityModifier.plugin,
+ new Runnable() {
+ @SuppressWarnings("deprecation")
+ public void run() {
+ double distance = EntityModifier.entity.getLocation().distance(
+ EntityModifier.player.getLocation());
+ if (distance < 11.0D) {
+ float speed = EntityModifier.Speed;
+ if (distance < 3.0D) {
+ speed = 0.0F;
+ }
+ ((CraftCreature) EntityModifier.entity)
+ .getHandle()
+ .getNavigation()
+ .a(EntityModifier.player.getLocation().getX(),
+ EntityModifier.player.getLocation().getY(),
+ EntityModifier.player.getLocation().getZ(),
+ speed);
+ } else if (EntityModifier.player.isOnGround()) {
+ EntityModifier.entity.teleport(EntityModifier.player);
+ }
+ }
+ }
+ , 0L, 1L);
+ return this;
+ }
+
+ public Builder stopFollowingPlayer() {
+ Bukkit.getScheduler().cancelTask(EntityModifier.scheduler);
+ return this;
+ }
+
+ public org.bukkit.entity.Entity build() {
+ return EntityModifier.entity;
+ }
}
- }
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/events/MoveEventFilter.java b/src/main/java/eu/univento/core/api/events/MoveEventFilter.java
index de71feb..fb64b9c 100644
--- a/src/main/java/eu/univento/core/api/events/MoveEventFilter.java
+++ b/src/main/java/eu/univento/core/api/events/MoveEventFilter.java
@@ -13,18 +13,14 @@ import java.util.WeakHashMap;
/**
* @author Crislibaer
*/
-public class MoveEventFilter implements Listener
-{
- public static class PlayerBlockMoveEvent extends PlayerMoveEvent
- {
- public PlayerBlockMoveEvent(PlayerMoveEvent pEvent)
- {
+public class MoveEventFilter implements Listener {
+ public static class PlayerBlockMoveEvent extends PlayerMoveEvent {
+ public PlayerBlockMoveEvent(PlayerMoveEvent pEvent) {
super(pEvent.getPlayer(), pEvent.getFrom(), pEvent.getTo());
}
}
- private static class BlockPosition
- {
+ private static class BlockPosition {
public int x;
public int y;
public int z;
@@ -34,16 +30,13 @@ public class MoveEventFilter implements Listener
private Server mServer;
private WeakHashMap mLastPosition = new WeakHashMap<>();
- public MoveEventFilter(Server pServer)
- {
+ public MoveEventFilter(Server pServer) {
mServer = pServer;
}
@EventHandler
- public void onPlayerMove(PlayerMoveEvent pEvent)
- {
- if(pEvent.isCancelled() || pEvent instanceof PlayerBlockMoveEvent)
- {
+ public void onPlayerMove(PlayerMoveEvent pEvent) {
+ if (pEvent.isCancelled() || pEvent instanceof PlayerBlockMoveEvent) {
return;
}
@@ -51,23 +44,17 @@ public class MoveEventFilter implements Listener
Location currentPos = pEvent.getTo();
boolean fireEvent = false;
- if(lastPos == null)
- {
+ if (lastPos == null) {
lastPos = new BlockPosition();
mLastPosition.put(pEvent.getPlayer(), lastPos);
fireEvent = true;
- }
- else if(lastPos.x != currentPos.getBlockX() || lastPos.z != currentPos.getBlockZ() || lastPos.y != currentPos.getBlockY())
- {
+ } else if (lastPos.x != currentPos.getBlockX() || lastPos.z != currentPos.getBlockZ() || lastPos.y != currentPos.getBlockY()) {
fireEvent = true;
- }
- else if(lastPos.world != currentPos.getWorld())
- {
+ } else if (lastPos.world != currentPos.getWorld()) {
fireEvent = true;
}
- if(fireEvent)
- {
+ if (fireEvent) {
// make sure that our event is synchronous
assert !pEvent.isAsynchronous();
@@ -76,8 +63,7 @@ public class MoveEventFilter implements Listener
mServer.getPluginManager().callEvent(event);
// check event state and only update new position if event does not gets canceled
- if(!event.isCancelled())
- {
+ if (!event.isCancelled()) {
// update new position
lastPos.world = currentPos.getWorld();
lastPos.x = currentPos.getBlockX();
diff --git a/src/main/java/eu/univento/core/api/items/ItemSkulls.java b/src/main/java/eu/univento/core/api/items/ItemSkulls.java
index 665a4ec..4c7e679 100644
--- a/src/main/java/eu/univento/core/api/items/ItemSkulls.java
+++ b/src/main/java/eu/univento/core/api/items/ItemSkulls.java
@@ -14,111 +14,92 @@ import java.lang.reflect.Method;
import java.util.Base64;
import java.util.UUID;
-public class ItemSkulls
-{
- private static Class> skullMetaClass;
- private static Class> tileEntityClass;
- private static Class> blockPositionClass;
- private static int mcVersion;
+public class ItemSkulls {
+ private static Class> skullMetaClass;
+ private static Class> tileEntityClass;
+ private static Class> blockPositionClass;
+ private static int mcVersion;
- static
- {
- String version = org.bukkit.Bukkit.getServer().getClass().getPackage().getName()
- .split("\\.")[3];
- mcVersion = Integer.parseInt(version.replaceAll("[^0-9]", ""));
- try {
- skullMetaClass = Class.forName("org.bukkit.craftbukkit." + version +
- ".inventory.CraftMetaSkull");
- tileEntityClass = Class.forName("net.minecraft.server." + version +
- ".TileEntitySkull");
- if (mcVersion > 174)
- blockPositionClass = Class.forName("net.minecraft.server." +
- version + ".BlockPosition");
- else
- blockPositionClass = null;
+ static {
+ String version = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
+ mcVersion = Integer.parseInt(version.replaceAll("[^0-9]", ""));
+ try {
+ skullMetaClass = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftMetaSkull");
+ tileEntityClass = Class.forName("net.minecraft.server." + version + ".TileEntitySkull");
+ if (mcVersion > 174)
+ blockPositionClass = Class.forName("net.minecraft.server." + version + ".BlockPosition");
+ else
+ blockPositionClass = null;
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
}
- catch (ClassNotFoundException e) {
- e.printStackTrace();
+
+ public static ItemStack getSkull(String skinURL) {
+ return getSkull(skinURL, 1);
}
- }
- public static ItemStack getSkull(String skinURL)
- {
- return getSkull(skinURL, 1);
- }
-
- public static ItemStack getSkull(String skinURL, int amount)
- {
- ItemStack skull = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
- SkullMeta meta = (SkullMeta)skull.getItemMeta();
- try {
- Field profileField = skullMetaClass.getDeclaredField("profile");
- profileField.setAccessible(true);
- profileField.set(meta, getProfile(skinURL));
- } catch (Exception ex) {
- ex.printStackTrace();
+ public static ItemStack getSkull(String skinURL, int amount) {
+ ItemStack skull = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
+ SkullMeta meta = (SkullMeta) skull.getItemMeta();
+ try {
+ Field profileField = skullMetaClass.getDeclaredField("profile");
+ profileField.setAccessible(true);
+ profileField.set(meta, getProfile(skinURL));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ skull.setItemMeta(meta);
+ return skull;
}
- skull.setItemMeta(meta);
- return skull;
- }
- public static boolean setBlock(Location loc, String skinURL)
- {
- return setBlock(loc.getBlock(), skinURL);
- }
-
- public static boolean setBlock(Block block, String skinURL)
- {
- boolean flag = block.getType() == Material.SKULL;
- if (!flag)
- block.setType(Material.SKULL);
- try
- {
- Object nmsWorld = block.getWorld().getClass()
- .getMethod("getHandle", new Class[0]).invoke(block.getWorld(), new Object[0]);
- Object tileEntity = null;
-
- if (mcVersion <= 174) {
- Method getTileEntity = nmsWorld.getClass().getMethod(
- "getTileEntity", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE });
- tileEntity = tileEntityClass.cast(getTileEntity.invoke(
- nmsWorld, new Object[] { Integer.valueOf(block.getX()), Integer.valueOf(block.getY()), Integer.valueOf(block.getZ()) }));
- } else {
- Method getTileEntity = nmsWorld.getClass().getMethod(
- "getTileEntity", new Class[] { blockPositionClass });
- tileEntity = tileEntityClass.cast(getTileEntity.invoke(
- nmsWorld, new Object[] {
- getBlockPositionFor(block.getX(), block.getY(),
- block.getZ()) }));
- }
-
- tileEntityClass.getMethod("setGameProfile", new Class[] { GameProfile.class })
- .invoke(tileEntity, new Object[] { getProfile(skinURL) });
- } catch (Exception ex) {
- ex.printStackTrace();
+ public static boolean setBlock(Location loc, String skinURL) {
+ return setBlock(loc.getBlock(), skinURL);
}
- return !flag;
- }
- private static GameProfile getProfile(String skinURL) {
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- String base64encoded = Base64.getEncoder().encodeToString(
- new String("{textures:{SKIN:{url:\"" + skinURL + "\"}}}")
- .getBytes());
- Property property = new Property("textures", base64encoded);
- profile.getProperties().put("textures", property);
- return profile;
- }
+ public static boolean setBlock(Block block, String skinURL) {
+ boolean flag = block.getType() == Material.SKULL;
+ if (!flag)
+ block.setType(Material.SKULL);
+ try {
+ Object nmsWorld = block.getWorld().getClass().getMethod("getHandle", new Class[0]).invoke(block.getWorld());
+ Object tileEntity = null;
- private static Object getBlockPositionFor(int x, int y, int z) {
- Object blockPosition = null;
- try {
- Constructor> cons = blockPositionClass.getConstructor(new Class[] { Integer.TYPE,
- Integer.TYPE, Integer.TYPE });
- blockPosition = cons.newInstance(new Object[] { Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(z) });
- } catch (Exception ex) {
- ex.printStackTrace();
+ if (mcVersion <= 174) {
+ Method getTileEntity = nmsWorld.getClass().getMethod("getTileEntity", Integer.TYPE, Integer.TYPE, Integer.TYPE);
+ tileEntity = tileEntityClass.cast(getTileEntity.invoke(nmsWorld, block.getX(), block.getY(), block.getZ()));
+ } else {
+ Method getTileEntity = nmsWorld.getClass().getMethod("getTileEntity", blockPositionClass);
+ tileEntity = tileEntityClass.cast(getTileEntity.invoke(
+ nmsWorld, getBlockPositionFor(block.getX(), block.getY(),
+ block.getZ())));
+ }
+
+ tileEntityClass.getMethod("setGameProfile", new Class[]{GameProfile.class})
+ .invoke(tileEntity, getProfile(skinURL));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return !flag;
+ }
+
+ private static GameProfile getProfile(String skinURL) {
+ GameProfile profile = new GameProfile(UUID.randomUUID(), null);
+ String base64encoded = Base64.getEncoder().encodeToString(
+ ("{textures:{SKIN:{url:\"" + skinURL + "\"}}}").getBytes());
+ Property property = new Property("textures", base64encoded);
+ profile.getProperties().put("textures", property);
+ return profile;
+ }
+
+ private static Object getBlockPositionFor(int x, int y, int z) {
+ Object blockPosition = null;
+ try {
+ Constructor> cons = blockPositionClass.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE);
+ blockPosition = cons.newInstance(x, y, z);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return blockPosition;
}
- return blockPosition;
- }
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/languages/Language_DE.java b/src/main/java/eu/univento/core/api/languages/Language_DE.java
index 46eb57d..e715542 100644
--- a/src/main/java/eu/univento/core/api/languages/Language_DE.java
+++ b/src/main/java/eu/univento/core/api/languages/Language_DE.java
@@ -1,7 +1,7 @@
package eu.univento.core.api.languages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.Perms;
+import eu.univento.core.api.player.Ranks;
/**
* @author joethei
@@ -141,7 +141,7 @@ public class Language_DE implements Languages{
}
@Override
- public String Core_SETRANK_SET(CustomPlayer p, Perms.Ranks rank) {
+ public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
return "§7Du hast dem Spieler " + p.getDisplayName() + " auf §e" + rank.toString() + " §7gesetzt";
}
@Override
diff --git a/src/main/java/eu/univento/core/api/languages/Language_EN.java b/src/main/java/eu/univento/core/api/languages/Language_EN.java
index d8a0af6..27326e8 100644
--- a/src/main/java/eu/univento/core/api/languages/Language_EN.java
+++ b/src/main/java/eu/univento/core/api/languages/Language_EN.java
@@ -1,7 +1,7 @@
package eu.univento.core.api.languages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.Perms;
+import eu.univento.core.api.player.Ranks;
/**
* @author joethei
@@ -140,7 +140,7 @@ public class Language_EN implements Languages{
}
@Override
- public String Core_SETRANK_SET(CustomPlayer p, Perms.Ranks rank) {
+ public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
return "§7You gave " + p.getDisplayName() + " the rank §e" + rank.toString();
}
@@ -356,7 +356,7 @@ public class Language_EN implements Languages{
@Override
public String LobbyItems_BUILDSERVER() {
- return "§aBuilding-Server";
+ return "§aBuilding-server";
}
@Override
@@ -406,7 +406,7 @@ public class Language_EN implements Languages{
@Override
public String LobbyItems_PETS_REMOVE() {
- return "§6ride pet";
+ return "§6remove pet";
}
@Override
diff --git a/src/main/java/eu/univento/core/api/languages/Language_IT.java b/src/main/java/eu/univento/core/api/languages/Language_IT.java
index 4be78ad..e8b1806 100644
--- a/src/main/java/eu/univento/core/api/languages/Language_IT.java
+++ b/src/main/java/eu/univento/core/api/languages/Language_IT.java
@@ -1,7 +1,7 @@
package eu.univento.core.api.languages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.Perms;
+import eu.univento.core.api.player.Ranks;
/**
* @author joethei
@@ -140,7 +140,7 @@ public class Language_IT implements Languages{
}
@Override
- public String Core_SETRANK_SET(CustomPlayer p, Perms.Ranks rank) {
+ public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
return "§7Hai dato " + p.getDisplayName() + " il gruppo §e" + rank.toString();
}
@Override
diff --git a/src/main/java/eu/univento/core/api/languages/Languages.java b/src/main/java/eu/univento/core/api/languages/Languages.java
index a74dd53..3146bc5 100644
--- a/src/main/java/eu/univento/core/api/languages/Languages.java
+++ b/src/main/java/eu/univento/core/api/languages/Languages.java
@@ -1,7 +1,7 @@
package eu.univento.core.api.languages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.Perms;
+import eu.univento.core.api.player.Ranks;
/**
* @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, Perms.Ranks rank);
+ String Core_SETRANK_SET(CustomPlayer p, Ranks rank);
String Core_TS_ALLREADY_VERIFIED();
String Core_TS_VERIFIED();
String Core_VANISH_ON();
diff --git a/src/main/java/eu/univento/core/api/languages/Messages.java b/src/main/java/eu/univento/core/api/languages/Messages.java
index f7bea72..78232f3 100644
--- a/src/main/java/eu/univento/core/api/languages/Messages.java
+++ b/src/main/java/eu/univento/core/api/languages/Messages.java
@@ -1,7 +1,7 @@
package eu.univento.core.api.languages;
import eu.univento.core.api.player.CustomPlayer;
-import eu.univento.core.api.player.Perms;
+import eu.univento.core.api.player.Ranks;
/**
@@ -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, Perms.Ranks rank) {
+ public String Core_SETRANK_SET(CustomPlayer p, Ranks rank) {
return lang.Core_SETRANK_SET(p, rank);
}
public String Core_TS_ALLREADY_VERIFIED() {
diff --git a/src/main/java/eu/univento/core/api/map/Map.java b/src/main/java/eu/univento/core/api/map/Map.java
index 901b65f..9d50a88 100644
--- a/src/main/java/eu/univento/core/api/map/Map.java
+++ b/src/main/java/eu/univento/core/api/map/Map.java
@@ -11,11 +11,13 @@ public class Map {
private String name;
private String builder;
private Material item;
+ private String download;
- public Map(String name, String builder, Material item) {
+ public Map(String name, String builder, Material item, String download) {
this.name = name;
this.builder = builder;
this.item = item;
+ this.download = download;
}
public String getName() {
@@ -29,4 +31,8 @@ public class Map {
public Material getItem() {
return item;
}
+
+ public String getDownloadLink() {
+ return download;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/eu/univento/core/api/map/MapDatabase.java b/src/main/java/eu/univento/core/api/map/MapDatabase.java
index 4f30c95..a218a75 100644
--- a/src/main/java/eu/univento/core/api/map/MapDatabase.java
+++ b/src/main/java/eu/univento/core/api/map/MapDatabase.java
@@ -15,9 +15,9 @@ public class MapDatabase {
public static ArrayList