These are chat archives for TheHolyWaffle/TeamSpeak-3-Java-API

14th
Jan 2017
LikeGeil
@LikeGeil
Jan 14 2017 15:42
How can i Change a Channel Name with the API?
LikeGeil
@LikeGeil
Jan 14 2017 15:44
Okay, Thanks.
Roger Baumgartner
@rogermb
Jan 14 2017 15:45
You're welcome :smile:
LikeGeil
@LikeGeil
Jan 14 2017 15:45
Thanks :+1: :smile:
But how can i use this ?
Roger Baumgartner
@rogermb
Jan 14 2017 15:47
TS3Api api = query.getApi();
api.editChannel(myChannelId, Collections.singletonMap(ChannelProperty.CHANNEL_NAME, "Super awesome name"));
The map is there because you can edit multiple properties at once
LikeGeil
@LikeGeil
Jan 14 2017 15:47
But in what Event?
Roger Baumgartner
@rogermb
Jan 14 2017 15:47
?
why would this require an event?
LikeGeil
@LikeGeil
Jan 14 2017 15:48
I will Change the Name at a Time
Roger Baumgartner
@rogermb
Jan 14 2017 15:50
... at what time? And what event does this require?
Sorry, I really can't follow you right now
LikeGeil
@LikeGeil
Jan 14 2017 15:51
I want to Change the Channel Name at 20 o'clock, But i don't know where i must use the API
Roger Baumgartner
@rogermb
Jan 14 2017 15:51
Well, that's something you have to do by yourself
Use some kind of scheduler
There's no "time has passed" event :laughing:
LikeGeil
@LikeGeil
Jan 14 2017 15:52
But Where i must use it?
.-.
Henny022
@Henny022
Jan 14 2017 15:53
that ist basic java stuff
LikeGeil
@LikeGeil
Jan 14 2017 15:53
Yes, But WHERE?
Roger Baumgartner
@rogermb
Jan 14 2017 15:53
what do you mean by WHERE?
in its own thread!
somewhere!
LikeGeil
@LikeGeil
Jan 14 2017 15:54
And in what thread?!
Henny022
@Henny022
Jan 14 2017 15:54
in your main method ore some method called by that
LikeGeil
@LikeGeil
Jan 14 2017 15:54
I use this API since today..
Roger Baumgartner
@rogermb
Jan 14 2017 15:54
@LikeGeil the thread you make that runs at whatever time you need it to run
Henny022
@Henny022
Jan 14 2017 15:54
this is no chat to teach you java
Roger Baumgartner
@rogermb
Jan 14 2017 15:55
Some basic Java knowledge is expected
Henny022
@Henny022
Jan 14 2017 15:55
your problem has nothing to do with the api ist basic java knowledge
LikeGeil
@LikeGeil
Jan 14 2017 15:55
@Henny022 i ignore you ...
Roger Baumgartner
@rogermb
Jan 14 2017 15:55
Well, I wouldn't call it "basic", but still
It's vanilla Java
LikeGeil
@LikeGeil
Jan 14 2017 15:55
hm.. okay
Roger Baumgartner
@rogermb
Jan 14 2017 15:56
Java 8 has a new Date & Time API you can use
Which probably makes some things easier, but some other things harder
LikeGeil
@LikeGeil
Jan 14 2017 15:57
doCommand is not public.
Roger Baumgartner
@rogermb
Jan 14 2017 15:57
why would you want to use doCommand now?
Have you read the readme and / or looked at any of the examples?
LikeGeil
@LikeGeil
Jan 14 2017 15:57
for editChannel?
Roger Baumgartner
@rogermb
Jan 14 2017 15:58
Are you seriously copying the "editChannel" method out of the TS3Api class?
LikeGeil
@LikeGeil
Jan 14 2017 15:58
yes xd
LikeGeil
@LikeGeil
Jan 14 2017 15:59
Thanks, But you don't Captain Picard.
Roger Baumgartner
@rogermb
Jan 14 2017 16:00

Please, first look at some kind of Java 101 tutorial. Read everything carefully. Maybe even do some examples.
Then you go and read our README file.
Then you take a look at some of the examples.
And if you still can't figure out what to do after that, you come back here.

Deal?

