|
1 | 1 | package com.earth2me.essentials.commands; |
2 | 2 |
|
3 | | -import com.earth2me.essentials.*; |
| 3 | +import java.util.List; |
| 4 | +import java.util.logging.Logger; |
| 5 | + |
4 | 6 | import org.bukkit.Server; |
5 | 7 | import org.bukkit.command.Command; |
6 | 8 | import org.bukkit.command.CommandSender; |
7 | 9 | import org.bukkit.entity.Player; |
8 | 10 |
|
9 | | -import java.util.List; |
10 | | -import java.util.logging.Logger; |
| 11 | +import com.earth2me.essentials.IEssentials; |
| 12 | +import com.earth2me.essentials.OfflinePlayer; |
| 13 | +import com.earth2me.essentials.Trade; |
| 14 | +import com.earth2me.essentials.User; |
| 15 | +import com.earth2me.essentials.Util; |
11 | 16 |
|
12 | 17 |
|
13 | 18 | public abstract class EssentialsCommand implements IEssentialsCommand { |
@@ -46,13 +51,19 @@ protected User getPlayer(final Server server, final String[] args, final int pos |
46 | 51 | if (args.length <= pos) { |
47 | 52 | throw new NotEnoughArgumentsException(); |
48 | 53 | } |
| 54 | + |
49 | 55 | final User user = ess.getUser(args[pos]); |
50 | | - if (user != null) { |
51 | | - if (!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden())) { |
52 | | - throw new NoSuchFieldException(Util.i18n("playerNotFound")); |
53 | | - } |
54 | | - return user; |
55 | | - } |
| 56 | + if ( |
| 57 | + user != null && ( // if the user exists, and either |
| 58 | + getOffline || // 1) we allow offline players |
| 59 | + !( // 2) the player is not offline/hidden |
| 60 | + user.getBase() instanceof OfflinePlayer || |
| 61 | + user.isHidden() |
| 62 | + ) |
| 63 | + ) |
| 64 | + ) return user; |
| 65 | + |
| 66 | + // try to find a user that matches the partial string |
56 | 67 | final List<Player> matches = server.matchPlayer(args[pos]); |
57 | 68 |
|
58 | 69 | if (!matches.isEmpty()) { |
|
0 commit comments