Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #7 from RappyLabyAddons/chore/verification
Browse files Browse the repository at this point in the history
Make addon suitable for being verified
  • Loading branch information
RappyTV authored Apr 4, 2024
2 parents bc2ace0 + 621a0c1 commit 5a7d793
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 117 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ labyMod {
author = "RappyTV"
description = "Interact with the LabyConnect chat by your minecraft chat."
minecraftVersion = "*"
version = System.getenv().getOrDefault("VERSION", "1.0.1")
version = System.getenv().getOrDefault("VERSION", "1.0.2")
}

minecraft {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.rappytv.labychatutils.LabyChatUtilsAddon;
import com.rappytv.labychatutils.command.subcommands.AcceptSubCommand;
import com.rappytv.labychatutils.command.subcommands.ClearSubCommand;
import com.rappytv.labychatutils.command.subcommands.DeclineSubCommand;
import com.rappytv.labychatutils.command.subcommands.ReadSubCommand;
import com.rappytv.labychatutils.command.subcommands.ReplySubCommand;
Expand All @@ -11,15 +10,15 @@
import net.labymod.api.client.chat.command.SubCommand;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;

public class LabyChatUtilsCommand extends Command {

public LabyChatUtilsCommand() {
super("lcu");

withSubCommand(new AcceptSubCommand());
withSubCommand(new ClearSubCommand());
withSubCommand(new DeclineSubCommand());
withSubCommand(new ReplySubCommand());
withSubCommand(new ReadSubCommand());
Expand All @@ -28,16 +27,15 @@ public LabyChatUtilsCommand() {

@Override
public boolean execute(String prefix, String[] arguments) {
String subcommands = getSubCommands()
.stream()
.map(SubCommand::getPrefix)
.collect(Collectors.joining("|"));
List<String> subcommands = new ArrayList<>();
for(SubCommand subCommand : getSubCommands())
subcommands.add(subCommand.getPrefix());

displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.usage",
NamedTextColor.RED,
Component.text(
prefix + " <" + subcommands + ">"
prefix + " <" + String.join("|", subcommands) + ">"
)
)));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.labymod.api.labyconnect.LabyConnectSession;
import net.labymod.api.labyconnect.protocol.model.request.IncomingFriendRequest;
import java.util.List;
import java.util.Optional;

public class AcceptSubCommand extends SubCommand {

Expand Down Expand Up @@ -42,23 +41,19 @@ public boolean execute(String prefix, String[] arguments) {
)));
return true;
}
Optional<IncomingFriendRequest> request = requests
.stream()
.filter((req) -> req.getName().equalsIgnoreCase(arguments[0]))
.findFirst();

if(request.isEmpty()) {
for(IncomingFriendRequest request : requests) {
if(!request.getName().equalsIgnoreCase(arguments[0])) continue;
request.accept();
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.request.notFound",
NamedTextColor.RED
)));
"labychatutils.messages.request.accepted",
Component.text(request.getName(), NamedTextColor.AQUA)
).color(NamedTextColor.GREEN)));
return true;
}
request.get().accept();
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.request.accepted",
Component.text(request.get().getName(), NamedTextColor.AQUA)
).color(NamedTextColor.GREEN)));
"labychatutils.messages.request.notFound",
NamedTextColor.RED
)));
return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.rappytv.labychatutils.LabyChatUtilsAddon;
import java.util.List;
import java.util.Optional;
import net.labymod.api.Laby;
import net.labymod.api.client.chat.command.SubCommand;
import net.labymod.api.client.component.Component;
Expand Down Expand Up @@ -42,23 +41,19 @@ public boolean execute(String prefix, String[] arguments) {
)));
return true;
}
Optional<IncomingFriendRequest> request = requests
.stream()
.filter((req) -> req.getName().equalsIgnoreCase(arguments[0]))
.findFirst();

if(request.isEmpty()) {
for(IncomingFriendRequest request : requests) {
if(!request.getName().equalsIgnoreCase(arguments[0])) continue;
request.decline();
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.request.notFound",
NamedTextColor.RED
)));
"labychatutils.messages.request.declined",
Component.text(request.getName())
).color(NamedTextColor.GREEN)));
return true;
}
request.get().decline();
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.request.declined",
Component.text(request.get().getName())
).color(NamedTextColor.GREEN)));
"labychatutils.messages.request.notFound",
NamedTextColor.RED
)));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.labymod.api.labyconnect.protocol.model.chat.Chat;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class ReplySubCommand extends SubCommand {

Expand Down Expand Up @@ -44,32 +43,24 @@ public boolean execute(String prefix, String[] arguments) {
)));
return true;
}
Optional<Chat> chat = chats
.stream()
.filter((req) -> {
List<User> users = req.getParticipants();
return users
.stream()
.anyMatch((usr) ->
usr.getName().equalsIgnoreCase(arguments[0])
);
})
.findFirst();
for(Chat chat : chats) {
boolean containsUser = false;
for(User user : chat.getParticipants()) {
if(user.getName().equalsIgnoreCase(arguments[0])) containsUser = true;
}
if(!containsUser) continue;
String message = String.join(
" ",
Arrays.copyOfRange(arguments, 1, arguments.length)
);

if(chat.isEmpty()) {
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.notFound",
NamedTextColor.RED
)));
chat.sendMessage(message);
return true;
}

String message = String.join(
" ",
Arrays.copyOfRange(arguments, 1, arguments.length)
);

chat.get().sendMessage(message);
displayMessage(LabyChatUtilsAddon.prefix.copy().append(Component.translatable(
"labychatutils.messages.notFound",
NamedTextColor.RED
)));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public void onFriendRequestReceive(LabyConnectIncomingFriendRequestAddEvent even
"https://laby.net/@" + request.getName()
))
))
.append(Component.text(" "))
.append(Component.text("\n"))
.append(LabyChatUtilsAddon.prefix)
.append(Component.translatable("labychatutils.messages.request.accept")
.color(NamedTextColor.GREEN)
.decorate(TextDecoration.BOLD)
Expand Down

0 comments on commit 5a7d793

Please sign in to comment.