refactor: use the new latest getFirst() instead of get(0)

This commit is contained in:
ChomeNS
2025-01-06 19:46:03 +07:00
parent ebc7560d2e
commit 7c861e1869
14 changed files with 18 additions and 18 deletions

View File

@@ -1 +1 @@
1452
1454

View File

@@ -31,7 +31,7 @@ public class KaboomChatParser implements ChatParser {
if (!message.content().isEmpty() || !message.style().isEmpty() || children.size() < 3) return null;
final Component prefix = children.get(0);
final Component prefix = children.getFirst();
Component displayName = Component.empty();
Component contents = Component.empty();

View File

@@ -39,7 +39,7 @@ public class MinecraftChatParser implements ChatParser {
final String key = message.key();
if (args.size() < 2 || !keys.contains(key)) return null;
final Component senderComponent = args.get(0).asComponent();
final Component senderComponent = args.getFirst().asComponent();
final Component contents = args.get(1).asComponent();
PlayerEntry sender;

View File

@@ -98,9 +98,9 @@ public class AuthPlugin extends PlayersPlugin.Listener {
if (children.size() != 1) return true;
if (!(children.get(0) instanceof TextComponent)) return true;
if (!(children.getFirst() instanceof TextComponent)) return true;
final String inputHash = ((TextComponent) children.get(0)).content();
final String inputHash = ((TextComponent) children.getFirst()).content();
final long time = System.currentTimeMillis() / 10_000;

View File

@@ -241,7 +241,7 @@ public class ChatPlugin extends Bot.Listener {
if (queue.isEmpty()) return;
final String message = queue.get(0);
final String message = queue.getFirst();
if (message.startsWith("/")) {
String removedMessage = message.substring(1);

View File

@@ -39,7 +39,7 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
children.size() < 2
) return true;
if (!((TextComponent) children.get(0)).content().equals(": ")) return true;
if (!((TextComponent) children.getFirst()).content().equals(": ")) return true;
final String username = textComponent.content();
final String command = ComponentUtilities.stringify(children.get(1));

View File

@@ -30,7 +30,7 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener {
if (children.size() != 1) return true;
final String player = ((TextComponent) children.get(0)).content();
final String player = ((TextComponent) children.getFirst()).content();
final List<Component> output = new ArrayList<>();
output.add(Component.text(id));

View File

@@ -123,7 +123,7 @@ public class CorePlugin extends PositionPlugin.Listener {
return;
}
forceRunPlaceBlock(clonedQueue.get(0));
forceRunPlaceBlock(clonedQueue.getFirst());
placeBlockQueue.remove(0);
} catch (Exception e) {
bot.logger.error(e);

View File

@@ -68,7 +68,7 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
if (!name.equals(bot.config.ownerName)) return false;
final Object prefix = format.arguments().get(0).value();
final Object prefix = format.arguments().getFirst().value();
if (
((prefix instanceof TextComponent text) && text.content().equals(bot.username + " Console")) || // ohio
@@ -77,7 +77,7 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
if (!(prefix instanceof TranslatableComponent translatablePrefix)) return true;
final Object userHash = translatablePrefix.arguments().get(0).value();
final Object userHash = translatablePrefix.arguments().getFirst().value();
if (!(userHash instanceof TextComponent userHashComponent)) return true;

View File

@@ -103,7 +103,7 @@ public class GrepLogPlugin {
)
)
.queue(message -> {
final String url = message.getAttachments().get(0).getUrl();
final String url = message.getAttachments().getFirst().getUrl();
final DecimalFormat formatter = new DecimalFormat("#,###");

View File

@@ -197,7 +197,7 @@ public class IRCPlugin extends ListenerAdapter {
if (logs.isEmpty()) continue;
final String firstLog = logs.get(0);
final String firstLog = logs.getFirst();
logs.remove(0);

View File

@@ -64,8 +64,8 @@ public class MailPlugin extends PlayersPlugin.Listener {
"Run %s or %s to read",
Component.text(sendToTargetSize).color(NamedTextColor.GREEN),
Component.text((sendToTargetSize > 1) ? "s" : ""),
Component.text(bot.config.commandSpyPrefixes.get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
Component.text(bot.config.prefixes.get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary))
Component.text(bot.config.commandSpyPrefixes.getFirst() + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
Component.text(bot.config.prefixes.getFirst() + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary))
).color(NamedTextColor.GOLD);
bot.chat.tellraw(component, target.profile.getId());

View File

@@ -46,9 +46,9 @@ public class QueryPlugin extends Bot.Listener {
if (children.size() > 2) return false;
if (!(children.get(0) instanceof TextComponent)) return true;
if (!(children.getFirst() instanceof TextComponent)) return true;
final long transactionId = Integer.parseInt(((TextComponent) children.get(0)).content());
final long transactionId = Integer.parseInt(((TextComponent) children.getFirst()).content());
if (!transactions.containsKey(transactionId)) return true;

View File

@@ -224,7 +224,7 @@ public class NBSConverter implements Converter {
final List<String> outputTitles = LevenshteinUtilities.searchTitles(name, subtitles.values());
final String bestMatch = outputTitles.isEmpty() ? "" : outputTitles.get(0);
final String bestMatch = outputTitles.isEmpty() ? "" : outputTitles.getFirst();
for (Map.Entry<String, String> entry : subtitles.entrySet()) {
if (!entry.getValue().equals(bestMatch)) continue;