Yen

Lv.1 初心者
管理成員
管理員
註冊
2022-08-22
文章
1
評分
3
聲望
0
1. 好的,首先進入 src/net/sf/odinms/server/AutobanManager.java (所有服務器都有這個)
這是一個基本的 AutobanManager.java 的樣子:

Java:
package net.sf.odinms.server;

import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.tools.MaplePacketCreator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AutobanManager implements Runnable {

    private static class ExpirationEntry implements Comparable<ExpirationEntry> {

        public long time;
        public int acc,  points;

        public ExpirationEntry(long time, int acc, int points) {
            this.time = time;
            this.acc = acc;
            this.points = points;
        }

        public int compareTo(AutobanManager.ExpirationEntry o) {
            return (int) (time - o.time);
        }
    }
    private Map<Integer, Integer> points = new HashMap<Integer, Integer>();
    private Map<Integer, List<String>> reasons = new HashMap<Integer, List<String>>();
    private Set<ExpirationEntry> expirations = new TreeSet<ExpirationEntry>();
    private static final int AUTOBAN_POINTS = 300000;
    private static AutobanManager instance = null;
    private static Logger log = LoggerFactory.getLogger(AutobanManager.class);

    public static AutobanManager getInstance() {
        if (instance == null) {
            instance = new AutobanManager();
        }
        return instance;
    }

    public void autoban(MapleClient c, String reason) {
        if (c.getPlayer().gmLevel() >= 1) {
        }
        addPoints(c, AUTOBAN_POINTS, 0, reason);
    }

    public synchronized void addPoints(MapleClient c, int points, long expiration, String reason) {
        // if (c.getPlayer().isGM()) return;
        int acc = c.getPlayer().getAccountID();
        List<String> reasonList;
        if (this.points.containsKey(acc)) {
            if (this.points.get(acc) >= AUTOBAN_POINTS) {
                return;
            }
            this.points.put(acc, this.points.get(acc) + points);
            reasonList = this.reasons.get(acc);
            reasonList.add(reason);
        } else {
            this.points.put(acc, points);
            reasonList = new LinkedList<String>();
            reasonList.add(reason);
            this.reasons.put(acc, reasonList);
        }
        if (this.points.get(acc) >= AUTOBAN_POINTS) {
            String name = c.getPlayer().getName();
            StringBuilder banReason = new StringBuilder("Autoban for char ");
            banReason.append(name);
            banReason.append(" (IP ");
            banReason.append(c.getSession().getRemoteAddress().toString());
            banReason.append("): ");
            for (String s : reasons.get(acc)) {
                banReason.append(s);
                banReason.append(", ");
            }

            if (c.getPlayer().gmLevel() >= 1) {
            } else {
                c.getPlayer().ban(banReason.toString());
                try {
                    c.getChannelServer().getWorldInterface().broadcastMessage(null,
                            MaplePacketCreator.serverNotice(0, "[Autoban] " + name + " banned by the system (Last reason: " + reason + ")").getBytes());
                } catch (RemoteException e) {
                    c.getChannelServer().reconnectWorld();
                }
                log.warn("[h4x] Autobanned player {} (accountid {})", name, acc);
            }
            return;
        }
        if (expiration > 0) {
            expirations.add(new ExpirationEntry(System.currentTimeMillis() + expiration, acc, points));
        }
    }

    public void run() {
        long now = System.currentTimeMillis();
        for (ExpirationEntry e : expirations) {
            if (e.time <= now) {
                this.points.put(e.acc, this.points.get(e.acc) - e.points);
            } else {
                return;
            }
        }
    }
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

2. 尋找

Java:
[/B]
  try {
                    c.getChannelServer().getWorldInterface().broadcastMessage(null,
                            MaplePacketCreator.serverNotice(0, "[Autoban] " + name + " 被系統禁止 (Last reason: " + reason + ")").getBytes( ));
                } catch (RemoteException e) {
                    c.getChannelServer().reconnectWorld();
                }
                log.warn("[h4x] Autobanned player {} (accountid {})", name, acc);
用這個替換它:
// try {
       // c.getChannelServer().getWorldInterface().broadcastMessage(null,
       // MaplePacketCreator.serverNotice(0, "[Autoban] " + name + " 被系統禁止 (Last reason: " + reason + " )").getBytes());
       // } catch (RemoteException e) {
       // c.getChannelServer().reconnectWorld();
       // }
       // log.warn("[h4x] Autobanned player {} (accountid {})", name, acc);



3. 保存並關閉。

4. 編譯,並擁有一個無 Autoban 的服務器!


轉自ragezone 論壇
 
由版主最後編輯:

揪北嵐

Lv.1 初心者
註冊
2022-09-22
文章
7
評分
0
聲望
0
想請教一下 白狐端113也能這樣處理嗎
package server;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import client.MapleClient;
import handling.world.World;
import java.util.concurrent.locks.ReentrantLock;
import tools.MaplePacketCreator;
public class AutobanManager implements Runnable {
private static class ExpirationEntry implements Comparable<ExpirationEntry> {
public long time;
public int acc;
public int points;
public ExpirationEntry(long time, int acc, int points) {
this.time = time;
this.acc = acc;
this.points = points;
}
public int compareTo(AutobanManager.ExpirationEntry o) {
return (int) (time - o.time);
}
@Override
public boolean equals(Object oth) {
if (!(oth instanceof AutobanManager.ExpirationEntry)) {
return false;
}
final AutobanManager.ExpirationEntry ee = (AutobanManager.ExpirationEntry) oth;
return (time == ee.time && points == ee.points && acc == ee.acc);
}
}
private Map<Integer, Integer> points = new HashMap<Integer, Integer>();
private Map<Integer, List<String>> reasons = new HashMap<Integer, List<String>>();
private Set<ExpirationEntry> expirations = new TreeSet<ExpirationEntry>();
private static final int AUTOBAN_POINTS = 5000;
private static AutobanManager instance = new AutobanManager();
private final ReentrantLock lock = new ReentrantLock(true);
public static final AutobanManager getInstance() {
return instance;
}
public final void autoban(final MapleClient c, final String reason) {
if (c.getPlayer().isGM() || c.getPlayer().isClone()) {
c.getPlayer().dropMessage(5, "[WARNING] A/b triggled : " + reason);
return;
}
addPoints(c, AUTOBAN_POINTS, 0, reason);
}
public final void addPoints(final MapleClient c, final int points, final long expiration, final String reason) {
lock.lock();
try {
List<String> reasonList;
final int acc = c.getPlayer().getAccountID();
if (this.points.containsKey(acc)) {
final int SavedPoints = this.points.get(acc);
if (SavedPoints >= AUTOBAN_POINTS) { // Already auto ban'd.
return;
}
this.points.put(acc, SavedPoints + points); // Add
reasonList = this.reasons.get(acc);
reasonList.add(reason);
} else {
this.points.put(acc, points);
reasonList = new LinkedList<String>();
reasonList.add(reason);
this.reasons.put(acc, reasonList);
}
if (this.points.get(acc) >= AUTOBAN_POINTS) { // See if it's sufficient to auto ban
if (c.getPlayer().isGM() || c.getPlayer().isClone()) {
c.getPlayer().dropMessage(5, "[WARNING] A/b triggled : " + reason);
return;
}
final StringBuilder sb = new StringBuilder("a/b ");
sb.append(c.getPlayer().getName());
sb.append(" (IP ");
sb.append(c.getSession().remoteAddress().toString());
sb.append("): ");
for (final String s : reasons.get(acc)) {
sb.append(s);
sb.append(", ");
}
// World.Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(0, "'" + c.getPlayer().getName() + "'使用外掛程式遭到系統封鎖").getBytes());
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DATE, 60);
// c.getPlayer().tempban(sb.toString(), cal, 1, false);
// c.getPlayer().ban(sb.toString(), false, true, false);
// c.disconnect(true, false);
} else {
if (expiration > 0) {
expirations.add(new ExpirationEntry(System.currentTimeMillis() + expiration, acc, points));
}
}
} finally {
lock.unlock();
}
}
public final void run() {
final long now = System.currentTimeMillis();
for (final ExpirationEntry e : expirations) {
if (e.time <= now) {
this.points.put(e.acc, this.points.get(e.acc) - e.points);
} else {
return;
}
}
}
}
 
最後編輯: