mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-19 14:59:21 +00:00
fix(fabric): fix issues with Fabric 1.21.5
This commit is contained in:
@@ -93,9 +93,7 @@ public class BukkitHuskSync extends JavaPlugin implements HuskSync, BukkitTask.S
|
|||||||
private static final int METRICS_ID = 13140;
|
private static final int METRICS_ID = 13140;
|
||||||
private static final String PLATFORM_TYPE_ID = "bukkit";
|
private static final String PLATFORM_TYPE_ID = "bukkit";
|
||||||
|
|
||||||
private final TreeMap<Identifier, Serializer<? extends Data>> serializers = Maps.newTreeMap(
|
private final HashMap<Identifier, Serializer<? extends Data>> serializers = Maps.newHashMap();
|
||||||
SerializerRegistry.DEPENDENCY_ORDER_COMPARATOR
|
|
||||||
);
|
|
||||||
private final Map<UUID, Map<Identifier, Data>> playerCustomDataStore = Maps.newConcurrentMap();
|
private final Map<UUID, Map<Identifier, Data>> playerCustomDataStore = Maps.newConcurrentMap();
|
||||||
private final Map<Integer, MapView> mapViews = Maps.newConcurrentMap();
|
private final Map<Integer, MapView> mapViews = Maps.newConcurrentMap();
|
||||||
private final List<Migrator> availableMigrators = Lists.newArrayList();
|
private final List<Migrator> availableMigrators = Lists.newArrayList();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface SerializerRegistry {
|
public interface SerializerRegistry {
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public interface SerializerRegistry {
|
|||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
<T extends Data> TreeMap<Identifier, Serializer<T>> getSerializers();
|
<T extends Data> Map<Identifier, Serializer<T>> getSerializers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a data serializer for the given {@link Identifier}
|
* Register a data serializer for the given {@link Identifier}
|
||||||
@@ -87,8 +88,7 @@ public interface SerializerRegistry {
|
|||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
default Optional<Identifier> getIdentifier(@NotNull String key) {
|
default Optional<Identifier> getIdentifier(@NotNull String key) {
|
||||||
return getSerializers().keySet().stream()
|
return getSerializers().keySet().stream().filter(e -> e.toString().equals(key)).findFirst();
|
||||||
.filter(id -> id.getKey().asString().equals(key)).findFirst();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +99,7 @@ public interface SerializerRegistry {
|
|||||||
* @since 3.5.4
|
* @since 3.5.4
|
||||||
*/
|
*/
|
||||||
default Optional<Serializer<Data>> getSerializer(@NotNull Identifier identifier) {
|
default Optional<Serializer<Data>> getSerializer(@NotNull Identifier identifier) {
|
||||||
return getSerializers().entrySet().stream()
|
return Optional.ofNullable(getSerializers().get(identifier));
|
||||||
.filter(entry -> entry.getKey().getKey().equals(identifier.getKey()))
|
|
||||||
.map(Map.Entry::getValue).findFirst();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,14 +151,14 @@ public interface SerializerRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the set of registered data types
|
* Get the list of registered data types, in dependency order
|
||||||
*
|
*
|
||||||
* @return the set of registered data types
|
* @return the list of registered data types
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
default Set<Identifier> getRegisteredDataTypes() {
|
default List<Identifier> getRegisteredDataTypes() {
|
||||||
return getSerializers().keySet();
|
return getSerializers().keySet().stream().sorted(DEPENDENCY_ORDER_COMPARATOR).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns if a data type is available and enabled in the config
|
// Returns if a data type is available and enabled in the config
|
||||||
|
|||||||
@@ -102,9 +102,7 @@ public class FabricHuskSync implements DedicatedServerModInitializer, HuskSync,
|
|||||||
private static final int VERSION1_21_4 = 4189; // Current
|
private static final int VERSION1_21_4 = 4189; // Current
|
||||||
private static final int VERSION1_21_5 = 4323;
|
private static final int VERSION1_21_5 = 4323;
|
||||||
|
|
||||||
private final TreeMap<Identifier, Serializer<? extends Data>> serializers = Maps.newTreeMap(
|
private final HashMap<Identifier, Serializer<? extends Data>> serializers = Maps.newHashMap();
|
||||||
SerializerRegistry.DEPENDENCY_ORDER_COMPARATOR
|
|
||||||
);
|
|
||||||
private final Map<UUID, Map<Identifier, Data>> playerCustomDataStore = Maps.newConcurrentMap();
|
private final Map<UUID, Map<Identifier, Data>> playerCustomDataStore = Maps.newConcurrentMap();
|
||||||
private final Map<String, Boolean> permissions = Maps.newHashMap();
|
private final Map<String, Boolean> permissions = Maps.newHashMap();
|
||||||
private final List<Migrator> availableMigrators = Lists.newArrayList();
|
private final List<Migrator> availableMigrators = Lists.newArrayList();
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import net.minecraft.stat.StatType;
|
|||||||
import net.minecraft.stat.Stats;
|
import net.minecraft.stat.Stats;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.world.GameMode;
|
|
||||||
import net.william278.desertwell.util.ThrowingConsumer;
|
import net.william278.desertwell.util.ThrowingConsumer;
|
||||||
import net.william278.husksync.FabricHuskSync;
|
import net.william278.husksync.FabricHuskSync;
|
||||||
import net.william278.husksync.HuskSync;
|
import net.william278.husksync.HuskSync;
|
||||||
@@ -557,13 +556,13 @@ public abstract class FabricData implements Data {
|
|||||||
// This is necessary to prevent weird re-mappings with Registry#getKey()
|
// This is necessary to prevent weird re-mappings with Registry#getKey()
|
||||||
//#if MC>0
|
//#if MC>0
|
||||||
//$$ final Registry<?> registry = stat.getValue().getRegistry();
|
//$$ final Registry<?> registry = stat.getValue().getRegistry();
|
||||||
//$$ final String registryId = registry.getKey().getValue().toString();
|
//$$ final String registryId = registry.getKey().getValue().value();
|
||||||
//$$ if (registryId.equals("custom_stat")) {
|
//$$ if (registryId.equals("custom_stat")) {
|
||||||
//$$ return;
|
//$$ return;
|
||||||
//$$ }
|
//$$ }
|
||||||
//#else
|
//#else
|
||||||
final Registry<?> registry = stat.getValue().getRegistry();
|
final Registry<?> registry = stat.getValue().getRegistry();
|
||||||
final String registryId = registry.getKey().getValue().toString();
|
final String registryId = registry.getKey().getValue().value();
|
||||||
if (registryId.equals("custom_stat")) {
|
if (registryId.equals("custom_stat")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ public interface FabricUserDataHolder extends UserDataHolder {
|
|||||||
//#else
|
//#else
|
||||||
final ItemStack[] combined = new ItemStack[inv.size()];
|
final ItemStack[] combined = new ItemStack[inv.size()];
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
while (inv.iterator().hasNext()) {
|
for (ItemStack itemStack : inv) {
|
||||||
combined[slot] = inv.iterator().next();
|
combined[slot] = itemStack;
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
return combined;
|
return combined;
|
||||||
|
|||||||
Reference in New Issue
Block a user