From f4f9f7efea046a15da3a29caa75b31953e0f43ed Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Thu, 4 Apr 2019 21:10:09 +0200 Subject: [PATCH] first stable version Signed-off-by: Yaruma3341 --- src/config.yml | 9 +- src/de/diamant/hunjy/MySQL/MySQL.java | 83 --------- .../diamant/hunjy/command/buildCommand.java | 56 ------ src/de/diamant/hunjy/command/setLocation.java | 53 ------ src/de/diamant/hunjy/listener/JoinEvent.java | 63 ------- .../hunjy/listener/LobbyInteractListener.java | 136 --------------- .../main => warking/lobby}/LobbySystem.java | 42 ++--- .../warking/lobby/command/buildCommand.java | 42 +++++ .../lobby}/command/checkCommand.java | 5 +- src/de/warking/lobby/command/setLocation.java | 30 ++++ .../lobby}/gadgets/Gadget.java | 2 +- .../lobby}/gadgets/GadgetManager.java | 2 +- .../lobby/inventorys/ExtrasInventorys.java | 99 +++++++++++ .../lobby/inventorys/LobbyInventorys.java | 92 ++++++++++ .../lobby}/listener/BlockListener.java | 14 +- .../listener/EntityDamageByEntityEvent.java | 7 +- .../lobby}/listener/FishEvent.java | 6 +- src/de/warking/lobby/listener/JoinEvent.java | 51 ++++++ .../lobby/listener/LobbyInteractListener.java | 75 ++++++++ .../lobby}/listener/LobbyInvClickManager.java | 164 +++++------------- .../lobby}/listener/PlayerKickEvent.java | 8 +- .../lobby/listener/PlayerMoveListener.java | 42 +++++ .../lobby/listener/PlayerQuitListener.java | 15 ++ .../listener/ProjectileLaunchEvent.java | 8 +- .../lobby}/listener/QuitEvent.java | 4 +- .../lobby}/listener/SneakListener.java | 6 +- .../lobby}/listener/TeleportEvent.java | 6 +- .../lobby}/manager/BackendManager.java | 4 +- .../lobby}/manager/FileManager.java | 4 +- .../lobby}/manager/LocationManager.java | 4 +- .../lobby}/utils/ItemBuilder.java | 7 +- src/plugin.yml | 7 +- 32 files changed, 565 insertions(+), 581 deletions(-) delete mode 100644 src/de/diamant/hunjy/MySQL/MySQL.java delete mode 100644 src/de/diamant/hunjy/command/buildCommand.java delete mode 100644 src/de/diamant/hunjy/command/setLocation.java delete mode 100644 src/de/diamant/hunjy/listener/JoinEvent.java delete mode 100644 src/de/diamant/hunjy/listener/LobbyInteractListener.java rename src/de/{diamant/hunjy/main => warking/lobby}/LobbySystem.java (74%) create mode 100644 src/de/warking/lobby/command/buildCommand.java rename src/de/{diamant/hunjy => warking/lobby}/command/checkCommand.java (94%) create mode 100644 src/de/warking/lobby/command/setLocation.java rename src/de/{diamant/hunjy => warking/lobby}/gadgets/Gadget.java (70%) rename src/de/{diamant/hunjy => warking/lobby}/gadgets/GadgetManager.java (97%) create mode 100644 src/de/warking/lobby/inventorys/ExtrasInventorys.java create mode 100644 src/de/warking/lobby/inventorys/LobbyInventorys.java rename src/de/{diamant/hunjy => warking/lobby}/listener/BlockListener.java (76%) rename src/de/{diamant/hunjy => warking/lobby}/listener/EntityDamageByEntityEvent.java (91%) rename src/de/{diamant/hunjy => warking/lobby}/listener/FishEvent.java (94%) create mode 100644 src/de/warking/lobby/listener/JoinEvent.java create mode 100644 src/de/warking/lobby/listener/LobbyInteractListener.java rename src/de/{diamant/hunjy => warking/lobby}/listener/LobbyInvClickManager.java (59%) rename src/de/{diamant/hunjy => warking/lobby}/listener/PlayerKickEvent.java (83%) create mode 100644 src/de/warking/lobby/listener/PlayerMoveListener.java create mode 100644 src/de/warking/lobby/listener/PlayerQuitListener.java rename src/de/{diamant/hunjy => warking/lobby}/listener/ProjectileLaunchEvent.java (92%) rename src/de/{diamant/hunjy => warking/lobby}/listener/QuitEvent.java (88%) rename src/de/{diamant/hunjy => warking/lobby}/listener/SneakListener.java (93%) rename src/de/{diamant/hunjy => warking/lobby}/listener/TeleportEvent.java (83%) rename src/de/{diamant/hunjy => warking/lobby}/manager/BackendManager.java (97%) rename src/de/{diamant/hunjy => warking/lobby}/manager/FileManager.java (93%) rename src/de/{diamant/hunjy => warking/lobby}/manager/LocationManager.java (95%) rename src/de/{diamant/hunjy => warking/lobby}/utils/ItemBuilder.java (90%) diff --git a/src/config.yml b/src/config.yml index 670a24e..76815d9 100644 --- a/src/config.yml +++ b/src/config.yml @@ -27,4 +27,11 @@ Items: Hider: ID: 'BLAZE_ROD' Display: '&9Spieler Verstecken' - Slot: 2 \ No newline at end of file + Slot: 2 +WorldMaxRadius: + minX: + minY: + minZ: + maxX: + maxY: + maxZ: \ No newline at end of file diff --git a/src/de/diamant/hunjy/MySQL/MySQL.java b/src/de/diamant/hunjy/MySQL/MySQL.java deleted file mode 100644 index 73402ec..0000000 --- a/src/de/diamant/hunjy/MySQL/MySQL.java +++ /dev/null @@ -1,83 +0,0 @@ -package de.diamant.hunjy.MySQL; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import de.diamant.hunjy.main.LobbySystem; - - -public class MySQL { - private String HOST = ""; - private String PORT = ""; - private String DATABASE = ""; - private String USER = ""; - private String PASSWORD = ""; - private Connection con; - - - public MySQL(String HOST, String PORT, String DATABASE, String USER, String PASSWORD) { - this.HOST = HOST; - this.PORT = PORT; - this.DATABASE = DATABASE; - this.USER = USER; - this.PASSWORD = PASSWORD; - - connect(); - } - - public MySQL(String HOST, String PORT, String DATABASE, String USER) { - this.HOST = HOST; - this.PORT = PORT; - this.DATABASE = DATABASE; - this.USER = USER; - - connect(); - } - - public void connect() { - try { - con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE + "?autoreconnect=true", USER, PASSWORD); - if(con != null) - System.out.println(LobbySystem.getInstance().getDescription().getFullName() + " >> MySQL: Verbunden"); - }catch (SQLException e) { - e.printStackTrace(); - } - } - - public void closeConnection() { - try { - if(con != null) - con.close(); - }catch (SQLException e) { - e.printStackTrace(); - } - } - - public void update(String qry) { - try { - PreparedStatement st = con.prepareStatement(qry); - st.executeUpdate(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - public ResultSet getResultSet(String qry) { - - try { - PreparedStatement st = con.prepareStatement(qry); - return st.executeQuery(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return null; - } - - public Connection getCon() { - return con; - } -} diff --git a/src/de/diamant/hunjy/command/buildCommand.java b/src/de/diamant/hunjy/command/buildCommand.java deleted file mode 100644 index 2c8c590..0000000 --- a/src/de/diamant/hunjy/command/buildCommand.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.diamant.hunjy.command; - -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.manager.BackendManager; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.utils.ItemBuilder; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; - -public class buildCommand implements CommandExecutor { - - public FileManager fm = LobbySystem.getInstance().getFileManager(); - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - - if(!(sender instanceof Player)) - return false; - - Player player = (Player) sender; - - if(player.hasPermission("lobby.build")) { - - if(!BackendManager.canBuild.contains(player)) { - BackendManager.canBuild.add(player); - LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player); - LobbySystem.getInstance().getGadgetManager().removePlayerGadgetCooldown(player); - setLobbyItems(player); - player.sendMessage(LobbySystem.prefix + "Du kannst nun auf der Lobby bauen!"); - } else { - BackendManager.canBuild.remove(player); - setLobbyItems(player); - player.sendMessage(LobbySystem.prefix + "Du kannst nun auf der Lobby nicht mehr bauen!"); - } - - } else - player.sendMessage(LobbySystem.prefix + "§cDu darfst das nicht!"); - return false; - } - - private void setLobbyItems(Player player) { - Inventory inv = player.getInventory(); - - inv.clear(); - player.getInventory().setArmorContents(null); - - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Navigator.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Navigator.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Extras.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Extras.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Lobby-Switcher.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Hider.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Hider.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Hider.Display").replaceAll("&", "§")).removeAllAtributs().build()); - } -} diff --git a/src/de/diamant/hunjy/command/setLocation.java b/src/de/diamant/hunjy/command/setLocation.java deleted file mode 100644 index 9eb5844..0000000 --- a/src/de/diamant/hunjy/command/setLocation.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.diamant.hunjy.command; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; - -import de.diamant.hunjy.listener.LobbyInvClickManager; -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.utils.ItemBuilder; - -public class setLocation implements CommandExecutor{ - - public FileManager fm = LobbySystem.getInstance().getFileManager(); - - @Override - public boolean onCommand(CommandSender sender, Command command, String lable, String[] args) { - if(!(sender instanceof Player)) - return false; - Player player = (Player)sender; - - if(player.hasPermission("lobby.admin.edit.location")) { - LobbyInvClickManager.inSetup.add(player); - player.openInventory(LobbyInventory()); - } - - return false; - } - - public Inventory LobbyInventory() { - String name = fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§").split(" ")[0]; - Inventory inv = Bukkit.createInventory(null, 45, name); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - inv.setItem(22, new ItemBuilder(Material.MAGMA_CREAM).setDisplayName("§8» §6Spawn §8«").removeAllAtributs().build()); - inv.setItem(2, new ItemBuilder(Material.ELYTRA).setDisplayName("§8» §3AirShip §8«").removeAllAtributs().build()); - inv.setItem(6, new ItemBuilder(Material.CHEST).setDisplayName("§8» §aMiniGames §8«").removeAllAtributs().build()); - inv.setItem(19, new ItemBuilder(Material.TNT).setDisplayName("§8» §9WarGear §8«").removeAllAtributs().build()); - inv.setItem(25, new ItemBuilder(Material.WOOD_SWORD).setDisplayName("§8» §2Survival §8«").removeAllAtributs().build()); - inv.setItem(38, new ItemBuilder(Material.EXPLOSIVE_MINECART).setDisplayName("§8» §bMini WarGear §8«").removeAllAtributs().build()); - inv.setItem(40, new ItemBuilder(Material.GOLD_NUGGET).setDisplayName("§8» §eTägliche Belohnung §8«").removeAllAtributs().build()); - inv.setItem(42, new ItemBuilder(Material.BOWL).setDisplayName("§8» §dBattleBox §8«").removeAllAtributs().build()); - return inv; - } - -} diff --git a/src/de/diamant/hunjy/listener/JoinEvent.java b/src/de/diamant/hunjy/listener/JoinEvent.java deleted file mode 100644 index 866b660..0000000 --- a/src/de/diamant/hunjy/listener/JoinEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.diamant.hunjy.listener; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.inventory.Inventory; - -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.manager.BackendManager; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.utils.ItemBuilder; - -public class JoinEvent implements Listener { - - public BackendManager backend = LobbySystem.getInstance().getBackendManager(); - public FileManager fm = LobbySystem.getInstance().getFileManager(); - - @EventHandler - private void onJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - - - if(backend.allowJoinMessage) { - - if(backend.allowFisrtJoinMessage) { - if(!player.hasPlayedBefore()) { - event.setJoinMessage(backend.FisrtJoinMessage); - } - } - event.setJoinMessage(backend.JoinMessage.replaceAll("%player%", player.getName())); - }else { - event.setJoinMessage(null); - } - - player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("main.lobby")); - setLobbyItems(player); - - - //hider - for(Player workPlayer : BackendManager.hideAll) { - workPlayer.hidePlayer(player); - } - - for(Player workPlayer : BackendManager.hideUsers) { - workPlayer.hidePlayer(player); - } - } - - private void setLobbyItems(Player player) { - Inventory inv = player.getInventory(); - - inv.clear(); - player.getInventory().setArmorContents(null); - - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Navigator.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Navigator.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Extras.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Extras.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Lobby-Switcher.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.Display").replaceAll("&", "§")).removeAllAtributs().build()); - inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Hider.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Hider.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Hider.Display").replaceAll("&", "§")).removeAllAtributs().build()); - } - -} diff --git a/src/de/diamant/hunjy/listener/LobbyInteractListener.java b/src/de/diamant/hunjy/listener/LobbyInteractListener.java deleted file mode 100644 index 1bbd570..0000000 --- a/src/de/diamant/hunjy/listener/LobbyInteractListener.java +++ /dev/null @@ -1,136 +0,0 @@ -package de.diamant.hunjy.listener; - -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.manager.BackendManager; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.Inventory; - -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.utils.ItemBuilder; - -public class LobbyInteractListener implements Listener { - - - // »« - - public FileManager fm = LobbySystem.getInstance().getFileManager(); - - @EventHandler - private void onInteract(PlayerInteractEvent event) { - if(event.getItem() != null) { - Player player = event.getPlayer(); - if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Navigator.ID"))) { - player.openInventory(LobbyInventory()); - event.setCancelled(true); - }else if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Hider.ID"))) { - player.openInventory(PlayerHideInventory(player)); - event.setCancelled(true); - }else if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Extras.ID"))) { - player.openInventory(ExtrasInventory()); - event.setCancelled(true); - } else if(event.getItem().getType() == Material.ELYTRA && event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§cJetpack")) { - event.setCancelled(true); - } else if(event.getItem().getType() ==Material.getMaterial(417) && event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§cTNT Kanone")) { - shootTNTCanon(player); - } - } - } - - public Inventory LobbyInventory() { - String name = fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§").split(" ")[0]; - Inventory inv = Bukkit.createInventory(null, 45, name); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - inv.setItem(22, new ItemBuilder(Material.MAGMA_CREAM).setDisplayName("§8» §6Spawn §8«").removeAllAtributs().build()); - inv.setItem(2, new ItemBuilder(Material.ELYTRA).setDisplayName("§8» §3AirShip §8«").removeAllAtributs().build()); - inv.setItem(6, new ItemBuilder(Material.CHEST).setDisplayName("§8» §aMiniGames §8«").removeAllAtributs().build()); - inv.setItem(19, new ItemBuilder(Material.TNT).setDisplayName("§8» §9WarGear §8«").removeAllAtributs().build()); - inv.setItem(25, new ItemBuilder(Material.WOOD_SWORD).setDisplayName("§8» §2Survival §8«").removeAllAtributs().build()); - inv.setItem(38, new ItemBuilder(Material.EXPLOSIVE_MINECART).setDisplayName("§8» §bMini WarGear §8«").removeAllAtributs().build()); - inv.setItem(40, new ItemBuilder(Material.GOLD_NUGGET).setDisplayName("§8» §eTägliche Belohnung §8«").removeAllAtributs().build()); - inv.setItem(42, new ItemBuilder(Material.BOWL).setDisplayName("§8» §dBattleBox §8«").removeAllAtributs().build()); - return inv; - } - - public Inventory PlayerHideInventory(Player player) { - String name = "§9Spieler Verstecken"; - Inventory inv = Bukkit.createInventory(null, InventoryType.BREWING, name); - inv.setItem(0, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§8» §aAlle Spieler §8«").removeAllAtributs().build()); - inv.setItem(1, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§8» §5YouTuber/ Teammitglieder §8«").removeAllAtributs().build()); - inv.setItem(2, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§8» §7Keine Spieler §8«").removeAllAtributs().build()); - - if(BackendManager.hideAll.contains(player)) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§7Aktuell §8» §aAlle Spieler").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); - if(BackendManager.hideUsers.contains(player)) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§7Aktuell §8» §5YouTuber/ Teammitglieder §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); - if(!(BackendManager.hideAll.contains(player) && BackendManager.hideUsers.contains(player))) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§7Aktuell §8» §7Keine Spieler §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); - - - inv.setItem(4, new ItemBuilder(Material.TNT).setDisplayName("§8» §cSilentLobby §8«").removeAllAtributs().build()); - - - return inv; - - } - - - - public Inventory ExtrasInventory() { - String name = fm.getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§").split(" ")[0]; - Inventory inv = Bukkit.createInventory(null, 45, name); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - inv.setItem(0, new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName("§8» §9Rüstung §8«").removeAllAtributs().build()); - - inv.setItem(9, new ItemBuilder(Material.PISTON_BASE).setDisplayName("§8» §aGadgets §8«").build()); - - inv.setItem(18, new ItemBuilder(Material.NETHER_STAR).setDisplayName("§8» §dPartikel §8«").build()); - - inv.setItem(27, new ItemBuilder(Material.BONE).setDisplayName("§8» §ePets §8«").build()); - - return inv; - - } - - public void shootTNTCanon(Player player) { - if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.TNT_CANNON && LobbySystem.getInstance().getGadgetManager().hasPlayerGadgetCooldown(player) == false) { - - Snowball snowball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class); - snowball.setVelocity(player.getLocation().getDirection().multiply(1.6)); - snowball.setShooter(player); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); - addCooldown(player, Gadget.TNT_CANNON); - player.getInventory().setItem(5, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§6Warten...").removeAllAtributs().build()); - player.getItemInHand().getItemMeta().setUnbreakable(true); - } - } - - private void addCooldown(Player player, Gadget gadget) { - LobbySystem.getInstance().getGadgetManager().setPlayerGadgetCooldown(player, gadget); - - Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), new Runnable() { - @Override - public void run() { - LobbySystem.getInstance().getGadgetManager().removePlayerGadgetCooldown(player); - if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.TNT_CANNON) player.getInventory().setItem(5, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); - } - }, 20*10); - } - -} diff --git a/src/de/diamant/hunjy/main/LobbySystem.java b/src/de/warking/lobby/LobbySystem.java similarity index 74% rename from src/de/diamant/hunjy/main/LobbySystem.java rename to src/de/warking/lobby/LobbySystem.java index 6bc71f1..991a9f8 100644 --- a/src/de/diamant/hunjy/main/LobbySystem.java +++ b/src/de/warking/lobby/LobbySystem.java @@ -1,21 +1,18 @@ -package de.diamant.hunjy.main; +package de.warking.lobby; - - -import de.diamant.hunjy.gadgets.GadgetManager; -import de.diamant.hunjy.listener.*; +import de.warking.lobby.command.buildCommand; +import de.warking.lobby.command.checkCommand; +import de.warking.lobby.command.setLocation; +import de.warking.lobby.gadgets.GadgetManager; +import de.warking.lobby.listener.*; +import de.warking.lobby.manager.BackendManager; +import de.warking.lobby.manager.FileManager; +import de.warking.lobby.manager.LocationManager; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import de.diamant.hunjy.command.*; -import de.diamant.hunjy.manager.BackendManager; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.manager.LocationManager; - - - -public class LobbySystem extends JavaPlugin{ +public class LobbySystem extends JavaPlugin { public static String prefix; @@ -32,10 +29,9 @@ public class LobbySystem extends JavaPlugin{ @Override public void onEnable() { - locationManager = new LocationManager(); - fileManager = new FileManager(instance); + fileManager = new de.warking.lobby.manager.FileManager(instance); loadBackend(); prefix = backendManager.prefix; @@ -43,21 +39,25 @@ public class LobbySystem extends JavaPlugin{ this.getCommand("check").setExecutor(new checkCommand()); this.getCommand("build").setExecutor(new buildCommand()); + init(); + } + public void init() { PluginManager pm = Bukkit.getPluginManager(); - pm.registerEvents(new JoinEvent(), instance); pm.registerEvents(new BlockListener(), instance); + pm.registerEvents(new EntityDamageByEntityEvent(), instance); + pm.registerEvents(new FishEvent(), instance); + pm.registerEvents(new JoinEvent(), instance); pm.registerEvents(new LobbyInteractListener(), instance); pm.registerEvents(new LobbyInvClickManager(), instance); - pm.registerEvents(new QuitEvent(), instance); - pm.registerEvents(new ProjectileLaunchEvent(), instance); pm.registerEvents(new PlayerKickEvent(), instance); + pm.registerEvents(new PlayerMoveListener(), instance); + pm.registerEvents(new ProjectileLaunchEvent(), instance); + pm.registerEvents(new QuitEvent(), instance); pm.registerEvents(new SneakListener(), instance); pm.registerEvents(new TeleportEvent(), instance); - pm.registerEvents(new FishEvent(), instance); - pm.registerEvents(new EntityDamageByEntityEvent(), instance); - + pm.registerEvents(new PlayerQuitListener(), instance); } public void loadBackend() { diff --git a/src/de/warking/lobby/command/buildCommand.java b/src/de/warking/lobby/command/buildCommand.java new file mode 100644 index 0000000..e17a294 --- /dev/null +++ b/src/de/warking/lobby/command/buildCommand.java @@ -0,0 +1,42 @@ +package de.warking.lobby.command; + +import de.warking.lobby.LobbySystem; +import de.warking.lobby.inventorys.LobbyInventorys; +import de.warking.lobby.manager.BackendManager; +import de.warking.lobby.manager.FileManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class buildCommand implements CommandExecutor { + + public FileManager fm = LobbySystem.getInstance().getFileManager(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + + if(!(sender instanceof Player)) + return false; + + Player player = (Player) sender; + + if(player.hasPermission("lobby.build")) { + + if(!BackendManager.canBuild.contains(player)) { + BackendManager.canBuild.add(player); + LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player); + LobbySystem.getInstance().getGadgetManager().removePlayerGadgetCooldown(player); + LobbyInventorys.setLobbyItems(player); + player.sendMessage(LobbySystem.prefix + "Du kannst nun auf der Lobby bauen!"); + } else { + BackendManager.canBuild.remove(player); + LobbyInventorys.setLobbyItems(player); + player.sendMessage(LobbySystem.prefix + "Du kannst nun auf der Lobby nicht mehr bauen!"); + } + + } else + player.sendMessage(LobbySystem.prefix + "§cDu darfst das nicht!"); + return false; + } +} diff --git a/src/de/diamant/hunjy/command/checkCommand.java b/src/de/warking/lobby/command/checkCommand.java similarity index 94% rename from src/de/diamant/hunjy/command/checkCommand.java rename to src/de/warking/lobby/command/checkCommand.java index df248bd..ded5597 100644 --- a/src/de/diamant/hunjy/command/checkCommand.java +++ b/src/de/warking/lobby/command/checkCommand.java @@ -1,12 +1,11 @@ -package de.diamant.hunjy.command; +package de.warking.lobby.command; +import de.warking.lobby.LobbySystem; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import de.diamant.hunjy.main.LobbySystem; - public class checkCommand implements CommandExecutor { @Override diff --git a/src/de/warking/lobby/command/setLocation.java b/src/de/warking/lobby/command/setLocation.java new file mode 100644 index 0000000..8abfc33 --- /dev/null +++ b/src/de/warking/lobby/command/setLocation.java @@ -0,0 +1,30 @@ +package de.warking.lobby.command; + +import de.warking.lobby.LobbySystem; +import de.warking.lobby.inventorys.LobbyInventorys; +import de.warking.lobby.listener.LobbyInvClickManager; +import de.warking.lobby.manager.FileManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class setLocation implements CommandExecutor { + + public FileManager fm = LobbySystem.getInstance().getFileManager(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String lable, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player)sender; + + if(player.hasPermission("lobby.admin.edit.location")) { + LobbyInvClickManager.inSetup.add(player); + player.openInventory(LobbyInventorys.getNavigatorInventory()); + } + + return false; + } + +} diff --git a/src/de/diamant/hunjy/gadgets/Gadget.java b/src/de/warking/lobby/gadgets/Gadget.java similarity index 70% rename from src/de/diamant/hunjy/gadgets/Gadget.java rename to src/de/warking/lobby/gadgets/Gadget.java index f80304b..b0b00d1 100644 --- a/src/de/diamant/hunjy/gadgets/Gadget.java +++ b/src/de/warking/lobby/gadgets/Gadget.java @@ -1,4 +1,4 @@ -package de.diamant.hunjy.gadgets; +package de.warking.lobby.gadgets; public enum Gadget { diff --git a/src/de/diamant/hunjy/gadgets/GadgetManager.java b/src/de/warking/lobby/gadgets/GadgetManager.java similarity index 97% rename from src/de/diamant/hunjy/gadgets/GadgetManager.java rename to src/de/warking/lobby/gadgets/GadgetManager.java index 3e68094..27c9ef2 100644 --- a/src/de/diamant/hunjy/gadgets/GadgetManager.java +++ b/src/de/warking/lobby/gadgets/GadgetManager.java @@ -1,4 +1,4 @@ -package de.diamant.hunjy.gadgets; +package de.warking.lobby.gadgets; import org.bukkit.entity.Player; diff --git a/src/de/warking/lobby/inventorys/ExtrasInventorys.java b/src/de/warking/lobby/inventorys/ExtrasInventorys.java new file mode 100644 index 0000000..8c3d81f --- /dev/null +++ b/src/de/warking/lobby/inventorys/ExtrasInventorys.java @@ -0,0 +1,99 @@ +package de.warking.lobby.inventorys; + +import de.warking.lobby.utils.ItemBuilder; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.inventory.Inventory; + +public class ExtrasInventorys { + + public static Inventory getGadgets() { + + Inventory inv = Bukkit.createInventory(null, 45, "§8» §aGadgets §8«"); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + inv.setItem(0, new ItemBuilder(Material.ENDER_PEARL).setDisplayName("§dEnder Perle").removeAllAtributs().build()); + inv.setItem(1, new ItemBuilder(Material.ELYTRA).setDisplayName("§cJetpack").removeAllAtributs().build()); + inv.setItem(2, new ItemBuilder(Material.FISHING_ROD).setDisplayName("§eGreifhaken").removeAllAtributs().build()); + //inv.setItem(3, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + + return inv; + } + + + public static Inventory getArmorInventory() { + + Inventory inv = Bukkit.createInventory(null, 45, "§8» §9Rüstung §8«"); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + inv.setItem(0, new ItemBuilder(Material.WOOD_HOE).setDisplayName("§0LEDER").removeAllAtributs().build()); + inv.setItem(2, new ItemBuilder(Material.STONE_SPADE).setDisplayName("§8KETTE").removeAllAtributs().build()); + inv.setItem(4, new ItemBuilder(Material.IRON_PICKAXE).setDisplayName("§7IRON").removeAllAtributs().build()); + inv.setItem(6, new ItemBuilder(Material.GOLD_AXE).setDisplayName("§eGOLD").removeAllAtributs().build()); + inv.setItem(8, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§bDIAMANT").removeAllAtributs().build()); + + + inv.setItem(9, new ItemBuilder(Material.LEATHER_HELMET).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(18, new ItemBuilder(Material.LEATHER_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(27, new ItemBuilder(Material.LEATHER_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(36, new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + + inv.setItem(11, new ItemBuilder(Material.CHAINMAIL_HELMET).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(20, new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(29, new ItemBuilder(Material.CHAINMAIL_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(38, new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + + inv.setItem(13, new ItemBuilder(Material.IRON_HELMET).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(22, new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(31, new ItemBuilder(Material.IRON_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(40, new ItemBuilder(Material.IRON_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + + inv.setItem(15, new ItemBuilder(Material.GOLD_HELMET).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(24, new ItemBuilder(Material.GOLD_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(33, new ItemBuilder(Material.GOLD_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(42, new ItemBuilder(Material.GOLD_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + + inv.setItem(17, new ItemBuilder(Material.DIAMOND_HELMET).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(26, new ItemBuilder(Material.DIAMOND_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(35, new ItemBuilder(Material.DIAMOND_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); + inv.setItem(44, new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + + return inv; + } + + + public static Inventory getPartikel() { + + Inventory inv = Bukkit.createInventory(null, 45, "§8» §dPartikel §8«"); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + // + + return inv; + } + + + public static Inventory getPets() { + + Inventory inv = Bukkit.createInventory(null, 45, "§8» §ePets §8«"); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + // + + return inv; + } + + +} diff --git a/src/de/warking/lobby/inventorys/LobbyInventorys.java b/src/de/warking/lobby/inventorys/LobbyInventorys.java new file mode 100644 index 0000000..8b1ec62 --- /dev/null +++ b/src/de/warking/lobby/inventorys/LobbyInventorys.java @@ -0,0 +1,92 @@ +package de.warking.lobby.inventorys; + +import de.warking.lobby.LobbySystem; +import de.warking.lobby.manager.BackendManager; +import de.warking.lobby.manager.FileManager; +import de.warking.lobby.utils.ItemBuilder; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; + +public class LobbyInventorys { + + public static void setLobbyItems(Player player) { + Inventory inv = player.getInventory(); + + inv.clear(); + player.getInventory().setArmorContents(null); + + + FileManager fm = LobbySystem.getInstance().getFileManager(); + + inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Navigator.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Navigator.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§")).removeAllAtributs().build()); + inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Extras.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Extras.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§")).removeAllAtributs().build()); + //inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Lobby-Switcher.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Lobby-Switcher.Display").replaceAll("&", "§")).removeAllAtributs().build()); + inv.setItem(fm.getIntegerFromConfig("Items.Lobby.Hider.Slot")-1, new ItemBuilder(Material.valueOf(fm.getStringFromConfig("Items.Lobby.Hider.ID"))).setDisplayName(fm.getStringFromConfig("Items.Lobby.Hider.Display").replaceAll("&", "§")).removeAllAtributs().build()); + } + + + public static Inventory getNavigatorInventory() { + String name = LobbySystem.getInstance().getFileManager().getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§").split(" ")[0]; + Inventory inv = Bukkit.createInventory(null, 45, name); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + inv.setItem(22, new ItemBuilder(Material.MAGMA_CREAM).setDisplayName("§8» §6Spawn §8«").removeAllAtributs().build()); + //inv.setItem(2, new ItemBuilder(Material.ELYTRA).setDisplayName("§8» §3AirShip §8«").removeAllAtributs().build()); + //inv.setItem(6, new ItemBuilder(Material.CHEST).setDisplayName("§8» §aMiniGames §8«").removeAllAtributs().build()); + //inv.setItem(19, new ItemBuilder(Material.TNT).setDisplayName("§8» §9WarGear §8«").removeAllAtributs().build()); + //inv.setItem(25, new ItemBuilder(Material.WOOD_SWORD).setDisplayName("§8» §2Survival §8«").removeAllAtributs().build()); + //inv.setItem(38, new ItemBuilder(Material.EXPLOSIVE_MINECART).setDisplayName("§8» §bMini WarGear §8«").removeAllAtributs().build()); + //inv.setItem(40, new ItemBuilder(Material.GOLD_NUGGET).setDisplayName("§8» §eTägliche Belohnung §8«").removeAllAtributs().build()); + //inv.setItem(42, new ItemBuilder(Material.BOWL).setDisplayName("§8» §dBattleBox §8«").removeAllAtributs().build()); + return inv; + } + + + public static Inventory ExtrasInventory() { + String name = LobbySystem.getInstance().getFileManager().getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§").split(" ")[0]; + Inventory inv = Bukkit.createInventory(null, 45, name); + + for(int i = 0; i < inv.getSize(); i++) { + inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); + } + + inv.setItem(0, new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName("§8» §9Rüstung §8«").removeAllAtributs().build()); + + inv.setItem(9, new ItemBuilder(Material.PISTON_BASE).setDisplayName("§8» §aGadgets §8«").build()); + + inv.setItem(18, new ItemBuilder(Material.NETHER_STAR).setDisplayName("§8» §dPartikel §8«").build()); + + inv.setItem(27, new ItemBuilder(Material.BONE).setDisplayName("§8» §ePets §8«").build()); + + return inv; + + } + + + public static Inventory PlayerHideInventory(Player player) { + String name = "§9Spieler Verstecken"; + Inventory inv = Bukkit.createInventory(null, InventoryType.BREWING, name); + inv.setItem(0, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§8» §aAlle Spieler §8«").removeAllAtributs().build()); + inv.setItem(1, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§8» §5YouTuber/ Teammitglieder §8«").removeAllAtributs().build()); + inv.setItem(2, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§8» §7Keine Spieler §8«").removeAllAtributs().build()); + + //if(BackendManager.hideAll.contains(player)) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§8» §7Keine Spieler §8«").removeAllAtributs().build()); + //if(BackendManager.hideUsers.contains(player)) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§7Aktuell §8» §5YouTuber/ Teammitglieder §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + //if(!(BackendManager.hideAll.contains(player) && BackendManager.hideUsers.contains(player))) inv.setItem(3, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§7Aktuell §8» §aAlle Spieler").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + + + inv.setItem(4, new ItemBuilder(Material.TNT).setDisplayName("§8» §cSilentLobby §8«").removeAllAtributs().build()); + + + return inv; + + } + +} diff --git a/src/de/diamant/hunjy/listener/BlockListener.java b/src/de/warking/lobby/listener/BlockListener.java similarity index 76% rename from src/de/diamant/hunjy/listener/BlockListener.java rename to src/de/warking/lobby/listener/BlockListener.java index 8204a4c..147cc36 100644 --- a/src/de/diamant/hunjy/listener/BlockListener.java +++ b/src/de/warking/lobby/listener/BlockListener.java @@ -1,6 +1,6 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.manager.BackendManager; +import de.warking.lobby.manager.BackendManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -8,16 +8,20 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.weather.WeatherChangeEvent; public class BlockListener implements Listener{ @EventHandler private void onDamage(EntityDamageEvent event) { - if(event.getEntity() instanceof Player) { - //event.setCancelled(true); - } + if(event.getEntity() instanceof Player) + event.setCancelled(true); + } + @EventHandler + private void onPlayerDropItem(PlayerDropItemEvent event) { + event.setCancelled(true); } @EventHandler diff --git a/src/de/diamant/hunjy/listener/EntityDamageByEntityEvent.java b/src/de/warking/lobby/listener/EntityDamageByEntityEvent.java similarity index 91% rename from src/de/diamant/hunjy/listener/EntityDamageByEntityEvent.java rename to src/de/warking/lobby/listener/EntityDamageByEntityEvent.java index b126f2c..7aef1cd 100644 --- a/src/de/diamant/hunjy/listener/EntityDamageByEntityEvent.java +++ b/src/de/warking/lobby/listener/EntityDamageByEntityEvent.java @@ -1,7 +1,7 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; import net.minecraft.server.v1_12_R1.PacketPlayOutExplosion; import net.minecraft.server.v1_12_R1.Vec3D; import org.bukkit.Bukkit; @@ -9,7 +9,6 @@ import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/de/diamant/hunjy/listener/FishEvent.java b/src/de/warking/lobby/listener/FishEvent.java similarity index 94% rename from src/de/diamant/hunjy/listener/FishEvent.java rename to src/de/warking/lobby/listener/FishEvent.java index e8ad3b2..768cc95 100644 --- a/src/de/diamant/hunjy/listener/FishEvent.java +++ b/src/de/warking/lobby/listener/FishEvent.java @@ -1,7 +1,7 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/de/warking/lobby/listener/JoinEvent.java b/src/de/warking/lobby/listener/JoinEvent.java new file mode 100644 index 0000000..582df3c --- /dev/null +++ b/src/de/warking/lobby/listener/JoinEvent.java @@ -0,0 +1,51 @@ +package de.warking.lobby.listener; + +import de.warking.hunjy.Core; +import de.warking.lobby.inventorys.LobbyInventorys; +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +import de.warking.lobby.LobbySystem; +import de.warking.lobby.manager.BackendManager; +import de.warking.lobby.manager.FileManager; + +public class JoinEvent implements Listener { + + public BackendManager backend = LobbySystem.getInstance().getBackendManager(); + public FileManager fm = LobbySystem.getInstance().getFileManager(); + + @EventHandler + private void onJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + + if(backend.allowJoinMessage) { + + if(backend.allowFisrtJoinMessage) { + if(!player.hasPlayedBefore()) { + event.setJoinMessage(backend.FisrtJoinMessage); + } + } + event.setJoinMessage(backend.JoinMessage.replaceAll("%player%", player.getName())); + }else { + event.setJoinMessage(null); + } + + player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("main.lobby")); + LobbyInventorys.setLobbyItems(player); + player.setGameMode(GameMode.ADVENTURE); + + //hider + for(Player workPlayer : BackendManager.hideAll) { + workPlayer.hidePlayer(player); + } + + for(Player workPlayer : BackendManager.hideUsers) { + if(Core.getInstance().getPlayerManager(player).getGroupName().equalsIgnoreCase("member")) + workPlayer.hidePlayer(player); + } + } +} diff --git a/src/de/warking/lobby/listener/LobbyInteractListener.java b/src/de/warking/lobby/listener/LobbyInteractListener.java new file mode 100644 index 0000000..c103e2c --- /dev/null +++ b/src/de/warking/lobby/listener/LobbyInteractListener.java @@ -0,0 +1,75 @@ +package de.warking.lobby.listener; + +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.inventorys.LobbyInventorys; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; + +import de.warking.lobby.LobbySystem; +import de.warking.lobby.manager.FileManager; +import de.warking.lobby.utils.ItemBuilder; + +public class LobbyInteractListener implements Listener { + + + // »« + + public FileManager fm = LobbySystem.getInstance().getFileManager(); + + @EventHandler + private void onInteract(PlayerInteractEvent event) { + if(event.getItem() != null) { + Player player = event.getPlayer(); + if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Navigator.ID"))) { + player.openInventory(LobbyInventorys.getNavigatorInventory()); + event.setCancelled(true); + }else if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Hider.ID"))) { + player.openInventory(LobbyInventorys.PlayerHideInventory(player)); + event.setCancelled(true); + }else if(event.getItem().getType() == Material.valueOf(fm.getStringFromConfig("Items.Lobby.Extras.ID"))) { + player.openInventory(LobbyInventorys.ExtrasInventory()); + event.setCancelled(true); + } else if(event.getItem().getType() == Material.ELYTRA && event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§cJetpack")) { + event.setCancelled(true); + } else if(event.getItem().getType() ==Material.getMaterial(417) && event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§cTNT Kanone")) { + shootTNTCanon(player); + } + } + } + + + + + public void shootTNTCanon(Player player) { + if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.TNT_CANNON && LobbySystem.getInstance().getGadgetManager().hasPlayerGadgetCooldown(player) == false) { + + Snowball snowball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class); + snowball.setVelocity(player.getLocation().getDirection().multiply(1.6)); + snowball.setShooter(player); + player.getWorld().playSound(player.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); + addCooldown(player, Gadget.TNT_CANNON); + player.getInventory().setItem(5, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§6Warten...").removeAllAtributs().build()); + player.getItemInHand().getItemMeta().setUnbreakable(true); + } + } + + private void addCooldown(Player player, Gadget gadget) { + LobbySystem.getInstance().getGadgetManager().setPlayerGadgetCooldown(player, gadget); + + Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), new Runnable() { + @Override + public void run() { + LobbySystem.getInstance().getGadgetManager().removePlayerGadgetCooldown(player); + if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.TNT_CANNON) player.getInventory().setItem(5, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + } + }, 20*10); + } + +} diff --git a/src/de/diamant/hunjy/listener/LobbyInvClickManager.java b/src/de/warking/lobby/listener/LobbyInvClickManager.java similarity index 59% rename from src/de/diamant/hunjy/listener/LobbyInvClickManager.java rename to src/de/warking/lobby/listener/LobbyInvClickManager.java index cd504f6..2f5ff06 100644 --- a/src/de/diamant/hunjy/listener/LobbyInvClickManager.java +++ b/src/de/warking/lobby/listener/LobbyInvClickManager.java @@ -1,11 +1,13 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; import java.util.ArrayList; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.manager.BackendManager; -import de.diamant.hunjy.manager.FileManager; -import de.diamant.hunjy.utils.ItemBuilder; +import de.warking.hunjy.Core; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.inventorys.ExtrasInventorys; +import de.warking.lobby.manager.BackendManager; +import de.warking.lobby.manager.FileManager; +import de.warking.lobby.utils.ItemBuilder; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -15,9 +17,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.LobbySystem; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; public class LobbyInvClickManager implements Listener{ @@ -151,26 +152,26 @@ public class LobbyInvClickManager implements Listener{ } if(BackendManager.hideUsers.contains(player)) BackendManager.hideUsers.remove(player); if(BackendManager.hideAll.contains(player)) BackendManager.hideAll.remove(player); - event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§7Aktuell §8» §aAlle Spieler").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + //event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)10).setDisplayName("§7Aktuell §8» §aAlle Spieler").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); break; case "§8» §5YouTuber/ Teammitglieder §8«": for (Player allPlayers : Bukkit.getServer().getOnlinePlayers()) { - if (!allPlayers.hasPermission("PERMISSION")) {//permission fehlt + if (Core.getInstance().getPlayerManager(allPlayers).getGroupName().equalsIgnoreCase("member")) { player.hidePlayer(allPlayers); } else player.showPlayer(allPlayers); } if(BackendManager.hideAll.contains(player)) BackendManager.hideAll.remove(player); if(!BackendManager.hideUsers.contains(player)) BackendManager.hideUsers.add(player); - event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§7Aktuell §8» §5YouTuber/ Teammitglieder §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + //event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)5).setDisplayName("§7Aktuell §8» §5YouTuber/ Teammitglieder §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); break; case "§8» §7Keine Spieler §8«": for (Player allPlayers : Bukkit.getServer().getOnlinePlayers()) { player.hidePlayer(allPlayers); } if(!BackendManager.hideAll.contains(player)) BackendManager.hideAll.add(player); - if(!BackendManager.hideUsers.contains(player)) BackendManager.hideUsers.add(player); - event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§7Aktuell §8» §7Keine Spieler §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + if(BackendManager.hideUsers.contains(player)) BackendManager.hideUsers.remove(player); + //event.getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§7Aktuell §8» §7Keine Spieler §8«").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); break; case "§8» §cSilentLobby §8«": //change server @@ -185,16 +186,16 @@ public class LobbyInvClickManager implements Listener{ switch (materialName) { case "§8» §9Rüstung §8«": - player.openInventory(ArmorInventory()); + player.openInventory(ExtrasInventorys.getArmorInventory()); break; case "§8» §aGadgets §8«": - player.openInventory(Gadgets()); + player.openInventory(ExtrasInventorys.getGadgets()); break; case "§8» §dPartikel §8«": - player.openInventory(Partikel()); + player.openInventory(ExtrasInventorys.getPartikel()); break; case "§8» §ePets §8«": - player.openInventory(Pets()); + player.openInventory(ExtrasInventorys.getPets()); break; } return; @@ -205,34 +206,34 @@ public class LobbyInvClickManager implements Listener{ switch (materialName) { case "§0LEDER": - player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); break; case "§8KETTE": - player.getInventory().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setChestplate(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setBoots(new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + player.getInventory().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setChestplate(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setBoots(new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); break; case "§7IRON": - player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); break; case "§eGOLD": - player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); break; case "§bDIAMANT": - player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(" ").removeAllAtributs().build()); + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(" ").setUnbreakable(true).removeAllAtributs().build()); break; } return; @@ -251,21 +252,21 @@ public class LobbyInvClickManager implements Listener{ player.updateInventory(); break; case "§cJetpack": - player.getInventory().setItem(5, new ItemBuilder(Material.ELYTRA).setDisplayName("§cJetpack").removeAllAtributs().build()); + player.getInventory().setItem(5, new ItemBuilder(Material.ELYTRA).setDisplayName("§cJetpack").setUnbreakable(true).removeAllAtributs().build()); if(LobbySystem.getInstance().getGadgetManager().hasPlayerGadget(player)) LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player); LobbySystem.getInstance().getGadgetManager().setPlayerGadget(player, Gadget.JETPACK); player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 100); player.updateInventory(); break; case "§eGreifhaken": - player.getInventory().setItem(5, new ItemBuilder(Material.FISHING_ROD).setDisplayName("§eGreifhaken").removeAllAtributs().build()); + player.getInventory().setItem(5, new ItemBuilder(Material.FISHING_ROD).setDisplayName("§eGreifhaken").setUnbreakable(true).removeAllAtributs().build()); if(LobbySystem.getInstance().getGadgetManager().hasPlayerGadget(player)) LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player); LobbySystem.getInstance().getGadgetManager().setPlayerGadget(player, Gadget.HOOK); player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 100); player.updateInventory(); break; case "§cTNT Kanone": - player.getInventory().setItem(5, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); + player.getInventory().setItem(5, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").setUnbreakable(true).addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); if(LobbySystem.getInstance().getGadgetManager().hasPlayerGadget(player)) LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player); LobbySystem.getInstance().getGadgetManager().setPlayerGadget(player, Gadget.TNT_CANNON); player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 100); @@ -276,90 +277,5 @@ public class LobbyInvClickManager implements Listener{ } } - - public Inventory ArmorInventory() { - - Inventory inv = Bukkit.createInventory(null, 45, "§8» §9Rüstung §8«"); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - inv.setItem(0, new ItemBuilder(Material.WOOD_HOE).setDisplayName("§0LEDER").removeAllAtributs().build()); - inv.setItem(2, new ItemBuilder(Material.STONE_SPADE).setDisplayName("§8KETTE").removeAllAtributs().build()); - inv.setItem(4, new ItemBuilder(Material.IRON_PICKAXE).setDisplayName("§7IRON").removeAllAtributs().build()); - inv.setItem(6, new ItemBuilder(Material.GOLD_AXE).setDisplayName("§eGOLD").removeAllAtributs().build()); - inv.setItem(8, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§bDIAMANT").removeAllAtributs().build()); - - - inv.setItem(9, new ItemBuilder(Material.LEATHER_HELMET).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(18, new ItemBuilder(Material.LEATHER_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(27, new ItemBuilder(Material.LEATHER_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(36, new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(" ").removeAllAtributs().build()); - - inv.setItem(11, new ItemBuilder(Material.CHAINMAIL_HELMET).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(20, new ItemBuilder(Material.CHAINMAIL_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(29, new ItemBuilder(Material.CHAINMAIL_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(38, new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(" ").removeAllAtributs().build()); - - inv.setItem(13, new ItemBuilder(Material.IRON_HELMET).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(22, new ItemBuilder(Material.IRON_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(31, new ItemBuilder(Material.IRON_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(40, new ItemBuilder(Material.IRON_BOOTS).setDisplayName(" ").removeAllAtributs().build()); - - inv.setItem(15, new ItemBuilder(Material.GOLD_HELMET).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(24, new ItemBuilder(Material.GOLD_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(33, new ItemBuilder(Material.GOLD_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(42, new ItemBuilder(Material.GOLD_BOOTS).setDisplayName(" ").removeAllAtributs().build()); - - inv.setItem(17, new ItemBuilder(Material.DIAMOND_HELMET).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(26, new ItemBuilder(Material.DIAMOND_CHESTPLATE).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(35, new ItemBuilder(Material.DIAMOND_LEGGINGS).setDisplayName(" ").removeAllAtributs().build()); - inv.setItem(44, new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(" ").removeAllAtributs().build()); - - return inv; - } - - public Inventory Gadgets() { - - Inventory inv = Bukkit.createInventory(null, 45, "§8» §aGadgets §8«"); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - inv.setItem(0, new ItemBuilder(Material.ENDER_PEARL).setDisplayName("§dEnder Perle").removeAllAtributs().build()); - inv.setItem(1, new ItemBuilder(Material.ELYTRA).setDisplayName("§cJetpack").removeAllAtributs().build()); - inv.setItem(2, new ItemBuilder(Material.FISHING_ROD).setDisplayName("§eGreifhaken").removeAllAtributs().build()); - inv.setItem(3, new ItemBuilder(Material.getMaterial(417)).setDisplayName("§cTNT Kanone").addEnchantment(Enchantment.DURABILITY, 1).removeAllAtributs().build()); - - return inv; - } - - public Inventory Partikel() { - - Inventory inv = Bukkit.createInventory(null, 45, "§8» §dPartikel §8«"); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - // - - return inv; - } - - public Inventory Pets() { - - Inventory inv = Bukkit.createInventory(null, 45, "§8» §ePets §8«"); - - for(int i = 0; i < inv.getSize(); i++) { - inv.setItem(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (short)15).setDisplayName(" ").build()); - } - - // - - return inv; - } } diff --git a/src/de/diamant/hunjy/listener/PlayerKickEvent.java b/src/de/warking/lobby/listener/PlayerKickEvent.java similarity index 83% rename from src/de/diamant/hunjy/listener/PlayerKickEvent.java rename to src/de/warking/lobby/listener/PlayerKickEvent.java index 5fef299..bbdca0d 100644 --- a/src/de/diamant/hunjy/listener/PlayerKickEvent.java +++ b/src/de/warking/lobby/listener/PlayerKickEvent.java @@ -1,8 +1,8 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.manager.BackendManager; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; +import de.warking.lobby.manager.BackendManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/de/warking/lobby/listener/PlayerMoveListener.java b/src/de/warking/lobby/listener/PlayerMoveListener.java new file mode 100644 index 0000000..89801a2 --- /dev/null +++ b/src/de/warking/lobby/listener/PlayerMoveListener.java @@ -0,0 +1,42 @@ +package de.warking.lobby.listener; + +import de.warking.lobby.LobbySystem; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +public class PlayerMoveListener implements Listener { + + private static Location location = LobbySystem.getInstance().getLocationManager().loadLocation("main.lobby"); + + private static int minX = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.minX"); + private static int minY = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.minY"); + private static int minZ = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.minZ"); + + private static int maxX = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.maxX"); + private static int maxY = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.maxY"); + private static int maxZ = LobbySystem.getInstance().getFileManager().getIntegerFromConfig("WorldMaxRadius.maxZ"); + + @EventHandler + public void handlePlayerMove(PlayerMoveEvent event) { + Player player = event.getPlayer(); + if(player.getLocation().getY() < 100) + player.teleport(location); + + Location playerLocation = player.getLocation(); + int x = playerLocation.getBlockX(); + int y = playerLocation.getBlockY(); + int z = playerLocation.getBlockZ(); + + if(x <= minX + || x >= maxX + || y <= minY + || y >= maxY + || z <= minZ + || z >= maxZ) + player.teleport(location); + } + +} diff --git a/src/de/warking/lobby/listener/PlayerQuitListener.java b/src/de/warking/lobby/listener/PlayerQuitListener.java new file mode 100644 index 0000000..c8f6912 --- /dev/null +++ b/src/de/warking/lobby/listener/PlayerQuitListener.java @@ -0,0 +1,15 @@ +package de.warking.lobby.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +public class PlayerQuitListener implements Listener { + + @EventHandler + public void handlePlayerQuit(PlayerQuitEvent event) { + event.setQuitMessage(""); + } + + +} diff --git a/src/de/diamant/hunjy/listener/ProjectileLaunchEvent.java b/src/de/warking/lobby/listener/ProjectileLaunchEvent.java similarity index 92% rename from src/de/diamant/hunjy/listener/ProjectileLaunchEvent.java rename to src/de/warking/lobby/listener/ProjectileLaunchEvent.java index 3508d32..f90b87e 100644 --- a/src/de/diamant/hunjy/listener/ProjectileLaunchEvent.java +++ b/src/de/warking/lobby/listener/ProjectileLaunchEvent.java @@ -1,8 +1,8 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; -import de.diamant.hunjy.utils.ItemBuilder; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; +import de.warking.lobby.utils.ItemBuilder; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.EnderPearl; diff --git a/src/de/diamant/hunjy/listener/QuitEvent.java b/src/de/warking/lobby/listener/QuitEvent.java similarity index 88% rename from src/de/diamant/hunjy/listener/QuitEvent.java rename to src/de/warking/lobby/listener/QuitEvent.java index 015357d..cb8eae4 100644 --- a/src/de/diamant/hunjy/listener/QuitEvent.java +++ b/src/de/warking/lobby/listener/QuitEvent.java @@ -1,6 +1,6 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.manager.BackendManager; +import de.warking.lobby.manager.BackendManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/de/diamant/hunjy/listener/SneakListener.java b/src/de/warking/lobby/listener/SneakListener.java similarity index 93% rename from src/de/diamant/hunjy/listener/SneakListener.java rename to src/de/warking/lobby/listener/SneakListener.java index 6fd5dbc..febe0fb 100644 --- a/src/de/diamant/hunjy/listener/SneakListener.java +++ b/src/de/warking/lobby/listener/SneakListener.java @@ -1,7 +1,7 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Player; diff --git a/src/de/diamant/hunjy/listener/TeleportEvent.java b/src/de/warking/lobby/listener/TeleportEvent.java similarity index 83% rename from src/de/diamant/hunjy/listener/TeleportEvent.java rename to src/de/warking/lobby/listener/TeleportEvent.java index 64fe7f1..28d68e7 100644 --- a/src/de/diamant/hunjy/listener/TeleportEvent.java +++ b/src/de/warking/lobby/listener/TeleportEvent.java @@ -1,7 +1,7 @@ -package de.diamant.hunjy.listener; +package de.warking.lobby.listener; -import de.diamant.hunjy.gadgets.Gadget; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.gadgets.Gadget; +import de.warking.lobby.LobbySystem; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/de/diamant/hunjy/manager/BackendManager.java b/src/de/warking/lobby/manager/BackendManager.java similarity index 97% rename from src/de/diamant/hunjy/manager/BackendManager.java rename to src/de/warking/lobby/manager/BackendManager.java index 549494a..658c5cf 100644 --- a/src/de/diamant/hunjy/manager/BackendManager.java +++ b/src/de/warking/lobby/manager/BackendManager.java @@ -1,6 +1,6 @@ -package de.diamant.hunjy.manager; +package de.warking.lobby.manager; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.LobbySystem; import org.bukkit.entity.Player; import java.util.ArrayList; diff --git a/src/de/diamant/hunjy/manager/FileManager.java b/src/de/warking/lobby/manager/FileManager.java similarity index 93% rename from src/de/diamant/hunjy/manager/FileManager.java rename to src/de/warking/lobby/manager/FileManager.java index 6fbf174..6662516 100644 --- a/src/de/diamant/hunjy/manager/FileManager.java +++ b/src/de/warking/lobby/manager/FileManager.java @@ -1,11 +1,11 @@ -package de.diamant.hunjy.manager; +package de.warking.lobby.manager; import java.io.File; import java.io.IOException; import org.bukkit.configuration.file.FileConfiguration; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.LobbySystem; public class FileManager { diff --git a/src/de/diamant/hunjy/manager/LocationManager.java b/src/de/warking/lobby/manager/LocationManager.java similarity index 95% rename from src/de/diamant/hunjy/manager/LocationManager.java rename to src/de/warking/lobby/manager/LocationManager.java index 5ae1669..86415c9 100644 --- a/src/de/diamant/hunjy/manager/LocationManager.java +++ b/src/de/warking/lobby/manager/LocationManager.java @@ -1,4 +1,4 @@ -package de.diamant.hunjy.manager; +package de.warking.lobby.manager; import java.io.File; import java.io.IOException; @@ -8,7 +8,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.file.YamlConfiguration; -import de.diamant.hunjy.main.LobbySystem; +import de.warking.lobby.LobbySystem; public class LocationManager { diff --git a/src/de/diamant/hunjy/utils/ItemBuilder.java b/src/de/warking/lobby/utils/ItemBuilder.java similarity index 90% rename from src/de/diamant/hunjy/utils/ItemBuilder.java rename to src/de/warking/lobby/utils/ItemBuilder.java index 3f652fa..1b31e76 100644 --- a/src/de/diamant/hunjy/utils/ItemBuilder.java +++ b/src/de/warking/lobby/utils/ItemBuilder.java @@ -1,4 +1,4 @@ -package de.diamant.hunjy.utils; +package de.warking.lobby.utils; import java.util.ArrayList; @@ -57,5 +57,10 @@ public class ItemBuilder { item.setItemMeta(meta); return item; } + + public ItemBuilder setUnbreakable(boolean unbreakable) { + meta.setUnbreakable(unbreakable); + return this; + } } diff --git a/src/plugin.yml b/src/plugin.yml index ae7a16e..0188af7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,9 +1,8 @@ name: LobbySystem version: 1.0 - -author: hunjy - -main: de.diamant.hunjy.main.LobbySystem +author: [hunjy, Yaruma3341] +depend: [CoreSystem] +main: de.warking.lobby.LobbySystem commands: setlocation: