economy charged after safe spot located

This commit is contained in:
SuperRonanCraft 2020-10-04 20:37:20 -04:00
parent 169b3940e4
commit 54482d897f
6 changed files with 17 additions and 13 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<version>2.14.1</version> <version>2.14.2</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>

View File

@ -139,20 +139,19 @@ public class Commands {
private boolean checkDelay(CommandSender sendi, Player player) { private boolean checkDelay(CommandSender sendi, Player player) {
if (rtping.containsKey(player.getUniqueId()) && rtping.get(player.getUniqueId())) { if (rtping.containsKey(player.getUniqueId()) && rtping.get(player.getUniqueId())) {
pl.getText().getAlready(player); pl.getText().getAlready(sendi);
return false; return false;
} else if (sendi != player || pl.getPerms().getBypassCooldown(player)) { //Bypassing/Forced? } else if (sendi != player || pl.getPerms().getBypassCooldown(player)) { //Bypassing/Forced?
return true; return true;
} else if (cooldowns.enabled) { //Cooling down? } else if (cooldowns.enabled) { //Cooling down?
Player p = (Player) sendi; UUID id = player.getUniqueId();
UUID id = p.getUniqueId();
if (cooldowns.exists(id)) { if (cooldowns.exists(id)) {
if (cooldowns.locked(id)) { //Infinite cooldown (locked) if (cooldowns.locked(id)) { //Infinite cooldown (locked)
pl.getText().getNoPermission(sendi); pl.getText().getNoPermission(sendi);
return false; return false;
} else { //Normal cooldown } else { //Normal cooldown
long Left = cooldowns.timeLeft(id); long Left = cooldowns.timeLeft(id);
if (pl.getSettings().delayEnabled && !pl.getPerms().getBypassDelay(p)) if (pl.getSettings().delayEnabled && !pl.getPerms().getBypassDelay(sendi))
Left = Left + delayTimer; Left = Left + delayTimer;
if (Left > 0) { if (Left > 0) {
//Still cooling down //Still cooling down

View File

@ -59,7 +59,7 @@ class RTPDelay implements Listener {
if (!Bukkit.getScheduler().isCurrentlyRunning(run)) { if (!Bukkit.getScheduler().isCurrentlyRunning(run)) {
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer()); getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer());
getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld); //getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
getPl().getCmd().cooldowns.remove(rtp.getPlayer().getUniqueId()); getPl().getCmd().cooldowns.remove(rtp.getPlayer().getUniqueId());
getPl().getCmd().rtping.put(rtp.getPlayer().getUniqueId(), false); getPl().getCmd().rtping.put(rtp.getPlayer().getUniqueId(), false);
} }

View File

@ -36,6 +36,7 @@ public class RTPPlayer {
Location loc = pWorld.generateRandomXZ(settings.defaultWorld); //randomLoc(pWorld); Location loc = pWorld.generateRandomXZ(settings.defaultWorld); //randomLoc(pWorld);
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(pWorld.getWorld(), loc.getBlockX(), loc.getBlockZ()); CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(pWorld.getWorld(), loc.getBlockX(), loc.getBlockZ());
chunk.thenAccept(result -> { chunk.thenAccept(result -> {
Main.debug("Checking location for " + p.getName());
Location tpLoc; Location tpLoc;
float yaw = p.getLocation().getYaw(); float yaw = p.getLocation().getYaw();
float pitch = p.getLocation().getPitch(); float pitch = p.getLocation().getPitch();
@ -47,10 +48,11 @@ public class RTPPlayer {
tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld); tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
} }
//Valid location? //Valid location?
if (tpLoc != null && checkDepends(tpLoc)) if (tpLoc != null && checkDepends(tpLoc)) {
if (getPl().getEco().charge(p, pWorld)) if (getPl().getEco().charge(p, pWorld)) {
settings.teleport.sendPlayer(sendi, p, tpLoc, pWorld.getPrice(), pWorld.getAttempts()); settings.teleport.sendPlayer(sendi, p, tpLoc, pWorld.getPrice(), pWorld.getAttempts());
else }
} else
randomlyTeleport(sendi); randomlyTeleport(sendi);
}); });
} }

View File

@ -57,7 +57,7 @@ public class DepEconomy {
Player player = pWorld.getPlayer(); Player player = pWorld.getPlayer();
//Hunger Stuff //Hunger Stuff
if (hunger != 0 if (hunger != 0
&& sendi == player && !Main.getInstance().getPerms().getBypassHunger(sendi)
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) { && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
boolean has_hunger = player.getFoodLevel() > hunger; boolean has_hunger = player.getFoodLevel() > hunger;
if (!has_hunger) { if (!has_hunger) {
@ -69,9 +69,10 @@ public class DepEconomy {
if (e != null && pWorld.getPrice() != 0 && !Main.getInstance().getPerms().getBypassEconomy(sendi)) { if (e != null && pWorld.getPrice() != 0 && !Main.getInstance().getPerms().getBypassEconomy(sendi)) {
try { try {
boolean passed_economy = e.getBalance(player) >= pWorld.getPrice(); boolean passed_economy = e.getBalance(player) >= pWorld.getPrice();
if (!passed_economy) if (!passed_economy) {
Main.getInstance().getText().getFailedPrice(sendi, pWorld.getPrice()); Main.getInstance().getText().getFailedPrice(sendi, pWorld.getPrice());
return passed_economy; return false;
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main main: me.SuperRonanCraft.BetterRTP.Main
version: '2.14.1' version: '2.14.2'
name: BetterRTP name: BetterRTP
author: SuperRonanCraft author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect] softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect]
@ -46,6 +46,8 @@ permissions:
description: Bypass delays description: Bypass delays
betterrtp.bypass.economy: betterrtp.bypass.economy:
description: Bypass economy description: Bypass economy
betterrtp.bypass.hunger:
description: Bypass hunger
betterrtp.reload: betterrtp.reload:
description: Reload the config description: Reload the config
default: op default: op