Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package abidux.testes;
- import org.bukkit.plugin.java.*;
- import org.bukkit.plugin.*;
- import java.util.*;
- import org.bukkit.event.player.*;
- import org.bukkit.scheduler.*;
- import org.bukkit.util.*;
- import org.bukkit.craftbukkit.v1_8_R3.entity.*;
- import org.bukkit.event.*;
- import org.bukkit.command.*;
- import org.bukkit.entity.*;
- import org.bukkit.*;
- import net.minecraft.server.v1_8_R3.*;
- import java.lang.reflect.*;
- import org.bukkit.inventory.*;
- import org.bukkit.inventory.meta.*;
- public class Main extends JavaPlugin implements Listener
- {
- ArrayList<Entity> animations;
- ArrayList<Entity> cooldown;
- HashMap<Entity, Float> start;
- String[] names;
- ArrayList<Player> players;
- public Main() {
- this.animations = new ArrayList<Entity>();
- this.cooldown = new ArrayList<Entity>();
- this.start = new HashMap<Entity, Float>();
- this.names = new String[] { "1", "2", "3", "4", "5", "6", "7" };
- this.players = new ArrayList<Player>();
- }
- public void onEnable() {
- Bukkit.getPluginManager().registerEvents((Listener)this, (Plugin)this);
- }
- public void onDisable() {
- for (final Entity ani : this.animations) {
- ani.remove();
- }
- }
- @EventHandler
- void click(final PlayerInteractAtEntityEvent e) {
- if (this.animations.contains(e.getRightClicked())) {
- e.setCancelled(true);
- final Entity en = e.getRightClicked();
- if (this.cooldown.contains(en)) {
- return;
- }
- this.cooldown.add(en);
- new BukkitRunnable() {
- private int counter = 0;
- private float speed = 27.5f;
- public void run() {
- 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]);
- for (final Player a : Bukkit.getOnlinePlayers()) {
- ((CraftPlayer)a).getHandle().playerConnection.sendPacket((Packet)packets);
- }
- final Location loc = en.getLocation();
- loc.setYaw(loc.getYaw() + this.speed);
- en.teleport(loc);
- if (this.counter == 59) {
- Main.this.cooldown.remove(en);
- this.cancel();
- }
- ++this.counter;
- if (this.counter >= 40) {
- --this.speed;
- }
- }
- }.runTaskTimer((Plugin)this, 0L, 1L);
- }
- }
- public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
- if (command.getName().equalsIgnoreCase("testes")) {
- if (args.length == 0) {
- sender.sendMessage("§cUse argumentos");
- }
- if (args.length == 1) {
- if (args[0].equalsIgnoreCase("animation:parar")) {
- if (sender instanceof Player) {
- final Player player = (Player)sender;
- if (this.animations.size() > 0) {
- for (final Entity en : this.animations) {
- if (!en.isDead()) {
- en.remove();
- final Location loc = en.getLocation();
- loc.setY(loc.getY() + 1.0);
- en.getWorld().playEffect(loc, Effect.EXPLOSION_HUGE, 100, 100);
- en.getWorld().playSound(en.getLocation(), Sound.EXPLODE, 1.0f, 1.0f);
- }
- }
- this.animations.clear();
- player.sendMessage("§aAnima\u00e7\u00f5es removidas.");
- }
- }
- else {
- sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
- }
- }
- else if (args[0].equalsIgnoreCase("animation:iniciar")) {
- if (sender instanceof Player) {
- final Player player = (Player)sender;
- final ArmorStand as = (ArmorStand)player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
- as.setCustomName("§cFornalha normal, logicamente.");
- as.setCustomNameVisible(true);
- as.setHelmet(new ItemStack(Material.FURNACE));
- as.setVisible(false);
- 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]);
- ((CraftPlayer)player).getHandle().playerConnection.sendPacket((Packet)packets);
- as.getWorld().playSound(as.getLocation(), Sound.FIRE, 1.0f, 1.0f);
- this.animations.add((Entity)as);
- this.start.put((Entity)as, as.getLocation().getYaw());
- }
- else {
- sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
- }
- }
- else if (args[0].equalsIgnoreCase("list")) {
- if (sender instanceof Player) {
- final Player player = (Player)sender;
- final Inventory inv = Bukkit.createInventory((InventoryHolder)null, 9, "§aLista");
- int a = 0;
- for (int i = 0; i < inv.getSize(); ++i) {
- if (i == 8) {
- return true;
- }
- if (i != 0 && i != 8) {
- final String nome = this.names[a];
- final ItemStack item = new ItemStack(Material.STONE);
- final ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(nome);
- item.setItemMeta(meta);
- inv.setItem(i, item);
- ++a;
- }
- player.openInventory(inv);
- }
- }
- else {
- sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
- }
- }
- else if (args[0].equalsIgnoreCase("tags:setup")) {
- if (sender instanceof Player) {
- final Player player = (Player)sender;
- new BukkitRunnable() {
- public void run() {
- final PacketPlayOutScoreboardTeam packets = new PacketPlayOutScoreboardTeam();
- try {
- final Field a = packets.getClass().getDeclaredField("a");
- final Field b = packets.getClass().getDeclaredField("b");
- final Field c = packets.getClass().getDeclaredField("c");
- final Field d = packets.getClass().getDeclaredField("d");
- final Field e = packets.getClass().getDeclaredField("e");
- final Field h = packets.getClass().getDeclaredField("h");
- final Field i = packets.getClass().getDeclaredField("i");
- a.setAccessible(true);
- a.set(packets, "teste");
- a.setAccessible(false);
- b.setAccessible(true);
- b.set(packets, "teste");
- b.setAccessible(false);
- c.setAccessible(true);
- c.set(packets, "§a[Teste]");
- c.setAccessible(false);
- d.setAccessible(true);
- d.set(packets, "§a[Lindo]");
- d.setAccessible(false);
- e.setAccessible(true);
- e.set(packets, "always");
- e.setAccessible(false);
- i.setAccessible(true);
- i.set(packets, 1);
- i.setAccessible(false);
- h.setAccessible(true);
- h.set(packets, Main.this.players.contains(player) ? 2 : 0);
- h.setAccessible(false);
- if (Main.this.players.contains(player)) {
- Main.this.players.remove(player);
- }
- }
- catch (NoSuchFieldException | IllegalAccessException ex2) {
- final ReflectiveOperationException ex;
- final ReflectiveOperationException e2 = ex;
- e2.printStackTrace();
- }
- Main.this.players.add(player);
- ((CraftPlayer)player).getHandle().playerConnection.sendPacket((Packet)packets);
- }
- }.runTaskTimer((Plugin)this, 0L, 1L);
- }
- else {
- sender.sendMessage("§cS\u00f3 players podem executar esse comando.");
- }
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement