mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-27 18:49:11 +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
|
// Performs a consuming function for every advancement registered on the server
|
||||||
private static void forEachAdvancement(@NotNull ThrowingConsumer<org.bukkit.advancement.Advancement> consumer) {
|
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);
|
Bukkit.getServer().advancementIterator().forEachRemaining(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,9 +268,14 @@ public interface BukkitMapHandler {
|
|||||||
|
|
||||||
// Read the pixel data and generate a map view otherwise
|
// Read the pixel data and generate a map view otherwise
|
||||||
getPlugin().debug("Deserializing map data from NBT and generating view...");
|
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
|
// 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);
|
final MapView view = generateRenderedMap(canvasData);
|
||||||
meta.setMapView(view);
|
meta.setMapView(view);
|
||||||
map.setItemMeta(meta);
|
map.setItemMeta(meta);
|
||||||
|
|||||||
@@ -234,6 +234,11 @@ public class Identifier {
|
|||||||
return obj instanceof Identifier other ? toString().equals(other.toString()) : super.equals(obj);
|
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
|
// Get the config entry for the identifier
|
||||||
@NotNull
|
@NotNull
|
||||||
private Map.Entry<String, Boolean> getConfigEntry() {
|
private Map.Entry<String, Boolean> getConfigEntry() {
|
||||||
@@ -313,6 +318,11 @@ public class Identifier {
|
|||||||
}
|
}
|
||||||
return false;
|
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.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -173,16 +174,24 @@ public abstract class FabricSerializer {
|
|||||||
container.putInt("size", items.length);
|
container.putInt("size", items.length);
|
||||||
final NbtList itemList = new NbtList();
|
final NbtList itemList = new NbtList();
|
||||||
final DynamicRegistryManager registryManager = plugin.getMinecraftServer().getRegistryManager();
|
final DynamicRegistryManager registryManager = plugin.getMinecraftServer().getRegistryManager();
|
||||||
|
final List<ItemStack> skipped = new ArrayList<>();
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
final ItemStack item = items[i];
|
final ItemStack item = items[i];
|
||||||
if (item == null || item.isEmpty()) {
|
if (item == null || item.isEmpty() || item.getCount() < 1 || item.getCount() > 99) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final NbtCompound entry = encodeNbt(item, registryManager);
|
final NbtCompound entry = encodeNbt(item, registryManager);
|
||||||
|
if (entry == null) {
|
||||||
|
skipped.add(item);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
entry.putInt("Slot", i);
|
entry.putInt("Slot", i);
|
||||||
itemList.add(entry);
|
itemList.add(entry);
|
||||||
}
|
}
|
||||||
|
if (!skipped.isEmpty()) {
|
||||||
|
plugin.debug("Skipped serializing items in array: %s".formatted(Arrays.toString(skipped.toArray())));
|
||||||
|
}
|
||||||
container.put(ITEMS_TAG, itemList);
|
container.put(ITEMS_TAG, itemList);
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
@@ -216,17 +225,21 @@ public abstract class FabricSerializer {
|
|||||||
).getValue();
|
).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@Nullable
|
||||||
private NbtCompound encodeNbt(@NotNull ItemStack item, @NotNull DynamicRegistryManager registryManager) {
|
private NbtCompound encodeNbt(@NotNull ItemStack item, @NotNull DynamicRegistryManager registryManager) {
|
||||||
//#if MC==12104
|
try {
|
||||||
return (NbtCompound) item.toNbt(registryManager);
|
//#if MC==12104
|
||||||
//#elseif MC==12101
|
return (NbtCompound) item.toNbt(registryManager);
|
||||||
//$$ return (NbtCompound) item.encode(registryManager);
|
//#elseif MC==12101
|
||||||
//#elseif MC==12001
|
//$$ return (NbtCompound) item.encode(registryManager);
|
||||||
//$$ final NbtCompound compound = new NbtCompound();
|
//#elseif MC==12001
|
||||||
//$$ item.writeNbt(compound);
|
//$$ final NbtCompound compound = new NbtCompound();
|
||||||
//$$ return compound;
|
//$$ item.writeNbt(compound);
|
||||||
//#endif
|
//$$ return compound;
|
||||||
|
//#endif
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user