-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into v3.0.0
# Conflicts: # README.md # buildSrc/src/main/kotlin/litecommands.java-conventions.gradle.kts # examples/bukkit/build.gradle.kts # examples/velocity/build.gradle.kts # litecommands-bukkit-adventure/README.md # litecommands-bukkit-adventure/src/main/java/dev/rollczi/litecommands/bukkit/adventure/LiteBukkitAdventureFactory.java # litecommands-bukkit/README.md # litecommands-bungee/README.md # litecommands-core/src/main/java/dev/rollczi/litecommands/argument/joiner/JoinerArgument.java # litecommands-core/src/main/java/dev/rollczi/litecommands/implementation/LiteFactory.java # litecommands-core/src/main/java/dev/rollczi/litecommands/suggestion/UniformSuggestionStack.java # litecommands-core/src/test/java/dev/rollczi/litecommands/suggestion/SuggestionStringTest.java # litecommands-minestom/README.md # litecommands-velocity/README.md # litecommands-velocity/src/main/java/dev/rollczi/litecommands/velocity/LiteVelocityFactory.java
- Loading branch information
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...src/main/java/dev/rollczi/litecommands/bukkit/adventure/KyoriComponentJoinerArgument.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,14 @@ | ||
package dev.rollczi.litecommands.bukkit.adventure; | ||
|
||
import dev.rollczi.litecommands.argument.joiner.JoinerArgument; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.serializer.ComponentSerializer; | ||
import org.bukkit.command.CommandSender; | ||
|
||
class KyoriComponentJoinerArgument extends JoinerArgument<CommandSender, Component> { | ||
|
||
KyoriComponentJoinerArgument(ComponentSerializer<Component, ?, String> kyoriComponentSerializer) { | ||
super(kyoriComponentSerializer::deserialize); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...ands-bungee/src/main/java/dev/rollczi/litecommands/bungee/tools/BungeePlayerArgument.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,37 @@ | ||
package dev.rollczi.litecommands.bungee.tools; | ||
|
||
import dev.rollczi.litecommands.argument.ArgumentName; | ||
import dev.rollczi.litecommands.argument.simple.OneArgument; | ||
import dev.rollczi.litecommands.command.LiteInvocation; | ||
import dev.rollczi.litecommands.suggestion.Suggestion; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import net.md_5.bungee.api.ProxyServer; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import panda.std.Option; | ||
import panda.std.Result; | ||
|
||
@ArgumentName("player") | ||
public class BungeePlayerArgument<T> implements OneArgument<ProxiedPlayer> { | ||
|
||
private final ProxyServer server; | ||
private final T playerNotFoundMessage; | ||
|
||
public BungeePlayerArgument(ProxyServer server, T playerNotFoundMessage) { | ||
this.server = server; | ||
this.playerNotFoundMessage = playerNotFoundMessage; | ||
} | ||
|
||
@Override | ||
public Result<ProxiedPlayer, Object> parse(LiteInvocation invocation, String argument) { | ||
return Option.of(this.server.getPlayer(argument)).toResult(playerNotFoundMessage); | ||
} | ||
|
||
@Override | ||
public List<Suggestion> suggest(LiteInvocation invocation) { | ||
return server.getPlayers().stream() | ||
.map(ProxiedPlayer::getName) | ||
.map(Suggestion::of) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...nds-core/src/main/java/dev/rollczi/litecommands/argument/joiner/StringJoinerArgument.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,9 @@ | ||
package dev.rollczi.litecommands.argument.joiner; | ||
|
||
public class StringJoinerArgument<SENDER> extends JoinerArgument<SENDER, String> { | ||
|
||
public StringJoinerArgument() { | ||
super(String::valueOf); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...elocity/src/main/java/dev/rollczi/litecommands/velocity/KyoriComponentJoinerArgument.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,18 @@ | ||
package dev.rollczi.litecommands.velocity; | ||
|
||
import com.velocitypowered.api.command.CommandSource; | ||
import dev.rollczi.litecommands.argument.joiner.JoinerArgument; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
|
||
class KyoriComponentJoinerArgument extends JoinerArgument<CommandSource, Component> { | ||
|
||
static final MiniMessage MINI_MESSAGE = MiniMessage.builder() | ||
.postProcessor(new LegacyProcessor()) | ||
.build(); | ||
|
||
KyoriComponentJoinerArgument() { | ||
super(MINI_MESSAGE::deserialize); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...elocity/src/main/java/dev/rollczi/litecommands/velocity/tools/VelocityPlayerArgument.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,36 @@ | ||
package dev.rollczi.litecommands.velocity.tools; | ||
|
||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import dev.rollczi.litecommands.argument.ArgumentName; | ||
import dev.rollczi.litecommands.argument.simple.OneArgument; | ||
import dev.rollczi.litecommands.command.LiteInvocation; | ||
import dev.rollczi.litecommands.suggestion.Suggestion; | ||
import java.util.List; | ||
import panda.std.Option; | ||
import panda.std.Result; | ||
|
||
@ArgumentName("player") | ||
public class VelocityPlayerArgument<T> implements OneArgument<Player> { | ||
|
||
private final ProxyServer server; | ||
private final T playerNotFoundMessage; | ||
|
||
public VelocityPlayerArgument(ProxyServer server, T playerNotFoundMessage) { | ||
this.server = server; | ||
this.playerNotFoundMessage = playerNotFoundMessage; | ||
} | ||
|
||
@Override | ||
public Result<Player, Object> parse(LiteInvocation invocation, String argument) { | ||
return Option.ofOptional(this.server.getPlayer(argument)).toResult(playerNotFoundMessage); | ||
} | ||
|
||
@Override | ||
public List<Suggestion> suggest(LiteInvocation invocation) { | ||
return server.getAllPlayers().stream() | ||
.map(Player::getUsername) | ||
.map(Suggestion::of) | ||
.toList(); | ||
} | ||
} |