-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
patches/server/0060-Configurable-player-list-file-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <dev@alpha93.kr> | ||
Date: Wed, 25 Dec 2024 13:24:51 +0900 | ||
Subject: [PATCH] Configurable player list file path | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java | ||
index 1f2958d21c279ecb377b7c90ba643ea83e217eca..6a411f609c48b28115b947494062f9f7bf5b2d93 100644 | ||
--- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java | ||
+++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java | ||
@@ -82,7 +82,7 @@ public class OldUsersConverter { | ||
} | ||
|
||
public static boolean convertUserBanlist(final MinecraftServer server) { | ||
- final UserBanList gameprofilebanlist = new UserBanList(PlayerList.USERBANLIST_FILE); | ||
+ final UserBanList gameprofilebanlist = new UserBanList((File) server.options.valueOf("banned-players")); // Plazma - Configurable player list file path | ||
|
||
if (OldUsersConverter.OLD_USERBANLIST.exists() && OldUsersConverter.OLD_USERBANLIST.isFile()) { | ||
if (gameprofilebanlist.getFile().exists()) { | ||
@@ -140,7 +140,7 @@ public class OldUsersConverter { | ||
} | ||
|
||
public static boolean convertIpBanlist(MinecraftServer server) { | ||
- IpBanList ipbanlist = new IpBanList(PlayerList.IPBANLIST_FILE); | ||
+ IpBanList ipbanlist = new IpBanList((File) server.options.valueOf("banned-ips")); // Plazma - Configurable player list file path | ||
|
||
if (OldUsersConverter.OLD_IPBANLIST.exists() && OldUsersConverter.OLD_IPBANLIST.isFile()) { | ||
if (ipbanlist.getFile().exists()) { | ||
@@ -181,7 +181,7 @@ public class OldUsersConverter { | ||
} | ||
|
||
public static boolean convertOpsList(final MinecraftServer server) { | ||
- final ServerOpList oplist = new ServerOpList(PlayerList.OPLIST_FILE); | ||
+ final ServerOpList oplist = new ServerOpList((File) server.options.valueOf("ops")); // Plazma - Configurable player list file path | ||
|
||
if (OldUsersConverter.OLD_OPLIST.exists() && OldUsersConverter.OLD_OPLIST.isFile()) { | ||
if (oplist.getFile().exists()) { | ||
@@ -225,7 +225,7 @@ public class OldUsersConverter { | ||
} | ||
|
||
public static boolean convertWhiteList(final MinecraftServer server) { | ||
- final UserWhiteList whitelist = new UserWhiteList(PlayerList.WHITELIST_FILE); | ||
+ final UserWhiteList whitelist = new UserWhiteList((File) server.options.valueOf("whitelist")); // Plazma - Configurable player list file path | ||
|
||
if (OldUsersConverter.OLD_WHITELIST.exists() && OldUsersConverter.OLD_WHITELIST.isFile()) { | ||
if (whitelist.getFile().exists()) { | ||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java | ||
index 70bb8a45217b51d3a156aabce32efbca1ae7fcc9..dee8346f0c9507576142e0f74e303b29b60af0c0 100644 | ||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java | ||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java | ||
@@ -126,10 +126,12 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent; | ||
|
||
public abstract class PlayerList { | ||
|
||
+ /* // Plazma - Configurable player list file path | ||
public static final File USERBANLIST_FILE = new File("banned-players.json"); | ||
public static final File IPBANLIST_FILE = new File("banned-ips.json"); | ||
public static final File OPLIST_FILE = new File("ops.json"); | ||
public static final File WHITELIST_FILE = new File("whitelist.json"); | ||
+ */ // Plazma - Configurable player list file path | ||
public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full"); | ||
public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login"); | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
@@ -167,14 +169,12 @@ public abstract class PlayerList { | ||
server.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper | ||
// CraftBukkit end | ||
|
||
- this.bans = new UserBanList(PlayerList.USERBANLIST_FILE); | ||
- this.ipBans = new IpBanList(PlayerList.IPBANLIST_FILE); | ||
- this.ops = new ServerOpList(PlayerList.OPLIST_FILE); | ||
- this.whitelist = new UserWhiteList(PlayerList.WHITELIST_FILE); | ||
- // CraftBukkit start | ||
- // this.stats = Maps.newHashMap(); | ||
- // this.advancements = Maps.newHashMap(); | ||
- // CraftBukkit end | ||
+ // Plazma start - Configurable player list file path | ||
+ this.bans = new UserBanList((File) server.options.valueOf("banned-players")); | ||
+ this.ipBans = new IpBanList((File) server.options.valueOf("banned-ips")); | ||
+ this.ops = new ServerOpList((File) server.options.valueOf("ops")); | ||
+ this.whitelist = new UserWhiteList((File) server.options.valueOf("whitelist")); | ||
+ // Plazma end - Configurable player list file path | ||
this.server = server; | ||
this.registries = registryManager; | ||
this.maxPlayers = maxPlayers; | ||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java | ||
index ba002bf801ec34f88671031fe916e0dddf86a437..61bd19718a5bf5f574b62013298217f0a88685a8 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java | ||
@@ -205,6 +205,32 @@ public class Main { | ||
.defaultsTo(new File(org.plazmamc.plazma.configurations.PlazmaConfigurations.CONFIG_DIR)) | ||
.describedAs("Configuration Directory"); | ||
// Plazma end - Configurable Plazma | ||
+ | ||
+ // Plazma start - Configurable player data storage | ||
+ acceptsAll(asList("banned-ips"), "File for banned IPs") | ||
+ .withRequiredArg() | ||
+ .ofType(File.class) | ||
+ .defaultsTo(new File("banned-ips.json")) | ||
+ .describedAs("JSON file"); | ||
+ | ||
+ acceptsAll(asList("banned-players"), "File for banned players") | ||
+ .withRequiredArg() | ||
+ .ofType(File.class) | ||
+ .defaultsTo(new File("banned-players.json")) | ||
+ .describedAs("JSON file"); | ||
+ | ||
+ acceptsAll(asList("ops"), "File for ops") | ||
+ .withRequiredArg() | ||
+ .ofType(File.class) | ||
+ .defaultsTo(new File("ops.json")) | ||
+ .describedAs("JSON file"); | ||
+ | ||
+ acceptsAll(asList("whitelist"), "File for whitelist") | ||
+ .withRequiredArg() | ||
+ .ofType(File.class) | ||
+ .defaultsTo(new File("whitelist.json")) | ||
+ .describedAs("JSON file"); | ||
+ // Plazma end - Configurable player data storage | ||
} | ||
}; | ||
|
147 changes: 147 additions & 0 deletions
147
patches/server/0061-Add-option-to-set-player-can-bypass-limit.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
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(); |