mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add /tpall
This commit is contained in:
1 parent
32f05de853
commit
0bfd990dee
4 files changed
+46
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TpAllCommand extends CommandBase {
|
||||
|
||||
protected TpAllCommand(@NotNull HuskHomes implementor) {
|
||||
super("tpall", Permission.COMMAND_TPALL, implementor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
// Update cached players
|
||||
plugin.getCache().updateOnlinePlayerList(plugin, onlineUser);
|
||||
|
||||
// Determine players to teleport
|
||||
final List<String> players = plugin.getCache().players.stream()
|
||||
.filter(userName -> !userName.equals(onlineUser.username)).toList();
|
||||
if (players.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_no_players_online").ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Teleport every player
|
||||
players.forEach(playerName -> plugin.getTeleportManager()
|
||||
.teleportPlayerByName(playerName, onlineUser.getPosition(), onlineUser));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,14 @@ public enum Permission {
|
||||
* Lets the user tp to where a user logged out ({@code /tpoffline [player_name]})
|
||||
*/
|
||||
COMMAND_TPOFFLINE("huskhomes.command.tpoffline", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user teleport everyone to their position ({@code /tpall})
|
||||
*/
|
||||
COMMAND_TPALL("huskhomes.command.tpall", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user send a teleport request asking everyone to teleport to them ({@code /tpaall})
|
||||
*/
|
||||
COMMAND_TPAALL("huskhomes.command.tpaall", DefaultAccess.OPERATORS),
|
||||
/**
|
||||
* Lets the user randomly teleport in the world they are in ({@code /rtp})
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user