0

i downloaded a minecraft mod and im trying to change the code, so i decompiled the mod and changed the code but when i try to compile it in cmd i get this error error: package com.google.gson does not exist import com.google.gson.Gson; for mutliple packages i tried using javac -classpath [Gson jar file path] filename.java

but still getting the error

the mod's directory https://i.stack.imgur.com/Dx8OM.png

i tried --module-path -classpath both didnt work

the full code:

package de.torui.coflsky.minecraft_integration;

import com.google.gson.Gson;

import com.google.gson.GsonBuilder;

import com.google.gson.TypeAdapter;

import com.google.gson.stream.JsonReader;

import com.google.gson.stream.JsonWriter;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.time.Duration;

import java.time.ZonedDateTime;

import java.util.HashMap;

import java.util.Map;

import java.util.UUID;

import java.util.stream.Collectors;

import net.minecraftforge.fml.common.Loader;

public class CoflSessionManager {

public static Gson gson = (new GsonBuilder()).registerTypeAdapter(ZonedDateTime.class, new TypeAdapter<ZonedDateTime>() {

public void write(JsonWriter out, ZonedDateTime value) throws IOException {

out.value(value.toString());

}

public ZonedDateTime read(JsonReader in) throws IOException {

return ZonedDateTime.parse(in.nextString());

}

}).enableComplexMapKeySerialization().create();

public static class CoflSession {

public String SessionUUID;

public ZonedDateTime timestampCreated;

public CoflSession() {}

public CoflSession(String sessionUUID, ZonedDateTime timestampCreated) {

this.SessionUUID = sessionUUID;

this.timestampCreated = timestampCreated;

}

}

public static void UpdateCoflSessions() throws IOException {

Map<String, CoflSession> sessions = GetCoflSessions();

for (String username : sessions.keySet()) {

if (!isValidSession(sessions.get(username)))

DeleteCoflSession(username);

}

}

public static Path GetTempFileFolder() {

Path dataPath = Paths.get(Loader.instance().getConfigDir().getPath(), new String[] { "CoflSky", "sessions" });

dataPath.toFile().mkdirs();

return dataPath;

}

public static Map<String, CoflSession> GetCoflSessions() throws IOException {

File[] sessions = GetTempFileFolder().toFile().listFiles();

Map<String, CoflSession> map = new HashMap<>();

for (int i = 0; i < sessions.length; i++)

map.put(sessions[i].getName(), GetCoflSession(sessions[i].getName()));

return map;

}

public static boolean isValidSession(CoflSession session) {

if (session.timestampCreated.plus

(Duration.ofDays(1800000L)).isAfter(ZonedDateTime.now
()))

return true;

return false;

}

private static Path GetUserPath(String username) {

return Paths.get(GetTempFileFolder().toString() + "/" + username, new String[0]);

}

public static void DeleteCoflSession(String username) {

Path path = GetUserPath(username);

}

public static void DeleteAllCoflSessions() {

Path path = GetTempFileFolder();

File[] sessions = path.toFile().listFiles();

for (File f : sessions)

f.delete();

}

public static CoflSession GetCoflSession(String username) throws IOException {

Path path = GetUserPath(username);

File file = path.toFile();

if (!file.exists()) {

CoflSession coflSession = new CoflSession(UUID.randomUUID().toString(), ZonedDateTime.now

());

OverwriteCoflSession(username, coflSession);

return coflSession;

}

BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

String raw = reader.lines().collect(Collectors.joining("\n"));

reader.close();

CoflSession session = (CoflSession)gson.fromJson(raw, CoflSession.class);

return session;

}

public static boolean OverwriteCoflSession(String username, CoflSession session) throws IOException {

Path path = GetUserPath(username);

File file = path.toFile();

file.createNewFile();

String data = gson.toJson(session);

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));

bw.append(data);

bw.flush();

bw.close();

return true;

}

}

full cmd error:

javac -classpath C:\Users\peleg\Desktop\test\META-INF\maven\com.neovisionaries\nv-websocket-client CoflSessionManager.java

CoflSessionManager.java:3

: error: package com.google.gson does not exist

import com.google.gson.Gson;

^

CoflSessionManager.java:4

: error: package com.google.gson does not exist

import com.google.gson.GsonBuilder;

^

CoflSessionManager.java:5

: error: package com.google.gson does not exist

import com.google.gson.TypeAdapter;

^

CoflSessionManager.java:6

: error: package com.google.gson.stream
 does not exist

import com.google.gson.stream.JsonReader;

^

CoflSessionManager.java:7

: error: package com.google.gson.stream
 does not exist

import com.google.gson.stream.JsonWriter;

^

CoflSessionManager.java:24

: error: package net.minecraftforge.fml.common does not exist

import net.minecraftforge.fml.common.Loader;

^

CoflSessionManager.java:27

