From 5c20b9a7073fb1411a7bb73c3da50b84d9f5f052 Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:02:55 +0100 Subject: [PATCH] cleanup unchecked --- .../java/serverutils/ServerUtilitiesPermissions.java | 2 -- src/main/java/serverutils/aurora/AuroraConfig.java | 2 +- .../java/serverutils/aurora/mc/PlayerListJson.java | 4 +--- .../java/serverutils/aurora/mc/PlayerListTable.java | 4 +--- .../serverutils/client/gui/SidebarButtonManager.java | 10 ++++------ src/main/java/serverutils/data/BlockDimPosStorage.java | 3 +-- src/main/java/serverutils/data/ClaimedChunks.java | 7 ++----- .../java/serverutils/data/ServerUtilitiesTeamData.java | 5 ++--- .../serverutils/data/ServerUtilitiesUniverseData.java | 3 +-- .../java/serverutils/events/ServerReloadEvent.java | 5 +---- .../handlers/ServerUtilitiesClientEventHandler.java | 2 +- .../handlers/ServerUtilitiesPlayerEventHandler.java | 5 +---- .../handlers/ServerUtilitiesServerEventHandler.java | 7 ++----- .../java/serverutils/lib/client/CachedVertexData.java | 2 +- src/main/java/serverutils/lib/command/CmdBase.java | 2 -- .../java/serverutils/lib/command/CommandTreeBase.java | 2 +- src/main/java/serverutils/lib/data/ForgeTeam.java | 3 +-- .../java/serverutils/lib/data/ServerUtilitiesAPI.java | 7 ++----- src/main/java/serverutils/lib/gui/ContainerBase.java | 2 +- .../java/serverutils/lib/gui/GuiContainerWrapper.java | 2 +- src/main/java/serverutils/lib/gui/GuiWrapper.java | 2 +- src/main/java/serverutils/lib/util/DimensionType.java | 4 ++-- src/main/java/serverutils/lib/util/InvUtils.java | 3 +-- src/main/java/serverutils/lib/util/JsonUtils.java | 6 ++---- src/main/java/serverutils/lib/util/NBTUtils.java | 7 +++---- src/main/java/serverutils/lib/util/ServerUtils.java | 8 +++----- .../lib/util/text_components/ChatComponentScore.java | 4 +--- .../lib/util/text_components/Notification.java | 4 +--- .../util/text_components/TextComponentCountdown.java | 4 +--- src/main/java/serverutils/net/MessageSyncData.java | 3 +-- 30 files changed, 41 insertions(+), 83 deletions(-) diff --git a/src/main/java/serverutils/ServerUtilitiesPermissions.java b/src/main/java/serverutils/ServerUtilitiesPermissions.java index e7994c116..6a2d3ff57 100644 --- a/src/main/java/serverutils/ServerUtilitiesPermissions.java +++ b/src/main/java/serverutils/ServerUtilitiesPermissions.java @@ -244,8 +244,6 @@ public static void registerPermissions() { } } - // CLAIMS_ITEM_BLACKLIST.add(Items.END_CRYSTAL); - for (Block block : GameData.getBlockRegistry().typeSafeIterable()) { String name = formatId(block); PermissionAPI.registerNode( diff --git a/src/main/java/serverutils/aurora/AuroraConfig.java b/src/main/java/serverutils/aurora/AuroraConfig.java index 6b1f6c583..bec0e128f 100644 --- a/src/main/java/serverutils/aurora/AuroraConfig.java +++ b/src/main/java/serverutils/aurora/AuroraConfig.java @@ -36,7 +36,7 @@ public static boolean sync() { "world_info_json", "ENABLED", "Enable the world info page, Default: ENABLED, Valid values: ENABLED, REQUIRES_AUTH, DISABLED") - .getString();; + .getString(); general.player_list_table = config.get( PAGES_CAT, "player_list_table", diff --git a/src/main/java/serverutils/aurora/mc/PlayerListJson.java b/src/main/java/serverutils/aurora/mc/PlayerListJson.java index 372c2ec0b..a81b3dfce 100644 --- a/src/main/java/serverutils/aurora/mc/PlayerListJson.java +++ b/src/main/java/serverutils/aurora/mc/PlayerListJson.java @@ -1,7 +1,5 @@ package serverutils.aurora.mc; -import java.util.List; - import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; @@ -37,7 +35,7 @@ public JsonElement getJson() { JsonArray players = new JsonArray(); - for (EntityPlayerMP player : (List) server.getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : server.getConfigurationManager().playerEntityList) { JsonObject o = new JsonObject(); o.addProperty("name", player.getDisplayName()); o.addProperty("uuid", player.getUniqueID().toString()); diff --git a/src/main/java/serverutils/aurora/mc/PlayerListTable.java b/src/main/java/serverutils/aurora/mc/PlayerListTable.java index 7a8117e17..6be6c09ac 100644 --- a/src/main/java/serverutils/aurora/mc/PlayerListTable.java +++ b/src/main/java/serverutils/aurora/mc/PlayerListTable.java @@ -1,7 +1,5 @@ package serverutils.aurora.mc; -import java.util.List; - import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; @@ -51,7 +49,7 @@ public boolean addBackButton() { public void body(Tag body) { Tag playerTable = body.table().addClass("player_table"); - for (EntityPlayerMP player : (List) server.getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : server.getConfigurationManager().playerEntityList) { String id = player.getUniqueID().toString().replace("-", ""); Tag row = playerTable.tr(); row.td().img("https://crafatar.com/avatars/" + id + "?size=16"); diff --git a/src/main/java/serverutils/client/gui/SidebarButtonManager.java b/src/main/java/serverutils/client/gui/SidebarButtonManager.java index bf2b5e020..127248a40 100644 --- a/src/main/java/serverutils/client/gui/SidebarButtonManager.java +++ b/src/main/java/serverutils/client/gui/SidebarButtonManager.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import net.minecraft.client.Minecraft; @@ -33,7 +32,6 @@ public enum SidebarButtonManager implements ISelectiveResourceReloadListener { public final List groups = new ArrayList<>(); @Override - @SuppressWarnings("unchecked") public void onResourceManagerReload(IResourceManager manager, Predicate resourcePredicate) { if (!resourcePredicate.test(ServerUtilitiesResourceType.SERVERUTILS_CONFIG)) { return; @@ -56,9 +54,9 @@ public void onResourceManagerReload(IResourceManager manager, Predicate groupMap = new HashMap<>(); - for (String domain : (Set) manager.getResourceDomains()) { + for (String domain : manager.getResourceDomains()) { try { - for (IResource resource : (List) manager + for (IResource resource : manager .getAllResources(new ResourceLocation(domain, "sidebar_button_groups.json"))) { JsonElement json = DataReader.get(resource).json(); @@ -85,9 +83,9 @@ public void onResourceManagerReload(IResourceManager manager, Predicate) manager.getResourceDomains()) { + for (String domain : manager.getResourceDomains()) { try { - for (IResource resource : (List) manager + for (IResource resource : manager .getAllResources(new ResourceLocation(domain, "sidebar_buttons.json"))) { JsonElement json = DataReader.get(resource).json(); diff --git a/src/main/java/serverutils/data/BlockDimPosStorage.java b/src/main/java/serverutils/data/BlockDimPosStorage.java index b4cdc5d7e..e8c77658b 100644 --- a/src/main/java/serverutils/data/BlockDimPosStorage.java +++ b/src/main/java/serverutils/data/BlockDimPosStorage.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import javax.annotation.Nullable; @@ -71,7 +70,7 @@ public void deserializeNBT(NBTTagCompound nbt) { map.clear(); names.clear(); - for (String name : (Set) nbt.func_150296_c()) { + for (String name : nbt.func_150296_c()) { BlockDimPos pos = BlockDimPos.fromIntArray(nbt.getIntArray(name)); if (pos != null) { diff --git a/src/main/java/serverutils/data/ClaimedChunks.java b/src/main/java/serverutils/data/ClaimedChunks.java index 6057c51eb..dc384c5b8 100644 --- a/src/main/java/serverutils/data/ClaimedChunks.java +++ b/src/main/java/serverutils/data/ClaimedChunks.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.OptionalInt; import java.util.Set; @@ -122,8 +121,7 @@ public void update(Universe universe, long now) { } } - for (EntityPlayerMP player : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) { ChunkDimPos playerPos = new ChunkDimPos(player); int startX = playerPos.posX - ChunkSelectorMap.TILES_GUI2; int startZ = playerPos.posZ - ChunkSelectorMap.TILES_GUI2; @@ -153,8 +151,7 @@ public void removeChunk(ChunkDimPos pos) { markDirty(); } if (OtherMods.isVPLoaded()) { - for (EntityPlayerMP player : (List) instance.universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : instance.universe.server.getConfigurationManager().playerEntityList) { if (PermissionAPI.hasPermission(player, ServerUtilitiesPermissions.CLAIMS_JOURNEYMAP)) { new MessageJourneyMapRemove(pos).sendTo(player); } diff --git a/src/main/java/serverutils/data/ServerUtilitiesTeamData.java b/src/main/java/serverutils/data/ServerUtilitiesTeamData.java index f5a38885c..12d399464 100644 --- a/src/main/java/serverutils/data/ServerUtilitiesTeamData.java +++ b/src/main/java/serverutils/data/ServerUtilitiesTeamData.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.Map; import java.util.OptionalInt; -import java.util.Set; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -101,7 +100,7 @@ public void onTeamLoaded(ForgeTeamLoadedEvent event) { NBTTagCompound claimedChunksTag = nbt.getCompoundTag("ClaimedChunks"); - for (String dim : (Set) claimedChunksTag.func_150296_c()) { + for (String dim : claimedChunksTag.func_150296_c()) { NBTTagList list = claimedChunksTag.getTagList(dim, Constants.NBT.TAG_COMPOUND); int dimInt = Integer.parseInt(dim); @@ -170,7 +169,7 @@ public void deserializeNBT(NBTTagCompound nbt) { team.markDirty(); NBTTagCompound claimedChunksTag = nbt.getCompoundTag("ClaimedChunks"); - for (String dim : (Set) claimedChunksTag.func_150296_c()) { + for (String dim : claimedChunksTag.func_150296_c()) { NBTTagList list = claimedChunksTag.getTagList(dim, Constants.NBT.TAG_COMPOUND); int dimInt = Integer.parseInt(dim); diff --git a/src/main/java/serverutils/data/ServerUtilitiesUniverseData.java b/src/main/java/serverutils/data/ServerUtilitiesUniverseData.java index 1b60ec9bd..b3c80e569 100644 --- a/src/main/java/serverutils/data/ServerUtilitiesUniverseData.java +++ b/src/main/java/serverutils/data/ServerUtilitiesUniverseData.java @@ -155,8 +155,7 @@ public void onUniverseLoaded(UniverseLoadedEvent.Finished event) { event.getUniverse().scheduleTask(TimeType.MILLIS, shutdownTime - t.millis(), universe -> { String timeString = t.toTimeString(); - for (EntityPlayerMP player : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) { Notification.of( RESTART_TIMER_ID, StringUtils.color( diff --git a/src/main/java/serverutils/events/ServerReloadEvent.java b/src/main/java/serverutils/events/ServerReloadEvent.java index 5902e1d98..70450cf5b 100644 --- a/src/main/java/serverutils/events/ServerReloadEvent.java +++ b/src/main/java/serverutils/events/ServerReloadEvent.java @@ -2,7 +2,6 @@ import java.util.Collection; import java.util.Collections; -import java.util.List; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; @@ -23,7 +22,6 @@ public class ServerReloadEvent extends UniverseEvent { private boolean clientReloadRequired; private final Collection onlinePlayers; - @SuppressWarnings("unchecked") public ServerReloadEvent(Universe u, ICommandSender c, EnumReloadType t, ResourceLocation id, Collection f) { super(u); @@ -32,8 +30,7 @@ public ServerReloadEvent(Universe u, ICommandSender c, EnumReloadType t, Resourc reloadId = id; failed = f; clientReloadRequired = false; - onlinePlayers = u.server.getConfigurationManager() != null - ? (List) u.server.getConfigurationManager().playerEntityList + onlinePlayers = u.server.getConfigurationManager() != null ? u.server.getConfigurationManager().playerEntityList : Collections.emptyList(); } diff --git a/src/main/java/serverutils/handlers/ServerUtilitiesClientEventHandler.java b/src/main/java/serverutils/handlers/ServerUtilitiesClientEventHandler.java index cd7c26b8f..f72436ca0 100644 --- a/src/main/java/serverutils/handlers/ServerUtilitiesClientEventHandler.java +++ b/src/main/java/serverutils/handlers/ServerUtilitiesClientEventHandler.java @@ -382,7 +382,7 @@ public NotificationWidget(IChatComponent n, FontRenderer f) { } Minecraft mc = Minecraft.getMinecraft(); - for (String s : (List) font.listFormattedStringToWidth( + for (String s : font.listFormattedStringToWidth( s0, new ScaledResolution(mc, mc.displayWidth, mc.displayHeight).getScaledWidth())) { for (String line : s.split("\n")) { diff --git a/src/main/java/serverutils/handlers/ServerUtilitiesPlayerEventHandler.java b/src/main/java/serverutils/handlers/ServerUtilitiesPlayerEventHandler.java index dcf6638bd..e277f9e68 100644 --- a/src/main/java/serverutils/handlers/ServerUtilitiesPlayerEventHandler.java +++ b/src/main/java/serverutils/handlers/ServerUtilitiesPlayerEventHandler.java @@ -1,7 +1,5 @@ package serverutils.handlers; -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; @@ -82,8 +80,7 @@ public void onPlayerLoggedIn(ForgePlayerLoggedInEvent event) { if (ServerUtilitiesConfig.chat.replace_tab_names) { new MessageUpdateTabName(player).sendToAll(); - for (EntityPlayerMP player1 : (List) player.mcServer - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player1 : player.mcServer.getConfigurationManager().playerEntityList) { if (player1 != player) { new MessageUpdateTabName(player1).sendTo(player); } diff --git a/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java b/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java index 00807ca73..966b31968 100644 --- a/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java +++ b/src/main/java/serverutils/handlers/ServerUtilitiesServerEventHandler.java @@ -1,6 +1,5 @@ package serverutils.handlers; -import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -161,8 +160,7 @@ public void onServerTick(TickEvent.ServerTickEvent event) { EntityPlayerMP playerToKickForAfk = null; // Do one at time, easier boolean afkEnabled = ServerUtilitiesConfig.afk.isEnabled(universe.server); - for (EntityPlayerMP player : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) { if (ServerUtils.isFake(player)) { continue; } @@ -185,8 +183,7 @@ public void onServerTick(TickEvent.ServerTickEvent event) { boolean isAFK = data.afkTime >= ServerUtilitiesConfig.afk.getNotificationTimer(); if (prevIsAfk != isAFK) { - for (EntityPlayerMP player1 : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player1 : universe.server.getConfigurationManager().playerEntityList) { EnumMessageLocation location = ServerUtilitiesPlayerData.get(universe.getPlayer(player1)) .getAFKMessageLocation(); diff --git a/src/main/java/serverutils/lib/client/CachedVertexData.java b/src/main/java/serverutils/lib/client/CachedVertexData.java index a1e8a59a2..7102429f7 100644 --- a/src/main/java/serverutils/lib/client/CachedVertexData.java +++ b/src/main/java/serverutils/lib/client/CachedVertexData.java @@ -106,7 +106,7 @@ private void appendTo(Tessellator tessellator) { } if (hasColor) { - tessellator.setColorRGBA(r, g, b, a);; + tessellator.setColorRGBA(r, g, b, a); } if (hasNormal) { diff --git a/src/main/java/serverutils/lib/command/CmdBase.java b/src/main/java/serverutils/lib/command/CmdBase.java index 4cb0d8ce8..65b1dd279 100644 --- a/src/main/java/serverutils/lib/command/CmdBase.java +++ b/src/main/java/serverutils/lib/command/CmdBase.java @@ -80,7 +80,6 @@ public void checkArgs(ICommandSender sender, String[] args, int i) throws Comman } @Override - @SuppressWarnings("unchecked") public List addTabCompletionOptions(ICommandSender sender, String[] args) { if (args.length == 0) { return Collections.emptyList(); @@ -101,7 +100,6 @@ public void setParent(@Nullable ICommand c) { parent = c; } - @SuppressWarnings("unchecked") public static List matchFromIterable(String[] args, Iterable possibilities) { return getListOfStringsFromIterableMatchingLastWord(args, Iterables.transform(possibilities, Object::toString)); } diff --git a/src/main/java/serverutils/lib/command/CommandTreeBase.java b/src/main/java/serverutils/lib/command/CommandTreeBase.java index c3c8e9a27..5dd5b8ddc 100644 --- a/src/main/java/serverutils/lib/command/CommandTreeBase.java +++ b/src/main/java/serverutils/lib/command/CommandTreeBase.java @@ -31,7 +31,7 @@ public void addSubcommand(ICommand command) { if (command.getCommandAliases() == null) { return; } - for (String alias : (List) command.getCommandAliases()) { + for (String alias : command.getCommandAliases()) { commandAliasMap.put(alias, command); } } diff --git a/src/main/java/serverutils/lib/data/ForgeTeam.java b/src/main/java/serverutils/lib/data/ForgeTeam.java index 6cece0c22..9f80a5980 100644 --- a/src/main/java/serverutils/lib/data/ForgeTeam.java +++ b/src/main/java/serverutils/lib/data/ForgeTeam.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.regex.Pattern; import javax.annotation.Nullable; @@ -158,7 +157,7 @@ public void deserializeNBT(NBTTagCompound nbt) { if (nbt.hasKey("Players")) { NBTTagCompound nbt1 = nbt.getCompoundTag("Players"); - for (String s : (Set) nbt1.func_150296_c()) { + for (String s : nbt1.func_150296_c()) { ForgePlayer player = universe.getPlayer(s); if (player != null) { diff --git a/src/main/java/serverutils/lib/data/ServerUtilitiesAPI.java b/src/main/java/serverutils/lib/data/ServerUtilitiesAPI.java index d07303ef4..1e55181cd 100644 --- a/src/main/java/serverutils/lib/data/ServerUtilitiesAPI.java +++ b/src/main/java/serverutils/lib/data/ServerUtilitiesAPI.java @@ -1,7 +1,6 @@ package serverutils.lib.data; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -58,8 +57,7 @@ public static void reloadServer(Universe universe, ICommandSender sender, EnumRe event.post(); - for (EntityPlayerMP player : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) { ForgePlayer p = universe.getPlayer(player); new MessageSyncData(false, player, p).sendTo(player); } @@ -67,8 +65,7 @@ public static void reloadServer(Universe universe, ICommandSender sender, EnumRe String millis = (System.currentTimeMillis() - ms) + "ms"; if (type == EnumReloadType.RELOAD_COMMAND) { - for (EntityPlayerMP player : (List) universe.server - .getConfigurationManager().playerEntityList) { + for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) { Notification notification = Notification.of(ServerUtilitiesNotifications.RELOAD_SERVER); notification.addLine(ServerUtilities.lang(player, "serverutilities.lang.reload_server", millis)); diff --git a/src/main/java/serverutils/lib/gui/ContainerBase.java b/src/main/java/serverutils/lib/gui/ContainerBase.java index d2eb24be4..b8fc7bba3 100644 --- a/src/main/java/serverutils/lib/gui/ContainerBase.java +++ b/src/main/java/serverutils/lib/gui/ContainerBase.java @@ -59,7 +59,7 @@ public ItemStack transferStackInSlot(EntityPlayer player, int index) { } ItemStack stack = InvUtils.EMPTY_STACK; - Slot slot = (Slot) inventorySlots.get(index); + Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack stack1 = slot.getStack(); diff --git a/src/main/java/serverutils/lib/gui/GuiContainerWrapper.java b/src/main/java/serverutils/lib/gui/GuiContainerWrapper.java index a1f63bc8e..ae45cfa8f 100644 --- a/src/main/java/serverutils/lib/gui/GuiContainerWrapper.java +++ b/src/main/java/serverutils/lib/gui/GuiContainerWrapper.java @@ -112,7 +112,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) { if (drawSlots) { GuiHelper.setupDrawing(); - for (Slot slot : (List) inventorySlots.inventorySlots) { + for (Slot slot : inventorySlots.inventorySlots) { theme.drawContainerSlot(guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, 16, 16); } } diff --git a/src/main/java/serverutils/lib/gui/GuiWrapper.java b/src/main/java/serverutils/lib/gui/GuiWrapper.java index c4c97d957..3c821561d 100644 --- a/src/main/java/serverutils/lib/gui/GuiWrapper.java +++ b/src/main/java/serverutils/lib/gui/GuiWrapper.java @@ -121,7 +121,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { if (object instanceof WrappedIngredient && ((WrappedIngredient) object).tooltip) { Object ingredient = WrappedIngredient.unwrap(object); - if (ingredient instanceof ItemStack && ((ItemStack) ingredient) != null) { + if (ingredient instanceof ItemStack) { renderToolTip((ItemStack) ingredient, mouseX, mouseY); } } diff --git a/src/main/java/serverutils/lib/util/DimensionType.java b/src/main/java/serverutils/lib/util/DimensionType.java index 1b51540dd..0dd786eed 100644 --- a/src/main/java/serverutils/lib/util/DimensionType.java +++ b/src/main/java/serverutils/lib/util/DimensionType.java @@ -45,7 +45,7 @@ public String getSuffix() { public WorldProvider createDimension() { try { Constructor constructor = this.clazz.getConstructor(); - return (WorldProvider) constructor.newInstance(); + return constructor.newInstance(); } catch (NoSuchMethodException var2) { throw new Error("Could not create new dimension", var2); } catch (InvocationTargetException var3) { @@ -83,7 +83,7 @@ public DimensionType setLoadSpawn(boolean value) { public static DimensionType register(String name, String suffix, int id, Class provider, boolean keepLoaded) { String enum_name = name.replace(" ", "_").toLowerCase(); - DimensionType ret = (DimensionType) EnumHelper + DimensionType ret = EnumHelper .addEnum(DimensionType.class, enum_name, ENUM_ARGS, new Object[] { id, name, suffix, provider }); return ret.setLoadSpawn(keepLoaded); } diff --git a/src/main/java/serverutils/lib/util/InvUtils.java b/src/main/java/serverutils/lib/util/InvUtils.java index 66ce68d61..da0623883 100644 --- a/src/main/java/serverutils/lib/util/InvUtils.java +++ b/src/main/java/serverutils/lib/util/InvUtils.java @@ -16,7 +16,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryBasic; -import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -199,7 +198,7 @@ public static void giveItemFromIterable(EntityPlayer player, Iterable public static void forceUpdate(Container container) { for (int i = 0; i < container.inventorySlots.size(); ++i) { - ItemStack itemstack = ((Slot) container.inventorySlots.get(i)).getStack(); + ItemStack itemstack = container.inventorySlots.get(i).getStack(); ItemStack itemstack1 = itemstack == null ? InvUtils.EMPTY_STACK : itemstack.copy(); container.inventoryItemStacks.set(i, itemstack1); diff --git a/src/main/java/serverutils/lib/util/JsonUtils.java b/src/main/java/serverutils/lib/util/JsonUtils.java index 023854a8f..251c5b601 100644 --- a/src/main/java/serverutils/lib/util/JsonUtils.java +++ b/src/main/java/serverutils/lib/util/JsonUtils.java @@ -11,9 +11,7 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.Collection; -import java.util.List; import java.util.Map; -import java.util.Set; import javax.annotation.Nullable; @@ -214,7 +212,7 @@ public static JsonElement serializeTextComponent(@Nullable IChatComponent compon if (!component.getSiblings().isEmpty()) { JsonArray array = new JsonArray(); - for (IChatComponent IChatComponent : (List) component.getSiblings()) { + for (IChatComponent IChatComponent : component.getSiblings()) { array.add(serializeTextComponent(IChatComponent)); } @@ -577,7 +575,7 @@ public static JsonElement toJson(@Nullable NBTBase nbt) { JsonObject json = new JsonObject(); if (!tagCompound.hasNoTags()) { - for (String s : (Set) tagCompound.func_150296_c()) { + for (String s : tagCompound.func_150296_c()) { json.add(s, toJson(tagCompound.getTag(s))); } } diff --git a/src/main/java/serverutils/lib/util/NBTUtils.java b/src/main/java/serverutils/lib/util/NBTUtils.java index 3816d5d20..b9df8edc6 100644 --- a/src/main/java/serverutils/lib/util/NBTUtils.java +++ b/src/main/java/serverutils/lib/util/NBTUtils.java @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; -import java.util.Set; import javax.annotation.Nullable; @@ -72,7 +71,7 @@ public static NBTTagCompound readNBT(File file) { public static void copyTags(@Nullable NBTTagCompound from, @Nullable NBTTagCompound to) { if (from != null && to != null && !from.hasNoTags()) { - for (String key : (Set) from.func_150296_c()) { + for (String key : from.func_150296_c()) { to.setTag(key, from.getTag(key)); } } @@ -86,7 +85,7 @@ public static NBTTagCompound minimize(@Nullable NBTTagCompound nbt) { NBTTagCompound nbt1 = null; - for (String key : (Set) nbt.func_150296_c()) { + for (String key : nbt.func_150296_c()) { NBTBase nbt2 = nbt.getTag(key); if (nbt2 instanceof NBTTagCompound) { @@ -156,7 +155,7 @@ private static StringBuilder getColoredNBTString(StringBuilder builder, @Nullabl boolean first = true; - for (String key : (Set) map.func_150296_c()) { + for (String key : map.func_150296_c()) { if (first) { first = false; } else { diff --git a/src/main/java/serverutils/lib/util/ServerUtils.java b/src/main/java/serverutils/lib/util/ServerUtils.java index 141c5f8cd..9ef21e491 100644 --- a/src/main/java/serverutils/lib/util/ServerUtils.java +++ b/src/main/java/serverutils/lib/util/ServerUtils.java @@ -2,7 +2,6 @@ import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.UUID; import javax.annotation.Nullable; @@ -73,7 +72,6 @@ public static boolean isVanillaClient(ICommandSender sender) { if (sender instanceof EntityPlayerMP) { NetHandlerPlayServer connection = ((EntityPlayerMP) sender).playerNetServerHandler; return connection != null && connection.netManager.channel().attr(NetworkRegistry.MOD_CONTAINER) == null; - // return connection != null; //&& !connection.netManager.channel().attr(NetworkRegistry.FML_MARKER).get(); } return false; @@ -111,7 +109,7 @@ public static boolean isOP(EntityPlayerMP player) { public static Collection getAllCommands(MinecraftServer server, ICommandSender sender) { Collection commands = new HashSet<>(); - for (ICommand c : (Collection) server.getCommandManager().getCommands().values()) { + for (ICommand c : server.getCommandManager().getCommands().values()) { if (c.canCommandSenderUseCommand(sender)) { commands.add(c); } @@ -147,7 +145,7 @@ public static SpawnType canMobSpawn(World world, int x, int y, int z) { @Nullable public static Entity getEntityByUUID(World world, UUID uuid) { - for (Entity e : (List) world.loadedEntityList) { + for (Entity e : world.loadedEntityList) { if (e.getUniqueID().equals(uuid)) { return e; } @@ -158,7 +156,7 @@ public static Entity getEntityByUUID(World world, UUID uuid) { public static void notifyChat(MinecraftServer server, @Nullable EntityPlayer player, IChatComponent component) { if (player == null) { - for (EntityPlayer player1 : (List) server.getConfigurationManager().playerEntityList) { + for (EntityPlayer player1 : server.getConfigurationManager().playerEntityList) { player1.addChatComponentMessage(component); } } else { diff --git a/src/main/java/serverutils/lib/util/text_components/ChatComponentScore.java b/src/main/java/serverutils/lib/util/text_components/ChatComponentScore.java index 6e1db27a5..65c562e46 100644 --- a/src/main/java/serverutils/lib/util/text_components/ChatComponentScore.java +++ b/src/main/java/serverutils/lib/util/text_components/ChatComponentScore.java @@ -1,7 +1,5 @@ package serverutils.lib.util.text_components; -import java.util.List; - import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentStyle; import net.minecraft.util.IChatComponent; @@ -24,7 +22,7 @@ public ChatComponentScore createCopy() { score.setValue(this.value); score.setChatStyle(this.getChatStyle().createShallowCopy()); - for (IChatComponent component : (List) this.getSiblings()) { + for (IChatComponent component : this.getSiblings()) { score.appendSibling(component.createCopy()); } return score; diff --git a/src/main/java/serverutils/lib/util/text_components/Notification.java b/src/main/java/serverutils/lib/util/text_components/Notification.java index f8c55fab9..118089cf7 100644 --- a/src/main/java/serverutils/lib/util/text_components/Notification.java +++ b/src/main/java/serverutils/lib/util/text_components/Notification.java @@ -1,7 +1,5 @@ package serverutils.lib.util.text_components; -import java.util.List; - import javax.annotation.Nullable; import net.minecraft.command.ICommandSender; @@ -50,7 +48,7 @@ public Notification(Notification n) { setChatStyle(n.getChatStyle().createShallowCopy()); - for (IChatComponent line : (List) n.getSiblings()) { + for (IChatComponent line : n.getSiblings()) { getSiblings().add(line.createCopy()); } diff --git a/src/main/java/serverutils/lib/util/text_components/TextComponentCountdown.java b/src/main/java/serverutils/lib/util/text_components/TextComponentCountdown.java index 62f9d466d..675a94012 100644 --- a/src/main/java/serverutils/lib/util/text_components/TextComponentCountdown.java +++ b/src/main/java/serverutils/lib/util/text_components/TextComponentCountdown.java @@ -1,7 +1,5 @@ package serverutils.lib.util.text_components; -import java.util.List; - import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; @@ -37,7 +35,7 @@ public TextComponentCountdown createCopy() { TextComponentCountdown component = new TextComponentCountdown(countdown); component.setChatStyle(getChatStyle().createShallowCopy()); - for (IChatComponent IChatComponent : (List) getSiblings()) { + for (IChatComponent IChatComponent : getSiblings()) { component.appendSibling(IChatComponent.createCopy()); } diff --git a/src/main/java/serverutils/net/MessageSyncData.java b/src/main/java/serverutils/net/MessageSyncData.java index ff773ec84..25c822dcf 100644 --- a/src/main/java/serverutils/net/MessageSyncData.java +++ b/src/main/java/serverutils/net/MessageSyncData.java @@ -2,7 +2,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.UUID; import net.minecraft.client.Minecraft; @@ -82,7 +81,7 @@ public void readData(DataIn data) { public void onMessage() { SidedUtils.UNIVERSE_UUID_CLIENT = universeId; - for (String key : (Set) syncData.func_150296_c()) { + for (String key : syncData.func_150296_c()) { ISyncData nbt = ServerUtilitiesCommon.SYNCED_DATA.get(key); if (nbt != null) {