LikeGeil
@LikeGeil
Jan 14 2017 16:01
hm... Okay
Roger Baumgartner
@rogermb
Jan 14 2017 16:02
Thanks for your patience. I know it can be frustrating if you want to just get something done but you don't yet know how
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:02
Hey
Roger Baumgartner
@rogermb
Jan 14 2017 16:03
Heyo! :smile:
If you have a question @elrobtossohn_twitter, then just interrupt me
@Henny022 still there?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:05
Okay :)
Henny022
@Henny022
Jan 14 2017 16:05
yeah
Roger Baumgartner
@rogermb
Jan 14 2017 16:06
I've just looked into the Java8 java.time package, and it's actually pretty neat ^^

So basically you'd do

LocalDateTime now = LocalDateTime.now();
LocalDateTime timeToRun = LocalDateTime.of(LocalDate.now(), LocalTime.of(20, 0));

to get the current time and the time you'd want your thread to run

elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:09
Can i quest in the TextEvent what Rank the Player have?
Roger Baumgartner
@rogermb
Jan 14 2017 16:09
Then you could get the time between the two by using Duration
Duration durationToWait = Duration.between(now, timeToRun);
long millis = durationToWait.toMillis();
// Use millis to wait or whatever
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:11
Can i quest in the TextEvent what Rank the Player have?
@rogermb
Roger Baumgartner
@rogermb
Jan 14 2017 16:11
You can get the client ID from the TextMessageEvent
Then you can use that ID to get a ClientInfo object by calling TS3Api#getClientInfo(int clientId)
Finally, the ClientInfo contains an array of the IDs of all server groups the client is in
@elrobtossohn_twitter I saw your message. Typing takes some time :stuck_out_tongue:
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:11
Okay :D
Can you give me a Code? .-.
xD
Roger Baumgartner
@rogermb
Jan 14 2017 16:13
To get the client's ID from TextMessageEvent, use getInvokerId
To get the array of server group IDs from the ClientInfo object, use getServerGroups
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:13
kk
Henny022
@Henny022
Jan 14 2017 16:14
pretty much like the c++ <chrono> header
Roger Baumgartner
@rogermb
Jan 14 2017 16:14
For the basic functions sure does look like it
But the java version also supports some other neat things like time zones and such
And both are certainly better than what we had before ^^
stupid java.util.Date grumbl grumbl
stupid manually adding longs together grumbl grumbl
Henny022
@Henny022
Jan 14 2017 16:19
maybe that motivates me to write the clock i wanted to programm
Roger Baumgartner
@rogermb
Jan 14 2017 16:20
Just unfortunate that very few other classes support this time API
Legacy stuff like Timer and TimerTask will probably never get updated, ScheduledExecutorService also doesn't support it (yet)
Henny022
@Henny022
Jan 14 2017 16:21
im sure there will come some support
Roger Baumgartner
@rogermb
Jan 14 2017 16:22
None in Java 9
None of the JEPs mention the time package
Henny022
@Henny022
Jan 14 2017 16:23
it will take some time but im sure there comes some support
could take some years
Roger Baumgartner
@rogermb
Jan 14 2017 16:23
Just like Project Valhalla :laughing:
Maybe, maybe we'll get it with Java 10. Which looks to take at least another 4 or 5 years to be released
C#: Queue<int> :smile:
Java: Queue<Integer> :cry:
Especially for high performance stuff the overhead generated by boxing and unboxing can be quite significant. And it certainly widens the gap between languages like C, C++, Rust, etc. and Java
Henny022
@Henny022
Jan 14 2017 16:26
well Integer has more stuff than int so that not that bad
yeah java is not really a performant language
Roger Baumgartner
@rogermb
Jan 14 2017 16:29

Integer has more stuff

Not really. Instance methods give you casts like you'd do with (cast). Everything is in static methods that take int and not Integer

java is not really a performant language

It of course can't keep up with stuff like C and C++, but it can usually beat similar safe, GCd languages with ease. C# is usually a bit slower

