From e80be187123a2611adf7f9b3cb47635f38a94a9a Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 16 Jan 2019 12:46:39 -0800 Subject: [PATCH 01/12] Updated to lated API --- pom.xml | 10 +++--- src/main/java/world/bentobox/warps/Warp.java | 33 +++++++------------ .../bentobox/warps/WarpSignsListenerTest.java | 11 ++++--- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 974b344..41d33a9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ world.bentobox WelcomeWarpSigns - 0.1.0-SNAPSHOT + 1.1-SNAPSHOT WelcomeWarpSigns WelcomeWarpSigns is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland. @@ -86,12 +86,12 @@ world.bentobox bentobox - 0.12.0-SNAPSHOT + 1.1-SNAPSHOT world.bentobox - Level - 0.1.0-SNAPSHOT + level + 1.1-SNAPSHOT provided @@ -218,7 +218,7 @@ sonar https://sonarcloud.io - tastybento-github + bentobox-world diff --git a/src/main/java/world/bentobox/warps/Warp.java b/src/main/java/world/bentobox/warps/Warp.java index bc62ee9..12d2f99 100644 --- a/src/main/java/world/bentobox/warps/Warp.java +++ b/src/main/java/world/bentobox/warps/Warp.java @@ -6,14 +6,13 @@ import java.util.UUID; import org.bukkit.World; +import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.api.addons.Addon; +import world.bentobox.bentobox.util.Util; import world.bentobox.level.Level; import world.bentobox.warps.commands.WarpCommand; import world.bentobox.warps.commands.WarpsCommand; import world.bentobox.warps.config.PluginConfig; -import world.bentobox.bentobox.BentoBox; -import world.bentobox.bentobox.api.addons.Addon; -import world.bentobox.bentobox.api.commands.CompositeCommand; -import world.bentobox.bentobox.util.Util; /** * Addin to BSkyBlock that enables welcome warp signs @@ -57,26 +56,16 @@ public class Warp extends Addon { // Load the listener getServer().getPluginManager().registerEvents(new WarpSignsListener(this), plugin); // Register commands + getPlugin().getAddonsManager().getGameModeAddons().stream() + .filter(a -> a.getDescription().getName().equals(BSKYBLOCK) || a.getDescription().getName().equals(ACIDISLAND)) + .forEach(a -> { + a.getPlayerCommand().ifPresent(c -> { + new WarpCommand(this, c); + new WarpsCommand(this, c); + registeredWorlds.add(c.getWorld()); + }); - // BSkyBlock hook in - this.getPlugin().getAddonsManager().getAddonByName(BSKYBLOCK).ifPresent(acidIsland -> { - CompositeCommand bsbIslandCmd = BentoBox.getInstance().getCommandsManager().getCommand("island"); - if (bsbIslandCmd != null) { - new WarpCommand(this, bsbIslandCmd); - new WarpsCommand(this, bsbIslandCmd); - registeredWorlds.add(bsbIslandCmd.getWorld()); - } }); - // AcidIsland hook in - this.getPlugin().getAddonsManager().getAddonByName(ACIDISLAND).ifPresent(acidIsland -> { - CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai"); - if (acidIslandCmd != null) { - new WarpCommand(this, acidIslandCmd); - new WarpsCommand(this, acidIslandCmd); - registeredWorlds.add(acidIslandCmd.getWorld()); - } - }); - // Done } diff --git a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java index b5dfe2e..945c869 100644 --- a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java +++ b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java @@ -9,6 +9,7 @@ import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.UUID; import org.bukkit.Bukkit; @@ -33,14 +34,12 @@ import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import world.bentobox.warps.Warp; -import world.bentobox.warps.WarpSignsListener; -import world.bentobox.warps.WarpSignsManager; -import world.bentobox.warps.config.PluginConfig; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandsManager; import world.bentobox.bentobox.managers.LocalesManager; +import world.bentobox.warps.config.PluginConfig; @RunWith(PowerMockRunner.class) @PrepareForTest({Bukkit.class}) @@ -122,6 +121,10 @@ public class WarpSignsListenerTest { // Sufficient level when(addon.getLevel(Mockito.any(), Mockito.any())).thenReturn(100L); + + IslandWorldManager iwm = mock(IslandWorldManager.class); + when(plugin.getIWM()).thenReturn(iwm); + when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); } @Test From 2bf5299a16ad24494fc0f612d7b447da16dffca5 Mon Sep 17 00:00:00 2001 From: tastybento Date: Tue, 29 Jan 2019 13:52:44 -0800 Subject: [PATCH 02/12] Version up. Fixed POM. --- pom.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 41d33a9..5ea0794 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ world.bentobox WelcomeWarpSigns - 1.1-SNAPSHOT + 1.2-SNAPSHOT WelcomeWarpSigns WelcomeWarpSigns is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland. @@ -51,13 +51,17 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots + + codemc + https://repo.codemc.org/repository/maven-snapshots/ + org.spigotmc spigot-api - 1.13-R0.1-SNAPSHOT + 1.13.2-R0.1-SNAPSHOT provided @@ -86,7 +90,7 @@ world.bentobox bentobox - 1.1-SNAPSHOT + 1.2.1-SNAPSHOT world.bentobox From da996714a162c62b6cd30089454687d8d463c5f8 Mon Sep 17 00:00:00 2001 From: tastybento Date: Tue, 29 Jan 2019 14:04:56 -0800 Subject: [PATCH 03/12] Check for warp file before loading --- .../bentobox/warps/WarpSignsManager.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/world/bentobox/warps/WarpSignsManager.java b/src/main/java/world/bentobox/warps/WarpSignsManager.java index 844a6f3..62a56ef 100644 --- a/src/main/java/world/bentobox/warps/WarpSignsManager.java +++ b/src/main/java/world/bentobox/warps/WarpSignsManager.java @@ -163,15 +163,18 @@ public class WarpSignsManager { private void loadWarpList() { addon.getLogger().info("Loading warps..."); worldsWarpList = new HashMap<>(); - WarpsData warps = handler.loadObject("warps"); - // Load into map - if (warps != null) { - warps.getWarpSigns().forEach((k,v) -> { - if (k != null && (k.getBlock().getType().equals(Material.SIGN) || k.getBlock().getType().equals(Material.WALL_SIGN))) { - // Add to map - getWarpMap(k.getWorld()).put(v, k); - } - }); + WarpsData warps = new WarpsData(); + if (handler.objectExists("warps")) { + warps = handler.loadObject("warps"); + // Load into map + if (warps != null) { + warps.getWarpSigns().forEach((k,v) -> { + if (k != null && (k.getBlock().getType().equals(Material.SIGN) || k.getBlock().getType().equals(Material.WALL_SIGN))) { + // Add to map + getWarpMap(k.getWorld()).put(v, k); + } + }); + } } } From aa1f0bdcba0e65107f302372b00c6dae3132b25d Mon Sep 17 00:00:00 2001 From: BONNe Date: Thu, 31 Jan 2019 20:25:32 +0200 Subject: [PATCH 04/12] Rename PluginConfig to Settings. - Settings is now correct Config for Addon. Improve Warp class a bit: - add some javaDoc. - load only if hooked. --- pom.xml | 2 +- src/main/java/world/bentobox/warps/Warp.java | 143 +++++++++++++----- .../bentobox/warps/config/PluginConfig.java | 24 --- .../world/bentobox/warps/config/Settings.java | 142 +++++++++++++++++ src/main/resources/config.yml | 5 + .../bentobox/warps/WarpSignsListenerTest.java | 31 ++-- 6 files changed, 268 insertions(+), 79 deletions(-) delete mode 100644 src/main/java/world/bentobox/warps/config/PluginConfig.java create mode 100644 src/main/java/world/bentobox/warps/config/Settings.java diff --git a/pom.xml b/pom.xml index 5ea0794..7afb225 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 world.bentobox - WelcomeWarpSigns + warps 1.2-SNAPSHOT WelcomeWarpSigns diff --git a/src/main/java/world/bentobox/warps/Warp.java b/src/main/java/world/bentobox/warps/Warp.java index 12d2f99..452a314 100644 --- a/src/main/java/world/bentobox/warps/Warp.java +++ b/src/main/java/world/bentobox/warps/Warp.java @@ -1,18 +1,18 @@ package world.bentobox.warps; + +import org.bukkit.World; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.World; - -import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.addons.Addon; +import world.bentobox.bentobox.api.configuration.Config; import world.bentobox.bentobox.util.Util; import world.bentobox.level.Level; import world.bentobox.warps.commands.WarpCommand; import world.bentobox.warps.commands.WarpsCommand; -import world.bentobox.warps.config.PluginConfig; +import world.bentobox.warps.config.Settings; /** * Addin to BSkyBlock that enables welcome warp signs @@ -20,55 +20,113 @@ import world.bentobox.warps.config.PluginConfig; * */ public class Warp extends Addon { +// --------------------------------------------------------------------- +// Section: Variables +// --------------------------------------------------------------------- - private static final String BSKYBLOCK = "BSkyBlock"; - private static final String ACIDISLAND = "AcidIsland"; + /** + * This variable stores string for Level addon. + */ private static final String LEVEL_ADDON_NAME = "Level"; - // The plugin instance. - private BentoBox plugin; - - // Warp panel objects + /** + * Warp panel Manager + */ private WarpPanelManager warpPanelManager; - // Warps signs objects + /** + * Worlds Sign manager. + */ private WarpSignsManager warpSignsManager; + /** + * This variable stores in which worlds this addon is working. + */ private Set registeredWorlds; - private PluginConfig settings; + /** + * This variable stores if addon settings. + */ + private Settings settings; + + /** + * This variable stores if addon is hooked or not. + */ + private boolean hooked; + +// --------------------------------------------------------------------- +// Section: Methods +// --------------------------------------------------------------------- + + + /** + * Executes code when loading the addon. This is called before {@link #onEnable()}. This should preferably + * be used to setup configuration and worlds. + */ + @Override + public void onLoad() + { + super.onLoad(); + // Save default config.yml + this.saveDefaultConfig(); + // Load the plugin's config + this.loadSettings(); + } + + + /** + * Executes code when reloading the addon. + */ + @Override + public void onReload() + { + super.onReload(); + + if (this.hooked) { + this.warpSignsManager.saveWarpList(); + + this.loadSettings(); + this.getLogger().info("WelcomeWarp addon reloaded."); + } + } + @Override public void onEnable() { - // Load the plugin's config - settings = new PluginConfig(this); - // Get the BSkyBlock plugin. This will be available because this plugin depends on it in plugin.yml. - plugin = this.getPlugin(); // Check if it is enabled - it might be loaded, but not enabled. - if (!plugin.isEnabled()) { + if (!this.getPlugin().isEnabled()) { this.setState(State.DISABLED); return; } - registeredWorlds = new HashSet<>(); - // Start warp signs - warpSignsManager = new WarpSignsManager(this, plugin); - warpPanelManager = new WarpPanelManager(this); - // Load the listener - getServer().getPluginManager().registerEvents(new WarpSignsListener(this), plugin); - // Register commands - getPlugin().getAddonsManager().getGameModeAddons().stream() - .filter(a -> a.getDescription().getName().equals(BSKYBLOCK) || a.getDescription().getName().equals(ACIDISLAND)) - .forEach(a -> { - a.getPlayerCommand().ifPresent(c -> { - new WarpCommand(this, c); - new WarpsCommand(this, c); - registeredWorlds.add(c.getWorld()); - }); + registeredWorlds = new HashSet<>(); + + // Register commands + this.getPlugin().getAddonsManager().getGameModeAddons().forEach(gameModeAddon -> { + if (!this.settings.getDisabledGameModes().contains(gameModeAddon.getDescription().getName())) + { + if (gameModeAddon.getPlayerCommand().isPresent()) + { + this.registeredWorlds.add(gameModeAddon.getOverWorld()); + + new WarpCommand(this, gameModeAddon.getPlayerCommand().get()); + new WarpsCommand(this, gameModeAddon.getPlayerCommand().get()); + this.hooked = true; + } + } }); - // Done + + if (hooked) + { + // Start warp signs + warpSignsManager = new WarpSignsManager(this, this.getPlugin()); + warpPanelManager = new WarpPanelManager(this); + // Load the listener + getServer().getPluginManager().registerEvents(new WarpSignsListener(this), this.getPlugin()); + } } + @Override public void onDisable(){ // Save the warps @@ -76,6 +134,21 @@ public class Warp extends Addon { warpSignsManager.saveWarpList(); } + + /** + * This method loads addon configuration settings in memory. + */ + private void loadSettings() { + this.settings = new Config<>(this, Settings.class).loadConfigObject(); + + if (this.settings == null) { + // Disable + this.logError("WelcomeWarp settings could not load! Addon disabled."); + this.setState(State.DISABLED); + } + } + + /** * Get warp panel manager * @return @@ -104,7 +177,7 @@ public class Warp extends Addon { /** * @return the settings */ - public PluginConfig getSettings() { + public Settings getSettings() { return settings; } @@ -115,7 +188,7 @@ public class Warp extends Addon { * @return island level or null if there is no level plugin */ public Long getLevel(World world, UUID uniqueId) { - return plugin.getAddonsManager().getAddonByName(LEVEL_ADDON_NAME).map(l -> ((Level) l).getIslandLevel(world, uniqueId)).orElse(null); + return this.getPlugin().getAddonsManager().getAddonByName(LEVEL_ADDON_NAME).map(l -> ((Level) l).getIslandLevel(world, uniqueId)).orElse(null); } } diff --git a/src/main/java/world/bentobox/warps/config/PluginConfig.java b/src/main/java/world/bentobox/warps/config/PluginConfig.java deleted file mode 100644 index ea8541b..0000000 --- a/src/main/java/world/bentobox/warps/config/PluginConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package world.bentobox.warps.config; - -import world.bentobox.warps.Warp; - -public class PluginConfig { - - private int warpLevelRestriction; - - /** - * Loads the various settings from the config.yml file into the plugin - */ - public PluginConfig(Warp plugin) { - plugin.saveDefaultConfig(); - warpLevelRestriction = plugin.getConfig().getInt("warplevelrestriction",10); - // All done - } - - /** - * @return the warpLevelRestriction - */ - public int getWarpLevelRestriction() { - return warpLevelRestriction; - } -} diff --git a/src/main/java/world/bentobox/warps/config/Settings.java b/src/main/java/world/bentobox/warps/config/Settings.java new file mode 100644 index 0000000..89d2f67 --- /dev/null +++ b/src/main/java/world/bentobox/warps/config/Settings.java @@ -0,0 +1,142 @@ +package world.bentobox.warps.config; + +import java.util.HashSet; +import java.util.Set; + +import world.bentobox.bentobox.api.configuration.ConfigComment; +import world.bentobox.bentobox.api.configuration.ConfigEntry; +import world.bentobox.bentobox.api.configuration.StoreAt; +import world.bentobox.bentobox.database.objects.DataObject; + + +@StoreAt(filename="config.yml", path="addons/WelcomeWarps") +@ConfigComment("WelcomeWarps Configuration [version]") +@ConfigComment("This config file is dynamic and saved when the server is shutdown.") +@ConfigComment("You cannot edit it while the server is running because changes will") +@ConfigComment("be lost! Use in-game settings GUI or edit when server is offline.") +@ConfigComment("") +public class Settings implements DataObject +{ + @ConfigComment("") + @ConfigComment("Warp Restriction - needed levels to be able to create a warp") + @ConfigComment("0 or negative values will disable this restriction 10 is default") + @ConfigEntry(path = "warplevelrestriction") + private int warpLevelRestriction; + + @ConfigComment("") + @ConfigComment("Text that player must put on sign to make it a warp sign") + @ConfigComment("Not case sensitive!") + @ConfigEntry(path = "welcomeLine") + private String welcomeLine; + + @ConfigComment("") + @ConfigComment("This list stores GameModes in which Level addon should not work.") + @ConfigComment("To disable addon it is necessary to write its name in new line that starts with -. Example:") + @ConfigComment("disabled-gamemodes:") + @ConfigComment(" - BSkyBlock") + @ConfigEntry(path = "disabled-gamemodes") + private Set disabledGameModes = new HashSet<>(); + + @ConfigComment("") + private String uniqueId = "config"; + +// --------------------------------------------------------------------- +// Section: Constructor +// --------------------------------------------------------------------- + + + /** + * Loads the various settings from the config.yml file into the plugin + */ + public Settings() + { + // empty constructor + } + + +// --------------------------------------------------------------------- +// Section: Methods +// --------------------------------------------------------------------- + + + /** + * @return the warpLevelRestriction + */ + public int getWarpLevelRestriction() + { + return warpLevelRestriction; + } + + + /** + * @return the uniqueId + */ + @Override + public String getUniqueId() + { + return uniqueId; + } + + + /** + * @param uniqueId - unique ID the uniqueId to set + */ + @Override + public void setUniqueId(String uniqueId) + { + this.uniqueId = uniqueId; + } + + + /** + * This method sets the warpLevelRestriction object value. + * @param warpLevelRestriction the warpLevelRestriction object new value. + * + */ + public void setWarpLevelRestriction(int warpLevelRestriction) + { + this.warpLevelRestriction = warpLevelRestriction; + } + + + /** + * This method returns the welcomeLine object. + * @return the welcomeLine object. + */ + public String getWelcomeLine() + { + return welcomeLine; + } + + + /** + * This method sets the welcomeLine object value. + * @param welcomeLine the welcomeLine object new value. + * + */ + public void setWelcomeLine(String welcomeLine) + { + this.welcomeLine = welcomeLine; + } + + + /** + * This method returns the disabledGameModes object. + * @return the disabledGameModes object. + */ + public Set getDisabledGameModes() + { + return disabledGameModes; + } + + + /** + * This method sets the disabledGameModes object value. + * @param disabledGameModes the disabledGameModes object new value. + * + */ + public void setDisabledGameModes(Set disabledGameModes) + { + this.disabledGameModes = disabledGameModes; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index eeed321..3dd16db 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,3 +7,8 @@ warplevelrestriction: 10 # Not case sensitive! welcomeLine: [WELCOME] +# This list stores GameModes in which Challenges addon should not work. +# To disable addon it is necessary to write its name in new line that starts with -. Example: +# disabled-gamemodes: +# - BSkyBlock +disabled-gamemodes: [] \ No newline at end of file diff --git a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java index 945c869..1f5dd3b 100644 --- a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java +++ b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java @@ -1,22 +1,7 @@ package world.bentobox.warps; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.configuration.file.FileConfiguration; @@ -33,13 +18,21 @@ import org.mockito.stubbing.Answer; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandsManager; import world.bentobox.bentobox.managers.LocalesManager; -import world.bentobox.warps.config.PluginConfig; +import world.bentobox.warps.config.Settings; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @PrepareForTest({Bukkit.class}) @@ -55,7 +48,7 @@ public class WarpSignsListenerTest { private UUID uuid; private String[] lines; private FileConfiguration config; - private PluginConfig settings; + private Settings settings; private IslandsManager im; @Before @@ -110,7 +103,7 @@ public class WarpSignsListenerTest { // Lines lines = new String[] {"[WELCOME]", "line2", "line3", "line4"}; - settings = mock(PluginConfig.class); + settings = mock(Settings.class); when(settings.getWarpLevelRestriction()).thenReturn(10); when(addon.getSettings()).thenReturn(settings); From 9c88792b2731fae866fd03e3d847d77d92b6993e Mon Sep 17 00:00:00 2001 From: BONNe Date: Thu, 31 Jan 2019 20:27:15 +0200 Subject: [PATCH 05/12] Disable warp teleport while falling if world Flags.PREVENT_TELEPORT_WHEN_FALLING is enabled. --- .../java/world/bentobox/warps/WarpSignsManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/world/bentobox/warps/WarpSignsManager.java b/src/main/java/world/bentobox/warps/WarpSignsManager.java index 62a56ef..1eee454 100644 --- a/src/main/java/world/bentobox/warps/WarpSignsManager.java +++ b/src/main/java/world/bentobox/warps/WarpSignsManager.java @@ -24,6 +24,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; +import world.bentobox.bentobox.lists.Flags; import world.bentobox.warps.objects.WarpsData; import world.bentobox.warps.event.WarpInitiateEvent; import world.bentobox.warps.event.WarpListEvent; @@ -353,6 +354,15 @@ public class WarpSignsManager { addon.getWarpSignsManager().removeWarp(world, owner); return; } + + if (this.plugin.getIWM().inWorld(user.getWorld()) && + Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) && + user.getPlayer().getFallDistance() > 0) { + // We're sending the "hint" to the player to tell them they cannot teleport while falling. + user.sendMessage(Flags.PREVENT_TELEPORT_WHEN_FALLING.getHintReference()); + return; + } + // Find out if island is locked // TODO: Fire event From 35f0ecb6f0e593944942f73eca1788b806f3c1d7 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 2 Feb 2019 16:11:40 -0800 Subject: [PATCH 06/12] Fixes config.yml uniqueId was missing. --- src/main/resources/config.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3dd16db..95291ee 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,14 +1,21 @@ +# WelcomeWarps Configuration ${version} +# This config file is dynamic and saved when the server is shutdown. +# You cannot edit it while the server is running because changes will +# be lost! Use in-game settings GUI or edit when server is offline. +# +# # Warp Restriction - needed levels to be able to create a warp -# 0 or negative values will disable this restriction -# 10 is default +# 0 or negative values will disable this restriction 10 is default warplevelrestriction: 10 - +# # Text that player must put on sign to make it a warp sign # Not case sensitive! -welcomeLine: [WELCOME] - -# This list stores GameModes in which Challenges addon should not work. +welcomeLine: '[Welcome]' +# +# This list stores GameModes in which Level addon should not work. # To disable addon it is necessary to write its name in new line that starts with -. Example: # disabled-gamemodes: # - BSkyBlock -disabled-gamemodes: [] \ No newline at end of file +disabled-gamemodes: [] +# +uniqueId: config From 2f86f91fa4a70794e823ffe779f351d7dcf294de Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 3 Feb 2019 17:07:08 +0200 Subject: [PATCH 07/12] Add CaveBlock and SkyGrid permissions. --- src/main/resources/addon.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 0cfe154..bca4d96 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -13,6 +13,7 @@ permissions: bskyblock.island.addwarp: description: Player can create a welcome warp sign default: true + acidisland.island.warp: description: Player can use warp or warps commands default: true @@ -20,3 +21,16 @@ permissions: description: Player can create a welcome warp sign default: true + caveblock.island.warp: + description: Player can use warp or warps commands + default: true + caveblock.island.addwarp: + description: Player can create a welcome warp sign + default: true + + skygrid.island.warp: + description: Player can use warp or warps commands + default: true + skygrid.island.addwarp: + description: Player can create a welcome warp sign + default: true \ No newline at end of file From 88c8ed89cf25feae4b48debe8d399eda60234cd2 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 22 Feb 2019 14:42:09 +0100 Subject: [PATCH 08/12] Added fr-FR locale --- src/main/resources/locales/fr-FR.yml | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/resources/locales/fr-FR.yml diff --git a/src/main/resources/locales/fr-FR.yml b/src/main/resources/locales/fr-FR.yml new file mode 100644 index 0000000..941beec --- /dev/null +++ b/src/main/resources/locales/fr-FR.yml @@ -0,0 +1,31 @@ +########################################################################################### +# This is a YML file. Be careful when editing. Check your edits in a YAML checker like # +# the one at http://yaml-online-parser.appspot.com # +########################################################################################### + +warps: + deactivate: "&cAncien panneau de Warp désactivé !" + success: "&aSuccès !" + sign-removed: "&cPanneau de Warp supprimé !" + title: "Panneau Warp" + player-warped: "&2[name] s'est téléporté sur votre île !" + previous: "&6Page précédente" + next: "&6Page suivante" + warpToPlayersSign: "&6Téléportation sur l'île de [player]..." + # The [text] is replaced with the welcome line text from config.yml + warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne." + error: + does-not-exist: "&cCe Warp n'existe plus !" + no-remove: "&cVous ne pouvez pas supprimer ce panneau !" + not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela !" + no-permission: "&cVous n'avez pas la permission pour faire cela !" + not-on-island: "&cVous devez être sur votre île pour faire cela !" + duplicate: "&cPanneau dupliqué placé." + no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur." + your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]." + help: + description: "Ouvre le menu des Warps" +warp: + help: + parameters: "" + description: "te téléporte au Warp d'un autre joueur" From 140e05770d1c9fdd76fe80da4668a3e264c33110 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 3 Mar 2019 17:35:38 -0800 Subject: [PATCH 09/12] Version up Added codemc public repo. --- pom.xml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 7afb225..9cd3633 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,12 @@ - 4.0.0 world.bentobox warps - 1.2-SNAPSHOT + 1.2.1-SNAPSHOT WelcomeWarpSigns WelcomeWarpSigns is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland. @@ -55,6 +56,10 @@ codemc https://repo.codemc.org/repository/maven-snapshots/ + + codemc-public + https://repo.codemc.org/repository/maven-public/ + @@ -90,12 +95,12 @@ world.bentobox bentobox - 1.2.1-SNAPSHOT + 1.3.0-SNAPSHOT world.bentobox level - 1.1-SNAPSHOT + 1.3.0 provided From 79b568fbdfd03051154633d56ed636f68a5b24d5 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 3 Mar 2019 18:53:36 -0800 Subject: [PATCH 10/12] Updates locales. Fixes nether and end warping. Fixes issue with warp level checking wrong environment. Adds warning when warping to PVP enabled islands. https://github.com/BentoBoxWorld/addon-welcomewarpsigns/issues/21 --- .../bentobox/warps/WarpSignsListener.java | 7 +-- .../bentobox/warps/WarpSignsManager.java | 45 +++++++++++-------- .../bentobox/warps/commands/WarpCommand.java | 26 +++++------ src/main/resources/locales/en-US.yml | 45 ++++++++++--------- src/main/resources/locales/fr-FR.yml | 44 +++++++++--------- src/main/resources/locales/ja-JP.yml | 33 ++++++++++++++ src/main/resources/locales/zh-CN.yml | 42 +++++++++-------- .../bentobox/warps/WarpSignsListenerTest.java | 33 +++++++++----- 8 files changed, 167 insertions(+), 108 deletions(-) create mode 100755 src/main/resources/locales/ja-JP.yml diff --git a/src/main/java/world/bentobox/warps/WarpSignsListener.java b/src/main/java/world/bentobox/warps/WarpSignsListener.java index 3ed5495..8fdd38a 100644 --- a/src/main/java/world/bentobox/warps/WarpSignsListener.java +++ b/src/main/java/world/bentobox/warps/WarpSignsListener.java @@ -15,9 +15,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.SignChangeEvent; -import world.bentobox.warps.event.WarpRemoveEvent; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.util.Util; +import world.bentobox.warps.event.WarpRemoveEvent; /** * Handles warping. Players can add one sign @@ -99,8 +100,8 @@ public class WarpSignsListener implements Listener { user.sendMessage("general.errors.you-need", "[permission]", addon.getPermPrefix(b.getWorld()) + ".island.addwarp"); return; } - // Get level is level addon is available - Long level = addon.getLevel(b.getWorld(), user.getUniqueId()); + // Get level if level addon is available + Long level = addon.getLevel(Util.getWorld(b.getWorld()), user.getUniqueId()); if (level != null && level < addon.getSettings().getWarpLevelRestriction()) { user.sendMessage("warps.error.not-enough-level"); user.sendMessage("warps.error.your-level-is", diff --git a/src/main/java/world/bentobox/warps/WarpSignsManager.java b/src/main/java/world/bentobox/warps/WarpSignsManager.java index 1eee454..80ceb57 100644 --- a/src/main/java/world/bentobox/warps/WarpSignsManager.java +++ b/src/main/java/world/bentobox/warps/WarpSignsManager.java @@ -24,15 +24,15 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; -import world.bentobox.bentobox.lists.Flags; -import world.bentobox.warps.objects.WarpsData; -import world.bentobox.warps.event.WarpInitiateEvent; -import world.bentobox.warps.event.WarpListEvent; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.Database; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.util.Util; +import world.bentobox.warps.event.WarpInitiateEvent; +import world.bentobox.warps.event.WarpListEvent; +import world.bentobox.warps.objects.WarpsData; /** * Handles warping. Players can add one sign @@ -56,8 +56,7 @@ public class WarpSignsManager { * @return map of warps */ public Map getWarpMap(World world) { - worldsWarpList.putIfAbsent(world, new HashMap<>()); - return worldsWarpList.get(world); + return worldsWarpList.computeIfAbsent(Util.getWorld(world), k -> new HashMap<>()); } /** @@ -282,7 +281,7 @@ public class WarpSignsManager { inFront.getBlockZ() + 0.5D, yaw, 30F); user.teleport(actualWarp); if (pvp) { - user.sendRawMessage(user.getTranslation("protection.flags.PVP_OVERWORLD.active")); + user.sendMessage("protection.flags.PVP_OVERWORLD.active"); user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F); } else { user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F); @@ -356,23 +355,31 @@ public class WarpSignsManager { } if (this.plugin.getIWM().inWorld(user.getWorld()) && - Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) && - user.getPlayer().getFallDistance() > 0) { + Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) && + user.getPlayer().getFallDistance() > 0) { // We're sending the "hint" to the player to tell them they cannot teleport while falling. user.sendMessage(Flags.PREVENT_TELEPORT_WHEN_FALLING.getHintReference()); return; } - // Find out if island is locked - // TODO: Fire event - Island island = addon.getPlugin().getIslands().getIsland(world, owner); boolean pvp = false; if (island != null) { - //if ((warpSpot.getWorld().equals(IslandWorld.getIslandWorld()) && island.getFlag(SettingsFlag.PVP_OVERWORLD)) - // || (warpSpot.getWorld().equals(IslandWorld.getNetherWorld()) && island.getFlag(SettingsFlag.PVP_NETHER))) { - // pvp = true; - //} + // Check for PVP + switch (warpSpot.getWorld().getEnvironment()) { + case NETHER: + pvp = island.isAllowed(Flags.PVP_NETHER); + break; + case NORMAL: + pvp = island.isAllowed(Flags.PVP_OVERWORLD); + break; + case THE_END: + pvp = island.isAllowed(Flags.PVP_END); + break; + default: + break; + + } } // Find out which direction the warp is facing Block b = warpSpot.getBlock(); @@ -397,7 +404,7 @@ public class WarpSignsManager { return; } if (!(plugin.getIslands().isSafeLocation(warpSpot))) { - user.sendMessage("warps.error.NotSafe"); + user.sendMessage("warps.error.not-safe"); // WALL_SIGN's will always be unsafe if the place in front is obscured. if (b.getType().equals(Material.SIGN)) { addon.getLogger().warning( @@ -408,13 +415,13 @@ public class WarpSignsManager { } else { final Location actualWarp = new Location(warpSpot.getWorld(), warpSpot.getBlockX() + 0.5D, warpSpot.getBlockY(), warpSpot.getBlockZ() + 0.5D); - user.teleport(actualWarp); if (pvp) { - //user.sendLegacyMessage(user.getTranslation("igs." + SettingsFlag.PVP_OVERWORLD) + " " + user.getTranslation("igs.Allowed")); + user.sendMessage("protection.flags.PVP_OVERWORLD.active"); user.getWorld().playSound(user.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F); } else { user.getWorld().playSound(user.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F); } + user.teleport(actualWarp); return; } } diff --git a/src/main/java/world/bentobox/warps/commands/WarpCommand.java b/src/main/java/world/bentobox/warps/commands/WarpCommand.java index 9ce0bf7..c3bb85c 100644 --- a/src/main/java/world/bentobox/warps/commands/WarpCommand.java +++ b/src/main/java/world/bentobox/warps/commands/WarpCommand.java @@ -6,9 +6,9 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; -import world.bentobox.warps.Warp; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.user.User; +import world.bentobox.warps.Warp; /** * The /is warp command @@ -33,18 +33,6 @@ public class WarpCommand extends CompositeCommand { this.setDescription("warp.help.description"); } - @Override - public Optional> tabComplete(User user, String alias, List args) { - List options = new ArrayList<>(); - final Set warpList = addon.getWarpSignsManager().listWarps(getWorld()); - - for (UUID warp : warpList) { - options.add(addon.getPlugin().getPlayers().getName(warp)); - } - - return Optional.of(options); - } - @Override public boolean execute(User user, String label, List args) { if (args.size() == 1) { @@ -71,5 +59,17 @@ public class WarpCommand extends CompositeCommand { return false; } + @Override + public Optional> tabComplete(User user, String alias, List args) { + List options = new ArrayList<>(); + final Set warpList = addon.getWarpSignsManager().listWarps(getWorld()); + + for (UUID warp : warpList) { + options.add(addon.getPlugin().getPlayers().getName(warp)); + } + + return Optional.of(options); + } + } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 3810b4e..9c98c0e 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -3,30 +3,31 @@ # the one at http://yaml-online-parser.appspot.com # ########################################################################################### -warps: +warp: + help: + description: "warp to the player's warp sign" + parameters: +warps: deactivate: "&cOld warp sign deactivated!" - success: "&ASuccess!" - sign-removed: "&CWarp sign removed!" - title: "Warp Signs" + error: + does-not-exist: "&cOh snap! That warp no longer exists!" + duplicate: "&CDuplicate sign placed" + no-permission: "&CYou do not have permission to do that!" + no-remove: "&CYou cannot remove that sign!" + no-warps-yet: "&CThere are no warps available yet" + not-enough-level: "&CYour island level is not high enough!" + not-on-island: "&CYou must be on your island to do that!" + not-safe: "&cThat warp is not safe!" + your-level-is: "&cYou island level is only [level] and must be higher than [required]" + help: + description: "open the warps panel" + next: "&6Next page" player-warped: "&2[name] warped to your warp sign!" previous: "&6Previous page" - next: "&6Next page" - warpToPlayersSign: "&6Warping to [player]'s sign" - # The [text] is replaced with the welcome line text from config.yml + sign-removed: "&CWarp sign removed!" + success: "&ASuccess!" + title: "Warp Signs" warpTip: "&6Place a warp sign with [text] on the top" - error: - does-not-exist: "&cOh snap! That warp no longer exists!" - no-remove: "&CYou cannot remove that sign!" - not-enough-level: "&CYour island level is not high enough!" - no-permission: "&CYou do not have permission to do that!" - not-on-island: "&CYou must be on your island to do that!" - duplicate: "&CDuplicate sign placed" - no-warps-yet: "&CThere are no warps available yet" - your-level-is: "&cYou island level is only [level] and must be higher than [required]" - help: - description: "open the warps panel" -warp: - help: - parameters: "" - description: "warp to the player's warp sign" + warpToPlayersSign: "&6Warping to [player]'s sign" + \ No newline at end of file diff --git a/src/main/resources/locales/fr-FR.yml b/src/main/resources/locales/fr-FR.yml index 941beec..d581453 100644 --- a/src/main/resources/locales/fr-FR.yml +++ b/src/main/resources/locales/fr-FR.yml @@ -3,29 +3,29 @@ # the one at http://yaml-online-parser.appspot.com # ########################################################################################### -warps: +warp: + help: + description: "te téléporte au Warp d'un autre joueur" + parameters: +warps: deactivate: "&cAncien panneau de Warp désactivé !" - success: "&aSuccès !" - sign-removed: "&cPanneau de Warp supprimé !" - title: "Panneau Warp" + error: + does-not-exist: "&cCe Warp n'existe plus !" + duplicate: "&cPanneau dupliqué placé." + no-permission: "&cVous n'avez pas la permission pour faire cela !" + no-remove: "&cVous ne pouvez pas supprimer ce panneau !" + no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur." + not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela !" + not-on-island: "&cVous devez être sur votre île pour faire cela !" + not-safe: "&cCe Warp n'est pas sûr!" + your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]." + help: + description: "Ouvre le menu des Warps" + next: "&6Page suivante" player-warped: "&2[name] s'est téléporté sur votre île !" previous: "&6Page précédente" - next: "&6Page suivante" - warpToPlayersSign: "&6Téléportation sur l'île de [player]..." - # The [text] is replaced with the welcome line text from config.yml + sign-removed: "&cPanneau de Warp supprimé !" + success: "&aSuccès !" + title: "Panneau Warp" warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne." - error: - does-not-exist: "&cCe Warp n'existe plus !" - no-remove: "&cVous ne pouvez pas supprimer ce panneau !" - not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela !" - no-permission: "&cVous n'avez pas la permission pour faire cela !" - not-on-island: "&cVous devez être sur votre île pour faire cela !" - duplicate: "&cPanneau dupliqué placé." - no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur." - your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]." - help: - description: "Ouvre le menu des Warps" -warp: - help: - parameters: "" - description: "te téléporte au Warp d'un autre joueur" + warpToPlayersSign: "&6Téléportation sur l'île de [player]..." diff --git a/src/main/resources/locales/ja-JP.yml b/src/main/resources/locales/ja-JP.yml new file mode 100755 index 0000000..3dc80a3 --- /dev/null +++ b/src/main/resources/locales/ja-JP.yml @@ -0,0 +1,33 @@ +########################################################################################### +# This is a YML file. Be careful when editing. Check your edits in a YAML checker like # +# the one at http://yaml-online-parser.appspot.com # +########################################################################################### + +warp: + help: + description: "プレイヤーのワープサインにワープする" + parameters: <名> +warps: + deactivate: "&c前のワープサインが無効になりました!" + error: + does-not-exist: "&cそのワープはもう存在しません!" + duplicate: "&C重複サインを配置" + no-permission: "&C許可がありません!" + no-remove: "&Cワープサインは外せません!" + no-warps-yet: "&C利用可能なワープはまだありません" + not-enough-level: "&C島のレベルは十分に高くありません!" + not-on-island: "&Cあなたの島にいなければなりません!" + not-safe: "&cワープは安全ではありません。!" + your-level-is: "&c島レベルはわずか[level]で、[required]より高くなければなりません" + help: + description: "ワープパネルを開く" + next: "&6次のページ" + player-warped: "&2[name]はあなたのワープサインに反った!" + previous: "&6前のページ" + sign-removed: "&Cワープサインを削除!" + success: "&A完了!" + title: "ワープサイン" + warpTip: "&6最初の行に[text]と一緒にワープサインを置きます" + warpToPlayersSign: "&6[player]のサインに反っている" + + \ No newline at end of file diff --git a/src/main/resources/locales/zh-CN.yml b/src/main/resources/locales/zh-CN.yml index 47e91d2..8e6d69c 100644 --- a/src/main/resources/locales/zh-CN.yml +++ b/src/main/resources/locales/zh-CN.yml @@ -3,27 +3,31 @@ # 请在 http://yaml-online-parser.appspot.com 等 YAML 检查器中检查您的编辑. # ########################################################################################### +warp: + help: + description: 传送到该玩家的传送木牌处 + parameters: <玩家名称> warps: - removed: "&C传送木牌已移除" - success: "&A成功!" - sign-removed: "&C传送木牌已移除!" - title: "传送木牌" - previous: "&6上一页" - next: "&6下一页" - warpToPlayersSign: "&6正传送到 [player] 的传送木牌" - warpTip: "&6放置一个第一行是 [text] 的木牌以创建传送木牌" - error: - no-remove: "&C无权移除传送木牌!" - not-enough-level: "&C岛屿等级不够高!" - no-permission: "&C权限不足!" - not-on-island: "&C操作必须在空岛上进行!" + deactivate: "&c禁用的旧转移标志!" + error: + does-not-exist: "&c转移不再存在!" duplicate: "&C木牌重复" + no-permission: "&C权限不足!" + no-remove: "&C无权移除传送木牌!" no-warps-yet: "&C暂无可用传送木牌" + not-enough-level: "&C岛屿等级不够高!" + not-on-island: "&C操作必须在空岛上进行!" + not-safe: "&c转移不安全!" your-level-is: "&c岛屿当前等级 [level], 需要等级 [required]" - help: - description: "打开传送面板" -warp: - help: - parameters: "<玩家名称>" - description: "传送到该玩家的传送木牌处" + help: + description: 打开传送面板 + next: "&6下一页" + player-warped: "&2[name]转移到你的标志!" + previous: "&6上一页" + sign-removed: "&C传送木牌已移除!" + success: "&A成功!" + title: 传送木牌 + warpTip: "&6放置一个第一行是 [text] 的木牌以创建传送木牌" + warpToPlayersSign: "&6正传送到 [player] 的传送木牌" + diff --git a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java index 1f5dd3b..b045625 100644 --- a/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java +++ b/src/test/java/world/bentobox/warps/WarpSignsListenerTest.java @@ -1,7 +1,23 @@ package world.bentobox.warps; -import org.bukkit.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.configuration.file.FileConfiguration; @@ -18,24 +34,17 @@ import org.mockito.stubbing.Answer; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandsManager; import world.bentobox.bentobox.managers.LocalesManager; +import world.bentobox.bentobox.util.Util; import world.bentobox.warps.config.Settings; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - @RunWith(PowerMockRunner.class) -@PrepareForTest({Bukkit.class}) +@PrepareForTest({Bukkit.class, Util.class}) public class WarpSignsListenerTest { private Warp addon; @@ -118,6 +127,10 @@ public class WarpSignsListenerTest { IslandWorldManager iwm = mock(IslandWorldManager.class); when(plugin.getIWM()).thenReturn(iwm); when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); + + // Util + PowerMockito.mockStatic(Util.class); + when(Util.getWorld(Mockito.any())).thenReturn(world); } @Test From 622057c906b752096149b93e7d0fc833d3b51e87 Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 6 Mar 2019 22:04:47 -0800 Subject: [PATCH 11/12] Checks for null worlds on load. --- src/main/java/world/bentobox/warps/WarpSignsManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/warps/WarpSignsManager.java b/src/main/java/world/bentobox/warps/WarpSignsManager.java index 80ceb57..b02d9fc 100644 --- a/src/main/java/world/bentobox/warps/WarpSignsManager.java +++ b/src/main/java/world/bentobox/warps/WarpSignsManager.java @@ -169,7 +169,7 @@ public class WarpSignsManager { // Load into map if (warps != null) { warps.getWarpSigns().forEach((k,v) -> { - if (k != null && (k.getBlock().getType().equals(Material.SIGN) || k.getBlock().getType().equals(Material.WALL_SIGN))) { + if (k != null && k.getWorld() != null && (k.getBlock().getType().equals(Material.SIGN) || k.getBlock().getType().equals(Material.WALL_SIGN))) { // Add to map getWarpMap(k.getWorld()).put(v, k); } From bfbf95486fc5d95065b4802e383249d7576455c5 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 28 Mar 2019 20:53:51 -0700 Subject: [PATCH 12/12] Version 1.4.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9cd3633..456ec17 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ world.bentobox warps - 1.2.1-SNAPSHOT + 1.4.0 WelcomeWarpSigns WelcomeWarpSigns is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland. @@ -95,12 +95,12 @@ world.bentobox bentobox - 1.3.0-SNAPSHOT + 1.4.0 world.bentobox level - 1.3.0 + 1.4.0 provided