More work towards relocating OnlinePlayer context

This context was conflicting with each other over multiple
ACF modules, so if someone wanted to use multiple ACF's in same jar,
it would clash and not work.

The PR to move these was incomplete and this finishes fixing the
context handlers to support new and old.
This commit is contained in:
Aikar
2019-02-23 21:23:35 -05:00
parent 5c1d446c19
commit 17d89ad216
13 changed files with 128 additions and 102 deletions
@@ -24,7 +24,7 @@
package co.aikar.commands;
import co.aikar.commands.contexts.CommandResultSupplier;
import co.aikar.commands.contexts.sponge.OnlinePlayer;
import co.aikar.commands.sponge.contexts.OnlinePlayer;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandSource;
@@ -50,6 +50,10 @@ public class SpongeCommandContexts extends CommandContexts<SpongeCommandExecutio
registerIssuerOnlyContext(CommandResultSupplier.class, c -> new CommandResultSupplier());
registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional()));
registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> {
OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional());
return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null;
});
registerContext(User.class, c -> {
String name = c.popFirstArg();
// try online players first
@@ -163,7 +167,6 @@ public class SpongeCommandContexts extends CommandContexts<SpongeCommandExecutio
@Nullable
OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument {
Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup);
//noinspection Duplicates
if (player == null) {
if (allowMissing) {
return null;
@@ -26,10 +26,10 @@ package co.aikar.commands.contexts;
import org.spongepowered.api.entity.living.player.Player;
/**
* @deprecated Use {@link co.aikar.commands.contexts.sponge.OnlinePlayer instead}
* @deprecated Use {@link co.aikar.commands.sponge.contexts.OnlinePlayer instead}
*/
@Deprecated
public class OnlinePlayer extends co.aikar.commands.contexts.sponge.OnlinePlayer {
public class OnlinePlayer extends co.aikar.commands.sponge.contexts.OnlinePlayer {
public OnlinePlayer(Player player) {
super(player);
}
@@ -21,7 +21,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package co.aikar.commands.contexts.sponge;
package co.aikar.commands.sponge.contexts;
import org.spongepowered.api.entity.living.player.Player;
@@ -53,8 +53,6 @@ public class OnlinePlayer {
@Override
public String toString() {
return "OnlinePlayer{" +
"player=" + player +
'}';
return "OnlinePlayer{player=" + player + '}';
}
}