TheHolyWaffle / TeamSpeak-3-Java-API

A Java wrapper of TeamSpeak's 3 server query API.
MIT License
307 stars 107 forks source link

Cannot Resolve Symbol 'TS3ApiAsync' #34

Closed Baylem closed 9 years ago

Baylem commented 9 years ago

i'm trying to create a chat bot but I can't compile because in TS3Query I keep getting that error along with

SocketReader (com.github.theholywaffle.teamspeak3.TS3Query) in Socket Reader cannot be applied to (net.darkstar.darkbot.TS3Query)

Sorry I'm new to coding and if someone could help me, it would be much appreciated :+1:

rogermb commented 9 years ago

That sounds a lot like you're having an issue with your IDE. I can't say exactly why this is happening though.

How did you set up your dependency management? Do you have Maven set up? Did you copy the .jar file into your project directory?

Oh, or actually I know what could be wrong: Could it be that copied all the .java files from this repository into your project? That would at least explain the second error you're getting. By copying the files into a different directory, you're actually placing them in a different package, which is why no "links" between the different classes work anymore.

If that's actually the case, I'd strongly advise you to read a bit about dependency management in Java. I know how you must feel, my first programming projects were quite clunky, too. In my experience, the best way to improve your code quality is to read through and understand other Java projects. I see you're working on some Bukkit plugins. You could, for example, look through the source code of a few smaller plugins, preferably by multiple authors. See how they did it and try to adapt their style :)

What is more, there are a bunch of very good general Java tutorials on the net. Maybe these could help you, too. Most important is, however, that you just keep programming and that you always try to improve further and produce better code. That's it, hope I didn't ramble on for too long!

Baylem commented 9 years ago

My project -> http://gyazo.com/a89e7765a53c98023b41f9d4b85e95b9 The code -> http://gyazo.com/6c17f50520c7d71fa5355dd1bedf650a

I decompiled the code and added the library to my desktop and "TS3ApiAsync" isnt even in any of the folders

http://gyazo.com/4d82d5a31aeb5f8613fa5b47b0de666d

socketReader.registerCallback(c, callback); is also giving me a cannot resolve symbol error as well

rogermb commented 9 years ago

Oh my.

You're not supposed to copy any files out of that .jar file, ever. You're also not supposed to decompile anything. What you did is you added the .jar file to the project and THEN added a newer version of the same file to the project. My reaction.

The asynchronous part of the API is not yet 100% ready. You'll have to wait until we release a new version.

Steps to using the API in your library:

  1. Add the .jar file as a dependency. DO NOT add any other .java files or decompile anything
  2. IMPORT the classes you're gonna need in the file you're using them. So if you want to use the class TS3Query, add an import statement after the package statement and before the class statement. e.g. import com.github.theholywaffle.teamspeak3.TS3Query;
  3. Then you can use these imported classes in your project. Tutorial on how to use the API here.
Baylem commented 9 years ago

So one last question, I know I'm really bad at this, what do I do with the Incompatible types of teamspeak.darkbot.TS3Query and com.github.theholywaffle.teamspeak3.TS3Query

rogermb commented 9 years ago

You delete the file you created in the package teamspeak.darkbot.TS3Query. You should only have the .jar file as a dependency and no other files from this API in your project.