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

Doubt about api #9

Open
alexissdev opened this issue Aug 2, 2019 · 22 comments
Open

Doubt about api #9

alexissdev opened this issue Aug 2, 2019 · 22 comments

Comments

@alexissdev
Copy link

Good I have a doubt how I can use the scoreboard api without using your .jar to improve the experience of my plugin

@MinusKube
Copy link
Owner

MinusKube commented Aug 4, 2019

Hello, you only have to copy/paste the content of the "core" and "bukkit" (or "sponge" if you're using Sponge) modules into your plugin

@alexissdev
Copy link
Author

alexissdev commented Aug 6, 2019 via email

@MinusKube
Copy link
Owner

If it blinks, it's either because you're using 1.7, either because you're not updating the line correctly just by using board.set("Test Score", 5); (maybe you're removing then setting the line again, or maybe you're destroying and recreating the scoreboard each time).

And I'm not sure what you mean by "reapeating lines", but if you want two lines with the same text, you need to make these lines a little different by adding a color at the end of the line for example, so the line is different, but looks exactly the same.

@alexissdev
Copy link
Author

alexissdev commented Aug 7, 2019 via email

@MinusKube
Copy link
Owner

Yeah, you're recreating the scoreboard for the player every time you call the setScoreboard method. You must create the scoreboard only once (when the player join for example), then, inside your scheduler, you can get the player's board using Netherboard.instance().getBoard(player) and call all the board.set(...) methods to update the lines.

@alexissdev
Copy link
Author

alexissdev commented Aug 8, 2019 via email

@MinusKube
Copy link
Owner

You use the Netherboard.instance().createBoard(...) inside your createScoreboard method to create the scoreboard only once for the player, then BPlayerBoard board = Netherboard.instance().getBoard(player) inside your setScoreboard method, in order to get the player's board so you can update it.

@alexissdev
Copy link
Author

alexissdev commented Aug 8, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 8, 2019 via email

@MinusKube
Copy link
Owner

You must put the display name of the scoreboard here

@alexissdev
Copy link
Author

alexissdev commented Aug 9, 2019 via email

@MinusKube
Copy link
Owner

MinusKube commented Aug 9, 2019

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

    // Create the scoreboard when the player joins
    Netherboard.instance().createBoard(player, "My Scoreboard");
}

@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();

    // Delete the scoreboard when the player leaves
    Netherboard.instance().deleteBoard(player);
}

public void initScoreboardTask(int delay) {
    Bukkit.getScheduler().runTaskTimer(plugin, () -> {
        FileConfiguration config = plugin.getConfig();
        
        for(Player player : Bukkit.getOnlinePlayers()) {
            // Update the scoreboard every <delay> ticks for each online player
            updateScoreboard(player, config);
        }
    }, 0, delay);
}

public void updateScoreboard(Player player, FileConfiguration config) {
    BPlayerBoard board = Netherboard.instance().getBoard(player);

    // You call all the set methods here
    board.set(...);
}

@alexissdev
Copy link
Author

alexissdev commented Aug 9, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 9, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 9, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 9, 2019 via email

@MinusKube
Copy link
Owner

MinusKube commented Aug 9, 2019

Hey, you wanted this question to be silly, but once I imported the core and the bukkit from the netherboard src, I have to use Netherboard. as if he was using the .jar?

Yeah, you only don't have to put depend: [Netherboard] inside your plugin.yml.

@MinusKube
Copy link
Owner

And I didn't understand your problem with your staff thing

@alexissdev
Copy link
Author

alexissdev commented Aug 10, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 11, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 15, 2019 via email

@alexissdev
Copy link
Author

alexissdev commented Aug 20, 2019 via email

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

No branches or pull requests

2 participants