Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.5 KiB

package engine.util;
import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager;
import engine.gameManager.GroupManager;
2 months ago
import engine.gameManager.SessionManager;
import engine.net.client.ClientConnection;
import engine.net.client.Protocol;
import engine.net.client.msg.ClientNetMsg;
2 months ago
import engine.net.client.msg.TargetObjectMsg;
import engine.objects.Group;
import engine.objects.PlayerCharacter;
2 months ago
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
public enum KeyCloneAudit {
KEYCLONEAUDIT;
public static boolean auditChatMsg(PlayerCharacter pc, String message) {
if(message.contains(String.valueOf(pc.selectedUUID))) {
//targeting software detected
Group g = GroupManager.getGroup(pc);
1 month ago
if (g == null) {
//pc.getClientConnection().forceDisconnect();
try {
DbManager.AccountQueries.SET_TRASH(pc.getClientConnection().machineID);
}catch(Exception e){
}
}else {
for (PlayerCharacter member : g.members) {
1 month ago
//member.getClientConnection().forceDisconnect();
try {
DbManager.AccountQueries.SET_TRASH(member.getClientConnection().machineID);
1 month ago
} catch (Exception e) {
}
}
1 month ago
}
return true;
}
return false;
}
public void audit(PlayerCharacter player, Group group) {
int machineCount = 0;
String machineID;
machineID = player.getClientConnection().machineID;
for (PlayerCharacter member : group.getMembers())
if (machineID.equals(member.getClientConnection().machineID))
machineCount = machineCount + 1;
if (machineCount > Integer.parseInt(ConfigManager.MB_WORLD_KEYCLONE_MAX.getValue())) {
Logger.error("Keyclone detected from: " + player.getAccount().getUname() +
" with machine count of: " + machineCount);
DbManager.AccountQueries.SET_TRASH(machineID);
}
}
public static void auditTargetMsg(ClientNetMsg msg) {
2 months ago
try {
TargetObjectMsg tarMsg = (TargetObjectMsg) msg;
2 months ago
ClientConnection origin = (ClientConnection) msg.getOrigin();
2 months ago
long now = System.currentTimeMillis();
if (tarMsg.getTargetType() != MBServerStatics.MASK_PLAYER)
return;
PlayerCharacter pc = origin.getPlayerCharacter();
pc.selectedUUID = ((TargetObjectMsg) msg).getTargetID();
if (System.currentTimeMillis() > origin.finalStrikeRefresh) {
origin.lastStrike = System.currentTimeMillis();
origin.strikes = 0;
origin.finalStrikes = 0;
origin.finalStrikeRefresh = System.currentTimeMillis();
}
// Calculate time since last target switch
long timeSinceLastTarget = now - origin.lastTargetSwitchTime;
origin.lastTargetSwitchTime = now;
if (timeSinceLastTarget < 150) {
origin.strikes++;
origin.finalStrikeRefresh = System.currentTimeMillis() + 1000L;
}
if (origin.strikes > 20) {
origin.finalStrikes++;
}
if (origin.finalStrikes > 3) {origin.forceDisconnect();
DbManager.AccountQueries.SET_TRASH(origin.machineID);
2 months ago
}
2 months ago
} catch (Exception e) {
2 months ago
}
}
2 months ago
}