From 60458c35f9d35c87b3246a0401e58ef68164c050 Mon Sep 17 00:00:00 2001 From: SuperRonanCraft Date: Mon, 21 Sep 2020 21:25:19 -0400 Subject: [PATCH] config.yml fix + hunger to rtp added --- .../references/depends/DepEconomy.java | 14 +++- .../BetterRTP/references/file/FileBasics.java | 1 - src/main/resources/config.yml | 78 +++++++++---------- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java index 839b9d4..2759ea8 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java @@ -4,6 +4,7 @@ import me.SuperRonanCraft.BetterRTP.references.file.FileBasics; import me.SuperRonanCraft.BetterRTP.Main; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; +import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.plugin.RegisteredServiceProvider; @@ -15,11 +16,15 @@ public class DepEconomy { public boolean charge(Player player, int price) { check(false); //Hunger Stuff - if (hunger != 0) { - boolean has_hunger = player.getSaturation() > hunger; + boolean took_food = false; + if (hunger != 0 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) { + boolean has_hunger = player.getFoodLevel() > hunger; if (!has_hunger) { Main.getInstance().getText().getFailedHunger(player); return false; + } else { + player.setFoodLevel(player.getFoodLevel() - hunger); + took_food = true; } } //Economy Stuff @@ -27,8 +32,11 @@ public class DepEconomy { try { EconomyResponse r = e.withdrawPlayer(player, price); boolean passed_economy = r.transactionSuccess(); - if (passed_economy) + if (!passed_economy) { Main.getInstance().getText().getFailedPrice(player, price); + if (took_food) + player.setFoodLevel(player.getFoodLevel() + hunger); + } return passed_economy; } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/FileBasics.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/FileBasics.java index 954cd48..2e67f9d 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/FileBasics.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/FileBasics.java @@ -100,7 +100,6 @@ public class FileBasics { config.options().copyDefaults(true); in.close(); } - Main.getInstance().saveDefaultConfig(); config.save(file); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b98b785..bd472e5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -48,18 +48,18 @@ Default: ## Blocks BetterRTP will NOT teleport onto. More Blocks at: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html # BlacklistedBlocks: - - stationary_water - - stationary_lava - - water - - flowing_water - - lava - - flowing_lava - - cactus - - leaves - - leaves_2 - - air - - void_air - - bedrock +- stationary_water +- stationary_lava +- water +- flowing_water +- lava +- flowing_lava +- cactus +- leaves +- leaves_2 +- air +- void_air +- bedrock ## Worlds to NOT allow /rtp in, unless there is an override to another enabled world # DisabledWorlds: @@ -69,22 +69,22 @@ DisabledWorlds: ## Worlds you want to have a custom min/max and spawn center in # ## [MaxRadius] and [MinRadius] MUST be positive! These cannot be equal to each other! CustomWorlds: - - custom_world_1: - UseWorldBorder: false - ## If UseWorldBorder is true, everything will be ignored EXCEPT "MinRadius"! - MaxRadius: 1000 - MinRadius: 100 - CenterX: 0 - CenterZ: 0 - - other_custom_world: - MaxRadius: 100000 - MinRadius: 1000 - CenterX: 123 - CenterZ: -123 - ## Biomes are optional, but useful! More biomes: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html - Biomes: - - 'desert' - - 'forest' +- custom_world_1: + UseWorldBorder: false + ## If UseWorldBorder is true, everything will be ignored EXCEPT "MinRadius"! + MaxRadius: 1000 + MinRadius: 100 + CenterX: 0 + CenterZ: 0 +- other_custom_world: + MaxRadius: 100000 + MinRadius: 1000 + CenterX: 123 + CenterZ: -123 + ## Biomes are optional, but useful! More biomes: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html + Biomes: + - 'desert' + - 'forest' ## Override a world and rtp a player executing the command in one world, to another Overrides: @@ -93,22 +93,22 @@ Overrides: - creative_world: 'world' WorldType: # Available types are NORMAL, NETHER - - world: NORMAL - - world_nether: NETHER - - world_the_end: NORMAL +- world: NORMAL +- world_nether: NETHER +- world_the_end: NORMAL PermissionConfigs: #Player requires "betterrtp.config." to trigger these configs - - vip: #betterrtp.config.vip +- vip: #betterrtp.config.vip - Build_World: #World named "Build_World" - MaxRadius: 10000 - MinRadius: 1000 + MaxRadius: 10000 + MinRadius: 1000 - Survival_World: MaxRadius: 5000 MinRadius: 1000 - - vip2: +- vip2: - Build_World: - MaxRadius: 25000 - MinRadius: 10000 + MaxRadius: 25000 + MinRadius: 10000 - Survival_World: - MaxRadius: 15000 - MinRadius: 1000 \ No newline at end of file + MaxRadius: 15000 + MinRadius: 1000 \ No newline at end of file