mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-04-04 15:06:01 +00:00
teleport during event + extraEffects addon
- portals addon can force ignore delay and cooldowns - Rtp commands were moved after a command was actually executed, fixing addons reload
This commit is contained in:
@@ -48,9 +48,9 @@ public class Commands {
|
||||
for (RTPCommand cmd : commands) {
|
||||
if (cmd.getName().equalsIgnoreCase(args[0])) {
|
||||
if (cmd.permission(sendi)) {
|
||||
cmd.execute(sendi, label, args);
|
||||
//Command Event
|
||||
Bukkit.getServer().getPluginManager().callEvent(new RTP_CommandEvent(sendi, cmd));
|
||||
cmd.execute(sendi, label, args);
|
||||
} else
|
||||
noPerm(sendi);
|
||||
return;
|
||||
@@ -137,21 +137,32 @@ public class Commands {
|
||||
}
|
||||
|
||||
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType) {
|
||||
if (checkDelay(sendi, player)) { //Cooling down or rtp'ing
|
||||
boolean delay = false;
|
||||
if (sendi == player) //Forced?
|
||||
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
|
||||
if (!pl.getPerms().getBypassDelay(player)) //Can bypass?
|
||||
delay = true;
|
||||
pl.getRTP().start(player, sendi, world, biomes, delay, rtpType);
|
||||
this.tp(player, sendi, world, biomes, rtpType, false, false);
|
||||
}
|
||||
|
||||
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType, boolean ignoreCooldown, boolean ignoreDelay) {
|
||||
if (checkRTPing(player, sendi)) { //Is RTP'ing
|
||||
if (!ignoreCooldown || checkCooldown(sendi, player)) { //Is Cooling down
|
||||
boolean delay = false;
|
||||
if (!ignoreDelay && sendi == player) //Forced?
|
||||
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
|
||||
if (!pl.getPerms().getBypassDelay(player)) //Can bypass?
|
||||
delay = true;
|
||||
pl.getRTP().start(player, sendi, world, biomes, delay, rtpType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkDelay(CommandSender sendi, Player player) {
|
||||
private boolean checkRTPing(Player player, CommandSender sendi) {
|
||||
if (rtping.containsKey(player.getUniqueId()) && rtping.get(player.getUniqueId())) {
|
||||
pl.getText().getAlready(sendi);
|
||||
return false;
|
||||
} else if (sendi != player || pl.getPerms().getBypassCooldown(player)) { //Bypassing/Forced?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkCooldown(CommandSender sendi, Player player) {
|
||||
if (sendi != player || pl.getPerms().getBypassCooldown(player)) { //Bypassing/Forced?
|
||||
return true;
|
||||
} else if (cooldowns.enabled) { //Cooling down?
|
||||
UUID id = player.getUniqueId();
|
||||
|
||||
@@ -41,17 +41,20 @@ public class RTPTeleport {
|
||||
// CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).cancel(true);
|
||||
// }
|
||||
|
||||
void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
|
||||
void sendPlayer(final CommandSender sendi, final Player p, final Location location, final int price,
|
||||
final int attempts) throws NullPointerException {
|
||||
Location oldLoc = p.getLocation();
|
||||
loadingTeleport(p, sendi); //Send loading message to player who requested
|
||||
List<CompletableFuture<Chunk>> asyncChunks = getChunks(loc); //Get a list of chunks
|
||||
List<CompletableFuture<Chunk>> asyncChunks = getChunks(location); //Get a list of chunks
|
||||
//playerLoads.put(p, asyncChunks);
|
||||
CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
||||
new BukkitRunnable() { //Run synchronously
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
RTP_TeleportEvent event = new RTP_TeleportEvent(p, location);
|
||||
getPl().getServer().getPluginManager().callEvent(event);
|
||||
Location loc = event.getLocation();
|
||||
PaperLib.teleportAsync(p, loc).thenRun(new BukkitRunnable() { //Async teleport
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class RTP_TeleportEvent extends Event {
|
||||
|
||||
Player p;
|
||||
Location loc;
|
||||
private static final HandlerList handler = new HandlerList();
|
||||
|
||||
public RTP_TeleportEvent(Player p, Location loc) {
|
||||
this.p = p;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void changeLocation(Location loc) {
|
||||
this.loc = loc;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user