Skip to content

Commit 40c32a7

Browse files
committed
fix compound example compile
1 parent 38a15e6 commit 40c32a7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

examples/example-sponge/src/main/java/org/incendo/cloud/examples/sponge/CloudExamplePlugin.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
// SOFTWARE.
2323
//
24-
package cloud.commandframework.examples.sponge;
24+
package org.incendo.cloud.examples.sponge;
2525

2626
import com.google.inject.Inject;
2727
import com.google.inject.Injector;
@@ -40,6 +40,7 @@
4040
import org.incendo.cloud.description.Description;
4141
import org.incendo.cloud.execution.ExecutionCoordinator;
4242
import org.incendo.cloud.minecraft.extras.MinecraftExceptionHandler;
43+
import org.incendo.cloud.parser.ArgumentParseResult;
4344
import org.incendo.cloud.parser.standard.StringParser;
4445
import org.incendo.cloud.permission.PredicatePermission;
4546
import org.incendo.cloud.sponge.CloudInjectionModule;
@@ -50,7 +51,7 @@
5051
import org.incendo.cloud.sponge.data.MultipleEntitySelector;
5152
import org.incendo.cloud.sponge.data.ProtoItemStack;
5253
import org.incendo.cloud.sponge.data.SinglePlayerSelector;
53-
import org.incendo.cloud.type.tuple.Pair;
54+
import org.incendo.cloud.sponge.exception.ComponentMessageRuntimeException;
5455
import org.spongepowered.api.ResourceKey;
5556
import org.spongepowered.api.Sponge;
5657
import org.spongepowered.api.command.CommandCause;
@@ -403,12 +404,16 @@ private void registerCommands() {
403404
.requiredArgumentPair(
404405
"itemstack",
405406
TypeToken.get(ItemStack.class),
406-
Pair.of("item", "amount"),
407-
Pair.of(ProtoItemStack.class, Integer.class),
408-
(sender, pair) -> {
409-
final ProtoItemStack proto = pair.first();
410-
final int amount = pair.second();
411-
return proto.createItemStack(amount, true);
407+
"item", protoItemStackParser(),
408+
"amount", integerParser(),
409+
(sender, proto, amount) -> {
410+
try {
411+
return ArgumentParseResult.successFuture(
412+
proto.createItemStack(amount, true)
413+
);
414+
} catch (final ComponentMessageRuntimeException e) {
415+
return ArgumentParseResult.failureFuture(e);
416+
}
412417
},
413418
Description.of("The ItemStack to give")
414419
)

0 commit comments

Comments
 (0)