mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Merge branch 'add-userip-event' into 'dev'
Added plugin event for getting user ip See merge request morningstar/Arcturus-Community!373
This commit is contained in:
commit
d8fbc3d0c3
@ -45,7 +45,7 @@ public class UserInfoCommand extends Command {
|
|||||||
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") +
|
||||||
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
||||||
|
|
||||||
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
||||||
|
@ -505,6 +505,7 @@ public class ModToolManager {
|
|||||||
return ban;
|
return ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean hasIPBan(Channel habbo) {
|
public boolean hasIPBan(Channel habbo) {
|
||||||
if (habbo == null)
|
if (habbo == null)
|
||||||
return false;
|
return false;
|
||||||
@ -512,9 +513,13 @@ public class ModToolManager {
|
|||||||
if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null)
|
if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
return this.hasIPBan(((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasIPBan(String ipAddress) {
|
||||||
boolean banned = false;
|
boolean banned = false;
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) {
|
||||||
statement.setString(1, ((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress());
|
statement.setString(1, ipAddress);
|
||||||
statement.setInt(2, Emulator.getIntUnixTimestamp());
|
statement.setInt(2, Emulator.getIntUnixTimestamp());
|
||||||
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
@ -525,7 +530,6 @@ public class ModToolManager {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Caught SQL exception", e);
|
LOGGER.error("Caught SQL exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return banned;
|
return banned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,10 @@ import com.eu.habbo.messages.outgoing.rooms.FloodCounterComposer;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
||||||
import com.eu.habbo.messages.outgoing.users.*;
|
import com.eu.habbo.messages.outgoing.users.*;
|
||||||
|
import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
||||||
|
import com.eu.habbo.plugin.events.users.UserGetIPAddressEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
||||||
import gnu.trove.TIntCollection;
|
import gnu.trove.TIntCollection;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
@ -114,11 +116,31 @@ public class Habbo implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void connect() {
|
public boolean connect() {
|
||||||
|
String ip = "";
|
||||||
|
|
||||||
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
|
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
|
||||||
SocketAddress address = this.client.getChannel().remoteAddress();
|
SocketAddress address = this.client.getChannel().remoteAddress();
|
||||||
|
ip = ((InetSocketAddress) address).getAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress());
|
if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) {
|
||||||
|
UserGetIPAddressEvent event = Emulator.getPluginManager().fireEvent(new UserGetIPAddressEvent(this, ip));
|
||||||
|
if (event.hasChangedIP()) {
|
||||||
|
ip = event.getUpdatedIp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
this.habboInfo.setIpLogin(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.habboInfo.getIpLogin())) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.habboInfo.setMachineID(this.client.getMachineId());
|
this.habboInfo.setMachineID(this.client.getMachineId());
|
||||||
@ -128,6 +150,7 @@ public class Habbo implements Runnable {
|
|||||||
|
|
||||||
Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this);
|
Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this);
|
||||||
LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin());
|
LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class HabboManager {
|
|||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) {
|
||||||
statement.setString(1, habbo.getHabboInfo().getIpRegister());
|
statement.setString(1, habbo.getHabboInfo().getIpRegister());
|
||||||
statement.setString(2, habbo.getClient().getChannel().remoteAddress().toString());
|
statement.setString(2, habbo.getHabboInfo().getIpLogin());
|
||||||
statement.setInt(3, habbo.getHabboInfo().getId());
|
statement.setInt(3, habbo.getHabboInfo().getId());
|
||||||
statement.setInt(4, limit);
|
statement.setInt(4, limit);
|
||||||
|
|
||||||
|
@ -77,19 +77,13 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
if (this.client.getHabbo() == null) {
|
if (this.client.getHabbo() == null) {
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) {
|
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.client.getChannel())) {
|
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
habbo.setClient(this.client);
|
habbo.setClient(this.client);
|
||||||
this.client.setHabbo(habbo);
|
this.client.setHabbo(habbo);
|
||||||
this.client.getHabbo().connect();
|
if(!this.client.getHabbo().connect()) {
|
||||||
|
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo() == null) {
|
if (this.client.getHabbo().getHabboInfo() == null) {
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
||||||
@ -191,7 +185,7 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
|
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getHabbo().getHabboInfo().getIpLogin()));
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
|
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
|
||||||
final Habbo finalHabbo = habbo;
|
final Habbo finalHabbo = habbo;
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package com.eu.habbo.messages.incoming.handshake;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
|
||||||
import com.eu.habbo.messages.outgoing.friends.FriendsComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.DebugConsoleComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.SessionRightsComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.navigator.*;
|
|
||||||
import com.eu.habbo.messages.outgoing.users.*;
|
|
||||||
import com.eu.habbo.plugin.events.users.UserLoginEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SecureLoginEvent_BACKUP extends MessageHandler {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle() throws Exception {
|
|
||||||
|
|
||||||
if (!Emulator.isReady)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String sso = this.packet.readString();
|
|
||||||
|
|
||||||
if (this.client.getHabbo() == null) {
|
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
|
||||||
if (habbo != null) {
|
|
||||||
habbo.setClient(this.client);
|
|
||||||
this.client.setHabbo(habbo);
|
|
||||||
this.client.getHabbo().connect();
|
|
||||||
//this.client.sendResponse(new DebugConsoleComposer());
|
|
||||||
Emulator.getThreading().run(habbo);
|
|
||||||
Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo);
|
|
||||||
|
|
||||||
ArrayList<ServerMessage> messages = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
messages.add(new SecureLoginOKComposer().compose());
|
|
||||||
messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose());
|
|
||||||
messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new UserClubComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new DebugConsoleComposer(Emulator.debugging).compose());
|
|
||||||
messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new NewUserIdentityComposer(habbo).compose());
|
|
||||||
messages.add(new UserPerksComposer(habbo).compose());
|
|
||||||
messages.add(new SessionRightsComposer().compose());
|
|
||||||
messages.add(new FavoriteRoomsCountComposer(habbo).compose());
|
|
||||||
//messages.add(new FriendsComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new NewUserIdentityComposer().compose());
|
|
||||||
//messages.add(new UserDataComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new SessionRightsComposer().compose());
|
|
||||||
//messages.add(new MinimailCountComposer().compose());
|
|
||||||
//messages.add(new MessengerInitComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new FriendsComposer(this.client.getHabbo()).compose());
|
|
||||||
|
|
||||||
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
|
||||||
messages.add(new ModToolComposer(this.client.getHabbo()).compose());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client.sendResponses(messages);
|
|
||||||
|
|
||||||
//Hardcoded
|
|
||||||
this.client.sendResponse(new NewNavigatorMetaDataComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorLiftedRoomsComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches()));
|
|
||||||
this.client.sendResponse(new NewNavigatorEventCategoriesComposer());
|
|
||||||
//this.client.sendResponse(new HotelViewComposer());
|
|
||||||
//this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()));
|
|
||||||
//this.client.sendResponse(new UserEffectsListComposer());
|
|
||||||
|
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.client.sendResponse(new GenericAlertComposer("Can't connect *sadpanda*"));
|
|
||||||
|
|
||||||
this.client.getChannel().close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.eu.habbo.plugin.events.users;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
public class UserGetIPAddressEvent extends UserEvent{
|
||||||
|
public final String oldIp;
|
||||||
|
|
||||||
|
private String updatedIp;
|
||||||
|
private boolean changedIP = false;
|
||||||
|
|
||||||
|
public UserGetIPAddressEvent(Habbo habbo, String ip) {
|
||||||
|
super(habbo);
|
||||||
|
this.oldIp = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedIp(String updatedIp) {
|
||||||
|
this.updatedIp = updatedIp;
|
||||||
|
this.changedIP = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChangedIP() {
|
||||||
|
return changedIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdatedIp() {
|
||||||
|
return updatedIp;
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,9 @@ import java.net.SocketAddress;
|
|||||||
|
|
||||||
public class UserLoginEvent extends UserEvent {
|
public class UserLoginEvent extends UserEvent {
|
||||||
|
|
||||||
public final SocketAddress ip;
|
public final String ip;
|
||||||
|
|
||||||
|
public UserLoginEvent(Habbo habbo, String ip) {
|
||||||
public UserLoginEvent(Habbo habbo, SocketAddress ip) {
|
|
||||||
super(habbo);
|
super(habbo);
|
||||||
|
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
Loading…
Reference in New Issue
Block a user