Skip to content

Commit

Permalink
Removed a bunch of casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Jan 18, 2024
1 parent d6736f3 commit bf3891a
Show file tree
Hide file tree
Showing 36 changed files with 372 additions and 523 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class WeatherArgumentType implements ArgumentType<Weather> {
private static final Collection<String> EXAMPLES = Arrays.asList(Weather.overworldClear.languageKey, Weather.overworldFog.languageKey);

public static ArgumentType<Weather> weather() {
public static WeatherArgumentType weather() {
return new WeatherArgumentType();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unchecked")
public class AchievementCommand {
private static final SimpleCommandExceptionType PLAYER_ALREADY_HAS_ACHIEVEMENT = new SimpleCommandExceptionType(() -> I18n.getInstance().translateKey("commands.commander.achievement.grant.exception_already_has_achievement"));

public static void register(CommandDispatcher<CommanderCommandSource> dispatcher) {
dispatcher.register((LiteralArgumentBuilder)(((LiteralArgumentBuilder)LiteralArgumentBuilder.literal("achievement"))
.requires(source -> ((CommanderCommandSource)source).hasAdmin())
.then(((LiteralArgumentBuilder)LiteralArgumentBuilder.<CommanderCommandSource>literal("grant"))
.then(RequiredArgumentBuilder.argument("entities", EntityArgumentType.players())
.then(RequiredArgumentBuilder.argument("achievement", AchievementArgumentType.achievement())
dispatcher.register(((LiteralArgumentBuilder.<CommanderCommandSource>literal("achievement"))
.requires(CommanderCommandSource::hasAdmin)
.then((LiteralArgumentBuilder.<CommanderCommandSource>literal("grant"))
.then(RequiredArgumentBuilder.<CommanderCommandSource, EntitySelector>argument("entities", EntityArgumentType.players())
.then(RequiredArgumentBuilder.<CommanderCommandSource, Achievement>argument("achievement", AchievementArgumentType.achievement())
.executes(c -> {
CommanderCommandSource source = (CommanderCommandSource) c.getSource();
CommanderCommandSource source = c.getSource();
List<? extends Entity> entities = c.getArgument("entities", EntitySelector.class).get(source);
Achievement achievement = c.getArgument("achievement", Achievement.class);

Expand All @@ -54,9 +53,9 @@ public static void register(CommandDispatcher<CommanderCommandSource> dispatcher

return Command.SINGLE_SUCCESS;
}))
.then(LiteralArgumentBuilder.literal("*")
.then(LiteralArgumentBuilder.<CommanderCommandSource>literal("*")
.executes(c -> {
CommanderCommandSource source = (CommanderCommandSource) c.getSource();
CommanderCommandSource source = c.getSource();
List<? extends Entity> entities = c.getArgument("entities", EntitySelector.class).get(source);

for (Achievement achievement : AchievementList.achievementList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
import net.pedroricardo.commander.content.arguments.BiomeArgumentType;
import net.pedroricardo.commander.content.arguments.IntegerCoordinatesArgumentType;
import net.pedroricardo.commander.content.helpers.Coordinates2D;
import net.pedroricardo.commander.content.helpers.IntegerCoordinate;
import net.pedroricardo.commander.content.helpers.IntegerCoordinates;

import java.util.ArrayDeque;
import java.util.Queue;

@SuppressWarnings("unchecked")
public class BiomeCommand {
private static final DynamicCommandExceptionType FAILURE = new DynamicCommandExceptionType(arg -> () -> I18n.getInstance().translateKeyAndFormat("commands.commander.biome.locate.exception_failure", arg));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.pedroricardo.commander.content.arguments.ChunkCoordinatesArgumentType;
import net.pedroricardo.commander.content.helpers.Coordinates2D;

@SuppressWarnings("unchecked")
public class ChunkCommand {
public static void register(CommandDispatcher<CommanderCommandSource> dispatcher) {
dispatcher.register(LiteralArgumentBuilder.<CommanderCommandSource>literal("chunk")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@

import java.util.*;

@SuppressWarnings("unchecked")
public class ClearCommand {
private static final SimpleCommandExceptionType FAILURE = new SimpleCommandExceptionType(() -> I18n.getInstance().translateKey("commands.commander.clear.exception_failure"));

public static void register(CommandDispatcher<CommanderCommandSource> dispatcher) {
dispatcher.register((LiteralArgumentBuilder) LiteralArgumentBuilder.literal("clear")
.requires(source -> ((CommanderCommandSource)source).hasAdmin())
dispatcher.register(LiteralArgumentBuilder.<CommanderCommandSource>literal("clear")
.requires(CommanderCommandSource::hasAdmin)
.executes(c -> {
CommanderCommandSource source = (CommanderCommandSource) c.getSource();
EntityPlayer sender = ((CommanderCommandSource)c.getSource()).getSender();
CommanderCommandSource source = c.getSource();
EntityPlayer sender = source.getSender();

if (sender == null) throw CommanderExceptions.notInWorld().create();

Expand All @@ -40,9 +39,9 @@ public static void register(CommandDispatcher<CommanderCommandSource> dispatcher

return Command.SINGLE_SUCCESS;
})
.then(RequiredArgumentBuilder.argument("players", EntityArgumentType.players())
.then(RequiredArgumentBuilder.<CommanderCommandSource, EntitySelector>argument("players", EntityArgumentType.players())
.executes(c -> {
CommanderCommandSource source = (CommanderCommandSource) c.getSource();
CommanderCommandSource source = c.getSource();
List<? extends Entity> players = c.getArgument("players", EntitySelector.class).get(source);

int itemsCleared = 0;
Expand All @@ -56,9 +55,9 @@ public static void register(CommandDispatcher<CommanderCommandSource> dispatcher

return Command.SINGLE_SUCCESS;
})
.then(RequiredArgumentBuilder.argument("item", ItemStackArgumentType.itemStack())
.then(RequiredArgumentBuilder.<CommanderCommandSource, ItemStack>argument("item", ItemStackArgumentType.itemStack())
.executes(c -> {
CommanderCommandSource source = (CommanderCommandSource) c.getSource();
CommanderCommandSource source = c.getSource();
List<? extends Entity> players = c.getArgument("players", EntitySelector.class).get(source);
ItemStack itemStack = c.getArgument("item", ItemStack.class);

Expand Down
Loading

0 comments on commit bf3891a

Please sign in to comment.