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-03-24 21:44:25 +01:00
index 350fc61fd709453a86c9f7f6e4bccc434065cc35..9dd9e86a5f7f30ce37b906ebfe4bccad0e52577f 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-02-14 01:20:10 +01:00
@@ -1283,6 +1283,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-02-14 01:20:10 +01:00
@@ -1461,6 +1462,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;