SteamWar/SpigotCore
Archiviert
13
0

Experimental ReflectionFix
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2023-03-03 17:19:37 +01:00
Ursprung f4e2051ec0
Commit 8982c0af29
2 geänderte Dateien mit 12 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -63,6 +63,7 @@ public final class Reflection {
* @param value - the new value of the field. * @param value - the new value of the field.
*/ */
void set(Object target, Object value); void set(Object target, Object value);
void setInt(Object target, int value);
/** /**
* Determine if the given object has this field. * Determine if the given object has this field.
@ -156,10 +157,16 @@ public final class Reflection {
@Override @Override
public void set(Object target, Object value) { public void set(Object target, Object value) {
try { try {
if(field.getDeclaringClass() == int.class) field.set(target, value);
field.setInt(target, (int)value); } catch (IllegalAccessException e) {
else throw new IllegalArgumentException("Cannot access reflection.", e);
field.set(target, value); }
}
@Override
public void setInt(Object target, int value) {
try {
field.setInt(target, value);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot access reflection.", e); throw new IllegalArgumentException("Cannot access reflection.", e);
} }

Datei anzeigen

@ -355,7 +355,7 @@ public class REntity {
protected Object getDataWatcherPacket(Object... dataWatcherKeyValues) { protected Object getDataWatcherPacket(Object... dataWatcherKeyValues) {
Object packet = Reflection.newInstance(metadataPacket); Object packet = Reflection.newInstance(metadataPacket);
metadataEntity.set(packet, entityId); metadataEntity.setInt(packet, entityId);
ArrayList<Object> nativeWatchers = new ArrayList<>(1); ArrayList<Object> nativeWatchers = new ArrayList<>(1);
for(int i = 0; i < dataWatcherKeyValues.length; i+=2) { for(int i = 0; i < dataWatcherKeyValues.length; i+=2) {