Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.47 KB | None | 0 0
  1. package abidux.testes;
  2.  
  3. import org.bukkit.plugin.java.*;
  4. import org.bukkit.plugin.*;
  5. import java.util.*;
  6. import org.bukkit.event.player.*;
  7. import org.bukkit.scheduler.*;
  8. import org.bukkit.util.*;
  9. import org.bukkit.craftbukkit.v1_8_R3.entity.*;
  10. import org.bukkit.event.*;
  11. import org.bukkit.command.*;
  12. import org.bukkit.entity.*;
  13. import org.bukkit.*;
  14. import net.minecraft.server.v1_8_R3.*;
  15. import java.lang.reflect.*;
  16. import org.bukkit.inventory.*;
  17. import org.bukkit.inventory.meta.*;
  18.  
  19. public class Main extends JavaPlugin implements Listener
  20. {
  21. ArrayList<Entity> animations;
  22. ArrayList<Entity> cooldown;
  23. HashMap<Entity, Float> start;
  24. String[] names;
  25. ArrayList<Player> players;
  26.  
  27. public Main() {
  28. this.animations = new ArrayList<Entity>();
  29. this.cooldown = new ArrayList<Entity>();
  30. this.start = new HashMap<Entity, Float>();
  31. this.names = new String[] { "1", "2", "3", "4", "5", "6", "7" };
  32. this.players = new ArrayList<Player>();
  33. }
  34.  
  35. public void onEnable() {
  36. Bukkit.getPluginManager().registerEvents((Listener)this, (Plugin)this);
  37. }
  38.  
  39. public void onDisable() {
  40. for (final Entity ani : this.animations) {
  41. ani.remove();
  42. }
  43. }
  44.  
  45. @EventHandler
  46. void click(final PlayerInteractAtEntityEvent e) {
  47. if (this.animations.contains(e.getRightClicked())) {
  48. e.setCancelled(true);
  49. final Entity en = e.getRightClicked();
  50. if (this.cooldown.contains(en)) {
  51. return;
  52. }
  53. this.cooldown.add(en);
  54. new BukkitRunnable() {
  55. private int counter = 0;
  56. private float speed = 27.5f;
  57.  
  58. public void run() {
  59. final PacketPlayOutWorldParticles packets = new PacketPlayOutWorldParticles(EnumParticle.FLAME, false, (float)en.getLocation().add(en.getLocation().getDirection().multiply(new Vector(1, 0, 1)).normalize()).getX(), (float)en.getLocation().getY() + 1.75f, (float)en.getLocation().add(en.getLocation().getDirection().multiply(new Vector(1, 0, 1)).normalize()).getZ(), 0.1f, 0.1f, 0.1f, 0.0f, 1, new int[0]);
  60. for (final Player a : Bukkit.getOnlinePlayers()) {
  61. ((CraftPlayer)a).getHandle().playerConnection.sendPacket((Packet)packets);
  62. }
  63. final Location loc = en.getLocation();
  64. loc.setYaw(loc.getYaw() + this.speed);
  65. en.teleport(loc);
  66. if (this.counter == 59) {
  67. Main.this.cooldown.remove(en);
  68. this.cancel();
  69. }
  70. ++this.counter;
  71. if (this.counter >= 40) {
  72. --this.speed;
  73. }
  74. }
  75. }.runTaskTimer((Plugin)this, 0L, 1L);
  76. }
  77. }
  78.  
  79. public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
  80. if (command.getName().equalsIgnoreCase("testes")) {
  81. if (args.length == 0) {
  82. sender.sendMessage("§cUse argumentos");
  83. }
  84. if (args.length == 1) {
  85. if (args[0].equalsIgnoreCase("animation:parar")) {
  86. if (sender instanceof Player) {
  87. final Player player = (Player)sender;
  88. if (this.animations.size() > 0) {
  89. for (final Entity en : this.animations) {
  90. if (!en.isDead()) {
  91. en.remove();
  92. final Location loc = en.getLocation();
  93. loc.setY(loc.getY() + 1.0);
  94. en.getWorld().playEffect(loc, Effect.EXPLOSION_HUGE, 100, 100);
  95. en.getWorld().playSound(en.getLocation(), Sound.EXPLODE, 1.0f, 1.0f);
  96. }
  97. }
  98. this.animations.clear();
  99. player.sendMessage("§aAnima\u00e7\u00f5es removidas.");
  100. }
  101. }
  102. else {
  103. sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
  104. }
  105. }
  106. else if (args[0].equalsIgnoreCase("animation:iniciar")) {
  107. if (sender instanceof Player) {
  108. final Player player = (Player)sender;
  109. final ArmorStand as = (ArmorStand)player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
  110. as.setCustomName("§cFornalha normal, logicamente.");
  111. as.setCustomNameVisible(true);
  112. as.setHelmet(new ItemStack(Material.FURNACE));
  113. as.setVisible(false);
  114. final PacketPlayOutWorldParticles packets = new PacketPlayOutWorldParticles(EnumParticle.FLAME, false, (float)as.getLocation().getX(), (float)as.getLocation().getY() + 2.5f, (float)as.getLocation().getZ(), 0.1f, 0.1f, 0.1f, 0.0f, 15, new int[0]);
  115. ((CraftPlayer)player).getHandle().playerConnection.sendPacket((Packet)packets);
  116. as.getWorld().playSound(as.getLocation(), Sound.FIRE, 1.0f, 1.0f);
  117. this.animations.add((Entity)as);
  118. this.start.put((Entity)as, as.getLocation().getYaw());
  119. }
  120. else {
  121. sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
  122. }
  123. }
  124. else if (args[0].equalsIgnoreCase("list")) {
  125. if (sender instanceof Player) {
  126. final Player player = (Player)sender;
  127. final Inventory inv = Bukkit.createInventory((InventoryHolder)null, 9, "§aLista");
  128. int a = 0;
  129. for (int i = 0; i < inv.getSize(); ++i) {
  130. if (i == 8) {
  131. return true;
  132. }
  133. if (i != 0 && i != 8) {
  134. final String nome = this.names[a];
  135. final ItemStack item = new ItemStack(Material.STONE);
  136. final ItemMeta meta = item.getItemMeta();
  137. meta.setDisplayName(nome);
  138. item.setItemMeta(meta);
  139. inv.setItem(i, item);
  140. ++a;
  141. }
  142. player.openInventory(inv);
  143. }
  144. }
  145. else {
  146. sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
  147. }
  148. }
  149. else if (args[0].equalsIgnoreCase("tags:setup")) {
  150. if (sender instanceof Player) {
  151. final Player player = (Player)sender;
  152. new BukkitRunnable() {
  153. public void run() {
  154. final PacketPlayOutScoreboardTeam packets = new PacketPlayOutScoreboardTeam();
  155. try {
  156. final Field a = packets.getClass().getDeclaredField("a");
  157. final Field b = packets.getClass().getDeclaredField("b");
  158. final Field c = packets.getClass().getDeclaredField("c");
  159. final Field d = packets.getClass().getDeclaredField("d");
  160. final Field e = packets.getClass().getDeclaredField("e");
  161. final Field h = packets.getClass().getDeclaredField("h");
  162. final Field i = packets.getClass().getDeclaredField("i");
  163. a.setAccessible(true);
  164. a.set(packets, "teste");
  165. a.setAccessible(false);
  166. b.setAccessible(true);
  167. b.set(packets, "teste");
  168. b.setAccessible(false);
  169. c.setAccessible(true);
  170. c.set(packets, "§a[Teste]");
  171. c.setAccessible(false);
  172. d.setAccessible(true);
  173. d.set(packets, "§a[Lindo]");
  174. d.setAccessible(false);
  175. e.setAccessible(true);
  176. e.set(packets, "always");
  177. e.setAccessible(false);
  178. i.setAccessible(true);
  179. i.set(packets, 1);
  180. i.setAccessible(false);
  181. h.setAccessible(true);
  182. h.set(packets, Main.this.players.contains(player) ? 2 : 0);
  183. h.setAccessible(false);
  184. if (Main.this.players.contains(player)) {
  185. Main.this.players.remove(player);
  186. }
  187. }
  188. catch (NoSuchFieldException | IllegalAccessException ex2) {
  189. final ReflectiveOperationException ex;
  190. final ReflectiveOperationException e2 = ex;
  191. e2.printStackTrace();
  192. }
  193. Main.this.players.add(player);
  194. ((CraftPlayer)player).getHandle().playerConnection.sendPacket((Packet)packets);
  195. }
  196. }.runTaskTimer((Plugin)this, 0L, 1L);
  197. }
  198. else {
  199. sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
  200. }
  201. }
  202. }
  203. }
  204. return false;
  205. }
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement