Netherboard icon indicating copy to clipboard operation
Netherboard copied to clipboard

Animated Scoreboard

Open ghost opened this issue 6 years ago • 18 comments

Hi, how could I make an animated scoreboard using your API?

ghost avatar Nov 16 '19 02:11 ghost

Hello, you must run a scheduler every X ticks and simply call the set method inside it with the line number and the String.

There is currently no utility class for doing some String animations easily, but it's planned for later.

MinusKube avatar Nov 16 '19 02:11 MinusKube

I think I rushed too much, I don't even get a static scoreboard, I followed the steps of github and I can't make a scoreboard with this api, I'm currently at 1.12.2

ghost avatar Nov 16 '19 02:11 ghost

This is my code

@EventHandler

public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer();

BPlayerBoard board = Netherboard.instance().createBoard(player, "My Scoreboard");
board.set("Hola", 1);
board.get(1);

}

ghost avatar Nov 16 '19 02:11 ghost

Your code seems correct, check if your listener is correctly registered, if your plugin is correctly exported, if you don't have any error in the console, and things like that

MinusKube avatar Nov 16 '19 02:11 MinusKube

My plugin is exported correctly, I don't receive errors, and my listener is registered

ghost avatar Nov 16 '19 02:11 ghost

it just doesn't show anything upon entering

ghost avatar Nov 16 '19 02:11 ghost

Ok, I solved it, I just had to put depend: Netherboard and put the pl to my server, how could I use the api correctly and not have to put Netherboard.jar in my plugins folder?

ghost avatar Nov 16 '19 02:11 ghost

You can copy the core and bukkit modules to your code, or include them inside your jar using Maven/Gradle

MinusKube avatar Nov 16 '19 03:11 MinusKube

Regarding the animated scoreboard, would this code be good?

`package miniprueba;

import fr.minuskube.netherboard.Netherboard; import fr.minuskube.netherboard.bukkit.BPlayerBoard; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler;

public class ScoreBoard implements Listener{

private final MiniPrueba plugin;
public ScoreBoard(MiniPrueba plugin){
    this.plugin = plugin;
}

@EventHandler
public void Sb(Player p) {

BPlayerBoard board = Netherboard.instance().getBoard(p);
board.set("Hola", 1);
board.get(1);
board.setName("Skere");
    }
public void R(){
    BukkitScheduler sc = Bukkit.getScheduler();
    sc.scheduleSyncRepeatingTask(plugin, new Runnable(){

        @Override
        public void run() {
          for(Player p : Bukkit.getOnlinePlayers()){
              Sb(p);
          }
        }
    }, 0L, 05L
    );
}
}

`

ghost avatar Nov 16 '19 03:11 ghost

If you create the Scoreboard on PlayerJoinEvent and make sure to call the method R(), this should work

MinusKube avatar Nov 16 '19 03:11 MinusKube

Yes, it worked, now how would it make the score lively? Sorry if I ask a lot of questions I am learning little by little ... Code: ` package miniprueba;

import fr.minuskube.netherboard.Netherboard; import fr.minuskube.netherboard.bukkit.BPlayerBoard; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler;

public class ScoreBoard implements Listener{

private final MiniPrueba plugin;
public ScoreBoard(MiniPrueba plugin){
    this.plugin = plugin;
}

public void Sb(Player p) {

BPlayerBoard board = Netherboard.instance().createBoard(p, "Skere");
board.set("Hola", 1);
board.get(1);
board.setName("Skere");
    }
@EventHandler
public void R(PlayerJoinEvent e){
    BukkitScheduler sc = Bukkit.getScheduler();
    sc.scheduleSyncRepeatingTask(plugin, new Runnable(){

        @Override
        public void run() {
            Bukkit.getOnlinePlayers().stream().forEach((p) -> {
                Sb(p);
            });
        }
    }, 0L, 05L
    );
}
}`

ghost avatar Nov 16 '19 03:11 ghost

.

ghost avatar Nov 16 '19 14:11 ghost

Firstly you must only create the scoreboard once, not each time the scheduler is called, and then in your Sb method you just do whatever you want in it and you'll be able to make animations, edit the texts, etc...

MinusKube avatar Nov 16 '19 14:11 MinusKube

So I would have to remove the method where I have created the scoreboard of the run () method?

ghost avatar Nov 16 '19 15:11 ghost

.

ghost avatar Nov 16 '19 20:11 ghost

You must create the scoreboard (createBoard) only once at the beginning of the PlayerJoinEvent, then, inside your scheduler, you get the board (getBoard) and you set the lines (set)

MinusKube avatar Nov 16 '19 21:11 MinusKube

`package miniprueba;

import fr.minuskube.netherboard.Netherboard; import fr.minuskube.netherboard.bukkit.BPlayerBoard; import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitScheduler;

public class ScoreBoard implements Listener{

private final MiniPrueba plugin;
public ScoreBoard(MiniPrueba plugin){
    this.plugin = plugin;
}
@EventHandler
 public void Sb(PlayerJoinEvent e) {
 Player p = e.getPlayer();
BPlayerBoard board = Netherboard.instance().createBoard(p, "Skere");
        board.get(1);
        board.set("Hola", 1);
        board.get(1);
        board.setName("Skere");
    
     
    BukkitScheduler sc = Bukkit.getScheduler();
    sc.scheduleSyncRepeatingTask(plugin, new Runnable(){
    @Override
    public void run(){
        BPlayerBoard boardget = Netherboard.instance().getBoard(p);
    boardget.set("Holanda", 1);
        boardget.get(1);
            }
        }, 0, 5L);

    }

}`

Ok. It is assumed that now I would have to change the text of the score, but how do I get it back to the text of the previous score?

ghost avatar Nov 17 '19 15:11 ghost

.

ghost avatar Nov 18 '19 15:11 ghost