Skip to content

Commit

Permalink
cleanup unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed Jan 22, 2024
1 parent 74a8aca commit 5c20b9a
Show file tree
Hide file tree
Showing 30 changed files with 41 additions and 83 deletions.
2 changes: 0 additions & 2 deletions src/main/java/serverutils/ServerUtilitiesPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/AuroraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/serverutils/aurora/mc/PlayerListJson.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package serverutils.aurora.mc;

import java.util.List;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;

Expand Down Expand Up @@ -37,7 +35,7 @@ public JsonElement getJson() {

JsonArray players = new JsonArray();

for (EntityPlayerMP player : (List<EntityPlayerMP>) server.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player : server.getConfigurationManager().playerEntityList) {
JsonObject o = new JsonObject();
o.addProperty("name", player.getDisplayName());
o.addProperty("uuid", player.getUniqueID().toString());
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/serverutils/aurora/mc/PlayerListTable.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package serverutils.aurora.mc;

import java.util.List;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;

Expand Down Expand Up @@ -51,7 +49,7 @@ public boolean addBackButton() {
public void body(Tag body) {
Tag playerTable = body.table().addClass("player_table");

for (EntityPlayerMP player : (List<EntityPlayerMP>) 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");
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/serverutils/client/gui/SidebarButtonManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +32,6 @@ public enum SidebarButtonManager implements ISelectiveResourceReloadListener {
public final List<SidebarButtonGroup> groups = new ArrayList<>();

@Override
@SuppressWarnings("unchecked")
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> resourcePredicate) {
if (!resourcePredicate.test(ServerUtilitiesResourceType.SERVERUTILS_CONFIG)) {
return;
Expand All @@ -56,9 +54,9 @@ public void onResourceManagerReload(IResourceManager manager, Predicate<IResourc

Map<ResourceLocation, SidebarButtonGroup> groupMap = new HashMap<>();

for (String domain : (Set<String>) manager.getResourceDomains()) {
for (String domain : manager.getResourceDomains()) {
try {
for (IResource resource : (List<IResource>) manager
for (IResource resource : manager
.getAllResources(new ResourceLocation(domain, "sidebar_button_groups.json"))) {
JsonElement json = DataReader.get(resource).json();

Expand All @@ -85,9 +83,9 @@ public void onResourceManagerReload(IResourceManager manager, Predicate<IResourc
}
}

for (String domain : (Set<String>) manager.getResourceDomains()) {
for (String domain : manager.getResourceDomains()) {
try {
for (IResource resource : (List<IResource>) manager
for (IResource resource : manager
.getAllResources(new ResourceLocation(domain, "sidebar_buttons.json"))) {
JsonElement json = DataReader.get(resource).json();

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/serverutils/data/BlockDimPosStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -71,7 +70,7 @@ public void deserializeNBT(NBTTagCompound nbt) {
map.clear();
names.clear();

for (String name : (Set<String>) nbt.func_150296_c()) {
for (String name : nbt.func_150296_c()) {
BlockDimPos pos = BlockDimPos.fromIntArray(nbt.getIntArray(name));

if (pos != null) {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/serverutils/data/ClaimedChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,8 +121,7 @@ public void update(Universe universe, long now) {
}
}

for (EntityPlayerMP player : (List<EntityPlayerMP>) 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;
Expand Down Expand Up @@ -153,8 +151,7 @@ public void removeChunk(ChunkDimPos pos) {
markDirty();
}
if (OtherMods.isVPLoaded()) {
for (EntityPlayerMP player : (List<EntityPlayerMP>) 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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/serverutils/data/ServerUtilitiesTeamData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +100,7 @@ public void onTeamLoaded(ForgeTeamLoadedEvent event) {

NBTTagCompound claimedChunksTag = nbt.getCompoundTag("ClaimedChunks");

for (String dim : (Set<String>) 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);

Expand Down Expand Up @@ -170,7 +169,7 @@ public void deserializeNBT(NBTTagCompound nbt) {
team.markDirty();
NBTTagCompound claimedChunksTag = nbt.getCompoundTag("ClaimedChunks");

for (String dim : (Set<String>) 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityPlayerMP>) universe.server
.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) {
Notification.of(
RESTART_TIMER_ID,
StringUtils.color(
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/serverutils/events/ServerReloadEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +22,6 @@ public class ServerReloadEvent extends UniverseEvent {
private boolean clientReloadRequired;
private final Collection<EntityPlayerMP> onlinePlayers;

@SuppressWarnings("unchecked")
public ServerReloadEvent(Universe u, ICommandSender c, EnumReloadType t, ResourceLocation id,
Collection<ResourceLocation> f) {
super(u);
Expand All @@ -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<EntityPlayerMP>) u.server.getConfigurationManager().playerEntityList
onlinePlayers = u.server.getConfigurationManager() != null ? u.server.getConfigurationManager().playerEntityList
: Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public NotificationWidget(IChatComponent n, FontRenderer f) {
}

Minecraft mc = Minecraft.getMinecraft();
for (String s : (List<String>) font.listFormattedStringToWidth(
for (String s : font.listFormattedStringToWidth(
s0,
new ScaledResolution(mc, mc.displayWidth, mc.displayHeight).getScaledWidth())) {
for (String line : s.split("\n")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -82,8 +80,7 @@ public void onPlayerLoggedIn(ForgePlayerLoggedInEvent event) {
if (ServerUtilitiesConfig.chat.replace_tab_names) {
new MessageUpdateTabName(player).sendToAll();

for (EntityPlayerMP player1 : (List<EntityPlayerMP>) player.mcServer
.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player1 : player.mcServer.getConfigurationManager().playerEntityList) {
if (player1 != player) {
new MessageUpdateTabName(player1).sendTo(player);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package serverutils.handlers;

import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -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<EntityPlayerMP>) universe.server
.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) {
if (ServerUtils.isFake(player)) {
continue;
}
Expand All @@ -185,8 +183,7 @@ public void onServerTick(TickEvent.ServerTickEvent event) {
boolean isAFK = data.afkTime >= ServerUtilitiesConfig.afk.getNotificationTimer();

if (prevIsAfk != isAFK) {
for (EntityPlayerMP player1 : (List<EntityPlayerMP>) universe.server
.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player1 : universe.server.getConfigurationManager().playerEntityList) {
EnumMessageLocation location = ServerUtilitiesPlayerData.get(universe.getPlayer(player1))
.getAFKMessageLocation();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/lib/client/CachedVertexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/serverutils/lib/command/CmdBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public void checkArgs(ICommandSender sender, String[] args, int i) throws Comman
}

@Override
@SuppressWarnings("unchecked")
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) {
if (args.length == 0) {
return Collections.emptyList();
Expand All @@ -101,7 +100,6 @@ public void setParent(@Nullable ICommand c) {
parent = c;
}

@SuppressWarnings("unchecked")
public static List<String> matchFromIterable(String[] args, Iterable<?> possibilities) {
return getListOfStringsFromIterableMatchingLastWord(args, Iterables.transform(possibilities, Object::toString));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/lib/command/CommandTreeBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void addSubcommand(ICommand command) {
if (command.getCommandAliases() == null) {
return;
}
for (String alias : (List<String>) command.getCommandAliases()) {
for (String alias : command.getCommandAliases()) {
commandAliasMap.put(alias, command);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/serverutils/lib/data/ForgeTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -158,7 +157,7 @@ public void deserializeNBT(NBTTagCompound nbt) {
if (nbt.hasKey("Players")) {
NBTTagCompound nbt1 = nbt.getCompoundTag("Players");

for (String s : (Set<String>) nbt1.func_150296_c()) {
for (String s : nbt1.func_150296_c()) {
ForgePlayer player = universe.getPlayer(s);

if (player != null) {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/serverutils/lib/data/ServerUtilitiesAPI.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -58,17 +57,15 @@ public static void reloadServer(Universe universe, ICommandSender sender, EnumRe

event.post();

for (EntityPlayerMP player : (List<EntityPlayerMP>) universe.server
.getConfigurationManager().playerEntityList) {
for (EntityPlayerMP player : universe.server.getConfigurationManager().playerEntityList) {
ForgePlayer p = universe.getPlayer(player);
new MessageSyncData(false, player, p).sendTo(player);
}

String millis = (System.currentTimeMillis() - ms) + "ms";

if (type == EnumReloadType.RELOAD_COMMAND) {
for (EntityPlayerMP player : (List<EntityPlayerMP>) 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));

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/lib/gui/ContainerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/lib/gui/GuiContainerWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
if (drawSlots) {
GuiHelper.setupDrawing();

for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
for (Slot slot : inventorySlots.inventorySlots) {
theme.drawContainerSlot(guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, 16, 16);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/lib/gui/GuiWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/serverutils/lib/util/DimensionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getSuffix() {
public WorldProvider createDimension() {
try {
Constructor<? extends WorldProvider> 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) {
Expand Down Expand Up @@ -83,7 +83,7 @@ public DimensionType setLoadSpawn(boolean value) {
public static DimensionType register(String name, String suffix, int id, Class<? extends WorldProvider> 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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/serverutils/lib/util/InvUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -199,7 +198,7 @@ public static void giveItemFromIterable(EntityPlayer player, Iterable<ItemStack>

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);

Expand Down
Loading

0 comments on commit 5c20b9a

Please sign in to comment.