-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c35279d
commit 782a25b
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/me/roinujnosde/titansbattle/commands/contexts/OnlinePlayerContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters