148 lines
8.5 KiB
Diff
148 lines
8.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Wed, 25 Dec 2024 15:08:03 +0900
|
|
Subject: [PATCH] Add option to set player can bypass limit
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/commands/OpCommand.java b/src/main/java/net/minecraft/server/commands/OpCommand.java
|
|
index e7b444a10b244828827b3c66c53465206ea8e0ec..02b037ab5ef746598903be17e93f7f49c095b434 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/OpCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/OpCommand.java
|
|
@@ -2,6 +2,8 @@ package net.minecraft.server.commands;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
import com.mojang.brigadier.CommandDispatcher;
|
|
+import com.mojang.brigadier.arguments.BoolArgumentType;
|
|
+import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
|
import java.util.Collection;
|
|
@@ -34,20 +36,41 @@ public class OpCommand {
|
|
}
|
|
)
|
|
.executes(context -> opPlayers(context.getSource(), GameProfileArgument.getGameProfiles(context, "targets")))
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ .then(
|
|
+ Commands.argument("permissionLevel", IntegerArgumentType.integer(0, 4))
|
|
+ .executes(context ->
|
|
+ opPlayers(context.getSource(), GameProfileArgument.getGameProfiles(context, "targets"), IntegerArgumentType.getInteger(context, "permissionLevel"), false)
|
|
+ )
|
|
+ .then(
|
|
+ Commands.argument("bypassPlayerLimit", BoolArgumentType.bool())
|
|
+ .executes(context ->
|
|
+ opPlayers(context.getSource(), GameProfileArgument.getGameProfiles(context, "targets"), IntegerArgumentType.getInteger(context, "permissionLevel"), BoolArgumentType.getBool(context, "bypassPlayerLimit"))
|
|
+ )
|
|
+ )
|
|
+ )
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
)
|
|
);
|
|
}
|
|
-
|
|
private static int opPlayers(CommandSourceStack source, Collection<GameProfile> targets) throws CommandSyntaxException {
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ return opPlayers(source, targets, source.getServer().getOperatorUserPermissionLevel(), false);
|
|
+ }
|
|
+
|
|
+ private static int opPlayers(final CommandSourceStack source, final Collection<GameProfile> targets, final int permissionLevel, final boolean bypassPlayerLimit) throws CommandSyntaxException {
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
PlayerList playerList = source.getServer().getPlayerList();
|
|
int i = 0;
|
|
|
|
for (GameProfile gameProfile : targets) {
|
|
- if (!playerList.isOp(gameProfile)) {
|
|
- playerList.op(gameProfile);
|
|
- i++;
|
|
- source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfile.getName()), true); // Paper - fixes MC-253721
|
|
- }
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ if (playerList.isOp(gameProfile) && playerList.canBypassPlayerLimit(gameProfile) == bypassPlayerLimit && playerList.getPermissionLevel(gameProfile) == permissionLevel) continue;
|
|
+
|
|
+ playerList.op(gameProfile, permissionLevel, bypassPlayerLimit);
|
|
+ source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfile.getName()), true); // Paper - fixes MC-253721
|
|
+ i++;
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
}
|
|
|
|
if (i == 0) {
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
|
|
index 20c531f11b310dab0a867e589c769393ed835df5..7d9358f3e287d1f05d799b1c8f59509e6ede8581 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
|
|
@@ -122,4 +122,11 @@ public class DedicatedPlayerList extends PlayerList {
|
|
public boolean canBypassPlayerLimit(GameProfile profile) {
|
|
return this.getOps().canBypassPlayerLimit(profile);
|
|
}
|
|
+
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ @Override
|
|
+ public int getPermissionLevel(GameProfile profile) {
|
|
+ return this.getOps().getLevel(profile);
|
|
+ }
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 3fdac9a6b2cbc9c9b460d83e53c309323d30a213..d7dbdd4c65c398b628bcb81a14b1fe0d3738024d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1933,6 +1933,8 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
|
|
|
@Override
|
|
protected void checkFallDamage(double heightDifference, boolean onGround, BlockState state, BlockPos landedPosition) {
|
|
+ LOGGER.info("Fall distance: {}, height difference: {}", this.fallDistance, heightDifference);
|
|
+
|
|
if (this.spawnExtraParticlesOnFall && onGround && this.fallDistance > 0.0F) {
|
|
Vec3 vec3d = landedPosition.getCenter().add(0.0D, 0.5D, 0.0D);
|
|
int i = (int) Mth.clamp(50.0F * this.fallDistance, 0.0F, 200.0F);
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index dee8346f0c9507576142e0f74e303b29b60af0c0..80c8a0963617c241d3643e702b2c623c64acf7ab 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -1085,8 +1085,14 @@ public abstract class PlayerList {
|
|
return this.ipBans;
|
|
}
|
|
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
public void op(GameProfile profile) {
|
|
- this.ops.add(new ServerOpListEntry(profile, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(profile)));
|
|
+ this.op(profile, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(profile));
|
|
+ }
|
|
+
|
|
+ public void op(final GameProfile profile, final int permissionLevel, final boolean bypassPlayerLimit) {
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
+ this.ops.add(new ServerOpListEntry(profile, permissionLevel, bypassPlayerLimit));
|
|
ServerPlayer entityplayer = this.getPlayer(profile.getId());
|
|
|
|
if (entityplayer != null) {
|
|
@@ -1530,6 +1536,12 @@ public abstract class PlayerList {
|
|
return false;
|
|
}
|
|
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ public int getPermissionLevel(GameProfile profile) {
|
|
+ return 0;
|
|
+ }
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
+
|
|
public void reloadResources() {
|
|
// Paper start - API for updating recipes on clients
|
|
this.reloadAdvancementData();
|
|
diff --git a/src/main/java/net/minecraft/server/players/ServerOpList.java b/src/main/java/net/minecraft/server/players/ServerOpList.java
|
|
index a1c9686043b5a8c5cb1614b46e10484000c920ae..c2f597375003065434f1559959783a5b7de838f1 100644
|
|
--- a/src/main/java/net/minecraft/server/players/ServerOpList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/ServerOpList.java
|
|
@@ -20,6 +20,13 @@ public class ServerOpList extends StoredUserList<GameProfile, ServerOpListEntry>
|
|
return this.getEntries().stream().map(StoredUserEntry::getUser).filter(Objects::nonNull).map(GameProfile::getName).toArray(String[]::new);
|
|
}
|
|
|
|
+ // Plazma start - Add an option to set player can bypass limit
|
|
+ public int getLevel(GameProfile profile) {
|
|
+ ServerOpListEntry serverOpListEntry = this.get(profile);
|
|
+ return serverOpListEntry != null ? serverOpListEntry.getLevel() : 0;
|
|
+ }
|
|
+ // Plazma end - Add an option to set player can bypass limit
|
|
+
|
|
public boolean canBypassPlayerLimit(GameProfile profile) {
|
|
ServerOpListEntry serverOpListEntry = this.get(profile);
|
|
return serverOpListEntry != null && serverOpListEntry.getBypassesPlayerLimit();
|