Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated Scoreboard #10

Open
ghost opened this issue Nov 16, 2019 · 18 comments
Open

Animated Scoreboard #10

ghost opened this issue Nov 16, 2019 · 18 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 16, 2019

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

@MinusKube
Copy link
Owner

MinusKube commented Nov 16, 2019

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.

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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
Copy link
Author

ghost commented Nov 16, 2019

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);

}

@MinusKube
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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

@ghost
Copy link
Author

ghost commented Nov 16, 2019

it just doesn't show anything upon entering

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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?

@MinusKube
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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
    );
}
}

`

@MinusKube
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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
Copy link
Author

ghost commented Nov 16, 2019

.

@MinusKube
Copy link
Owner

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...

@ghost
Copy link
Author

ghost commented Nov 16, 2019

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

@ghost
Copy link
Author

ghost commented Nov 16, 2019

.

@MinusKube
Copy link
Owner

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)

@ghost
Copy link
Author

ghost commented Nov 17, 2019

`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
Copy link
Author

ghost commented Nov 18, 2019

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant