() {
- @Override
- protected void initChannel(Channel channel) throws Exception {
-
- }
- });
- bootstrap.connect("master.univento.eu", 8000).sync().channel().closeFuture().sync();
- }finally {
- child.shutdownGracefully();
- }
-}
-
-}
\ No newline at end of file
diff --git a/src/eu/univento/core/Core.java b/src/eu/univento/core/Core.java
deleted file mode 100644
index 23db3a0..0000000
--- a/src/eu/univento/core/Core.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package eu.univento.core;
-
-import eu.univento.core.api.BossBar;
-import eu.univento.core.api.Config;
-import eu.univento.core.api.SignInput;
-import eu.univento.core.api.database.MySQL;
-import eu.univento.core.api.events.MoveEventFilter;
-import eu.univento.core.api.fakeplayer.PlayerKi;
-import eu.univento.core.api.player.TeamSpeak;
-import eu.univento.core.api.server.ServerSettings;
-import eu.univento.core.commands.*;
-import eu.univento.core.listeners.*;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * main class
- * @author joethei
- * @version 1.0
- */
-public class Core extends JavaPlugin{
-
- //TODO: rewrite time critical database functions from MySQL to MongoDB
-
- /**
- * plugin instance
- */
- public static Core instance;
- /**
- * @return plugin instance
- */
- public static Core getInstance() {
- return instance;
- }
-
- /**
- * 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"));
- /**
- * @return sql
- */
- public static MySQL returnSQL() {
- return sql;
- }
-
- private static TeamSpeak ts;
-
- public static TeamSpeak getTs() {
- return ts;
- }
- /**
- * logging and stuff
- */
- private static Logger log = Bukkit.getLogger();
-
- /**
- * @param level Log level
- * @param string String
- */
- public static void log(Level level, String string) {
- if(ServerSettings.isDebug()) {
- log.log(level, "[Core] " + string);
- }
- }
-
- private SignInput signInput;
-
- public SignInput getSignInput() {
- return signInput;
- }
-
- @Override
- public void onEnable() {
- ServerSettings.setDebug(true);
- try {
- Config.writeDefault();
- } catch (ClassNotFoundException | SQLException | IOException e) {
- e.printStackTrace();
- }
- instance = this;
- this.signInput = new SignInput(this);
- if(ServerSettings.isDebug()) log(Level.INFO, "Debug Modus aktiviert");
- PluginManager pm = Bukkit.getPluginManager();
- pm.registerEvents(new Commands(), this);
- pm.registerEvents(new JoinQuit(), this);
- pm.registerEvents(new Chat(), this);
- pm.registerEvents(new Blocks(), this);
- pm.registerEvents(new Events(), this);
- pm.registerEvents(new MoveEventFilter(getServer()), this);
- pm.registerEvents(new BossBar(), this);
- pm.registerEvents(new PlayerKi(), this);
-
- log(Level.INFO, "Events registriert");
-
- String[] fix = {""};
- if(ServerSettings.isGame()) new Fix(this, "fix", "Fixe dich oder andere Spieler", fix);
-
- String[] runas = {""};
- new RunAs(this, "RunAs", "Sende einen Befehl als ein anderer Spieler", runas);
-
- String[] systeminfo = {""};
- new SystemInfo(this, "SystemInfo", "Gibt Infos über den ServerPinger aus", systeminfo);
-
- String[] vanish = {""};
- new Vanish(this, "vanish", "Lässt dich verschwinden", vanish);
-
- String[] gamemode = {"gm"};
- new GameMode(this, "gamemode" , "Setzt deinen GameMode", gamemode);
-
- String[] setrank = {"sr"};
- new SetRank(this, "setrank" , "Setzt den Rang eines Spielers", setrank);
-
- String[] globalmute = {"globalmute"};
- new GlobalMute(this, "globalmute", "Muted den gesamten ServerPinger", globalmute);
-
- String[] youtuber = {""};
- new Youtuber(this, "youtuber", "setzt Spieler in den Youtuber Rang", youtuber);
-
- String[] ts = {""};
- new TS(this, "ts", "verifiziert Spieler auf dem TS", ts);
-
- String[] ban = {""};
- new Ban(this, "ban", "Bannt Spieler", ban);
-
- String[] build = {"b"};
- new Build(this, "build", "Setzt den Spieler in den Bau Modus", build);
-
- String[] chatclear = {"cc"};
- new ChatClear(this, "chatclear", "Cleart den Chat", chatclear);
-
- if(ServerSettings.isGame()) {
- String[] nick = {""};
- new Nick(this, "nick", "ändert das Verhalten des Nicksystems", nick);
- log(Level.INFO, "/nick aktiviert");
- }
-
- log(Level.INFO, "Alle Befehle registriert");
-
- Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
-
- this.ts = new TeamSpeak();
-
- log(Level.INFO, "Plugin ver. " + getDescription().getVersion() + " gestartet");
- }
-
- @Override
- public void onDisable() {
- log(Level.INFO, "Plugin beendet");
- getTs().disconnect();
- }
-
-}
\ No newline at end of file
diff --git a/src/eu/univento/core/api/Actionbar.java b/src/eu/univento/core/api/Actionbar.java
deleted file mode 100644
index 924b36d..0000000
--- a/src/eu/univento/core/api/Actionbar.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package eu.univento.core.api;
-
-import net.minecraft.server.v1_8_R3.IChatBaseComponent;
-import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
-import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class Actionbar {
-
- public static void send(Player player, String message){
- CraftPlayer p = (CraftPlayer) player;
- IChatBaseComponent cbc = ChatSerializer.a("{\"text\": \"" + message + "\"}");
- PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc,(byte) 2);
- ((CraftPlayer) p).getHandle().playerConnection.sendPacket(ppoc);
- }
-
-}
diff --git a/src/eu/univento/core/api/AutoCommand.java b/src/eu/univento/core/api/AutoCommand.java
deleted file mode 100644
index 2644456..0000000
--- a/src/eu/univento/core/api/AutoCommand.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package eu.univento.core.api;
-
-import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandMap;
-import org.bukkit.command.CommandSender;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author PostCrafter
- * @see href http://postcrafter.de/viewtopic.php?f=15&t=143
- * @param main class
- */
-public abstract class AutoCommand
extends Command {
-
- private static String VERSION;
-
- static {
- String path = Bukkit.getServer().getClass().getPackage().getName();
-
- AutoCommand.VERSION = path.substring(path.lastIndexOf(".") + 1, path.length());
-
- System.out.println("[PostLib] AutoCommand hook for Bukkit " + AutoCommand.VERSION);
- }
-
- protected final P plugin;
- protected final String command;
-
- public AutoCommand(P plugin, String command, String description, String... aliases) {
- super(command);
- this.plugin = plugin;
- this.command = command;
-
- super.setDescription(description);
- List aliasList = new ArrayList();
- for (String alias : aliases) {
- aliasList.add(alias);
- }
- super.setAliases(aliasList);
-
- this.register();
- }
-
- public void register() {
- try {
- Field f = Class.forName("org.bukkit.craftbukkit." + AutoCommand.VERSION + ".CraftServer").getDeclaredField("commandMap");
- f.setAccessible(true);
-
- CommandMap map = (CommandMap) f.get(Bukkit.getServer());
- map.register(this.plugin.getName(), this);
- } catch (Exception exc) {
- exc.printStackTrace();
- }
- }
-
- public abstract boolean execute(CommandSender sender, String label, String[] args);
-
- public abstract List tabComplete(CommandSender sender, String label, String[] args);
-
- public String buildString(String[] args, int start) {
- String str = "";
- if (args.length > start) {
- str += args[start];
- for (int i = start + 1; i < args.length; i++) {
- str += " " + args[i];
- }
- }
- return str;
- }
-
- public P getPlugin() {
- return this.plugin;
- }
-}
diff --git a/src/eu/univento/core/api/Blackscreen.java b/src/eu/univento/core/api/Blackscreen.java
deleted file mode 100644
index acad260..0000000
--- a/src/eu/univento/core/api/Blackscreen.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package eu.univento.core.api;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- *
- * @author janhektor
- *
- */
-public class Blackscreen
-{
- private static Object packetObject;
- private static Class> packetClass;
- private static String VERSION;
- private static Map ticksLeft = new HashMap();
-
- static { String path = Bukkit.getServer().getClass().getPackage().getName();
- VERSION = path.substring(path.lastIndexOf(".") + 1, path.length());
- try {
- packetClass = Class.forName("net.minecraft.server." + VERSION + ".Packet");
- Class> packetGameStateClass = Class.forName("net.minecraft.server." + VERSION + ".PacketPlayOutGameStateChange");
- packetObject = packetGameStateClass.getConstructor(new Class[] { Integer.TYPE, Float.TYPE }).newInstance(new Object[] { Integer.valueOf(4), Integer.valueOf(0) });
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public static void setupUtil(Plugin instance)
- {
- setupUtil(instance, 2);
- }
-
- public static void setupUtil(Plugin instance, int repeatingTicks)
- {
- Bukkit.getScheduler().runTaskTimer(instance, new Runnable()
- {
- public void run()
- {
- for (UUID uuid : Blackscreen.ticksLeft.keySet()) {
- Player p = Bukkit.getPlayer(uuid);
- if (p == null) {
- Blackscreen.ticksLeft.remove(uuid);
- }
- else if (((Integer)Blackscreen.ticksLeft.get(uuid)).intValue() > 0) {
- Blackscreen.ticksLeft.put(uuid, Integer.valueOf(((Integer)Blackscreen.ticksLeft.get(uuid)).intValue() - 2));
- Blackscreen.access(p);
- } else {
- Blackscreen.ticksLeft.remove(uuid);
- }
- }
- }
- }
- , 0L, repeatingTicks);
- }
-
- protected static void access(Player p) {
-
-}
-
-private static void sendPacket(Player p) {
- try {
- Object nmsPlayer = p.getClass().getMethod("getHandle", new Class[0]).invoke(p, new Object[0]);
- Field playerConnectionField = nmsPlayer.getClass().getField("playerConnection");
- Object pConnection = playerConnectionField.get(nmsPlayer);
- Method sendPacket = pConnection.getClass().getMethod("sendPacket", new Class[] { packetClass });
- sendPacket.invoke(pConnection, new Object[] { packetObject });
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public static void setBlack(Player p, int seconds)
- {
- ticksLeft.put(p.getUniqueId(), Integer.valueOf(seconds * 20));
- sendPacket(p);
- }
-}
\ No newline at end of file
diff --git a/src/eu/univento/core/api/BossBar.java b/src/eu/univento/core/api/BossBar.java
deleted file mode 100644
index 847249e..0000000
--- a/src/eu/univento/core/api/BossBar.java
+++ /dev/null
@@ -1,301 +0,0 @@
-package eu.univento.core.api;
-
-import eu.univento.core.Core;
-import eu.univento.core.api.utils.FDragon;
-import eu.univento.core.api.utils.FWither;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Thanks for chasechocolate and BigTeddy98 for the tutorial
- * it is based on the code by them and some other tutorial
- * https://forums.bukkit.org/threads/util-set-a-players-boss-bar-nms.245073/
- * https://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar.158018/
- * @author Marzouki Ghofrane , mgone CraftZone.fr
- */
-
-
-public class BossBar implements Listener {
-
-
- public static Plugin plugin;
- public static Map playerdragonbartask = new HashMap<>();
- public static Map healthdragonbartask = new HashMap<>();
- public static Map cooldownsdragonbar= new HashMap<>();
- public static Map starttimerdragonbar= new HashMap<>();
-
- public static Map playerwitherbartask = new HashMap<>();
- public static Map healthwitherbartask = new HashMap<>();
- public static Map cooldownswitherbar= new HashMap<>();
- public static Map starttimerwitherbar= new HashMap<>();
-
- public void DragonBarTask() {
-
- new BukkitRunnable() {
-
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for(Player p : plugin.getServer().getOnlinePlayers()){
-
- if(!cooldownsdragonbar.containsKey(p)) {
-
- if(playerdragonbartask.containsKey(p) && !healthdragonbartask.containsKey(p)) { setBarDragon(p, playerdragonbartask.get(p)); }
- else if(playerdragonbartask.containsKey(p) && healthdragonbartask.containsKey(p)) { setBarDragonHealth(p, playerdragonbartask.get(p), healthdragonbartask.get(p)); }
-
- }
-
- if(!cooldownswitherbar.containsKey(p)) {
-
- if(playerwitherbartask.containsKey(p) && !healthwitherbartask.containsKey(p)) { setBarWither(p, playerwitherbartask.get(p)); }
- else if(playerwitherbartask.containsKey(p) && healthwitherbartask.containsKey(p)) { setBarWitherHealth(p, playerwitherbartask.get(p), healthwitherbartask.get(p)); }
-
- }
-
- }
- }
- }.runTaskTimer(Core.getInstance(), 0, 40);
-
-
-
-
- new BukkitRunnable() {
-
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for(Player p : plugin.getServer().getOnlinePlayers()){
-
- if(cooldownsdragonbar.containsKey(p)) {
-
- if(cooldownsdragonbar.get(p) > 0)
- { cooldownsdragonbar.put(p,cooldownsdragonbar.get(p)-1); setBarDragonTimer(p, playerdragonbartask.get(p), cooldownsdragonbar.get(p)); }
- else removeBarDragon(p);
-
- }
-
-
- if(cooldownswitherbar.containsKey(p)) {
-
- if(cooldownswitherbar.get(p) > 0)
- { cooldownswitherbar.put(p,cooldownswitherbar.get(p)-1); setBarWitherTimer(p, playerwitherbartask.get(p), cooldownswitherbar.get(p)); }
- else removeBarWither(p);
-
- }
-
- }
- }
- }.runTaskTimer(Core.getInstance(), 0, 20);
-
-
- }
-
-
-
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
- public void PlayerQuit(PlayerQuitEvent event) {
- Player p = event.getPlayer();
- removeBar(p);
- FDragon.removehorligneD(p);
- FWither.removehorligneW(p);
- }
-
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
- public void PlayerKick(PlayerKickEvent event) {
- Player p = event.getPlayer();
- removeBar(p);
- FDragon.removehorligneD(p);
- FWither.removehorligneW(p);
- }
-
-
- //dragon
-
-
-
- public static void setBarDragon(Player p, String text) {
- playerdragonbartask.put(p, text);
- FDragon.setBossBartext(p, text);
- }
-
-
- public static void setBarDragonHealth(Player p, String text, float health) {
- if(health<=0 || health >100) { health = 100; text = "health must be between 1 and 100 it's a %";}
- playerdragonbartask.put(p, text);
- healthdragonbartask.put(p, (health/100)*200);
- FDragon.setBossBar(p, text, health);
- }
-
- public static void setBarDragonTimer(Player p, String text, int timer) {
- playerdragonbartask.put(p, text);
- cooldownsdragonbar.put(p, timer);
- if(!starttimerdragonbar.containsKey(p)) starttimerdragonbar.put(p, timer);
- int unite = Math.round(200/starttimerdragonbar.get(p));
- FDragon.setBossBar(p, text, unite*timer);
-
- }
-
-
- public static void removeBarDragon(Player p) {
- playerdragonbartask.remove(p);
- healthdragonbartask.remove(p);
- cooldownsdragonbar.remove(p);
- starttimerdragonbar.remove(p);
- FDragon.removeBossBar(p);
- }
-
- public static boolean hasBarDragon(Player p) {
- return playerdragonbartask.get(p) != null;
- }
-
-
- public static String getMessageDragon(Player p) {
- if(playerdragonbartask.containsKey(p)) return playerdragonbartask.get(p);
- else return " ";
- }
-
-
-
-
- //wither
-
- public static void setBarWither(Player p, String text) {
- playerwitherbartask.put(p, text);
- FWither.setBossBartext(p, text);
- }
-
-
- public static void setBarWitherHealth(Player p, String text, float health) {
- if(health<=0 || health >100) { health = 100; text = "health must be between 1 and 100 it's a %";}
- playerwitherbartask.put(p, text);
- healthwitherbartask.put(p, (health/100)*300);
- FWither.setBossBar(p, text, health);
- }
-
- public static void setBarWitherTimer(Player p, String text, int timer) {
- playerwitherbartask.put(p, text);
- cooldownswitherbar.put(p, timer);
- if(!starttimerwitherbar.containsKey(p)) starttimerwitherbar.put(p, timer);
- int unite = Math.round(300/starttimerwitherbar.get(p));
- FWither.setBossBar(p, text, unite*timer);
-
- }
-
-
- public static void removeBarWither(Player p) {
- playerwitherbartask.remove(p);
- healthwitherbartask.remove(p);
- cooldownswitherbar.remove(p);
- starttimerwitherbar.remove(p);
- FWither.removeBossBar(p);
- }
-
- public static boolean hasBarWither(Player p) {
- return playerwitherbartask.get(p) != null;
- }
-
-
- public static String getMessageWither(Player p) {
- if(playerwitherbartask.containsKey(p)) return playerwitherbartask.get(p);
- else return " ";
- }
-
-
-
-
-
- //both
-
- public static void setBar(Player p, String text) {
- if(McVersion(p)) {
- playerwitherbartask.put(p, text);
- FWither.setBossBartext(p, text); }
-
- playerdragonbartask.put(p, text);
- FDragon.setBossBartext(p, text);
- }
-
-
- public static void setBarHealth(Player p, String text, float health) {
- if(health<=0 || health >100) { health = 100; text = "health must be between 1 and 100 it's a %";}
- if(McVersion(p)) {
- playerwitherbartask.put(p, text);
- healthwitherbartask.put(p, (health/100)*300);
- FWither.setBossBar(p, text, health); }
-
- playerdragonbartask.put(p, text);
- healthdragonbartask.put(p, (health/100)*200);
- FDragon.setBossBar(p, text, health);
- }
-
- public static void setBarTimer(Player p, String text, int timer) {
- if(McVersion(p)) {
- playerwitherbartask.put(p, text);
- cooldownswitherbar.put(p, timer);
- if(!starttimerwitherbar.containsKey(p)) starttimerwitherbar.put(p, timer);
- int unite = Math.round(300/starttimerwitherbar.get(p));
- FWither.setBossBar(p, text, unite*timer); }
-
- playerdragonbartask.put(p, text);
- cooldownsdragonbar.put(p, timer);
- if(!starttimerdragonbar.containsKey(p)) starttimerdragonbar.put(p, timer);
- int unite1 = Math.round(200/starttimerdragonbar.get(p));
- FDragon.setBossBar(p, text, unite1*timer);
-
- }
-
-
- public static void removeBar(Player p) {
- if(McVersion(p)) {
- playerwitherbartask.remove(p);
- healthwitherbartask.remove(p);
- cooldownswitherbar.remove(p);
- starttimerwitherbar.remove(p);
- FWither.removeBossBar(p); }
-
- playerdragonbartask.remove(p);
- healthdragonbartask.remove(p);
- cooldownsdragonbar.remove(p);
- starttimerdragonbar.remove(p);
- FDragon.removeBossBar(p);
- }
-
- public static boolean hasBar(Player p) {
-
- if(McVersion(p)) {
-
- if(playerwitherbartask.containsKey(p) && playerdragonbartask.containsKey(p))
- return true;
- else return false; }
-
-
- else {
-
- return playerdragonbartask.get(p) != null;
- }
- }
-
-
- public static String getMessage(Player p) {
- if(playerdragonbartask.containsKey(p)) return playerdragonbartask.get(p);
- else return " ";
- }
-
-
-
-
- public static boolean McVersion(Player p) {
- return true;
- }
-
-}
diff --git a/src/eu/univento/core/api/Config.java b/src/eu/univento/core/api/Config.java
deleted file mode 100644
index db310da..0000000
--- a/src/eu/univento/core/api/Config.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package eu.univento.core.api;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-
-/**
- * gets data from config file
- * @author joethei
- * @version 1.1
- */
-public class Config {
-
- /**config file*/
- private static File file = new File("plugins/Core", "config.yml");
- /**load configuration */
- private static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
-
- /**
- * write default data to config
- * @throws ClassNotFoundException Class couldn't be found
- * @throws SQLException SQL server not available or throwing error
- * @throws IOException I/O failed
- */
- public static void writeDefault() throws ClassNotFoundException, SQLException, IOException {
- //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.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.options().copyDefaults(true);
- cfg.save(file);
-
- }
-
- /**
- * write data as string to config
- * @param path path to data
- * @param obj data
- */
- public static void write(String path, String obj) {
- cfg.set(path, obj);
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * write data as integer to config
- * @param path path to data
- * @param obj data
- */
- public static void write(String path, int obj) {
- cfg.set(path, obj);
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * write data as double to config
- * @param path path to data
- * @param obj data
- */
- public static void write(String path, double obj) {
- cfg.set(path, obj);
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * write location to config
- * @param path path to data
- * @param loc location
- */
- public static void write(String path, Location loc) {
- String world = loc.getWorld().getName();
- double x = loc.getX();
- double y = loc.getY();
- double z = loc.getZ();
- double yaw = (double) loc.getYaw();
- double pitch = (double) loc.getPitch();
-
- cfg.set(path + ".World", world);
- cfg.set(path + ".X", x);
- cfg.set(path + ".Y", y);
- cfg.set(path + ".Z", z);
- cfg.set(path + ".Yaw", yaw);
- cfg.set(path + ".Pitch", pitch);
-
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * read integer from config
- * @param path path to data
- * @return Integer
- */
- public static int readInt(String path) {
- return cfg.getInt(path);
- }
-
- /**
- * read double from config
- * @param path path to data
- * @return Double
- */
- public static double readDouble(String path) {
- return cfg.getDouble(path);
- }
-
- /**
- * read string from config
- * @param path path to data
- * @return String
- */
- public static String readString(String path) {
- return cfg.getString(path);
- }
-
- /**
- * read location from config
- * @param path path to data
- * @return Location
- */
- public static Location readLocation(String path) {
- String world = cfg.getString(path + ".World");
- double x = cfg.getDouble(path + ".X");
- double y = cfg.getDouble(path + ".Y");
- double z = cfg.getDouble(path + ".Z");
- float yaw = (float) cfg.getDouble(path + ".Yaw");
- float pitch = (float) cfg.getDouble(path + ".Pitch");
-
- Location loc = new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
- return loc;
- }
-
- /**
- * checks if data is existing
- * @param path path do data
- * @return true / false
- */
- public static boolean isExsisting(String path) {
- return cfg.contains(path);
- }
-
-}
\ No newline at end of file
diff --git a/src/eu/univento/core/api/Hologram.java b/src/eu/univento/core/api/Hologram.java
deleted file mode 100644
index 635d9ea..0000000
--- a/src/eu/univento/core/api/Hologram.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package eu.univento.core.api;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-
-public class Hologram
-{
- private List lines;
- private Location loc;
- private static final double ABS = 0.23D;
- private static String path = Bukkit.getServer().getClass().getPackage().getName();
- private static String version = path.substring(path.lastIndexOf(".") + 1, path.length());
- private static Class> armorStand;
- private static Class> worldClass;
- private static Class> nmsEntity;
- private static Class> craftWorld;
- private static Class> packetClass;
- private static Class> entityLivingClass;
- private static Constructor> armorStandConstructor;
- private static Class> nmsPacket;
-
- static
- {
- try
- {
- armorStand = Class.forName("net.minecraft.server." + version +
- ".EntityArmorStand");
- worldClass = Class.forName("net.minecraft.server." + version +
- ".World");
- nmsEntity = Class.forName("net.minecraft.server." + version +
- ".Entity");
- craftWorld = Class.forName("org.bukkit.craftbukkit." + version +
- ".CraftWorld");
- packetClass = Class.forName("net.minecraft.server." + version +
- ".PacketPlayOutSpawnEntityLiving");
- entityLivingClass = Class.forName("net.minecraft.server." + version +
- ".EntityLiving");
- armorStandConstructor = armorStand
- .getConstructor(new Class[] { worldClass });
-
- nmsPacket = Class.forName("net.minecraft.server." + version +
- ".Packet");
- }
- catch (java.lang.NoSuchMethodException ex) {
- System.err.println("Error - Classes not initialized!");
- ex.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- public Hologram(Location loc, List lines) {
- this.lines = lines;
- this.loc = loc;
- }
-
- public boolean display(Player p)
- {
- Location displayLoc = this.loc.clone().add(0.0D, 0.23D * this.lines.size() - 1.97D,
- 0.0D);
- for (int i = 0; i < this.lines.size(); i++) {
- Object packet = null;
- try {
- packet = getPacket(this.loc.getWorld(),
- displayLoc.getX(), displayLoc.getY(), displayLoc.getZ(),
- this.lines.get(i));
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- if (packet == null)
- return false;
- sendPacket(p, packet);
- displayLoc.add(0.0D, -0.23D, 0.0D);
- }
-
- return true;
- }
-
- private Object getPacket(World w, double x, double y, double z, String text) throws NoSuchMethodException {
- try {
- Object craftWorldObj = craftWorld.cast(w);
- Method getHandleMethod = craftWorldObj.getClass().getMethod(
- "getHandle", new Class[0]);
- Object entityObject = armorStandConstructor
- .newInstance(new Object[] { getHandleMethod
- .invoke(craftWorldObj, new Object[0]) });
- Method setCustomName = entityObject.getClass().getMethod(
- "setCustomName", new Class[] { String.class });
- setCustomName.invoke(entityObject, new Object[] { text });
- Method setCustomNameVisible = nmsEntity.getMethod(
- "setCustomNameVisible", new Class[] { Boolean.TYPE });
- setCustomNameVisible.invoke(entityObject, new Object[] { Boolean.valueOf(true) });
- Method setGravity = entityObject.getClass().getMethod("setGravity",
- new Class[] { Boolean.TYPE });
- setGravity.invoke(entityObject, new Object[] { Boolean.valueOf(false) });
- Method setLocation = entityObject.getClass().getMethod(
- "setLocation",
- new Class[] { Double.TYPE, Double.TYPE, Double.TYPE,
- Float.TYPE, Float.TYPE });
- setLocation.invoke(entityObject,
- new Object[] { Double.valueOf(x), Double.valueOf(y), Double.valueOf(z), Float.valueOf(0.0F), Float.valueOf(0.0F) });
- Method setInvisible = entityObject.getClass().getMethod(
- "setInvisible", new Class[] { Boolean.TYPE });
- setInvisible.invoke(entityObject, new Object[] { Boolean.valueOf(true) });
- Constructor> cw = packetClass
- .getConstructor(new Class[] { entityLivingClass });
- Object packetObject = cw.newInstance(new Object[] { entityObject });
- return packetObject;
- }
- catch (java.lang.SecurityException e)
- {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private void sendPacket(Player p, Object packet) {
- try {
- Method getHandle = p.getClass().getMethod("getHandle", new Class[0]);
- Object entityPlayer = getHandle.invoke(p, new Object[0]);
- Object pConnection = entityPlayer.getClass()
- .getField("playerConnection").get(entityPlayer);
- Method sendMethod = pConnection.getClass().getMethod("sendPacket",
- new Class[] { nmsPacket });
- sendMethod.invoke(pConnection, new Object[] { packet });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-public static double getAbs() {
- return ABS;
-}
-}
\ No newline at end of file
diff --git a/src/eu/univento/core/api/SignInput.java b/src/eu/univento/core/api/SignInput.java
deleted file mode 100644
index 314a813..0000000
--- a/src/eu/univento/core/api/SignInput.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package eu.univento.core.api;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToMessageDecoder;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.plugin.Plugin;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Consumer;
-
-
-/**
- * @author Janhektor This class in licensed under GPLv3 For more information
- * look at http://www.gnu.org/licenses/gpl-3.0
- */
-public final class SignInput implements Listener, Runnable {
-
- private final static String VERSION;
-
- static {
- String path = Bukkit.getServer().getClass().getPackage().getName();
- VERSION = path.substring(path.lastIndexOf(".") + 1, path.length());
- }
-
- private final Plugin plugin;
- private final Map> inputResults;
-
- public SignInput(Plugin plugin) {
- this.plugin = plugin;
- this.inputResults = new HashMap>();
- Bukkit.getScheduler().runTaskTimer(this.plugin, this, 0L, 20 * 3L);
-
- }
-
- /**
- * Use this method to read the SignInput from a player The accept()-method
- * of your consumer will be called, when the player close the sign
- *
- * @return boolean successful
- * @param p
- * - The Player, who have to type an input
- * @param result
- * - The consumer (String[]) for the result; String[] contains
- * strings for 4 lines
- */
- public boolean readInput(Player p, Consumer result) {
- inputResults.put(p.getUniqueId(), result);
- try {
- Class> packetClass = Class.forName(getNMSClass("PacketPlayOutOpenSignEditor"));
- Class> blockPositionClass = Class.forName(getNMSClass("BlockPosition"));
- Constructor> blockPosCon = blockPositionClass
- .getConstructor(new Class[] { int.class, int.class, int.class });
- Object blockPosition = blockPosCon.newInstance(new Object[] { 0, 0, 0 });
- Constructor> packetCon = packetClass.getConstructor(new Class[] { blockPositionClass });
- Object packet = packetCon.newInstance(new Object[] { blockPosition });
-
- Method getHandle = p.getClass().getMethod("getHandle");
- Object nmsPlayer = getHandle.invoke(p);
- Field pConnectionField = nmsPlayer.getClass().getField("playerConnection");
- Object pConnection = pConnectionField.get(nmsPlayer);
- Method sendMethod = pConnection.getClass().getMethod("sendPacket",
- new Class[] { Class.forName(getNMSClass("Packet")) });
- sendMethod.invoke(pConnection, new Object[] { packet });
- return true;
- } catch (Exception ex) {
- ex.printStackTrace();
- return false;
- }
- }
-
- /* Garbage Collection */
- @Override
- public void run() {
- for (UUID uuid : inputResults.keySet()) {
- if (Bukkit.getPlayer(uuid) == null)
- inputResults.remove(uuid);
- }
- }
-
- /* Events */
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- Player p = e.getPlayer();
- getNettyChannel(p).pipeline().addAfter("decoder", "signListener", new MessageToMessageDecoder