Skip to content

Commit

Permalink
fix: Replace usage of deprecated SWorldBorder with new NmsWorldBorder
Browse files Browse the repository at this point in the history
SWorldBorder will be removed soon:tm:
  • Loading branch information
SpraxDev committed Mar 27, 2024
1 parent 211e6a0 commit e9642ad
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/craftaro/skyblock/api/utils/APIUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.craftaro.skyblock.api.utils;

import com.craftaro.core.world.SWorldBorder;
import com.craftaro.core.nms.world.NmsWorldBorder;
import com.craftaro.skyblock.api.island.IslandBorderColor;
import com.craftaro.skyblock.api.island.IslandUpgrade;
import com.craftaro.skyblock.api.island.IslandWorld;
Expand Down Expand Up @@ -191,26 +191,26 @@ public static com.craftaro.skyblock.api.island.IslandMessage fromImplementation(
return null;
}

public static SWorldBorder.Color toImplementation(IslandBorderColor color) {
public static NmsWorldBorder.BorderColor toImplementation(IslandBorderColor color) {
switch (color) {
case BLUE:
return SWorldBorder.Color.Blue;
return NmsWorldBorder.BorderColor.BLUE;
case GREEN:
return SWorldBorder.Color.Green;
return NmsWorldBorder.BorderColor.GREEN;
case RED:
return SWorldBorder.Color.Red;
return NmsWorldBorder.BorderColor.RED;
}

return null;
}

public static IslandBorderColor fromImplementation(SWorldBorder.Color color) {
public static IslandBorderColor fromImplementation(NmsWorldBorder.BorderColor color) {
switch (color) {
case Blue:
case BLUE:
return IslandBorderColor.BLUE;
case Green:
case GREEN:
return IslandBorderColor.GREEN;
case Red:
case RED:
return IslandBorderColor.RED;
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/craftaro/skyblock/island/Island.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.craftaro.skyblock.island;

import com.craftaro.core.compatibility.CompatibleBiome;
import com.craftaro.core.nms.world.NmsWorldBorder;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.utils.NumberUtils;
import com.craftaro.core.utils.PlayerUtils;
import com.craftaro.core.world.SWorldBorder;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.api.event.island.IslandBiomeChangeEvent;
import com.craftaro.skyblock.api.event.island.IslandLocationChangeEvent;
Expand Down Expand Up @@ -150,7 +150,7 @@ public Island(@Nonnull OfflinePlayer player) {

if (configLoad.getString("Border") == null) {
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", SWorldBorder.Color.Blue.name());
configLoad.set("Border.Color", NmsWorldBorder.BorderColor.BLUE.name());
}

if (configLoad.getString("Members") != null) {
Expand Down Expand Up @@ -246,7 +246,7 @@ public Island(@Nonnull OfflinePlayer player) {
configLoad.set("UUID", this.islandUUID.toString());
configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status").toUpperCase());
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", SWorldBorder.Color.Blue.name());
configLoad.set("Border.Color", NmsWorldBorder.BorderColor.BLUE.name());
configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase());
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); // TODO: Synchronized
configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time"));
Expand Down Expand Up @@ -449,13 +449,13 @@ public void setBorder(boolean border) {
.getFileConfiguration().set("Border.Enable", border);
}

public SWorldBorder.Color getBorderColor() {
return SWorldBorder.Color.valueOf(this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Border.Color"));
public NmsWorldBorder.BorderColor getBorderColor() {
String colorString = this.plugin.getFileManager().getConfig(new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Border.Color");
return NmsWorldBorder.BorderColor.valueOf(colorString.toUpperCase());
}

public void setBorderColor(SWorldBorder.Color color) {
public void setBorderColor(NmsWorldBorder.BorderColor color) {
this.plugin.getFileManager().getConfig(
new File(new File(this.plugin.getDataFolder(), "island-data"), this.ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Border.Color", color.name());
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/craftaro/skyblock/island/IslandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.craftaro.core.compatibility.CompatibleBiome;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.world.SWorldBorder;
import com.craftaro.core.nms.Nms;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.api.event.island.IslandCreateEvent;
import com.craftaro.skyblock.api.event.island.IslandDeleteEvent;
Expand Down Expand Up @@ -43,6 +41,8 @@
import com.craftaro.skyblock.utils.world.block.BlockDegreesType;
import com.craftaro.skyblock.visit.VisitManager;
import com.craftaro.skyblock.world.WorldManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.eatthepath.uuid.FastUUID;
import com.google.common.base.Preconditions;
import io.papermc.lib.PaperLib;
Expand Down Expand Up @@ -1511,10 +1511,10 @@ public void loadPlayer(Player player) {
if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) {
Location islandLocation = island.getLocation(worldManager.getIslandWorld(player.getWorld()), IslandEnvironment.ISLAND);
if (islandLocation != null) {
SWorldBorder.send(player, island.getBorderColor(), island.getSize(), islandLocation.clone().add(increment, 0, increment));
Nms.getImplementations().getWorldBorder().send(player, island.getBorderColor(), island.getSize(), islandLocation.clone().add(increment, 0, increment));
}
} else {
SWorldBorder.send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0));
Nms.getImplementations().getWorldBorder().send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0));
}
});
}
Expand Down Expand Up @@ -1666,7 +1666,7 @@ public void updateBorder(Island island) {
if (worldList != IslandWorld.NETHER || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
SWorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.ISLAND).clone().add(increment, 0, increment));
Nms.getImplementations().getWorldBorder().send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.ISLAND).clone().add(increment, 0, increment));
}
});
}
Expand All @@ -1678,7 +1678,7 @@ public void updateBorder(Island island) {
if (worldList != IslandWorld.NETHER || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(this.plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
SWorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
Nms.getImplementations().getWorldBorder().send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
}
});
}
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/com/craftaro/skyblock/menus/Border.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.craftaro.skyblock.menus;