: error: cannot find symbol

public static Gson gson = (new GsonBuilder()).registerTypeAdapter(ZonedDateTime.class, new TypeAdapter<ZonedDateTime>() {

^

symbol: class Gson

location: class CoflSessionManager

CoflSessionManager.java:27

: error: cannot find symbol

public static Gson gson = (new GsonBuilder()).registerTypeAdapter(ZonedDateTime.class, new TypeAdapter<ZonedDateTime>() {

^

symbol: class TypeAdapter

location: class CoflSessionManager

CoflSessionManager.java:28

: error: cannot find symbol

public void write(JsonWriter out, ZonedDateTime value) throws IOException {

^

symbol: class JsonWriter

CoflSessionManager.java:32

: error: cannot find symbol

public ZonedDateTime read(JsonReader in) throws IOException {

^

symbol: class JsonReader

CoflSessionManager.java:27

: error: cannot find symbol

public static Gson gson = (new GsonBuilder()).registerTypeAdapter(ZonedDateTime.class, new TypeAdapter<ZonedDateTime>() {

^

symbol: class GsonBuilder

location: class CoflSessionManager

CoflSessionManager.java:59

: error: cannot find symbol

Path dataPath = Paths.get(Loader.instance().getConfigDir().getPath(), new String[] { "CoflSky", "sessions" });

^

symbol: variable Loader

location: class CoflSessionManager

12 errors

this is the error i get when i try --module-path [Gson jar file path] filename.java

:

javac --module-path C:\Users\peleg\Downloads\jar_files CoflSessionManager.java

CoflSessionManager.java:3

: error: package com.google.gson is not visible

import com.google.gson.Gson;

^

(package com.google.gson is declared in module com.google.gson, which is not in the module graph)

CoflSessionManager.java:4

: error: package com.google.gson is not visible

import com.google.gson.GsonBuilder;

^

(package com.google.gson is declared in module com.google.gson, which is not in the module graph)

CoflSessionManager.java:5

: error: package com.google.gson is not visible

import com.google.gson.TypeAdapter;

^

(package com.google.gson is declared in module com.google.gson, which is not in the module graph)

CoflSessionManager.java:6

: error: package com.google.gson.stream
 is not visible

import com.google.gson.stream.JsonReader;

^

(package com.google.gson.stream

is declared in module com.google.gson, which is not in the module graph)

CoflSessionManager.java:7

: error: package com.google.gson.stream
 is not visible

import com.google.gson.stream.JsonWriter;

^

(package com.google.gson.stream

is declared in module com.google.gson, which is not in the module graph)

CoflSessionManager.java:24

: error: package net.minecraftforge.fml.common does not exist

import net.minecraftforge.fml.common.Loader;

^

CoflSessionManager.java:59

: error: cannot find symbol

Path dataPath = Paths.get(Loader.instance().getConfigDir().getPath(), new String[] { "CoflSky", "sessions" });

^

symbol: variable Loader

location: class CoflSessionManager

7 errors

pom.xml:

project xmlns="http://maven.apache.org/POM/4.0.0

" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd
">

<modelVersion>4.0.0</modelVersion>

<groupId>com.neovisionaries</groupId>

<artifactId>nv-websocket-client</artifactId>

<version>2.14</version>

<packaging>bundle</packaging>

<name>${project.groupId}:${project.artifactId}</name>

<description>WebSocket client implementation in Java.</description>

<url>https://github.com/TakahikoKawasaki/nv-websocket-client

</url>

<licenses>

<license>

<name>The Apache Software License, Version 2.0</name>

<url>http://www.apache.org/licenses/LICENSE-2.0.txt

</url>

</license>

</licenses>

<developers>

<developer>

<name>Takahiko Kawasaki</name>

</developer>

</developers>

<scm>

<connection>scm:git:git@github.com:TakahikoKawasaki/nv-websocket-client.git</connection>

<developerConnection>scm:git:git@github.com:TakahikoKawasaki/nv-websocket-client.git</developerConnection>

<url>git@github.com:TakahikoKawasaki/nv-websocket-client.git</url>

<tag>nv-websocket-client-2.14</tag>

</scm>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<distributionManagement>

<snapshotRepository>

<id>darutk</id>

<url>https://oss.sonatype.org/content/repositories/snapshots

</url>

</snapshotRepository>

<repository>

<id>darutk</id>

<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/

</url>

</repository>

</distributionManagement>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.13.1</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>com.google.code.gson</groupId>

<artifactId>gson</artifactId>

<version>2.8.5</version>

<scope>provided</scope>

</dependency>

</dependencies>

<profiles>

<profile>

<id>doclint</id>

<activation>

<jdk>[1.8,)</jdk>

</activation>

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-javadoc-plugin</artifactId>

<configuration>

<additionalparam>-Xdoclint:-html</additionalparam>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-site-plugin</artifactId>

<configuration>

<reportPlugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-javadoc-plugin</artifactId>

<configuration>

<additionalparam>-Xdoclint:-html</additionalparam>

</configuration>

</plugin>

</reportPlugins>

</configuration>

</plugin>

</plugins>

</build>

</profile>

</profiles>

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.2</version>

<configuration>

<source>1.5</source>

<target>1.5</target>

<fork>true</fork>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-source-plugin</artifactId>

<version>2.3</version>

<executions>

<execution>

<id>attach-sources</id>

<goals>

<goal>jar-no-fork</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-javadoc-plugin</artifactId>

<version>2.10.1</version>

<configuration>

<additionalJOption>-J-Duser.language=en</additionalJOption>

</configuration>

<executions>

<execution>

<id>attach-javadocs</id>

<goals>

<goal>jar</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-jar-plugin</artifactId>

<version>2.5</version>

<configuration>

<archive>

<manifestEntries>

<Built-By>Neo Visionaries Inc.</Built-By>

</manifestEntries>

</archive>

</configuration>

</plugin>

<plugin>

<groupId>org.sonatype.plugins</groupId>

<artifactId>nexus-staging-maven-plugin</artifactId>

<version>1.6.4</version>

<extensions>true</extensions>

<configuration>

<serverId>darutk</serverId>

<nexusUrl>https://oss.sonatype.org/

</nexusUrl>

<autoReleaseAfterClose>true</autoReleaseAfterClose>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-release-plugin</artifactId>

<version>2.5.1</version>

<configuration>

<autoVersionSubmodules>true</autoVersionSubmodules>

<useReleaseProfile>false</useReleaseProfile>

<releaseProfiles>release</releaseProfiles>

<goals>deploy</goals>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-gpg-plugin</artifactId>

<version>1.5</version>

<executions>

<execution>

<id>sign-artifacts</id>

<phase>verify</phase>

<goals>

<goal>sign</goal>

</goals>

<configuration>

<keyname>E3F58E5C</keyname>

</configuration>

</execution>

</executions>

</plugin>

<plugin>

<groupId>org.apache.felix</groupId>

<artifactId>maven-bundle-plugin</artifactId>

<version>2.5.3</version>

<extensions>true</extensions>

<configuration>

<instructions>

<Bundle-SymbolicName>${project.groupId}.ws.client</Bundle-SymbolicName>

</instructions>

</configuration>

</plugin>

</plugins>

</build>

</project>

the mod:

https://www.mediafire.com/file/ca73tnwv7qxdh2i/test.jar/file

if you need any other information ask and ill write itenter code here

askaine_
  • 1
  • 1
  • The code for the mod including the build script seems to be on GitHub: https://github.com/Coflnet/SkyblockMod (please verify yourself though that this is really the correct code); can't you just use that? – Marcono1234 Mar 18 '23 at 23:41
  • Use that how? And where is the build script? – askaine_ Mar 19 '23 at 05:02
  • can you explain how to use the build script? – askaine_ Mar 19 '23 at 13:52
  • If you already have a pom.xml, you need to use maven to build. Install Maven if you haven't yet, and run `mvn build` or such. Check a Maven tutorial for details. – Robert Mar 19 '23 at 16:13
  • but im not trying to build im trying to compile a java file – askaine_ Mar 19 '23 at 16:53
  • i used mvn compile but same error because when i creat a new project in intellij IDEA i copy the txt from the pom.xml file of the mod to a new pom.xml file in the project and i get a lot of errors that the things in the pom.xml file like plugins and dependencies dont exist the pom.xml file in the project is the same as i wrote in the question – askaine_ Mar 19 '23 at 19:22
  • i was able to fix everything except the net.minecraftforge.fml.common.Loader; and from what i understood it is in the build.gradle file so i added it to the project and still says that the package doesnt exist – askaine_ Mar 19 '23 at 20:03
  • For the GitHub repository above (assuming this is really the legit repository), you need to clone it (or download as ZIP) and then probably run `./gradlew build`. But your question is more about how to use Maven / Gradle, respectively getting started with developing Minecraft mods. – Marcono1234 Mar 19 '23 at 21:51
  • i get this error when i do gradlew build * What went wrong: Script compilation error: Line 48: forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") ^ Unresolved reference: forge – askaine_ Mar 20 '23 at 12:40
  • do you know how to fix this? – askaine_ Mar 20 '23 at 13:29
  • i fixed it the gradlew build was successful but still error of net.minecraftforge.fml.common.Loader; does not exist – askaine_ Mar 20 '23 at 14:00
  • Does this answer your question? [Why does IntelliJ give me "Package doesn't exist" error?](https://stackoverflow.com/questions/20137020/why-does-intellij-give-me-package-doesnt-exist-error) – Elikill58 Apr 12 '23 at 14:56

0 Answers0