mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
1 parent
088d536bf4
commit
998b555e67
4 files changed
+118
No files matched your search
@@ -57,6 +57,7 @@ import net.draycia.carbon.common.command.commands.MuteCommand;
|
|||||||
import net.draycia.carbon.common.command.commands.MuteInfoCommand;
|
import net.draycia.carbon.common.command.commands.MuteInfoCommand;
|
||||||
import net.draycia.carbon.common.command.commands.NicknameCommand;
|
import net.draycia.carbon.common.command.commands.NicknameCommand;
|
||||||
import net.draycia.carbon.common.command.commands.PartyCommands;
|
import net.draycia.carbon.common.command.commands.PartyCommands;
|
||||||
|
import net.draycia.carbon.common.command.commands.RealNameCommand;
|
||||||
import net.draycia.carbon.common.command.commands.ReloadCommand;
|
import net.draycia.carbon.common.command.commands.ReloadCommand;
|
||||||
import net.draycia.carbon.common.command.commands.ReplyCommand;
|
import net.draycia.carbon.common.command.commands.ReplyCommand;
|
||||||
import net.draycia.carbon.common.command.commands.SpyCommand;
|
import net.draycia.carbon.common.command.commands.SpyCommand;
|
||||||
@@ -269,6 +270,7 @@ public final class CarbonCommonModule extends AbstractModule {
|
|||||||
commands.addBinding().to(MuteInfoCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(MuteInfoCommand.class).in(Scopes.SINGLETON);
|
||||||
commands.addBinding().to(NicknameCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(NicknameCommand.class).in(Scopes.SINGLETON);
|
||||||
commands.addBinding().to(ReloadCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(ReloadCommand.class).in(Scopes.SINGLETON);
|
||||||
|
commands.addBinding().to(RealNameCommand.class).in(Scopes.SINGLETON);
|
||||||
commands.addBinding().to(ReplyCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(ReplyCommand.class).in(Scopes.SINGLETON);
|
||||||
commands.addBinding().to(SpyCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(SpyCommand.class).in(Scopes.SINGLETON);
|
||||||
commands.addBinding().to(ToggleMessagesCommand.class).in(Scopes.SINGLETON);
|
commands.addBinding().to(ToggleMessagesCommand.class).in(Scopes.SINGLETON);
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* CarbonChat
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 Josua Parks (Vicarious)
|
||||||
|
* Contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package net.draycia.carbon.common.command.commands;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import java.util.Locale;
|
||||||
|
import net.draycia.carbon.api.CarbonServer;
|
||||||
|
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||||
|
import net.draycia.carbon.common.command.CarbonCommand;
|
||||||
|
import net.draycia.carbon.common.command.CommandSettings;
|
||||||
|
import net.draycia.carbon.common.command.Commander;
|
||||||
|
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
import org.incendo.cloud.CommandManager;
|
||||||
|
import org.incendo.cloud.parser.standard.StringParser;
|
||||||
|
|
||||||
|
import static org.incendo.cloud.minecraft.extras.RichDescription.richDescription;
|
||||||
|
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public final class RealNameCommand extends CarbonCommand {
|
||||||
|
|
||||||
|
private final CommandManager<Commander> commandManager;
|
||||||
|
private final CarbonMessages carbonMessages;
|
||||||
|
private final CarbonServer server;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public RealNameCommand(
|
||||||
|
final CommandManager<Commander> commandManager,
|
||||||
|
final CarbonMessages carbonMessages,
|
||||||
|
final CarbonServer server
|
||||||
|
) {
|
||||||
|
this.commandManager = commandManager;
|
||||||
|
this.carbonMessages = carbonMessages;
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandSettings defaultCommandSettings() {
|
||||||
|
return new CommandSettings("realname", "rn");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Key key() {
|
||||||
|
return Key.key("carbon", "realname");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||||
|
.required("player", StringParser.greedyStringParser(),
|
||||||
|
richDescription(this.carbonMessages.commandRealNameArgumentPlayer()))
|
||||||
|
.permission("carbon.realname")
|
||||||
|
.senderType(Commander.class)
|
||||||
|
.commandDescription(richDescription(this.carbonMessages.commandRealNameDescription()))
|
||||||
|
.handler(handler -> {
|
||||||
|
final String input = handler.<String>get("player").split(" ")[0].toLowerCase(Locale.ENGLISH);
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
for (final CarbonPlayer player : this.server.players()) {
|
||||||
|
if (player.vanished() && !handler.sender().hasPermission("carbon.realname.vanished")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String plainName = PlainTextComponentSerializer.plainText().serialize(player.displayName()).toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
|
if (plainName.contains(input)) {
|
||||||
|
found = true;
|
||||||
|
this.carbonMessages.realName(handler.sender(), player.displayName(), player.username());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
this.carbonMessages.realNameTargetInvalid(handler.sender(), input);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.commandManager.command(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -266,6 +266,12 @@ public interface CarbonMessages {
|
|||||||
@Message("nickname.reset.others")
|
@Message("nickname.reset.others")
|
||||||
void nicknameResetOthers(final Audience audience, final String target);
|
void nicknameResetOthers(final Audience audience, final String target);
|
||||||
|
|
||||||
|
@Message("nickname.realname")
|
||||||
|
void realName(final Audience audience, final Component target, final String username);
|
||||||
|
|
||||||
|
@Message("nickname.realname.target_invalid")
|
||||||
|
void realNameTargetInvalid(final Audience audience, final String input);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =============================================================
|
* =============================================================
|
||||||
* ========================== Ignore ===========================
|
* ========================== Ignore ===========================
|
||||||
@@ -501,6 +507,12 @@ public interface CarbonMessages {
|
|||||||
@Message("command.whisper.description")
|
@Message("command.whisper.description")
|
||||||
Component commandWhisperDescription();
|
Component commandWhisperDescription();
|
||||||
|
|
||||||
|
@Message("command.realname.description")
|
||||||
|
Component commandRealNameDescription();
|
||||||
|
|
||||||
|
@Message("command.realname.argument.player")
|
||||||
|
Component commandRealNameArgumentPlayer();
|
||||||
|
|
||||||
@Message("command.updateusername.description")
|
@Message("command.updateusername.description")
|
||||||
Component commandUpdateUsernameDescription();
|
Component commandUpdateUsernameDescription();
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ command.party.accept.description=Accept party invites.
|
|||||||
command.party.leave.description=Leave your current party.
|
command.party.leave.description=Leave your current party.
|
||||||
command.party.already_in_party=<display_name><red> is already in your party.
|
command.party.already_in_party=<display_name><red> is already in your party.
|
||||||
command.party.disband.description=Disband your current party.
|
command.party.disband.description=Disband your current party.
|
||||||
|
command.realname.description=Shows the player's real name.
|
||||||
|
command.realname.argument.player=The player's display name.
|
||||||
command.spy.enabled=<green>Spying is now enabled.
|
command.spy.enabled=<green>Spying is now enabled.
|
||||||
command.spy.disabled=<red>Spying is now disabled.
|
command.spy.disabled=<red>Spying is now disabled.
|
||||||
command.spy.description=Allows a player to view all private and channel messages they otherwise wouldn't see.
|
command.spy.description=Allows a player to view all private and channel messages they otherwise wouldn't see.
|
||||||
@@ -141,6 +143,7 @@ nickname.show=<green>Your nickname is </green><nickname>
|
|||||||
nickname.error.character_limit=<red>Nickname "<nickname>" has exceeded the character limit. Must be set to <min_length>~<max_length> characters.
|
nickname.error.character_limit=<red>Nickname "<nickname>" has exceeded the character limit. Must be set to <min_length>~<max_length> characters.
|
||||||
nickname.error.blacklist=<red>Nickname "<nickname>" is not allowed. Please choose another name.
|
nickname.error.blacklist=<red>Nickname "<nickname>" is not allowed. Please choose another name.
|
||||||
nickname.error.filter=<red>Nicknames must be alphanumeric!
|
nickname.error.filter=<red>Nicknames must be alphanumeric!
|
||||||
|
nickname.realname=<target>'s real name is <username>
|
||||||
reply.target.missing=<red>You have no-one to reply to
|
reply.target.missing=<red>You have no-one to reply to
|
||||||
reply.target.self=<red>You cannot whisper to yourself
|
reply.target.self=<red>You cannot whisper to yourself
|
||||||
whisper.console=<gold>[<green><sender_display_name></green>] -> [<green><recipient_display_name></green>] <message>
|
whisper.console=<gold>[<green><sender_display_name></green>] -> [<green><recipient_display_name></green>] <message>
|
||||||
|
|||||||
Reference in new issue
Block a user