aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-03-04 02:54:50 +0100
committerGitHub <noreply@github.com>2023-03-04 12:54:50 +1100
commit5dd063fbba6bde64806a7620541dc2d9bdf42871 (patch)
tree01aee1a743a32a0b2546513c59a43559ce3085fe /src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java
parentdb86c98e0c72b18663ef26cd46cef7d53c1d6414 (diff)
downloadnotenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.tar.gz
notenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.tar.bz2
notenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.zip
Replace all commands in NEU with a brigadier implementation (#599)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java94
1 files changed, 0 insertions, 94 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java
deleted file mode 100644
index cf0d0c56..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
- *
- * This file is part of NotEnoughUpdates.
- *
- * NotEnoughUpdates is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * NotEnoughUpdates is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package io.github.moulberry.notenoughupdates.commands.misc;
-
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
-import io.github.moulberry.notenoughupdates.util.MinecraftExecutor;
-import io.github.moulberry.notenoughupdates.util.PronounDB;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiNewChat;
-import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.util.ChatComponentText;
-
-import java.util.Optional;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-
-public class PronounsCommand extends ClientCommandBase {
- public PronounsCommand() {
- super("neupronouns");
- }
-
- @Override
- public String getCommandUsage(ICommandSender sender) {
- return "/neupronouns <username> [platform]";
- }
-
- @Override
- public void processCommand(ICommandSender sender, String[] args) throws CommandException {
- switch (args.length) {
- case 1:
- fetchPronouns("minecraft", args[0]);
- break;
- case 2:
- fetchPronouns(args[1], args[0]);
- break;
- default:
- sender.addChatMessage(new ChatComponentText("§4" + getCommandUsage(sender)));
- }
- }
-
- private void fetchPronouns(String platform, String user) {
- GuiNewChat nc = Minecraft.getMinecraft().ingameGUI.getChatGUI();
- int id = new Random().nextInt();
- nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] Fetching Pronouns..."), id);
-
- CompletableFuture<Optional<PronounDB.PronounChoice>> pronouns;
- if ("minecraft".equals(platform)) {
- CompletableFuture<UUID> c = new CompletableFuture<>();
- NotEnoughUpdates.profileViewer.getPlayerUUID(user, uuidString -> {
- if (uuidString == null) {
- c.completeExceptionally(new NullPointerException());
- } else {
- c.complete(Utils.parseDashlessUUID(uuidString));
- }
- });
- pronouns = c.thenCompose(PronounDB::getPronounsFor);
- } else {
- pronouns = PronounDB.getPronounsFor(platform, user);
- }
- pronouns.handleAsync((pronounChoice, throwable) -> {
- if (throwable != null || !pronounChoice.isPresent()) {
- nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] §4Failed to fetch pronouns."), id);
- return null;
- }
- PronounDB.PronounChoice betterPronounChoice = pronounChoice.get();
- nc.printChatMessageWithOptionalDeletion(new ChatComponentText(
- "§e[NEU] Pronouns for §b" + user + " §eon §b" + platform + "§e:"), id);
- betterPronounChoice.render().forEach(it -> nc.printChatMessage(new ChatComponentText("§e[NEU] §a" + it)));
- return null;
- }, MinecraftExecutor.OnThread);
-
- }
-}