Skip to content

Commit

Permalink
Fix being unable to enable multiworld support
Browse files Browse the repository at this point in the history
See the now fixed #128 for more information.
  • Loading branch information
Pokechu22 committed Jul 9, 2019
1 parent 87ce648 commit 376fdaf
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 36 deletions.
43 changes: 25 additions & 18 deletions share/src/main/java/wdl/WDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,23 @@ public class WDL {
* @return true when the calling method should exit (this is prompting), false if it should continue
*/
public boolean promptForInfoForSettings(String context, boolean checkLastModified, Runnable callback, Runnable cancel) {
if (!propsFound) {
minecraft.displayGuiScreen(new GuiWDLMultiworld(new GuiWDLMultiworld.MultiworldCallback() {
// NOTE: This is checked first, even though this condition will fail initially while
// the !propsFound one will be hit first.
// That's because this one will trigger on the next call, but the properties
// will not have yet been loaded. We want to ask this question next, and
// then the properties will finally be loaded.
// This code really needs to be redone.
if (isMultiworld && worldName.isEmpty()) {
minecraft.displayGuiScreen(new GuiWDLMultiworldSelect(this,
new TextComponentTranslation("wdl.gui.multiworldSelect.title." + context),
new GuiWDLMultiworldSelect.WorldSelectionCallback() {
@Override
public void onSelect(boolean enableMutliworld) {
isMultiworld = enableMutliworld;

if (!isMultiworld) {
serverProps.setValue(MiscSettings.LINKED_WORLDS, "");
saveProps();
propsFound = true;
}
public void onWorldSelected(String selectedWorld) {
worldName = selectedWorld;

worldProps = loadWorldProps(selectedWorld);
propsFound = true; // Successfully loaded, even if the file doesn't exist.
gameRules = loadGameRules(selectedWorld);
callback.run();
}

Expand All @@ -315,16 +320,18 @@ public void onCancel() {
return true;
}

if (isMultiworld && worldName.isEmpty()) {
minecraft.displayGuiScreen(new GuiWDLMultiworldSelect(this,
new TextComponentTranslation("wdl.gui.multiworldSelect.title." + context),
new GuiWDLMultiworldSelect.WorldSelectionCallback() {
if (!propsFound) {
minecraft.displayGuiScreen(new GuiWDLMultiworld(new GuiWDLMultiworld.MultiworldCallback() {
@Override
public void onWorldSelected(String selectedWorld) {
worldName = selectedWorld;
public void onSelect(boolean enableMutliworld) {
isMultiworld = enableMutliworld;

if (!isMultiworld) {
serverProps.setValue(MiscSettings.LINKED_WORLDS, "");
saveProps();
propsFound = true;
}

worldProps = loadWorldProps(selectedWorld);
gameRules = loadGameRules(selectedWorld);
callback.run();
}

Expand Down
43 changes: 25 additions & 18 deletions share_14/src/main/java/wdl/WDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,23 @@ public class WDL {
* @return true when the calling method should exit (this is prompting), false if it should continue
*/
public boolean promptForInfoForSettings(String context, boolean checkLastModified, Runnable callback, Runnable cancel) {
if (!propsFound) {
minecraft.displayGuiScreen(new GuiWDLMultiworld(new GuiWDLMultiworld.MultiworldCallback() {
// NOTE: This is checked first, even though this condition will fail initially while
// the !propsFound one will be hit first.
// That's because this one will trigger on the next call, but the properties
// will not have yet been loaded. We want to ask this question next, and
// then the properties will finally be loaded.
// This code really needs to be redone.
if (isMultiworld && worldName.isEmpty()) {
minecraft.displayGuiScreen(new GuiWDLMultiworldSelect(this,
new TranslationTextComponent("wdl.gui.multiworldSelect.title." + context),
new GuiWDLMultiworldSelect.WorldSelectionCallback() {
@Override
public void onSelect(boolean enableMutliworld) {
isMultiworld = enableMutliworld;

if (!isMultiworld) {
serverProps.setValue(MiscSettings.LINKED_WORLDS, "");
saveProps();
propsFound = true;
}
public void onWorldSelected(String selectedWorld) {
worldName = selectedWorld;

worldProps = loadWorldProps(selectedWorld);
propsFound = true; // Successfully loaded, even if the file doesn't exist.
gameRules = loadGameRules(selectedWorld);
callback.run();
}

Expand All @@ -307,16 +312,18 @@ public void onCancel() {
return true;
}

if (isMultiworld && worldName.isEmpty()) {
minecraft.displayGuiScreen(new GuiWDLMultiworldSelect(this,
new TranslationTextComponent("wdl.gui.multiworldSelect.title." + context),
new GuiWDLMultiworldSelect.WorldSelectionCallback() {
if (!propsFound) {
minecraft.displayGuiScreen(new GuiWDLMultiworld(new GuiWDLMultiworld.MultiworldCallback() {
@Override
public void onWorldSelected(String selectedWorld) {
worldName = selectedWorld;
public void onSelect(boolean enableMutliworld) {
isMultiworld = enableMutliworld;

if (!isMultiworld) {
serverProps.setValue(MiscSettings.LINKED_WORLDS, "");
saveProps();
propsFound = true;
}

worldProps = loadWorldProps(selectedWorld);
gameRules = loadGameRules(selectedWorld);
callback.run();
}

Expand Down

0 comments on commit 376fdaf

Please sign in to comment.