Skip to content

Commit

Permalink
cooldown ignore fix + essentials try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperRonanCraft committed Dec 29, 2023
1 parent 418ef2a commit d056634
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ void move(PlayerMoveEvent e) {

if (ploc.getBlockX() <= Math.max(loc1.getBlockX(), loc2.getBlockX())
&& ploc.getBlockX() >= Math.min(loc1.getBlockX(), loc2.getBlockX()))
if (ploc.getBlockZ() <= Math.max(loc1.getBlockZ(), loc2.getBlockZ())
&& ploc.getBlockZ() >= Math.min(loc1.getBlockZ(), loc2.getBlockZ()))
if (ploc.getBlockY() <= Math.max(loc1.getBlockY(), loc2.getBlockY())
&& ploc.getBlockY() >= Math.min(loc1.getBlockY(), loc2.getBlockY())) {
if (ploc.getBlockZ() <= Math.max(loc1.getBlockZ(), loc2.getBlockZ())
&& ploc.getBlockZ() >= Math.min(loc1.getBlockZ(), loc2.getBlockZ()))
if (ploc.getBlockY() <= Math.max(loc1.getBlockY(), loc2.getBlockY())
&& ploc.getBlockY() >= Math.min(loc1.getBlockY(), loc2.getBlockY())) {
playerPortaling.put(e.getPlayer(), portal);
World world = portal.getWorld() != null ? Bukkit.getWorld(portal.getWorld()) : null;
HelperRTP.tp(e.getPlayer(), e.getPlayer(), world, null, RTP_TYPE.ADDON_PORTAL, ignoreCooldown, ignoreDelay);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.19.7</version>
<version>2.20.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import io.papermc.lib.PaperLib;
import lombok.Getter;
import me.RonanCraft.Pueblos.resources.tools.HelperEvent;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_FailedEvent;
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_FindLocationEvent;
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_SettingUpEvent;
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Check;
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.RandomLocation;
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
import me.SuperRonanCraft.BetterRTP.versions.FoliaHandler;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
Expand Down Expand Up @@ -111,6 +115,8 @@ private void metMax(CommandSender sendi, Player p) {
settings.teleport.failedTeleport(p, sendi);
getPl().getCooldowns().removeCooldown(p, worldPlayer.getWorld());
getPl().getPInfo().getRtping().remove(p);
//RTP Failed Event
Bukkit.getServer().getPluginManager().callEvent(new RTP_FailedEvent(this));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public RTP_PlayerInfo() {
}

public RTP_PlayerInfo(boolean applyDelay, boolean applyCooldown) {
this(applyDelay, applyCooldown, true, true, true);
this(applyDelay, applyCooldown, true);
}

public RTP_PlayerInfo(boolean applyDelay, boolean applyCooldown, boolean checkCooldown) {
this(applyDelay, applyCooldown, checkCooldown, true, true);
}

public RTP_PlayerInfo(boolean applyDelay,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.SuperRonanCraft.BetterRTP.references.customEvents;

import lombok.Getter;
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPPlayer;
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.Nullable;

//Called when an rtp is finding a valid location
@Getter public class RTP_FailedEvent extends RTPEvent {

Player p;
RTPWorld world;
int attempts;

public RTP_FailedEvent(RTPPlayer rtpPlayer) {
this.p = rtpPlayer.getPlayer();
this.world = rtpPlayer.getWorldPlayer();
this.attempts = rtpPlayer.getAttempts();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
public class DepEssentials {

public static void setBackLocation(Player player, Location location) {
Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (ess == null) return;
User user = ess.getUser(player.getUniqueId());
if (user == null) return;
user.setLastLocation(location);
try {
Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (ess == null)
return;
User user = ess.getUser(player.getUniqueId());
if (user == null)
return;
user.setLastLocation(location);
} catch (ClassCastException e) {
//Something wrong happened, idk why this would break...
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void tp(@NotNull Player player,
boolean ignoreCooldown,
boolean ignoreDelay,
@Nullable WorldLocation location) {
tp(player, sendi, world, biomes, rtpType, location, new RTP_PlayerInfo(!ignoreDelay, !ignoreCooldown));
tp(player, sendi, world, biomes, rtpType, location, new RTP_PlayerInfo(!ignoreDelay, true, !ignoreCooldown));
}

public static void tp(@NotNull Player player,
Expand Down

0 comments on commit d056634

Please sign in to comment.