import com.craftaro.core.nms.world.NmsWorldBorder;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.core.world.SWorldBorder;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.island.Island;
import com.craftaro.skyblock.island.IslandManager;
Expand Down Expand Up @@ -82,13 +82,13 @@ public void open(Player player) {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")))))) {
if (island.getBorderColor() == SWorldBorder.Color.Blue) {
if (island.getBorderColor() == NmsWorldBorder.BorderColor.BLUE) {
soundManager.playSound(player, XSound.ENTITY_CHICKEN_EGG);

event.setWillClose(false);
event.setWillDestroy(false);
} else {
island.setBorderColor(SWorldBorder.Color.Blue);
island.setBorderColor(NmsWorldBorder.BorderColor.BLUE);
islandManager.updateBorder(island);

soundManager.playSound(player, XSound.BLOCK_WOODEN_BUTTON_CLICK_ON);
Expand All @@ -100,13 +100,13 @@ public void open(Player player) {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")))))) {
if (island.getBorderColor() == SWorldBorder.Color.Green) {
if (island.getBorderColor() == NmsWorldBorder.BorderColor.GREEN) {
soundManager.playSound(player, XSound.ENTITY_CHICKEN_EGG);

event.setWillClose(false);
event.setWillDestroy(false);
} else {
island.setBorderColor(SWorldBorder.Color.Green);
island.setBorderColor(NmsWorldBorder.BorderColor.GREEN);
islandManager.updateBorder(island);

soundManager.playSound(player, XSound.BLOCK_WOODEN_BUTTON_CLICK_ON);
Expand All @@ -118,13 +118,13 @@ public void open(Player player) {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")))))) {
if (island.getBorderColor() == SWorldBorder.Color.Red) {
if (island.getBorderColor() == NmsWorldBorder.BorderColor.RED) {
soundManager.playSound(player, XSound.ENTITY_CHICKEN_EGG);

event.setWillClose(false);
event.setWillDestroy(false);
} else {
island.setBorderColor(SWorldBorder.Color.Red);
island.setBorderColor(NmsWorldBorder.BorderColor.RED);
islandManager.updateBorder(island);

soundManager.playSound(player, XSound.BLOCK_WOODEN_BUTTON_CLICK_ON);
Expand All @@ -139,7 +139,7 @@ public void open(Player player) {
nInv.addItem(nInv.createItem(XMaterial.OAK_FENCE_GATE.parseItem(),
configLoad.getString("Menu.Border.Item.Exit.Displayname"), null, null, null, null), 0);

SWorldBorder.Color borderColor = island.getBorderColor();
NmsWorldBorder.BorderColor borderColor = island.getBorderColor();
String borderToggle;

if (island.isBorder()) {
Expand All @@ -152,9 +152,8 @@ public void open(Player player) {
configLoad.getString("Menu.Border.Item.Toggle.Displayname"),
configLoad.getStringList("Menu.Border.Item.Toggle.Lore"),
new Placeholder[]{new Placeholder("%toggle", borderToggle)}, null, null), 1);

if (player.hasPermission("fabledskyblock.island.border.blue")) {
if (borderColor == SWorldBorder.Color.Blue) {
if (borderColor == NmsWorldBorder.BorderColor.BLUE) {
nInv.addItem(nInv.createItem(XMaterial.LIGHT_BLUE_DYE.parseItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
Expand All @@ -174,7 +173,7 @@ public void open(Player player) {
"", null, null, null, null), 2);
}
if (player.hasPermission("fabledskyblock.island.border.green")) {
if (borderColor == SWorldBorder.Color.Green) {
if (borderColor == NmsWorldBorder.BorderColor.GREEN) {
nInv.addItem(nInv.createItem(XMaterial.LIME_DYE.parseItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
Expand All @@ -196,7 +195,7 @@ public void open(Player player) {
"", null, null, null, null), 3);
}
if (player.hasPermission("fabledskyblock.island.border.red")) {
if (borderColor == SWorldBorder.Color.Red) {
if (borderColor == NmsWorldBorder.BorderColor.RED) {
nInv.addItem(nInv.createItem(XMaterial.RED_DYE.parseItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
Expand Down

0 comments on commit e9642ad

Please sign in to comment.