Files
sweetgum-server/src/client/autoban/AutobanManager.java
ronancpl 5480035005 Level/exp on all equips + Player stats overhaul + Chair handler patch
Implemented a massive overhaul on Character.wz, adding in equipment level-related nodes in order to make equipments level/EXP info available for anyone to check.
Implemented a major overhaul on the player stat management throughout the source, properly encapsulating and concurrency protecting it's mechanics.
Reviewed several MoveLifeHandler aspects, some of them trying to prevent mobs from falling from footholds in certain circumstances.
Fixed MP Recovery instant killing players when they run out of HP to use.
Fixed some chairs arbitrarily disconnecting players upon HP/MP recovery.
Fixed Puppets sticking to maps in certain scenarios.
Cached data and added concurrency protection for EXP gain on equipments.
Reworked Chair Mastery skill, now with recovering amounts based on a player's base HP/MP pool.
Fixed several deadlock issues revolving rate coupons and character inventory.
Improved overall autopot handler performance.
Reworked door bosses (such as Crocell), now spawning each 3 hours instead of upon player's demand.
Fixed alliances not saving rank names on DB at creation time.
Fixed alliances retaining disbanded guild info on DB.
Added Mystic Door support for the Mushroom Castle area.
2018-09-23 22:37:00 -03:00

119 lines
3.4 KiB
Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package client.autoban;
import client.MapleCharacter;
import java.util.HashMap;
import java.util.Map;
import tools.FilePrinter;
/**
*
* @author kevintjuh93
*/
public class AutobanManager {
private MapleCharacter chr;
private Map<AutobanFactory, Integer> points = new HashMap<>();
private 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];
public AutobanManager(MapleCharacter chr) {
this.chr = chr;
}
public void addPoint(AutobanFactory fac, String reason) {
if (chr.isGM() || chr.isBanned()){
return;
}
if (lastTime.containsKey(fac)) {
if (lastTime.get(fac) < (System.currentTimeMillis() - fac.getExpire())) {
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
}
}
if (fac.getExpire() != -1)
lastTime.put(fac, System.currentTimeMillis());
if (points.containsKey(fac)) {
points.put(fac, points.get(fac) + 1);
} else
points.put(fac, 1);
if (points.get(fac) >= fac.getMaximum()) {
chr.autoban(reason);
//chr.autoban("Autobanned for " + fac.name() + " ;" + reason, 1);
//chr.sendPolice("You have been blocked by #bMooplePolice for the HACK reason#k.");
}
// Lets log every single point too.
FilePrinter.printError("autobanwarning.txt", MapleCharacter.makeMapleReadable(chr.getName()) + " caused " + fac.name() + " " + reason + "\r\n");
}
public void addMiss() {
this.misses++;
}
public void resetMisses() {
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;
this.misses = 0;
}
//Don't use the same type for more than 1 thing
public void spam(int type) {
this.spam[type] = System.currentTimeMillis();
}
public void spam(int type, int timestamp) {
this.spam[type] = timestamp;
}
public long getLastSpam(int type) {
return spam[type];
}
/**
* Timestamp checker
*
* <code>type</code>:<br>
* 1: Pet Food<br>
* 2: InventoryMerge<br>
* 3: InventorySort<br>
* 4: SpecialMove<br>
* 5: UseCatchItem<br>
* 6: Item Drop<br>
* 7: Chat<br>
* 8: HealOverTimeHP<br>
* 9: HealOverTimeMP<br>
*
* @param type type
* @return Timestamp checker
*/
public void setTimestamp(int type, int time, int times) {
if (this.timestamp[type] == time) {
this.timestampcounter[type]++;
if (this.timestampcounter[type] >= times) {
chr.getClient().disconnect(false, false);
FilePrinter.print(FilePrinter.EXPLOITS, "Player " + chr + " was caught spamming TYPE " + type + " and has been disconnected.");
}
return;
}
this.timestamp[type] = time;
}
}