List of usage examples for net.minecraftforge.fml.client.config GuiMessageDialog GuiMessageDialog
public GuiMessageDialog(@Nullable Screen nextScreen, String title, ITextComponent message, String buttonText)
From source file:com.blogspot.jabelarminecraft.blocksmith.gui.GuiConfig.java
License:Open Source License
@Override protected void actionPerformed(GuiButton button) { if (button.id == 2000) { // DEBUG//from www. j ava 2s .c o m System.out.println("Pressed DONE button"); boolean flag = true; try { if ((configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig)) && (this.entryList.hasChangedEntry(true))) { // DEBUG System.out.println("Saving config elements"); boolean requiresMcRestart = this.entryList.saveConfigElements(); if (Loader.isModLoaded(modID)) { ConfigChangedEvent event = new OnConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart); FMLCommonHandler.instance().bus().post(event); if (!event.getResult().equals(Result.DENY)) FMLCommonHandler.instance().bus().post( new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart)); if (requiresMcRestart) { flag = false; mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (this.parentScreen instanceof GuiConfig) ((GuiConfig) this.parentScreen).needsRefresh = true; } } } catch (Throwable e) { e.printStackTrace(); } if (flag) this.mc.displayGuiScreen(this.parentScreen); } }
From source file:com.blogspot.jabelarminecraft.magicbeans.gui.GuiConfig.java
License:Open Source License
@Override protected void actionPerformed(GuiButton button) { if (button.id == 2000) { // DEBUG/*from w ww .ja v a2s. co m*/ System.out.println("Pressed DONE button"); boolean flag = true; try { if ((configID != null || parentScreen == null || !(parentScreen instanceof GuiConfig)) && (entryList.hasChangedEntry(true))) { // DEBUG System.out.println("Saving config elements"); boolean requiresMcRestart = entryList.saveConfigElements(); if (Loader.isModLoaded(modID)) { ConfigChangedEvent event = new OnConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart); MinecraftForge.EVENT_BUS.post(event); // FMLCommonHandler.instance().bus().post(event); // Deprecated if (!event.getResult().equals(Result.DENY)) MinecraftForge.EVENT_BUS.post( new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart)); // FMLCommonHandler.instance().bus().post(new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart)); if (requiresMcRestart) { flag = false; mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (parentScreen instanceof GuiConfig) ((GuiConfig) parentScreen).needsRefresh = true; } } } catch (Throwable e) { e.printStackTrace(); } if (flag) mc.displayGuiScreen(parentScreen); } }
From source file:com.blogspot.jabelarminecraft.magicbeans.gui.GuiConfigMagicBeans.java
License:Open Source License
@Override protected void actionPerformed(GuiButton button) { if (button.id == 2000) { // DEBUG// w w w . j a va 2s . c o m System.out.println("Pressed DONE button"); boolean flag = true; try { if ((configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig)) && (this.entryList.hasChangedEntry(true))) { // DEBUG System.out.println("Saving config elements"); boolean requiresMcRestart = this.entryList.saveConfigElements(); if (Loader.isModLoaded(modID)) { ConfigChangedEvent event = new OnConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart); FMLCommonHandler.instance().bus().post(event); if (!event.getResult().equals(Result.DENY)) FMLCommonHandler.instance().bus().post( new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart)); if (requiresMcRestart) { flag = false; mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", new ChatComponentText(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (this.parentScreen instanceof GuiConfig) ((GuiConfig) this.parentScreen).needsRefresh = true; } } } catch (Throwable e) { e.printStackTrace(); } if (flag) this.mc.displayGuiScreen(this.parentScreen); } }