Skip to content

Commit

Permalink
Continue observing while using direct server join.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Dec 30, 2017
1 parent 16dcec2 commit e0f74a4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void draw(final DrawScreenEvent.Post e) {
this.guiHandler.draw(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Pre e) {
this.guiHandler.action(e);
}

@SubscribeEvent
public void action(final ActionPerformedEvent.Post e) {
this.guiHandler.action(e);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ modid=serverobserver
modname=ServerObserver
version_major=1
version_minor=0
version_patch=1
version_patch=2
extra_changelog_location=
extra_fmlcore=
extra_fmlmod=
Expand Down
38 changes: 21 additions & 17 deletions src/main/java/net/teamfruit/serverobserver/GuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface SkeletonButtonDrawInside {

@CoreEvent
public void open(final InitGuiEvent.Post e) {
this.manualOpen = this.manual;
Timer.tick();
this.targetServerStatus = null;
final GuiScreen screen = this.mc.currentScreen;
Expand Down Expand Up @@ -85,6 +86,7 @@ public void open(final InitGuiEvent.Post e) {
if (Config.getConfig().durationMainMenu.get()>0)
reset(Config.getConfig().durationMainMenu);
}
this.manual = false;
}

@CoreEvent
Expand All @@ -96,7 +98,7 @@ public void draw(final DrawScreenEvent.Post e) {
this.disableBackButton.displayString = I18n.format("serverobserver.gui.backandstop.time", I18n.format("serverobserver.gui.backandstop"), timeremain());
} else if (gui instanceof GuiMainMenu) {
final GuiButton button = this.mainMenuButtonMulti;
if (button!=null&&this.target.getIP()!=null&&!this.hasGuiOpened)
if (button!=null&&this.target.getIP()!=null&&!this.manualOpen)
button.displayString = I18n.format("serverobserver.gui.maintomulti.time", I18n.format("menu.multiplayer"), timeremain());
}
}
Expand All @@ -107,6 +109,11 @@ public void draw(final DrawScreenEvent.Post e) {
private TargetServer target = new TargetServer();
private AutoLoginMode autologin = new AutoLoginMode();

@CoreEvent
public void action(final ActionPerformedEvent.Pre e) {
this.manual = true;
}

@CoreEvent
public void action(final ActionPerformedEvent.Post e) {
this.targetServerStatus = null;
Expand All @@ -132,10 +139,11 @@ public void action(final ActionPerformedEvent.Post e) {
final GuiDisconnected dcgui = (GuiDisconnected) screen;
this.autologin.set(false);
this.target.set(null);
dcgui.mc.displayGuiScreen(this.compat.getParentScreen(dcgui));
this.mc.displayGuiScreen(this.compat.getParentScreen(dcgui));
}
this.displayTime = "";
reset(Config.getConfig().durationPing);
this.manual = false;
}

public class TargetServer {
Expand Down Expand Up @@ -188,17 +196,13 @@ public boolean is() {

private final Minecraft mc = Minecraft.getMinecraft();
private Timer timer = new Timer();
private boolean hasMainMenuOpened;
private boolean hasGuiOpened;
private boolean manual;
private boolean manualOpen;

@CoreEvent
public void tickclient() {
Timer.tick();
final GuiScreen screen = this.mc.currentScreen;
if (screen instanceof GuiMainMenu)
this.hasMainMenuOpened = true;
else if (this.hasMainMenuOpened)
this.hasGuiOpened = true;

if (screen instanceof GuiMultiplayer) {
final GuiMultiplayer mpgui = (GuiMultiplayer) screen;
Expand Down Expand Up @@ -231,18 +235,18 @@ else if (this.autologin.is())
} else if (screen instanceof GuiDisconnected) {
final GuiDisconnected dcgui = (GuiDisconnected) screen;
if (this.timer.getTime()>0) {
final GuiScreen screen2 = this.compat.getParentScreen(dcgui);
dcgui.mc.displayGuiScreen(screen2);
if (screen2 instanceof GuiMultiplayer) {
final GuiMultiplayer mpgui = (GuiMultiplayer) screen2;
final ServerData serverData = this.target.get(mpgui);
if (serverData!=null)
this.compat.setPinged(serverData, false);
}
GuiScreen screen2 = this.compat.getParentScreen(dcgui);
if (!(screen2 instanceof GuiMultiplayer))
screen2 = new GuiMultiplayer(screen2);
this.mc.displayGuiScreen(screen2);
final GuiMultiplayer mpgui = (GuiMultiplayer) screen2;
final ServerData serverData = this.target.get(mpgui);
if (serverData!=null)
this.compat.setPinged(serverData, false);
}
} else if (screen instanceof GuiMainMenu) {
final GuiMainMenu mmgui = (GuiMainMenu) screen;
if (this.target.getIP()!=null&&!this.hasGuiOpened&&Config.getConfig().durationDisconnected.get()>=10)
if (this.target.getIP()!=null&&!this.manualOpen&&Config.getConfig().durationDisconnected.get()>=10)
if (this.timer.getTime()>0)
this.mc.displayGuiScreen(new GuiMultiplayer(mmgui));
}
Expand Down

0 comments on commit e0f74a4

Please sign in to comment.