diff --git a/src/main/java/com/mojang/brigadier/arguments/IntegerArgumentType.java b/src/main/java/com/mojang/brigadier/arguments/IntegerArgumentType.java index d2da367..3e56f74 100644 --- a/src/main/java/com/mojang/brigadier/arguments/IntegerArgumentType.java +++ b/src/main/java/com/mojang/brigadier/arguments/IntegerArgumentType.java @@ -38,7 +38,7 @@ public class IntegerArgumentType implements CommandArgumentType { } public static int getInteger(CommandContext context, String name) { - return context.getArgument(name, int.class).getResult(); + return context.getArgument(name, int.class); } @Override diff --git a/src/main/java/com/mojang/brigadier/context/CommandContext.java b/src/main/java/com/mojang/brigadier/context/CommandContext.java index e2705ac..237755e 100644 --- a/src/main/java/com/mojang/brigadier/context/CommandContext.java +++ b/src/main/java/com/mojang/brigadier/context/CommandContext.java @@ -34,7 +34,7 @@ public class CommandContext { } @SuppressWarnings("unchecked") - public ParsedArgument getArgument(String name, Class clazz) { + public V getArgument(String name, Class clazz) { ParsedArgument argument = arguments.get(name); if (argument == null) { @@ -42,7 +42,7 @@ public class CommandContext { } if (Primitives.wrap(clazz).isAssignableFrom(argument.getResult().getClass())) { - return (ParsedArgument) argument; + return ((ParsedArgument) argument).getResult(); } else { throw new IllegalArgumentException("Argument '" + name + "' is defined as " + argument.getResult().getClass().getSimpleName() + ", not " + clazz); } diff --git a/src/test/java/com/mojang/brigadier/context/CommandContextTest.java b/src/test/java/com/mojang/brigadier/context/CommandContextTest.java index a680584..fc802e3 100644 --- a/src/test/java/com/mojang/brigadier/context/CommandContextTest.java +++ b/src/test/java/com/mojang/brigadier/context/CommandContextTest.java @@ -46,7 +46,7 @@ public class CommandContextTest { @Test public void testGetArgument() throws Exception { CommandContext context = builder.withArgument("foo", integer().parse("123")).build(); - assertThat(context.getArgument("foo", int.class).getResult(), is(123)); + assertThat(context.getArgument("foo", int.class), is(123)); } @Test @@ -88,11 +88,11 @@ public class CommandContextTest { when(supplier.get()).thenReturn(first); CommandContext context = builder.withNode(literal("test").build(), "test").withArgument("test", new DynamicParsedArgument<>("test", supplier)).build(); - assertThat(context.getArgument("test", Object.class).getResult(), is(first)); + assertThat(context.getArgument("test", Object.class), is(first)); when(supplier.get()).thenReturn(second); CommandContext copy = context.copy(); assertThat(context, is(equalTo(copy))); - assertThat(copy.getArgument("test", Object.class).getResult(), is(second)); + assertThat(copy.getArgument("test", Object.class), is(second)); } } \ No newline at end of file