Archiviert
13
0
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-28 19:55:07 +01:00
Ursprung e2db48c06d
Commit 4e00e3153f
25 geänderte Dateien mit 1568 neuen und 0 gelöschten Zeilen

3
.gitignore vendored Normale Datei
Datei anzeigen

@ -0,0 +1,3 @@
.idea
pom.xml
*.iml

30
src/config.yml Normale Datei
Datei anzeigen

@ -0,0 +1,30 @@
Event:
Join:
allowJoinMessage: false
JoinMessage: '&e%player% &eist dem Server beigetreten!'
allowFirstJoinMessage: false
FirstJoinMessage: '&e%player% &eist neu auf dem Server beigetreten!'
allowQuitMessage: false
QuitMessage: '&e%player% &ehat den Server verlassen!'
Messages:
Commands:
SetLocationMessage: '%prefix% &7Die Positionfür &8[%display%&8] &7wurde gesetzt!'
Prefix: '&bLobbySystem &8>> &7'
Items:
Lobby:
Navigator:
ID: 'COMPASS'
Display: '&bNavigator'
Slot: 1
Extras:
ID: 'CHEST'
Display: '&aExtras'
Slot: 5
Lobby-Switcher:
ID: 'NETHER_STAR'
Display: '&eServer Wechseln'
Slot: 9
Hider:
ID: 'BLAZE_ROD'
Display: '&9Spieler Verstecken'
Slot: 2

Datei anzeigen

@ -0,0 +1,83 @@
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;
}
}

Datei anzeigen

@ -0,0 +1,56 @@
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());
}
}

Datei anzeigen

@ -0,0 +1,40 @@
package de.diamant.hunjy.command;
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
public boolean onCommand(CommandSender sender, Command command, String lable, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player)sender;
if(args.length == 0) {
player.sendMessage(LobbySystem.prefix + "§7Benutze §c/check [loc/mysql/config]");
}else if(args.length == 1) {
if(args[0].equalsIgnoreCase("loc") || args[0].equalsIgnoreCase("l") || args[0].equalsIgnoreCase("location")) {
if(player.hasPermission("lobby.admin.edit.location")) {
String[] split = LobbySystem.getInstance().getBackendManager().checkLocations().split(" newLine ");
player.sendMessage(LobbySystem.prefix + "§7Es fehlen folgene Positionen!");
if(split.length > 0) {
for(int i = 0; i < split.length; i++) {
player.sendMessage(split[i]);
}
player.sendMessage(LobbySystem.prefix + "§7Du kannst die fehlnene Positionen mit §c/setlocation §7erstellen");
}else {
player.sendMessage(LobbySystem.prefix + "§aEs wurden alle Positionen gesetzt!");
}
}
}
}
return false;
}
}

Datei anzeigen

@ -0,0 +1,53 @@
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;
}
}

Datei anzeigen

@ -0,0 +1,9 @@
package de.diamant.hunjy.gadgets;
public enum Gadget {
ENDER_PEARL,
JETPACK,
HOOK,
TNT_CANNON;
}

Datei anzeigen

@ -0,0 +1,50 @@
package de.diamant.hunjy.gadgets;
import org.bukkit.entity.Player;
import java.util.HashMap;
public class GadgetManager {
public HashMap<Player, Gadget> playerGadgets = new HashMap<>();
public HashMap<Player, Gadget> playerGadgetCooldown = new HashMap<>();
public GadgetManager() {
}
public Gadget getPlayerGadget(Player player) {
return playerGadgets.get(player);
}
public void setPlayerGadget(Player player, Gadget gadget) {
playerGadgets.put(player, gadget);
}
public void removePlayerGadget(Player player) {
playerGadgets.remove(player);
}
public boolean hasPlayerGadget(Player player) {
if(playerGadgets.containsKey(player)) {
return true;
} else
return false;
}
public void setPlayerGadgetCooldown(Player player, Gadget gadget) {
playerGadgetCooldown.put(player, gadget);
}
public void removePlayerGadgetCooldown(Player player) {
playerGadgetCooldown.remove(player);
}
public boolean hasPlayerGadgetCooldown(Player player) {
if(playerGadgetCooldown.containsKey(player)) {
return true;
} else
return false;
}
}

