Skip to content

Commit fb92b51

Browse files
committed
Resolved conflicts
2 parents 8a8f98b + 96e170f commit fb92b51

File tree

8 files changed

+43
-19
lines changed

8 files changed

+43
-19
lines changed

api/src/main/java/at/helpch/chatchat/api/Channel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ public interface Channel {
1919

2020
Set<User> targets(@NotNull final User source);
2121

22-
boolean isUseableBy(@NotNull final ChatUser user);
22+
boolean isUsableBy(@NotNull final ChatUser user);
2323
}

plugin/src/main/java/at/helpch/chatchat/channel/AbstractChannel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ public int radius() {
5757
return radius;
5858
}
5959

60-
6160
@Override
62-
public boolean isUseableBy(@NotNull final ChatUser user) {
61+
public boolean isUsableBy(@NotNull final ChatUser user) {
62+
if (ChatChannel.defaultChannel().equals(this)) {
63+
return true;
64+
}
65+
6366
return user.hasPermission(ChannelUtils.USE_CHANNEL_PERMISSION + name());
6467
}
6568

plugin/src/main/java/at/helpch/chatchat/command/IgnoreCommand.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public IgnoreCommand(final ChatChatPlugin plugin) {
2121
@Permission(IGNORE_PERMISSION)
2222
@Default
2323
public void ignore(ChatUser sender, ChatUser target) {
24+
if (sender.uuid().equals(target.uuid())) {
25+
sender.sendMessage(plugin.configManager().messages().cantIgnoreYourself());
26+
return;
27+
}
28+
2429
if (sender.ignoredUsers().contains(target.uuid())) {
2530
sender.sendMessage(plugin.configManager().messages().alreadyIgnored()
2631
.replaceText(builder -> builder.matchLiteral("<player>").replacement(target.player().getDisplayName())));

plugin/src/main/java/at/helpch/chatchat/command/SwitchChannelCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void switchChannel(final ChatUser user, @Join @Optional @NotNull final St
4545
}
4646
}
4747

48-
if (!channel.isUseableBy(user)) {
48+
if (!channel.isUsableBy(user)) {
4949
user.sendMessage(plugin.configManager().messages().channelNoPermission());
5050
return;
5151
}

plugin/src/main/java/at/helpch/chatchat/config/holder/MessagesHolder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public final class MessagesHolder {
3535
private Component unignoredPlayer = text("Successfully un-ignored <player>.", GREEN);
3636
private Component alreadyIgnored = text("You are already ignoring <player>.", RED);
3737
private Component notIgnored = text("You are not ignoring <player>.", RED);
38+
private Component cantIgnoreYourself = text("You cannot ignore yourself!", RED);
3839
private Component cantMessageIgnoredPlayer = text("You cannot message a player who you ignore.", RED);
3940
private Component cantMessageGeneral = text("You cannot message this player.", RED);
4041

@@ -165,6 +166,10 @@ public final class MessagesHolder {
165166
return notIgnored;
166167
}
167168

169+
public @NotNull Component cantIgnoreYourself() {
170+
return cantIgnoreYourself;
171+
}
172+
168173
public @NotNull Component personalMentionsEnabled() {
169174
return personalMentionsEnabled;
170175
}

plugin/src/main/java/at/helpch/chatchat/hooks/towny/AbstractTownyChannel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ private Optional<ResidentList> residentList(@NotNull final UUID uuid) {
3434
}
3535

3636
@Override
37-
public boolean isUseableBy(@NotNull final ChatUser user) {
38-
return super.isUseableBy(user) && residentList(user.uuid()).isPresent();
37+
public boolean isUsableBy(@NotNull final ChatUser user) {
38+
return super.isUsableBy(user) && residentList(user.uuid()).isPresent();
3939
}
4040

4141
protected abstract @Nullable ResidentList residentList(@NotNull final Resident resident);

plugin/src/main/java/at/helpch/chatchat/listener/ChatListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public void onChat(final AsyncPlayerChatEvent event) {
4545
List.copyOf(plugin.configManager().channels().channels().values()),
4646
event.getMessage());
4747

48-
final var message = channelByPrefix.isEmpty() || !channelByPrefix.get().isUseableBy(user)
48+
final var message = channelByPrefix.isEmpty() || !channelByPrefix.get().isUsableBy(user)
4949
? event.getMessage()
5050
: event.getMessage().replaceFirst(Pattern.quote(channelByPrefix.get().messagePrefix()), "");
5151

52-
final var channel = channelByPrefix.isEmpty() || !channelByPrefix.get().isUseableBy(user)
52+
final var channel = channelByPrefix.isEmpty() || !channelByPrefix.get().isUsableBy(user)
5353
? user.channel()
5454
: channelByPrefix.get();
5555

plugin/src/main/java/at/helpch/chatchat/util/PapiTagUtils.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ private PapiTagUtils() {
2020
return null;
2121
}
2222

23-
final String next = argumentQueue.pop().value().toLowerCase(Locale.ROOT);
24-
if (!argumentQueue.hasNext()) {
25-
return null;
26-
}
23+
final String next = argumentQueue.pop().value();
2724

2825
final boolean inserting;
2926
final boolean append;
30-
switch (next) {
27+
switch (next.toLowerCase(Locale.ROOT)) {
3128
case "closing":
3229
inserting = false;
3330
append = false;
@@ -57,6 +54,10 @@ private PapiTagUtils() {
5754
}
5855

5956
final var parsedPlaceholder = PlaceholderAPI.setPlaceholders(player, '%' + placeholder + '%');
57+
if (parsedPlaceholder.equals("%" + placeholder + '%')) {
58+
return null;
59+
}
60+
6061
final var kyorifiedPlaceholder = Kyorifier.kyorify(parsedPlaceholder);
6162
final var componentPlaceholder = MessageUtils.parseToMiniMessage(kyorifiedPlaceholder);
6263

@@ -73,24 +74,30 @@ private PapiTagUtils() {
7374
return null;
7475
}
7576

76-
final String next = argumentQueue.pop().value().toLowerCase(Locale.ROOT);
77-
if (!argumentQueue.hasNext()) {
78-
return null;
79-
}
77+
final String next = argumentQueue.pop().value();
8078

8179
final boolean inserting;
82-
switch (next) {
80+
final boolean append;
81+
switch (next.toLowerCase(Locale.ROOT)) {
8382
case "closing":
8483
inserting = false;
84+
append = false;
8585
break;
8686
case "inserting":
8787
inserting = true;
88+
append = false;
8889
break;
8990
default:
90-
return null;
91+
inserting = false;
92+
append = true;
93+
break;
9194
}
9295

9396
final var arguments = new ArrayList<String>();
97+
if (append) {
98+
arguments.add(next);
99+
}
100+
94101
while (argumentQueue.hasNext()) {
95102
arguments.add(argumentQueue.pop().value());
96103
}
@@ -106,6 +113,10 @@ private PapiTagUtils() {
106113
target,
107114
'%' + placeholder + '%'
108115
);
116+
if (parsedPlaceholder.equals("%" + placeholder + '%')) {
117+
return null;
118+
}
119+
109120
final var kyorifiedPlaceholder = Kyorifier.kyorify(parsedPlaceholder);
110121
final var componentPlaceholder = MessageUtils.parseToMiniMessage(kyorifiedPlaceholder);
111122

0 commit comments

Comments
 (0)