use of net.minecraft.text.LiteralText in project pingspam by BasiqueEvangelist.
the class NotificationsCommand method showNotifications.
public static int showNotifications(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
ServerCommandSource src = ctx.getSource();
List<Text> notifs = PlayerUtils.getUnreadPingsFor(src.getPlayer());
if (!notifs.isEmpty()) {
MutableText response = new LiteralText("You have " + notifs.size() + " unread message" + (notifs.size() != 1 ? "s" : "") + ":").formatted(Formatting.GREEN);
for (Text notif : notifs) {
response.append(new LiteralText("\n- ").formatted(Formatting.WHITE).append(notif));
}
src.sendFeedback(response, false);
notifs.clear();
return 1;
} else {
src.sendFeedback(new LiteralText("You have no unread messages.").formatted(Formatting.GREEN), false);
return 0;
}
}
use of net.minecraft.text.LiteralText in project pingspam by BasiqueEvangelist.
the class GroupCommand method removePlayerGroup.
private static int removePlayerGroup(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
ServerCommandSource src = ctx.getSource();
String group = StringArgumentType.getString(ctx, "groupname");
ServerPlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
List<String> groups = PlayerUtils.getPingGroupsOf(player);
if (!GROUPNAME_PATTERN.asPredicate().test(group))
throw INVALID_GROUPNAME.create();
if (groups.stream().noneMatch(x -> x.equalsIgnoreCase(group)))
throw NOT_IN_GROUP_OTHER.create(player);
groups.removeIf(x -> x.equalsIgnoreCase(group));
if (!NameLogic.isValidName(src.getMinecraftServer().getPlayerManager(), group, false))
ServerNetworkLogic.removePossibleName(src.getMinecraftServer().getPlayerManager(), group);
src.sendFeedback(new LiteralText("Removed player ").formatted(Formatting.RED).append(new LiteralText(player.getEntityName()).formatted(Formatting.AQUA)).append(" from group ").append(new LiteralText(group).formatted(Formatting.YELLOW)).append(new LiteralText(".")), true);
return 0;
}
use of net.minecraft.text.LiteralText in project pingspam by BasiqueEvangelist.
the class PingIgnoreCommand method listIgnoredPlayers.
private static int listIgnoredPlayers(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
ServerCommandSource src = ctx.getSource();
ServerPlayerEntity player = src.getPlayer();
List<UUID> ignoredPlayers = PlayerUtils.getIgnoredPlayersOf(player);
if (ignoredPlayers.isEmpty()) {
src.sendFeedback(new LiteralText("You are not ignoring any players.").formatted(Formatting.GREEN), false);
return 0;
}
StringBuilder contentBuilder = new StringBuilder();
int count = 0;
for (UUID ignoredPlayerUuid : ignoredPlayers) {
contentBuilder.append("\n - ").append(OfflineNameCache.INSTANCE.getNameFromUUID(ignoredPlayerUuid));
count++;
}
src.sendFeedback(new LiteralText("You are ignoring " + count + " player(s):").formatted(Formatting.GREEN).append(new LiteralText(contentBuilder.toString()).formatted(Formatting.AQUA)), false);
return 0;
}
use of net.minecraft.text.LiteralText in project quilt-standard-libraries by QuiltMC.
the class ChannelScreen method init.
@Override
protected void init() {
this.s2cButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 55, 5, 50, 20, new LiteralText("S2C"), this::toS2C, (button, matrices, mouseX, mouseY) -> {
this.renderTooltip(matrices, new LiteralText("Packets this client can receive"), mouseX, mouseY);
}));
this.c2sButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, 5, 50, 20, new LiteralText("C2S"), this::toC2S, (button, matrices, mouseX, mouseY) -> {
this.renderTooltip(matrices, new LiteralText("Packets the server can receive"), mouseX, mouseY);
}));
this.closeButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 60, this.height - 25, 120, 20, new LiteralText("Close"), button -> this.onClose()));
this.channelList = this.addDrawable(new ChannelList(this.client, this.width, this.height - 60, 30, this.height - 30, this.textRenderer.fontHeight + 2));
}
use of net.minecraft.text.LiteralText in project quilt-standard-libraries by QuiltMC.
the class NetworkingChannelTest method registerChannel.
private static int registerChannel(CommandContext<ServerCommandSource> context, ServerPlayerEntity executor) throws CommandSyntaxException {
final Identifier channel = getIdentifier(context, "channel");
if (ServerPlayNetworking.getReceived(executor).contains(channel)) {
throw new SimpleCommandExceptionType(new LiteralText(String.format("Cannot register channel %s twice for server player", channel))).create();
}
ServerPlayNetworking.registerReceiver(executor.networkHandler, channel, (server, player, handler, buf, sender) -> {
System.out.printf("Received packet on channel %s%n", channel);
});
context.getSource().sendFeedback(new LiteralText(String.format("Registered channel %s for %s", channel, executor.getEntityName())), false);
return 1;
}
Aggregations