Skip to content

Commit

Permalink
Remove update check & dont let create version be inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Nov 4, 2024
1 parent 636e20a commit cb5cca2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import dev.ithundxr.createnumismatics.registry.NumismaticsCommands;
import dev.ithundxr.createnumismatics.registry.NumismaticsCreativeModeTabs.Tabs;
import dev.ithundxr.createnumismatics.registry.NumismaticsPackets;
import dev.ithundxr.createnumismatics.util.NumismaticsUpdateCheck;
import dev.ithundxr.createnumismatics.util.MethodVarHandleUtils;
import dev.ithundxr.createnumismatics.util.Utils;
import net.minecraft.SharedConstants;
import net.minecraft.commands.CommandSourceStack;
Expand All @@ -65,8 +65,8 @@ public class Numismatics {
}

public static void init() {
String createVersion = MethodVarHandleUtils.getStaticField(Create.class, "VERSION", String.class, "UNKNOWN");
LOGGER.info("{} v{} initializing! Commit hash: {} Create version: {} on platform: {}", NAME, NumismaticsBuildInfo.VERSION, NumismaticsBuildInfo.GIT_COMMIT, Create.VERSION, Loader.getFormatted());
NumismaticsUpdateCheck.execute();

ModSetup.register();
finalizeRegistrate();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Numismatics
* Copyright (c) 2024 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.ithundxr.createnumismatics.util;

import java.lang.invoke.MethodHandles;

@SuppressWarnings("unchecked")
public class MethodVarHandleUtils {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();

public static <T> T getStaticField(Class<?> clazz, String fieldName, Class<T> type) throws NoSuchFieldException, IllegalAccessException {
return (T) lookup.findStaticVarHandle(clazz, fieldName, type).get();
}

public static <T> T getStaticField(Class<?> clazz, String fieldName, Class<T> type, T defaultValue) {
T returnValue = defaultValue;

try {
returnValue = getStaticField(clazz, fieldName, type);
} catch (NoSuchFieldException | IllegalAccessException ignored) {}

return returnValue;
}
}

This file was deleted.

0 comments on commit cb5cca2

Please sign in to comment.