Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for disappearing sidebar buttons #30

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ developmentEnvironmentUserName = Developer
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true

# Define a source file of your project with:
# Enables injecting missing generics into the decompiled source code for a better coding experience
# Turns most publicly visible List, Map, etc. into proper List<Type>, Map<K, V> 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.
generateGradleTokenClass = serverutils.Tags
gradleTokenVersion = GRADLETOKEN_VERSION
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = ServerUtilities.java
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/ServerUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ServerUtilities {

public static final String MOD_ID = "serverutilities";
public static final String MOD_NAME = "Server Utilities";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String VERSION = Tags.GRADLETOKEN_VERSION;
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
public static final String SERVER_FOLDER = MOD_ID + "/server/";

Expand Down
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
2 changes: 1 addition & 1 deletion src/main/java/serverutils/command/CmdLeaderboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CmdLeaderboard() {
@Override
public List<String> 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);
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 @@ -61,6 +61,7 @@
import serverutils.lib.math.Ticks;
import serverutils.lib.util.InvUtils;
import serverutils.lib.util.NBTUtils;
import serverutils.lib.util.SidedUtils;
import serverutils.lib.util.StringUtils;
import serverutils.lib.util.text_components.Notification;
import serverutils.net.MessageAdminPanelGui;
Expand Down Expand Up @@ -102,11 +103,17 @@ public static void setBadge(UUID id, String url) {
public void onClientDisconnected(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
BADGE_CACHE.clear();
shutdownTime = 0L;
SidedUtils.SERVER_MODS.clear();
if (OtherMods.isVPLoaded()) {
VPIntegration.CLAIMS.clear();
}
}

@SubscribeEvent
public void onClientConnected(FMLNetworkEvent.ClientConnectedToServerEvent event) {
SidedUtils.SERVER_MODS.putAll(SidedUtils.SERVER_MODS_0);
}

@SubscribeEvent
public void onClientWorldTick(TickEvent.ClientTickEvent event) {
Minecraft mc = Minecraft.getMinecraft();
Expand Down Expand Up @@ -375,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,9 +1,9 @@
package serverutils.handlers;

import java.util.List;
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;
Expand Down Expand Up @@ -160,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 @@ -184,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 Expand Up @@ -260,9 +258,11 @@ public void onWorldTick(TickEvent.WorldTickEvent event) {
}

if (ServerUtilitiesConfig.world.show_playtime && event.world.getTotalWorldTime() % 20L == 7L) {
for (EntityPlayerMP player : (List<EntityPlayerMP>) 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);
}
}
}
}
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
Loading