mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-22 22:14:57 +00:00
Add offline tp command
This commit is contained in:
parent
bbf6f0eb82
commit
bcb179a2a1
3 changed files with 47 additions and 1 deletions
|
@ -0,0 +1,41 @@
|
|||
package me.StevenLawson.TotalFreedomMod.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
public class Command_offlinetp extends FreedomCommand {
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
OfflinePlayer target = null;
|
||||
String searchString = args[0];
|
||||
|
||||
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||
if(offlinePlayer.getName().equalsIgnoreCase(searchString)) {
|
||||
target = offlinePlayer;
|
||||
break;
|
||||
} else if (offlinePlayer.getName().startsWith(searchString.toLowerCase())) {
|
||||
target = offlinePlayer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(target == null) {
|
||||
playerMsg(sender, FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(target.isOnline()) {
|
||||
playerMsg(sender, "That player is already online. Use /tp.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg(sender, String.format("Teleporting to %s's last known location...", target.getName()));
|
||||
sender_p.teleport(target.getPlayer().getLocation());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -107,5 +107,6 @@ public class Commands {
|
|||
plugin.getCommand("wipeflatlands").setExecutor(new Command_wipeflatlands());
|
||||
plugin.getCommand("wipeuserdata").setExecutor(new Command_wipeuserdata());
|
||||
plugin.getCommand("whoami").setExecutor(new Command_whoami());
|
||||
plugin.getCommand("offlinetp").setExecutor(new Command_offlinetp());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,4 +333,8 @@ commands:
|
|||
usage: '/<command> <clearloginmsg | setlogin <message>>'
|
||||
whoami:
|
||||
description: 'Who am I? Who are you? What am I doing here?'
|
||||
usage: '/<command>'
|
||||
usage: '/<command>'
|
||||
offlinetp:
|
||||
aliases: ["otp"]
|
||||
description: 'Teleport to an offline player''s last known location.'
|
||||
usage: '/<command> <partialName>'
|
Loading…
Reference in a new issue