This is more crappier then pali's lol, and you should make your text print out cause your server might possibly be crossing something outCreated by Codeusa palis was crap i re did it
|
|
Any IdeaS?/*
* Class PublicChat
*
* Version 1.0
*
* Sunday, August 17, 2008
*
* Created by Codeusa palis was crap i re did it
*/
package net.com.net.packethandler;
import net.com.Server;
import net.com.model.Player;
import net.com.util.Misc;
import net.com.Engine;
import net.com.content.clanchat.*;
public class PublicChat implements Packet {
/**
* Handles player chatting.
* @param p The Player which the frame should be handled for.
* @param packetId The packet id this belongs to.
* @param packetSize The amount of bytes being recieved for this packet.
*/
public void handlePacket(Player p, int packetId, int packetSize) {
if (p == null || p.stream == null) {
return;
}
p.chatTextEffects = p.stream.readUnsignedWord();
int numChars = p.stream.readUnsignedByte();
p.chatText = Misc.decryptPlayerChat(p.stream, numChars);
String chatText = Misc.decryptPlayerChat(p.stream, numChars);
Engine.fileManager.appendData("characters/logs/ChatLogs/" + p.username + ".txt", "[" + Misc.getDate() + "] " + p.username +": "+ p.chatText);
Engine.fileManager.appendData("characters/logs/ChatLogs/MasterChatLog.txt", "[" + Misc.getDate() + "] " + p.username +": " + p.chatText);
for (String s : Engine.Censor.censored) {
if (p.chatText.contains(s)) {
int length = s.length();
String replace = "";
for(int i = 0; i < length; i++) {
replace += "*";
}
p.chatText = p.chatText.replaceAll(s, replace);
}
}
if (p.muteType > 0) {
p.getActionSender().sendMessage(p, "You are muted and cannot talk.");
return;
}
if (chatText.startsWith("/")) {
if (p.clanRoom.length() > 0) {
Engine.clanChat.sendMessage(p, chatText.substring(1));
}
String[] funny = {"lol", "l0l", "LOL", "lmao", "lmfao", "rofl", "lawl"}; // More here...
for (String f : funny) {
if (p.chatText.toLowerCase().contains(f)) {
p.requestAnim(861, 1);
}
}
String[] confused = {"what?", "who?", "when?", "where?", "huh?", "what the hell?", "what are you talking about?", "wtf?"}; // More here...
for (String c : confused) {
if (p.chatText.toLowerCase().contains(c)) {
p.requestAnim(857, 1);
}
}
String[] happy = {"yay", "woot", "w00t", "hooray"}; // More here...
for (String h : happy) {
if (p.chatText.toLowerCase().contains) {
p.requestAnim(2109, 1);
}
}
if (p.chatText.equalsIgnoreCase(p.lastMsg)) {
return;
}
}
p.chatTextUpdateReq = true;
p.lastMsg = p.chatText;
p.updateReq = true;
}
}
What it does is when I type in "/" it just shows the text above the characters head instead of using it in ClanChat.
Everything else works fine besides that.
Thats the code that uses that method... Must be in wrong place?if (chatText.startsWith("/")) {
if (p.clanRoom.length() > 0) {
Engine.clanChat.sendMessage(p, chatText.substring(1));
}

Well yeah its crappy its basic for now I'll redo the class later.


Learn the java conventions...
Replace it with this, and add whatever you had from before to it.
than it should work.
Code:/* * Class PublicChat * * Version 1.0 * * Sunday, August 17, 2008 * * Created by Codeusa palis was crap i re did it */ package net.com.codeusa.net.packethandler; import net.com.codeusa.Server; import net.com.codeusa.model.Player; import net.com.codeusa.util.Misc; public class PublicChat implements Packet { /** * Handles player chatting. * @param p The Player which the frame should be handled for. * @param packetId The packet id this belongs to. * @param packetSize The amount of bytes being recieved for this packet. */ public void handlePacket(Player p, int packetId, int packetSize) { if (p == null || p.stream == null) { return; } p.chatTextEffects = p.stream.readUnsignedWord(); int numChars = p.stream.readUnsignedByte(); p.chatText = Misc.decryptPlayerChat(p.stream, numChars); if (p.muteType > 0) { p.getActionSender().sendMessage(p, "You are muted and cannot talk."); return; } if (p.chatText.startsWith("/")) { try { String chat = p.activeChat; for (Player player : Server.engine.players) { if (player != null) { if (player.activeChatOwner.equals(p.activeChatOwner)) { if (p.rights == 0 && p.donator == 0) { p.getActionSender().sendMessage(p, "You must be a donator or apart of the staff to use yell."); } else if (p.rights == 1) { player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=0>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:"); } else if (p.rights >= 2) { player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=1>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:"); } else if (p.donator == 1) { player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=2>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:"); } } } } } catch (Exception e) { return; } return; } p.chatTextUpdateReq = true; p.updateReq = true; } }
| « Is it possible... | how do you make your server work with 508/525? » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |