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

[Question]: /money top = showing Null players, when Towny is installed. #24

Closed
ventus008 opened this issue Jan 15, 2023 · 16 comments
Closed
Assignees
Labels
Question Question or help

Comments

@ventus008
Copy link

Your Question

I have question about top players list, some of it is showing null. Is there a way to remove it? I would appreciate all answers.

@ventus008 ventus008 added the Question Question or help label Jan 15, 2023
@LcyDev
Copy link
Collaborator

LcyDev commented Jan 15, 2023

Yes, i had the same issue.
I'm working on a patch for this.

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 15, 2023

Would you like to remove them from the database or just to not show them in the baltop?

@EncryptSL
Copy link
Owner

Please post your version in 1.2.1-SNAPSHOT, balance top working for me.

image

@EncryptSL
Copy link
Owner

Or update to 1.2.1-SNAPSHOT

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 15, 2023

In my case, i deleted Essentials/playerdata (Towns included), this caused towny to generate new uuids for the towns.

After that, null accounts appeared in the baltop
image

I'm making a command to set player names in the MySQL database, so i can know what accounts are null, save them, delete them and manually send money to the respected Town

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 15, 2023

image
Nice.

@EncryptSL
Copy link
Owner

I can say only i this confirm with towny.

@EncryptSL
Copy link
Owner

Issue with null player name is because towny using npc fake accounts.

And LiteEco don't know what is fake account.

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 15, 2023

I made a command to remove null players but the implementation is not elegant (Iterating over HashMap obtained from Baltop)

Do you think this command could be a feature?

@ventus008
Copy link
Author

Hello, Thank you for your responses.

So the "null" players is being generated by towny? And in order to remove them from showing in Baltop is to access databese.db?

@ventus008 ventus008 reopened this Jan 15, 2023
@EncryptSL
Copy link
Owner

EncryptSL commented Jan 15, 2023

I made a command to remove null players but the implementation is not elegant (Iterating over HashMap obtained from Baltop)

Do you think this command could be a feature?

I'm not sure if this is a possible way, because everytime towny generating accounts.
Can be implemented something like /money|balance|bal purge [argument] something like nullaccounts, or /money purge. Only for feature like a tool when something broke. Like a your feature

Towny must be blocked for now,

Hello, Thank you for your responses.

So the "null" players is being generated by towny? And in order to remove them from showing in Baltop is to access databese.db?

In this, case you don't have tools how delete null accounts because database.db can't be opened with programs.
In next update can be implemented tool how null accounts delete.

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 16, 2023

The thing is, towns SHOULD have names, normally they aren't null and are something like town-Bonn

@EncryptSL
Copy link
Owner

EncryptSL commented Jan 16, 2023

Yes of course, you have right but, but this is a FakePlayer, with uuid.
And my api isn't ready on usernames, because i don't planned support for towny.

  1. Solution add into config.yml towny-balance: true, and need another stuff for controlling.
  2. Solution add into existing table column username or name, there must be used something like migration tool. Because we must iterate in balanceTop usernames or name from columns. And we must add into still existed data, offline players usernames.
  3. Simple solution for balancetop is add check if player name is null or not, another solution is add check if player playedBefore.

For third solution. I think this is a simple solution, but need tests.

        val balances = liteEco.api.getTopBalance().entries.sortedByDescending { e -> e.value }
            .filter { data -> Bukkit.getOfflinePlayer(UUID.fromString(data.key)).hasPlayedBefore() }
            .positionIndexed { index, mutableEntry -> LegacyComponentSerializer.legacyAmpersand().serialize(ModernText.miniModernText(
                liteEco.translationConfig.getMessage("messages.balance_top_format"),
                TagResolver.resolver(
                    Placeholder.parsed("position", index.toString()),
                    Placeholder.parsed(
                        "player",
                        Bukkit.getOfflinePlayer(UUID.fromString(mutableEntry.key)).name.toString()
                    ),
                    Placeholder.parsed("money", liteEco.api.formatting(mutableEntry.value))
                )
            )) }

OR

        val balances = liteEco.api.getTopBalance().entries.sortedByDescending { e -> e.value }
            .filter { data -> Bukkit.getOfflinePlayer(UUID.fromString(data.key)).name.isNullOrEmpty() }
            .positionIndexed { index, mutableEntry -> LegacyComponentSerializer.legacyAmpersand().serialize(ModernText.miniModernText(
                liteEco.translationConfig.getMessage("messages.balance_top_format"),
                TagResolver.resolver(
                    Placeholder.parsed("position", index.toString()),
                    Placeholder.parsed(
                        "player",
                        Bukkit.getOfflinePlayer(UUID.fromString(mutableEntry.key)).name.toString()
                    ),
                    Placeholder.parsed("money", liteEco.api.formatting(mutableEntry.value))
                )
            )) }

@EncryptSL
Copy link
Owner

But i think there is not another necessary, add another functions. But Imho, idk.

@LcyDev
Copy link
Collaborator

LcyDev commented Jan 16, 2023

I see now. Beware that if you add a new column this could happen:

[12:58:20] [Craft Scheduler Thread - 22 - Essentials/WARN]: [Exposed] Transaction attempt #0 failed: java.sql.SQLException: Field 'name' doesn't have a default value. Statement(s): INSERT INTO lite_eco (money, uuid) VALUES (?, ?)
org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLException: Field 'name' doesn't have a default value
	at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:64) ~[?:?]

But fixeable

@EncryptSL EncryptSL changed the title [Question]: /money top = showing Null players [Question]: /money top = showing Null players, when Towny is installed. Jan 23, 2023
Repository owner locked as resolved and limited conversation to collaborators Jan 23, 2023
@EncryptSL
Copy link
Owner

Plugin Towny is not supported for now, maybe in future...

@EncryptSL EncryptSL pinned this issue Jan 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question Question or help
Projects
None yet
Development

No branches or pull requests

3 participants