mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Fixed stuck command and added home teleport command (#647)
With my custom print stream PR, this will also automatically log the player stuck command usage to a log file.
This commit is contained in:
@@ -75,6 +75,7 @@ import org.apollo.util.security.IsaacRandom;
|
||||
public abstract class Player {
|
||||
|
||||
public byte buffer[] = null;
|
||||
private long lastHomeTeleport = 0;
|
||||
public String lastConnectedFrom;
|
||||
public int xpRate = 1;
|
||||
public String discordCode;
|
||||
@@ -167,6 +168,14 @@ public abstract class Player {
|
||||
public int getXPRate() { return xpRate; }
|
||||
|
||||
public void setXPRate(int xpRate) { this.xpRate = xpRate; }
|
||||
|
||||
public long getLastHomeTeleport() {
|
||||
return lastHomeTeleport;
|
||||
}
|
||||
|
||||
public void setLastHomeTeleport(long lastHomeTeleport) {
|
||||
this.lastHomeTeleport = lastHomeTeleport;
|
||||
}
|
||||
|
||||
public String getDiscordCode() { return discordCode; }
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.rs2.world.clip.Region;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Commands implements PacketType {
|
||||
|
||||
@@ -49,10 +50,25 @@ public class Commands implements PacketType {
|
||||
switch (playerCommand.toLowerCase()) {
|
||||
case "stuck":
|
||||
if(JavaCord.token != null) {
|
||||
if (JavaCord.api.getTextChannelById(JavaCord.logChannelId).isPresent())
|
||||
if (JavaCord.api != null && JavaCord.api.getTextChannelById(JavaCord.logChannelId).isPresent())
|
||||
JavaCord.api.getTextChannelById(JavaCord.logChannelId).get().sendMessage(player.playerName + " used ::stuck at X/Y: " + player.absX + "/" + player.absY);
|
||||
}
|
||||
System.err.println("Player " + player.playerName + " used ::stuck at X/Y: " + player.absX + "/" + player.absY);
|
||||
player.getPlayerAssistant().spellTeleport(Constants.RESPAWN_X, Constants.RESPAWN_Y, 0);
|
||||
break;
|
||||
case "home":
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long cooldown = 30 * 60 * 1000; // 30 minutes in milliseconds
|
||||
if (player.getLastHomeTeleport() == 0 || (currentTime - player.getLastHomeTeleport() >= cooldown)) {
|
||||
player.getPlayerAssistant().spellTeleport(Constants.RESPAWN_X, Constants.RESPAWN_Y, 0);
|
||||
player.setLastHomeTeleport(currentTime); // Update the last teleport time
|
||||
} else {
|
||||
long remainingTime = cooldown - (currentTime - player.getLastHomeTeleport());
|
||||
long minutesLeft = TimeUnit.MILLISECONDS.toMinutes(remainingTime);
|
||||
long secondsLeft = TimeUnit.MILLISECONDS.toSeconds(remainingTime) - TimeUnit.MINUTES.toSeconds(minutesLeft);
|
||||
player.getPacketSender().sendMessage("You need to wait " + minutesLeft + " minutes and " + secondsLeft + " seconds to use home teleport again.");
|
||||
}
|
||||
break;
|
||||
case "link":
|
||||
player.setDiscordCode(arguments[0]);
|
||||
player.getPacketSender().sendMessage("Your Account has now been linked with Discord User ID:");
|
||||
|
||||
Reference in New Issue
Block a user