Reformat and clean up "client" package
This commit is contained in:
@@ -30,75 +30,74 @@ import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public enum AutobanFactory {
|
||||
MOB_COUNT,
|
||||
GENERAL,
|
||||
FIX_DAMAGE,
|
||||
DAMAGE_HACK(15, 60 * 1000),
|
||||
DISTANCE_HACK(10, 120 * 1000),
|
||||
PORTAL_DISTANCE(5, 30000),
|
||||
PACKET_EDIT,
|
||||
ACC_HACK,
|
||||
CREATION_GENERATOR,
|
||||
HIGH_HP_HEALING,
|
||||
FAST_HP_HEALING(15),
|
||||
FAST_MP_HEALING(20, 30000),
|
||||
GACHA_EXP,
|
||||
TUBI(20, 15000),
|
||||
SHORT_ITEM_VAC,
|
||||
ITEM_VAC,
|
||||
FAST_ITEM_PICKUP(5, 30000),
|
||||
FAST_ATTACK(10, 30000),
|
||||
MPCON(25, 30000);
|
||||
MOB_COUNT,
|
||||
GENERAL,
|
||||
FIX_DAMAGE,
|
||||
DAMAGE_HACK(15, 60 * 1000),
|
||||
DISTANCE_HACK(10, 120 * 1000),
|
||||
PORTAL_DISTANCE(5, 30000),
|
||||
PACKET_EDIT,
|
||||
ACC_HACK,
|
||||
CREATION_GENERATOR,
|
||||
HIGH_HP_HEALING,
|
||||
FAST_HP_HEALING(15),
|
||||
FAST_MP_HEALING(20, 30000),
|
||||
GACHA_EXP,
|
||||
TUBI(20, 15000),
|
||||
SHORT_ITEM_VAC,
|
||||
ITEM_VAC,
|
||||
FAST_ITEM_PICKUP(5, 30000),
|
||||
FAST_ATTACK(10, 30000),
|
||||
MPCON(25, 30000);
|
||||
|
||||
private int points;
|
||||
private long expiretime;
|
||||
private final int points;
|
||||
private final long expiretime;
|
||||
|
||||
private AutobanFactory() {
|
||||
this(1, -1);
|
||||
}
|
||||
AutobanFactory() {
|
||||
this(1, -1);
|
||||
}
|
||||
|
||||
private AutobanFactory(int points) {
|
||||
this.points = points;
|
||||
this.expiretime = -1;
|
||||
}
|
||||
AutobanFactory(int points) {
|
||||
this.points = points;
|
||||
this.expiretime = -1;
|
||||
}
|
||||
|
||||
private AutobanFactory(int points, long expire) {
|
||||
this.points = points;
|
||||
this.expiretime = expire;
|
||||
}
|
||||
AutobanFactory(int points, long expire) {
|
||||
this.points = points;
|
||||
this.expiretime = expire;
|
||||
}
|
||||
|
||||
public int getMaximum() {
|
||||
return points;
|
||||
}
|
||||
public int getMaximum() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public long getExpire() {
|
||||
return expiretime;
|
||||
}
|
||||
public long getExpire() {
|
||||
return expiretime;
|
||||
}
|
||||
|
||||
public void addPoint(AutobanManager ban, String reason) {
|
||||
ban.addPoint(this, reason);
|
||||
}
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if(YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
if (chr != null && MapleLogger.ignored.contains(chr.getId())){
|
||||
return;
|
||||
}
|
||||
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
|
||||
public void addPoint(AutobanManager ban, String reason) {
|
||||
ban.addPoint(this, reason);
|
||||
}
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
if (chr != null && MapleLogger.ignored.contains(chr.getId())) {
|
||||
return;
|
||||
}
|
||||
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
|
||||
}
|
||||
if (YamlConfig.config.server.USE_AUTOBAN_LOG) {
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, (chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void autoban(Character chr, String value) {
|
||||
if(YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, (chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void autoban(Character chr, String value) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,18 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class AutobanManager {
|
||||
private Character chr;
|
||||
private Map<AutobanFactory, Integer> points = new HashMap<>();
|
||||
private Map<AutobanFactory, Long> lastTime = new HashMap<>();
|
||||
private final Character chr;
|
||||
private final Map<AutobanFactory, Integer> points = new HashMap<>();
|
||||
private final Map<AutobanFactory, Long> lastTime = new HashMap<>();
|
||||
private int misses = 0;
|
||||
private int lastmisses = 0;
|
||||
private int samemisscount = 0;
|
||||
private long[] spam = new long[20];
|
||||
private int[] timestamp = new int[20];
|
||||
private byte[] timestampcounter = new byte[20];
|
||||
private final long[] spam = new long[20];
|
||||
private final int[] timestamp = new int[20];
|
||||
private final byte[] timestampcounter = new byte[20];
|
||||
|
||||
|
||||
public AutobanManager(Character chr) {
|
||||
@@ -34,23 +33,25 @@ public class AutobanManager {
|
||||
}
|
||||
|
||||
public void addPoint(AutobanFactory fac, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr.isGM() || chr.isBanned()){
|
||||
return;
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr.isGM() || chr.isBanned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lastTime.containsKey(fac)) {
|
||||
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
|
||||
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
|
||||
}
|
||||
}
|
||||
if (fac.getExpire() != -1)
|
||||
if (fac.getExpire() != -1) {
|
||||
lastTime.put(fac, Server.getInstance().getCurrentTime());
|
||||
}
|
||||
|
||||
if (points.containsKey(fac)) {
|
||||
points.put(fac, points.get(fac) + 1);
|
||||
} else
|
||||
} else {
|
||||
points.put(fac, 1);
|
||||
}
|
||||
|
||||
if (points.get(fac) >= fac.getMaximum()) {
|
||||
chr.autoban(reason);
|
||||
@@ -70,20 +71,21 @@ public class AutobanManager {
|
||||
if (lastmisses == misses && misses > 6) {
|
||||
samemisscount++;
|
||||
}
|
||||
if (samemisscount > 4)
|
||||
chr.sendPolice("You will be disconnected for miss godmode.");
|
||||
//chr.autoban("Autobanned for : " + misses + " Miss godmode", 1);
|
||||
else if (samemisscount > 0)
|
||||
|
||||
this.lastmisses = misses;
|
||||
if (samemisscount > 4) {
|
||||
chr.sendPolice("You will be disconnected for miss godmode.");
|
||||
}
|
||||
//chr.autoban("Autobanned for : " + misses + " Miss godmode", 1);
|
||||
else if (samemisscount > 0) {
|
||||
this.lastmisses = misses;
|
||||
}
|
||||
this.misses = 0;
|
||||
}
|
||||
|
||||
|
||||
//Don't use the same type for more than 1 thing
|
||||
public void spam(int type) {
|
||||
this.spam[type] = Server.getInstance().getCurrentTime();
|
||||
}
|
||||
|
||||
|
||||
public void spam(int type, int timestamp) {
|
||||
this.spam[type] = timestamp;
|
||||
}
|
||||
@@ -95,7 +97,7 @@ public class AutobanManager {
|
||||
/**
|
||||
* Timestamp checker
|
||||
*
|
||||
* <code>type</code>:<br>
|
||||
* <code>type</code>:<br>
|
||||
* 1: Pet Food<br>
|
||||
* 2: InventoryMerge<br>
|
||||
* 3: InventorySort<br>
|
||||
@@ -110,13 +112,13 @@ public class AutobanManager {
|
||||
* @return Timestamp checker
|
||||
*/
|
||||
public void setTimestamp(int type, int time, int times) {
|
||||
if (this.timestamp[type] == time) {
|
||||
if (this.timestamp[type] == time) {
|
||||
this.timestampcounter[type]++;
|
||||
if (this.timestampcounter[type] >= times) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
chr.getClient().disconnect(false, false);
|
||||
}
|
||||
|
||||
|
||||
FilePrinter.print(FilePrinter.EXPLOITS, "Player " + chr + " was caught spamming TYPE " + type + " and has been disconnected.");
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user