Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package party.events;
- import java.io.File;
- import org.bukkit.Bukkit;
- import org.bukkit.GameMode;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- 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.ItemStack;
- import party.main.PartyPvP;
- public class Join implements Listener {
- private PartyPvP plugin;
- int Start = 6;
- int Countdown;
- public Join(PartyPvP partyPvP) {
- this.plugin = partyPvP;
- plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
- }
- public boolean isStarted = false;
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- final Player p = e.getPlayer();
- e.setJoinMessage(plugin.Prefix + "§5" + p.getName() + "§7 hat den PartyPvP Server betreten.");
- if(plugin.blue.size() == 0) {
- plugin.blue.add(p);
- p.sendMessage(plugin.Prefix + "Du wurdest in das Team §9Blau §7verschoben!");
- p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
- } else if(plugin.red.size() == 0) {
- plugin.red.add(p);
- p.sendMessage(plugin.Prefix + "Du wurdest in das Team §cRot §7verschoben!");
- p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
- } else if(plugin.green.size() == 0) {
- plugin.green.add(p);
- p.sendMessage(plugin.Prefix + "Du wurdest in das Team §aGrün §7verschoben!");
- p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
- } else if(plugin.yellow.size() == 0) {
- plugin.yellow.add(p);
- p.sendMessage(plugin.Prefix + "Du wurdest in das Team §eGelb §7verschoben!");
- p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind.");
- p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3);
- }
- startCountdown();
- }
- private void Items(Player p) {
- p.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
- p.getInventory().addItem(new ItemStack(Material.FISHING_ROD));
- p.getInventory().addItem(new ItemStack(Material.BOW));
- p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 1));
- p.getInventory().addItem(new ItemStack(Material.BREAD, 5));
- p.getInventory().addItem(new ItemStack(Material.ARROW, 5));
- p.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
- p.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
- p.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
- p.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS));
- }
- public void startCountdown() {
- if(isStarted || Bukkit.getOnlinePlayers().length != 4) {
- return;
- }
- if(Bukkit.getOnlinePlayers().length == 4) {
- for(final Player players : Bukkit.getOnlinePlayers()) {
- Countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- @Override
- public void run() {
- if(isStarted) {
- return;
- }
- isStarted = true;
- Start--;
- if(Start == 5) {
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §55 §7Sekunden!");
- } else if(Start == 4) {
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §54 §7Sekunden!");
- } else if(Start == 3) {
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §53 §7Sekunden!");
- } else if(Start == 2) {
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §52 §7Sekunden!");
- } else if(Start == 1) {
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §51 §7Sekunde!");
- } else if(Start == 0) {
- Bukkit.getScheduler().cancelTask(Countdown);
- Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel hat gestartet! §5Viel Glück!");
- for(Player red : plugin.red) {
- File file = new File("plugins/PartyPvP/", "Red-Point.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- String world = cfg.getString("red.World");
- double x = cfg.getDouble("red.X");
- double y = cfg.getDouble("red.Y");
- double z = cfg.getDouble("red.Z");
- double yaw = cfg.getDouble("red.Yaw");
- double pitch = cfg.getDouble("red.Pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- red.teleport(loc);
- Items(red);
- red.setGameMode(GameMode.ADVENTURE);
- }
- for(Player blue : plugin.blue) {
- File file = new File("plugins/PartyPvP/", "Blue-Point.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- String world = cfg.getString("blue.World");
- double x = cfg.getDouble("blue.X");
- double y = cfg.getDouble("blue.Y");
- double z = cfg.getDouble("blue.Z");
- double yaw = cfg.getDouble("blue.Yaw");
- double pitch = cfg.getDouble("blue.Pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- blue.teleport(loc);
- Items(blue);
- blue.setGameMode(GameMode.ADVENTURE);
- }
- for(Player green : plugin.green) {
- File file = new File("plugins/PartyPvP/", "Green-Point.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- String world = cfg.getString("green.World");
- double x = cfg.getDouble("green.X");
- double y = cfg.getDouble("green.Y");
- double z = cfg.getDouble("green.Z");
- double yaw = cfg.getDouble("green.Yaw");
- double pitch = cfg.getDouble("green.Pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- green.teleport(loc);
- Items(green);
- green.setGameMode(GameMode.ADVENTURE);
- }
- for(Player yellow : plugin.yellow) {
- File file = new File("plugins/PartyPvP/", "Yellow-Point.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- String world = cfg.getString("yellow.World");
- double x = cfg.getDouble("yellow.X");
- double y = cfg.getDouble("yellow.Y");
- double z = cfg.getDouble("yellow.Z");
- double yaw = cfg.getDouble("yellow.Yaw");
- double pitch = cfg.getDouble("yellow.Pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- yellow.teleport(loc);
- Items(yellow);
- yellow.setGameMode(GameMode.ADVENTURE);
- }
- }
- }
- }, 0, 20);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement