SteamWar/BauSystem2.0
Archiviert
12
0

TinyProtocol #51

Zusammengeführt
YoyoNow hat 12 Commits von TinyProtocol nach master 2021-10-12 21:38:59 +02:00 zusammengeführt
Nur Änderungen aus Commit fb0e4dbd23 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -80,34 +80,4 @@ public class ProtocolAPI {
public static void broadcastPacket(Object packet) {
Bukkit.getOnlinePlayers().stream().map(tinyProtocol::getChannel).filter(tinyProtocol::hasInjected).forEach(channel -> tinyProtocol.sendPacket(channel, packet));
}
private static BiConsumer<Object, Object> shallowFill(Class<?> clazz) {
if (clazz == null)
return (source, clone) -> {
};
BiConsumer<Object, Object> superFiller = shallowFill(clazz.getSuperclass());
Field[] fds = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<>();
for (Field field : fds) {
if (Modifier.isStatic(field.getModifiers()))
continue;
field.setAccessible(true);
fields.add(field);
}
return (source, clone) -> {
superFiller.accept(source, clone);
try {
for (Field field : fields) {
field.set(clone, field.get(source));
}
} catch (IllegalAccessException e) {
throw new IllegalStateException("Could not set field", e);
}
};
}
}