mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Plugins can now create friend list entries - See Arcturus Extended for examples
This commit is contained in:
parent
2b19bdd0d6
commit
4fb9cd8d5c
@ -49,9 +49,6 @@ public final class Emulator
|
||||
|
||||
public static String build = "";
|
||||
|
||||
|
||||
public static MessengerBuddy publicChatBuddy;
|
||||
|
||||
public static boolean isReady = false;
|
||||
|
||||
public static boolean isShuttingDown = false;
|
||||
@ -100,7 +97,6 @@ public final class Emulator
|
||||
Emulator.getLogging().logStart("\r" + Emulator.logo +
|
||||
" Build: " + build + "\n");
|
||||
random = new Random();
|
||||
publicChatBuddy = new MessengerBuddy(-1, "Staff Chat", "", (short) 0, 0);
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
Emulator.runtime = Runtime.getRuntime();
|
||||
|
@ -124,6 +124,11 @@ public class Messenger
|
||||
this.friends.remove(habbo.getHabboInfo().getId());
|
||||
}
|
||||
|
||||
public void addBuddy(MessengerBuddy buddy)
|
||||
{
|
||||
this.friends.put(buddy.getId(), buddy);
|
||||
}
|
||||
|
||||
public static void unfriend(int userOne, int userTwo)
|
||||
{
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendships WHERE (user_one_id = ? AND user_two_id = ?) OR (user_one_id = ? AND user_two_id = ?)"))
|
||||
|
@ -1,15 +1,19 @@
|
||||
package com.eu.habbo.habbohotel.messenger;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.messages.ISerialize;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MessengerBuddy implements Runnable {
|
||||
public class MessengerBuddy implements Runnable, ISerialize {
|
||||
|
||||
private int id;
|
||||
private String username;
|
||||
@ -176,4 +180,39 @@ public class MessengerBuddy implements Runnable {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onMessageReceived(Habbo from, String message) {
|
||||
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(this.id);
|
||||
|
||||
if(habbo == null)
|
||||
return;
|
||||
|
||||
Message chatMessage = new Message(from.getHabboInfo().getId(), this.id, message);
|
||||
Emulator.getThreading().run(chatMessage);
|
||||
|
||||
if (WordFilter.ENABLED_FRIENDCHAT)
|
||||
{
|
||||
chatMessage.setMessage(Emulator.getGameEnvironment().getWordFilter().filter(chatMessage.getMessage(), from));
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new FriendChatMessageComposer(chatMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ServerMessage message) {
|
||||
message.appendInt(this.id);
|
||||
message.appendString(this.username);
|
||||
message.appendInt(this.gender.equals(HabboGender.M) ? 0 : 1);
|
||||
message.appendBoolean(this.online == 1);
|
||||
message.appendBoolean(this.inRoom); //IN ROOM
|
||||
message.appendString(this.look);
|
||||
message.appendInt(0);
|
||||
message.appendString(this.motto);
|
||||
message.appendString("");
|
||||
message.appendString("");
|
||||
message.appendBoolean(false); //Offline messaging.
|
||||
message.appendBoolean(false);
|
||||
message.appendBoolean(false);
|
||||
message.appendShort(this.relation);
|
||||
}
|
||||
}
|
||||
|
@ -30,40 +30,14 @@ public class FriendPrivateMessageEvent extends MessageHandler
|
||||
}
|
||||
this.client.getHabbo().getHabboStats().lastChat = millis;
|
||||
|
||||
if(userId == Emulator.publicChatBuddy.getId())
|
||||
{
|
||||
if(message.startsWith(":"))
|
||||
{
|
||||
CommandHandler.handleCommand(this.client, message);
|
||||
return;
|
||||
}
|
||||
Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new FriendChatMessageComposer(new Message(this.client.getHabbo().getHabboInfo().getId(), -1, message)).compose(), "acc_staff_chat", this.client);
|
||||
return;
|
||||
}
|
||||
|
||||
MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(userId);
|
||||
if (buddy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UserFriendChatEvent event = new UserFriendChatEvent(this.client.getHabbo(), buddy, message);
|
||||
if(Emulator.getPluginManager().fireEvent(event).isCancelled())
|
||||
return;
|
||||
|
||||
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(userId);
|
||||
|
||||
if(habbo == null)
|
||||
return;
|
||||
|
||||
Message chatMessage = new Message(this.client.getHabbo().getHabboInfo().getId(), userId, event.message);
|
||||
Emulator.getThreading().run(chatMessage);
|
||||
|
||||
if (WordFilter.ENABLED_FRIENDCHAT)
|
||||
{
|
||||
chatMessage.setMessage(Emulator.getGameEnvironment().getWordFilter().filter(chatMessage.getMessage(), this.client.getHabbo()));
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new FriendChatMessageComposer(chatMessage));
|
||||
buddy.onMessageReceived(this.client.getHabbo(), message);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class FriendsComposer extends MessageComposer
|
||||
//this.response.appendInt(3); //Club level
|
||||
this.response.appendInt(this.habbo.hasPermission("acc_infinite_friends") ? Integer.MAX_VALUE : Messenger.MAXIMUM_FRIENDS);
|
||||
this.response.appendInt(this.habbo.hasPermission("acc_infinite_friends") ? Integer.MAX_VALUE : Messenger.MAXIMUM_FRIENDS);
|
||||
this.response.appendInt(this.habbo.getMessenger().getFriends().size() + (this.habbo.hasPermission("acc_staff_chat") ? 1 : 0));
|
||||
this.response.appendInt(this.habbo.getMessenger().getFriends().size()/* + (this.habbo.hasPermission("acc_staff_chat") ? 1 : 0)*/);
|
||||
|
||||
for (Map.Entry<Integer, MessengerBuddy> row : this.habbo.getMessenger().getFriends().entrySet()) {
|
||||
this.response.appendInt(row.getKey());
|
||||
@ -51,7 +51,7 @@ public class FriendsComposer extends MessageComposer
|
||||
this.response.appendShort(row.getValue().getRelation());
|
||||
}
|
||||
|
||||
if(this.habbo.hasPermission("acc_staff_chat"))
|
||||
/*if(this.habbo.hasPermission("acc_staff_chat"))
|
||||
{
|
||||
this.response.appendInt(-1);
|
||||
this.response.appendString("Staff Chat");
|
||||
@ -67,7 +67,8 @@ public class FriendsComposer extends MessageComposer
|
||||
this.response.appendBoolean(false);
|
||||
this.response.appendBoolean(false);
|
||||
this.response.appendShort(0);
|
||||
}
|
||||
}*/
|
||||
|
||||
return this.response;
|
||||
}
|
||||
catch(Exception e)
|
||||
|
Loading…
Reference in New Issue
Block a user