Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <>-- KnockIT --<>
- @EventHandler
- public void onMove(PlayerMoveEvent e) {
- Player p = e.getPlayer();
- File file = new File("plugins//KnockIT//locations.yml");
- YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- if ((p.getLocation().getY() < cfg.getDouble("Todesgrenze.Y")))
- {
- ItemStack stick = createItem(Material.STICK, 1, "§5Knüppel");
- stick.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
- ItemStack enterhaken = createItem(Material.FISHING_ROD, 1, "§5Enterhaken");
- ItemStack boots = createItem(Material.DIAMOND_BOOTS, 1, "§5Yeezy Boost 9000");
- ItemStack leave = createItem(Material.MAGMA_CREAM, 1, "§cZurück zur Lobby §7§o<Rechtsklick>");
- PlayerHandler.clearPlayer(p);
- Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
- public void run() {
- p.getInventory().setItem(0, stick);
- p.getInventory().setItem(1, enterhaken);
- p.getInventory().setItem(8, leave);
- p.getInventory().setBoots(boots);
- }
- }, 10L);
- p.teleport(Main.getConfigManager().LoadLocation(Main.map + ".Spawn"));
- if (Main.killer.containsKey(p))
- {
- Player killer = (Player)Main.killer.get(p);
- p.sendMessage(Main.prefix + "§7Du wurdest von §e" + killer.getDisplayName() + " §7getötet!");
- killer.sendMessage(Main.prefix + "§7Du hast §e" + p.getDisplayName() + " §7getötet!");
- p.playSound(p.getLocation(), Sound.ZOMBIE_DEATH, 1.0F, 1.0F);
- killer.playSound(killer.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
- killer.sendMessage(Main.prefix + "§a+1 Punkt");
- killer.sendMessage(me.cakegames.CoinsAPI.Main.global + "§a+1 Cake");
- StatsAPI.addDeaths(p.getUniqueId().toString(), Integer.valueOf(1));
- StatsAPI.addKills(killer.getUniqueId().toString(), Integer.valueOf(1));
- StatsAPI.addPoints(killer.getUniqueId().toString(), Integer.valueOf(1));
- me.cakegames.CoinsAPI.CoinsAPI.addCakes(killer.getUniqueId().toString(), Integer.valueOf(1));
- Main.killer.remove(killer);
- killer.setLevel(killer.getLevel() + 1);
- PlayerHandler.clearPlayer(p);
- p.spigot().respawn();
- Main.killer.remove(p);
- }
- else
- {
- p.sendMessage(Main.prefix + "§cDu bist runtergefallen!");
- StatsAPI.addDeaths(p.getUniqueId().toString(), Integer.valueOf(1));
- p.playSound(p.getLocation(), Sound.ZOMBIE_DEATH, 1.0F, 1.0F);
- PlayerHandler.clearPlayer(p);
- p.spigot().respawn();
- }
- }
- if (p.getHealth() < 20.0D) {
- p.setHealth(20.0D);
- }
- }
- @EventHandler
- public void onDeath(PlayerDeathEvent e) {
- Player p = e.getEntity();
- e.getDrops().clear();
- e.setDeathMessage(null);
- PlayerHandler.clearPlayer(p);
- p.teleport(Main.getConfigManager().LoadLocation("Spawn"));
- }
- @EventHandler
- public void onRespawn(PlayerRespawnEvent e) {
- Player p = e.getPlayer();
- ItemStack stick = createItem(Material.STICK, 1, "§5Knüppel");
- stick.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
- ItemStack enterhaken = createItem(Material.FISHING_ROD, 1, "§5Enterhaken");
- ItemStack boots = createItem(Material.DIAMOND_BOOTS, 1, "§5Yeezy Boost 9000");
- ItemStack leave = createItem(Material.MAGMA_CREAM, 1, "§cZurück zur Lobby §7§o<Rechtsklick>");
- Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
- public void run() {
- p.getInventory().setItem(0, stick);
- p.getInventory().setItem(1, enterhaken);
- p.getInventory().setItem(8, leave);
- p.getInventory().setBoots(boots);
- }
- }, 10L);
- p.teleport(Main.getConfigManager().LoadLocation("Spawn"));
- }
- @EventHandler
- public void onLogin(PlayerLoginEvent e)
- {
- Player p = e.getPlayer();
- if(Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers()) {
- if(p.hasPermission("system.premiumjoin")) {
- for(Player players : Bukkit.getOnlinePlayers()) {
- if(!players.hasPermission("system.premiumjoin")) {
- players.kickPlayer(Main.system + "§cDu wurdest auf die Lobby gesendet, um einem Spieler mit §ehöheren Rang §cPlatz zu machen!");
- e.allow();
- return;
- }
- }
- e.disallow(null, Main.global + "§cDer Server ist voll!");
- }
- e.disallow(null, Main.global + "§cDer Server ist voll! §cDu brauchst ein §ehöheren Rang §cum trotzdem joinen zu können!");
- }
- }
- public class MySQL
- {
- public static String username;
- public static String password;
- public static String database;
- public static String host;
- public static String port;
- public static Connection con;
- public MySQL(String user, String pass, String host2, String dB) {}
- public static void connect()
- {
- if (!isConnected()) {
- try
- {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true", username, password);
- System.out.println(Main.console + "Die MySQL Verbindung wurde erfolgreich hergestellt!");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static void close()
- {
- if (isConnected()) {
- try
- {
- con.close();
- System.out.println(Main.console + "Die MySQL Verbindung wurde erfolgreich getrennt!");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected()
- {
- return con != null;
- }
- public static void createTable()
- {
- if (isConnected()) {
- try
- {
- con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS StatsAPI (UUID VARCHAR(100), POINTS int, KILLS int , DEATHS int)");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static void update(String qry)
- {
- if (isConnected()) {
- try
- {
- con.createStatement().executeUpdate(qry);
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static ResultSet getResult(String qry)
- {
- ResultSet rs = null;
- try
- {
- Statement st = con.createStatement();
- rs = st.executeQuery(qry);
- }
- catch (SQLException e)
- {
- connect();
- System.err.println(e);
- }
- return rs;
- }
- public static File getMySQLFile()
- {
- return new File("plugins/KnockIT", "MySQL.yml");
- }
- public static FileConfiguration getMySQLFileConfiguration()
- {
- return YamlConfiguration.loadConfiguration(getMySQLFile());
- }
- public static void setStandardMySQL()
- {
- FileConfiguration cfg = getMySQLFileConfiguration();
- cfg.options().copyDefaults(true);
- cfg.addDefault("host", "127.0.0.1");
- cfg.addDefault("port", "3306");
- cfg.addDefault("database", "localhost");
- cfg.addDefault("username", "root");
- cfg.addDefault("password", "password");
- try
- {
- cfg.save(getMySQLFile());
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- public static void readMySQL()
- {
- FileConfiguration cfg = getMySQLFileConfiguration();
- host = cfg.getString("host");
- port = cfg.getString("port");
- database = cfg.getString("database");
- username = cfg.getString("username");
- password = cfg.getString("password");
- }
- public static Connection con;
- public static boolean playerExists(String uuid)
- {
- try
- {
- ResultSet rs = MySQL.getResult("SELECT * FROM StatsAPI WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- return rs.getString("UUID") != null;
- }
- return false;
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- return false;
- }
- public static void createPlayer(String uuid)
- {
- if (!playerExists(uuid)) {
- MySQL.update("INSERT INTO StatsAPI (UUID, POINTS, KILLS, DEATHS) VALUES ('" + uuid + "', '0', '0', '0');");
- }
- }
- public static Integer getPoints(String uuid)
- {
- Integer i = Integer.valueOf(0);
- if (playerExists(uuid))
- {
- try
- {
- ResultSet rs = MySQL.getResult("SELECT * FROM StatsAPI WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- Integer.valueOf(rs.getInt("POINTS"));
- }
- i = Integer.valueOf(rs.getInt("POINTS"));
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- createPlayer(uuid);
- getPoints(uuid);
- }
- return i;
- }
- public static Integer getKills(String uuid)
- {
- Integer i = Integer.valueOf(0);
- if (playerExists(uuid))
- {
- try
- {
- ResultSet rs = MySQL.getResult("SELECT * FROM StatsAPI WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- Integer.valueOf(rs.getInt("KILLS"));
- }
- i = Integer.valueOf(rs.getInt("KILLS"));
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- createPlayer(uuid);
- getKills(uuid);
- }
- return i;
- }
- public static Integer getDeaths(String uuid)
- {
- Integer i = Integer.valueOf(0);
- if (playerExists(uuid))
- {
- try
- {
- ResultSet rs = MySQL.getResult("SELECT * FROM StatsAPI WHERE UUID='" + uuid + "'");
- if (rs.next()) {
- Integer.valueOf(rs.getInt("DEATHS"));
- }
- i = Integer.valueOf(rs.getInt("DEATHS"));
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- createPlayer(uuid);
- getDeaths(uuid);
- }
- return i;
- }
- public static void setPoints(String uuid, Integer points)
- {
- if (playerExists(uuid))
- {
- MySQL.update("UPDATE StatsAPI SET POINTS='" + points + "' WHERE UUID='" + uuid + "'");
- }
- else
- {
- createPlayer(uuid);
- setPoints(uuid, points);
- }
- }
- public static void setKills(String uuid, Integer kills)
- {
- if (playerExists(uuid))
- {
- MySQL.update("UPDATE StatsAPI SET KILLS='" + kills + "' WHERE UUID='" + uuid + "'");
- }
- else
- {
- createPlayer(uuid);
- setKills(uuid, kills);
- }
- }
- public static void setDeaths(String uuid, Integer deaths)
- {
- if (playerExists(uuid))
- {
- MySQL.update("UPDATE StatsAPI SET DEATHS='" + deaths + "' WHERE UUID='" + uuid + "'");
- }
- else
- {
- createPlayer(uuid);
- setDeaths(uuid, deaths);
- }
- }
- public static void addPoints(String uuid, Integer points)
- {
- if (playerExists(uuid))
- {
- setPoints(uuid, Integer.valueOf(getPoints(uuid).intValue() + points.intValue()));
- }
- else
- {
- createPlayer(uuid);
- addPoints(uuid, points);
- }
- }
- public static void addKills(String uuid, Integer kills)
- {
- if (playerExists(uuid))
- {
- setKills(uuid, Integer.valueOf(getKills(uuid).intValue() + kills.intValue()));
- }
- else
- {
- createPlayer(uuid);
- addKills(uuid, kills);
- }
- }
- public static void addDeaths(String uuid, Integer deaths)
- {
- if (playerExists(uuid))
- {
- setDeaths(uuid, Integer.valueOf(getDeaths(uuid).intValue() + deaths.intValue()));
- }
- else
- {
- createPlayer(uuid);
- addDeaths(uuid, deaths);
- }
- }
- public static void removePoints(String uuid, Integer points)
- {
- if (playerExists(uuid))
- {
- setPoints(uuid, Integer.valueOf(getPoints(uuid).intValue() - points.intValue()));
- }
- else
- {
- createPlayer(uuid);
- removePoints(uuid, points);
- }
- }
- public static void removeKills(String uuid, Integer kills)
- {
- if (playerExists(uuid))
- {
- setKills(uuid, Integer.valueOf(getKills(uuid).intValue() - kills.intValue()));
- }
- else
- {
- createPlayer(uuid);
- removeKills(uuid, kills);
- }
- }
- public static void removeDeaths(String uuid, Integer deaths)
- {
- if (playerExists(uuid))
- {
- setKills(uuid, Integer.valueOf(getDeaths(uuid).intValue() - deaths.intValue()));
- }
- else
- {
- createPlayer(uuid);
- removeDeaths(uuid, deaths);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement