From e5c69e42a6f12726f632ecee792501d4e874aad8 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 24 Dec 2018 20:49:43 -0800 Subject: [PATCH] Fixes bugs with CompositeCommand world setting. Removes debug from previous commit. Relates to https://github.com/BentoBoxWorld/BentoBox/pull/415 --- .../bentobox/api/commands/CompositeCommand.java | 10 ++++++---- .../bentobox/bentobox/managers/AddonsManager.java | 2 -- .../bentobox/bentobox/managers/LocalesManager.java | 2 +- .../bentobox/bentobox/managers/SchemsManager.java | 7 ++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/CompositeCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/CompositeCommand.java index d0daf681f..9cfcd28bb 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/CompositeCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/CompositeCommand.java @@ -85,7 +85,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi /** * The prefix to be used in this command */ - private String permissionPrefix = ""; + private String permissionPrefix; /** * The world that this command operates in. This is an overworld and will cover any associated nether or end @@ -101,7 +101,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi /** * The top level label */ - private String topLabel = ""; + private String topLabel; /** * Cool down tracker @@ -133,11 +133,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi setDescription(COMMANDS + label + ".description"); setParametersHelp(COMMANDS + label + ".parameters"); permissionPrefix = (addon != null) ? addon.getPermissionPrefix() : ""; - setup(); // Set up world if this is an AddonGameMode if (addon instanceof GameModeAddon) { - this.world = ((GameModeAddon)addon).getOverWorld(); + addon.log("DEBUG: gamemode command - world = " +((GameModeAddon)addon).getOverWorld()); + setWorld(((GameModeAddon)addon).getOverWorld()); } + // Run setup + setup(); if (!getSubCommand("help").isPresent() && !label.equals("help")) { new DefaultHelpCommand(this); } diff --git a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java index eee328675..3a8435eac 100644 --- a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java @@ -153,10 +153,8 @@ public class AddonsManager { GameModeAddon gameMode = (GameModeAddon)addon; // Create the gameWorlds gameMode.createWorlds(); - plugin.logDebug("GameModeAddon found! overWorld = " + gameMode.getOverWorld()); plugin.getIWM().addWorld(gameMode.getOverWorld(), gameMode.getWorldSettings()); // Register the schems - plugin.logDebug("Trying to register schems"); plugin.getSchemsManager().loadIslands(gameMode); } } catch (Exception e) { diff --git a/src/main/java/world/bentobox/bentobox/managers/LocalesManager.java b/src/main/java/world/bentobox/bentobox/managers/LocalesManager.java index cedd58bdc..ffe8c18db 100644 --- a/src/main/java/world/bentobox/bentobox/managers/LocalesManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/LocalesManager.java @@ -119,7 +119,7 @@ public class LocalesManager { // We cannot use Bukkit's saveResource, because we want it to go into a specific folder, so... // Get the last part of the name int lastIndex = name.lastIndexOf('/'); - File targetFile = new File(localeDir, name.substring(lastIndex >= 0 ? lastIndex : 0, name.length())); + File targetFile = new File(localeDir, name.substring(lastIndex >= 0 ? lastIndex : 0)); copyFile(name, targetFile); } } catch (IOException e) { diff --git a/src/main/java/world/bentobox/bentobox/managers/SchemsManager.java b/src/main/java/world/bentobox/bentobox/managers/SchemsManager.java index 960c8f004..13d870a01 100644 --- a/src/main/java/world/bentobox/bentobox/managers/SchemsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/SchemsManager.java @@ -41,12 +41,9 @@ public class SchemsManager { plugin.logError("Could not make schems folder!"); return; } - // Save any schems that + // Save any schems that are in the jar try (JarFile jar = new JarFile(addon.getFile())) { - plugin.getAddonsManager().listJarFiles(jar, "schems", ".schem").forEach(name -> { - plugin.logDebug("Found " + name); - addon.saveResource(name, false); - }); + plugin.getAddonsManager().listJarFiles(jar, "schems", ".schem").forEach(name -> addon.saveResource(name, false)); } catch (IOException e) { plugin.logError("Could not load schem files from addon jar " + e.getMessage()); }