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

[bugreport]: Scoreboard does not update #33

Closed
DSeeLP opened this issue Oct 31, 2020 · 8 comments
Closed

[bugreport]: Scoreboard does not update #33

DSeeLP opened this issue Oct 31, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@DSeeLP
Copy link
Contributor

DSeeLP commented Oct 31, 2020

Describe the bug

The method in that the scoreboard is declared is called but the scoreboard is not changing. i need to reconnect to apply the changes

Environment information

  • Operating system: Windows 10
  • Java-Version: 1.8
  • Kelp-Core-Version: v.0.0.4
  • Version-Implementation: 1.8
@DSeeLP DSeeLP added the bug Something isn't working label Oct 31, 2020
@PXAV
Copy link
Member

PXAV commented Oct 31, 2020

Could you please provide the code for your sidebar as well as the snippet from which you call the update method?

@DSeeLP
Copy link
Contributor Author

DSeeLP commented Oct 31, 2020

i don't call the update method but the code gets executed.

    @CreateSidebar(identifier = "", setOnJoin = true)
    public AnimatedSidebar defaultSidebar(Player player) {
        AnimatedSidebar sidebar = sidebarFactory.newAnimatedSidebar();
        //sidebar.withTitle(animationFactory.newStaticTextAnimation("§6\u2022§e\u25cf §eDunityGames"));
        sidebar.withTitle(animationFactory.newStaticTextAnimation("§e§lDunityGames"));
        sidebar.addComponent(componentFactory.simpleTextComponent("§8➜ §eBargeld§8").line(15));
        sidebar.addComponent(componentFactory.simpleTextComponent("§8 ➥ §7"+ Economy.getMoney(player.getUniqueId())+"$").line(14));
        sidebar.addComponent(componentFactory.emptyLineComponent(13));
        sidebar.addComponent(componentFactory.simpleTextComponent("§8➜ §eBank§8").line(12));
        sidebar.addComponent(componentFactory.simpleTextComponent("§8 ➥ §7"+ Economy.getBank(player.getUniqueId())+"$").line(11));

        return sidebar;
    }

@DSeeLP
Copy link
Contributor Author

DSeeLP commented Oct 31, 2020

I set an breakpoint at AnimatedSidebar sidebar = sidebarFactory.newAnimatedSidebar(); and it was executed repeatedly

@PXAV
Copy link
Member

PXAV commented Oct 31, 2020

But how should the Sidebar update if the update method is never called? Try assigning a real identifier to the sidebar and call the update method in order to update it without rejoining

EDIT: What do you mean by i don't call the update method the code is executed?? Is the code executed although you have never called the method?

@DSeeLP
Copy link
Contributor Author

DSeeLP commented Oct 31, 2020

yes the code is always executed and i never called the method

@PXAV
Copy link
Member

PXAV commented Oct 31, 2020

Could you try removing the breakpoint?

@DSeeLP
Copy link
Contributor Author

DSeeLP commented Oct 31, 2020

when i replace the AnimatedSidebar with the SimpleSidebar the method isn't called always

@PXAV
Copy link
Member

PXAV commented Oct 31, 2020

Ah ok now I get your point. Yes, if you choose AnimatedSidebar as sidebar type, Kelp calls the sidebar method in the given animation interval in order to send the title update to the player. In your case, this does not make much sense, because you have chosen a static title. Here is the corresponding code from the Kelp source code:

// load the sidebar for the player
AnimatedSidebar sidebar = (AnimatedSidebar) getSidebar(identifier, player);
Preconditions.checkNotNull(sidebar);

// update the state. If the state index it out of bounds, reset it to 0.
animationStates.put(player, animationStates.get(player) + 1);
if (state >= sidebar.maxStates() - 1) {
  this.animationStates.put(player, 0);
}

// finally update the title.
sidebar.updateTitleOnly(player, state);

But thank you very much for reporting this issue, when developing the sidebar system I did not think of possible side effects, which can occur when the entire sidebar method is called every few seconds (querying databases within the sidebar method for example would cause a huge server lag). I think I will have to change the design of sidebar creation and apply the same principle used in the command system, where specific attributes such as permission, etc. are set in a different method (onCommandRegister) so that the main command method does not have to be called multiple times.

I think for the future, sidebars will take a dedicated class or lambda class in order to avoid this problem. I'll try my best to fix this issue!

pxav.

@PXAV PXAV closed this as completed Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants