2023-03-23 10:51:04 +01:00
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
2024-08-24 22:13:45 +02:00
index 454cac11619fc1e8317db0b95a174f6747af6e60..39e4493ef5c7d4bfd903da18b76e14235a535ab5 100644
2023-03-23 10:51:04 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2024-07-31 05:09:52 +02:00
@@ -1310,6 +1310,7 @@ public final class CraftServer implements Server {
2023-03-23 10:51:04 +01:00
@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.
2023-06-13 23:24:31 +02:00
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
2024-07-31 05:09:52 +02:00
@@ -1488,6 +1489,7 @@ public final class CraftServer implements Server {
2023-03-23 10:51:04 +01:00
@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
2024-01-21 05:33:21 +01:00
index 253574890a9ed23d38a84680ba1eb221dc72b310..ce8b91f00f925960ad17f381162a11294e8b511d 100644
2023-03-23 10:51:04 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
2023-12-17 00:32:48 +01:00
@@ -45,6 +45,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
2023-03-23 10:51:04 +01:00
}
@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();
}
2023-12-17 00:32:48 +01:00
@@ -204,6 +205,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
2023-03-23 10:51:04 +01:00
@Override
2023-08-10 00:34:49 +02:00
public Team registerNewTeam(String name) {
2023-03-23 10:51:04 +01:00
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
2023-06-13 23:24:31 +02:00
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);
2023-12-17 00:32:48 +01:00
@@ -231,6 +233,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
2023-03-23 10:51:04 +01:00
@Override
2023-08-10 00:34:49 +02:00
public void clearSlot(DisplaySlot slot) {
2023-03-23 10:51:04 +01:00
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
2023-06-13 23:24:31 +02:00
Preconditions.checkArgument(slot != null, "Slot cannot be null");
2023-03-23 10:51:04 +01:00
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
2023-12-17 00:32:48 +01:00
index b3e1adeb932da9b3bed16acd94e2f16da48a7c72..46a8262f21ef95714c122240ee86f01858010047 100644
2023-03-23 10:51:04 +01:00
--- 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
2023-08-10 00:34:49 +02:00
public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) {
2023-03-23 10:51:04 +01:00
+ if (true) throw new UnsupportedOperationException(); // Folia - not supported yet
2023-06-13 23:24:31 +02:00
Preconditions.checkArgument(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard");
2023-03-23 10:51:04 +01:00
CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard;