-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PGM switch to cloud command framework
Signed-off-by: Pugzy <[email protected]>
- Loading branch information
1 parent
cc3e489
commit 976ba89
Showing
11 changed files
with
203 additions
and
168 deletions.
There are no files selected for viewing
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
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/dev/pgm/events/commands/CommandException.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,26 @@ | ||
package dev.pgm.events.commands; | ||
|
||
import static net.kyori.adventure.text.Component.text; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.util.ComponentMessageThrowable; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CommandException extends RuntimeException implements ComponentMessageThrowable { | ||
|
||
private Component component; | ||
|
||
public CommandException(String message) { | ||
super(message); | ||
} | ||
|
||
public CommandException(Component component) { | ||
this.component = component; | ||
} | ||
|
||
@Override | ||
public @Nullable Component componentMessage() { | ||
if (component != null) return component; | ||
return text(this.getMessage()); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/dev/pgm/events/commands/EventsCommandGraph.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,69 @@ | ||
package dev.pgm.events.commands; | ||
|
||
import dev.pgm.events.EventsPlugin; | ||
import dev.pgm.events.TournamentManager; | ||
import dev.pgm.events.api.teams.TournamentTeamRegistry; | ||
import dev.pgm.events.commands.providers.TournamentProvider; | ||
import dev.pgm.events.format.TournamentFormat; | ||
import dev.pgm.events.team.TournamentTeamManager; | ||
import java.util.List; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import tc.oc.pgm.api.PGM; | ||
import tc.oc.pgm.api.match.Match; | ||
import tc.oc.pgm.api.player.MatchPlayer; | ||
import tc.oc.pgm.command.injectors.MatchPlayerProvider; | ||
import tc.oc.pgm.command.injectors.MatchProvider; | ||
import tc.oc.pgm.command.injectors.PlayerProvider; | ||
import tc.oc.pgm.command.util.CommandGraph; | ||
import tc.oc.pgm.lib.cloud.commandframework.extra.confirmation.CommandConfirmationManager; | ||
import tc.oc.pgm.lib.cloud.commandframework.minecraft.extras.MinecraftHelp; | ||
import tc.oc.pgm.util.Audience; | ||
|
||
public class EventsCommandGraph extends CommandGraph<EventsPlugin> { | ||
|
||
public EventsCommandGraph(EventsPlugin plugin) throws Exception { | ||
super(plugin); | ||
} | ||
|
||
@Override | ||
protected MinecraftHelp<CommandSender> createHelp() { | ||
return new MinecraftHelp<>("/events help", Audience::get, manager); | ||
} | ||
|
||
@Override | ||
protected CommandConfirmationManager<CommandSender> createConfirmationManager() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void setupInjectors() { | ||
// PGM Injectors | ||
registerInjector(PGM.class, PGM::get); | ||
registerInjector(Match.class, new MatchProvider()); | ||
registerInjector(MatchPlayer.class, new MatchPlayerProvider()); | ||
registerInjector(Player.class, new PlayerProvider()); | ||
|
||
// Events Injectors | ||
registerInjector(TournamentManager.class, EventsPlugin::getTournamentManager); | ||
registerInjector(TournamentTeamRegistry.class, EventsPlugin::getTeamRegistry); | ||
registerInjector(TournamentTeamManager.class, EventsPlugin::getTeamManager); | ||
registerInjector(TournamentFormat.class, new TournamentProvider(plugin.getTournamentManager())); | ||
} | ||
|
||
@Override | ||
protected void setupParsers() { | ||
// No custom parses used | ||
} | ||
|
||
@Override | ||
public void registerCommands() { | ||
register(new VetoCommands()); | ||
register(new TournamentUserCommands()); | ||
register(new TournamentAdminCommands()); | ||
} | ||
|
||
public <T> void registerCommands(List<T> commands) { | ||
commands.forEach(this::register); | ||
} | ||
} |
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
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
Oops, something went wrong.