mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-27 02:29:10 +00:00
Compare commits
8 Commits
refactor/l
...
test/debug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70d6b671f2 | ||
|
|
98576c72fb | ||
|
|
ae657acee3 | ||
|
|
34dc6a537d | ||
|
|
e99ba66271 | ||
|
|
546e663e4e | ||
|
|
0111f25865 | ||
|
|
2a59a0b3f5 |
@@ -375,6 +375,9 @@ public abstract class BukkitData implements Data {
|
||||
|
||||
// Performs a consuming function for every advancement registered on the server
|
||||
private static void forEachAdvancement(@NotNull ThrowingConsumer<org.bukkit.advancement.Advancement> consumer) {
|
||||
final StringJoiner joiner = new StringJoiner(", ");
|
||||
Bukkit.getServer().advancementIterator().forEachRemaining(a -> joiner.add(a.toString()));
|
||||
Bukkit.getLogger().log(Level.INFO, "Advancements: %s".formatted(joiner.toString()));
|
||||
Bukkit.getServer().advancementIterator().forEachRemaining(consumer);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +268,14 @@ public interface BukkitMapHandler {
|
||||
|
||||
// Read the pixel data and generate a map view otherwise
|
||||
getPlugin().debug("Deserializing map data from NBT and generating view...");
|
||||
final MapData canvasData = Objects.requireNonNull(readMapData(originServerName, originalMapId), "Pixel data null!").getKey();
|
||||
final @Nullable Map.Entry<MapData, Boolean> readMapData = readMapData(originServerName, originalMapId);
|
||||
if (readMapData == null) {
|
||||
getPlugin().debug("Read pixel data was not found in database, skipping...");
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a renderer to the map with the data and save to file
|
||||
final MapData canvasData = Objects.requireNonNull(readMapData, "Pixel data null!").getKey();
|
||||
final MapView view = generateRenderedMap(canvasData);
|
||||
meta.setMapView(view);
|
||||
map.setItemMeta(meta);
|
||||
|
||||
@@ -234,6 +234,11 @@ public class Identifier {
|
||||
return obj instanceof Identifier other ? toString().equals(other.toString()) : super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.toString().hashCode();
|
||||
}
|
||||
|
||||
// Get the config entry for the identifier
|
||||
@NotNull
|
||||
private Map.Entry<String, Boolean> getConfigEntry() {
|
||||
@@ -313,6 +318,11 @@ public class Identifier {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.toString().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -173,16 +174,24 @@ public abstract class FabricSerializer {
|
||||
container.putInt("size", items.length);
|
||||
final NbtList itemList = new NbtList();
|
||||
final DynamicRegistryManager registryManager = plugin.getMinecraftServer().getRegistryManager();
|
||||
final List<ItemStack> skipped = new ArrayList<>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
final ItemStack item = items[i];
|
||||
if (item == null || item.isEmpty()) {
|
||||
if (item == null || item.isEmpty() || item.getCount() < 1 || item.getCount() > 99) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final NbtCompound entry = encodeNbt(item, registryManager);
|
||||
if (entry == null) {
|
||||
skipped.add(item);
|
||||
continue;
|
||||
}
|
||||
entry.putInt("Slot", i);
|
||||
itemList.add(entry);
|
||||
}
|
||||
if (!skipped.isEmpty()) {
|
||||
plugin.debug("Skipped serializing items in array: %s".formatted(Arrays.toString(skipped.toArray())));
|
||||
}
|
||||
container.put(ITEMS_TAG, itemList);
|
||||
return container;
|
||||
}
|
||||
@@ -216,17 +225,21 @@ public abstract class FabricSerializer {
|
||||
).getValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
private NbtCompound encodeNbt(@NotNull ItemStack item, @NotNull DynamicRegistryManager registryManager) {
|
||||
//#if MC==12104
|
||||
return (NbtCompound) item.toNbt(registryManager);
|
||||
//#elseif MC==12101
|
||||
//$$ return (NbtCompound) item.encode(registryManager);
|
||||
//#elseif MC==12001
|
||||
//$$ final NbtCompound compound = new NbtCompound();
|
||||
//$$ item.writeNbt(compound);
|
||||
//$$ return compound;
|
||||
//#endif
|
||||
try {
|
||||
//#if MC==12104
|
||||
return (NbtCompound) item.toNbt(registryManager);
|
||||
//#elseif MC==12101
|
||||
//$$ return (NbtCompound) item.encode(registryManager);
|
||||
//#elseif MC==12001
|
||||
//$$ final NbtCompound compound = new NbtCompound();
|
||||
//$$ item.writeNbt(compound);
|
||||
//$$ return compound;
|
||||
//#endif
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user