diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java index 4f58f7e..5a9cde0 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java @@ -52,8 +52,6 @@ public class RTP { if (getPl().getSettings().debug) getPl().getLogger().info("- Override '" + entry.getKey() + "' -> '" + entry.getValue() + "' added"); } - //for (String s : config.getConfigurationSection("Override").getKeys(false)) - // overriden.put(s, config.getString("Override." + s)); } catch (Exception e) { //No Overrides } @@ -158,9 +156,8 @@ public class RTP { if (this.world_type.containsKey(worldName)) world_type = this.world_type.get(worldName); pWorld.setWorldtype(world_type); - // Check world price + // Economy if (!getPl().getEco().charge(p, pWorld.getPrice())) { - getPl().getText().getFailedPrice(p, pWorld.getPrice()); getPl().getCmd().cooldowns.remove(p.getUniqueId()); return; } diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/Permissions.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/Permissions.java index d00692d..ace75bb 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/Permissions.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/Permissions.java @@ -19,10 +19,14 @@ public class Permissions { return perm(pre + "use", sendi); } - public boolean getEconomy(CommandSender sendi) { + public boolean getBypassEconomy(CommandSender sendi) { return perm(pre + "bypass.economy", sendi); } + public boolean getBypassHunger(CommandSender sendi) { + return perm(pre + "bypass.hunger", sendi); + } + public boolean getBypassCooldown(CommandSender sendi) { return perm(pre + "bypass.cooldown", sendi); } 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 275f7eb..839b9d4 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/depends/DepEconomy.java @@ -9,19 +9,32 @@ import org.bukkit.plugin.RegisteredServiceProvider; public class DepEconomy { private Economy e; + private int hunger = 0; private boolean checked = false; public boolean charge(Player player, int price) { check(false); - //player.sendMessage("Charging = " + (e != null) + " charge = " + price); - if (e != null) - if (price != 0) { - if (!Main.getInstance().getPerms().getEconomy(player)) { - EconomyResponse r = e.withdrawPlayer(player, price); - return r.transactionSuccess(); - } - return true; + //Hunger Stuff + if (hunger != 0) { + boolean has_hunger = player.getSaturation() > hunger; + if (!has_hunger) { + Main.getInstance().getText().getFailedHunger(player); + return false; } + } + //Economy Stuff + if (e != null && price != 0 && !Main.getInstance().getPerms().getBypassEconomy(player)) { + try { + EconomyResponse r = e.withdrawPlayer(player, price); + boolean passed_economy = r.transactionSuccess(); + if (passed_economy) + Main.getInstance().getText().getFailedPrice(player, price); + return passed_economy; + } catch (Exception e) { + e.printStackTrace(); + } + } + //Default value return true; } @@ -38,6 +51,10 @@ public class DepEconomy { private void check(boolean force) { if (!checked || force) registerEconomy(); + if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Hunger.Enabled")) + hunger = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Hunger.Honches"); + else + hunger = 0; } private void registerEconomy() { diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java index 52234d4..3d01bf3 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java @@ -48,6 +48,10 @@ public class Messages { sms(sendi, getLang().getString(preM + "Failed.Price").replaceAll("%price%", String.valueOf(price))); } + public void getFailedHunger(CommandSender sendi) { + sms(sendi, getLang().getString(preM + "Failed.Hunger")); + } + public void getOtherNotSafe(CommandSender sendi, int attempts, String player) { sms(sendi, getLang().getString(preM + "Other.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)) .replaceAll("%player%", player)); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 641086c..b98b785 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -96,3 +96,19 @@ WorldType: # Available types are NORMAL, NETHER - world: NORMAL - world_nether: NETHER - world_the_end: NORMAL + +PermissionConfigs: #Player requires "betterrtp.config." to trigger these configs + - vip: #betterrtp.config.vip + - Build_World: #World named "Build_World" + MaxRadius: 10000 + MinRadius: 1000 + - Survival_World: + MaxRadius: 5000 + MinRadius: 1000 + - vip2: + - Build_World: + MaxRadius: 25000 + MinRadius: 10000 + - Survival_World: + MaxRadius: 15000 + MinRadius: 1000 \ No newline at end of file diff --git a/src/main/resources/economy.yml b/src/main/resources/economy.yml index c6f9253..2f7383a 100644 --- a/src/main/resources/economy.yml +++ b/src/main/resources/economy.yml @@ -5,6 +5,10 @@ Economy: ## Give players the permission "betterrtp.eco.bypass" to bypass economy Price: 5 +Hunger: #Make rtp'ing take up hunger to avoid exploits + Enabled: false + Honches: 4 + CustomWorlds: ## Enable custom world charging Enabled: true diff --git a/src/main/resources/lang/chn.yml b/src/main/resources/lang/chn.yml index 557f487..4fde006 100644 --- a/src/main/resources/lang/chn.yml +++ b/src/main/resources/lang/chn.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&c你的钱不够了,&7你至少要有$%price%&7才能随机传送!' NotSafe: '&c由于在%attempts%次尝试内未能找到安全的位置,&7你未被传送!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player%被传送到了&7 x=%x% y=%y% z=%z%。共尝试&f%attempts%&7次!' NotSafe: '&c由于在%attempts%次尝试内未能找到安全的位置,&7%player%未被传送!' diff --git a/src/main/resources/lang/cht.yml b/src/main/resources/lang/cht.yml index 80ca9ca..c1de170 100644 --- a/src/main/resources/lang/cht.yml +++ b/src/main/resources/lang/cht.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&c您的資金不夠了!&7您需要有$%price%&7才能嘗試RTP!' NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7您未被傳送!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player%被傳送到了&7 x=%x% y=%y% z=%z%。一共嘗試&f%attempts%&7次!' NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7%player%未被傳送!' diff --git a/src/main/resources/lang/du.yml b/src/main/resources/lang/du.yml index 1323d65..b2905d3 100644 --- a/src/main/resources/lang/du.yml +++ b/src/main/resources/lang/du.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&cKan niet rtpen vanwege onvoldoende saldo! &7Je moet minstens $%price% &7hebben om te rtpen!' NotSafe: '&cKon geen veilige plek vinden, Probeer opnieuw! &7Je bent niet ge tp''d!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player% is getp''d naar&7 x=%x% y=%y% z=%z% in &f%attempts% &7pogingen!' NotSafe: '&cKon geen veilige plek binnenin %attempts% pogingen! &7%player% is niet gertp''d!' diff --git a/src/main/resources/lang/en.yml b/src/main/resources/lang/en.yml index 5d79fe1..b4d2440 100644 --- a/src/main/resources/lang/en.yml +++ b/src/main/resources/lang/en.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&cCould not rtp because of insufficent funds! &7You must have atleast $%price% &7to rtp!' NotSafe: '&cCould not find safe spot within %attempts% attempts! &7You were not RTP''d!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player% has been tp''d to&7 x=%x% y=%y% z=%z% in &f%attempts% &7attempts!' NotSafe: '&cCould not find safe spot within %attempts% attempts! &7%player% was not rtp''d!' diff --git a/src/main/resources/lang/fr.yml b/src/main/resources/lang/fr.yml index d340fdf..f752bcd 100644 --- a/src/main/resources/lang/fr.yml +++ b/src/main/resources/lang/fr.yml @@ -9,6 +9,7 @@ Messages: Failed: Price: '&cTu n''a pas pu être téléporté; Manque de fonds! &7Tu doit avoir au moins $%price% &7pour te téléporter!' NotSafe: '&cImpossible de trouver un endroit sûr en %attempts% tentatives! &7Tu n''a pas été téléporté!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player% a été téléporté à&7 x=%x% y=%y% z=%z% em &f%attempts% &7tentatives!' NotSafe: '&cImpossible de trouver un endroit sûr en %attempts% tentatives! &7%player% n''a pas été téléporté!' diff --git a/src/main/resources/lang/ja.yml b/src/main/resources/lang/ja.yml index f20acd3..59fc302 100644 --- a/src/main/resources/lang/ja.yml +++ b/src/main/resources/lang/ja.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&c資金が不十分のためRTPできませんでした! &7RTPには最低$%price%&7が必要です!' NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7あなたははRTPされませんでした!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player%が&7x=%x% y=%y% z=%z% に&f%attempts%&7回の試行でテレポートしました!' NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7%player%はRTPされませんでした!' diff --git a/src/main/resources/lang/ru.yml b/src/main/resources/lang/ru.yml index 68bd456..55264ab 100644 --- a/src/main/resources/lang/ru.yml +++ b/src/main/resources/lang/ru.yml @@ -8,6 +8,7 @@ Messages: Failed: Price: '&cУ вас недостаточно денег для телепортации! &7У вас должно быть хотябы $%price% &7для rtp!' NotSafe: '&cНе удалось найти безопасное место за %attempts% попыток! &7Вас не телепортировало!' + Hunger: '&cCould not rtp because you are... &7too hungry&c, eat something fella!' Other: Success: '&a%player% был телепортирован на&7 x=%x% y=%y% z=%z% за &f%attempts% &7попыток!' NotSafe: '&cНе удалось найти безопасное место за %attempts% попыток! &7%player% не был телепортирован!'