mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-06-28 08:16:41 +00:00
More patches
This commit is contained in:
@ -1,32 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 16:49:17 -0600
|
||||
Subject: [PATCH] Reject oversized components from updating
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
index 584a58659fae6ba3d8b53858890bc6ec509ffb0e..54a7dae26854d320d9e53f63eb411a85a2d78159 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
@@ -39,8 +39,9 @@ public class ComponentUtils {
|
||||
}
|
||||
|
||||
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||
+ MutableComponent result; // Scissors
|
||||
if (depth > 100) {
|
||||
- return text.copy();
|
||||
+ result = text.copy(); // Scissors
|
||||
} else {
|
||||
// Paper start
|
||||
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
||||
@@ -53,8 +54,9 @@ public class ComponentUtils {
|
||||
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
||||
}
|
||||
|
||||
- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); // Scissors
|
||||
}
|
||||
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; // Scissors
|
||||
}
|
||||
|
||||
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
@ -1,508 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:12:04 +0100
|
||||
Subject: [PATCH] Add Scissors configuration file & command
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb190a622d 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
@@ -25,6 +25,7 @@ package co.aikar.timings;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
@@ -242,7 +243,8 @@ public class TimingsExport extends Thread {
|
||||
parent.put("config", createObject(
|
||||
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
||||
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
||||
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
|
||||
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
|
||||
+ pair("scissors", mapAsJSON(ScissorsConfig.config, null)) // Scissors
|
||||
));
|
||||
|
||||
new TimingsExport(listeners, parent, history).start();
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67ed3d6e95
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
||||
@@ -0,0 +1,150 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+import com.google.common.base.Functions;
|
||||
+import com.google.common.base.Joiner;
|
||||
+import com.google.common.collect.ImmutableSet;
|
||||
+import com.google.common.collect.Iterables;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.*;
|
||||
+import java.util.stream.Collectors;
|
||||
+
|
||||
+public class ScissorsCommand extends Command
|
||||
+{
|
||||
+
|
||||
+ private static final String BASE_PERM = "bukkit.command.scissors.";
|
||||
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("reload", "version").build();
|
||||
+
|
||||
+ public ScissorsCommand(String name)
|
||||
+ {
|
||||
+ super(name);
|
||||
+ this.description = "Scissors related commands";
|
||||
+ this.usageMessage = "/scissors [" + Joiner.on(" | ").join(SUBCOMMANDS) + "]";
|
||||
+ this.setPermission("bukkit.command.scissors;" + Joiner.on(';').join(SUBCOMMANDS.stream().map(s -> BASE_PERM + s).collect(Collectors.toSet())));
|
||||
+ }
|
||||
+
|
||||
+ private static boolean testPermission(CommandSender commandSender, String permission)
|
||||
+ {
|
||||
+ if (commandSender.hasPermission(BASE_PERM + permission) || commandSender.hasPermission("bukkit.command.scissors"))
|
||||
+ return true;
|
||||
+ commandSender.sendMessage(Bukkit.getPermissionMessage()); // Sorry, kashike
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Code from Mojang - copyright them
|
||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] args, String... matches)
|
||||
+ {
|
||||
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
|
||||
+ }
|
||||
+
|
||||
+ public static boolean matches(String s, String s1)
|
||||
+ {
|
||||
+ return s1.regionMatches(true, 0, s, 0, s.length());
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] strings, Collection<?> collection)
|
||||
+ {
|
||||
+ String last = strings[strings.length - 1];
|
||||
+ ArrayList<String> results = Lists.newArrayList();
|
||||
+
|
||||
+ if (!collection.isEmpty())
|
||||
+ {
|
||||
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
|
||||
+
|
||||
+ while (iterator.hasNext())
|
||||
+ {
|
||||
+ String s1 = (String) iterator.next();
|
||||
+
|
||||
+ if (matches(last, s1) && (sender.hasPermission(BASE_PERM + s1) || sender.hasPermission("bukkit.command.scissors")))
|
||||
+ {
|
||||
+ results.add(s1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (results.isEmpty())
|
||||
+ {
|
||||
+ iterator = collection.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext())
|
||||
+ {
|
||||
+ Object object = iterator.next();
|
||||
+
|
||||
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath()))
|
||||
+ {
|
||||
+ results.add(String.valueOf(object));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return results;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException
|
||||
+ {
|
||||
+ if (args.length <= 1)
|
||||
+ return getListMatchingLast(sender, args, SUBCOMMANDS);
|
||||
+
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+ // end copy stuff
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
+ {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ if (args.length == 0)
|
||||
+ {
|
||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (SUBCOMMANDS.contains(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
+ {
|
||||
+ if (!testPermission(sender, args[0].toLowerCase(Locale.ENGLISH))) return true;
|
||||
+ }
|
||||
+ switch (args[0].toLowerCase(Locale.ENGLISH))
|
||||
+ {
|
||||
+ case "reload":
|
||||
+ doReload(sender);
|
||||
+ break;
|
||||
+ case "ver":
|
||||
+ if (!testPermission(sender, "version"))
|
||||
+ break; // "ver" needs a special check because it's an alias. All other commands are checked up before the switch statement (because they are present in the SUBCOMMANDS set)
|
||||
+ case "version":
|
||||
+ Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ if (ver != null)
|
||||
+ {
|
||||
+ ver.execute(sender, commandLabel, new String[0]);
|
||||
+ break;
|
||||
+ }
|
||||
+ // else - fall through to default
|
||||
+ default:
|
||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void doReload(CommandSender sender)
|
||||
+ {
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||
+
|
||||
+ MinecraftServer console = MinecraftServer.getServer();
|
||||
+ ScissorsConfig.init((File) console.options.valueOf("scissors-settings"));
|
||||
+ console.server.reloadCount++;
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Scissors config reload complete.");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8cd2848aa6b06c5efbe797ed2d75ff4b025b3c52
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
@@ -0,0 +1,225 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.regex.Pattern;
|
||||
+
|
||||
+// TODO - Migrate to new format
|
||||
+public class ScissorsConfig
|
||||
+{
|
||||
+
|
||||
+ private static final String HEADER = """
|
||||
+ This is the main configuration file for Scissors.
|
||||
+ As you can see, there's tons to configure. Some options may impact gameplay, so use
|
||||
+ with caution, and make sure you know what each option does before configuring.
|
||||
+
|
||||
+ If you need help with the configuration or have any questions related to Scissors,
|
||||
+ join us in our Discord.
|
||||
+
|
||||
+ Discord: https://discord.com/invite/mtVQcHn58h
|
||||
+ Website: https://scissors.gg/\s
|
||||
+ Docs: https://javadoc.scissors.gg/1.20.1/\s
|
||||
+ """;
|
||||
+ private static final Pattern SPACE = Pattern.compile(" ");
|
||||
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
||||
+ /*========================================================================*/
|
||||
+ public static YamlConfiguration config;
|
||||
+ static int version;
|
||||
+ /*========================================================================*/
|
||||
+ static Map<String, Command> commands;
|
||||
+ private static File CONFIG_FILE;
|
||||
+
|
||||
+ public static void init(File configFile)
|
||||
+ {
|
||||
+ final File configFolder = (File) DedicatedServer.getServer().options.valueOf("scissors-settings" + "-directory");
|
||||
+ final Path configFolderPath = configFolder.toPath();
|
||||
+ final Path oldConfigFilePath = configFile.toPath();
|
||||
+ final Path newConfigFilePath = configFolderPath.resolve(configFile.toPath());
|
||||
+
|
||||
+ if (configFile.exists())
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ Files.move(oldConfigFilePath, newConfigFilePath);
|
||||
+ }
|
||||
+ catch (IOException e)
|
||||
+ {
|
||||
+ throw new RuntimeException("Error migrating configuration file to new directory!", e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ CONFIG_FILE = newConfigFilePath.toFile();
|
||||
+ config = new YamlConfiguration();
|
||||
+ try
|
||||
+ {
|
||||
+ config.load(CONFIG_FILE);
|
||||
+ }
|
||||
+ catch (IOException ex)
|
||||
+ {
|
||||
+ }
|
||||
+ catch (InvalidConfigurationException ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load scissors.yml, please correct your syntax errors", ex);
|
||||
+ throw Throwables.propagate(ex);
|
||||
+ }
|
||||
+
|
||||
+ commands = new HashMap<>();
|
||||
+ commands.put("scissors", new ScissorsCommand("scissors"));
|
||||
+
|
||||
+ config.options().header(HEADER);
|
||||
+ config.options().copyDefaults(true);
|
||||
+
|
||||
+ version = getInt("config-version", 5);
|
||||
+ set("config-version", 5);
|
||||
+ readConfig(ScissorsConfig.class, null);
|
||||
+ }
|
||||
+
|
||||
+ protected static void logError(String s)
|
||||
+ {
|
||||
+ Bukkit.getLogger().severe(s);
|
||||
+ }
|
||||
+
|
||||
+ protected static void fatal(String s)
|
||||
+ {
|
||||
+ throw new RuntimeException("Fatal scissors.yml config error: " + s);
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands()
|
||||
+ {
|
||||
+ for (Map.Entry<String, Command> entry : commands.entrySet())
|
||||
+ {
|
||||
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Scissors", entry.getValue());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ static void readConfig(Class<?> clazz, Object instance)
|
||||
+ {
|
||||
+ for (Method method : clazz.getDeclaredMethods())
|
||||
+ {
|
||||
+ if (Modifier.isPrivate(method.getModifiers()))
|
||||
+ {
|
||||
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE)
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ method.setAccessible(true);
|
||||
+ method.invoke(instance);
|
||||
+ }
|
||||
+ catch (InvocationTargetException ex)
|
||||
+ {
|
||||
+ throw Throwables.propagate(ex.getCause());
|
||||
+ }
|
||||
+ catch (Exception ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ saveConfig();
|
||||
+ }
|
||||
+
|
||||
+ static void saveConfig()
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ config.save(CONFIG_FILE);
|
||||
+ }
|
||||
+ catch (IOException ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static boolean runCommandsInBooks = false;
|
||||
+
|
||||
+ private static void runCommandsInBooks()
|
||||
+ {
|
||||
+ runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||
+ }
|
||||
+
|
||||
+ // people still may want them to bypass permissions for warps
|
||||
+ public static boolean commandSignsBypassPermissions = false;
|
||||
+ private static void commandSignsBypassPermissions()
|
||||
+ {
|
||||
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean chatSignaturesEnabled = true;
|
||||
+ private static void chatSignaturesEnabled()
|
||||
+ {
|
||||
+ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean excludePlayersFromNbtComponents = false;
|
||||
+ private static void excludePlayersFromNbtComponents()
|
||||
+ {
|
||||
+ excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false);
|
||||
+ }
|
||||
+ public static int componentDepthLimit = 128;
|
||||
+ private static void componentDepthLimit()
|
||||
+ {
|
||||
+ componentDepthLimit = getInt("componentDepthLimit", 128);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static void set(String path, Object val)
|
||||
+ {
|
||||
+ config.set(path, val);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean getBoolean(String path, boolean def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getBoolean(path, config.getBoolean(path));
|
||||
+ }
|
||||
+
|
||||
+ private static double getDouble(String path, double def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getDouble(path, config.getDouble(path));
|
||||
+ }
|
||||
+
|
||||
+ private static float getFloat(String path, float def)
|
||||
+ {
|
||||
+ // TODO: Figure out why getFloat() always returns the default value.
|
||||
+ return (float) getDouble(path, def);
|
||||
+ }
|
||||
+
|
||||
+ private static int getInt(String path, int def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getInt(path, config.getInt(path));
|
||||
+ }
|
||||
+
|
||||
+ private static <T> List getList(String path, T def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getList(path, config.getList(path));
|
||||
+ }
|
||||
+
|
||||
+ private static String getString(String path, String def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getString(path, config.getString(path));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index a7ebf851a65231074c89a24f30de4ac2fb5b63e4..641fe69cb2131413654c39a32a73c62e2bc092f6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -147,6 +147,7 @@ public class Main {
|
||||
// Paper start - load config files for access below if needed
|
||||
org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings"));
|
||||
org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings"));
|
||||
+ org.bukkit.configuration.file.YamlConfiguration scissorsConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("scissors-settings")); // Scissors - TODO Change this
|
||||
// Paper end
|
||||
|
||||
if (optionset.has("initSettings")) { // CraftBukkit
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index c49802c936ae8e3f4dc1badd98414d96714ecd60..c9725f2df7a66eba3d5994a2b4b16b07ff0f696d 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -222,6 +222,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||
// Paper end
|
||||
|
||||
+ // Scissors start
|
||||
+ try {
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.init((java.io.File) options.valueOf("scissors-settings"));
|
||||
+ } catch (Exception e) {
|
||||
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands();
|
||||
+ // Scissors end
|
||||
+
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 26937b8dd0411b0c96e461c57eeee6ae8595211e..bf8ade78a771b0295811f48cba96aeb05a39524e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1036,6 +1036,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.init(((File) console.options.valueOf("scissors-settings"))); // Scissors
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
@@ -1067,6 +1068,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands(); // Scissors
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -2912,6 +2914,14 @@ public final class CraftServer implements Server {
|
||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ @Override
|
||||
+ public YamlConfiguration getScissorsConfig()
|
||||
+ {
|
||||
+ return me.totalfreedom.scissors.ScissorsConfig.config;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public void restart() {
|
||||
org.spigotmc.RestartCommand.restart();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index d1c8671ba5ca95c425e4c679445d55c4bbba217e..3be40632c70f5a7994ada3e61616dca632cef2da 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -180,6 +180,20 @@ public class Main {
|
||||
.defaultsTo("Unknown Server")
|
||||
.describedAs("Name");
|
||||
// Paper end
|
||||
+
|
||||
+ // Scissors start
|
||||
+ acceptsAll(asList("scissors-dir", "scissors-settings-directory"), "Directory for Scissors settings")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
|
||||
+ .describedAs("Config directory");
|
||||
+
|
||||
+ acceptsAll(asList("scissors", "scissors-settings"), "File for Scissors settings")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File("scissors.yml"))
|
||||
+ .describedAs("YAML file");
|
||||
+ // Scissors end
|
||||
}
|
||||
};
|
||||
|
@ -1,28 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Wed, 30 Mar 2022 18:20:09 -0600
|
||||
Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
|
||||
to CraftMetaItems
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index f9741039dada19391e80d9623f2d8cabc1089506..38238d9e6d464990caf10557997c6ca88ee100c0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
+import net.minecraft.resources.ResourceLocation; // Scissors
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
@@ -486,7 +487,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||
|
||||
String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
||||
- if (attributeName == null || attributeName.isEmpty()) {
|
||||
+ if (attributeName == null || attributeName.isEmpty() || attributeName.length() > 256 || !ResourceLocation.isValidResourceLocation(attributeName)) { // Scissors
|
||||
continue;
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sat, 9 Apr 2022 13:00:27 -0600
|
||||
Subject: [PATCH] Don't query player data in the `nbt` component
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||
index 8a6799b50062c1b7b141ee1568dc523f9ee7ecfd..80e7b0889235288b60d813a569daecb7e08e108e 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.network.chat.contents;
|
||||
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.List;
|
||||
@@ -11,6 +12,7 @@ import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.player.Player; // Scissors
|
||||
|
||||
public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource {
|
||||
public EntityDataSource(String rawPath) {
|
||||
@@ -31,7 +33,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
|
||||
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
||||
if (this.compiledSelector != null) {
|
||||
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
||||
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
|
||||
+ // Scissors start
|
||||
+ Stream<? extends Entity> stream = list.stream();
|
||||
+ if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player));
|
||||
+ return stream.map(NbtPredicate::getEntityTagToCompare);
|
||||
+ // Scissors end
|
||||
} else {
|
||||
return Stream.empty();
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 8 Apr 2022 23:38:12 -0300
|
||||
Subject: [PATCH] Limit string tag visitors to 1024 elements
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||
index e07cc7970955ce240754cfe424d768c2bba0241a..a4f41bb4ec6cb20f782668c714229b61415cfdfb 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||
@@ -89,6 +89,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||
public void visitByteArray(ByteArrayTag element) {
|
||||
StringBuilder stringBuilder = (new StringBuilder("[")).append("B").append(";");
|
||||
byte[] bs = element.getAsByteArray();
|
||||
+ if (bs.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < bs.length; ++i) {
|
||||
stringBuilder.append(" ").append((int)bs[i]).append("B");
|
||||
@@ -105,6 +106,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||
public void visitIntArray(IntArrayTag element) {
|
||||
StringBuilder stringBuilder = (new StringBuilder("[")).append("I").append(";");
|
||||
int[] is = element.getAsIntArray();
|
||||
+ if (is.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < is.length; ++i) {
|
||||
stringBuilder.append(" ").append(is[i]);
|
||||
@@ -122,6 +124,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||
String string = "L";
|
||||
StringBuilder stringBuilder = (new StringBuilder("[")).append("L").append(";");
|
||||
long[] ls = element.getAsLongArray();
|
||||
+ if (ls.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < ls.length; ++i) {
|
||||
stringBuilder.append(" ").append(ls[i]).append("L");
|
||||
@@ -136,7 +139,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||
|
||||
@Override
|
||||
public void visitList(ListTag element) {
|
||||
- if (element.isEmpty()) {
|
||||
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
|
||||
this.result = "[]";
|
||||
} else {
|
||||
StringBuilder stringBuilder = new StringBuilder("[");
|
||||
@@ -166,7 +169,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||
|
||||
@Override
|
||||
public void visitCompound(CompoundTag compound) {
|
||||
- if (compound.isEmpty()) {
|
||||
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
|
||||
this.result = "{}";
|
||||
} else {
|
||||
StringBuilder stringBuilder = new StringBuilder("{");
|
||||
diff --git a/src/main/java/net/minecraft/nbt/StringTagVisitor.java b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||
index a687a0f17df30126d53a1e3a669dc6d157c23ed5..2c50f41dd8034af16fcceca75eeb6c7a9940e327 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||
@@ -53,6 +53,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||
public void visitByteArray(ByteArrayTag element) {
|
||||
this.builder.append("[B;");
|
||||
byte[] bs = element.getAsByteArray();
|
||||
+ if (bs.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < bs.length; ++i) {
|
||||
if (i != 0) {
|
||||
@@ -69,6 +70,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||
public void visitIntArray(IntArrayTag element) {
|
||||
this.builder.append("[I;");
|
||||
int[] is = element.getAsIntArray();
|
||||
+ if (is.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < is.length; ++i) {
|
||||
if (i != 0) {
|
||||
@@ -85,6 +87,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||
public void visitLongArray(LongArrayTag element) {
|
||||
this.builder.append("[L;");
|
||||
long[] ls = element.getAsLongArray();
|
||||
+ if (ls.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < ls.length; ++i) {
|
||||
if (i != 0) {
|
||||
@@ -100,6 +103,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||
@Override
|
||||
public void visitList(ListTag element) {
|
||||
this.builder.append('[');
|
||||
+ if (element.size() > 1024) { this.builder.append(']'); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < element.size(); ++i) {
|
||||
if (i != 0) {
|
||||
@@ -116,6 +120,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||
public void visitCompound(CompoundTag compound) {
|
||||
this.builder.append('{');
|
||||
List<String> list = Lists.newArrayList(compound.getAllKeys());
|
||||
+ if (list.size() > 1024) { this.builder.append('}'); return; } // Scissors
|
||||
Collections.sort(list);
|
||||
|
||||
for(String string : list) {
|
||||
diff --git a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||
index 149def3da0b92f64e4fc04630965dce44884f938..c9d753f37bd65e35f8a4e2eb5c6fe8f74d5d1606 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||
@@ -97,6 +97,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||
Component component = Component.literal("B").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||
byte[] bs = element.getAsByteArray();
|
||||
+ if (bs.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < bs.length; ++i) {
|
||||
MutableComponent mutableComponent2 = Component.literal(String.valueOf((int)bs[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
|
||||
@@ -115,6 +116,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||
Component component = Component.literal("I").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||
int[] is = element.getAsIntArray();
|
||||
+ if (is.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < is.length; ++i) {
|
||||
mutableComponent.append(" ").append(Component.literal(String.valueOf(is[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER));
|
||||
@@ -132,6 +134,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||
Component component = Component.literal("L").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||
long[] ls = element.getAsLongArray();
|
||||
+ if (ls.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||
|
||||
for(int i = 0; i < ls.length; ++i) {
|
||||
Component component2 = Component.literal(String.valueOf(ls[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
|
||||
@@ -147,7 +150,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||
|
||||
@Override
|
||||
public void visitList(ListTag element) {
|
||||
- if (element.isEmpty()) {
|
||||
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
|
||||
this.result = Component.literal("[]");
|
||||
} else if (INLINE_ELEMENT_TYPES.contains(element.getElementType()) && element.size() <= 8) {
|
||||
String string = ELEMENT_SEPARATOR + " ";
|
||||
@@ -190,7 +193,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||
|
||||
@Override
|
||||
public void visitCompound(CompoundTag compound) {
|
||||
- if (compound.isEmpty()) {
|
||||
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
|
||||
this.result = Component.literal("{}");
|
||||
} else {
|
||||
MutableComponent mutableComponent = Component.literal("{");
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 18 Apr 2022 16:55:19 +0100
|
||||
Subject: [PATCH] Fix negative death times
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index e11d7283662834047b2ff81a2fd25a4263792deb..4bd7eea49a0720063db2a8ed10f53bd19e9499ad 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -629,7 +629,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) { // Scissors
|
||||
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 11 Jun 2022 22:56:59 -0500
|
||||
Subject: [PATCH] Add custom classes used by Scissors
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/MathUtility.java b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..754b578b575137a9c48cb20dee965a9388fedb3c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
||||
@@ -0,0 +1,29 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+public class MathUtility
|
||||
+{
|
||||
+ public static int clampInt(int number, int minimum, int maximum)
|
||||
+ {
|
||||
+ return Math.min(Math.max(number, minimum), maximum);
|
||||
+ }
|
||||
+
|
||||
+ public static long clampLong(long number, long minimum, long maximum)
|
||||
+ {
|
||||
+ return Math.min(Math.max(number, minimum), maximum);
|
||||
+ }
|
||||
+
|
||||
+ public static double clampDouble(double number, double minimum, double maximum)
|
||||
+ {
|
||||
+ return Math.min(Math.max(number, minimum), maximum);
|
||||
+ }
|
||||
+
|
||||
+ public static int safeDoubleToInt(double number)
|
||||
+ {
|
||||
+ return (int) clampDouble(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
+ }
|
||||
+
|
||||
+ public static int safeLongToInt(long number)
|
||||
+ {
|
||||
+ return (int) clampLong(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/NbtUtility.java b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b3efac47ee700d5a7ff26452d6bcbf2f687a32cf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||
@@ -0,0 +1,75 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import javax.annotation.Nullable;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import net.minecraft.nbt.Tag;
|
||||
+
|
||||
+public class NbtUtility
|
||||
+{
|
||||
+ public static final long MAXIMUM_SIZE = (256 * 1024);
|
||||
+
|
||||
+ public static long getTagSize(@Nullable Tag tag, int depth)
|
||||
+ {
|
||||
+ if (depth > 512)
|
||||
+ {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ if (tag == null)
|
||||
+ {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ long size = 0;
|
||||
+
|
||||
+ if (tag.getType() == CompoundTag.TYPE)
|
||||
+ {
|
||||
+ CompoundTag compoundTag = (CompoundTag) tag;
|
||||
+ for (String key : compoundTag.getAllKeys())
|
||||
+ {
|
||||
+ size += key.getBytes(StandardCharsets.UTF_8).length;
|
||||
+ size += getTagSize(compoundTag.get(key), depth + 1);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (tag.getType() == ListTag.TYPE)
|
||||
+ {
|
||||
+ ListTag listTag = (ListTag) tag;
|
||||
+ for (Tag tag1 : listTag)
|
||||
+ {
|
||||
+ size += getTagSize(tag1, depth + 1);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length;
|
||||
+ }
|
||||
+
|
||||
+ return size;
|
||||
+ }
|
||||
+
|
||||
+ public static long getTagSize(@Nullable CompoundTag tag)
|
||||
+ {
|
||||
+ return getTagSize(tag, 0);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||
+ {
|
||||
+ if (tag == null)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return getTagSize(tag) > MAXIMUM_SIZE;
|
||||
+ }
|
||||
+
|
||||
+ public static class Item
|
||||
+ {
|
||||
+ public static CompoundTag removeItemData(CompoundTag tag)
|
||||
+ {
|
||||
+ CompoundTag cleaned = new CompoundTag();
|
||||
+ cleaned.putString("id", tag.getString("id"));
|
||||
+ cleaned.putByte("Count", tag.getByte("Count"));
|
||||
+ return cleaned;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c5dcc833d6f2c0daa1d0c2a7ab81430f25e0b2f3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
||||
@@ -0,0 +1,53 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.border.WorldBorder;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
+
|
||||
+public class PositionUtility
|
||||
+{
|
||||
+
|
||||
+ public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity)
|
||||
+ {
|
||||
+ final BlockPos validBlockPos = getValidBlockPos(blockPos, entity);
|
||||
+
|
||||
+ return new Vec3(validBlockPos.getX(), validBlockPos.getY(), validBlockPos.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPos getValidBlockPos(BlockPos blockPos, Entity entity)
|
||||
+ {
|
||||
+ final Level level = entity.level();
|
||||
+
|
||||
+ try
|
||||
+ {
|
||||
+ if (level.isInWorldBounds(blockPos))
|
||||
+ {
|
||||
+ return blockPos;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ final int x = blockPos.getX();
|
||||
+ final int y = blockPos.getY();
|
||||
+ final int z = blockPos.getZ();
|
||||
+
|
||||
+ final WorldBorder worldBorder = level.getWorldBorder();
|
||||
+
|
||||
+ final int maxX = MathUtility.safeDoubleToInt(worldBorder.getMaxX());
|
||||
+ final int maxY = level.getMaxBuildHeight();
|
||||
+ final int maxZ = MathUtility.safeDoubleToInt(worldBorder.getMaxZ());
|
||||
+
|
||||
+ final int minX = MathUtility.safeDoubleToInt(worldBorder.getMinX());
|
||||
+ final int minY = level.getMinBuildHeight();
|
||||
+ final int minZ = MathUtility.safeDoubleToInt(worldBorder.getMinZ());
|
||||
+
|
||||
+ return new BlockPos(MathUtility.clampInt(x, minX, maxX), MathUtility.clampInt(y, minY, maxY), MathUtility.clampInt(z, minZ, maxZ));
|
||||
+ }
|
||||
+ }
|
||||
+ catch (Exception e)
|
||||
+ { // If we throw some sort of exception due to the position being crazy, catch it
|
||||
+ return new BlockPos(0, 0, 0);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
@ -1,313 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 18 Apr 2022 03:56:09 +0100
|
||||
Subject: [PATCH] Reset large tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..04c47cf1a920ae6c356449df801227ee14f6dfb7 100644
|
||||
--- a/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
+++ b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -22,10 +23,12 @@ public class ContainerHelper {
|
||||
|
||||
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
||||
ListTag listTag = new ListTag();
|
||||
+ long total = 0; // Scissors
|
||||
|
||||
for(int i = 0; i < stacks.size(); ++i) {
|
||||
ItemStack itemStack = stacks.get(i);
|
||||
if (!itemStack.isEmpty()) {
|
||||
+ total += NbtUtility.getTagSize(itemStack.getTag()); // Scissors
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
compoundTag.putByte("Slot", (byte)i);
|
||||
itemStack.save(compoundTag);
|
||||
@@ -33,7 +36,7 @@ public class ContainerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
- if (!listTag.isEmpty() || setIfEmpty) {
|
||||
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) { // Scissors
|
||||
nbt.put("Items", listTag);
|
||||
}
|
||||
|
||||
@@ -42,11 +45,19 @@ public class ContainerHelper {
|
||||
|
||||
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
|
||||
ListTag listTag = nbt.getList("Items", 10);
|
||||
+ long total = 0; // Scissors - Account for items inside containers
|
||||
|
||||
for(int i = 0; i < listTag.size(); ++i) {
|
||||
CompoundTag compoundTag = listTag.getCompound(i);
|
||||
int j = compoundTag.getByte("Slot") & 255;
|
||||
if (j >= 0 && j < stacks.size()) {
|
||||
+ // Scissors start
|
||||
+ total += NbtUtility.getTagSize(compoundTag);
|
||||
+ if (total >= NbtUtility.MAXIMUM_SIZE) {
|
||||
+ stacks.clear();
|
||||
+ break;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
stacks.set(j, ItemStack.of(compoundTag));
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index d138660e459b2d09ba9dd7ae2bf3da499d9ae25c..8c5fe0166a5442a2fa4f212d7c53343c937f53f1 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -21,6 +21,7 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
@@ -253,6 +254,12 @@ public final class ItemStack {
|
||||
|
||||
// CraftBukkit - break into own method
|
||||
private void load(CompoundTag nbttagcompound) {
|
||||
+ // Scissors start - Reset large tags
|
||||
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
||||
+ // Reset tag without destroying item
|
||||
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -556,7 +563,11 @@ public final class ItemStack {
|
||||
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
|
||||
nbt.putByte("Count", (byte) this.count);
|
||||
if (this.tag != null) {
|
||||
- nbt.put("tag", this.tag.copy());
|
||||
+ // Scissors start - Don't save large tags
|
||||
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
||||
+ nbt.put("tag", this.tag.copy());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
return nbt;
|
||||
@@ -886,6 +897,7 @@ public final class ItemStack {
|
||||
// Paper end
|
||||
|
||||
public void setTag(@Nullable CompoundTag nbt) {
|
||||
+ if (NbtUtility.isTooLarge(nbt)) return; // Scissors - Ignore large tags
|
||||
this.tag = nbt;
|
||||
this.processEnchantOrder(this.tag); // Paper
|
||||
if (this.getItem().canBeDepleted()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index 40e59b8db83aec1143e3c394427e916beea7c01f..f292aa0016e6f741b36ddc1417f6f63d248f987f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -212,6 +213,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
index 416aa989ebb18a8741cc9d605a1180ab830f6643..a9a8c9e68e5b767dec2c26495685da88e0caa627 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -34,6 +35,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
index c57efcb9a79337ec791e4e8f6671612f0a82b441..2cbb8170953cb555411db8c171a3d1d91eb799bb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -73,6 +74,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||
}
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..f51abf1722e98d7ce9e616d84472d847e597eafb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -40,6 +41,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
index 881379681c39230a00b3a1f11cd87498984396c7..d0513b72cdaec3b67b9341d251367b193bafa40c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -28,6 +29,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index b11f51762ca289d99eaa49e66e31e58595bcea4e..06adfdc61f1064c1ec0db34632a8740fc09a1782 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -6,6 +6,7 @@ import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -56,6 +57,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..db3a4a8cd19da9775bb0884c33494f1e8591b1fa 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -60,6 +61,17 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
public boolean opened;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors start - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.itemStacks) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.itemStacks.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return this.itemStacks;
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 17 May 2022 05:57:52 +0100
|
||||
Subject: [PATCH] Don't log invalid teams to console
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4bd7eea49a0720063db2a8ed10f53bd19e9499ad..953c2702880b358c0da4b8117c77b76bae849271 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -861,7 +861,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
boolean flag = scoreboardteam != null && this.level().getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||
|
||||
if (!flag) {
|
||||
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
||||
+ // Scissors - Prevent log spam possible with this error message, easily provokable by players in creative.
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Fri, 19 Aug 2022 00:49:38 -0600
|
||||
Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
index 66cf0a6cd1525ecf2615809210a26d55f445d07d..74fb79d4ea11f88f2c0de65b492a5fecc49684f1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
@@ -270,6 +270,13 @@ public abstract class HangingEntity extends Entity {
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
BlockPos blockposition = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
||||
|
||||
+ // Scissors start - Fixes exploit where bad TileX, TileY, and TileZ coordinates can crash servers
|
||||
+ if (level().isLoadedAndInBounds(blockposition))
|
||||
+ {
|
||||
+ this.pos = blockposition;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (!blockposition.closerThan(this.blockPosition(), 16.0D)) {
|
||||
HangingEntity.LOGGER.error("Hanging entity at invalid position: {}", blockposition);
|
||||
} else {
|
@ -1,158 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 4 Jul 2022 22:12:19 +0100
|
||||
Subject: [PATCH] Add MasterBlockFireEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..0ae03d3934ad7b2b38afa45a65c7753dcbe796d2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -25,6 +26,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
+import org.bukkit.Location; // Scissors
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
@@ -117,6 +119,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
}
|
||||
|
||||
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
||||
+ // Scissors start - Add master block fire event
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (hasCommand) {
|
||||
executor.performCommand(world);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
index 182e16c1d968707a11329150d71b7d01df6c6e52..8582a9369cffe0eebeb82a81fc413d0bf4ad28ed 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world.level.block.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -17,6 +18,7 @@ import net.minecraft.world.level.block.JigsawBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
+import org.bukkit.Location; // Scissors
|
||||
|
||||
public class JigsawBlockEntity extends BlockEntity {
|
||||
public static final String TARGET = "target";
|
||||
@@ -107,6 +109,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||
+ // Scissors start - Add master block fire event
|
||||
+ final BlockPos pos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front());
|
||||
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
|
||||
// Paper start - Replace getHolderOrThrow with a null check
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
index 9792bf3ee083f571f1f4089d30beb586839f5f6b..fa6592cdc916d3578fccc6c0075eb616fd3f73eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
@@ -5,6 +5,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -29,6 +30,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
+import org.bukkit.Location; // Scissors
|
||||
|
||||
public class StructureBlockEntity extends BlockEntity {
|
||||
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
|
||||
@@ -264,7 +266,7 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
- int i = 80;
|
||||
+ // Scissors - Obfuscation fixes
|
||||
BlockPos blockPos2 = new BlockPos(blockPos.getX() - 80, this.level.getMinBuildHeight(), blockPos.getZ() - 80);
|
||||
BlockPos blockPos3 = new BlockPos(blockPos.getX() + 80, this.level.getMaxBuildHeight() - 1, blockPos.getZ() + 80);
|
||||
Stream<BlockPos> stream = this.getRelatedCorners(blockPos2, blockPos3);
|
||||
@@ -321,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean saveStructure(boolean bl) {
|
||||
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
|
||||
+ // Scissors start - Add master block fire event
|
||||
+ final BlockPos pos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
||||
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl) {
|
||||
if (this.mode == StructureMode.LOAD && this.structureName != null) {
|
||||
+ // Scissors start - Add master block fire event
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
StructureTemplateManager structureTemplateManager = world.getStructureManager();
|
||||
|
||||
Optional<StructureTemplate> optional;
|
||||
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void unloadStructure() {
|
||||
+ // Scissors start - Add master block fire event
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.structureName != null) {
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
@ -1,32 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 5 Jul 2022 04:12:31 +0100
|
||||
Subject: [PATCH] Add spectator teleport event
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 3c0651fa5a5db880202c9a3805a6455269c5f16d..d7ddd44fb9b571850515edc6ee2e6801092f6446 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
@@ -2113,6 +2114,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
+ // Scissors start - Add spectator teleport event
|
||||
+ final SpectatorTeleportEvent event = new SpectatorTeleportEvent(this.player.getBukkitEntity(), entity.getBukkitEntity());
|
||||
+
|
||||
+ if(!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
|
||||
return;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
||||
Subject: [PATCH] Prevent invalid container events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index bf7cf2108c0273552a41a9734dfd66b6a68a24d4..1c102fa91711ed595626633e127c89a83ed6b6c5 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -30,6 +30,7 @@ import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor; // Scissors
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -3037,6 +3038,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
+ .color(NamedTextColor.RED)
|
||||
+ );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
||||
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
||||
|
@ -1,73 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:29:03 +0100
|
||||
Subject: [PATCH] Disable running commands in books by default
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
index 31911c09fe15753ae32fa39417bdc9e9de552a88..b810a5afcb2343174e37efb7dd8a36b968b07c3a 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world.item;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -9,8 +10,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.ComponentUtils;
|
||||
+import net.minecraft.network.chat.*; // Scissors
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -161,9 +161,43 @@ public class WrittenBookItem extends Item {
|
||||
component2 = Component.literal(text);
|
||||
}
|
||||
|
||||
- return Component.Serializer.toJson(component2);
|
||||
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
|
||||
}
|
||||
|
||||
+ // Scissors start - Allow server owners to disable run command in books
|
||||
+ public static Component sanitize(Component component, int depth)
|
||||
+ {
|
||||
+ if (depth > 128)
|
||||
+ {
|
||||
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
|
||||
+ }
|
||||
+
|
||||
+ MutableComponent component2 = component.copy();
|
||||
+
|
||||
+ final Style style = component2.getStyle();
|
||||
+ final ClickEvent clickEvent = style.getClickEvent();
|
||||
+
|
||||
+ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
|
||||
+ {
|
||||
+ final String clickEventValue = clickEvent.getValue();
|
||||
+
|
||||
+ component2 = component2.copy().setStyle(style
|
||||
+ .withClickEvent(null)
|
||||
+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran" : "said") + ": " + clickEvent.getValue())))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ final List<Component> processedExtra = component2.getSiblings()
|
||||
+ .stream()
|
||||
+ .map(comp -> sanitize(comp, depth + 1))
|
||||
+ .toList();
|
||||
+ component2.getSiblings().clear();
|
||||
+ component2.getSiblings().addAll(processedExtra);
|
||||
+
|
||||
+ return component2;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return true;
|
@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 11 Jul 2022 17:29:12 -0300
|
||||
Subject: [PATCH] Validate block entity/entity tag query positions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 3c4825e295eefc7fcd628ba804fcc7dd5f160f28..280ebeee9bfae3059b6681873fa5633a9e929161 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1376,7 +1376,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (this.player.hasPermissions(2)) {
|
||||
Entity entity = this.player.level().getEntity(packet.getEntityId());
|
||||
|
||||
- if (entity != null) {
|
||||
+ if (entity != null && this.player.distanceToSqr(entity.position().x, entity.position().y, entity.position().z) < 32 * 32) { // Scissors - Validate entity tag query positions
|
||||
CompoundTag nbttagcompound = entity.saveWithoutId(new CompoundTag());
|
||||
|
||||
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));
|
||||
@@ -1388,7 +1388,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.hasPermissions(2)) {
|
||||
+ // Scissors start - Validate block entity tag query positions
|
||||
+ if (this.player.hasPermissions(2) && this.player.level().isLoadedAndInBounds(packet.getPos())
|
||||
+ && this.player.distanceToSqr(packet.getPos().getX(), packet.getPos().getY(), packet.getPos().getZ()) < 32 * 32) {
|
||||
+ // Scissors end
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
|
||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||
|
@ -1,67 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 13 Jul 2022 12:13:22 +0100
|
||||
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index f356196aaeb498a6d2c9ad2112329cef5a3103d6..a8d8445be1cfb67de1adcaf64847d0bfaf8c503d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -8,8 +8,10 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.UnaryOperator;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.commands.Commands; // Scissors
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
@@ -19,6 +21,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
+import net.minecraft.server.MinecraftServer; // Scissors
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.FilteredText;
|
||||
@@ -30,6 +33,7 @@ import net.minecraft.world.level.block.SignBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity; // Scissors
|
||||
import org.slf4j.Logger;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
@@ -37,6 +41,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
// CraftBukkit end
|
||||
+import org.bukkit.craftbukkit.CraftServer; // Scissors
|
||||
|
||||
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
||||
|
||||
@@ -291,6 +296,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
}
|
||||
player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
||||
// Paper end
|
||||
+ // Scissors start - Add optional permissions to command signs
|
||||
+ final MinecraftServer vanillaServer = player.getServer();
|
||||
+ final CraftServer craftServer = vanillaServer.server;
|
||||
+ final CraftHumanEntity craftPlayer = player.getBukkitEntity();
|
||||
+ final Commands commands = vanillaServer.getCommands();
|
||||
+
|
||||
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
||||
+ {
|
||||
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
||||
+ }
|
||||
+ // Scissors end
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
@ -5,23 +5,38 @@ Subject: [PATCH] Patch large selector distance crash
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
index 60d32afe2eecdfebdc91531ca3672f8f130ac30e..73b0f516f80ef810379860ea74697a3429c646e5 100644
|
||||
index 8897496323378080135127f53db004d576476c21..109fbcddd1814013692b1200d37fea09d069cfd5 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
@@ -177,7 +177,7 @@ public abstract class MinMaxBounds<T extends Number> {
|
||||
return value == null ? null : value * value;
|
||||
@@ -131,7 +131,7 @@ public interface MinMaxBounds<T extends Number> {
|
||||
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
|
||||
public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
|
||||
|
||||
- private Doubles(Optional<Double> optional, Optional<Double> optional2) {
|
||||
+ public Doubles(Optional<Double> optional, Optional<Double> optional2) {
|
||||
this(optional, optional2, squareOpt(optional), squareOpt(optional2));
|
||||
}
|
||||
|
||||
- private Doubles(@Nullable Double min, @Nullable Double max) {
|
||||
+ public Doubles(@Nullable Double min, @Nullable Double max) { // Scissors - private -> public
|
||||
super(min, max);
|
||||
this.minSq = squareOpt(min);
|
||||
this.maxSq = squareOpt(max);
|
||||
@@ -143,7 +143,7 @@ public interface MinMaxBounds<T extends Number> {
|
||||
}
|
||||
}
|
||||
|
||||
- private static Optional<Double> squareOpt(Optional<Double> optional) {
|
||||
+ public static Optional<Double> squareOpt(Optional<Double> optional) {
|
||||
return optional.map((double_) -> {
|
||||
return double_ * double_;
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..e8cf963f0190438bbf65f827d144775ab0b02b63 100644
|
||||
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..ef54de7a77cda9793c723ce58403fb1a610a7956 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -10,6 +10,7 @@ import java.util.function.BiConsumer;
|
||||
@@ -5,11 +5,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
+import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
@ -29,7 +44,7 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..e8cf963f0190438bbf65f827d144775a
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -60,9 +61,27 @@ public class EntitySelector {
|
||||
@@ -60,9 +62,27 @@ public class EntitySelector {
|
||||
this.includesEntities = includesNonPlayers;
|
||||
this.worldLimited = localWorldOnly;
|
||||
this.predicate = basePredicate;
|
||||
@ -37,8 +52,8 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..e8cf963f0190438bbf65f827d144775a
|
||||
+
|
||||
+ // Scissors start - Patch large selector distance crash
|
||||
+ this.range = new MinMaxBounds.Doubles(
|
||||
+ distance.getMin() != null ? Math.min(distance.getMin(), 1024) : null,
|
||||
+ distance.getMax() != null ? Math.min(distance.getMax(), 1024) : null
|
||||
+ distance.min().isPresent() ? Optional.of(Math.min(distance.min().get(), 1024)) : null,
|
||||
+ distance.max().isPresent() ? Optional.of(Math.min(distance.max().get(), 1024)) : null
|
||||
+ );
|
||||
this.position = positionOffset;
|
||||
- this.aabb = box;
|
@ -1,18 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 16 Aug 2022 17:13:02 +0100
|
||||
Subject: [PATCH] Refuse to convert legacy messages over 1k characters
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..c006ac8531cf2c029fd2fac449f96736a4afed0d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -199,6 +199,7 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
||||
+ if (message.length() > 1_000) return new Component[]{Component.empty()}; // Scissors - Refuse to convert legacy messages over 1k characters
|
||||
return new StringMessage(message, keepNewlines, plain).getOutput();
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 27 Nov 2022 05:14:18 +0000
|
||||
Subject: [PATCH] Prevent velocity freeze
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
index 6c9a8f062f989db022154155e8a05b334a0510da..978fad27ad17de03d108ade2c2bfa464b7d83491 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.entity.projectile;
|
||||
|
||||
+import me.totalfreedom.scissors.MathUtility; // Scissors
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -41,9 +42,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
if (d6 != 0.0D) {
|
||||
- this.xPower = d3 / d6 * 0.1D;
|
||||
- this.yPower = d4 / d6 * 0.1D;
|
||||
- this.zPower = d5 / d6 * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = d3 / d6 * 0.1D;
|
||||
+ //this.yPower = d4 / d6 * 0.1D;
|
||||
+ //this.zPower = d5 / d6 * 0.1D;
|
||||
+
|
||||
+ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d);
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,6 +146,25 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower}));
|
||||
}
|
||||
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ public void setPower(double xPower, double yPower, double zPower)
|
||||
+ {
|
||||
+ if (Double.isInfinite(xPower) || Double.isInfinite(yPower) || Double.isInfinite(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (Double.isNaN(xPower) || Double.isNaN(yPower) || Double.isNaN(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.xPower = MathUtility.clampDouble(xPower, -1024, 1024);
|
||||
+ this.yPower = MathUtility.clampDouble(yPower, -1024, 1024);
|
||||
+ this.zPower = MathUtility.clampDouble(zPower, -1024, 1024);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
@@ -148,9 +172,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
ListTag nbttaglist = nbt.getList("power", 6);
|
||||
|
||||
if (nbttaglist.size() == 3) {
|
||||
- this.xPower = nbttaglist.getDouble(0);
|
||||
- this.yPower = nbttaglist.getDouble(1);
|
||||
- this.zPower = nbttaglist.getDouble(2);
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = nbttaglist.getDouble(0);
|
||||
+ //this.yPower = nbttaglist.getDouble(1);
|
||||
+ //this.zPower = nbttaglist.getDouble(2);
|
||||
+
|
||||
+ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2));
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +212,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
Vec3 vec3d = entity.getLookAngle();
|
||||
|
||||
this.setDeltaMovement(vec3d);
|
||||
- this.xPower = vec3d.x * 0.1D;
|
||||
- this.yPower = vec3d.y * 0.1D;
|
||||
- this.zPower = vec3d.z * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = vec3d.x * 0.1D;
|
||||
+ //this.yPower = vec3d.y * 0.1D;
|
||||
+ //this.zPower = vec3d.z * 0.1D;
|
||||
+
|
||||
+ setPower(vec3d.x * 0.1D, vec3d.y * 0.1D, vec3d.z * 0.1D);
|
||||
+ // Scissors end
|
||||
this.setOwner(entity);
|
||||
}
|
||||
|
@ -1,105 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 31 Jan 2023 23:16:52 +0000
|
||||
Subject: [PATCH] Add configuration option to disable chat signatures
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..516c61cbb8299828b2f28d4564d08ae1829649b5 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.network.chat;
|
||||
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public interface OutgoingChatMessage {
|
||||
@@ -44,10 +45,21 @@ public interface OutgoingChatMessage {
|
||||
// Paper end
|
||||
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
||||
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
||||
- if (!playerChatMessage.isFullyFiltered()) {
|
||||
+ // Scissors start
|
||||
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
|
||||
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
|
||||
+ return;
|
||||
}
|
||||
|
||||
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
|
||||
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
|
||||
+ null,
|
||||
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
|
||||
+ unsigned,
|
||||
+ playerChatMessage.filterMask(),
|
||||
+ playerChatMessage.result()
|
||||
+ ), params);
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
index c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47c5312c6c 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.util.SignatureUpdater;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
import net.minecraft.util.Signer;
|
||||
@@ -41,7 +42,7 @@ public class SignedMessageChain {
|
||||
if (!playerChatMessage.verify(signatureValidator)) {
|
||||
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
|
||||
} else {
|
||||
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
|
||||
+ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) { // Scissors
|
||||
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", (Object)body.content());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 562289bbe08b8d8e75436ad94cfc02e7c0e95d2e..a98134b3b59e194c03bb8110652a9208263c420d 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
@@ -2368,7 +2369,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
- if (exception.shouldDisconnect()) {
|
||||
+ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled
|
||||
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
|
||||
} else {
|
||||
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
|
||||
@@ -2424,6 +2425,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
|
||||
|
||||
if (optional.isEmpty()) {
|
||||
+ if (!ScissorsConfig.chatSignaturesEnabled) return optional; // Scissors
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
||||
}
|
||||
@@ -2632,6 +2634,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
synchronized (this.lastSeenMessages) {
|
||||
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
||||
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
||||
}
|
||||
@@ -3673,6 +3676,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
|
||||
RemoteChatSession.Data remotechatsession_a = packet.chatSession();
|
||||
ProfilePublicKey.Data profilepublickey_a = this.chatSession != null ? this.chatSession.profilePublicKey().data() : null;
|
||||
ProfilePublicKey.Data profilepublickey_a1 = remotechatsession_a.profilePublicKey();
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 20 Mar 2023 07:04:50 +0000
|
||||
Subject: [PATCH] Patch invalid entity rotation log spam
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 842f8af14b2bd694a48ee6573d98e6cfcf910e16..e9e98f09e13d7f21333450d892cdc80b0667c915 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4617,7 +4617,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
public void setXRot(float pitch) {
|
||||
if (!Float.isFinite(pitch)) {
|
||||
- Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding.");
|
||||
+ // Scissors - Patch invalid entity rotation log spam
|
||||
} else {
|
||||
this.xRot = pitch;
|
||||
}
|
Reference in New Issue
Block a user