Restore files omitted by sparse release checkout

This commit is contained in:
unimatrixgit 2026-11-21 20:22:37 +01:00
commit 35b68e0e73

View file

@ -0,0 +1,14 @@
package com.dunerealms.gui;
import java.lang.reflect.Field;
/** Detach only the lobby's vanilla End fight, without killing entities or editing NBT. */
final class DragonController {
record Detached(Object handle,Field field,Object previous){
void restore() throws IllegalAccessException {if(field.get(handle)==null)field.set(handle,previous);}
}
static Detached detach(Object handle)throws ReflectiveOperationException {
for(Class<?> type=handle.getClass();type!=null;type=type.getSuperclass())for(Field field:type.getDeclaredFields())if(field.getType().getSimpleName().equals("EndDragonFight")){
field.setAccessible(true);Object previous=field.get(handle);field.set(handle,null);return new Detached(handle,field,previous);
}
throw new NoSuchFieldException("Lobby EndDragonFight controller");
}
}