TeamSpeak-3-Java-API
TeamSpeak-3-Java-API copied to clipboard
Icon ID = -1. Why?
Hey Guys! I'm trying to use this: https://github.com/TheHolyWaffle/TeamSpeak-3-Java-API/issues/192 but the IconID is "-1"
Code: for example the same as there Anyone know why?
I really don't like blindly guessing in these kinds of situations: could you please turn on communications logging and send me the console log at and just before the file transfer commands?
[18:20:33 INFO]: < [event] {}notifytextmessage targetmode=1 msg=Verify target=1 invokerid=5 invokername=devcode invokeruid=serveradmin
[18:20:33 INFO]: [{}] < {}sendtextmessageerror id=0 msg=ok
[18:20:33 INFO]: notifytextmessage
[18:20:33 INFO]: BufferedImage@806cca: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@a5245d transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 16 height = 16 #numDataElements 3 dataOff[0] = 2
[18:20:33 INFO]: [B@1915a0b
[18:20:33 INFO]: > {}ftinitupload clientftfid=0 name=\/icon_1935014271 cid=0 cpw= size=217 overwrite=0 resume=0 proto=0
[18:20:33 INFO]: [{}] < {}ftinituploadclientftfid=0 status=2050 msg=file\salready\sexists size=217
[18:20:33 INFO]: [{}] < {}ftinituploaderror id=0 msg=ok
[18:20:33 INFO]: Icon ID = -1
Edit by @rogermb: Used block code tags
[18:20:33 INFO]: [{}] < {}ftinituploadclientftfid=0 status=2050 msg=file\salready\sexists size=217
That pretty much tells you everything you need to know: The icon you're trying to upload already exists on the server, hence it is rejected :smile:
Yea i thought about that too but i took right now a new Icon and its still "[18:20:33 INFO]: [{}] < {}ftinituploadclientftfid=0 status=2050 msg=file\salready\sexists size=217" so maybe a bug?
Hmm, maybe the image is not being loaded / generated correctly and you're trying to upload the same blank image over and over again?
By the way, did you change something about the logging? Usually, those log lines shouldn't look like that. They especially shouldn't just contain empty "{}"s
Okay i just restarted the ts3server and now its working... weird bug could u tell me how i can get the icon if its already uploaded and not by the id
Okay figured out thx for your help :) <3
Sorry for asking, but how did you do it? I'm almost certain I built in a way, but I can't remember it anymore for the life of me 😛
Oh, and I'd also like to know what logging provider you're using, so we can fix whatever logging issue you're encountering!
public long getIconId(byte[] data) { final CRC32 crc32 = new CRC32(); crc32.update(data); return crc32.getValue(); }
U get the iconId if it already exist and logging isnt my problem i am just to lazy for {+...+} :D and i'm using the default Logger
So I assume you copied that code from FileTransferHelper into your own code? Because if I recall correctly, users shouldn't be able to access any instances of FileTransferHelper. I mean, that works, but it's still pretty bad API design. I might have to do something about that ^^
and i'm using the default Logger
Sorry, but which would that be? You must be using some kind of SLF4J-compatible logging framework - otherwise you wouldn't be getting any log output, at all.
No i didnt copied it in ur method uploadIconDirect: iconId = helper.getIconId(data);
Well, yes, but you can't call that method yourself in case the command fails, because you don't have (or shouldn't have) access to an instance of FileTransferHelper.
And uploadIcon and uploadIconDirect won't return the ID of the icon if the upload failed.
`public long uploadIconDirect(byte[] data) { final FileTransferHelper helper = query.getFileTransferHelper(); final long iconId; iconId = helper.getIconId(data);
final String path = "/icon_" + iconId;
if (uploadFileDirect(data, path, false, 0)) {
return iconId;
}
return iconId;
}`
u just returned -1 and not return iconId
Alright, but in that case you couldn't differentiate between a failed and a successful upload anymore 😛 There is also the situation that two icons could have the same CRC32 hash despite being different images.
well okay i dont know how u know then if it is already uploaded
Hi @rogermb, I still dont now how to use the Code, witch is given. Can you please send a complete code for the complete Theme #192 and #238 in a context. LG Paul
Hm could you maybe specify your issue in more detail, guess it's hard to help you from the given information...
@randomguy1111 Can you send me your Code, because it don´t work for. That's my Code:
else if(args[0].equalsIgnoreCase("!kopfm")) { if(!c.isServerQueryClient()) { if(c.isInServerGroup(supportmsg)) { if(args.length == 2) { try { URL url = new URL("https://minotar.net/helm/" + args[1] + "/16.png"); InputStream in = new BufferedInputStream(url.openStream()); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int i = 0; while(-1 != (i = in.read(buf))) { out.write(buf, 0 ,i); } in.close(); out.close(); byte[] response = out.toByteArray(); long iconID = Load.api.uploadIconDirect(response); String ICONID = Long.toString(iconID); Map<ChannelProperty, String> property = new HashMap<ChannelProperty, String>(); property.put(ChannelProperty.CHANNEL_ICON_ID, ICONID); Load.api.editChannel(c.getChannelId(), property); Load.api.sendPrivateMessage(c.getId(), "[color=green][B]Das Channel-Icon wurde erfolgreich geuploaded!"); property.clear(); } catch (Exception e1) { e1.printStackTrace(); } }else { Load.api.sendPrivateMessage(c.getId(), "[B]Bitte verwende '!kopfm <Name>'"); } }else { Load.api.sendPrivateMessage(c.getId(), noper); } } }