From 74a8acac2fe8e8f90c9dba0d348dd806bbab6f1b Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:51:46 +0100 Subject: [PATCH] enable generic injections and fix resulting errors --- gradle.properties | 4 ++++ src/main/java/serverutils/command/CmdLeaderboard.java | 2 +- .../handlers/ServerUtilitiesServerEventHandler.java | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index e9f40cb7b..d31d5d1f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,6 +25,10 @@ developmentEnvironmentUserName = Developer # See https://github.com/bsideup/jabel for details on how this works. enableModernJavaSyntax = true +# Enables injecting missing generics into the decompiled source code for a better coding experience +# Turns most publicly visible List, Map, etc. into proper List, Map types +enableGenericInjection = true + # Generate a class with a String field for the mod version named as defined below. # If generateGradleTokenClass is empty or not missing, no such class will be generated. # If gradleTokenVersion is empty or missing, the field will not be present in the class. diff --git a/src/main/java/serverutils/command/CmdLeaderboard.java b/src/main/java/serverutils/command/CmdLeaderboard.java index a8e47dbbf..fd341fed9 100644 --- a/src/main/java/serverutils/command/CmdLeaderboard.java +++ b/src/main/java/serverutils/command/CmdLeaderboard.java @@ -30,7 +30,7 @@ public CmdLeaderboard() { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args) { if (args.length == 1) { - return getListOfStringsFromIterableMatchingLastWord(args, ServerUtilitiesCommon.LEADERBOARDS.keySet()); + return matchFromIterable(args, ServerUtilitiesCommon.LEADERBOARDS.keySet()); } return super.addTabCompletionOptions(sender, args); diff --git a/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java b/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java index 87bd28656..00807ca73 100644 --- a/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java +++ b/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.regex.Pattern; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.stats.StatList; import net.minecraft.util.ChatComponentText; @@ -260,9 +261,11 @@ public void onWorldTick(TickEvent.WorldTickEvent event) { } if (ServerUtilitiesConfig.world.show_playtime && event.world.getTotalWorldTime() % 20L == 7L) { - for (EntityPlayerMP player : (List) event.world.playerEntities) { - new MessageUpdatePlayTime(player.func_147099_x().writeStat(StatList.minutesPlayedStat)) - .sendTo(player); + for (EntityPlayer player : event.world.playerEntities) { + if (player instanceof EntityPlayerMP playerMP) { + new MessageUpdatePlayTime(playerMP.func_147099_x().writeStat(StatList.minutesPlayedStat)) + .sendTo(playerMP); + } } } }