-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move command handling to Brigadier (#7)
- Loading branch information
Showing
18 changed files
with
700 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package de.t14d3.zones; | ||
|
||
import de.t14d3.zones.brigadier.Command; | ||
import de.t14d3.zones.utils.Flags; | ||
import de.t14d3.zones.utils.Utils; | ||
import io.papermc.paper.command.brigadier.Commands; | ||
import io.papermc.paper.plugin.bootstrap.BootstrapContext; | ||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap; | ||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext; | ||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; | ||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
public class PaperBootstrap implements PluginBootstrap { | ||
|
||
private Zones zones; | ||
private Flags flags; | ||
|
||
@Override | ||
public void bootstrap(BootstrapContext context) { | ||
flags = new Flags(); | ||
for (Map.Entry<String, String> entry : Utils.defaultFlags().entrySet()) { | ||
flags.registerFlag(entry.getKey(), entry.getValue()); | ||
} | ||
Command cmd = new Command(this); | ||
LifecycleEventManager<@NotNull BootstrapContext> eventManager = context.getLifecycleManager(); | ||
eventManager.registerEventHandler(LifecycleEvents.COMMANDS, event -> { | ||
final Commands commands = event.registrar(); | ||
commands.register(cmd.node()); | ||
}); | ||
} | ||
|
||
@Override | ||
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) { | ||
zones = new Zones(this); | ||
return zones; | ||
} | ||
|
||
public Flags getFlags() { | ||
return flags; | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.