Skip to content

Commit 4b24c5c

Browse files
committed
fix: Improved MC 1.19.1+ signed players ignoring
1 parent 9054611 commit 4b24c5c

File tree

6 files changed

+35
-12
lines changed

6 files changed

+35
-12
lines changed

src/main/java/me/dreamerzero/chatregulator/listener/chat/ChatListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void onChat(final PlayerChatEvent event, final Continuation continuation)
4444
final InfractionPlayer infractor = InfractionPlayer.get(player);
4545
final EventWrapper<PlayerChatEvent> wrapper = new ChatWrapper(event, continuation);
4646

47-
if(unicode(infractor, message, wrapper, plugin)
47+
if (unicode(infractor, message, wrapper, plugin)
4848
|| caps(infractor, message, wrapper, plugin)
4949
|| flood(infractor, message, wrapper, plugin)
5050
|| regular(infractor, message, wrapper, plugin)

src/main/java/me/dreamerzero/chatregulator/listener/command/CommandListener.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ && checkAndCall(
9696
),
9797
plugin
9898
)
99-
){
99+
) {
100+
if (!event.canBeModified()) {
101+
return false;
102+
}
100103
event.cancel();
101104
event.resume();
102105
return true;
@@ -120,6 +123,9 @@ && checkAndCall(
120123
plugin
121124
)
122125
) {
126+
if (!event.canBeModified()) {
127+
return false;
128+
}
123129
event.cancel();
124130
event.resume();
125131
return true;

src/main/java/me/dreamerzero/chatregulator/utils/GeneralUtils.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ public static boolean unicode(InfractionPlayer player, AtomicReference<String> s
111111
plugin.getLogger().error("An Error ocurred on Unicode Check", e);
112112
return new Result("", false);
113113
}).thenApplyAsync(result -> {
114-
if(GeneralUtils.checkAndCall(new EventBundle(player, string.get(), InfractionType.UNICODE, result, event.source()), plugin)){
114+
if (GeneralUtils.checkAndCall(new EventBundle(player, string.get(), InfractionType.UNICODE, result, event.source()), plugin)){
115+
if (!event.canBeModified()) {
116+
return false;
117+
}
115118
if(plugin.getConfig().getUnicodeConfig().isBlockable()){
116119
event.cancel();
117120
event.resume();
118121
return true;
119122
}
120-
if(event.shouldReplace() && result instanceof final ReplaceableResult replaceable){
123+
if(result instanceof final ReplaceableResult replaceable){
121124
string.set(replaceable.replaceInfraction());
122125
event.setString(string.get());
123126
}
@@ -133,12 +136,15 @@ public static boolean caps(InfractionPlayer player, AtomicReference<String> stri
133136
return new Result("", false);
134137
}).thenApplyAsync(result -> {
135138
if(GeneralUtils.checkAndCall(new EventBundle(player, string.get(), InfractionType.CAPS, result, event.source()), plugin)){
139+
if (!event.canBeModified()) {
140+
return false;
141+
}
136142
if(plugin.getConfig().getCapsConfig().isBlockable()){
137143
event.cancel();
138144
event.resume();
139145
return true;
140146
}
141-
if(event.shouldReplace() && result instanceof final IReplaceable replaceable){
147+
if(result instanceof final IReplaceable replaceable){
142148
string.set(replaceable.replaceInfraction());
143149
event.setString(string.get());
144150
}
@@ -154,12 +160,15 @@ public static boolean flood(InfractionPlayer player, AtomicReference<String> str
154160
return new Result("", false);
155161
}).thenApplyAsync(result -> {
156162
if(GeneralUtils.checkAndCall(new EventBundle(player, string.get(), InfractionType.FLOOD, result, event.source()), plugin)) {
163+
if (!event.canBeModified()) {
164+
return false;
165+
}
157166
if(plugin.getConfig().getFloodConfig().isBlockable()){
158167
event.cancel();
159168
event.resume();
160169
return true;
161170
}
162-
if(event.shouldReplace() && result instanceof final IReplaceable replaceable){
171+
if(result instanceof final IReplaceable replaceable){
163172
string.set(replaceable.replaceInfraction());
164173
event.setString(string.get());
165174
}
@@ -175,12 +184,15 @@ public static boolean regular(InfractionPlayer player, AtomicReference<String> s
175184
return new Result("", false);
176185
}).thenApplyAsync(result -> {
177186
if(GeneralUtils.checkAndCall(new EventBundle(player, string.get(), InfractionType.REGULAR, result, event.source()), plugin)) {
187+
if (!event.canBeModified()) {
188+
return false;
189+
}
178190
if(plugin.getConfig().getInfractionsConfig().isBlockable()){
179191
event.cancel();
180192
event.resume();
181193
return true;
182194
}
183-
if(event.shouldReplace() && result instanceof final IReplaceable replaceable){
195+
if(result instanceof final IReplaceable replaceable){
184196
string.set(replaceable.replaceInfraction());
185197
event.setString(string.get());
186198
}
@@ -198,6 +210,9 @@ public static boolean spam(InfractionPlayer player, AtomicReference<String> stri
198210
if (GeneralUtils.cooldownSpamCheck(result, player, plugin.getConfig())
199211
&& GeneralUtils.callViolationEvent(new EventBundle(player, string.get(), InfractionType.SPAM, result, event.source()), plugin)
200212
) {
213+
if (!event.canBeModified()) {
214+
return false;
215+
}
201216
event.cancel();
202217
event.resume();
203218
return true;

src/main/java/me/dreamerzero/chatregulator/wrapper/event/ChatWrapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.velocitypowered.api.event.Continuation;
44
import com.velocitypowered.api.event.player.PlayerChatEvent;
55
import com.velocitypowered.api.event.player.PlayerChatEvent.ChatResult;
6+
import com.velocitypowered.api.network.ProtocolVersion;
67
import com.velocitypowered.api.proxy.Player;
78

89
import me.dreamerzero.chatregulator.enums.SourceType;
@@ -29,9 +30,9 @@ public SourceType source() {
2930
}
3031

3132
@Override
32-
public boolean shouldReplace() {
33+
public boolean canBeModified() {
3334
Player player = event.getPlayer();
3435
return player.getIdentifiedKey() == null
35-
|| player.getProtocolVersion().getProtocol() < 760;
36+
|| player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) < 0;
3637
}
3738
}

src/main/java/me/dreamerzero/chatregulator/wrapper/event/CommandWrapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.velocitypowered.api.event.Continuation;
44
import com.velocitypowered.api.event.command.CommandExecuteEvent;
55
import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
6+
import com.velocitypowered.api.network.ProtocolVersion;
67
import com.velocitypowered.api.proxy.Player;
78

89
import me.dreamerzero.chatregulator.enums.SourceType;
@@ -29,10 +30,10 @@ public SourceType source() {
2930
}
3031

3132
@Override
32-
public boolean shouldReplace() {
33+
public boolean canBeModified() {
3334
if(event.getCommandSource() instanceof Player player) {
3435
return player.getIdentifiedKey() == null
35-
|| player.getProtocolVersion().getProtocol() < 760;
36+
|| player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) < 0;
3637
}
3738
return true;
3839
}

src/main/java/me/dreamerzero/chatregulator/wrapper/event/EventWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ public void resume() {
2828

2929
// Fixes chat messages not replaceable on Minecraft 1.19.1, muchas gracias Mojang
3030
// https://github.com/PaperMC/Velocity/pull/772/commits/eb32a765206383a828445ba11789c9a88ca2b585#diff-841534de988d03173f1983984bc82b9fe24e2bd3296db704a3bd6412b32674ea
31-
public abstract boolean shouldReplace();
31+
public abstract boolean canBeModified();
3232
}

0 commit comments

Comments
 (0)