Folia/patches/server/0008-Throw-UnsupportedOpera...

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 a6ba1d101dc23b8c27a1498f3f0d21270dfcc18c..a8bf1f542ab20eb7c40c80b5e42b55982677373d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1284,6 +1284,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");
@@ -1425,6 +1426,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 500f2eb0df5a07637cd278c263e95592b0037eb6..7ab760a57d1305bc4dccec97526328972c2ddfc3 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;