mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 00:55:45 +00:00
economy uncharge removed
now charges before teleporting after it's found a safe spot
This commit is contained in:
parent
7b2871f17d
commit
ea1fa435dd
@ -144,33 +144,35 @@ public class RTP {
|
|||||||
world_name = overriden.get(world_name);
|
world_name = overriden.get(world_name);
|
||||||
// Not forced and has 'betterrtp.world.<world>'
|
// Not forced and has 'betterrtp.world.<world>'
|
||||||
if (sendi == p && !getPl().getPerms().getAWorld(sendi, world_name)) {
|
if (sendi == p && !getPl().getPerms().getAWorld(sendi, world_name)) {
|
||||||
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
|
||||||
getPl().getText().getNoPermissionWorld(p, world_name);
|
getPl().getText().getNoPermissionWorld(p, world_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check disabled worlds
|
// Check disabled worlds
|
||||||
if (disabledWorlds.contains(world_name)) {
|
if (disabledWorlds.contains(world_name)) {
|
||||||
getPl().getText().getDisabledWorld(sendi, world_name);
|
getPl().getText().getDisabledWorld(sendi, world_name);
|
||||||
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check if nulled or world doesnt exist
|
// Check if nulled or world doesnt exist
|
||||||
if (Bukkit.getWorld(world_name) == null) {
|
if (Bukkit.getWorld(world_name) == null) {
|
||||||
getPl().getText().getNotExist(sendi, world_name);
|
getPl().getText().getNotExist(sendi, world_name);
|
||||||
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldPlayer pWorld = getPlayerWorld(p, world_name, biomes, true);
|
WorldPlayer pWorld = getPlayerWorld(p, world_name, biomes, true);
|
||||||
// Economy
|
// Economy
|
||||||
if (!getPl().getEco().charge(sendi, pWorld)) {
|
if (!getPl().getEco().hasBalance(sendi, pWorld)) {
|
||||||
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
rtp(sendi, pWorld, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rtp(CommandSender sendi, WorldPlayer pWorld, boolean delay) {
|
||||||
//Cooldown
|
//Cooldown
|
||||||
|
Player p = pWorld.getPlayer();
|
||||||
getPl().getCmd().cooldowns.add(p.getUniqueId());
|
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
|
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);
|
RTPPlayer rtp = new RTPPlayer(p, this, pWorld);
|
||||||
|
// Delaying? Else, just go
|
||||||
if (getPl().getSettings().delayEnabled && delay) {
|
if (getPl().getSettings().delayEnabled && delay) {
|
||||||
new RTPDelay(sendi, rtp, delayTime, cancelOnMove, cancelOnDamage);
|
new RTPDelay(sendi, rtp, delayTime, cancelOnMove, cancelOnDamage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,8 +46,10 @@ public class RTPPlayer {
|
|||||||
default:
|
default:
|
||||||
tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
|
tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
|
||||||
}
|
}
|
||||||
|
//Valid location?
|
||||||
if (tpLoc != null && checkDepends(tpLoc))
|
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
|
else
|
||||||
randomlyTeleport(sendi);
|
randomlyTeleport(sendi);
|
||||||
});
|
});
|
||||||
@ -61,7 +63,7 @@ public class RTPPlayer {
|
|||||||
else
|
else
|
||||||
getPl().getText().getOtherNotSafe(sendi, settings.maxAttempts, p.getName());
|
getPl().getText().getOtherNotSafe(sendi, settings.maxAttempts, p.getName());
|
||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
getPl().getEco().unCharge(p, pWorld);
|
//getPl().getEco().unCharge(p, pWorld);
|
||||||
getPl().getCmd().rtping.put(p.getUniqueId(), false);
|
getPl().getCmd().rtping.put(p.getUniqueId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +52,38 @@ public class DepEconomy {
|
|||||||
return true;
|
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)
|
if (e != null && pWorld.getPrice() != 0 && pWorld.eco_money_taken)
|
||||||
e.depositPlayer(p, pWorld.getPrice());
|
e.depositPlayer(p, pWorld.getPrice());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
check(true);
|
check(true);
|
||||||
|
@ -17,12 +17,10 @@ Settings:
|
|||||||
FactionsUUID: false
|
FactionsUUID: false
|
||||||
## Output to console some debugging info
|
## Output to console some debugging info
|
||||||
Debugger: false
|
Debugger: false
|
||||||
## Must be a positive integer #
|
|
||||||
MinRadius: 25
|
|
||||||
## Amount of chunks to preload around a safe location
|
## Amount of chunks to preload around a safe location
|
||||||
PreloadRadius: 5
|
PreloadRadius: 5
|
||||||
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
|
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
|
||||||
MaxAttempts: 15
|
MaxAttempts: 32
|
||||||
RtpOnFirstJoin: # Will execute as console to override delays
|
RtpOnFirstJoin: # Will execute as console to override delays
|
||||||
Enabled: false # Make the player rtp when joining the server for the first time
|
Enabled: false # Make the player rtp when joining the server for the first time
|
||||||
World: 'world' # World to first rtp in
|
World: 'world' # World to first rtp in
|
||||||
@ -62,6 +60,8 @@ BlacklistedBlocks:
|
|||||||
- air
|
- air
|
||||||
- void_air
|
- void_air
|
||||||
- bedrock
|
- bedrock
|
||||||
|
- oak_leaves
|
||||||
|
- jungle_leaves
|
||||||
|
|
||||||
## Worlds to NOT allow /rtp in, unless there is an override to another enabled world #
|
## Worlds to NOT allow /rtp in, unless there is an override to another enabled world #
|
||||||
DisabledWorlds:
|
DisabledWorlds:
|
||||||
|
18
src/main/resources/locations.yml
Normal file
18
src/main/resources/locations.yml
Normal 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
|
Loading…
x
Reference in New Issue
Block a user