Jump to content

Recommended Posts

Posted

I am moving over to forge from spigot for a while to see how it works differently and stuff. I am trying to make a mod that connects to a MySQL database and adds a name when a command is run, then when someone with that username in the database joins a server you are in or you join a server they are in a little thingy appears in the corner for a few seconds to let you know they are in your server. Its mainly made to add hackers to the database then let you know when you join a server with them so you can leave :P

 

I just have a few questions.

When I run the project in eclipse, and do /hacker add <username> which adds the username to the database it works just fine. But then when I build the mod and open it in actual Minecraft, and try and add a username to the database it gives me this error.

[15:48:13] [Client thread/INFO]: [com.billehbawb.hackerdetect.Main:getConnection:73]: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I have looked up a lot about this error and I have come to the conclusion that I have to add the sql connector jar to my classpath in my jvm arguments, but I don't know how. Help on that would be appreciated.

 

My next problem is that something simply doesn't work.

 
 
That is my PlayerJoin class. What it is SUPPOSED to do is get when a player joins, check if they are in the database and then if they are add them to inNotify for 10 seconds. Now I know there are 2 things you are thinking right now. First off, what does inNotify do? We will get to that in a second. Also, I call Main.getUsernames(). So while we are on it, here is all my SQL stuff in my main class.
 
Ok, and then this is my render image thingy.
Basically it checks if the person is in inNotify and then displays the message to them. I have tested the message without checking if they are innotify, and it works but it displays all the time so having it check if the player is in the list is the best I could think of.
 
Anyways I know this may have been not very descriptive, and a lot of people are about to hate me but I would really prefer if instead of giving me a vauge answer I would much rather have actual code I can look at. Thanks.
Posted

Just a reminder: The SQL stuff DOES work while I am testing it in eclipse. It is only after I export it to a jar and try and run it with my normal client it gives me the error. I also have added the MySQL thing to my dependencies, to no avail. Neither of these have been solved yet. I am going to sleep now, so don't expect replies for a while if you post here. Thanks!

Posted

You need to shade the MySQL connector into your JAR using the Gradle Shadow plugin.

 

You can see how I shade a dependency in my mod here.

 

Make sure you relocate the MySQL connector's packages when shading to avoid conflicts with other mods. This will automatically use the new package names in your code, but not in strings (e.g. the string you pass to Class.forName).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
11 hours ago, Choonster said:

You need to shade the MySQL connector into your JAR using the Gradle Shadow plugin.

 

You can see how I shade a dependency in my mod here.

 

Make sure you relocate the MySQL connector's packages when shading to avoid conflicts with other mods. This will automatically use the new package names in your code, but not in strings (e.g. the string you pass to Class.forName).

How do I use it?

Posted
11 hours ago, BillehBawb said:

How do I use it?

 

Read the documentation or look at my example.

 

If you've actually tried to use it and it's not working, post your code and the error message(s).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.