2.11.3 - Async Delays issue

Added the ability to disable delays in the config
This commit is contained in:
SuperRonanCraft
2020-08-07 09:45:00 -04:00
parent 060361c6e7
commit b8930a510d
6 changed files with 28 additions and 24 deletions

View File

@@ -153,19 +153,24 @@ public class RTP {
return;
}
// Delaying? Else, just go
getPl().getCmd().rtping.put(p.getUniqueId(), true);
if (delay) {
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
if (getPl().getSettings().delayEnabled && delay) {
new Delay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
} else
tp(sendi, pWorld);
}
void tp(CommandSender sendi, PlayerWorld pWorld) {
Location loc = randomLoc(pWorld);
if (loc != null)
teleport.sendPlayer(sendi, pWorld.getPlayer(), loc, pWorld.getPrice(), pWorld.getAttempts());
else
metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
new BukkitRunnable(){
@Override
public void run() {
Location loc = randomLoc(pWorld);
if (loc != null)
teleport.sendPlayer(sendi, pWorld.getPlayer(), loc, pWorld.getPrice(), pWorld.getAttempts());
else
metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
}
}.runTaskAsynchronously(getPl());
}
// Compressed code for MaxAttempts being met

View File

@@ -126,19 +126,10 @@ public class Commands {
if (sendi == player)
delay = true;
//pl.getRTP().start(player, sendi, world, biomes, delay);
tpSync(player, sendi, world, biomes, delay);
pl.getRTP().start(player, sendi, world, biomes, delay);
}
}
private void tpSync(Player player, CommandSender sendi, String world, List<String> biomes, boolean delay) {
new BukkitRunnable(){
@Override
public void run() {
pl.getRTP().start(player, sendi, world, biomes, delay);
}
}.runTaskAsynchronously(pl);
}
private boolean checkDelay(CommandSender sendi, Player player) {
if (rtping.containsKey(player.getUniqueId())) //Already rtp'ing
if (rtping.get(player.getUniqueId())) {

View File

@@ -5,17 +5,23 @@ import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
public class Settings {
public boolean debug = false;
public boolean debug;
public boolean delayEnabled;
//Dependencies
private SoftDepends depends = new SoftDepends();
public void load() { //Load Settings
depends.load();
debug = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG).getBoolean("Settings.Debugger");
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG);
debug = config.getBoolean("Settings.Debugger");
delayEnabled = config.getBoolean("Settings.Delay.Enabled");
}
public SoftDepends getsDepends() {
return depends;
}
private Main getPl() {
return Main.getInstance();
}
}

View File

@@ -22,6 +22,7 @@ Settings:
Time: 10
## Time between command and actually rtp'ing, time is in SECONDS. Set to "0" to disable delay timer #
Delay:
Enabled: true
Time: 5
CancelOnMove: true
DisableUpdater: false

View File

@@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main
version: '2.11.2'
version: '2.11.3'
name: BetterRTP
author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]