Advertisement
NiRoXz

startCountdown(); und teleport();

Mar 20th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.60 KB | None | 0 0
  1.       public void startCountdown() {
  2.           this.cd = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  3.            
  4.             @Override
  5.             public void run() {
  6.                
  7.                 if(Bukkit.getOnlinePlayers().size() < 2) {
  8.                     for(Player all : Bukkit.getOnlinePlayers()) {
  9.                         all.sendMessage(prefix + "§cEs müssen mindestens §e2 §cSpieler im Spiel sein!");
  10.                     }
  11.                     return;
  12.                 }
  13.                
  14.                 cdamount--;
  15.                
  16.                 for(Player all : Bukkit.getOnlinePlayers()) {
  17.                     all.setLevel(cdamount);
  18.                     all.setExp((float) (cdamount)/50);
  19.                 }
  20.                
  21.                 if(cdamount == 50) {
  22.                     for(Player all : Bukkit.getOnlinePlayers()) {
  23.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §650 §7Sekunden!");
  24.                         all.playSound(all.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1, 2);
  25.                     }
  26.                 }
  27.                
  28.                 if(cdamount == 30) {
  29.                     for(Player all : Bukkit.getOnlinePlayers()) {
  30.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §630 §7Sekunden!");
  31.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  32.                     }
  33.                 }
  34.                
  35.                 if(cdamount == 15) {
  36.                     for(Player all : Bukkit.getOnlinePlayers()) {
  37.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §615 §7Sekunden!");
  38.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  39.                     }
  40.                 }
  41.                
  42.                 if(cdamount == 10) {
  43.                     for(Player all : Bukkit.getOnlinePlayers()) {
  44.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §610 §7Sekunden!");
  45.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  46.                     }
  47.                 }
  48.                
  49.                 if(cdamount == 5) {
  50.                     for(Player all : Bukkit.getOnlinePlayers()) {
  51.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §65 §7Sekunden!");
  52.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  53.                     }
  54.                 }
  55.                
  56.                 if(cdamount == 4) {
  57.                     for(Player all : Bukkit.getOnlinePlayers()) {
  58.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §64 §7Sekunden!");
  59.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  60.                     }
  61.                 }
  62.                
  63.                 if(cdamount == 3) {
  64.                     for(Player all : Bukkit.getOnlinePlayers()) {
  65.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §63 §7Sekunden!");
  66.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  67.                     }
  68.                 }
  69.                
  70.                 if(cdamount == 2) {
  71.                     for(Player all : Bukkit.getOnlinePlayers()) {
  72.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §62 §7Sekunden!");
  73.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  74.                     }
  75.                 }
  76.                
  77.                 if(cdamount == 1) {
  78.                     for(Player all : Bukkit.getOnlinePlayers()) {
  79.                         all.sendMessage(prefix + "§7Das Spiel beginnt in §61 §7Sekunden!");
  80.                         all.playSound(all.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
  81.                     }
  82.                 }
  83.                
  84.                 if(cdamount == 0) {
  85.                     Bukkit.getScheduler().cancelTask(cd);
  86.                     cdamount = 51;
  87.                                        
  88.                     for(Player all : Bukkit.getOnlinePlayers()) {
  89.                         sendIngameScoreboard(all);
  90.                         all.sendMessage(prefix + "§aDas Spiel startet!");
  91.                         all.playSound(all.getLocation(), Sound.ENTITY_ENDERDRAGON_GROWL, 1, 2);
  92.                     }
  93.                    
  94.                     gs = GameState.INGAME;
  95.                    
  96.                     startBronzeSpawner();
  97.                     startEisenSpawner();
  98.                     startGoldSpawner();
  99.                    
  100.                     for (final Player all : Bukkit.getOnlinePlayers()) {
  101.                        
  102.                         if(!(TeamRot.contains(all) | TeamBlau.contains(all))) {
  103.                             int max = 0;
  104.                             int tr = TeamRot.size();
  105.                             int tb = TeamBlau.size();
  106.                            
  107.                             if(tr > tb) {
  108.                                 TeamBlau.add(all);
  109.                                   all.sendMessage(MainClass.prefix + "§7Du wurdest in das §9Team Blau §7geschoben!");
  110.                             }
  111.                             if(tb > tr) {
  112.                                 TeamRot.add(all);
  113.                               all.sendMessage(MainClass.prefix + "§7Du wurdest in das §cTeam Rot §7geschoben!");
  114.                             }
  115.                             if(tb == tr) {
  116.                                 Random r = new Random();
  117.                                 int i = r.nextInt(2);
  118.                                
  119.                                 if(i == 1) {
  120.                                     TeamBlau.add(all);
  121.                                     all.sendMessage(MainClass.prefix + "§7Du wurdest in das §9Team Blau §7geschoben!");
  122.                                 } else
  123.                                 if(i == 2) {
  124.                                     TeamRot.add(all);
  125.                                     all.sendMessage(MainClass.prefix + "§7Du wurdest in das §cTeam Rot §7geschoben!");
  126.                                 }
  127.                             }
  128.                            
  129.                         }
  130.                        
  131.                     }
  132.                    
  133.                    
  134.                     for (Player teamblau : TeamBlau) {
  135.                        
  136.                         teleport(teamblau);
  137.                        
  138.                         BountifulAPI.sendTitle(teamblau,20,10,10,"§e" +ms ,"§9Team Blau");
  139.                         HasBlock.add(teamblau);
  140.                     }
  141.                    
  142.                     for (Player teamrot : TeamRot) {   
  143.                        
  144.                         teleport(teamrot);
  145.                        
  146.                         BountifulAPI.sendTitle(teamrot,20,10,10,"§e" +ms ,"§cTeam Rot");
  147.                         HasBlock.add(teamrot);
  148.                     }
  149.                 }
  150.             }
  151.         }, 0, 20L);
  152.       }
  153.      
  154.  
  155.       public void teleport(Player p) {
  156.           int team = 0;
  157.          
  158.           if(TeamBlau.contains(p)) team = 1;
  159.           if(TeamRot.contains(p)) team = 2;
  160.          
  161.           if(team == 1) {
  162.               File mapfile = new File("plugins/NextPlugin/Maps", "maps.yml");
  163.                 FileConfiguration cfgmap = YamlConfiguration.loadConfiguration(mapfile);
  164.                  
  165.                 String world = cfgmap.getString("Warps." +ms+ ".Blau.World");
  166.                 double x = cfgmap.getDouble("Warps." +ms+ ".Blau.X");
  167.                 double y = cfgmap.getDouble("Warps." +ms+ ".Blau.Y");
  168.                 double z = cfgmap.getDouble("Warps." +ms+ ".Blau.Z");
  169.                 double yaw = cfgmap.getDouble("Warps." +ms+ ".Blau.Yaw");
  170.                 double pitch = cfgmap.getDouble("Warps." +ms+ ".Blau.Pitch");
  171.                 Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  172.                 loc.setYaw((float)yaw);
  173.                 loc.setPitch((float)pitch);
  174.  
  175.                 p.teleport(loc);
  176.           }
  177.          
  178.           if(team == 2) {
  179.               File mapfile = new File("plugins/NextPlugin/Maps", "maps.yml");
  180.                 FileConfiguration cfgmap = YamlConfiguration.loadConfiguration(mapfile);
  181.                  
  182.                 String world = cfgmap.getString("Warps." +ms+ ".Rot.World");
  183.                 double x = cfgmap.getDouble("Warps." +ms+ ".Rot.X");
  184.                 double y = cfgmap.getDouble("Warps." +ms+ ".Rot.Y");
  185.                 double z = cfgmap.getDouble("Warps." +ms+ ".Rot.Z");
  186.                 double yaw = cfgmap.getDouble("Warps." +ms+ ".Rot.Yaw");
  187.                 double pitch = cfgmap.getDouble("Warps." +ms+ ".Rot.Pitch");
  188.                 Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  189.                 loc.setYaw((float)yaw);
  190.                 loc.setPitch((float)pitch);
  191.  
  192.                 p.teleport(loc);
  193.           }
  194.          
  195.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement