2011-04-09 02:58:41 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 21:59:39 +02:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2011-04-09 02:58:41 +02:00
|
|
|
import com.earth2me.essentials.User;
|
2014-01-12 02:23:12 +01:00
|
|
|
import org.bukkit.Location;
|
2011-11-18 18:42:26 +01:00
|
|
|
import org.bukkit.Server;
|
2011-12-07 02:12:36 +01:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2011-04-09 02:58:41 +02:00
|
|
|
|
2017-06-11 02:17:43 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
2011-04-09 02:58:41 +02:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
public class Commandtpall extends EssentialsCommand {
|
|
|
|
public Commandtpall() {
|
|
|
|
super("tpall");
|
|
|
|
}
|
2011-04-09 02:58:41 +02:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
if (sender.isPlayer()) {
|
2020-06-24 10:52:25 +02:00
|
|
|
teleportAllPlayers(server, sender, ess.getUser(sender.getPlayer()), commandLabel);
|
2015-04-15 06:06:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
final User target = getPlayer(server, sender, args, 0);
|
2020-06-24 10:52:25 +02:00
|
|
|
teleportAllPlayers(server, sender, target, commandLabel);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
|
2020-06-24 10:52:25 +02:00
|
|
|
private void teleportAllPlayers(Server server, CommandSource sender, User target, String label) {
|
2015-04-15 06:06:16 +02:00
|
|
|
sender.sendMessage(tl("teleportAll"));
|
|
|
|
final Location loc = target.getLocation();
|
|
|
|
for (User player : ess.getOnlineUsers()) {
|
|
|
|
if (target == player) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-04-25 14:08:57 +02:00
|
|
|
if (sender.getSender().equals(target.getBase()) && target.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !target.isAuthorized("essentials.worlds." + target.getWorld().getName())) {
|
2015-04-15 06:06:16 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-06-24 10:52:25 +02:00
|
|
|
player.getAsyncTeleport().now(loc, false, TeleportCause.COMMAND, getNewExceptionFuture(sender, label));
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-11 02:17:43 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1) {
|
|
|
|
return getPlayers(server, sender);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-04-09 02:58:41 +02:00
|
|
|
}
|