Datei anzeigen

@ -0,0 +1,44 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.manager.BackendManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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.weather.WeatherChangeEvent;
public class BlockListener implements Listener{
@EventHandler
private void onDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player) {
//event.setCancelled(true);
}
}
@EventHandler
private void onFoodChange(FoodLevelChangeEvent event) {
event.setCancelled(true);
}
@EventHandler
private void onBuild(BlockPlaceEvent event) {
if(!BackendManager.canBuild.contains(event.getPlayer())) event.setCancelled(true);
}
@EventHandler
private void onBreak(BlockBreakEvent event) {
if(!BackendManager.canBuild.contains(event.getPlayer())) event.setCancelled(true);
}
@EventHandler
private void onwehthgerChange(WeatherChangeEvent event) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -0,0 +1,38 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import net.minecraft.server.v1_12_R1.PacketPlayOutExplosion;
import net.minecraft.server.v1_12_R1.Vec3D;
import org.bukkit.Bukkit;
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;
import java.util.Collections;
public class EntityDamageByEntityEvent implements Listener {
@EventHandler
public void handleProjectileHit(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
if(event.getDamager() instanceof Snowball) {
event.setCancelled(true);
if(((Snowball) event.getDamager()).getShooter() instanceof Player) {
Player player = ((Player) ((Snowball) event.getDamager()).getShooter()).getPlayer();
if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.TNT_CANNON) {
for(Player allPlayers : Bukkit.getServer().getOnlinePlayers()) {
((CraftPlayer)allPlayers).getHandle().playerConnection.sendPacket(new PacketPlayOutExplosion(event.getDamager().getLocation().getBlockX(), event.getDamager().getLocation().getBlockY(), event.getDamager().getLocation().getBlockZ(), Float.MAX_VALUE, Collections.EMPTY_LIST, new Vec3D(2.5, 2.5, 2.5)));
}
player.getWorld().playSound(event.getDamager().getLocation(), Sound.ENTITY_ENDERDRAGON_FIREBALL_EXPLODE, 1, 1);
}
}
}
}
}

Datei anzeigen

@ -0,0 +1,49 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.util.Vector;
public class FishEvent implements Listener {
@EventHandler
public void handlePlayerFish(PlayerFishEvent event) {
Player player = event.getPlayer();
if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.HOOK) {
Fish fish = event.getHook();
if(((event.getState().equals(PlayerFishEvent.State.IN_GROUND)) || (event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) || (event.getState().equals(PlayerFishEvent.State.FAILED_ATTEMPT))) && (Bukkit.getWorld(event.getPlayer().getWorld().getName()).getBlockAt(fish.getLocation().getBlockX(), fish.getLocation().getBlockY() - 1, fish.getLocation().getBlockZ()).getType() != Material.AIR) && (Bukkit.getWorld(event.getPlayer().getWorld().getName()).getBlockAt(fish.getLocation().getBlockX(), fish.getLocation().getBlockY() - 1, fish.getLocation().getBlockZ()).getType() != Material.STATIONARY_WATER)) {
Location location = player.getLocation();
Location to = event.getHook().getLocation();
location.setY(location.getY() + 0.8D);
player.teleport(location);
double t = to.distance(location);
double v_x = (1.0D + 0.07D * t) * (to.getX() - location.getX()) / t;
double v_y = (1.0D + 0.03D * t) * (to.getY() - location.getY()) / t - -0.04D * t;
double v_z = (1.0D + 0.07D * t) * (to.getZ() - location.getZ()) / t;
Vector vector = player.getVelocity();
vector.setX(v_x);
vector.setY(v_y);
vector.setZ(v_z);
player.setVelocity(vector);
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
}
}
}
}

Datei anzeigen

@ -0,0 +1,63 @@
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());
}
}

Datei anzeigen

@ -0,0 +1,136 @@
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);
}
}

Datei anzeigen

