economy uncharge removed

now charges before teleporting after it's found a safe spot
This commit is contained in:
SuperRonanCraft 2020-10-01 11:55:56 -04:00
parent 7b2871f17d
commit ea1fa435dd
5 changed files with 63 additions and 13 deletions

View File

@ -144,33 +144,35 @@ public class RTP {
world_name = overriden.get(world_name);
// Not forced and has 'betterrtp.world.<world>'
if (sendi == p && !getPl().getPerms().getAWorld(sendi, world_name)) {
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
getPl().getText().getNoPermissionWorld(p, world_name);
return;
}
// Check disabled worlds
if (disabledWorlds.contains(world_name)) {
getPl().getText().getDisabledWorld(sendi, world_name);
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
return;
}
// Check if nulled or world doesnt exist
if (Bukkit.getWorld(world_name) == null) {
getPl().getText().getNotExist(sendi, world_name);
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
return;
}
WorldPlayer pWorld = getPlayerWorld(p, world_name, biomes, true);
// Economy
if (!getPl().getEco().charge(sendi, pWorld)) {
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
if (!getPl().getEco().hasBalance(sendi, pWorld)) {
return;
}
rtp(sendi, pWorld, delay);
}
private void rtp(CommandSender sendi, WorldPlayer pWorld, boolean delay) {
//Cooldown
Player p = pWorld.getPlayer();
getPl().getCmd().cooldowns.add(p.getUniqueId());
// Delaying? Else, just go
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
//Setup player rtp methods
RTPPlayer rtp = new RTPPlayer(p, this, pWorld);
// Delaying? Else, just go
if (getPl().getSettings().delayEnabled && delay) {
new RTPDelay(sendi, rtp, delayTime, cancelOnMove, cancelOnDamage);
} else {

View File

@ -46,8 +46,10 @@ public class RTPPlayer {
default:
tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
}
//Valid location?
if (tpLoc != null && checkDepends(tpLoc))
settings.teleport.sendPlayer(sendi, p, tpLoc, pWorld.getPrice(), pWorld.getAttempts());
if (getPl().getEco().charge(p, pWorld))
settings.teleport.sendPlayer(sendi, p, tpLoc, pWorld.getPrice(), pWorld.getAttempts());
else
randomlyTeleport(sendi);
});
@ -61,7 +63,7 @@ public class RTPPlayer {
else
getPl().getText().getOtherNotSafe(sendi, settings.maxAttempts, p.getName());
getPl().getCmd().cooldowns.remove(p.getUniqueId());
getPl().getEco().unCharge(p, pWorld);
//getPl().getEco().unCharge(p, pWorld);
getPl().getCmd().rtping.put(p.getUniqueId(), false);
}

View File

@ -52,10 +52,38 @@ public class DepEconomy {
return true;
}
public void unCharge(Player p, WorldPlayer pWorld) {
public boolean hasBalance(CommandSender sendi, WorldPlayer pWorld) {
check(false);
Player player = pWorld.getPlayer();
//Hunger Stuff
if (hunger != 0
&& sendi == player
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
boolean has_hunger = player.getFoodLevel() > hunger;
if (!has_hunger) {
Main.getInstance().getText().getFailedHunger(sendi);
return false;
}
}
//Economy Stuff
if (e != null && pWorld.getPrice() != 0 && !Main.getInstance().getPerms().getBypassEconomy(sendi)) {
try {
boolean passed_economy = e.getBalance(player) >= pWorld.getPrice();
if (!passed_economy)
Main.getInstance().getText().getFailedPrice(sendi, pWorld.getPrice());
return passed_economy;
} catch (Exception e) {
e.printStackTrace();
}
}
//Default value
return true;
}
/*public void unCharge(Player p, WorldPlayer pWorld) {
if (e != null && pWorld.getPrice() != 0 && pWorld.eco_money_taken)
e.depositPlayer(p, pWorld.getPrice());
}
}*/
public void load() {
check(true);

View File

@ -17,12 +17,10 @@ Settings:
FactionsUUID: false
## Output to console some debugging info
Debugger: false
## Must be a positive integer #
MinRadius: 25
## Amount of chunks to preload around a safe location
PreloadRadius: 5
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
MaxAttempts: 15
MaxAttempts: 32
RtpOnFirstJoin: # Will execute as console to override delays
Enabled: false # Make the player rtp when joining the server for the first time
World: 'world' # World to first rtp in
@ -62,6 +60,8 @@ BlacklistedBlocks:
- air
- void_air
- bedrock
- oak_leaves
- jungle_leaves
## Worlds to NOT allow /rtp in, unless there is an override to another enabled world #
DisabledWorlds:

View File

@ -0,0 +1,18 @@
#Locations where rtp will center upon
#Format:
# LOCATION_NAME:
# World: world
# CenterX: 100
# CenterY: 150
# MaxRadius: 100
# MinRadius: 5
Settings:
Enabled: false
RandomLocations: true #When rtp'ing, a random location will be selected, else the nearest will be selected
Locations:
main_loc:
World: world
CenterX: 100
CenterY: 150
MaxRadius: 100
MinRadius: 5