Hi there JGO community,
I’ve a small bug if I even can call it a bug. I am currently working on a chat-system. Not that different as the Login, disconnect, move packet. But i want to make a server that say who just connected etc. So I thaught: Just change the name to SERVER and draw it different:
GameServer:
Packet03Chat packet03 = new Packet03Chat("SERVER", ((Packet00Login)packet).getUsername() + " has connected.");
Chat (render):
for(int i = 0; i <= 11; i++){
if(chatMessages.size() - i > 0){
int colour = 555;
System.out.println(chatNames.get(chatNames.size()-i - 1));
if(chatNames.get(chatNames.size()-i - 1) == "SERVER"){
if(typingMessage){
Font.render(chatMessages.get(chatMessages.size()-i - 1), screen, 10 + screen.xOffset, 120 + screen.yOffset - i * 10, Colours.get(000, -1, -1, 324), 1);
} else {
Font.render(chatMessages.get(chatMessages.size()-i - 1), screen, 10 + screen.xOffset, 130 + screen.yOffset - i * 10, Colours.get(000, -1, -1, 324), 1);
}
}
if(typingMessage){
Font.render(chatNames.get(chatNames.size()-i - 1) + ":" + chatMessages.get(chatMessages.size()-i - 1), screen, 10 + screen.xOffset, 120 + screen.yOffset - i * 10, Colours.get(000, -1, -1, colour), 1);
} else {
Font.render(chatNames.get(chatNames.size()-i - 1) + ":" + chatMessages.get(chatMessages.size()-i - 1), screen, 10 + screen.xOffset, 130 + screen.yOffset - i * 10, Colours.get(000, -1, -1, colour), 1);
}
}
}
I thaught this would work, and even didn’t needed to think of anything other. But it didn’t worked so I did some System.out.println, and saw some “SERVER”'s had a space: "SERVER " (Which is kinda weird because in the chat it is without a space…). So I removed the last space if their were any:
if(name.lastIndexOf(" ") == name.length()){
name = name.substring(0, name.length() -1);
}
Then I debugged it again and the System.out.println was only saiying: “SERVER”. So basically it worked, but it didn’t.
Does anyone know what I am doing wrong?
Screen:
http://img826.imageshack.us/img826/6505/ke3r.png
If you want more information just ask I will give it.
Thanks for helping me and being a good community,
Sincerely with much love, RoseSlayer