@ -0,0 +1,365 @@
package de.diamant.hunjy.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 org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import de.diamant.hunjy.main.LobbySystem;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public class LobbyInvClickManager implements Listener{
public static ArrayList<Player> inSetup = new ArrayList<Player>();
public FileManager fm = LobbySystem.getInstance().getFileManager();
@EventHandler
private void onInvClick(InventoryClickEvent event) {
Player player = (Player)event.getWhoClicked();
if(!BackendManager.canBuild.contains(player)) {
event.setCancelled(true);
} else {
player.closeInventory();
player.sendMessage(LobbySystem.prefix + "Du kannst im Builder Modus keine Tools nutzen nutzen!");
}
//inSetup
if(inSetup.contains(player)) {
if(event.getCurrentItem() == null || event.getClickedInventory() == null || event.getClickedInventory() == player.getOpenInventory().getBottomInventory())return;
Material mat = event.getCurrentItem().getType();
String name = event.getCurrentItem().getItemMeta().getDisplayName();
String msg = LobbySystem.getInstance().getBackendManager().SetLobbyMessage.replaceAll("%display%", name);
switch (mat) {
case MAGMA_CREAM:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("main.lobby", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case ELYTRA:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.airship", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case CHEST:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.minigame", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case TNT:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.wargear", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case WOOD_SWORD:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.survival", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case EXPLOSIVE_MINECART:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.miniwargear", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case GOLD_NUGGET:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.tb", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
case BOWL:
player.closeInventory();
LobbySystem.getInstance().getLocationManager().saveLocation("navigation.battlebox", player.getLocation());
player.sendMessage(msg);
inSetup.remove(player);
break;
default:
break;
}
}else {
if(event.getCurrentItem() == null || event.getClickedInventory() == null || event.getClickedInventory() == player.getOpenInventory().getBottomInventory())return;
Material material = event.getCurrentItem().getType();
String materialName = event.getCurrentItem().getItemMeta().getDisplayName();
//navigator
String navigatorName = fm.getStringFromConfig("Items.Lobby.Navigator.Display").replaceAll("&", "§");
if(event.getClickedInventory().getType() == InventoryType.CHEST && event.getClickedInventory().getName().equals(navigatorName)) {
switch (materialName) {
case "§8» §6Spawn §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("main.lobby"));
break;
case "§8» §3AirShip §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.airship"));
break;
case "§8» §aMiniGames §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.minigame"));
break;
case "§8» §9WarGear §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.wargear"));
break;
case "§8» §2Survival §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.survival"));
break;
case "§8» §bMini WarGear §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.miniwargear"));
break;
case "§8» §eTägliche Belohnung §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.tb"));
break;
case "§8» §dBattleBox §8«":
player.teleport(LobbySystem.getInstance().getLocationManager().loadLocation("navigation.battlebox"));
break;
}
return;
}
//hide players
String hiderName = fm.getStringFromConfig("Items.Lobby.Hider.Display").replaceAll("&", "§");
if (event.getClickedInventory().getType() == InventoryType.BREWING && event.getClickedInventory().getName().equals(hiderName)) {
switch (materialName) {
case "§8» §aAlle Spieler §8«":
for (Player allPlayers : Bukkit.getServer().getOnlinePlayers()) {
player.showPlayer(allPlayers);
}
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());
break;
case "§8» §5YouTuber/ Teammitglieder §8«":
for (Player allPlayers : Bukkit.getServer().getOnlinePlayers()) {
if (!allPlayers.hasPermission("PERMISSION")) {//permission fehlt
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());
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());
break;
case "§8» §cSilentLobby §8«":
//change server
break;
}
return;
}
//Extras
String extrasName = fm.getStringFromConfig("Items.Lobby.Extras.Display").replaceAll("&", "§").split(" ")[0];
if (event.getClickedInventory().getType() == InventoryType.CHEST && event.getClickedInventory().getName().equals(extrasName)) {
switch (materialName) {
case "§8» §9Rüstung §8«":
player.openInventory(ArmorInventory());
break;
case "§8» §aGadgets §8«":
player.openInventory(Gadgets());
break;
case "§8» §dPartikel §8«":
player.openInventory(Partikel());
break;
case "§8» §ePets §8«":
player.openInventory(Pets());
break;
}
return;
}
if(event.getClickedInventory().getType() == InventoryType.CHEST && event.getClickedInventory().getName().equals("§8» §9Rüstung §8«")) {
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());
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());
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());
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());
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());
break;
}
return;
}
//Gadgets
if(event.getClickedInventory().getType() == InventoryType.CHEST && event.getClickedInventory().getName().equals("§8» §aGadgets §8«")) {
switch (materialName) {
case "§dEnder Perle":
player.getInventory().setItem(5, new ItemBuilder(Material.ENDER_PEARL).setDisplayName("§dEnder Perle").removeAllAtributs().build());
if(LobbySystem.getInstance().getGadgetManager().hasPlayerGadget(player)) LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player);
LobbySystem.getInstance().getGadgetManager().setPlayerGadget(player, Gadget.ENDER_PEARL);
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 100);
player.updateInventory();
break;
case "§cJetpack":
player.getInventory().setItem(5, new ItemBuilder(Material.ELYTRA).setDisplayName("§cJetpack").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());
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());
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);
player.updateInventory();
break;
}
}
}
}
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;
}
}

