rtp player info

This commit is contained in:
SuperRonanCraft
2023-06-14 00:21:18 -04:00
parent f7e6665c42
commit 919e458477
7 changed files with 87 additions and 20 deletions

View File

@@ -109,7 +109,7 @@
<dependency>
<groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId>
<version>3.6.8-3</version>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<!-- ProtocolLib -->

View File

@@ -4,6 +4,7 @@ import me.SuperRonanCraft.BetterRTP.BetterRTP;
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandType;
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_PlayerInfo;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
@@ -32,7 +33,15 @@ public class CmdPlayer implements RTPCommand, RTPCommandHelpable {
public void execute(CommandSender sendi, String label, String[] args) {
if (args.length == 2)
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline())
HelperRTP.tp(Bukkit.getPlayer(args[1]), sendi, Bukkit.getPlayer(args[1]).getWorld(), null, RTP_TYPE.FORCED);
HelperRTP.tp(Bukkit.getPlayer(args[1]),
sendi,
Bukkit.getPlayer(args[1]).getWorld(),
null,
RTP_TYPE.FORCED,
false,
false,
null,
new RTP_PlayerInfo(false, false));
else if (Bukkit.getPlayer(args[1]) != null)
MessagesCore.NOTONLINE.send(sendi, args[1]);
else

View File

@@ -97,13 +97,13 @@ public class RTP {
//Cooldown
Player p = pWorld.getPlayer();
//p.sendMessage("Cooling down: " + cooldown);
if (pWorld.isApplyCooldown())
if (pWorld.getPlayerInfo().isApplyCooldown())
getPl().getCooldowns().add(p, pWorld.getWorld());
getPl().getpInfo().getRtping().put(p, true); //Cache player so they cant run '/rtp' again while rtp'ing
//Setup player rtp methods
RTPPlayer rtpPlayer = new RTPPlayer(p, this, pWorld, type);
// Delaying? Else, just go
if (getPl().getSettings().isDelayEnabled() && pWorld.isApplyDelay()) {
if (getPl().getSettings().isDelayEnabled() && pWorld.getPlayerInfo().isApplyDelay()) {
new RTPDelay(sendi, rtpPlayer, delayTime, cancelOnMove, cancelOnDamage);
} else {
if (!teleport.beforeTeleportInstant(sendi, p))

View File

@@ -17,11 +17,10 @@ public class RTPSetupInformation {
@Getter @NonNull private final CommandSender sender;
@Getter @Nullable private final Player player;
@Getter private final boolean personalized;
@Getter private final boolean cooldown;
@Getter @Setter @Nullable private List<String> biomes;
@Getter @Setter @Nullable private WorldLocation location;
@Getter private final boolean delay;
@Getter @Nullable private final RTP_TYPE rtp_type;
@Getter private final RTP_PlayerInfo playerInfo;
public RTPSetupInformation(@Nullable World world,
@NonNull CommandSender sender,
@@ -50,18 +49,28 @@ public class RTPSetupInformation {
@Nullable RTP_TYPE rtp_type,
@Nullable WorldLocation location,
boolean cooldown) {
this(world, sender, player, personalized, biomes, rtp_type, location, new RTP_PlayerInfo(delay, cooldown));
}
public RTPSetupInformation(@Nullable World world,
@NonNull CommandSender sender,
@Nullable Player player,
boolean personalized,
@Nullable List<String> biomes,
@Nullable RTP_TYPE rtp_type,
@Nullable WorldLocation location,
RTP_PlayerInfo playerInfo) {
this.world = world;
this.sender = sender;
this.player = player;
this.personalized = personalized;
this.biomes = biomes;
this.delay = delay;
this.rtp_type = rtp_type;
this.location = location;
if (this.world == null) {
if (player != null)
this.world = player.getWorld();
}
this.cooldown = cooldown;
this.playerInfo = playerInfo;
}
}

View File

@@ -0,0 +1,32 @@
package me.SuperRonanCraft.BetterRTP.player.rtp;
import lombok.Getter;
import lombok.Setter;
public class RTP_PlayerInfo {
@Getter @Setter boolean
applyDelay,
applyCooldown,
checkCooldown,
takeMoney,
takeHunger;
public RTP_PlayerInfo(boolean applyDelay, boolean applyCooldown) {
this.applyDelay = applyDelay;
this.applyCooldown = applyCooldown;
}
public RTP_PlayerInfo(boolean applyDelay,
boolean applyCooldown,
boolean checkCooldown,
boolean takeMoney,
boolean takeHunger) {
this.applyDelay = applyDelay;
this.applyCooldown = applyCooldown;
this.checkCooldown = checkCooldown;
this.takeMoney = takeMoney;
this.takeHunger = takeHunger;
}
}

View File

@@ -2,10 +2,7 @@ package me.SuperRonanCraft.BetterRTP.references.helpers;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdLocation;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_ERROR_REQUEST_REASON;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
import me.SuperRonanCraft.BetterRTP.player.rtp.*;
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
import me.SuperRonanCraft.BetterRTP.references.WarningHandler;
@@ -26,7 +23,7 @@ public class HelperRTP {
//Teleported and Sender are the same
public static void tp(Player player, World world, List<String> biomes, RTP_TYPE rtpType) {
tp(player, player, world, biomes, rtpType, false, false);
tp(player, player, world, biomes, rtpType);
}
//Teleported and Sender MAY be different
@@ -49,11 +46,32 @@ public class HelperRTP {
player,
true,
biomes,
!ignoreDelay && HelperRTP_Check.applyDelay(player, sendi),
rtpType,
location,
!ignoreCooldown && HelperRTP_Check.applyCooldown(sendi, player)
new RTP_PlayerInfo(
!ignoreDelay && HelperRTP_Check.applyDelay(player, sendi),
!ignoreCooldown && HelperRTP_Check.applyCooldown(sendi, player))
);
tp(player, sendi, ignoreCooldown, ignoreDelay, setup_info);
}
public static void tp(@NotNull Player player, CommandSender sendi, @Nullable World world, List<String> biomes, RTP_TYPE rtpType,
boolean ignoreCooldown, boolean ignoreDelay, @Nullable WorldLocation location, RTP_PlayerInfo playerInfo) {
world = getActualWorld(player, world, location);
RTPSetupInformation setup_info = new RTPSetupInformation(
world,
sendi,
player,
true,
biomes,
rtpType,
location,
playerInfo
);
tp(player, sendi, ignoreCooldown, ignoreDelay, setup_info);
}
public static void tp(@NotNull Player player, CommandSender sendi, boolean ignoreCooldown, boolean ignoreDelay, RTPSetupInformation setup_info) {
//RTP request cancelled reason
WorldPlayer pWorld = getPlayerWorld(setup_info);
RTP_ERROR_REQUEST_REASON cantReason = HelperRTP_Check.canRTP(player, sendi, pWorld, ignoreCooldown);

View File

@@ -4,6 +4,7 @@ import lombok.Getter;
import me.SuperRonanCraft.BetterRTP.player.commands.RTP_SETUP_TYPE;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_PlayerInfo;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
import org.bukkit.Location;
@@ -22,7 +23,7 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
private List<String> Biomes;
@Getter private final Player player;
@Getter private final CommandSender sendi;
@Getter private final boolean applyCooldown, applyDelay;
@Getter private final RTP_PlayerInfo playerInfo;
@Getter private final RTP_TYPE rtp_type;
private final World world;
private WORLD_TYPE world_type;
@@ -30,17 +31,15 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
private RTP_SHAPE shape;
public RTP_SETUP_TYPE setup_type = RTP_SETUP_TYPE.DEFAULT;
public String setup_name;
//Economy
public boolean eco_money_taken = false;
@Getter private boolean setup = false;
public WorldPlayer(RTPSetupInformation setup_info) {
this.sendi = setup_info.getSender();
this.player = setup_info.getPlayer();
this.world = setup_info.getWorld();
this.applyCooldown = setup_info.isCooldown();
this.applyDelay = setup_info.isDelay();
this.rtp_type = setup_info.getRtp_type();
this.playerInfo = setup_info.getPlayerInfo();
}
public void setup(String setup_name, RTPWorld world, List<String> biomes) {