Sueta

HologramAPI

v0.4

Development API to create Text Holograms before the Player

·Plugin

bannerHologramAPI.jpg

Easy to create own Text Holograms!

How to use it?

  1. Add the plugin as Library in your development environment
  2. Spawn the hologramm with
    Code
    HashMap<String, Double> TextInHashmap= new HashMap<String, Double>();
                   
    TextInHashmap.put("§aText1", 0.0);
    TextInHashmap.put("§7Text2", 0.4);
    TextInHashmap.put("§cText3", [Relative Y position]);
    [...]
    
    TextObject hologram = new TextObjects([Plugin Instance], [Player], [DistanceToPlayer], TextInHashmap);
  3. Destroy the hologram with
    Code
    hologram.delete();
  4. Do this in combination with a ArrayList or Hashmap, as in the example.
  5. Export your plugin and do it with the HologramAPI.jar in the "plugins" order of your server.
  6. READY!

Other Methods in the TextObjects class:

  • getPlayer(), return the Player.
  • getDistanceToPlayer(), return the distance.
  • setDistanceToPlayer(double distance), set the distance, work without respawn.
  • spawn(), spawn the hologram, only for respawn. Automatically spawn, spawn() is in the constructor.
  • delete(), remove the NPCs, you can make spawn() to respawn.
Example
HashMap<UUID, TextObjects> TextObjects = new HashMap<UUID, TextObjects>();
 
    @EventHandler
    public void onToggleSneak(PlayerToggleSneakEvent e) {
        Player player = e.getPlayer();

        if(player.isSneaking()) {
            if(TextObjects.containsKey(player.getUniqueId())) {
                TextObjects.get(player.getUniqueId()).delete();
                TextObjects.remove(player.getUniqueId());
            }
        } else {
            if(!TextObjects.containsKey(player.getUniqueId())) {
                HashMap<String, Double> Text = new HashMap<String, Double>();
             
                int Kills = 37;
                int Deaths = 21;             
                double KD = Double.valueOf(Math.round(((double)Kills / (double)Deaths) * 100)) / 100;
             
                Text.put("§aYour Stats:", 0.0);
                Text.put("§7Kills: §6" + Kills, 0.4);
                Text.put("§7Deaths: §6" + Deaths, 0.7);
                Text.put("§7K/D: §6" + KD, 1.0);
             
                TextObjects.put(player.getUniqueId(), new TextObjects(Main.getInstance(), player, 3, Text));
            }
        }
    }

Similar projects

Plugin →