Datei anzeigen

@ -0,0 +1,26 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import de.diamant.hunjy.manager.BackendManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PlayerKickEvent implements Listener {
@EventHandler
public void handlePlayerKick(org.bukkit.event.player.PlayerKickEvent event) {
Player player = event.getPlayer();
if (event.getReason().equals("Flying is not enabled on this server")) {
if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.ENDER_PEARL) event.setCancelled(true);
if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.JETPACK) event.setCancelled(true);
} else {
LobbySystem.getInstance().getGadgetManager().removePlayerGadget(player);
if(BackendManager.canBuild.contains(player)) BackendManager.canBuild.remove(player);
}
}
}

Datei anzeigen

@ -0,0 +1,56 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import de.diamant.hunjy.utils.ItemBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
public class ProjectileLaunchEvent implements Listener {
@EventHandler
public void handleProjectileLaunch(org.bukkit.event.entity.ProjectileLaunchEvent event) {
Entity projectile = event.getEntity();
if(projectile instanceof EnderPearl) {
final EnderPearl enderpearl = (EnderPearl)projectile;
if(enderpearl.getShooter() instanceof Player) {
final Player player = (Player)enderpearl.getShooter();
Vector vec = enderpearl.getVelocity();
vec.multiply(4);
Bukkit.getScheduler().scheduleSyncDelayedTask(LobbySystem.getInstance(), new Runnable() {
@Override
public void run() {
player.getInventory().setItem(5, new ItemBuilder(Material.INK_SACK, (short)8).setDisplayName("§6Warten...").removeAllAtributs().build());
}
}, 5L);
player.updateInventory();
LobbySystem.getInstance().getGadgetManager().setPlayerGadgetCooldown(player, Gadget.ENDER_PEARL);
Bukkit.getScheduler().runTaskLater(LobbySystem.getInstance(), new Runnable() {
@Override
public void run() {
LobbySystem.getInstance().getGadgetManager().removePlayerGadgetCooldown(player);
if(!LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player).equals(Gadget.ENDER_PEARL)) return;
player.getInventory().setItem(5, new ItemBuilder(Material.ENDER_PEARL).setDisplayName("§dEnder Perle").removeAllAtributs().build());
}
}, 20*10);
player.setVelocity(vec);
enderpearl.setPassenger(player);
}
}
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.manager.BackendManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class QuitEvent implements Listener {
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(BackendManager.hideAll.contains(player)) BackendManager.hideAll.remove(player);
if(BackendManager.hideUsers.contains(player)) BackendManager.hideUsers.remove(player);
if(BackendManager.canBuild.contains(player)) BackendManager.canBuild.remove(player);
}
}

Datei anzeigen

@ -0,0 +1,45 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class SneakListener implements Listener {
@EventHandler
public void handleSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
if(LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.JETPACK) {
new BukkitRunnable() {
@Override
public void run() {
if(player.isSneaking() && LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.JETPACK) {
player.setVelocity(player.getLocation().getDirection().multiply(0.7D).setY(0.3D));
} else
cancel();
}
}.runTaskTimer(LobbySystem.getInstance(), 1L, 4L);
new BukkitRunnable() {
@Override
public void run() {
if(player.isSneaking() && LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.JETPACK) {
player.getWorld().playEffect(player.getLocation(), Effect.LAVA_POP, 10);
player.getWorld().playEffect(player.getLocation(), Effect.LAVA_POP, 10);
player.getWorld().playEffect(player.getLocation(), Effect.LAVA_POP, 10);
player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_LAUNCH, 0.1F, 0.1F);
}
}
}.runTaskTimer(LobbySystem.getInstance(), 1L, 1L);
}
}
}

