1.8 Hologram LIB

Discussion in 'Spigot Plugin Help' started by OldCrafterHD, Nov 30, 2014.

  1. Sorry for my Bad english I'm german.
    Here is my old LIB of Holograms for version 1.7:
    Code (Text):
    private static final double distance = 0.25D;
        private List<String> lines = new ArrayList();
        private List<Integer> ids = new ArrayList();
        private boolean showing = false;
        private Location location;
        private Player player;
         
        public Hologram(Player player, Location loc, String... lines) {
            this.location = loc;
            this.player = player;
            this.lines.addAll(Arrays.asList(lines));
          }
         
          public void change(String... lines) {
            destroy();
            this.lines = Arrays.asList(lines);
            show();
          }
         
          public void show() {
            if (this.showing) {
              try {
                throw new Exception("Is already showing!");
              }
              catch (Exception e) {
                e.printStackTrace();
              }
            }
            Location first = this.location
              .clone()
              .add(0.0D,
              this.lines.size() /
              2 *
              0.23D, 0.0D);
            for (int i = 0; i < this.lines.size(); i++) {
              this.ids.addAll(showLine(first.clone(), (String)this.lines.get(i)));
              first.subtract(0.0D, 0.25D, 0.0D);
            }
            this.showing = true;
          }
         
          public void destroy() {
            if (!this.showing) {
              try
              {
                throw new Exception("Isn't showing!");
              }
              catch (Exception e)
              {
                e.printStackTrace();
              }
            }
            int[] ints = new int[this.ids.size()];
            for (int j = 0; j < ints.length; j++) {
              ints[j] = ((Integer)this.ids.get(j)).intValue();
            }
            PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ints);
            for (Player player : Bukkit.getOnlinePlayers()) {
              ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
            }
            this.showing = false;
            this.location = null;
          }
         
          private List<Integer> showLine(Location loc, String text) {
            WorldServer world = ((CraftWorld)loc.getWorld()).getHandle();
            EntityWitherSkull skull = new EntityWitherSkull(world);
            skull.setLocation(loc.getX(), loc.getY() + 1.0D + 55.0D, loc.getZ(), 0.0F, 0.0F);
            PacketPlayOutSpawnEntity skull_packet = new PacketPlayOutSpawnEntity(skull, 64);
           
            EntityHorse horse = new EntityHorse(world);
            horse.setLocation(loc.getX(), loc.getY() + 55.0D, loc.getZ(), 0.0F, 0.0F);
            horse.setAge(-1700000);
            horse.setCustomName(text);
            horse.setCustomNameVisible(true);
            PacketPlayOutSpawnEntityLiving packedt = new PacketPlayOutSpawnEntityLiving(horse);
            EntityPlayer nmsPlayer = ((CraftPlayer)this.player).getHandle();
            nmsPlayer.playerConnection.sendPacket(packedt);
            nmsPlayer.playerConnection.sendPacket(skull_packet);
           
            PacketPlayOutAttachEntity pa = new PacketPlayOutAttachEntity(0, horse, skull);
            nmsPlayer.playerConnection.sendPacket(pa);
            return Arrays.asList(new Integer[] { Integer.valueOf(skull.getId()), Integer.valueOf(horse.getId()) });
          }
    Anyone have an Hologram LIB for Version 1.8?
    Please help me.
     
  2. What does not work?
    Errors?
     
  3. The hologram is not displayed
    There is no error.
     
  4. Holograms in 1.8 use armor stands I believe, not skulls.
     
  5. Can you send me the code for Armorstands?
     
  6. I can help you tomorrow, when it's OK for you. I have some mistakes in my code. If you know, how to fix it, here's the Code:

    The only thing you have to do, is to replace the package-name.
    Then you have to fix the Problem, because no Objects are summoned.
    PHP:
    package de.ilouHD.HolographicDisplays.manager;

    import net.minecraft.server.v1_8_R1.EntityArmorStand;
    import net.minecraft.server.v1_8_R1.EntityPlayer;
    import net.minecraft.server.v1_8_R1.PacketPlayOutSpawnEntity;
    import net.minecraft.server.v1_8_R1.WorldServer;

    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.entity.Player;

    public class HologramManager {
     
        public final Location location;
     
        private final double distance = 0.25;
     
        private final String text;

        public HologramManager( Location location, String message ) {
            this.location = location;
         
            this.text = message;
        }
     
        public void spawnHologram( int BlockHeight ) {
            WorldServer worldServer = (( CraftWorld ) location.getWorld() ).getHandle();
         
            EntityArmorStand armorStand = new EntityArmorStand( worldServer );
            armorStand.setLocation( location.getX(), location.getY() + (BlockHeight / 2) * distance, location.getZ(), 0, 0 );
         
            PacketPlayOutSpawnEntity packetSpawnEntity = new PacketPlayOutSpawnEntity( armorStand, 0 );
         
            armorStand.setCustomName( this.text );
            armorStand.setCustomNameVisible( true );
            armorStand.setInvisible( true );
         
            for( Player all : location.getWorld().getPlayers() ) {
                EntityPlayer player = (( CraftPlayer ) all ).getHandle();
             
                player.playerConnection.sendPacket( packetSpawnEntity );
            }
         
        }
     
    }
     
    I hope, i could help you.

    Best regards,
    ilouHD

    PS: This only summons a ArmorStand. I work at it, to delete them.
     
  7. Thank you so much <3
     
  8. @OldCrafterHD , as I told yesterday I try to finish that class to spawn a Hologram and I did. I have now a 100% working class for Spigot 1.8.
    Here you have:
    PHP:

    package de.ilouHD.HolographicDisplays.manager;

    import net.minecraft.server.v1_8_R1.EntityWitherSkull;
    import net.minecraft.server.v1_8_R1.WorldServer;

    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;

    public class HologramManager {
       
        public final Location location;
       
        private final double distance = 0.25D;
       
        private final String text;

        public HologramManager( Location location, String message ) {
            this.location = location;
           
            this.text = message;
        }
       
        public void spawnHologram( int BlockHeight ) {
            WorldServer worldServer = (( CraftWorld ) location.getWorld() ).getHandle();
           
            EntityWitherSkull witherSkull = new EntityWitherSkull( worldServer );
            witherSkull.setLocation( location.getX(), location.getY() + (BlockHeight * distance), location.getZ(), 0, 0 );
           
            witherSkull.setCustomName( this.text );
            witherSkull.setCustomNameVisible( true );
            witherSkull.setInvisible( true );

            ((CraftWorld) location.getWorld()).getHandle().addEntity(witherSkull);
           
        }
       
    }

     

    PHP:
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("hologram")) {
                if(sender instanceof Player) {
                    Player p = (Player) sender;
                    HologramManager manager = new HologramManager(p.getLocation(), args[0].replaceAll("_", " "));
                    manager.spawnHologram(Integer.parseInt(args[1]));
                 
                    p.sendMessage("§5HolographicDisplays §7>> §6Object summoned!");
                }
            }
            return true;
        }

    I hope, I could help you.

    Best regards,
    ilouHD
     
    #8 ilouHD, Dec 3, 2014
    Last edited: Dec 3, 2014
    • Useful Useful x 1
  9. @ilouHD
    Kannst du mir die Spigot Version schicken, die du benutzt?
    Meine für 1.8 ist total verbuggt.
     
  10. No, sry. Please speak quite English ;)

    You just have to downlaod the required Files. An description to download the files is here: (in German): http://postcrafter.de/viewtopic.php?f=27&t=1820&start=50#p15505

    Eventually I will load it to my webspace but not in the next two month, because there's no more diskspace.
    And you told me, you need it as fast as you can get it.