• Chào bạn, hãy đăng ký hoặc đăng nhập để tham gia cùng bọn mình và sử dụng được đầy đủ chức năng của diễn đàn :).
Huy12345

Java AE xin cách fix lỗi Java này với

Huy12345

THÀNH VIÊN
Tham gia
13/08/2018
Bài viết
973
Mã:
package me.huyyon.rpg.holograms;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import me.huyyon.rpg.Main;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.entity.decoration.EntityArmorStand;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_21_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_21_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

public class Hologramm {
   private Main plugin;
   private List<EntityArmorStand> entitylist;
   private String[] Text;
   private Location location;
   private double DISTANCE;
   public static double HEIGHT = 0.3D;
   private int count;

   public Hologramm(String[] var1, Location var2) {
      this.plugin = Main.plugin;
      this.entitylist = new ArrayList();
      this.DISTANCE = 0.25D;
      this.Text = var1;
      this.location = var2;
      this.create();
   }

   public void showPlayerTemp(final Player var1, int var2) {
      this.showPlayer(var1);
      (new BukkitRunnable() {
         public void run() {
            Hologramm.this.hidePlayer(var1);
         }
      }).runTaskLaterAsynchronously(this.plugin, (long)var2);
   }

   public void showPlayer(final Player var1) {
      (new BukkitRunnable() {
         public void run() {
            Iterator var2 = Hologramm.this.entitylist.iterator();

            while(var2.hasNext()) {
               EntityArmorStand var1x = (EntityArmorStand)var2.next();
               PacketPlayOutSpawnEntity var3 = new PacketPlayOutSpawnEntity(var1x);
               PacketPlayOutEntityMetadata var4 = new PacketPlayOutEntityMetadata(var1x.getId(), var1x.getDataWatcher(), true);
               PlayerConnection var5 = ((CraftPlayer)var1).getHandle().b;
               var5.sendPacket(var3);
               var5.sendPacket(var4);
            }

         }
      }).runTaskAsynchronously(this.plugin);
   }

   public void hidePlayer(final Player var1) {
      (new BukkitRunnable() {
         public void run() {
            Iterator var2 = Hologramm.this.entitylist.iterator();

            while(var2.hasNext()) {
               EntityArmorStand var1x = (EntityArmorStand)var2.next();
               PacketPlayOutEntityDestroy var3 = new PacketPlayOutEntityDestroy(new int[]{var1x.getId()});
               ((CraftPlayer)var1).getHandle().b.sendPacket(var3);
            }

         }
      }).runTaskAsynchronously(this.plugin);
   }

   private void create() {
      String[] var4;
      int var3 = (var4 = this.Text).length;

      for(int var2 = 0; var2 < var3; ++var2) {
         String var1 = var4[var2];
         EntityArmorStand var5 = new EntityArmorStand(((CraftWorld)this.location.getWorld()).getHandle(), this.location.getX(), this.location.getY() + HEIGHT, this.location.getZ());
         var5.setCustomName(new ChatComponentText(var1));
         var5.setCustomNameVisible(true);
         var5.setInvisible(true);
         var5.setNoGravity(true);
         this.entitylist.add(var5);
         this.location.subtract(0.0D, this.DISTANCE, 0.0D);
         ++this.count;
      }

      for(int var6 = 0; var6 < this.count; ++var6) {
         this.location.add(0.0D, this.DISTANCE, 0.0D);
      }

      this.count = 0;
   }
}

48220
48221
48222
 
Similar content Most view Xem thêm
Back
Top Bottom