Datei anzeigen

@ -0,0 +1,20 @@
package de.diamant.hunjy.listener;
import de.diamant.hunjy.gadgets.Gadget;
import de.diamant.hunjy.main.LobbySystem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportEvent implements Listener {
@EventHandler
public void handlePlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if(event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && LobbySystem.getInstance().getGadgetManager().getPlayerGadget(player) == Gadget.ENDER_PEARL && event.getTo().distance(player.getLocation()) <= 0) event.setCancelled(true);
}
}

Datei anzeigen

@ -0,0 +1,88 @@
package de.diamant.hunjy.main;
import de.diamant.hunjy.gadgets.GadgetManager;
import de.diamant.hunjy.listener.*;
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 static String prefix;
private static LobbySystem instance;
private LocationManager locationManager;
private FileManager fileManager;
private BackendManager backendManager;
private GadgetManager gadgetManager;
@Override
public void onLoad() {
instance = this;
}
@Override
public void onEnable() {
locationManager = new LocationManager();
fileManager = new FileManager(instance);
loadBackend();
prefix = backendManager.prefix;
this.getCommand("setlocation").setExecutor(new setLocation());
this.getCommand("check").setExecutor(new checkCommand());
this.getCommand("build").setExecutor(new buildCommand());
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new JoinEvent(), instance);
pm.registerEvents(new BlockListener(), 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 SneakListener(), instance);
pm.registerEvents(new TeleportEvent(), instance);
pm.registerEvents(new FishEvent(), instance);
pm.registerEvents(new EntityDamageByEntityEvent(), instance);
}
public void loadBackend() {
backendManager = new BackendManager();
backendManager.loadBackend(fileManager);
gadgetManager = new GadgetManager();
}
public static LobbySystem getInstance() {
return instance;
}
public LocationManager getLocationManager() {
return locationManager;
}
public FileManager getFileManager() {
return fileManager;
}
public BackendManager getBackendManager() {
return backendManager;
}
public GadgetManager getGadgetManager() { return gadgetManager; }
}

Datei anzeigen

@ -0,0 +1,79 @@
package de.diamant.hunjy.manager;
import de.diamant.hunjy.main.LobbySystem;
import org.bukkit.entity.Player;
import java.util.ArrayList;
public class BackendManager {
public boolean allowJoinMessage;
public String JoinMessage;
public boolean allowQuitMessage;
public String QuitMessage;
public boolean allowFisrtJoinMessage;
public String FisrtJoinMessage;
public String prefix;
public String SetLobbyMessage;
public static ArrayList<Player> hideAll = new ArrayList<>();//alle Spieler verstecken
public static ArrayList<Player> hideUsers = new ArrayList<>();//nur YouTuber/Teammitglieder anzeigen
public static ArrayList<Player> canBuild = new ArrayList<>();
public BackendManager() {
}
public void loadBackend(FileManager fileManager) {
allowJoinMessage = fileManager.getBooleanFromConfig("Event.Join.allowJoinMessage");
allowFisrtJoinMessage = fileManager.getBooleanFromConfig("Event.Join.allowFirstJoinMessage");
allowQuitMessage = fileManager.getBooleanFromConfig("Event.Join.allowQuitMessage");
JoinMessage = fileManager.getStringFromConfig("Event.Join.JoinMessage");
FisrtJoinMessage = fileManager.getStringFromConfig("Event.Join.FirstJoinMessage");
QuitMessage = fileManager.getStringFromConfig("Event.Join.QuitMessage");
prefix = fileManager.getStringFromConfig("Messages.Prefix");
SetLobbyMessage = fileManager.getStringFromConfig("Messages.Commands.SetLocationMessage").replaceAll("%prefix%", prefix).replaceAll("&", "§");
}
public String checkLocations() {
LocationManager locManager = LobbySystem.getInstance().getLocationManager();
String errorCode = "";
if(!locManager.hasLocation("main.lobby")) {
errorCode += "§8[§c✕§8] §cSpawn newLine ";
}
if(!locManager.hasLocation("navigation.airship")) {
errorCode += "§8[§c✕§8] §cAirShip" + " newLine ";
}
if(!locManager.hasLocation("navigation.minigame")) {
errorCode += "§8[§c✕§8] §cSpawn" + " newLine ";
}
if(!locManager.hasLocation("navigation.wargear")) {
errorCode += "§8[§c✕§8] §cWarGear" + " newLine ";
}
if(!locManager.hasLocation("navigation.survival")) {
errorCode += "§8[§c✕§8] §cSurvival" + " newLine ";
}
if(!locManager.hasLocation("navigation.miniwargear")) {
errorCode += "§8[§c✕§8] §cMini WarGear" + " newLine ";
}
if(!locManager.hasLocation("navigation.tb")) {
errorCode += "§8[§c✕§8] §cTägliche Belohnung" + " newLine ";
}
if(!locManager.hasLocation("navigation.battlebox")) {
errorCode += "§8[§c✕§8] §cBattle Box" + " newLine ";
}
return errorCode;
}
}

