diff --git a/Islands.iml b/Islands.iml
index 49fdce5..16be83f 100644
--- a/Islands.iml
+++ b/Islands.iml
@@ -8,9 +8,9 @@
-
+
\ No newline at end of file
diff --git a/src/config.yml b/src/config.yml
index 69bd6b5..3c4d4b5 100644
--- a/src/config.yml
+++ b/src/config.yml
@@ -7,10 +7,10 @@ groupLimits: # Requires vault to work, all limits can
islandSizes: # Island sizing. You can add or remove as many sizes as you want.
BIG: 80 # NORMAL is the fallback size. At least 1 size has to be defined.
- NORMAL: 64
- SMALL: 32
+ NORMAL: 64 # For now due to bukkit api, the default sizes here can be disabled only by
+ SMALL: 32 # setting their size as 0.
-islandCost:
+islandPrices: # If vault has been enabled, you can set island creation prices here
BIG: 5000
NORMAL: 3000
SMALL: 1000
diff --git a/src/me/aleksilassila/islands/GUIs/CreateGUI.java b/src/me/aleksilassila/islands/GUIs/CreateGUI.java
index adc3bc7..ba3ba0b 100644
--- a/src/me/aleksilassila/islands/GUIs/CreateGUI.java
+++ b/src/me/aleksilassila/islands/GUIs/CreateGUI.java
@@ -6,7 +6,6 @@
import me.aleksilassila.islands.Islands;
import me.aleksilassila.islands.utils.BiomeMaterials;
import me.aleksilassila.islands.utils.Messages;
-import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Biome;
@@ -83,11 +82,13 @@ private Gui getSizeGui(Biome biome) {
Gui gui = createPaginatedGUI(2, Messages.get("gui.create.SIZE_TITLE"), availableSizePanes("island " + subcommand + " " + biome.name()));
gui.setOnTopClick(inventoryClickEvent -> inventoryClickEvent.setCancelled(true));
- StaticPane balance = new StaticPane(0, 1, 1, 1);
+ if (plugin.econ != null) {
+ StaticPane balance = new StaticPane(0, 1, 1, 1);
- balance.addItem(new GuiItem(createGuiItem(Material.EMERALD, Messages.get("gui.create.BALANCE"), true, Messages.get("gui.create.BALANCE_LORE", plugin.econ.getBalance(player)))), 0, 0); // FIXME test without vault
+ balance.addItem(new GuiItem(createGuiItem(Material.EMERALD, Messages.get("gui.create.BALANCE"), true, Messages.get("gui.create.BALANCE_LORE", plugin.econ.getBalance(player)))), 0, 0); // FIXME test without vault
- gui.addPane(balance);
+ gui.addPane(balance);
+ }
return gui;
}
@@ -107,12 +108,17 @@ private List availableSizePanes(String createCommand) {
int islandSize = plugin.definedIslandSizes.get(key);
if (!player.hasPermission(plugin.getCreatePermission(islandSize))) continue;
- double cost = plugin.islandCosts.getOrDefault(islandSize, 0.0) + recreateCost;
+ double cost = 0.0;
+
+ if (plugin.econ != null) {
+ cost = plugin.islandPrices.getOrDefault(islandSize, 0.0) + recreateCost;
- if (oldCost != null) {
- cost = Math.max(cost - oldCost, 0);
+ if (oldCost != null) {
+ cost = Math.max(cost - oldCost, 0);
+ }
}
+
pane.addItem(
new GuiItem(
createGuiItem(
diff --git a/src/me/aleksilassila/islands/Islands.java b/src/me/aleksilassila/islands/Islands.java
index 3342abe..39cf770 100644
--- a/src/me/aleksilassila/islands/Islands.java
+++ b/src/me/aleksilassila/islands/Islands.java
@@ -51,7 +51,7 @@ public class Islands extends JavaPlugin {
public Set playersWithNoFall = new HashSet<>();
public HashMap confirmations;
public Map teleportCooldowns;
- public Map islandCosts;
+ public Map islandPrices;
public Map definedIslandSizes;
public Map> definedIslandShapes;
@@ -306,12 +306,12 @@ private boolean setupEconomy() {
}
econ = rsp.getProvider();
- islandCosts = new HashMap<>();
+ islandPrices = new HashMap<>();
for (String size : Objects.requireNonNull(getConfig().getConfigurationSection("islandSizes")).getKeys(false)) {
- if (getConfig().getDouble("islandCost." + size) > 0) {
- getLogger().info("Added cost: " + getConfig().getInt("islandSizes." + size) + " for " + getConfig().getDouble("islandCost." + size));
- islandCosts.put(getConfig().getInt("islandSizes." + size), getConfig().getDouble("islandCost." + size));
+ if (getConfig().getDouble("islandPrices." + size) > 0) {
+ getLogger().info("Added cost: " + getConfig().getInt("islandSizes." + size) + " for " + getConfig().getDouble("islandPrices." + size));
+ islandPrices.put(getConfig().getInt("islandSizes." + size), getConfig().getDouble("islandPrices." + size));
}
}
diff --git a/src/me/aleksilassila/islands/commands/subcommands/CreateSubcommand.java b/src/me/aleksilassila/islands/commands/subcommands/CreateSubcommand.java
index d29d24b..e7ed97d 100644
--- a/src/me/aleksilassila/islands/commands/subcommands/CreateSubcommand.java
+++ b/src/me/aleksilassila/islands/commands/subcommands/CreateSubcommand.java
@@ -1,6 +1,5 @@
package me.aleksilassila.islands.commands.subcommands;
-import com.mojang.brigadier.Message;
import me.aleksilassila.islands.GUIs.CreateGUI;
import me.aleksilassila.islands.IslandLayout;
import me.aleksilassila.islands.Islands;
@@ -8,7 +7,6 @@
import me.aleksilassila.islands.commands.Subcommand;
import me.aleksilassila.islands.utils.Messages;
import me.aleksilassila.islands.utils.Permissions;
-import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
@@ -50,15 +48,6 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
if (args.length < 1) {
new CreateGUI(plugin, player, "create").open();
- // player.sendMessage(Messages.help.CREATE);
-//
-// for (Biome biome : availableLocations.keySet()) {
-// if (availableLocations.get(biome).size() > 0) {
-// player.sendMessage(ChatColor.GOLD + biome.toString() + ChatColor.GREEN + " has " + ChatColor.GOLD
-// + availableLocations.get(biome).size() + ChatColor.GREEN + " island variations available.");
-// }
-// }
-
return;
}
@@ -89,7 +78,7 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
return;
}
- if (!hasFunds(player, islandSize)) {
+ if (plugin.econ != null && !hasFunds(player, islandSize)) {
player.sendMessage(Messages.get("error.INSUFFICIENT_FUNDS"));
return;
}
@@ -114,14 +103,14 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
return;
}
- pay(player, islandSize);
+ if (plugin.econ != null) pay(player, islandSize);
player.sendTitle(Messages.get("success.ISLAND_GEN_TITLE"), Messages.get("success.ISLAND_GEN_SUBTITLE"), 10, 20 * 7, 10);
}
private boolean hasFunds(Player player, int islandSize) {
if (plugin.econ == null) return true;
- double cost = plugin.islandCosts.getOrDefault(islandSize, 0.0);
+ double cost = plugin.islandPrices.getOrDefault(islandSize, 0.0);
return plugin.econ.has(player, cost);
}
@@ -129,7 +118,7 @@ private boolean hasFunds(Player player, int islandSize) {
private void pay(Player player, int islandSize) {
if (plugin.econ == null) return;
- double cost = plugin.islandCosts.getOrDefault(islandSize, 0.0);
+ double cost = plugin.islandPrices.getOrDefault(islandSize, 0.0);
if (cost > 0) {
plugin.econ.withdrawPlayer(player, cost);
diff --git a/src/me/aleksilassila/islands/commands/subcommands/RecreateSubcommand.java b/src/me/aleksilassila/islands/commands/subcommands/RecreateSubcommand.java
index 6a565c3..27aab1d 100644
--- a/src/me/aleksilassila/islands/commands/subcommands/RecreateSubcommand.java
+++ b/src/me/aleksilassila/islands/commands/subcommands/RecreateSubcommand.java
@@ -65,8 +65,8 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
if (args.length < 1) {
CreateGUI gui = new CreateGUI(plugin, player, "recreate");
- if (plugin.getConfig().getBoolean("economy.recreateSum")) {
- double oldCost = plugin.islandCosts.getOrDefault(plugin.getIslandsConfig().getInt(islandId + ".size"), 0.0);
+ if (plugin.econ != null && plugin.getConfig().getBoolean("economy.recreateSum")) {
+ double oldCost = plugin.islandPrices.getOrDefault(plugin.getIslandsConfig().getInt(islandId + ".size"), 0.0);
gui.setOldCost(oldCost);
}
@@ -74,18 +74,22 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
return;
}
- double cost = plugin.islandCosts.getOrDefault(islandSize, 0.0);
- cost += plugin.getConfig().getDouble("economy.recreateCost");
+ double cost = 0.0;
- if (plugin.getConfig().getBoolean("economy.recreateSum")) {
- double oldCost = plugin.islandCosts.getOrDefault(plugin.getIslandsConfig().getInt(islandId + ".size"), 0.0);
+ if (plugin.econ != null) {
+ cost = plugin.islandPrices.getOrDefault(islandSize, 0.0);
+ cost += plugin.getConfig().getDouble("economy.recreateCost");
- cost = Math.max(cost - oldCost, 0);
- }
+ if (plugin.getConfig().getBoolean("economy.recreateSum")) {
+ double oldCost = plugin.islandPrices.getOrDefault(plugin.getIslandsConfig().getInt(islandId + ".size"), 0.0);
- if (!hasFunds(player, islandSize, cost)) {
- player.sendMessage(Messages.get("error.INSUFFICIENT_FUNDS"));
- return;
+ cost = Math.max(cost - oldCost, 0);
+ }
+
+ if (!hasFunds(player, islandSize, cost)) {
+ player.sendMessage(Messages.get("error.INSUFFICIENT_FUNDS"));
+ return;
+ }
}
targetBiome = utils.getTargetBiome(args[0]);
@@ -113,7 +117,7 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
return;
}
- pay(player, islandSize, cost);
+ if (plugin.econ != null) pay(player, islandSize, cost);
player.sendTitle(Messages.get("success.ISLAND_GEN_TITLE"), Messages.get("success.ISLAND_GEN_SUBTITLE"), 10, 20 * 7, 10);
} catch (IllegalArgumentException e) {