Skip to content

Commit 1a6da05

Browse files
committed
Refactor PlayerVoteListener to improve user validity checks
- Updated validity check logic to use properName instead of creditedName. - Maintained existing behavior for handling unjoined players based on config settings. - Added warning log for players who have not joined before voting.
1 parent 8193c25 commit 1a6da05

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/PlayerVoteListener.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,28 @@ public void onplayerVote(PlayerVoteEvent event) {
5656
// check for name casing
5757
final String properName = plugin.getUserManager().getProperName(playerName);
5858

59-
// Resolve Bedrock/Java + add prefix only when appropriate
60-
BedrockNameResolver.Result rn = plugin.getBedrockHandle().resolve(properName);
61-
String creditedName = rn.finalName;
62-
63-
plugin.debug("Vote name resolved: " + properName + " -> " + creditedName + " (" + rn.rationale + ")");
64-
6559
// Single validity check on the final name
6660
boolean allowUnJoinedCheckServer = plugin.getConfigFile().isAllowUnJoinedCheckServer();
67-
boolean isValid = PlayerManager.getInstance().isValidUser(creditedName, allowUnJoinedCheckServer);
61+
boolean isValid = PlayerManager.getInstance().isValidUser(properName, allowUnJoinedCheckServer);
6862

6963
// Handle not-valid the same way you did before
7064
if (!isValid) {
7165
if (!plugin.getConfigFile().isAllowUnjoined()) {
72-
plugin.getLogger().warning("Player " + creditedName + " has not joined before, disregarding vote. "
66+
plugin.getLogger().warning("Player " + properName + " has not joined before, disregarding vote. "
7367
+ "Set AllowUnjoined to true to accept.");
7468
if (event.isBungee() && plugin.getBungeeSettings().isRemoveInvalidUsers()) {
75-
plugin.getVotingPluginUserManager().getVotingPluginUser(creditedName).remove();
69+
plugin.getVotingPluginUserManager().getVotingPluginUser(properName).remove();
7670
}
7771
return;
7872
}
7973
}
8074

75+
// Resolve Bedrock/Java + add prefix only when appropriate
76+
BedrockNameResolver.Result rn = plugin.getBedrockHandle().resolve(properName);
77+
String creditedName = rn.finalName;
78+
79+
plugin.debug("Vote name resolved: " + properName + " -> " + creditedName + " (" + rn.rationale + ")");
80+
8181
// If we get here, use the resolved/possibly-prefixed name going forward
8282
playerName = creditedName;
8383

0 commit comments

Comments
 (0)