Command related patches
This commit is contained in:
@@ -1,291 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Fri, 3 Nov 2023 00:11:50 +0900
|
||||
Subject: [PATCH] Plazma Configurations
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/Commands.java b/src/main/java/org/plazmamc/plazma/commands/Commands.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4497d8f8a52db0fc89ce27168b54657d172b1445
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/Commands.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package org.plazmamc.plazma.commands;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.plazmamc.plazma.commands.plazma.PlazmaCommand;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class Commands {
|
||||
+
|
||||
+ private static final Map<String, Command> COMMANDS = new HashMap<>() {{
|
||||
+ put("plazma", new PlazmaCommand("plazma"));
|
||||
+ }};
|
||||
+
|
||||
+ public static void register(final MinecraftServer server) {
|
||||
+ COMMANDS.forEach((s, command) -> server.server.getCommandMap().register(s, "Plazma", command));
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/PlazmaSubCommand.java b/src/main/java/org/plazmamc/plazma/commands/PlazmaSubCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e25ba7935e2743aab5c1334c6582459556ec643a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/PlazmaSubCommand.java
|
||||
@@ -0,0 +1,19 @@
|
||||
+package org.plazmamc.plazma.commands;
|
||||
+
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public interface PlazmaSubCommand {
|
||||
+
|
||||
+ boolean execute(final CommandSender sender, final String subCommand, final String[] args);
|
||||
+
|
||||
+ default List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/plazma/PlazmaCommand.java b/src/main/java/org/plazmamc/plazma/commands/plazma/PlazmaCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1628bee2fb106ad149cad95fb5e3d1100448c697
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/plazma/PlazmaCommand.java
|
||||
@@ -0,0 +1,120 @@
|
||||
+package org.plazmamc.plazma.commands.plazma;
|
||||
+
|
||||
+import io.papermc.paper.command.CommandUtil;
|
||||
+import it.unimi.dsi.fastutil.Pair;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.minecraft.Util;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.permissions.PermissionDefault;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.plazmamc.plazma.commands.PlazmaSubCommand;
|
||||
+import org.plazmamc.plazma.commands.plazma.subcommand.ReloadCommand;
|
||||
+import org.plazmamc.plazma.commands.plazma.subcommand.VersionCommand;
|
||||
+
|
||||
+import java.util.*;
|
||||
+import java.util.stream.Collectors;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class PlazmaCommand extends Command {
|
||||
+
|
||||
+ private static final Map<String, PlazmaSubCommand> SUB_COMMANDS = Util.make(() -> {
|
||||
+ final Map<Set<String>, PlazmaSubCommand> commands = new HashMap<>() {{
|
||||
+ put(Set.of("reload"), new ReloadCommand());
|
||||
+ put(Set.of("version"), new VersionCommand());
|
||||
+ }};
|
||||
+
|
||||
+ return commands.entrySet().stream()
|
||||
+ .flatMap(entry -> entry.getKey().stream().map(key -> Map.entry(key, entry.getValue())))
|
||||
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
+ });
|
||||
+
|
||||
+ private static final Map<String, String> ALIASES = Util.make(() -> {
|
||||
+ final Map<String, Set<String>> aliases = new HashMap<>() {{
|
||||
+ put("reload", Set.of("rl"));
|
||||
+ put("version", Set.of("ver"));
|
||||
+ }};
|
||||
+
|
||||
+ return aliases.entrySet().stream()
|
||||
+ .flatMap(entry -> entry.getValue().stream().map(s -> Map.entry(s, entry.getKey())))
|
||||
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
+ });
|
||||
+
|
||||
+ public PlazmaCommand(final String name) {
|
||||
+ super(name);
|
||||
+
|
||||
+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
+
|
||||
+ final List<String> permissions = new ArrayList<>();
|
||||
+ permissions.add("bukkit.command.plazma");
|
||||
+ permissions.addAll(SUB_COMMANDS.keySet().stream().map(s -> "bukkit.command.plazma." + s).toList());
|
||||
+
|
||||
+ this.description = "Plazma related commands";
|
||||
+ this.usageMessage = String.format("/plazma [%s]", String.join("|", SUB_COMMANDS.keySet()));
|
||||
+ this.setPermission(String.join(";", permissions));
|
||||
+
|
||||
+ permissions.forEach(perm -> pluginManager.addPermission(new Permission(perm, PermissionDefault.OP)));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ if (args.length == 0) {
|
||||
+ sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final @Nullable Pair<String, PlazmaSubCommand> subCommand = resolveSubCommand(args[0]);
|
||||
+
|
||||
+ if (subCommand == null) {
|
||||
+ sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!testPermission(sender, subCommand.first())) return true;
|
||||
+
|
||||
+ final String[] choppedArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
+ return subCommand.second().execute(sender, subCommand.first(), choppedArgs);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(final CommandSender sender, final String aliases, final String[] args) throws IllegalArgumentException {
|
||||
+ if (args.length <= 1) return CommandUtil.getListMatchingLast(sender, args, SUB_COMMANDS.keySet());
|
||||
+
|
||||
+ final @Nullable Pair<String, PlazmaSubCommand> subCommand = resolveSubCommand(args[0]);
|
||||
+
|
||||
+ if (subCommand != null) return subCommand.second().tabComplete(sender, subCommand.first(), Arrays.copyOfRange(args, 1, args.length));
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ private static boolean testPermission(final CommandSender sender, final String permission) {
|
||||
+ if (sender.hasPermission("bukkit.command.plazma." + permission) || sender.hasPermission("bukkit.command.plazma")) return true;
|
||||
+ sender.sendMessage(Bukkit.permissionMessage());
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private static @Nullable Pair<String, PlazmaSubCommand> resolveSubCommand(String label) {
|
||||
+ label = label.toLowerCase(Locale.ENGLISH);
|
||||
+ @Nullable PlazmaSubCommand subCommand = SUB_COMMANDS.get(label);
|
||||
+
|
||||
+ if (subCommand == null) {
|
||||
+ final @Nullable String command = ALIASES.get(label);
|
||||
+ if (command != null) {
|
||||
+ label = command;
|
||||
+ subCommand = SUB_COMMANDS.get(label);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (subCommand != null) return Pair.of(label, subCommand);
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/ReloadCommand.java b/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/ReloadCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1c83926923f50fb4da1a83dc91614c20a831555f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/ReloadCommand.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+package org.plazmamc.plazma.commands.plazma.subcommand;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.plazmamc.plazma.commands.PlazmaSubCommand;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class ReloadCommand implements PlazmaSubCommand {
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ this.reload(sender);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void reload(final CommandSender sender) {
|
||||
+ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", NamedTextColor.RED));
|
||||
+ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", NamedTextColor.RED));
|
||||
+
|
||||
+ MinecraftServer server = ((CraftServer) sender.getServer()).getServer();
|
||||
+ server.plazmaConfigurations.reloadConfigs(server);
|
||||
+ server.server.reloadCount++;
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, text("Successfully reloaded Plazma configuration files.", NamedTextColor.GREEN));
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/VersionCommand.java b/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/VersionCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b6664ba0fce55f5cfa0c8d3051dc8c2be0fd0703
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/plazma/subcommand/VersionCommand.java
|
||||
@@ -0,0 +1,21 @@
|
||||
+package org.plazmamc.plazma.commands.plazma.subcommand;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.plazmamc.plazma.commands.PlazmaSubCommand;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class VersionCommand implements PlazmaSubCommand {
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ if (ver != null) return ver.execute(sender, "plazma", new String[0]);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java
|
||||
index 309d371247adcddf0a1b370cc5faff3e6e01cb0f..285a90ff5cdc8cb28fafd4ea3dae306ae5b899c9 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServerHelper.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServerHelper.java
|
||||
@@ -92,6 +92,7 @@ public final class DummyServerHelper {
|
||||
// Paper end - testing additions
|
||||
|
||||
io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - configuration files - setup global configuration test base
|
||||
+ org.plazmamc.plazma.configurations.GlobalConfigurationTestingBase.setupGlobalConfigForTest(); // Plazma - Configurable Plazma
|
||||
|
||||
// Paper start - add test for recipe conversion
|
||||
when(instance.recipeIterator()).thenAnswer(ignored ->
|
||||
diff --git a/src/test/java/org/plazmamc/plazma/configurations/GlobalConfigurationTestingBase.java b/src/test/java/org/plazmamc/plazma/configurations/GlobalConfigurationTestingBase.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c63942e2dc00ed6d6b4119f418bdaa5a64b4c0fe
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/org/plazmamc/plazma/configurations/GlobalConfigurationTestingBase.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package org.plazmamc.plazma.configurations;
|
||||
+
|
||||
+import org.spongepowered.configurate.ConfigurationNode;
|
||||
+import org.spongepowered.configurate.serialize.SerializationException;
|
||||
+
|
||||
+public class GlobalConfigurationTestingBase {
|
||||
+
|
||||
+ public static void setupGlobalConfigForTest() {
|
||||
+ if (GlobalConfiguration.get() == null) {
|
||||
+ ConfigurationNode node = PlazmaConfigurations.createForTesting();
|
||||
+ try {
|
||||
+ GlobalConfiguration globalConfiguration = node.require(GlobalConfiguration.class);
|
||||
+ GlobalConfiguration.set(globalConfiguration);
|
||||
+ } catch (SerializationException e) {
|
||||
+ throw new RuntimeException(e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -1,90 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 5 Nov 2023 11:27:51 +0900
|
||||
Subject: [PATCH] Add option to change nether portal size
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
index acdff7b4a00d563739fd301c3633a266875296fa..1266aaf4bfcf53aa16d7b9bd697a0c483d3218a9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
@@ -113,7 +113,7 @@ public class PortalShape {
|
||||
private static int calculateWidth(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
int i = PortalShape.getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection, blocks); // CraftBukkit
|
||||
|
||||
- return i >= 2 && i <= 21 ? i : 0;
|
||||
+ return i >= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.width.min() && i <= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.width.max() ? i : 0; // Plazma - Configurable nether portal size
|
||||
}
|
||||
|
||||
private static int getDistanceUntilEdgeAboveFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
@@ -146,7 +146,7 @@ public class PortalShape {
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
int j = PortalShape.getDistanceUntilTop(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, mutableint, blocks); // CraftBukkit
|
||||
|
||||
- return j >= 3 && j <= 21 && PortalShape.hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j, blocks) ? j : 0; // CraftBukkit
|
||||
+ return j >= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.height.min() && j <= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.height.max() && PortalShape.hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j, blocks) ? j : 0; // Craftbukkit // Plazma - Configurable nether portal size
|
||||
}
|
||||
|
||||
private static boolean hasTopFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockPos.MutableBlockPos blockposition_mutableblockposition, int i, int j, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
@@ -200,7 +200,7 @@ public class PortalShape {
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
- return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
|
||||
+ return this.width >= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.width.min() && this.width <= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.width.max() && this.height >= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.height.min() && this.height <= org.plazmamc.plazma.configurations.GlobalConfiguration.get().structure.netherPortal.height.max(); // Plazma - Configurable nether portal size
|
||||
}
|
||||
|
||||
// CraftBukkit start - return boolean, add entity
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 3a9fa2ac6dc5eaa153deb06a005be51c59786bbe..f99a281244f7b736bd979cfc0bcd0787d9da9a42 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -76,6 +76,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public Structure structure;
|
||||
public class Structure extends ConfigurationPart {
|
||||
|
||||
+ public NetherPortal netherPortal;
|
||||
+ public class NetherPortal extends ConfigurationPart {
|
||||
+
|
||||
+ public Width width;
|
||||
+ public class Width extends ConfigurationPart {
|
||||
+
|
||||
+ int min = 2; public int min() { return Math.max(this.min, 1); }
|
||||
+ int max = 21; public int max() { return Math.max(this.min, this.max); }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Height height;
|
||||
+ public class Height extends ConfigurationPart {
|
||||
+
|
||||
+ int min = 3; public int min() { return Math.max(this.min, 2); }
|
||||
+ int max = 21; public int max() { return Math.max(this.min, this.max); }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index c222d58520b655b54b8975ec226a4ba948691cd4..c703237d46b114227cf0d5cdff2e033839bc5f57 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -36,17 +36,6 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
|
||||
}
|
||||
|
||||
- public Structure structure;
|
||||
- public class Structure extends ConfigurationPart {
|
||||
-
|
||||
- public NetherPortal netherPortal;
|
||||
- public class NetherPortal extends ConfigurationPart {
|
||||
-
|
||||
-
|
||||
- }
|
||||
-
|
||||
- }
|
||||
-
|
||||
public Block block;
|
||||
public class Block extends ConfigurationPart {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Tue, 7 Nov 2023 15:32:24 +0900
|
||||
Subject: [PATCH] Configurable cave lava sea level
|
||||
|
||||
This patch also fix MC-237017.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
index 3f39d6c786d9dfdd9ad591e08ff05fcbb41a1df6..0346fd4ab7095d66c0eef5a440afbc7a8ba52466 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
@@ -71,14 +71,14 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
}
|
||||
|
||||
private static Aquifer.FluidPicker createFluidPicker(NoiseGeneratorSettings settings) {
|
||||
- Aquifer.FluidStatus aquifer_b = new Aquifer.FluidStatus(-54, Blocks.LAVA.defaultBlockState());
|
||||
- int i = settings.seaLevel();
|
||||
- Aquifer.FluidStatus aquifer_b1 = new Aquifer.FluidStatus(i, settings.defaultFluid());
|
||||
- Aquifer.FluidStatus aquifer_b2 = new Aquifer.FluidStatus(DimensionType.MIN_Y * 2, Blocks.AIR.defaultBlockState());
|
||||
-
|
||||
- return (j, k, l) -> {
|
||||
- return k < Math.min(-54, i) ? aquifer_b : aquifer_b1;
|
||||
- };
|
||||
+ // Plazma start - Configurable default lava sea level
|
||||
+ int i = org.plazmamc.plazma.configurations.GlobalConfiguration.get().worldgen.lavaSea.startLevel;
|
||||
+ int j = settings.seaLevel();
|
||||
+ Aquifer.FluidStatus aquifer1 = new Aquifer.FluidStatus(i, org.plazmamc.plazma.configurations.GlobalConfiguration.get().worldgen.lavaSea.seaBlock());
|
||||
+ Aquifer.FluidStatus aquifer2 = new Aquifer.FluidStatus(j, settings.defaultFluid());
|
||||
+
|
||||
+ return (x, y, z) -> y < Math.min(i, j) ? aquifer1 : aquifer2;
|
||||
+ // Plazma end - Configurable default lava sea level
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 6d313edc60082a5f2d30ef8ad9fbd57772f361fe..5450d2a784511122a8236d30485f6b1f798822f3 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -51,6 +51,24 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public WorldGeneration worldgen;
|
||||
public class WorldGeneration extends ConfigurationPart {
|
||||
|
||||
+ public LavaSea lavaSea;
|
||||
+ public class LavaSea extends ConfigurationPart {
|
||||
+
|
||||
+ public int startLevel = -54;
|
||||
+ String seaBlock = "default";
|
||||
+
|
||||
+ public net.minecraft.world.level.block.state.BlockState seaBlock() {
|
||||
+ if (this.seaBlock.equalsIgnoreCase("default")) return net.minecraft.world.level.block.Blocks.LAVA.defaultBlockState();
|
||||
+ return net.minecraft.core.registries.BuiltInRegistries.BLOCK
|
||||
+ .getOptional(net.minecraft.resources.ResourceLocation.tryParse(this.seaBlock))
|
||||
+ .orElseGet(() -> {
|
||||
+ PlazmaConfigurations.LOGGER.warn("Invalid custom sea level block: {}, defaulting to lava", this.seaBlock);
|
||||
+ return net.minecraft.world.level.block.Blocks.LAVA;
|
||||
+ })
|
||||
+ .defaultBlockState();
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Mon, 4 Dec 2023 23:01:32 +0900
|
||||
Subject: [PATCH] Variable entity wakeup duration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index 9e408d6c1826d36a935b3e382e8eb0283f3d1580..a371893777a2c2d1de22e7d52f2fd3f55b82d74d 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -37,6 +37,20 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
|
||||
}
|
||||
|
||||
+ public WakeUpDurationVariance wakeUpDurationVariance;
|
||||
+ public class WakeUpDurationVariance extends ConfigurationPart {
|
||||
+
|
||||
+ private double defaultValue() {
|
||||
+ return OPTIMIZE ? 0.2 : 0.0;
|
||||
+ }
|
||||
+
|
||||
+ double animal = defaultValue(); public double animal() { return Math.max(this.animal, 0.0); }
|
||||
+ double monster = defaultValue(); public double monster() { return Math.max(this.monster, 0.0); }
|
||||
+ double flying = defaultValue(); public double flying() { return Math.max(this.flying, 0.0); }
|
||||
+ double villager = defaultValue(); public double villager() { return Math.max(this.villager, 0.0); }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
public Block block;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 9b1a16747aa23b18e4cff986efaac6ce64b6ddb9..6a45bafaa1d7ddc0f80c0945e15c3d6c67f9f2b3 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -66,29 +66,37 @@ public class ActivationRange
|
||||
net.minecraft.world.entity.schedule.Activity.PANIC
|
||||
};
|
||||
|
||||
+ // Plazma start - Variable entity wakeup duration
|
||||
+ private static int getWakeUpDuration(net.minecraft.util.RandomSource random, int duration, double deviation) {
|
||||
+ if (deviation == 0) return duration;
|
||||
+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(duration * (1 + deviation * random.nextGaussian()))));
|
||||
+ }
|
||||
+ // Plazma end - Variable entity wakeup duration
|
||||
+
|
||||
private static int checkInactiveWakeup(Entity entity) {
|
||||
Level world = entity.level();
|
||||
SpigotWorldConfig config = world.spigotConfig;
|
||||
+ org.plazmamc.plazma.configurations.WorldConfigurations plazmaConfig = world.plazmaConfig(); // Plazma - Variable entity wakeup duration
|
||||
long inactiveFor = MinecraftServer.currentTick - entity.activatedTick;
|
||||
if (entity.activationType == ActivationType.VILLAGER) {
|
||||
if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) {
|
||||
world.wakeupInactiveRemainingVillagers--;
|
||||
- return config.wakeUpInactiveVillagersFor;
|
||||
+ return getWakeUpDuration(world.getRandom(), config.wakeUpInactiveVillagersFor, plazmaConfig.entity.wakeUpDurationVariance.villager()); // Plazma - Variable entity wakeup duration
|
||||
}
|
||||
} else if (entity.activationType == ActivationType.ANIMAL) {
|
||||
if (inactiveFor > config.wakeUpInactiveAnimalsEvery && world.wakeupInactiveRemainingAnimals > 0) {
|
||||
world.wakeupInactiveRemainingAnimals--;
|
||||
- return config.wakeUpInactiveAnimalsFor;
|
||||
+ return getWakeUpDuration(world.getRandom(), config.wakeUpInactiveAnimalsFor, plazmaConfig.entity.wakeUpDurationVariance.animal()); // Plazma - Variable entity wakeup duration
|
||||
}
|
||||
} else if (entity.activationType == ActivationType.FLYING_MONSTER) {
|
||||
if (inactiveFor > config.wakeUpInactiveFlyingEvery && world.wakeupInactiveRemainingFlying > 0) {
|
||||
world.wakeupInactiveRemainingFlying--;
|
||||
- return config.wakeUpInactiveFlyingFor;
|
||||
+ return getWakeUpDuration(world.getRandom(), config.wakeUpInactiveFlyingFor, plazmaConfig.entity.wakeUpDurationVariance.flying()); // Plazma - Variable entity wakeup duration
|
||||
}
|
||||
} else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) {
|
||||
if (inactiveFor > config.wakeUpInactiveMonstersEvery && world.wakeupInactiveRemainingMonsters > 0) {
|
||||
world.wakeupInactiveRemainingMonsters--;
|
||||
- return config.wakeUpInactiveMonstersFor;
|
||||
+ return getWakeUpDuration(world.getRandom(), config.wakeUpInactiveMonstersFor, plazmaConfig.entity.wakeUpDurationVariance.monster()); // Plazma - Variable entity wakeup duration
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -1,113 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Fri, 13 Dec 2024 11:14:49 +0900
|
||||
Subject: [PATCH] Add option to allow shoot fireball
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/FireChargeItem.java b/src/main/java/net/minecraft/world/item/FireChargeItem.java
|
||||
index 641eb27097740219199ce61ed3e6aa5f42a51b1c..f51be1746fc649d636bc9e3ae451d18e35a04026 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/FireChargeItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/FireChargeItem.java
|
||||
@@ -30,6 +30,58 @@ public class FireChargeItem extends Item implements ProjectileItem {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
+ // Plazma start - Option to shoot fireballs
|
||||
+ @Override
|
||||
+ public InteractionResult use(Level world, Player user, net.minecraft.world.InteractionHand hand) {
|
||||
+ if (!(world instanceof net.minecraft.server.level.ServerLevel level) || !world.plazmaConfig().item.shootableFireCharge.enabled) {
|
||||
+ super.use(world, user, hand);
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+
|
||||
+ Vec3 vec = user.getDirection().getUnitVec3().multiply(10, 10, 10);
|
||||
+ net.minecraft.world.entity.projectile.AbstractHurtingProjectile fireball = switch(world.plazmaConfig().item.shootableFireCharge.shootType) {
|
||||
+ case SMALL_FIREBALL -> new SmallFireball(world, user, vec);
|
||||
+ case LARGE_FIREBALL -> new net.minecraft.world.entity.projectile.LargeFireball(world, user, vec, world.plazmaConfig().item.shootableFireCharge.explosionPower);
|
||||
+ case DRAGON_FIREBALL -> new net.minecraft.world.entity.projectile.DragonFireball(world, user, vec);
|
||||
+ case WITHER_SKULL -> new net.minecraft.world.entity.projectile.WitherSkull(world, user, vec);
|
||||
+ };
|
||||
+
|
||||
+ ItemStack itemStack = user.getItemInHand(hand);
|
||||
+ net.minecraft.world.entity.projectile.Projectile.Delayed<net.minecraft.world.entity.projectile.AbstractHurtingProjectile> delayed;
|
||||
+ delayed = net.minecraft.world.entity.projectile.Projectile.spawnProjectileDelayed(
|
||||
+ fireball,
|
||||
+ level,
|
||||
+ itemStack,
|
||||
+ projectile -> {
|
||||
+ projectile.setPos(user.getX(), user.getEyeY() - 0.10000000149011612D, user.getZ());
|
||||
+ projectile.shootFromRotation(user, user.getXRot(), user.getYRot(), world.plazmaConfig().item.shootableFireCharge.shootRoll, world.plazmaConfig().item.shootableFireCharge.shootPower, world.plazmaConfig().item.shootableFireCharge.shootOffset);
|
||||
+ if (!(projectile instanceof net.minecraft.world.entity.projectile.Fireball ball)) return;
|
||||
+ ball.setItem(itemStack);
|
||||
+ }
|
||||
+ );
|
||||
+
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event;
|
||||
+ event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent(
|
||||
+ (org.bukkit.entity.Player) user.getBukkitEntity(),
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack),
|
||||
+ (org.bukkit.entity.Projectile) delayed.projectile().getBukkitEntity()
|
||||
+ );
|
||||
+
|
||||
+ if (event.callEvent() && delayed.attemptSpawn(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FIRE_CHARGE)) {
|
||||
+ user.awardStat(net.minecraft.stats.Stats.ITEM_USED.get(this));
|
||||
+
|
||||
+ if (event.shouldConsume()) itemStack.consume(1, user);
|
||||
+ else if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+
|
||||
+ world.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.FIRECHARGE_USE, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+
|
||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ // Plazma end - Option to shoot fireballs
|
||||
+
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
Level world = context.getLevel();
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
index ac0f038de0ce5cf6df0b730af69d3229c3119eff..ba3331a81002304187318ed32fec2dd31e4c23ee 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
@@ -7,7 +7,8 @@ import static org.spongepowered.configurate.NodePath.path;
|
||||
interface RemovedConfigurations {
|
||||
|
||||
NodePath[] WORLD_PATHS = {
|
||||
- path("structure", "nether-portal")
|
||||
+ path("structure", "nether-portal"),
|
||||
+ path("item", "allow-shoot-fireballs")
|
||||
};
|
||||
|
||||
NodePath[] GLOBAL_PATHS = {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index c1d4a96cf5be77f4460c54ed19622f527d42ca06..bbb51ccf2016987202811ee893f855da2612dd17 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -86,6 +86,25 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
public Item item;
|
||||
public class Item extends ConfigurationPart {
|
||||
|
||||
+ public ShootableFireCharge shootableFireCharge;
|
||||
+ public class ShootableFireCharge extends ConfigurationPart {
|
||||
+
|
||||
+ public boolean enabled = false;
|
||||
+ public ShootType shootType = ShootType.SMALL_FIREBALL;
|
||||
+ public int explosionPower = 1;
|
||||
+
|
||||
+ public float shootRoll = 0.0f;
|
||||
+ public float shootPower = 1.5f;
|
||||
+ public float shootOffset = 1.0f;
|
||||
+
|
||||
+ public enum ShootType {
|
||||
+ SMALL_FIREBALL,
|
||||
+ LARGE_FIREBALL,
|
||||
+ DRAGON_FIREBALL,
|
||||
+ WITHER_SKULL
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sat, 14 Dec 2024 01:03:07 +0900
|
||||
Subject: [PATCH] Add option to disable beacon effect ambient
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
index c8ac3df678bc62985972d520f84f26a44ddd6970..ee97079a57750cc5f0ee06567704575987afea47 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -368,24 +368,20 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
}
|
||||
|
||||
- private static void applyEffect(List list, @Nullable Holder<MobEffect> holder, int j, int b0, boolean isPrimary, BlockPos worldPosition) { // Paper - BeaconEffectEvent
|
||||
- if (!list.isEmpty()) { // Paper - BeaconEffectEvent
|
||||
- Iterator iterator = list.iterator();
|
||||
+ private static void applyEffect(List<Player> list, @Nullable Holder<MobEffect> holder, int j, int b0, boolean isPrimary, BlockPos worldPosition) { // Paper - BeaconEffectEvent
|
||||
+ if (list.isEmpty()) return;
|
||||
|
||||
- Player entityhuman;
|
||||
+ // Paper start - BeaconEffectEvent
|
||||
+ org.bukkit.craftbukkit.block.CraftBlock block = org.bukkit.craftbukkit.block.CraftBlock.at(list.getFirst().level(), worldPosition);
|
||||
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(holder, j, b0, true, !(block).getCraftWorld().getHandle().plazmaConfig().entity.disableBeaconEffectAmbient, true));
|
||||
+ // Paper end - BeaconEffectEvent
|
||||
+
|
||||
+ for (final Player player : list) {
|
||||
// Paper start - BeaconEffectEvent
|
||||
- org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(((Player) list.get(0)).level(), worldPosition);
|
||||
- PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(holder, j, b0, true, true));
|
||||
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (org.bukkit.entity.Player) player.getBukkitEntity(), isPrimary);
|
||||
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
|
||||
+ player.addEffect(new MobEffectInstance(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
||||
// Paper end - BeaconEffectEvent
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- // Paper start - BeaconEffectEvent
|
||||
- entityhuman = (ServerPlayer) iterator.next();
|
||||
- BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), isPrimary);
|
||||
- if (CraftEventFactory.callEvent(event).isCancelled()) continue;
|
||||
- entityhuman.addEffect(new MobEffectInstance(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
||||
- // Paper end - BeaconEffectEvent
|
||||
- }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index 36345efa302413ad4e7d6e611d182572622f76ff..e88b18ff76bf21d9fa340a1d58abedefbf30ec91 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -30,6 +30,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
|
||||
public int sensorTick = 1;
|
||||
public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE;
|
||||
+ public boolean disableBeaconEffectAmbient = false;
|
||||
|
||||
public Phantom phantom;
|
||||
public class Phantom extends ConfigurationPart {
|
||||
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sat, 14 Dec 2024 11:06:41 +0900
|
||||
Subject: [PATCH] Tick toggle subcommand
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/TickCommand.java b/src/main/java/net/minecraft/server/commands/TickCommand.java
|
||||
index 13d96b54f48d60b098b80e04ba6168762c335c75..5aab945085eb4ed2ea44832319c6daad96fe3a71 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/TickCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/TickCommand.java
|
||||
@@ -21,6 +21,10 @@ public class TickCommand {
|
||||
dispatcher.register(
|
||||
Commands.literal("tick")
|
||||
.requires(source -> source.hasPermission(3))
|
||||
+ // Plazma start - Tick toggle subcommand
|
||||
+ .executes(context -> toggleFreeze(context.getSource()))
|
||||
+ .then(Commands.literal("toggle").executes(context -> toggleFreeze(context.getSource())))
|
||||
+ // Plazma end - Tick toggle subcommand
|
||||
.then(Commands.literal("query").executes(context -> tickQuery(context.getSource())))
|
||||
.then(
|
||||
Commands.literal("rate")
|
||||
@@ -108,6 +112,14 @@ public class TickCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
+ // Plazma start - Tick toggle subcommand
|
||||
+ private static int toggleFreeze(CommandSourceStack source) {
|
||||
+ ServerTickRateManager serverTickRateManager = source.getServer().tickRateManager();
|
||||
+ boolean frozen = !serverTickRateManager.isFrozen();
|
||||
+ return setFreeze(source, frozen);
|
||||
+ }
|
||||
+ // Plazma end - Tick toggle subcommand
|
||||
+
|
||||
private static int setFreeze(CommandSourceStack source, boolean frozen) {
|
||||
ServerTickRateManager serverTickRateManager = source.getServer().tickRateManager();
|
||||
if (frozen) {
|
||||
@@ -1,263 +0,0 @@
|
||||
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] Add options to modify configurations path
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index 21a3761f075ace896c981936b2810fccb0b5d610..d99adf4a0b430b8a1ae41d3f4f04ad0c7a6e7eaa 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -135,7 +135,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
}
|
||||
|
||||
private @Nullable Component getHistory() {
|
||||
- final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.getInstance().getVersionData(); // Plazma - Add options to modify the configuration files
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
|
||||
index 660b2ec6b63a4ceffee44ab11f54dfa7c0d0996f..aa936d21bd458deef5672ddd782897c41daa765e 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
|
||||
@@ -19,8 +19,24 @@ import org.bukkit.Bukkit;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
-public enum VersionHistoryManager {
|
||||
- INSTANCE;
|
||||
+// Plazma start - Add options to modify the configuration files
|
||||
+public final class VersionHistoryManager {
|
||||
+ private static VersionHistoryManager INSTANCE;
|
||||
+
|
||||
+ public static VersionHistoryManager getInstance() {
|
||||
+ if (INSTANCE == null) {
|
||||
+ throw new IllegalStateException("VersionHistoryManager has not been initialized yet");
|
||||
+ }
|
||||
+ return INSTANCE;
|
||||
+ }
|
||||
+
|
||||
+ public static void initialize(final joptsimple.OptionSet options) {
|
||||
+ if (INSTANCE != null) {
|
||||
+ throw new IllegalStateException("VersionHistoryManager has already been initialized");
|
||||
+ }
|
||||
+ INSTANCE = new VersionHistoryManager((java.io.File) options.valueOf("version-history"));
|
||||
+ }
|
||||
+ // Plazma end - Add options to modify the configuration files
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
@@ -28,8 +44,10 @@ public enum VersionHistoryManager {
|
||||
|
||||
private VersionData currentData = null;
|
||||
|
||||
- VersionHistoryManager() {
|
||||
- final Path path = Paths.get("version_history.json");
|
||||
+ // Plazma start - Add options to modify the configuration files
|
||||
+ private VersionHistoryManager(final @Nonnull java.io.File file) {
|
||||
+ final Path path = file.toPath();
|
||||
+ // Plazma end - Add options to modify the configuration files
|
||||
|
||||
if (Files.exists(path)) {
|
||||
// Basic file santiy checks
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
index 06323dcc745aed16123980fc559d7b65c42f1e1c..ee37957264b7830c29a72f76ef4d7729bc66040c 100644
|
||||
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
@@ -117,7 +117,7 @@ public class PufferfishVersionFetcher implements VersionFetcher {
|
||||
}
|
||||
|
||||
private @Nullable Component getHistory() {
|
||||
- final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.getInstance().getVersionData(); // Plazma - Add options to modify the configuration files
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -129,4 +129,4 @@ public class PufferfishVersionFetcher implements VersionFetcher {
|
||||
|
||||
return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 3e211e6ea16c8110e662d6201e8325ecd3d6a93b..011cdc8dbef3e823bdccf1a1c7cf945cf0cf7005 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -256,7 +256,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands();
|
||||
// Purpur end - Purpur config files
|
||||
- com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||
+ com.destroystokyo.paper.VersionHistoryManager.initialize(this.options); // Paper - load version history now // Plazma - Add options to modify the configuration files
|
||||
gg.pufferfish.pufferfish.PufferfishConfig.pufferfishFile = (java.io.File) options.valueOf("pufferfish-settings"); // Purpur - Fix pufferfish issues
|
||||
gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish
|
||||
gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish
|
||||
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 d5d09bf63f4b7fba73188f75d5fe9599b8da2844..8ab6df63d9a22ac76b2ba14bc8fef318e65484c8 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/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 15527e902484496a6804c879d1de589bed3f8713..b2f924d0236683dc0a994350efe9a9db54b2ab98 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -276,12 +276,12 @@ public final class CraftServer implements Server {
|
||||
private final ServicesManager servicesManager = new SimpleServicesManager();
|
||||
private final CraftScheduler scheduler = new CraftScheduler();
|
||||
private final CraftCommandMap commandMap; // Paper - Move down
|
||||
- private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
|
||||
+ private final SimpleHelpMap helpMap;
|
||||
private final StandardMessenger messenger = new StandardMessenger();
|
||||
private final SimplePluginManager pluginManager; // Paper - Move down
|
||||
public final io.papermc.paper.plugin.manager.PaperPluginManagerImpl paperPluginManager; // Paper
|
||||
private final StructureManager structureManager;
|
||||
- protected final DedicatedServer console;
|
||||
+ public final DedicatedServer console; // Plazma - AT (protected -> public)
|
||||
protected final DedicatedPlayerList playerList;
|
||||
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
|
||||
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
|
||||
@@ -421,6 +421,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
Bukkit.setServer(this);
|
||||
// Paper start
|
||||
+ this.helpMap = new SimpleHelpMap(this); // Plazma - Add options to modify the configuration files
|
||||
this.commandMap = new CraftCommandMap(this);
|
||||
this.pluginManager = new SimplePluginManager(this, commandMap);
|
||||
this.paperPluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(this, this.commandMap, pluginManager);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index a75f3328ba32466b6ceeddb0069c856524f19c0a..913213c77fa2cf8038768a34b38bb59d698e714b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -205,6 +205,44 @@ 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");
|
||||
+
|
||||
+ acceptsAll(asList("version-history"), "File for version history")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File("version_history.json"))
|
||||
+ .describedAs("JSON file");
|
||||
+
|
||||
+ acceptsAll(asList("help"), "File for help command")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File("help.yml"))
|
||||
+ .describedAs("Yaml file");
|
||||
+ // Plazma end - Configurable player data storage
|
||||
}
|
||||
};
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
|
||||
index 5923d3c17756c489fcb392044c0679fe52e2d58f..3ec5cf874dfd9d2e016daa9f7c7aee2646e67861 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
|
||||
@@ -25,7 +25,7 @@ public class HelpYamlReader {
|
||||
public HelpYamlReader(Server server) {
|
||||
this.server = server;
|
||||
|
||||
- File helpYamlFile = new File("help.yml");
|
||||
+ File helpYamlFile = (File) ((org.bukkit.craftbukkit.CraftServer) server).console.options.valueOf("help"); // Plazma - Add options to modify the configuration files
|
||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
|
||||
|
||||
try {
|
||||
@@ -1,125 +0,0 @@
|
||||
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..af455e7f1c22fda87dbc5b487b757d046dcc2d49 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/OpCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/OpCommand.java
|
||||
@@ -34,20 +34,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", com.mojang.brigadier.arguments.IntegerArgumentType.integer(0, 4))
|
||||
+ .executes(context ->
|
||||
+ opPlayers(context.getSource(), GameProfileArgument.getGameProfiles(context, "targets"), com.mojang.brigadier.arguments.IntegerArgumentType.getInteger(context, "permissionLevel"), false)
|
||||
+ )
|
||||
+ .then(
|
||||
+ Commands.argument("bypassPlayerLimit", com.mojang.brigadier.arguments.BoolArgumentType.bool())
|
||||
+ .executes(context ->
|
||||
+ opPlayers(context.getSource(), GameProfileArgument.getGameProfiles(context, "targets"), com.mojang.brigadier.arguments.IntegerArgumentType.getInteger(context, "permissionLevel"), com.mojang.brigadier.arguments.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/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 8ab6df63d9a22ac76b2ba14bc8fef318e65484c8..81bae0453e09454c43d547c48de2f201a5e41023 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();
|
||||
@@ -1,122 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Wed, 25 Dec 2024 19:07:19 +0900
|
||||
Subject: [PATCH] Add heal command
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index c416b1eaf27699de59aaa6b352ff1aa991d3f660..90ecfc550324521a7aece274bab330f8dc2de3f3 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -180,6 +180,7 @@ public class Commands {
|
||||
org.purpurmc.purpur.command.CompassCommand.register(this.dispatcher); // Purpur
|
||||
org.purpurmc.purpur.command.RamBarCommand.register(this.dispatcher); // Purpur - Implement ram and rambar commands
|
||||
org.purpurmc.purpur.command.RamCommand.register(this.dispatcher); // Purpur - Implement ram and rambar commands
|
||||
+ org.plazmamc.plazma.commands.HealCommand.register(this.dispatcher); // Plazma - Add heal command
|
||||
}
|
||||
|
||||
if (environment.includeIntegrated) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/commands/HealCommand.java b/src/main/java/org/plazmamc/plazma/commands/HealCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b10725af7ec4433e98557cfbafb563822cd4f908
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/commands/HealCommand.java
|
||||
@@ -0,0 +1,66 @@
|
||||
+package org.plazmamc.plazma.commands;
|
||||
+
|
||||
+import com.mojang.brigadier.CommandDispatcher;
|
||||
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
+import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.commands.Commands;
|
||||
+import net.minecraft.commands.arguments.EntityArgument;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.LivingEntity;
|
||||
+import net.minecraft.world.entity.player.Player;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.plazmamc.plazma.configurations.GlobalConfiguration;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collection;
|
||||
+import java.util.Collections;
|
||||
+
|
||||
+import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class HealCommand {
|
||||
+
|
||||
+ public static void register(final CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
+ dispatcher.register(Commands.literal("heal")
|
||||
+ .requires(source -> source.hasPermission(2, "bukkit.command.heal"))
|
||||
+ .executes(ctx -> execute(ctx.getSource(), Collections.singleton(ctx.getSource().getEntityOrException())))
|
||||
+ .then(Commands.argument("targets", EntityArgument.entities())
|
||||
+ .requires(source -> source.hasPermission(3, "bukkit.command.heal.others"))
|
||||
+ .executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntities(ctx, "targets")))
|
||||
+ )
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ @Contract(pure = true)
|
||||
+ private static int execute(final CommandSourceStack sender, Collection<? extends Entity> targets) throws CommandSyntaxException {
|
||||
+ final ArrayList<Component> success = new ArrayList<>();
|
||||
+
|
||||
+ for (Entity target : targets) {
|
||||
+ if (!(target instanceof LivingEntity entity)) continue;
|
||||
+ if (entity.isDeadOrDying()) continue;
|
||||
+
|
||||
+ entity.heal(entity.getMaxHealth());
|
||||
+ success.add(PaperAdventure.asAdventure(entity.getDisplayName()));
|
||||
+
|
||||
+ if (!(entity instanceof Player player)) continue;
|
||||
+ player.getFoodData().setFoodLevel(20);
|
||||
+ player.getFoodData().setSaturation(5.0F);
|
||||
+ }
|
||||
+
|
||||
+ if (success.isEmpty()) {
|
||||
+ throw new SimpleCommandExceptionType(PaperAdventure.asVanilla(miniMessage().deserialize(GlobalConfiguration.get().messages.heal.noTargets))).create();
|
||||
+ }
|
||||
+
|
||||
+ final Component successJoined = success.stream().reduce((a, b) -> a.append(Component.text(", ").append(b))).orElseThrow();
|
||||
+
|
||||
+ sender.sendSuccess(miniMessage().deserialize(GlobalConfiguration.get().messages.heal.healed, Placeholder.component("targets", successJoined)));
|
||||
+ return success.size();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 898f9e6ec6f306a15639ee0d03bcfe7bf55e2c6c..02a164ff2c855864e246dcaaf8186274421edea7 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -31,6 +31,13 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public Messages messages;
|
||||
public class Messages extends ConfigurationPart {
|
||||
|
||||
+ public Heal heal;
|
||||
+ public class Heal extends ConfigurationPart {
|
||||
+
|
||||
+ public String healed = "Healed %s";
|
||||
+ public String noTargets = "No targets matched selector";
|
||||
+
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
|
||||
index 180c0a532bbac10a8280b63eb7aa783a1bfbb237..75ddd1a811d0a07c6fe5431a527b3a74e52ad53a 100644
|
||||
--- a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
|
||||
+++ b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
|
||||
@@ -78,7 +78,8 @@ public class MinecraftCommandPermissionsTest {
|
||||
"minecraft.command.gamemode.survival",
|
||||
"minecraft.command.gamemode.survival.other",
|
||||
// Purpur end
|
||||
- "minecraft.command.selector"
|
||||
+ "minecraft.command.selector",
|
||||
+ "minecraft.command.heal" // Plazma
|
||||
);
|
||||
|
||||
private static Set<String> collectMinecraftCommandPerms() {
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Wed, 25 Dec 2024 19:10:40 +0900
|
||||
Subject: [PATCH] Add missing argument place for /compass command
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/command/CompassCommand.java b/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
|
||||
index 79b8490832d2a0cc7846ddcb091cb6bcac74ea45..bc4bdb86dc9a8f454058e0e9555e0af6f70d6b37 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
|
||||
@@ -22,6 +22,24 @@ public class CompassCommand {
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
+ // Plazma start - Add missing argument place for /compass command
|
||||
+ .then(Commands.argument("targets", net.minecraft.commands.arguments.EntityArgument.players())
|
||||
+ .requires(listener -> listener.hasPermission(2, "bukkit.command.compass.other"))
|
||||
+ .executes(context -> {
|
||||
+ for (ServerPlayer player : net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets")) {
|
||||
+ CompassTask task = CompassTask.instance();
|
||||
+ if (player.compassBar()) {
|
||||
+ task.removePlayer(player.getBukkitEntity());
|
||||
+ player.compassBar(false);
|
||||
+ } else {
|
||||
+ task.addPlayer(player.getBukkitEntity());
|
||||
+ player.compassBar(true);
|
||||
+ }
|
||||
+ }
|
||||
+ return net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets").size();
|
||||
+ })
|
||||
+ )
|
||||
+ // Plazma end - Add missing argument place for /compass command
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user