Datei anzeigen

@ -0,0 +1,68 @@
package de.diamant.hunjy.manager;
import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.FileConfiguration;
import de.diamant.hunjy.main.LobbySystem;
public class FileManager {
public File file;
public FileConfiguration config;
public FileManager(LobbySystem instance) {
config = instance.getConfig();
config.options().copyDefaults(true);
file = new File(instance.getDataFolder(), "config.yml");
instance.saveConfig();
}
public void reloadFiles(LobbySystem instance) {
instance.reloadConfig();
}
public void addNewPath(String path, String data) {
if(config.contains(path) || config.contains(data))
return;
config.set(path, data);
save();
}
public String getStringFromConfig(String path) {
return config.getString(path).replaceAll("&", "§");
}
public int getIntegerFromConfig(String path) {
return config.getInt(path);
}
public boolean getBooleanFromConfig(String path) {
return config.getBoolean(path);
}
public File getFile() {
return file;
}
public FileConfiguration getConfig() {
return config;
}
public void save() {
try {
config.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

Datei anzeigen

@ -0,0 +1,73 @@
package de.diamant.hunjy.manager;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import de.diamant.hunjy.main.LobbySystem;
public class LocationManager {
private File file;
private YamlConfiguration config;
public LocationManager() {
file = new File(LobbySystem.getInstance().getDataFolder() + "/Data/Locations", "locs.yml");
config = YamlConfiguration.loadConfiguration(file);
}
public void saveLocation(String path, Location loc) {
config.set(path + ".WORLD", loc.getWorld().getName());
config.set(path + ".X", loc.getX());
config.set(path + ".Y", loc.getY());
config.set(path + ".Z", loc.getZ());
config.set(path + ".YAW", loc.getYaw());
config.set(path + ".PITCH", loc.getPitch());
save();
}
public Location loadLocation(String path) {
World world = Bukkit.getWorld(config.getString(path + ".WORLD"));
double x = config.getDouble(path + ".X");
double y = config.getDouble(path + ".Y");
double z = config.getDouble(path + ".Z");
float yaw = (float) config.getDouble(path + ".YAW");
float pitch = (float) config.getDouble(path + ".PITCH");
return new Location(world, x, y, z, yaw, pitch);
}
public void save() {
try {
config.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
public File getFile() {
return file;
}
public YamlConfiguration getConfig() {
return config;
}
public boolean hasLocation(String string) {
if(config.contains(string))
return true;
return false;
}
}

Datei anzeigen

@ -0,0 +1,61 @@
package de.diamant.hunjy.utils;
import java.util.ArrayList;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ItemBuilder {
private ItemStack item;
private ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
meta = item.getItemMeta();
}
public ItemBuilder removeAllAtributs() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(ArrayList<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
return this;
}
public ItemStack build() {
item.setItemMeta(meta);
return item;
}
}

12
src/plugin.yml Normale Datei
Datei anzeigen

@ -0,0 +1,12 @@
name: LobbySystem
version: 1.0
author: hunjy
main: de.diamant.hunjy.main.LobbySystem
commands:
setlocation:
check:
build: