Open ghost opened 4 years ago
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.
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
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);
}
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
My plugin is exported correctly, I don't receive errors, and my listener is registered
it just doesn't show anything upon entering
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?
You can copy the core and bukkit modules to your code, or include them inside your jar using Maven/Gradle
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
);
}
}
`
If you create the Scoreboard on PlayerJoinEvent and make sure to call the method R()
, this should work
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
);
}
}`
.
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...
So I would have to remove the method where I have created the scoreboard of the run () method?
.
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
)
`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?
.
Hi, how could I make an animated scoreboard using your API?