Creating a Custom Boss Bar Plugin Without BarAPI

Discussion in 'Plugin Development' started by HexLazer205, Sep 16, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    HexLazer205

    Hi, I would like to know how to create a custom Boss Bar Message plugin that shows a custom boss bar without the BarAPI, as all of the plugins in my server are intended to be custom-coded like in Mineplex. I do not care if this will be more difficult to code, as I expect it to be. So could you guys help me out and maybe start me from scratch with this? Thanks in advance :)
     
  2. Offline

    97WaterPolo

    The general gist of it is to spawn an enderdragon ~ 300 blocks below the player, and every x ticks teleport the dragon below the player, if you have a smaller server that is pretty intensive, I have done some testing and the enderdragon bar still works/displays if you are within 100 blocks of the dragon, so the way I did it, was every 5 seconds it would teleport the dragon.

    Setting the health of the dragon is how full the bar is, and name of the dragon is the message itself.
     
  3. Offline

    HexLazer205

    Alright thanks, and what do you mean by it is intensive on a small server? Also, this does work with custom colors in the boss bar message (It will work if I want the message to be Welcome! and I make the name ChatColor.GREEN + "Welcome!")? Oh and also, in Mineplex, you see the Dragon is defeated and respawned every 5-10 seconds or so while looking down, what does that mean and why is that?
     
  4. Offline

    Freack100

    HexLazer205
    It's because they change the "content" (not the text/dragon name) and if the bar is emtpy, the dragon dies and needs to be respawned.
     
  5. Offline

    AronTheGamer

    You should better use packets only, no real entities as they lag the server out
     
  6. Offline

    HexLazer205

    Can you tell me how to summon entities like an enderdragon and set their data such as name, speed, spawn location, and path they take?

    AronTheGamer what are packets?
     
  7. Offline

    Skionz

  8. Offline

    HexLazer205

    Thanks, but can you answer my question?
    How do I summon an entity and set custom name, health, speed, movement path, customnamevisible, etc.?
    Also when you set a custom name, is the name color customizable like:
    Code:
    ChatColor.GREEN + "Welcome!"
    
     
  9. Offline

    ROTN

    You have to create an EnderDragon entity through NMS (also learn reflection for this). Then you would change the name of the dragon and whatnot (ChatColor's are supported, you probably want to use ยง for colour codes instead of ChatColor.XYZ). Then you would send that packet to the player, and an enderdragon would actually spawn client side, and have no impact on your server.
     
  10. Offline

    HexLazer205

    OK, how do I send the packet to the player? Can you please be more detailed, I'm not understanding this very well. Can you also tell me how to summon an EnderDragon with a custom name, health, speed, direction, custom name visible? I've asked this multiple times and no one has answered it. I do not know the code to do this.
     
  11. Offline

    caderape

    because this is not easy and you mut have serious understanding of java for do it. This is not for nothing barApi is used by many servers.

    I don't think you will find a way to do it
     
  12. Offline

    HexLazer205

    That didn't help. I know java and I am studying syntaxes and everything for bukkit. I asked a question, you answer it. How it is going now is I ask a question, and you don't answer it and say oh this is too difficult for you. I know java and it is not too difficult. Please answer my question, as it is only difficult because you are not answering it. And caderape, there are many ways to do one thing in java. Please answer my question. That's all i am asking.
     
  13. Offline

    GeorgeeeHD

    HexLazer205
    if you wanna be lazy just copy their source code
     
  14. Offline

    HexLazer205

    Please stop or I will start reporting. Please answer my question or what I really want to do will not exist. It means a lot to me.
     
  15. Offline

    Skionz

    HexLazer205 I don't see why you can't just use BarAPI?
     
  16. Offline

    HexLazer205

    And I DON'T SEE WHY YOU CAN'T ANSWER MY QUESTION. I'm using a computer to code plugins that I'm not allowed to download anything except for eclipse and JDK. ALL of my plugins are CUSTOM-CODED. Please re-read my post and ANSWER MY QUESTION.
     
  17. Offline

    Skionz

  18. Offline

    XD 3VIL M0NKEY

    HexLazer205
    Who do you think you are?
    Skionz Don't bother helping him. He's got no respect.
    Maybe when he learns some respect he will get help.
     
    ChipDev and UnlikeAny like this.
  19. Offline

    ZeldoKavira


    They have answered your question quite a few times. If you cannot take a more respectful approach to your responses I will lock the thread.
     
    ChipDev likes this.
  20. Offline

    gyurix

    Maybe you are right, but you should be more respectful, because you asked a bit difficult question. The right answer is here :D
    1. You should use wither instead of ender dragon, because the wither makes less client lag
    2. You should spawn the wither only client side, because if you do it normally, then both the server and the client will must to handle several withers, which can cause lag.
    3. You said , that you don't know what are these packets, java reflections and how to use them, so I give you a link, where it is written really detailly: http://forums.bukkit.org/threads/li...sily-modify-sent-and-recieved-packets.101035/
    4. BarAPI has some things, which can be done better, for example the boss type, it uses ender dragon, but wither is better and the position of the dragon, it teleports the dragon under the player, so if the player is in a void world, then he can see the dragon.
    5. So the best way to do it is analyzing the BarAPI's source code, and find the secret in it. That can be a bit difficult, but if you are good at java, you can understand it. If you don't like the sourceforge, you can also use decompiler to get BarAPIs code. I always use this jd gui for it: jd.benow.ca
    I hope, that I answered properly for your question.
     
  21. Offline

    ToPoEdiTs

    LOOK:
    use libraries: BarAPI, bukkit
    this example easy
    Code:java
    1. package example;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5. import java.util.Random;
    6.  
    7. import me.confuser.barapi.BarAPI;
    8.  
    9. import org.bukkit.Bukkit;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.player.PlayerJoinEvent;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class Example extends JavaPlugin implements Listener {
    17.  
    18. Random r = new Random();
    19.  
    20. List<String> list = new ArrayList<>();
    21.  
    22. public void onEnable() {
    23. list.add("ยง0Much Custom. So Tutorial. Wow.");
    24. list.add("ยง1Much Custom. So Tutorial. Wow.");
    25.  
    26. showBarChanging();
    27. }
    28.  
    29. public void showBarChanging(){
    30. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    31. public void run(){
    32.  
    33. String message = (String) list.get(r.nextInt(list.size()));
    34.  
    35. for(Player p : Bukkit.getOnlinePlayers()){
    36. BarAPI.setMessage(p, message);
    37. }
    38. }
    39. }, 0, 1 * 20);
    40. }
    41. }
     
  22. Offline

    SmooshCakez

    224%
     
  23. Offline

    ToPoEdiTs

    lol sorry had not realized I was not that delay xd
     
  24. Offline

    HexLazer205

    XD 3VIL MONKEY, if you disrespect me like that again I will report your comment. I have showed no disrespect, whatsoever. I just used a bit of CAPS to point that part out more clearly. Telling someone not to help someone else is being a bystander, and not helping out. And ZeldoKavira, read my comments! I asked how to summon an EnderDragon with all the data and such, but they did not answer. Also, I am not going to bother spawning a wither gyurix, as the atmosphere will turn a purple-ish color. Also, I already said I am not allowed to download anything on this computer, so I cannot download the program to decompile the jar file BarAPI. When did you give me a code to say how to spawn a Wither and such? And ToPoEdiTs, I said I cannot use BarAPI as 1. I am not allowed to download anything on this computer, and 2. All of my plugins on my server are custom-coded. Now answer my question. How do I spawn an EnderDragon with custom data, such as name, speed, direction, customnamevisible? What is the code to do so? If you guys are good at programming Java and Bukkit Plugins, then you should know how to do this. Please answer my question. That is ALL I'M ASKING. I will tahg and like the comments that actually tell me how to do this.
     
  25. Offline

    Da_Co0k1eZ

    Dude, at least 3 different people have told you specifically NOT to spawn an ender dragon, just use packets.
    Besides, if you don't understand how to spawn an ender dragon, you should probably take a look at the Bukkit wiki.
    They might have something regarding it on there.

    But, please DO NOT spawn an ender dragon, use packets please, for the sake of your server.
     
  26. Offline

    Skionz

    HexLazer205 I was really interested in this so I decided to figure it out and I got it kind of working :D
    [​IMG]
    Ignore all the boats they were from failed attempts lol. Anyway here is the code; It is a method for spawning withers client side
    Code:java
    1. public static void newBar(Player player) {
    2. Location loc = player.getLocation();
    3. WorldServer world = ((CraftWorld) player.getLocation().getWorld()).getHandle();
    4. EntityWither wither = new EntityWither(world);
    5. wither.setLocation(loc.getX(), loc.getY() - 10, loc.getZ(), 0, 0);
    6. wither.setCustomName("This is a test!");
    7. Packet packet = new PacketPlayOutSpawnEntityLiving(wither);
    8. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    9. }


    EDIT: Just found out you can actually set the wither to be invisible although you will still be able to see the smoke particles
     
  27. Offline

    ChipDev

    Well, If you want to whine, then go and figure out barAPI's source code.
    Yea. I said it.

    Bro, I want dem boats code xP
    In fact, I want it SO badly, I will code it myself.
    For a random reason, boats look beepin' cool!
    Will dis work?
    Code:java
    1. package com.chip;
    2.  
    3. import org.bukkit.entity.Entity;
    4. import org.bukkit.entity.EntityType;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerMoveEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9. import org.bukkit.util.Vector;
    10.  
    11. public class Rolley extends JavaPlugin implements Listener {
    12.  
    13. public void onEnable() {
    14. getServer().getPluginManager().registerEvents(this, this);
    15. }
    16. public void spawnBoat(Player p) {
    17. Entity skull = p.getWorld().spawnEntity(p.getLocation(), EntityType.WITHER_SKULL);
    18. Entity boat = p.getWorld().spawnEntity(p.getLocation().add(0, -1, 0), EntityType.BOAT);
    19. skull.setVelocity(new Vector(0, 0 ,0));
    20. skull.setPassenger(boat);
    21. }
    22. public void onPlayerMoveEvent(PlayerMoveEvent e) {
    23. spawnBoat(e.getPlayer());
    24. }
    25.  
    26. }
    27.  

    Skionz
    edit:
    Code:java
    1. package com.chip;
    2.  
    3. import org.bukkit.entity.Entity;
    4. import org.bukkit.entity.EntityType;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.entity.WitherSkull;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.player.PlayerMoveEvent;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11. import org.bukkit.util.Vector;
    12.  
    13. public class Rolley extends JavaPlugin implements Listener {
    14.  
    15. public void onEnable() {
    16. getServer().getPluginManager().registerEvents(this, this);
    17. }
    18. public void spawnBoat(Player p) {
    19. WitherSkull skull = (WitherSkull) p.getWorld().spawn(p.getLocation(), WitherSkull.class);
    20. skull.setDirection(new Vector(0, 0, 0));
    21. skull.setVelocity(new Vector(0, 0, 0));
    22. Entity boat = p.getWorld().spawnEntity(p.getLocation().add(0, -1, 0), EntityType.BOAT);
    23. skull.setPassenger(boat);
    24. }
    25. @EventHandler
    26. public void onPlayerMoveEvent(PlayerMoveEvent e) {
    27. spawnBoat(e.getPlayer());
    28. }
    29.  
    30. }
    31.  

    does
    [​IMG]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
    Totom3 and XD 3VIL M0NKEY like this.
  28. Offline

    Skionz

    ChipDev I have no idea how I got the boats xD. They are really cool though you can walk on them like stairs and they don't fall!
    HexLazer205 After a bit more testing I have come to a conclusion... Withers suck for bars. Sure they are less laggy I guess but you can only see the bar from around 70 or 80 blocks away. Using enderdragons you can see it from about 200 blocks away
     
  29. Offline

    ChipDev

    Skionz
    Suddendly, 300 withers above every player.
     
  30. Offline

    Skionz

    ChipDev Any idea on how to remove an EntityEnderDragon?
     
Thread Status:
Not open for further replies.

Share This Page