mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Close #103, add /tpaall and /tpall commands
This commit is contained in:
1 parent
2b96d65421
commit
54206f110e
8 files changed
+104
-11
No files matched your search
@@ -35,7 +35,7 @@
|
||||
* /publichome, /publichomelist
|
||||
* /warp, /setwarp, /editwarp, /warplist
|
||||
* /tpa, /tpahere, /tpaccept, /tpdeny
|
||||
* /tp, /tphere
|
||||
* /tp, /tphere, /tpall, /tpaall
|
||||
* /spawn, /rtp
|
||||
* And more...
|
||||
|
||||
|
||||
@@ -165,6 +165,8 @@ public final class HuskHomes extends JavaPlugin {
|
||||
new SetWarpCommand().register(getCommand("setwarp")).setTabCompleter(emptyTab);
|
||||
new BackCommand().register(getCommand("back")).setTabCompleter(emptyTab);
|
||||
new TpOfflineCommand().register(getCommand("tpoffline")).setTabCompleter(emptyTab);
|
||||
new TpaAllCommand().register(getCommand("tpaall")).setTabCompleter(emptyTab);
|
||||
new TpAllCommand().register(getCommand("tpall")).setTabCompleter(emptyTab);
|
||||
|
||||
// Update caches
|
||||
PublicHomeCommand.updatePublicHomeTabCache();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpAllCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportManager.teleportAllHere(p);
|
||||
MessageManager.sendMessage(p, "teleporting_all_players");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpaAllCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
protected void onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportRequestHandler.sendTeleportAllHereRequest(p);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -222,6 +222,22 @@ public class TeleportManager {
|
||||
new TimedTeleport(player).begin();
|
||||
}
|
||||
|
||||
public static void teleportAllHere(Player requester) {
|
||||
for (String playerName : HuskHomes.getPlayerList().getPlayers()) {
|
||||
if (playerName.equals(requester.getName())) {
|
||||
continue;
|
||||
}
|
||||
Player targetPlayer = Bukkit.getPlayerExact(playerName);
|
||||
if (targetPlayer != null) {
|
||||
teleportPlayer(targetPlayer, requester.getName());
|
||||
} else {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
teleportHereCrossServer(requester, playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void teleportHere(Player requester, String targetPlayerName) throws SQLException {
|
||||
Player targetPlayer = Bukkit.getPlayerExact(targetPlayerName);
|
||||
if (targetPlayer != null) {
|
||||
|
||||
@@ -64,20 +64,46 @@ public class TeleportRequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTeleportAllHereRequest(Player requester) {
|
||||
if (HuskHomes.getPlayerList().getPlayers().size() <= 1) {
|
||||
MessageManager.sendMessage(requester, "error_no_other_online_players");
|
||||
return;
|
||||
}
|
||||
for (String playerName : HuskHomes.getPlayerList().getPlayers()) {
|
||||
if (playerName.equals(requester.getName())) {
|
||||
continue;
|
||||
}
|
||||
final Player targetPlayer = Bukkit.getPlayerExact(playerName);
|
||||
if (targetPlayer != null) {
|
||||
sendLocalTpaHereRequest(requester, playerName, targetPlayer);
|
||||
} else {
|
||||
if (HuskHomes.getSettings().doBungee()) {
|
||||
sendTeleportRequestCrossServer(requester, playerName, TeleportRequest.RequestType.TPA_HERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageManager.sendMessage(requester, "tpaall_request_sent");
|
||||
}
|
||||
|
||||
// Send the local tpa here request, provided the user is not ignoring requests
|
||||
private static void sendLocalTpaHereRequest(Player requester, String playerName, Player targetPlayer) {
|
||||
if (!HuskHomes.isIgnoringTeleportRequests(targetPlayer.getUniqueId())) {
|
||||
if (isDuplicateRequest(playerName, targetPlayer)) {
|
||||
return;
|
||||
}
|
||||
teleportRequests.get(targetPlayer).put(requester.getName(), new TeleportRequest(requester.getName(),
|
||||
TeleportRequest.RequestType.TPA_HERE));
|
||||
MessageManager.sendMessage(targetPlayer, "tpahere_request_ask", requester.getName());
|
||||
MessageManager.sendMessage(targetPlayer, "teleport_request_options", requester.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTeleportHereRequest(Player requester, String targetPlayerName) {
|
||||
Player targetPlayer = Bukkit.getPlayerExact(targetPlayerName);
|
||||
if (targetPlayer != null) {
|
||||
if (targetPlayer.getUniqueId() != requester.getUniqueId()) {
|
||||
sendLocalTpaHereRequest(requester, targetPlayerName, targetPlayer);
|
||||
MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||
if (!HuskHomes.isIgnoringTeleportRequests(targetPlayer.getUniqueId())) {
|
||||
if (isDuplicateRequest(targetPlayerName, targetPlayer)) {
|
||||
return;
|
||||
}
|
||||
teleportRequests.get(targetPlayer).put(requester.getName(), new TeleportRequest(requester.getName(),
|
||||
TeleportRequest.RequestType.TPA_HERE));
|
||||
MessageManager.sendMessage(targetPlayer, "tpahere_request_ask", requester.getName());
|
||||
MessageManager.sendMessage(targetPlayer, "teleport_request_options", requester.getName());
|
||||
}
|
||||
} else {
|
||||
MessageManager.sendMessage(requester, "error_tp_self");
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ error_no_homes_set_other: '[Error:](#ff3300) [%1% hasn''t set any homes!](#ff7e5
|
||||
error_home_invalid_other: '[Error:](#ff3300) [%1% doesn''t have a home set named "%2%"](#ff7e5e)'
|
||||
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
|
||||
teleporting_cancelled_pvp: '[Teleportation cancelled; you engaged in combat!](#ff7e5e)'
|
||||
tpaall_request_sent: '[You sent a teleport request asking everyone to teleport to you!](#00fb9a)'
|
||||
error_no_other_online_players: '[Error:](#ff3300) [There are no other online players to send a request to!](#ff7e5e)'
|
||||
teleporting_all_players: '[Teleporting all players to your position...](#00fb9a)'
|
||||
home_command_description: 'Teleport to one of your homes'
|
||||
sethome_command_description: 'Set a new home with given name'
|
||||
delhome_command_description: 'Delete a home you previously set'
|
||||
@@ -145,4 +148,6 @@ tpoffline_command_description: 'Teleport to where a player was last online'
|
||||
rtp_command_description: 'Teleport randomly into the wild'
|
||||
spawn_command_description: 'Teleport to spawn'
|
||||
setspawn_command_description: 'Set the spawn position'
|
||||
tpaall_command_description: 'Request that everyone teleports to you'
|
||||
tpall_command_description: 'Teleport everyone to your position'
|
||||
huskhomes_command_description: 'View plugin information & reload configs'
|
||||
@@ -94,6 +94,14 @@ commands:
|
||||
setspawn:
|
||||
usage: /<command>
|
||||
permission: huskhomes.spawn.set
|
||||
tpaall:
|
||||
usage: /<command>
|
||||
aliases: [tpaallhere, tpahereall, tprequestall]
|
||||
permission: huskhomes.tpaall
|
||||
tpall:
|
||||
usage: /<command>
|
||||
aliases: [tphereall, tpallhere]
|
||||
permission: huskhomes.tpall
|
||||
huskhomes:
|
||||
usage: /<command> <about/update/reload/migrate>
|
||||
|
||||
@@ -264,4 +272,10 @@ permissions:
|
||||
default: op
|
||||
huskhomes.edithome.public:
|
||||
description: Allows you to make a home public
|
||||
default: true
|
||||
default: true
|
||||
huskhomes.tpaall:
|
||||
description: Allows you to request everyone to teleport to you
|
||||
default: op
|
||||
huskhomes.tpall:
|
||||
description: Allows you to teleport everyone to you
|
||||
default: op
|
||||
Reference in new issue
Block a user