Skip to content

Commit

Permalink
fix(uni): avoid broken data prevent fetch cache
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Dec 22, 2024
1 parent 74e6bc1 commit bc29e05
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

<maven.settings.file>${project.basedir}/.mvn/settings.xml</maven.settings.file>

<!-- Spigot properties -->
<spigot.version>1.21</spigot.version>
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
<!-- Paper properties -->
<paper.version>1.21</paper.version>
<paper.javadocs>https://papermc.io/javadocs</paper.javadocs>
</properties>

<issueManagement>
Expand Down Expand Up @@ -273,9 +273,9 @@
<dependencies>
<!-- Hard dependencies -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}-R0.1-SNAPSHOT</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${paper.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,11 @@ public void getUniversalBlockData(@Nonnull UUID uuid, IAsyncReadCallback<Slimefu

var cache = loadedUniversalData.get(uuid);

return cache == null
? getUniversalBlockData(uuid)
: (cache instanceof SlimefunUniversalBlockData ubd ? ubd : null);
if (cache instanceof SlimefunUniversalBlockData ubd) {
return ubd;
} else {
return null;
}
}

/**
Expand All @@ -540,7 +542,8 @@ public Optional<SlimefunUniversalBlockData> getUniversalBlockDataFromCache(@Nonn

return loadedUniversalData.values().stream()
.filter(uniData -> uniData instanceof SlimefunUniversalBlockData ubd
&& ubd.getLastPresent().toLocation().equals(l))
&& ubd.getLastPresent() != null
&& l.equals(ubd.getLastPresent().toLocation()))
.map(data -> (SlimefunUniversalBlockData) data)
.findFirst();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public void run() {
return;
}

if (Bukkit.getOfflinePlayer(UUID.fromString(pUuid)).isOnline()) {
if (Bukkit.getOfflinePlayer(UUID.fromString(pUuid)).isConnected()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.controller.attributes.UniversalDataTrait;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Location;

public class SlimefunUniversalBlockData extends SlimefunUniversalData {
Expand Down Expand Up @@ -36,7 +38,8 @@ public BlockPosition getLastPresent() {
var data = getData("location");

if (data == null) {
throw new IllegalArgumentException("UniversalBlockData missing location data");
Slimefun.logger().log(Level.WARNING, "UniversalBlockData [" + getUUID() + "] missing location data");
return null;
}

lastPresent = new BlockPosition(LocationUtils.toLocation(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ public void onEnable() {
// We want to ensure that the Server uses a compatible server software and have no
// incompatible plugins
getServer().getPluginManager().disablePlugin(this);
} else if (!PaperLib.isPaper()) {
getLogger().log(Level.WARNING, "#######################################################");
getLogger().log(Level.WARNING, "");
getLogger().log(Level.WARNING, "自 24/12/22 起 Slimefun 汉化版");
getLogger().log(Level.WARNING, "转为 Paper 插件, 你必须要使用 Paper");
getLogger().log(Level.WARNING, "或其分支才可使用 Slimefun.");
getLogger().log(Level.WARNING, "立即下载 Paper: https://papermc.io/downloads/paper");
getLogger().log(Level.WARNING, "");
getLogger().log(Level.WARNING, "#######################################################");
getServer().getPluginManager().disablePlugin(this);
} else {
// The Environment has been validated.
onPluginStart();
Expand Down

0 comments on commit bc29e05

Please sign in to comment.