Markdown pls, markdown why
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:41
I will send the Client a Message, and in the Console he say the ID was not found
Roger Baumgartner
@rogermb
Jan 14 2017 16:41
Are you sure you're using the correct ID? Client ID vs database ID, etc.
And are you sure that the value is not 0 or -1 by accident?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:42
Datebase ID
Roger Baumgartner
@rogermb
Jan 14 2017 16:43
Yeah, that doesn't work. You need to use the Client ID, as described in the Javadoc
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:43
And how?
Roger Baumgartner
@rogermb
Jan 14 2017 16:44
Where do you get the database ID from? Maybe that class also provides a way to get a client ID
Otherwise you need to do a lookup via TS3Api
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:44
so:
api.getDatabaseClientByUId(event.get()).getDatabaseId()
Roger Baumgartner
@rogermb
Jan 14 2017 16:44
What is event.get()?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:44
I mean this:
api.getDatabaseClientByUId(event.getInvokerUniqueId()).getDatabaseId()
Sorry :D
Roger Baumgartner
@rogermb
Jan 14 2017 16:45
event.getInvokerId() gets you the client ID
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:45
ah okay
So i must use getDatabaseClientInfo(event.getInvokerId())?
Roger Baumgartner
@rogermb
Jan 14 2017 16:46
No no no, unrelated to that
just
int clientId = event.getInvokerId(); // Gets the client ID of the client who sent the message
and you can use clientId for sendTextMessage
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 16:48
ah Okay
Thanks :D
Roger Baumgartner
@rogermb
Jan 14 2017 16:48
You're welcome :smile:
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 17:15
@rogermb How can i get the Rank from the Client?
I want to do it in a if request :D
Roger Baumgartner
@rogermb
Jan 14 2017 18:09
@elrobtossohn_twitter Sorry for the late reply, was just having dinner and watched the SpaceX launch
did you manage to get the array of server group IDs from the ClientInfo object?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 18:12
No
Roger Baumgartner
@rogermb
Jan 14 2017 18:13
Can you show me your code?
And just to make sure we're on the same page: by "rank" you mean the server group of the client, right? Stuff like "Server Admin", "Normal" or "Guest", right?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 18:18
Yes
@rogermb
Roger Baumgartner
@rogermb
Jan 14 2017 18:23

You can get the client ID from the TextMessageEvent
Then you can use that ID to get a ClientInfo object by calling TS3Api#getClientInfo(int clientId)
Finally, the ClientInfo contains an array of the IDs of all server groups the client is in

So basically, what I thought you could do was this...

int clientId = event.getInvokerId();
ClientInfo clientInfo = api.getClientInfo(clientId);
int[] serverGroupIds = clientInfo.getServerGroups();
for (int groupId : serverGroupIds) {
    if (groupId == SERVER_ADMIN_ID) doSomething();
}
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:10
┬┤Thanks.
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:29
What you mean with doSomething();? @rogermb
Roger Baumgartner
@rogermb
Jan 14 2017 19:29
I dunno, it's an example
If this if-condition is met, you're dealing with a user who's also a server admin
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:34
Also i can remove it?
Roger Baumgartner
@rogermb
Jan 14 2017 19:35
Yes, replace it with whatever you need to do
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:36
Can i do if (groupId == SERVER_ADMIN_ID) {?
Roger Baumgartner
@rogermb
Jan 14 2017 19:37
You don't need my permission or approval to code. Just do it
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:38
Okay xD
But if a Client Join and it's a Teammember how can i say the Server a Teammember is Online, Open the Support
Roger Baumgartner
@rogermb
Jan 14 2017 19:41
Combine an onClientJoin listener, an onClientMove listener, some kind of data structure (e.g. a map from client ID to channel ID), your code editor and your brain and hopefully you'll get a working program
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:42
I use it in Java this API xD
Roger Baumgartner
@rogermb
Jan 14 2017 19:42
... did I imply you didn't use Java?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:44
I use Java
Roger Baumgartner
@rogermb
Jan 14 2017 19:45
I feel inclined to use the Picard pic again
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 19:48
If you do it... :worried:
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:14
@rogermb How can i quest if a new Client comes in a Channel?
Roger Baumgartner
@rogermb
Jan 14 2017 20:14
use onClientMove
check the target channel ID in the event object
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:14
And how?
Roger Baumgartner
@rogermb
Jan 14 2017 20:16
Override onClientMove of your TS3EventAdapter click me
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:17
I have
Roger Baumgartner
@rogermb
Jan 14 2017 20:18
Then what are you having trouble with?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:18
I don't know how to Check it?
Roger Baumgartner
@rogermb
Jan 14 2017 20:19
It's really hard to help you if you keep withholding information from me. What is it you don't know how to check?
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:19
yes :D
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:41
@rogermb Is there a Methode to write to all Stuff Members there are Online there is a new Client in this Channel?
Roger Baumgartner
@rogermb
Jan 14 2017 20:42
Nope. You need to sendPrivateMessage every client individually.
elrobtossohn
@elrobtossohn_twitter
Jan 14 2017 20:55
okay