finished logic for reply command
This commit is contained in:
parent
f96356b620
commit
471cd8e610
@ -8,6 +8,7 @@ import eu.mhsl.craftattack.spawn.appliances.privateMessage.commands.PrivateMessa
|
||||
import eu.mhsl.craftattack.spawn.appliances.privateMessage.commands.PrivateReplyCommand;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -51,8 +52,10 @@ public class PrivateMessage extends Appliance {
|
||||
return Bukkit.getOfflinePlayer(conversation.target()).getName();
|
||||
}
|
||||
})
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(
|
||||
Component.text()
|
||||
.append(Component.text("Das Ziel für /r hat sich bei dir in den letzten "))
|
||||
@ -61,7 +64,7 @@ public class PrivateMessage extends Appliance {
|
||||
);
|
||||
|
||||
|
||||
Component newTextComponent = Component.text("");
|
||||
final Component[] finalComponent = {Component.text("")};
|
||||
|
||||
String firstTargetName;
|
||||
if(Bukkit.getPlayer(youngestEntry.target()) == null) {
|
||||
@ -70,24 +73,21 @@ public class PrivateMessage extends Appliance {
|
||||
firstTargetName = Objects.requireNonNull(Bukkit.getPlayer(youngestEntry.target())).getName();
|
||||
}
|
||||
|
||||
if(firstTargetName != null) {
|
||||
Component nameComponent = Component.text("");
|
||||
nameComponent.append(Component.text(firstTargetName, NamedTextColor.LIGHT_PURPLE));
|
||||
|
||||
newTextComponent
|
||||
.append(nameComponent.clickEvent(ClickEvent.runCommand("/msg " + firstTargetName + " " + message)));
|
||||
newTextComponent.append(Component.text(" "));
|
||||
if(firstTargetName != null && !playerNames.contains(firstTargetName)) {
|
||||
finalComponent[0] = finalComponent[0].append(Component.text(firstTargetName, NamedTextColor.GOLD)
|
||||
.clickEvent(ClickEvent.runCommand("/msg " + firstTargetName + " " + message))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Klicke, um diesem Spieler zu schreiben.").color(NamedTextColor.GOLD))))
|
||||
.append(Component.text(" "));
|
||||
}
|
||||
|
||||
playerNames.forEach(playerName -> finalComponent[0] = finalComponent[0].append(Component.text(playerName, NamedTextColor.GOLD)
|
||||
.clickEvent(ClickEvent.runCommand("/msg " + playerName + " " + message))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Klicke, um diesem Spieler zu schreiben.").color(NamedTextColor.GOLD))))
|
||||
.append(Component.text(" ")));
|
||||
|
||||
playerNames.forEach(playerName -> {
|
||||
Component nameComponent = Component.text(playerName, NamedTextColor.LIGHT_PURPLE);
|
||||
newTextComponent
|
||||
.append(nameComponent.clickEvent(ClickEvent.runCommand("/msg " + playerName + " " + message)));
|
||||
newTextComponent.append(Component.text(" "));
|
||||
});
|
||||
|
||||
sender.sendMessage(newTextComponent);
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(finalComponent[0]);
|
||||
sender.sendMessage("");
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user