hunger to rtp + custom permission configs (framework)

This commit is contained in:
SuperRonanCraft 2020-09-21 19:03:45 -04:00
parent 020fa52898
commit 18f4ebb40e
13 changed files with 62 additions and 13 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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() {

View File

@ -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));

View File

@ -96,3 +96,19 @@ WorldType: # Available types are NORMAL, NETHER
- world: NORMAL
- world_nether: NETHER
- world_the_end: NORMAL
PermissionConfigs: #Player requires "betterrtp.config.<world_name>" 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

View File

@ -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

View File

@ -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%未被传送!'

View File

@ -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%未被傳送!'

View File

@ -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!'

View File

@ -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!'

View File

@ -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é!'

View File

@ -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されませんでした'

View File

@ -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% не был телепортирован!'