mirror of
https://github.com/PaperMC/Folia.git
synced 2025-04-23 04:39:19 +08:00
Remove patches specific for stream
Specifically, the /msg and /me command removal and the operator only chat. Additionally, remove the TPA commands.
This commit is contained in:
parent
ee737050a0
commit
0911c7a58a
@ -3217,17 +3217,14 @@ index 92154550b41b2e1d03deb1271b71bb3baa735e0a..bc97ad0ae019edb52e189e44d0d69897
|
|||||||
|
|
||||||
return commands.entrySet().stream()
|
return commands.entrySet().stream()
|
||||||
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||||
index d31b5ed47cffc61c90c926a0cd2005b72ebddfc5..9b9c5bda073914a0588d4a6c8b584e5ce23468d8 100644
|
index d31b5ed47cffc61c90c926a0cd2005b72ebddfc5..0bc4ba2b8718d399223fdf10b970c0fcf4cf28b7 100644
|
||||||
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
|
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||||
@@ -17,7 +17,10 @@ public final class PaperCommands {
|
@@ -17,7 +17,7 @@ public final class PaperCommands {
|
||||||
private static final Map<String, Command> COMMANDS = new HashMap<>();
|
private static final Map<String, Command> COMMANDS = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
COMMANDS.put("paper", new PaperCommand("paper"));
|
COMMANDS.put("paper", new PaperCommand("paper"));
|
||||||
- COMMANDS.put("mspt", new MSPTCommand("mspt"));
|
- COMMANDS.put("mspt", new MSPTCommand("mspt"));
|
||||||
+ COMMANDS.put("tpa", new io.papermc.paper.threadedregions.commands.CommandsTPA()); // Folia - region threading
|
|
||||||
+ COMMANDS.put("tpaaccept", new io.papermc.paper.threadedregions.commands.CommandsTPAAccept()); // Folia - region threading
|
|
||||||
+ COMMANDS.put("tpadeny", new io.papermc.paper.threadedregions.commands.CommandsTPADeny()); // Folia - region threading
|
|
||||||
+ COMMANDS.put("tps", new io.papermc.paper.threadedregions.commands.CommandServerHealth()); // Folia - region threading
|
+ COMMANDS.put("tps", new io.papermc.paper.threadedregions.commands.CommandServerHealth()); // Folia - region threading
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8880,370 +8877,6 @@ index 0000000000000000000000000000000000000000..d016294fc7eafbddf6d2a758e5803498
|
|||||||
+
|
+
|
||||||
+ private CommandUtil() {}
|
+ private CommandUtil() {}
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPA.java b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPA.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..2861e0a2e1182bc8fd142acbf63facbcf6a392dc
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPA.java
|
|
||||||
@@ -0,0 +1,138 @@
|
|
||||||
+package io.papermc.paper.threadedregions.commands;
|
|
||||||
+
|
|
||||||
+import net.kyori.adventure.text.Component;
|
|
||||||
+import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
+import net.kyori.adventure.text.event.HoverEvent;
|
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
+import org.bukkit.command.Command;
|
|
||||||
+import org.bukkit.command.CommandSender;
|
|
||||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
||||||
+import java.util.ArrayList;
|
|
||||||
+import java.util.List;
|
|
||||||
+import java.util.function.Function;
|
|
||||||
+
|
|
||||||
+public final class CommandsTPA extends Command {
|
|
||||||
+
|
|
||||||
+ public CommandsTPA() {
|
|
||||||
+ super("tpa");
|
|
||||||
+ this.setUsage("/<command> <player name>");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean testPermissionSilent(final CommandSender target) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
|
||||||
+ if (!(sender instanceof CraftPlayer playerSender)) {
|
|
||||||
+ sender.sendMessage(commandLabel + " only works for players");
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (args.length != 1) {
|
|
||||||
+ sender.sendMessage(Component.text("Usage: /" + commandLabel + " <player name>", NamedTextColor.DARK_RED));
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final ServerPlayer target = CommandUtil.getPlayer(args[0]);
|
|
||||||
+
|
|
||||||
+ if (target == null) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Found no such player ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(args[0], NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (target == playerSender.getHandle()) {
|
|
||||||
+ sender.sendMessage(Component.text("Cannot tpa to yourself!", NamedTextColor.DARK_RED));
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final String targetName = target.getGameProfile().getName();
|
|
||||||
+
|
|
||||||
+ if (!target.pendingTpas.add(playerSender.getUniqueId())) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("You already have a tpa request to ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(targetName, NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Sent tpa request to ", NamedTextColor.GRAY))
|
|
||||||
+ .append(Component.text(targetName, NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ target.getBukkitEntity().sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.RED))
|
|
||||||
+ .append(Component.text(" has requested to teleport to you!\n", NamedTextColor.GRAY))
|
|
||||||
+ .append(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Run or click ", NamedTextColor.GRAY))
|
|
||||||
+ .append(Component.text("/tpaaccept ", NamedTextColor.DARK_GREEN))
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.GREEN))
|
|
||||||
+ .append(Component.text(" to accept\n", NamedTextColor.GRAY))
|
|
||||||
+ .build()
|
|
||||||
+ .clickEvent(ClickEvent.runCommand("/tpaaccept " + playerSender.getName()))
|
|
||||||
+ .hoverEvent(
|
|
||||||
+ HoverEvent.showText(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Click to accept tpa request from ", NamedTextColor.DARK_GREEN))
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.GREEN))
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ .append(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Run or click ", NamedTextColor.GRAY))
|
|
||||||
+ .append(Component.text("/tpadeny ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.RED))
|
|
||||||
+ .append(Component.text(" to deny", NamedTextColor.GRAY))
|
|
||||||
+ .build()
|
|
||||||
+ .clickEvent(ClickEvent.runCommand("/tpadeny " + playerSender.getName()))
|
|
||||||
+ .hoverEvent(
|
|
||||||
+ HoverEvent.showText(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Click to reject tpa request from ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.RED))
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public List<String> tabComplete(final CommandSender sender, final String alias,
|
|
||||||
+ final String[] args) throws IllegalArgumentException {
|
|
||||||
+ if (!(sender instanceof CraftPlayer)) {
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final List<ServerPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
|
||||||
+
|
|
||||||
+ final Function<ServerPlayer, String> playerToName = (final ServerPlayer value) -> {
|
|
||||||
+ return value.getGameProfile().getName();
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ if (args.length == 0) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName);
|
|
||||||
+ } else if (args.length == 1) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName, args[0]);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPAAccept.java b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPAAccept.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..b648d67f3ade11172af4ed76d6d14de7ca39c5d6
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPAAccept.java
|
|
||||||
@@ -0,0 +1,109 @@
|
|
||||||
+package io.papermc.paper.threadedregions.commands;
|
|
||||||
+
|
|
||||||
+import io.papermc.paper.threadedregions.TeleportUtils;
|
|
||||||
+import net.kyori.adventure.text.Component;
|
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
+import net.minecraft.world.entity.Entity;
|
|
||||||
+import org.bukkit.command.Command;
|
|
||||||
+import org.bukkit.command.CommandSender;
|
|
||||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
||||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
+import java.util.ArrayList;
|
|
||||||
+import java.util.List;
|
|
||||||
+import java.util.function.Function;
|
|
||||||
+
|
|
||||||
+public final class CommandsTPAAccept extends Command {
|
|
||||||
+
|
|
||||||
+ public CommandsTPAAccept() {
|
|
||||||
+ super("tpaaccept");
|
|
||||||
+ this.setUsage("/<command> <player name>");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean testPermissionSilent(final CommandSender target) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
|
||||||
+ if (!(sender instanceof CraftPlayer playerSender)) {
|
|
||||||
+ sender.sendMessage(commandLabel + " only works for players");
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (args.length != 1) {
|
|
||||||
+ sender.sendMessage(Component.text("Usage: /" + commandLabel + " <player name>", NamedTextColor.DARK_RED));
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final ServerPlayer target = CommandUtil.getPlayer(args[0]);
|
|
||||||
+
|
|
||||||
+ if (target == null) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Found no such player ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(args[0], NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!playerSender.getHandle().pendingTpas.remove(target.getUUID())) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("No tpa request to accept from ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(args[0], NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Accepted tpa request from ", NamedTextColor.GRAY))
|
|
||||||
+ .append(Component.text(target.getGameProfile().getName(), NamedTextColor.GREEN))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ target.getBukkitEntity().sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.GREEN))
|
|
||||||
+ .append(Component.text(" accepted", NamedTextColor.DARK_GREEN))
|
|
||||||
+ .append(Component.text(" your tpa request!", NamedTextColor.GRAY))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+
|
|
||||||
+ TeleportUtils.teleport(
|
|
||||||
+ target, true, playerSender.getHandle(),
|
|
||||||
+ Float.valueOf(playerSender.getHandle().getYRot()), Float.valueOf(playerSender.getHandle().getXRot()),
|
|
||||||
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
|
|
||||||
+ PlayerTeleportEvent.TeleportCause.COMMAND, null
|
|
||||||
+ );
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public List<String> tabComplete(final CommandSender sender, final String alias,
|
|
||||||
+ final String[] args) throws IllegalArgumentException {
|
|
||||||
+ if (!(sender instanceof CraftPlayer playerSender)) {
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final List<ServerPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
|
||||||
+
|
|
||||||
+ // The laziest implementation possible.
|
|
||||||
+ final Function<ServerPlayer, String> playerToName = (final ServerPlayer value) -> {
|
|
||||||
+ return playerSender.getHandle().pendingTpas.contains(value.getUUID()) ? value.getGameProfile().getName() : null;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ if (args.length == 0) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName);
|
|
||||||
+ } else if (args.length == 1) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName, args[0]);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPADeny.java b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPADeny.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..5bf205d8c0a03ba932be85cc1a63d6cea304b517
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/threadedregions/commands/CommandsTPADeny.java
|
|
||||||
@@ -0,0 +1,99 @@
|
|
||||||
+package io.papermc.paper.threadedregions.commands;
|
|
||||||
+
|
|
||||||
+import net.kyori.adventure.text.Component;
|
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
+import org.bukkit.command.Command;
|
|
||||||
+import org.bukkit.command.CommandSender;
|
|
||||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
||||||
+import java.util.ArrayList;
|
|
||||||
+import java.util.List;
|
|
||||||
+import java.util.function.Function;
|
|
||||||
+
|
|
||||||
+public final class CommandsTPADeny extends Command {
|
|
||||||
+
|
|
||||||
+ public CommandsTPADeny() {
|
|
||||||
+ super("tpadeny");
|
|
||||||
+ this.setUsage("/<command> <player name>");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean testPermissionSilent(final CommandSender target) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
|
||||||
+ if (!(sender instanceof CraftPlayer playerSender)) {
|
|
||||||
+ sender.sendMessage(commandLabel + " only works for players");
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (args.length != 1) {
|
|
||||||
+ sender.sendMessage(Component.text("Usage: /" + commandLabel + " <player name>", NamedTextColor.DARK_RED));
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final ServerPlayer target = CommandUtil.getPlayer(args[0]);
|
|
||||||
+
|
|
||||||
+ if (target == null) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Found no such player ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(args[0], NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!playerSender.getHandle().pendingTpas.remove(target.getUUID())) {
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("No tpa request to reject from ", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(args[0], NamedTextColor.RED))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text("Rejected tpa request from ", NamedTextColor.GRAY))
|
|
||||||
+ .append(Component.text(target.getGameProfile().getName(), NamedTextColor.GREEN))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+ target.getBukkitEntity().sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text(playerSender.getName(), NamedTextColor.RED))
|
|
||||||
+ .append(Component.text(" rejected", NamedTextColor.DARK_RED))
|
|
||||||
+ .append(Component.text(" your tpa request!", NamedTextColor.GRAY))
|
|
||||||
+ .build()
|
|
||||||
+ );
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public List<String> tabComplete(final CommandSender sender, final String alias,
|
|
||||||
+ final String[] args) throws IllegalArgumentException {
|
|
||||||
+ if (!(sender instanceof CraftPlayer playerSender)) {
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final List<ServerPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
|
||||||
+
|
|
||||||
+ // The laziest implementation possible.
|
|
||||||
+ final Function<ServerPlayer, String> playerToName = (final ServerPlayer value) -> {
|
|
||||||
+ return playerSender.getHandle().pendingTpas.contains(value.getUUID()) ? value.getGameProfile().getName() : null;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ if (args.length == 0) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName);
|
|
||||||
+ } else if (args.length == 1) {
|
|
||||||
+ return CommandUtil.getSortedList(players, playerToName, args[0]);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return new ArrayList<>();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaEntityScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaEntityScheduler.java
|
diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaEntityScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaEntityScheduler.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..c0b9f43fc53a5c9b3d9788f080e4fd3f4f94ebfe
|
index 0000000000000000000000000000000000000000..c0b9f43fc53a5c9b3d9788f080e4fd3f4f94ebfe
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
||||||
Date: Thu, 9 Mar 2023 19:46:04 -0800
|
|
||||||
Subject: [PATCH] Stream mode
|
|
||||||
|
|
||||||
We need to disable chat for the public test, because people
|
|
||||||
will want to play "get x banned from twitch any %"
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
||||||
index 22f06033a731c3ba1b815842be7a9d575fa820f2..93262f2ade2e9f70377bbf9acfe1a02e741e68d4 100644
|
|
||||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
||||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
|
||||||
@@ -138,7 +138,7 @@ public class Commands {
|
|
||||||
this(); // CraftBukkit
|
|
||||||
AdvancementCommands.register(this.dispatcher);
|
|
||||||
AttributeCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
- ExecuteCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
+ ExecuteCommand.register(this.dispatcher, commandRegistryAccess); // Folia - stream mode
|
|
||||||
//BossBarCommands.register(this.dispatcher); // Folia - region threading - TODO
|
|
||||||
ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
//CloneCommands.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO
|
|
||||||
@@ -148,7 +148,7 @@ public class Commands {
|
|
||||||
DefaultGameModeCommands.register(this.dispatcher);
|
|
||||||
DifficultyCommand.register(this.dispatcher);
|
|
||||||
EffectCommands.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
- EmoteCommands.register(this.dispatcher);
|
|
||||||
+ //EmoteCommands.register(this.dispatcher); // Folia - stream mode
|
|
||||||
EnchantCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
ExperienceCommand.register(this.dispatcher);
|
|
||||||
FillCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
@@ -165,7 +165,7 @@ public class Commands {
|
|
||||||
ListPlayersCommand.register(this.dispatcher);
|
|
||||||
LocateCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
//LootCommand.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO later
|
|
||||||
- MsgCommand.register(this.dispatcher);
|
|
||||||
+ //MsgCommand.register(this.dispatcher); // Folia - stream mode
|
|
||||||
ParticleCommand.register(this.dispatcher, commandRegistryAccess);
|
|
||||||
PlaceCommand.register(this.dispatcher);
|
|
||||||
PlaySoundCommand.register(this.dispatcher);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
index 19b7bcb7a773d48580842cbd33e022c57f08f019..5f01b0c09df6ebcb32e076581e33075835deda35 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
@@ -2222,7 +2222,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
|
|
||||||
// Folia - region threading
|
|
||||||
} else {
|
|
||||||
- Optional<LastSeenMessages> optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages());
|
|
||||||
+ // Folia - stream mode
|
|
||||||
+ Optional<LastSeenMessages> optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages(), true); // Folia - disable chat
|
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
// this.server.submit(() -> { // CraftBukkit - async chat
|
|
||||||
@@ -2258,7 +2259,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper
|
|
||||||
// Folia - region threading
|
|
||||||
} else {
|
|
||||||
- Optional<LastSeenMessages> optional = this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages());
|
|
||||||
+ Optional<LastSeenMessages> optional = this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages(), false); // Folia - disable chat
|
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
this.player.getBukkitEntity().taskScheduler.schedule((ServerPlayer player) -> { // Folia - region threading
|
|
||||||
@@ -2335,14 +2336,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
- private Optional<LastSeenMessages> tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
|
|
||||||
+ private Optional<LastSeenMessages> tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment, boolean chat) { // Folia - stream mode
|
|
||||||
if (!this.updateChatOrder(timestamp)) {
|
|
||||||
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}': {} > {}", this.player.getName().getString(), message, this.lastChatTimeStamp.get().getEpochSecond(), timestamp.getEpochSecond()); // Paper
|
|
||||||
// Folia - region threading
|
|
||||||
this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event ca
|
|
||||||
// Folia - region threading
|
|
||||||
return Optional.empty();
|
|
||||||
- } else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
|
|
||||||
+ } else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN || (chat && !this.player.getBukkitEntity().isOp())) { // CraftBukkit - dead men tell no tales // Folia - stream mode
|
|
||||||
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
|
|
||||||
return Optional.empty();
|
|
||||||
} else {
|
|
Loading…
x
Reference in New Issue
Block a user