Skip to content

Commit

Permalink
fix: bedrock nicknames not accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
RoinujNosde committed Aug 11, 2023
1 parent c35279d commit 782a25b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.roinujnosde.titansbattle.commands.contexts;

import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.MinecraftMessageKeys;
import co.aikar.commands.bukkit.contexts.OnlinePlayer;
import me.roinujnosde.titansbattle.TitansBattle;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class OnlinePlayerContext extends AbstractContextResolver<OnlinePlayer> {

public OnlinePlayerContext(@NotNull TitansBattle plugin) {
super(plugin);
}

@Override
public @NotNull Class<OnlinePlayer> getType() {
return OnlinePlayer.class;
}

@Override
public OnlinePlayer getContext(BukkitCommandExecutionContext cec) throws InvalidCommandArgument {
String name = cec.popFirstArg();
Player player = Bukkit.getPlayerExact(name);
if (player == null) {
throw new InvalidCommandArgument(MinecraftMessageKeys.NO_PLAYER_FOUND_SERVER, "{search}", name);
}
return new OnlinePlayer(player);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private void registerContexts() {
registerContext(new ChallengeRequestContext(getPlugin()));
registerContext(new ArenaConfigurationContext(getPlugin()));
registerContext(new GameConfigurationContext(getPlugin()));
registerContext(new OnlinePlayerContext(getPlugin()));
}

private void registerReplacements() {
Expand Down

0 comments on commit 782a25b

Please sign in to comment.