-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update outdated paper references to legacy and add modern section
- Loading branch information
1 parent
7476b35
commit b81ab31
Showing
6 changed files
with
112 additions
and
24 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
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
63 changes: 63 additions & 0 deletions
63
code/src/main/java/org/incendo/cloud/snippet/minecraft/PaperExample.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,63 @@ | ||
package org.incendo.cloud.snippet.minecraft; | ||
|
||
import io.papermc.paper.command.brigadier.CommandSourceStack; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.incendo.cloud.SenderMapper; | ||
import org.incendo.cloud.execution.ExecutionCoordinator; | ||
import org.incendo.cloud.paper.LegacyPaperCommandManager; | ||
import org.incendo.cloud.paper.PaperCommandManager; | ||
|
||
public class PaperExample { | ||
|
||
public void exampleLegacyNative(final @NonNull JavaPlugin yourPlugin) { | ||
final ExecutionCoordinator<CommandSender> executionCoordinator = ExecutionCoordinator.simpleCoordinator(); | ||
// --8<-- [start:legacy_native] | ||
LegacyPaperCommandManager<CommandSender> commandManager = LegacyPaperCommandManager.createNative( | ||
yourPlugin, /* 1 */ | ||
executionCoordinator /* 2 */ | ||
); | ||
// --8<-- [end:legacy_native] | ||
} | ||
|
||
public void exampleLegacyCustom( | ||
final @NonNull JavaPlugin yourPlugin, | ||
final @NonNull SenderMapper<CommandSender, YourSenderType> senderMapper | ||
) { | ||
final ExecutionCoordinator<YourSenderType> executionCoordinator = ExecutionCoordinator.simpleCoordinator(); | ||
// --8<-- [start:legacy_custom] | ||
LegacyPaperCommandManager<YourSenderType> commandManager = new LegacyPaperCommandManager<>( | ||
yourPlugin, /* 1 */ | ||
executionCoordinator, /* 2 */ | ||
senderMapper /* 3 */ | ||
); | ||
// --8<-- [end:legacy_custom] | ||
} | ||
|
||
public void exampleModernNative(final @NonNull JavaPlugin javaPlugin) { | ||
final ExecutionCoordinator<CommandSourceStack> executionCoordinator = ExecutionCoordinator.simpleCoordinator(); | ||
// --8<-- [start:modern_native] | ||
PaperCommandManager<CommandSourceStack> commandManager = PaperCommandManager.builder() | ||
.executionCoordinator(executionCoordinator) | ||
.buildOnEnable(javaPlugin); | ||
// or: .buildBootstrapped(bootstrapContext); | ||
// --8<-- [end:modern_native] | ||
} | ||
|
||
public void exampleModernCustom( | ||
final @NonNull JavaPlugin javaPlugin, | ||
final @NonNull SenderMapper<CommandSourceStack, YourSenderType> senderMapper | ||
) { | ||
final ExecutionCoordinator<YourSenderType> executionCoordinator = ExecutionCoordinator.simpleCoordinator(); | ||
// --8<-- [start:modern_custom] | ||
PaperCommandManager<YourSenderType> commandManager = PaperCommandManager.builder(senderMapper) | ||
.executionCoordinator(executionCoordinator) | ||
.buildOnEnable(javaPlugin); | ||
// or: .buildBootstrapped(bootstrapContext); | ||
// --8<-- [end:modern_custom] | ||
} | ||
|
||
public record YourSenderType() { | ||
} | ||
} |
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