Converted
This commit is contained in:
@@ -6,23 +6,25 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class MinionsGui {
|
||||
protected final @Nullable MinionsGui parent;
|
||||
protected final ServerPlayerEntity viewer;
|
||||
private @Nullable MinionsGui child = null;
|
||||
protected @Nullable MinionsGui child = null;
|
||||
private boolean open = true;
|
||||
|
||||
public MinionsGui(MinionsGui parent) {
|
||||
this.viewer = parent.viewer;
|
||||
this.parent = parent;
|
||||
parent.child = this;
|
||||
open();
|
||||
}
|
||||
|
||||
public MinionsGui(ServerPlayerEntity viewer) {
|
||||
this.viewer = viewer;
|
||||
this.parent = null;
|
||||
open();
|
||||
}
|
||||
|
||||
protected void open() {}
|
||||
public ServerPlayerEntity getViewer() {
|
||||
return viewer;
|
||||
}
|
||||
|
||||
protected abstract void open();
|
||||
|
||||
protected void reopen() {
|
||||
open();
|
||||
@@ -38,17 +40,26 @@ public abstract class MinionsGui {
|
||||
|
||||
public void close() {
|
||||
if(open) {
|
||||
if(child != null) {
|
||||
child.close();
|
||||
}
|
||||
if(parent != null) {
|
||||
parent.child = null;
|
||||
parent.reopen();
|
||||
}
|
||||
onClose();
|
||||
open = false;
|
||||
closeNoOpen(parent == null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onClose() {}
|
||||
private void closeNoOpen(boolean closeBacking) {
|
||||
if(child != null) {
|
||||
child.closeNoOpen(closeBacking);
|
||||
}
|
||||
if(parent != null) {
|
||||
parent.child = null;
|
||||
}
|
||||
if(closeBacking) {
|
||||
closeBacking();
|
||||
}
|
||||
open = false;
|
||||
}
|
||||
|
||||
protected abstract void closeBacking();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user