Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.66 KB | None | 0 0
  1. package com.loumaster;
  2.  
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.io.PrintStream;
  7. import java.net.Socket;
  8. import java.util.ArrayList;
  9. import java.util.Random;
  10.  
  11. import org.bukkit.Bukkit;
  12. import org.bukkit.ChatColor;
  13. import org.bukkit.Color;
  14. import org.bukkit.FireworkEffect;
  15. import org.bukkit.FireworkEffect.Type;
  16. import org.bukkit.GameMode;
  17. import org.bukkit.Location;
  18. import org.bukkit.Material;
  19. import org.bukkit.Sound;
  20. import org.bukkit.World;
  21. import org.bukkit.WorldCreator;
  22. import org.bukkit.block.Block;
  23. import org.bukkit.command.Command;
  24. import org.bukkit.command.CommandSender;
  25. import org.bukkit.entity.EntityType;
  26. import org.bukkit.entity.Firework;
  27. import org.bukkit.entity.Player;
  28. import org.bukkit.event.EventHandler;
  29. import org.bukkit.event.Listener;
  30. import org.bukkit.event.block.BlockBreakEvent;
  31. import org.bukkit.event.block.BlockPlaceEvent;
  32. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  33. import org.bukkit.event.entity.EntityDamageEvent;
  34. import org.bukkit.event.entity.PlayerDeathEvent;
  35. import org.bukkit.event.player.AsyncPlayerChatEvent;
  36. import org.bukkit.event.player.PlayerJoinEvent;
  37. import org.bukkit.event.player.PlayerMoveEvent;
  38. import org.bukkit.event.player.PlayerQuitEvent;
  39. import org.bukkit.event.weather.WeatherChangeEvent;
  40. import org.bukkit.inventory.ItemStack;
  41. import org.bukkit.inventory.meta.FireworkMeta;
  42. import org.bukkit.plugin.java.JavaPlugin;
  43.  
  44. import com.connorlinfoot.titleapi.TitleAPI;
  45.  
  46.  
  47. public class Main extends JavaPlugin implements Listener{
  48. int PAOOOOO;
  49. int EMOREU;
  50. int MAMAE;
  51. boolean bhxfvbhfxdbhjf = false;
  52. public void onEnable(){
  53. getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
  54. EMOREU = Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  55. new Runnable() {
  56. public void run() {
  57. if(bhxfvbhfxdbhjf == true){
  58. Bukkit.getScheduler().cancelTask(PAOOOOO);
  59. pao("§9§l[EM JOGO]");
  60. }
  61. }
  62. },
  63. 0L,
  64. 17L);
  65. PAOOOOO = Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  66. new Runnable() {
  67. public void run() {
  68. pao("§a§l[ENTRAR]");
  69. }
  70. },
  71. 0L,
  72. 17L);
  73. World w = Bukkit.getServer().getWorld("world");
  74. w.setAutoSave(false);
  75. getServer().getPluginManager().registerEvents(this, this);
  76. Bukkit.setDefaultGameMode(GameMode.SURVIVAL);
  77. Block block = Bukkit.getWorld("world").getBlockAt(100, 102, 69);
  78. block.setType(Material.OBSIDIAN);
  79. Block blockA = Bukkit.getWorld("world").getBlockAt(100, 101, 101);
  80. blockA.setType(Material.OBSIDIAN);
  81. }
  82. public static void unloadMap(String mapname){
  83. if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
  84. }else{
  85. }
  86. }
  87. public static void loadMap(String mapname){
  88. Bukkit.getServer().createWorld(new WorldCreator(mapname));
  89. World w = Bukkit.getServer().createWorld(new WorldCreator(mapname));
  90. w.setAutoSave(false);
  91. }
  92. public static void rollback(String mapname){
  93. unloadMap(mapname);
  94. loadMap(mapname);
  95. }
  96. public void onDisable(){
  97. rollback("world");
  98. try{
  99. Bukkit.getScheduler().cancelTask(EMOREU);
  100. } catch(Exception e){
  101. System.out.println("Task Não estava ligada.");
  102. }
  103.  
  104. pao("§4§l[REINICIANDO]");
  105. }
  106. public void pao(String MODOO){
  107. Socket cliente;
  108. try {
  109. cliente = new Socket("127.0.0.1", 12345);
  110. PrintStream saida = new PrintStream(cliente.getOutputStream());
  111. saida.println("2 "+MODOO);
  112.  
  113. saida.close();
  114. cliente.close();
  115. } catch (IOException e) {
  116. System.out.println("Erro ao conctar... Tentando novamente.");
  117. }
  118. }
  119.  
  120.  
  121. ArrayList<Player> red = new ArrayList<Player>();
  122. ArrayList<Player> blue = new ArrayList<Player>();
  123. int MaxPlayers = 12;
  124. String MODE = "START";
  125. int countdownS;
  126. int countdownB;
  127. boolean ModoBuild = false;
  128. boolean countdownIniciado = false;
  129. int countdown = 60;
  130. int countdownFinal = 20;
  131. int countdownBuild = 31;
  132. Location redSpawn = new Location(Bukkit.getWorld("world"), 98, 100, 100);
  133. Location blueSpawn = new Location(Bukkit.getWorld("world"), 98, 101, 70);
  134.  
  135. public int getRandom(int lower, int upper) {
  136. Random random = new Random();
  137. return random.nextInt((upper - lower) + 1) + lower;
  138. }
  139.  
  140. public void DivididorTimes(Player p){
  141. if(red.size() > blue.size()){
  142. blue.add(p);
  143. }else if(red.size() < blue.size()){
  144. red.add(p);
  145. }else if(red.size() == blue.size()){
  146. int r = getRandom(0, 1);
  147. if(r == 1){
  148. red.add(p);
  149. }else if(r == 0){
  150. blue.add(p);
  151. }
  152. }
  153. }
  154.  
  155. @EventHandler
  156. public void quebrar(BlockBreakEvent e){
  157. Player p1 = e.getPlayer();
  158. if(ModoBuild == true){
  159. if(e.getBlock().getLocation().getBlockZ() == 86){
  160. e.setCancelled(true);
  161. }
  162. if(blue.contains(p1)){
  163. if(e.getBlock().getLocation().getBlockZ() > 86){
  164. e.setCancelled(true);
  165. }
  166. }else if(red.contains(p1)){
  167. if(e.getBlock().getLocation().getBlockZ() < 86){
  168. e.setCancelled(true);
  169. }
  170. }
  171. }
  172. if(MODE == "INICIADO" && ModoBuild == false){
  173. if(blue.contains(p1) && e.getBlock().getType() == Material.OBSIDIAN && e.getBlock().getLocation().getBlockZ() > 86){
  174. MODE = "ACABANDO";
  175. for(Player p : Bukkit.getOnlinePlayers()){
  176. p.setGameMode(GameMode.CREATIVE);
  177. if(blue.contains(p)){
  178. Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  179. new Runnable() {
  180. public void run() {
  181. if(countdownFinal > 0){
  182. countdownFinal--;
  183. } else {
  184. sendToServer(p, "lobby");
  185. Bukkit.shutdown();
  186. }
  187. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 O time §9§lAzul§6 ganhou o MiniGuerra!");
  188. spawnFirework(p);
  189. }
  190.  
  191. },
  192. 0L,
  193. 10L);
  194. }
  195. }
  196. } else if(red.contains(p1) && e.getBlock().getType() == Material.OBSIDIAN && e.getBlock().getLocation().getBlockZ() < 86){
  197. MODE = "ACABANDO";
  198. for(Player p : Bukkit.getOnlinePlayers()){
  199. p.setGameMode(GameMode.CREATIVE);
  200. if(red.contains(p)){
  201. Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  202. new Runnable() {
  203. public void run() {
  204. if(countdownFinal > 0){
  205. countdownFinal--;
  206. } else {
  207. Bukkit.shutdown();
  208. }
  209. if(countdownFinal == 3){
  210. sendToServer(p, "lobby");
  211. }
  212. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 O time §9§lVermelho§6 ganhou o MiniGuerra!");
  213. spawnFirework(p);
  214. }
  215.  
  216. },
  217. 0L,
  218. 10L);
  219. }
  220. }
  221. }else if(!red.contains(p1) && e.getBlock().getType() == Material.OBSIDIAN && e.getBlock().getLocation().getBlockZ() < 86){
  222. e.setCancelled(true);
  223. }else if(!blue.contains(p1) && e.getBlock().getType() == Material.OBSIDIAN && e.getBlock().getLocation().getBlockZ() > 86){
  224. e.setCancelled(true);
  225. }
  226. }
  227. }
  228. private Color getColor(int i) {
  229. Color c = null;
  230. if(i==1){c=Color.AQUA;}
  231. if(i==2){c=Color.BLACK;}
  232. if(i==3){c=Color.BLUE;}
  233. if(i==4){c=Color.FUCHSIA;}
  234. if(i==5){c=Color.GRAY;}
  235. if(i==6){c=Color.GREEN;}
  236. if(i==7){c=Color.LIME;}
  237. if(i==8){c=Color.MAROON;}
  238. if(i==9){c=Color.NAVY;}
  239. if(i==10){c=Color.OLIVE;}
  240. if(i==11){c=Color.ORANGE;}
  241. if(i==12){c=Color.PURPLE;}
  242. if(i==13){c=Color.RED;}
  243. if(i==14){c=Color.SILVER;}
  244. if(i==15){c=Color.TEAL;}
  245. if(i==16){c=Color.WHITE;}
  246. if(i==17){c=Color.YELLOW;}
  247. return c;}
  248.  
  249.  
  250. @EventHandler
  251. public void tempo(WeatherChangeEvent e){
  252. e.setCancelled(true);
  253. }
  254.  
  255. public void IniciarCountdown() {
  256. countdownS = Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  257. new Runnable() {
  258. public void run() {
  259. if(countdownIniciado == false){
  260. countdownIniciado = true;
  261. }
  262. if (countdown > 0) {
  263. countdown--;
  264. }else if(countdown <= 0){
  265. Bukkit.getScheduler().cancelTask(countdownS);
  266. iniciarJogo();
  267. ModoBuild = true;
  268. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 A partida iniciou! Vocês teram 5 minutos para construir a base!");
  269. }
  270. if(countdown == 5){
  271. bhxfvbhfxdbhjf = true;
  272. }
  273. if(countdown == 30 || countdown == 15 || countdown == 10 || countdown == 5 || countdown == 3 || countdown == 2 || countdown == 1){
  274. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 Tempo restante: §3"+countdown+"§6 segundos!");
  275. }else if(countdown == 59){
  276. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 Tempo restante: §31§6 minuto!");
  277. }
  278. }
  279.  
  280. },
  281. 0L,
  282. 20L);
  283. }
  284.  
  285. public void IniciarCountdownBuild() {
  286. countdownB = Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  287. new Runnable() {
  288. @SuppressWarnings("deprecation")
  289. public void run() {
  290. if (countdownBuild == 30 || countdownBuild == 15 || countdownBuild == 10 || countdownBuild == 5 || countdownBuild == 4 || countdownBuild == 3 || countdownBuild == 2 || countdownBuild == 1) {
  291. for(Player p : Bukkit.getOnlinePlayers()){
  292. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l"+countdownBuild+" segundos Restantes");
  293. }
  294. }else if (countdownBuild == 60 ) {
  295. for(Player p : Bukkit.getOnlinePlayers()){
  296. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l1 Minuto Restante");
  297. }
  298. }else if (countdownBuild == 120 ) {
  299. for(Player p : Bukkit.getOnlinePlayers()){
  300. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l2 Minutos Restantes");
  301. }
  302. }else if (countdownBuild == 180 ) {
  303. for(Player p : Bukkit.getOnlinePlayers()){
  304. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l3 Minutos Restantes");
  305. }
  306. } else if (countdownBuild == 240 ) {
  307. for(Player p : Bukkit.getOnlinePlayers()){
  308. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l4 Minutos Restantes");
  309. }
  310. } else if (countdownBuild == 299 ) {
  311. for(Player p : Bukkit.getOnlinePlayers()){
  312. TitleAPI.sendTitle(p, 20, 100, 20, "§a§l5 Minuto Restantes");
  313. }
  314. } else if (countdownBuild == 0 ) {
  315. Bukkit.getScheduler().cancelTask(countdownB);
  316. iniciarLuta();
  317. ModoBuild = false;
  318. for(Player p : Bukkit.getOnlinePlayers()){
  319. TitleAPI.sendTitle(p, 20, 100, 20, "§a§lDestrua a §3§lOBSIDIAN§a§l inimiga!");
  320. }
  321. }
  322. if(countdownBuild > 0){
  323. countdownBuild--;
  324. }
  325. }
  326.  
  327. },
  328. 0L,
  329. 20L);
  330. }
  331. @EventHandler
  332. public void dano(EntityDamageEvent e){
  333. if(MODE == "COUNTDOWN" || MODE == "BUILD" || MODE == "START"){
  334. e.setCancelled(true);
  335. }
  336. }
  337.  
  338. @EventHandler
  339. public void join(PlayerJoinEvent e){
  340. Player p = e.getPlayer();
  341. p.setHealth(20);
  342. p.setHealth(20);
  343. p.setFireTicks(0);
  344. p.setFoodLevel(20);
  345. p.getInventory().clear();
  346. p.setFoodLevel(20);
  347. World w = Bukkit.getServer().getWorld(
  348. getConfig().getString(
  349. "SpawnWorld"));
  350. double x = getConfig()
  351. .getDouble("SpawnX");
  352. double y = getConfig().getDouble(
  353. "SpawnY");
  354. double z = getConfig().getDouble(
  355. "SpawnZ");
  356. float yaw = (float) getConfig().getDouble("SpawnYA");
  357. float pitch = (float) getConfig().getDouble("SpawnP");
  358. Location loc = new Location(w, x, y, z);
  359. loc.setPitch(pitch);
  360. loc.setYaw(yaw);
  361. p.teleport(loc);
  362. int playerOnline = Bukkit.getOnlinePlayers().size();
  363. e.setJoinMessage("§b[§6MiniGuerra§b]§6 §3"+p.getName()+" §6se juntou a partida! §3("+playerOnline+"/"+MaxPlayers+")");
  364. DivididorTimes(p);
  365. if(playerOnline > 1 && countdownIniciado == false){
  366. IniciarCountdown();
  367. }
  368. }
  369.  
  370. public void spawnFirework(Player p){
  371. Firework fw = (Firework) p.getWorld().spawnEntity(p.getLocation(), EntityType.FIREWORK);
  372. FireworkMeta fwm = fw.getFireworkMeta();
  373.  
  374. Random r = new Random();
  375.  
  376. int rt = r.nextInt(4) + 1;
  377. Type type = Type.BALL;
  378. if (rt == 1) type = Type.BALL;
  379. if (rt == 2) type = Type.BALL_LARGE;
  380. if (rt == 3) type = Type.BURST;
  381. if (rt == 4) type = Type.CREEPER;
  382. if (rt == 5) type = Type.STAR;
  383.  
  384. int r1i = r.nextInt(17) + 1;
  385. int r2i = r.nextInt(17) + 1;
  386. Color c1 = getColor(r1i);
  387. Color c2 = getColor(r2i);
  388.  
  389. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
  390.  
  391. fwm.addEffect(effect);
  392.  
  393. int rp = r.nextInt(2) + 1;
  394. fwm.setPower(rp);
  395.  
  396. fw.setFireworkMeta(fwm);
  397. }
  398. @EventHandler
  399. public void quit(PlayerQuitEvent e){
  400. Player p = e.getPlayer();
  401. if(red.contains(p)){
  402. red.remove(p);
  403. }
  404. if(blue.contains(p)){
  405. blue.remove(p);
  406. }
  407. int playerOnline = Bukkit.getOnlinePlayers().size()-1;
  408. e.setQuitMessage("§b[§6MiniGuerra§b]§6 §3"+p.getName()+"§6 saiu da partida! §3("+playerOnline+"/"+MaxPlayers+")");
  409. if(MODE == "COUNTDOWN"){
  410. if(playerOnline < 1 && MODE == "COUNTDOWN"){
  411. if(countdownIniciado == true){
  412. Bukkit.getScheduler().cancelTask(countdownS);
  413. countdownIniciado = false;
  414. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 A contagem parou por não ter jogadores suficientes.");
  415. }
  416. }
  417. }
  418. if(MODE == "INICIADO"){
  419. new java.util.Timer().schedule(
  420. new java.util.TimerTask() {
  421. public void run() {
  422. testEnd();
  423. }
  424. },
  425. 1000
  426. );
  427. }
  428. }
  429.  
  430. public void iniciarJogo(){
  431. MODE = "INICIADO";
  432. IniciarCountdownBuild();
  433. for(Player p1 : Bukkit.getOnlinePlayers()){
  434. p1.getInventory().clear();
  435. p1.setGameMode(GameMode.CREATIVE);
  436. if(blue.contains(p1)){
  437. World w = Bukkit.getServer().getWorld(
  438. getConfig().getString(
  439. "BlueWorld"));
  440. double x = getConfig()
  441. .getDouble("BlueX");
  442. double y = getConfig().getDouble(
  443. "BlueY");
  444. double z = getConfig().getDouble(
  445. "BlueZ");
  446. float yaw = (float) getConfig().getDouble("BlueYA");
  447. float pitch = (float) getConfig().getDouble("BlueP");
  448. Location loc = new Location(w, x, y, z);
  449. loc.setPitch(pitch);
  450. loc.setYaw(yaw);
  451. p1.teleport(loc);
  452. }
  453. if(red.contains(p1)){
  454. World w = Bukkit.getServer().getWorld(
  455. getConfig().getString(
  456. "RedWorld"));
  457. double x = getConfig()
  458. .getDouble("RedX");
  459. double y = getConfig().getDouble(
  460. "RedY");
  461. double z = getConfig().getDouble(
  462. "RedZ");
  463. float yaw = (float) getConfig().getDouble("RedYA");
  464. float pitch = (float) getConfig().getDouble("RedP");
  465. Location loc = new Location(w, x, y, z);
  466. loc.setPitch(pitch);
  467. loc.setYaw(yaw);
  468. p1.teleport(loc);
  469. }
  470. }
  471. }
  472.  
  473. public void iniciarLuta(){
  474. for(Player p1 : Bukkit.getOnlinePlayers()){
  475. p1.setGameMode(GameMode.SURVIVAL);
  476. p1.getActivePotionEffects().clear();
  477. p1.getInventory().clear();
  478. p1.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD));
  479. p1.getInventory().setItem(1, new ItemStack(Material.BOW));
  480. p1.getInventory().setItem(2, new ItemStack(Material.WATER_BUCKET));
  481. p1.getInventory().setItem(3, new ItemStack(Material.LAVA_BUCKET));
  482. p1.getInventory().setItem(4, new ItemStack(Material.APPLE, 64));
  483. p1.getInventory().setItem(5, new ItemStack(Material.DIAMOND_PICKAXE));
  484. p1.getInventory().setItem(6, new ItemStack(Material.FLINT_AND_STEEL));
  485. p1.getInventory().setItem(7, new ItemStack(Material.COBBLESTONE, 64));
  486. p1.getInventory().setItem(8, new ItemStack(Material.REDSTONE_TORCH_OFF, 64));
  487. p1.getInventory().addItem(new ItemStack(Material.TNT, 64));
  488. p1.getInventory().addItem(new ItemStack(Material.ARROW, 64));
  489. p1.getInventory().addItem(new ItemStack(Material.TNT, 64));
  490. p1.getInventory().addItem(new ItemStack(Material.LEVER, 64));
  491. p1.getInventory().addItem(new ItemStack(Material.REDSTONE, 64));
  492. p1.playSound(p1.getLocation(), Sound.NOTE_PLING, 1, 7);
  493. }
  494. }
  495. @EventHandler
  496. public void dano(EntityDamageByEntityEvent e){
  497. if(e.getDamager() instanceof Player){
  498. if(MODE == "COUNTDOWN" || MODE == "START"){
  499. e.setCancelled(true);
  500. }
  501. }
  502. if(e.getEntity().getType().equals(EntityType.PLAYER) && e.getDamager().getType().equals(EntityType.PLAYER)){
  503. Player p = (Player) e.getEntity();
  504. Player d = (Player) e.getDamager();
  505. if(blue.contains(p) && blue.contains(d)){
  506. e.setCancelled(true);
  507. }
  508. if(red.contains(p) && red.contains(d)){
  509. e.setCancelled(true);
  510. }
  511. }
  512. }
  513. @EventHandler
  514. public void MORREU(PlayerDeathEvent e){
  515. Player p = (Player) e.getEntity().getPlayer();
  516. p.setHealth(20);
  517. if(blue.contains(p)){
  518. World w = Bukkit.getServer().getWorld(
  519. getConfig().getString(
  520. "BlueWorld"));
  521. double x = getConfig()
  522. .getDouble("BlueX");
  523. double y = getConfig().getDouble(
  524. "BlueY");
  525. double z = getConfig().getDouble(
  526. "BlueZ");
  527. float yaw = (float) getConfig().getDouble("BlueYA");
  528. float pitch = (float) getConfig().getDouble("BlueP");
  529. Location loc = new Location(w, x, y, z);
  530. loc.setPitch(pitch);
  531. loc.setYaw(yaw);
  532. e.getEntity().getPlayer().teleport(loc);
  533. if(p.getKiller() != null && p.getKiller() != p){
  534. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §c§l"+p.getKiller().getName()+" §6matou o §9§l"+p.getName()+"§6!");
  535. }
  536. if(p.getKiller() == null){
  537. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §9§l"+p.getName()+" §6morreu!");
  538. }
  539. if(p.getKiller() != null && p.getKiller() == p){
  540. if(p.getKiller() == null){
  541. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §9§l"+p.getName()+" §6se matou!");
  542. }
  543. }
  544. }else if(red.contains(p)){
  545. World w = Bukkit.getServer().getWorld(
  546. getConfig().getString(
  547. "RedWorld"));
  548. double x = getConfig()
  549. .getDouble("RedX");
  550. double y = getConfig().getDouble(
  551. "RedY");
  552. double z = getConfig().getDouble(
  553. "RedZ");
  554. float yaw = (float) getConfig().getDouble("RedYA");
  555. float pitch = (float) getConfig().getDouble("RedP");
  556. Location loc = new Location(w, x, y, z);
  557. loc.setPitch(pitch);
  558. loc.setYaw(yaw);
  559. p.teleport(loc);
  560. if(p.getKiller() != null && p.getKiller() != p){
  561. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §9§l"+p.getKiller().getName()+" §6matou o §c§l"+p.getName()+"§6!");
  562. }
  563. if(p.getKiller() == null){
  564. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §c§l"+p.getName()+" §6morreu!");
  565. }
  566. if(p.getKiller() != null && p.getKiller() == p){
  567. if(p.getKiller() == null){
  568. e.setDeathMessage("§b[§6MiniGuerra§b] §6O Jogador §c§l"+p.getName()+" §6se matou!");
  569. }
  570. }
  571. }
  572.  
  573. }
  574. @EventHandler
  575. public void chat(AsyncPlayerChatEvent e){
  576. Player p = e.getPlayer();
  577. String m = e.getMessage();
  578. if(blue.contains(p)){
  579. e.setFormat("§9"+p.getName()
  580. + ChatColor.WHITE + " §f» §7" + m.replaceAll("&", "§"));
  581. }else if(red.contains(p)){
  582. e.setFormat("§c"+p.getName()
  583. + ChatColor.WHITE + " §f» §7" + m.replaceAll("&", "§"));
  584. }
  585. }
  586.  
  587. @EventHandler
  588. public void colocar(BlockPlaceEvent e){
  589. Block b = e.getBlock();
  590. Player p = e.getPlayer();
  591. if(b.getType() == Material.BEDROCK){
  592. p.sendMessage("§b[§6MiniGuerra§b]§6 Não é permitido usar §3§lBEDROCK §6desculpe.");
  593. p.getItemInHand().setType(Material.AIR);
  594. e.setCancelled(true);
  595. }else if(b.getType() == Material.OBSIDIAN){
  596. p.sendMessage("§b[§6MiniGuerra§b]§6 Não é permitido usar §3§lOBSIDIAN §6desculpe.");
  597. p.getItemInHand().setType(Material.AIR);
  598. e.setCancelled(true);
  599. }else if(b.getType() == Material.ENCHANTMENT_TABLE){
  600. p.sendMessage("§b[§6MiniGuerra§b]§6 Não é permitido usar §3§lMESA DE ENCANTAMENTOS §6desculpe.");
  601. p.getItemInHand().setType(Material.AIR);
  602. e.setCancelled(true);
  603. }else if(b.getType() == Material.CHEST){
  604. p.sendMessage("§b[§6MiniGuerra§b]§6 Não é permitido usar §3§lBau §6desculpe.");
  605. p.getItemInHand().setType(Material.AIR);
  606. e.setCancelled(true);
  607. }else if(b.getType() == Material.ENDER_CHEST){
  608. p.sendMessage("§b[§6MiniGuerra§b]§6 Não é permitido usar §3§lENDER CHEST §6desculpe.");
  609. p.getItemInHand().setType(Material.AIR);
  610. e.setCancelled(true);
  611. }
  612. if(p.getLocation().getBlockY() > 150){
  613. e.setCancelled(true);
  614. p.sendMessage("§b[§6MiniGuerra§b]§6 Limite de §3§lALTURA §6foi atingido.");
  615. }
  616. }
  617. @EventHandler
  618. public void move(PlayerMoveEvent e){
  619. if(e.getTo().getY() > 150){
  620. e.getPlayer().sendMessage("§b[§6MiniGuerra§b]§6 Limite de §3§lALTURA §6foi atingido.");
  621. }
  622. if(ModoBuild == true){
  623. if(e.getTo().getZ() > 86 && e.getTo().getZ() < 87){
  624. e.setCancelled(true);
  625. }
  626. }
  627. if(e.getTo().getY() < 50){
  628. if(MODE == "BUILD" || MODE == "INICIADO"){
  629. if(blue.contains(e.getPlayer())){
  630. World w = Bukkit.getServer().getWorld(
  631. getConfig().getString(
  632. "BlueWorld"));
  633. double x = getConfig()
  634. .getDouble("BlueX");
  635. double y = getConfig().getDouble(
  636. "BlueY");
  637. double z = getConfig().getDouble(
  638. "BlueZ");
  639. float yaw = (float) getConfig().getDouble("BlueYA");
  640. float pitch = (float) getConfig().getDouble("BlueP");
  641. Location loc = new Location(w, x, y, z);
  642. loc.setPitch(pitch);
  643. loc.setYaw(yaw);
  644. e.getPlayer().teleport(loc);
  645. }else if(red.contains(e.getPlayer())){
  646. World w = Bukkit.getServer().getWorld(
  647. getConfig().getString(
  648. "RedWorld"));
  649. double x = getConfig()
  650. .getDouble("RedX");
  651. double y = getConfig().getDouble(
  652. "RedY");
  653. double z = getConfig().getDouble(
  654. "RedZ");
  655. float yaw = (float) getConfig().getDouble("RedYA");
  656. float pitch = (float) getConfig().getDouble("RedP");
  657. Location loc = new Location(w, x, y, z);
  658. loc.setPitch(pitch);
  659. loc.setYaw(yaw);
  660. e.getPlayer().teleport(loc);
  661. }
  662. }
  663. }
  664. }
  665.  
  666. public void testEnd(){
  667. if(red.size() == 0){
  668. for(Player p : Bukkit.getOnlinePlayers()){
  669. if(blue.contains(p)){
  670. Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  671. new Runnable() {
  672. public void run() {
  673. if(countdownFinal > 0){
  674. countdownFinal--;
  675. } else {
  676. Bukkit.shutdown();
  677. }
  678. if(countdownFinal == 2){
  679. sendToServer(p, "lobby");
  680. }
  681. if(MODE == "INICIADO"){
  682. Bukkit.getScheduler().cancelTask(countdownB);
  683. }
  684. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 O time §9§lAzul §6ganhou o MiniGuerra!");
  685. spawnFirework(p);
  686. }
  687.  
  688. },
  689. 0L,
  690. 25L);
  691. }
  692. }
  693. }
  694. if(blue.size() == 0){
  695. for(Player p : Bukkit.getOnlinePlayers()){
  696. if(red.contains(p)){
  697. Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
  698. new Runnable() {
  699. public void run() {
  700. if(countdownFinal > 0){
  701. countdownFinal--;
  702. } else {
  703. Bukkit.shutdown();
  704. }
  705. if(countdownFinal == 2){
  706. sendToServer(p, "lobby");
  707. }
  708. if(MODE == "INICIADO"){
  709. Bukkit.getScheduler().cancelTask(countdownB);
  710. }
  711. Bukkit.broadcastMessage("§b[§6MiniGuerra§b]§6 O time §c§lVermelho §6ganhou o MiniGuerra!");
  712. spawnFirework(p);
  713. }
  714.  
  715. },
  716. 0L,
  717. 25L);
  718. }
  719. }
  720. }
  721.  
  722. }
  723.  
  724. public boolean onCommand(CommandSender sender, Command cmd, String label,
  725. String[] args) {
  726. if (cmd.getName().equalsIgnoreCase("setazul")) {
  727. Player p = (Player) sender;
  728. this.getConfig().set("BlueWorld",
  729. p.getLocation().getWorld().getName());
  730. this.getConfig().set("BlueX",
  731. Double.valueOf(p.getLocation().getX()));
  732. this.getConfig().set("BlueY",
  733. Double.valueOf(p.getLocation().getY()+1));
  734. this.getConfig().set("BlueZ",
  735. Double.valueOf(p.getLocation().getZ()));
  736. this.getConfig().set("BlueP",
  737. Double.valueOf(p.getLocation().getPitch()));
  738. this.getConfig().set("BlueYA",
  739. Double.valueOf(p.getLocation().getYaw()));
  740. this.saveConfig();
  741. p.sendMessage("§a§oAZUL setado!");
  742. return true;
  743. }else if (cmd.getName().equalsIgnoreCase("setred")) {
  744. Player p = (Player) sender;
  745. this.getConfig().set("RedWorld",
  746. p.getLocation().getWorld().getName());
  747. this.getConfig().set("RedX",
  748. Double.valueOf(p.getLocation().getX()));
  749. this.getConfig().set("RedY",
  750. Double.valueOf(p.getLocation().getY()+1));
  751. this.getConfig().set("RedZ",
  752. Double.valueOf(p.getLocation().getZ()));
  753. this.getConfig().set("RedP",
  754. Double.valueOf(p.getLocation().getPitch()));
  755. this.getConfig().set("RedYA",
  756. Double.valueOf(p.getLocation().getYaw()));
  757. this.saveConfig();
  758. p.sendMessage("§a§oRed setado!");
  759. return true;
  760. }else if (cmd.getName().equalsIgnoreCase("setspawn")) {
  761. Player p = (Player) sender;
  762. this.getConfig().set("SpawnWorld",
  763. p.getLocation().getWorld().getName());
  764. this.getConfig().set("SpawnX",
  765. Double.valueOf(p.getLocation().getX()));
  766. this.getConfig().set("SpawnY",
  767. Double.valueOf(p.getLocation().getY()+1));
  768. this.getConfig().set("SpawnZ",
  769. Double.valueOf(p.getLocation().getZ()));
  770. this.getConfig().set("SpawnP",
  771. Double.valueOf(p.getLocation().getPitch()));
  772. this.getConfig().set("SpawnYA",
  773. Double.valueOf(p.getLocation().getYaw()));
  774. this.saveConfig();
  775. p.sendMessage("§a§oSpawn setado!");
  776. return true;
  777. }else if(cmd.getName().equalsIgnoreCase("sair") || cmd.getName().equalsIgnoreCase("leave")){
  778. Player p = (Player) sender;
  779. sendToServer(p, "lobby");
  780. }
  781.  
  782. return false;
  783. }
  784. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement