Folia/patches/server/0008-Throw-UnsupportedOperationException-for-broken-APIs.patch
Spottedleaf 4a59238743 Update to 1.20.2
Very early build, network configuration switching is supported
but not tested (note: changes need to be backported to Paper)

Changes:
 - Supports per player mob caps
 - Adds entity tracker optimisations which are not in Paper
   (and will not be ported to Paper due to plugin conflicts)
 - No longer reverts paper distance map optimisations, as
   those are replaced by the NearbyPlayers class

These changes should bring Folia in-line with Paper's optimisations
at least (probably more given the entity tracker optimisations),
still missing features like world loading / some commands
2023-09-26 13:28:33 -07:00

75 lines
5.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Wed, 22 Mar 2023 14:40:24 -0700
Subject: [PATCH] Throw UnsupportedOperationException() for broken APIs
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7d35722cbf2da92fb0fb8a6306f18472f2499595..249ff636a40f6493444a6ea8b8a5e017cb2c30eb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1266,6 +1266,7 @@ public final class CraftServer implements Server {
@Override
public World createWorld(WorldCreator creator) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not implemented properly yet
Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP");
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
@@ -1407,6 +1408,7 @@ public final class CraftServer implements Server {
@Override
public boolean unloadWorld(World world, boolean save) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not implemented properly yet
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot unload a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
if (world == null) {
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
index a8c5bfc54ed2b8bd873f124c7080d73fe73a86ad..f59e9e6dd21a7d034b5e3b6e7787458d3c3c7bbc 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
@@ -43,6 +43,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
}
@Override
public CraftObjective registerNewObjective(String name, Criteria criteria, net.kyori.adventure.text.Component displayName, RenderType renderType) throws IllegalArgumentException {
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
if (displayName == null) {
displayName = net.kyori.adventure.text.Component.empty();
}
@@ -198,6 +199,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
@Override
public Team registerNewTeam(String name) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
Preconditions.checkArgument(name != null, "Team name cannot be null");
Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "Team name '%s' is longer than the limit of 32767 characters (%s)", name, name.length());
Preconditions.checkArgument(this.board.getPlayerTeam(name) == null, "Team name '%s' is already in use", name);
@@ -225,6 +227,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
@Override
public void clearSlot(DisplaySlot slot) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
Preconditions.checkArgument(slot != null, "Slot cannot be null");
this.board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
index 7a2f46579352870cfbb32c343d7c68919758ffe3..7fb12a9124a8436f87028269599c40ccf5b1b78f 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
@@ -42,6 +42,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
@Override
public CraftScoreboard getNewScoreboard() {
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
org.spigotmc.AsyncCatcher.catchOp("scoreboard creation"); // Spigot
CraftScoreboard scoreboard = new CraftScoreboard(new ServerScoreboard(this.server));
// Paper start
@@ -68,6 +69,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
// CraftBukkit method
public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
Preconditions.checkArgument(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard");
CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard;