some more fix

This commit is contained in:
Chayapak 2023-08-21 19:47:07 +07:00
parent 481eab7a03
commit 672de54b26
2 changed files with 12 additions and 7 deletions

View file

@ -45,6 +45,10 @@ public class AuthPlugin extends PlayersPlugin.Listener {
public void playerJoined(PlayerEntry target) {
if (!target.profile.getName().equals(bot.config.ownerName) || !bot.options.useCore) return;
bot.executor.schedule(() -> sendVerificationMessage(target), 2, TimeUnit.SECONDS);
}
public void sendVerificationMessage (PlayerEntry entry) {
started = true;
final long currentTime = System.currentTimeMillis();
@ -63,7 +67,7 @@ public class AuthPlugin extends PlayersPlugin.Listener {
.text(id)
.append(Component.text(hash))
.append(Component.text(UUIDUtilities.selector(bot.profile.getId()))), // convenient reason
target.profile.getId()
entry.profile.getId()
);
}
@ -72,6 +76,7 @@ public class AuthPlugin extends PlayersPlugin.Listener {
if (!target.profile.getName().equals(bot.config.ownerName)) return;
hasCorrectHash = false;
started = false;
}
private void systemMessageReceived (Component component) {
@ -98,8 +103,6 @@ public class AuthPlugin extends PlayersPlugin.Listener {
.toString()
.substring(0, 8);
bot.logger.info("Input: " + inputHash + " Real Hash: " + hash);
hasCorrectHash = inputHash.equals(hash);
} catch (Exception ignored) {}
}
@ -113,6 +116,8 @@ public class AuthPlugin extends PlayersPlugin.Listener {
final long timeSinceJoined = System.currentTimeMillis() - timeJoined;
if (!hasCorrectHash) sendVerificationMessage(entry);
if (timeSinceJoined > bot.config.ownerAuthentication.timeout && !hasCorrectHash) {
bot.filter.mute(entry, "Not verified");
bot.filter.deOp(entry);

View file

@ -91,19 +91,19 @@ public class ChatPlugin extends Bot.Listener {
if (playerMessage != null) break;
}
boolean isCommandSuggestions = false;
boolean ignore = false;
if (component instanceof TextComponent t_component) {
final String id = t_component.content();
if (id.equals(bot.commandSuggestion.id)) isCommandSuggestions = true;
if (id.equals(bot.commandSuggestion.id) || id.equals(bot.auth.id)) ignore = true;
}
final String string = ComponentUtilities.stringify(component);
final String ansi = ComponentUtilities.stringifyAnsi(component);
for (Listener listener : listeners) {
if (!isCommandSuggestions) listener.systemMessageReceived(component, string, ansi);
listener.systemMessageReceived(component, isCommandSuggestions, string, ansi);
if (!ignore) listener.systemMessageReceived(component, string, ansi);
listener.systemMessageReceived(component, ignore, string, ansi);
if (playerMessage != null) listener.playerMessageReceived(playerMessage);
}