Skip to content

Commit

Permalink
Improved threat assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Sep 8, 2024
1 parent f36b852 commit 7b5d009
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3319,7 +3319,9 @@ public void onCompletion(Server server) {
}
break;
case ProtocolInfo.COMMAND_REQUEST_PACKET:
VIOLATION_LISTENER.onCommandRequest(this);
CommandRequestPacket commandRequestPacket = (CommandRequestPacket) packet;

VIOLATION_LISTENER.onCommandRequest(this, commandRequestPacket.command.length());

if (!this.spawned || !this.isAlive()) {
break;
Expand All @@ -3332,7 +3334,6 @@ public void onCompletion(Server server) {
break;
}

CommandRequestPacket commandRequestPacket = (CommandRequestPacket) packet;
if (commandRequestPacket.command.length() > 512) {
break;
}
Expand Down Expand Up @@ -4012,12 +4013,12 @@ public boolean chat(String message) {
this.craftingType = CRAFTING_SMALL;

if (this.messageCounter <= 0) {
VIOLATION_LISTENER.onChatTooFast(this);
VIOLATION_LISTENER.onChatTooFast(this, message.length());
return false;
}

if (message.length() > this.messageCounter * 512 + 1) {
VIOLATION_LISTENER.onChatTooLong(this);
VIOLATION_LISTENER.onChatTooLong(this, message.length());
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/food/Food.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class Food {
.addEffect(Effect.getEffect(Effect.ABSORPTION).setDuration(2 * 60 * 20))
.addRelative(Item.GOLDEN_APPLE));
public static final Food apple_golden_enchanted = registerDefaultFood(new FoodEffective(4, 9.6F)
.addEffect(Effect.getEffect(Effect.REGENERATION).setAmplifier(4).setDuration(30 * 20))
.addEffect(Effect.getEffect(Effect.REGENERATION).setAmplifier(1).setDuration(30 * 20))
.addEffect(Effect.getEffect(Effect.ABSORPTION).setDuration(2 * 60 * 20).setAmplifier(3))
.addEffect(Effect.getEffect(Effect.RESISTANCE).setDuration(5 * 60 * 20))
.addEffect(Effect.getEffect(Effect.FIRE_RESISTANCE).setDuration(5 * 60 * 20))
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/utils/PlayerViolationListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public interface PlayerViolationListener {
PlayerViolationListener NOPE = new PlayerViolationListener() {
};

default void onCommandRequest(Player player) {
default void onCommandRequest(Player player, int length) {
}

default void onChatTooFast(Player player) {
default void onChatTooFast(Player player, int length) {
}

default void onChatTooLong(Player player) {
default void onChatTooLong(Player player, int length) {
}
}

0 comments on commit 7b5d009

Please sign in to comment.