diff options
Diffstat (limited to 'common')
5 files changed, 26 insertions, 230 deletions
diff --git a/common/build.gradle b/common/build.gradle index 3aaffbf..4a48098 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,53 +1,33 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' id 'maven-publish' + id 'java' } version = project.mod_version group = project.maven_group repositories { - maven { url 'https://maven.terraformersmc.com/releases' } - maven { url "https://maven.shedaniel.me/" } - - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. + mavenCentral() + // Add repositories for your dependencies here. } + dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation 'com.terraformersmc:modmenu:8.0.0' - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modApi("me.shedaniel.cloth:cloth-config-fabric:12.0.109") { - exclude(group: "net.fabricmc.fabric-api") - } + implementation("org.apache.httpcomponents:httpclient:4.5.13") + implementation("com.google.code.gson:gson:2.10.1") + implementation("org.lwjgl:lwjgl-glfw:3.3.3") + // Add your common dependencies for Forge and any other libraries here. } processResources { - inputs.property "version", project.version - inputs.property "minecraft_version", project.minecraft_version - inputs.property "loader_version", project.loader_version - //inputs.property "discord", project.discord +// inputs.property "version", project.version +// inputs.property "loader_version", project.loader_version filteringCharset "UTF-8" - filesMatching("fabric.mod.json") { - expand "version": project.version, - "minecraft_version": project.minecraft_version, - "loader_version": project.loader_version - } } def targetJavaVersion = 17 tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. + // Ensure that the encoding is set to UTF-8. it.options.encoding = "UTF-8" if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { it.options.release = targetJavaVersion @@ -55,15 +35,13 @@ tasks.withType(JavaCompile).configureEach { } java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 def javaVersion = JavaVersion.toVersion(targetJavaVersion) if (JavaVersion.current() < javaVersion) { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } archivesBaseName = project.archives_base_name - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() } jar { @@ -76,19 +54,14 @@ jar { } } -// configure the maven publication +// Configure the maven publication if needed. publishing { publications { mavenJava(MavenPublication) { from components.java } } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. + // Add repositories for publishing here. } -}
\ No newline at end of file +} diff --git a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java index 0d5535f..91ba982 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java @@ -1,11 +1,9 @@ package de.hype.bbsentials.common.client; -import com.mojang.brigadier.arguments.StringArgumentType; import de.hype.bbsentials.common.chat.Chat; import de.hype.bbsentials.common.client.Commands.CommandsOLD; import de.hype.bbsentials.common.communication.BBsentialConnection; -import de.hype.bbsentials.fabric.BBsentialsConfigScreemFactory; -import de.hype.bbsentials.fabric.Options; +import de.hype.bbsentials.common.mclibraries.Options; import org.lwjgl.glfw.GLFW; import java.lang.reflect.InvocationTargetException; @@ -87,158 +85,6 @@ public class BBsentials { initialised = true; } } - - { - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { - dispatcher.register(ClientCommandManager.literal("bbi") - .then(ClientCommandManager.literal("reconnect") - .executes((context) -> { - connectToBBserver(); - return 1; - })) - .then(ClientCommandManager.literal("reconnect-stable-server") - .executes((context) -> { - connectToBBserver(false); - return 1; - })) - .then(ClientCommandManager.literal("reconnect-test-server") - .executes((context) -> { - connectToBBserver(true); - return 1; - })) - .then(ClientCommandManager.literal("config") - .then(ClientCommandManager.argument("category", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for config subfolder - return CommandSource.suggestMatching(new String[]{"save", "reset", "load"}, builder); - }).executes((context) -> { - String category = StringArgumentType.getString(context, "category"); - switch (category) { - case "save": - getConfig().save(); - Chat.sendPrivateMessageToSelfSuccess("Saved config successfully"); - break; - case "load": - BBsentials.config = Config.load(); - break; - case "reset": - // Reset logic here - break; - } - return 1; - })) - .then(ClientCommandManager.literal("set-value") - .then(ClientCommandManager.argument("className", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for classes - ArrayList<String> classNames = new ArrayList<>(); - classNames.add("Config"); - // Replace with your own logic to retrieve class names - return CommandSource.suggestMatching(classNames, builder); - }) - .then(ClientCommandManager.argument("variableName", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for variable names - List<String> variableNames; - variableNames = List.of(Chat.getVariableInfo("de.hype.bbsentials.client", "Config")); - return CommandSource.suggestMatching(variableNames, builder); - }) - .then(ClientCommandManager.argument("variableValue", StringArgumentType.string()) - .executes((context) -> { - // Handle "variableName" and "variableValue" logic here - String variableName = StringArgumentType.getString(context, "variableName"); - String variableValue = StringArgumentType.getString(context, "variableValue"); - try { - if (!variableName.toLowerCase().contains("dev") || config.hasBBRoles("dev")) { - Chat.setVariableValue(getConfig(), variableName, variableValue); - } - getConfig().save(); - } catch (ClassNotFoundException | - NoSuchFieldException | - IllegalAccessException | - InstantiationException | - InvocationTargetException | - NoSuchMethodException e) { - Chat.sendPrivateMessageToSelfError("Invalid variable or value"); - } - return 1; - }))))) - .then(ClientCommandManager.literal("get-value") - .then(ClientCommandManager.argument("className", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for classes - ArrayList<String> classNames = new ArrayList<>(); - classNames.add("Config"); - // Replace with your own logic to retrieve class names - return CommandSource.suggestMatching(classNames, builder); - }) - .then(ClientCommandManager.argument("variableName", StringArgumentType.string()) - .suggests((context, builder) -> { - // Provide tab-completion options for variable names - List<String> variableNames; - variableNames = List.of(Chat.getVariableInfo("de.hype.bbsentials.client", "Config")); - return CommandSource.suggestMatching(variableNames, builder); - }) - .executes((context) -> { - // Handle "variableName" and "variableValue" logic here - String variableName = StringArgumentType.getString(context, "variableName"); - try { - Chat.getVariableValue(getConfig(), variableName); - } catch (Exception e) { - e.printStackTrace(); - } - return 1; - }))).executes((context) -> { - // Handle the case when "config" argument is not provided - // ... - return 1; - }))) - ); - }); //bbi - - KeyBinding devKeyBind = new KeyBinding("Open Mod Menu Config", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_ADD, "BBsentials: Developing Tools"); - KeyBindingHelper.registerKeyBinding(devKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (devKeyBind.wasPressed()) { - MinecraftClient.getInstance().setScreen(BBsentialsConfigScreemFactory.create(MinecraftClient.getInstance().currentScreen)); - } - }); - - KeyBinding promptKeyBind = new KeyBinding("Chat Prompt Yes / Open Menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_R, "BBsentials"); - KeyBindingHelper.registerKeyBinding(promptKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (promptKeyBind.wasPressed()) { - if (config.getLastChatPromptAnswer() != null) { - if (config.isDetailedDevModeEnabled()) { - Chat.sendPrivateMessageToSelfDebug(config.getLastChatPromptAnswer()); - } - MinecraftClient.getInstance().getNetworkHandler().sendChatMessage(config.getLastChatPromptAnswer()); - } - config.setLastChatPromptAnswer(null); - } - }); - KeyBinding craftKeyBind = new KeyBinding("Craft", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, "BBsentials"); - KeyBindingHelper.registerKeyBinding(craftKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (craftKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/craft"); - }); - KeyBinding petKeyBind = new KeyBinding("Open Pet Menu", InputUtil.Type.KEYSYM, -1, "BBsentials"); - KeyBindingHelper.registerKeyBinding(petKeyBind); - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (petKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/pets"); - }); - for (int i = 1; i <= 9; i++) { - KeyBinding ecPageKeyBind = new KeyBinding("Ender Chest Page " + i, InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_1 + (i - 1), "BBsentials"); - KeyBindingHelper.registerKeyBinding(ecPageKeyBind); - int pageNum = i; // Capture the page number for lambda - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (ecPageKeyBind.wasPressed()) { - BBsentials.getConfig().sender.addImmediateSendTask("/ec " + pageNum); - } - }); - } - } // KeyBinds - public void manualLoad() { initialised = true; config = Config.load(); diff --git a/common/src/main/java/de/hype/bbsentials/common/client/Config.java b/common/src/main/java/de/hype/bbsentials/common/client/Config.java index f012c0c..ddbe890 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/Config.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/Config.java @@ -3,7 +3,6 @@ package de.hype.bbsentials.common.client; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import de.hype.bbsentials.common.chat.Sender; -import de.hype.bbsentials.fabric.MCUtils; import java.io.*; import java.time.LocalDate; diff --git a/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java b/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java index 18ef94d..9047403 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/DebugThread.java @@ -1,7 +1,5 @@ package de.hype.bbsentials.common.client; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.PlayerListEntry; import java.util.ArrayList; import java.util.List; @@ -19,34 +17,6 @@ public class DebugThread implements Runnable { } public static List<String> test() { - List<PlayerListEntry> tabList = MinecraftClient.getInstance().player.networkHandler.getPlayerList().stream().toList(); - List<PlayerListEntry> goodTabList = MinecraftClient.getInstance().player.networkHandler.getPlayerList().stream().toList(); - for (PlayerListEntry playerListEntry : tabList) { - try { - if (!playerListEntry.getProfile().getName().startsWith("!")) { - goodTabList.add(playerListEntry); - } - } catch (Exception ignored) { - - } - } - List<String> stringList = new ArrayList<>(); - for (PlayerListEntry playerListEntry : goodTabList) { - try { - String string = playerListEntry.getDisplayName().getString(); - String string2 = (string.replaceAll("\\[\\d+\\]", "")); - if (!string.isEmpty()) { - if (!string.equals(string2)) { - stringList.add(string2); - } - } - } catch (Exception ignored) { - } - } - return stringList; - } - - public static List<String> playersOnTabList() { - return test().stream().map((string) -> string.replaceAll("[^\\p{L}\\p{N}]+", "")).toList(); + return List.of(""); } } diff --git a/common/src/main/java/de/hype/bbsentials/common/mclibraries/Options.java b/common/src/main/java/de/hype/bbsentials/common/mclibraries/Options.java new file mode 100644 index 0000000..b5cb014 --- /dev/null +++ b/common/src/main/java/de/hype/bbsentials/common/mclibraries/Options.java @@ -0,0 +1,8 @@ +package de.hype.bbsentials.common.mclibraries; + +public interface Options { + void setFov(int value); + + void setGamma(double value); +} + |