Advertisement
THGPlay

Admin

Oct 23rd, 2016
1,595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. package com.tke.admin;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.World;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandExecutor;
  12. import org.bukkit.command.CommandSender;
  13. import org.bukkit.enchantments.Enchantment;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.event.EventHandler;
  16. import org.bukkit.event.Listener;
  17. import org.bukkit.event.entity.PlayerDeathEvent;
  18. import org.bukkit.event.player.PlayerInteractEntityEvent;
  19. import org.bukkit.inventory.ItemStack;
  20. import org.bukkit.util.Vector;
  21.  
  22. public class Admin implements Listener , CommandExecutor{
  23.  
  24. private static List<String> modo = new ArrayList<String>();
  25. private static List<String> nofall = new ArrayList<String>();
  26.  
  27. @Override
  28. public boolean onCommand(CommandSender sender, Command cmd, String lb, String[] args) {
  29.  
  30. if (!(sender instanceof Player)) return true;
  31.  
  32. Player p = (Player)sender;
  33. if (cmd.getName().equalsIgnoreCase("admin")){
  34. if (!(p.isOp())) {
  35. p.sendMessage("§cVocê não tem OP!");
  36. return true;
  37. }
  38.  
  39. if (modo.contains(p.getName())){
  40. modo.remove(p.getName());
  41. p.sendMessage("§cVocê saiu do modo Admin!");
  42. p.getInventory().clear();
  43. p.getEquipment().setArmorContents(null);
  44. for (Player players : Bukkit.getOnlinePlayers()){
  45. players.showPlayer(p);
  46. }
  47. } else {
  48.  
  49. for (Player players : Bukkit.getOnlinePlayers()){
  50. if (players.isOp()){
  51. players.showPlayer(p);
  52. } else {
  53. players.hidePlayer(p);
  54. }
  55. }
  56.  
  57. modo.add(p.getName());
  58. p.sendMessage("§aVocê entrou no modo Admin!");
  59. p.getInventory().clear();
  60. p.getEquipment().setArmorContents(null);
  61.  
  62. ItemStack prisao = Criar.add(Material.IRON_FENCE, "§7Prisao");
  63. ItemStack fall = Criar.add(Material.BEACON, "§6Teste de No-Fall");
  64. ItemStack knock = Criar.add(Material.DIAMOND_PICKAXE, "§5Teste de Anti-KnockBack", Enchantment.KNOCKBACK, 10);
  65.  
  66. p.getInventory().setItem(1, prisao);
  67. p.getInventory().setItem(4, fall);
  68. p.getInventory().setItem(7, knock);
  69. }
  70.  
  71. }
  72.  
  73. return false;
  74. }
  75.  
  76. @EventHandler
  77. public void onFall(PlayerDeathEvent e){
  78. if (e.getEntity() instanceof Player){
  79. Player p = (Player)e.getEntity();
  80. if (nofall.contains(p.getName())){
  81. nofall.remove(p.getName());
  82. }
  83. }
  84. }
  85.  
  86. @EventHandler
  87. public void onInteract(PlayerInteractEntityEvent e){
  88. if (!(e.getRightClicked() instanceof Player)){
  89. return;
  90. }
  91. final Player p = (Player)e.getPlayer();
  92. final Player target = (Player)e.getRightClicked();
  93. if (modo.contains(p.getName()) && p.getItemInHand().getItemMeta().getDisplayName().equals("§7Prisao")){
  94.  
  95. double x = target.getLocation().getX();
  96. double y = target.getLocation().getY() + 7;
  97. double z = target.getLocation().getZ();
  98. World world = target.getWorld();
  99. Material tipo = Material.BEDROCK;
  100.  
  101. Location loc1 = new Location(world, x + 1, y, z);
  102. Location loc2 = new Location(world, x - 1, y, z);
  103. Location loc3 = new Location(world, x, y, z + 1);
  104. Location loc4 = new Location(world, x, y, z - 1);
  105. Location loc5 = new Location(world, x, y - 1, z);
  106. Location loc6 = new Location(world, x, y + 2, z);
  107.  
  108. world.getBlockAt(loc1).setType(tipo);
  109. world.getBlockAt(loc2).setType(tipo);
  110. world.getBlockAt(loc3).setType(tipo);
  111. world.getBlockAt(loc4).setType(tipo);
  112. world.getBlockAt(loc5).setType(tipo);
  113. world.getBlockAt(loc6).setType(tipo);
  114.  
  115. target.teleport(new Location(world, x, y, z));
  116. p.sendMessage("§aVocê prendeu o jogador: §f" + target.getName());
  117. }
  118. if (modo.contains(p.getName()) && p.getItemInHand().getItemMeta().getDisplayName().equals("§6Teste de No-Fall")){
  119. target.setVelocity(new Vector(target.getVelocity().getX(), target.getVelocity().getY() + 10, target.getVelocity().getZ()));
  120. nofall.add(target.getName());
  121.  
  122. Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
  123. public void run() {
  124.  
  125. if (nofall.contains(target.getName())){
  126. p.sendMessage("§cJogador: §f" + target.getName() + "§c Está de No-Fall");
  127. } else {
  128. p.sendMessage("§aJogador: §f" + target.getName() + "§a não está de No-Fall");
  129. }
  130.  
  131. }
  132. }, 8*20);
  133. }
  134. }
  135.  
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement