SteamWar/BauSystem2.0
Archiviert
12
0

Add tinyprotocol
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-10-12 21:24:37 +02:00
Ursprung 83e26406ad
Commit fb0e4dbd23

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);
}
};
}
}