ActivityTracker 是我编写的一个插件,作为我正在开发的反破坏插件 Heimdall 的垫脚石,该插件将对玩家活动进行启发式分析以自动检测破坏行为。ActivityTracker 将所有玩家活动记录到单个日志文件(每个玩家一个)中以便轻松分析,其预期用途是开启“访客”权限组的记录功能,这样你就可以拥有所有访客(通常是破坏者)执行的所有活动的单一日志。为此,它有一个权限列表,拥有这些权限的玩家将被追踪,没有这些权限的玩家将被此插件忽略。
如果有 LogBlock,ActivityTracker 会与其挂钩以确定方块所有者,并且不属于该玩家的方块破坏会被标记,以便在日志文件中轻松 grep:
# grep "NOT BLOCK OWNER" maxx1910.log
[12/18/11 11:06:53 AM] block broken at {1dot8,x=-1501,y=54,z=1681}, blockType=TORCH, lbOwner=graemejr, blockData=2 ** NOT BLOCK OWNER **
[12/18/11 11:06:59 AM] block broken at {1dot8,x=-1501,y=54,z=1674}, blockType=TORCH, lbOwner=graemejr, blockData=3 ** NOT BLOCK OWNER **
以下是日志示例:example。
有了这个插件,你可以在访客的日志文件上运行 'tail -f',并从服务器命令提示符下观察他们所做的每一件事,效果就像你隐形跟随他们一样。此外,如果你因为破坏行为封禁了他们,你就有了一个单一的日志,记录了从他们登录你的服务器到被 ban 为止的所有行为,全部在一个方便的地方。
这**不是**对像 LogBlock 这样优秀的反破坏工具的替代——事实上,当与 LogBlock 结合使用时,此插件效果最佳,因为它可以报告方块所有者并在访客登录并开始破坏不属于他们的方块时轻松标记破坏行为。
安装
- 下载 jar 文件,放入 plugins 目录。
- 根据需要配置 config.yml(首次运行时会自动复制到位)。
性能
等等,所以每次玩家行动都记录,包括移动和方块破坏,并且每次都要进行 LogBlock 查找?!天哪,那一定非常慢并且会导致卡顿!!错。我在自己的服务器上运行这个插件,这是一个 humble 4G VPS,最多支持 20 个槽位,我没有任何性能影响(满 20 tps 和满 20 名玩家)。原因如下:
- 此插件只追踪访客,因此它对 80% 的服务器人口几乎不做任何工作(通常同时只有 3-5 名访客)
- 方块破坏存储在高效的循环缓冲区中,所有繁重的工作都在另一个线程上完成,利用多核优势,让主 Bukkit 线程空闲以运行你的服务器。
- 玩家移动**不**挂钩 PLAYER_MOVE。相反,它每 5 秒异步运行一次并记录之前的位置,每 5 秒只记录和报告差异。
- 文件日志使用 BufferedWriter 完成,以便 Java 高效地缓冲写入内容,不会阻塞任何线程的文件 I/O。
- LogBlock 查找在异步 Block 线程中完成,但它们进一步缓存在循环缓冲区中,以便对同一方块的多次查找(如 ChestAccess 日志中发生的情况)不会超过一次访问数据库。
正如你所见,我非常重视我的插件的性能,主要是因为我的服务器托管在 humble VPS 上,没有多余的功率用于浪费处理,所以我非常仔细地选择我的插件,并在开发之初就考虑到性能来编写我的插件。
ActivityTracker is a plugin I wrote as a stepping stone to an anti-grief plugin I'm working on called Heimdall, which will do hueristic analysis of player activity to automatically detect griefing behavior. ActivityTracker logs all player activities to a single log file (per player) for easy analysis, it's intended use is to be turned on for your "guest" rank so you have a single log of all activity that your guests (often griefers) perform. To accomplish this, it has a permission list and anyone who has those permissions will be tracked, anyone who does not will be ignored by this plugin.
ActivityTracker will hook into LogBlock (if you have it) to determine block owners, and block destruction that is not owned by the player is flagged for easy grep'ing in the logfile:
# grep "NOT BLOCK OWNER" maxx1910.log
[12/18/11 11:06:53 AM] block broken at {1dot8,x=-1501,y=54,z=1681}, blockType=TORCH, lbOwner=graemejr, blockData=2 ** NOT BLOCK OWNER **
[12/18/11 11:06:59 AM] block broken at {1dot8,x=-1501,y=54,z=1674}, blockType=TORCH, lbOwner=graemejr, blockData=3 ** NOT BLOCK OWNER **
Here is an example of what a log looks like.
With this plugin in place, it's possible to run 'tail -f' on a guest's logfile and watch everything they do from your server command prompt, just as effective as if you were on the server following them invisible. Further, if you do ban them for griefing behavior, you have a single log that tracked everything they did from the moment they logged into your server until they got banned all in one convenient place.
This is NOT a replacement for excellent anti-griefer tools such as LogBlock - in fact this plugin works best when used in conjunction with LogBlock in order to report block owners and easily flag griefing behavior when guests login and start tearing up blocks that don't belong to them.
Installation
- Download the jar, put it in your plugins directory.
- Configure the config.yml (copied into place on first run) to your liking.
Performance
Wait, so logging every player action, including movement and block breaks and doing LogBlock lookups for every block?! OMG, that must be SO slow and going to lag!! Wrong. I run this on my own server, which is a humble 4G VPS that maxes out at 20 slots, and I have had no performance impact as a result of running this on my server (full 20 tps with full 20 players). Here's why:
- This plugin only tracks guests, so it does almost no work for 80% of the server population (usually only 3-5 guests on at a time)
- Block breaks are stored efficiently in a circular buffer and all heavy lifting is done on another thread, taking advantage of multiple cores and leaving the main Bukkit thread free to run your server.
- Player movement does NOT hook PLAYER_MOVE. Instead, it runs asynchronously every 5 seconds and records the previous location, tracking and reporting only the difference every 5 seconds.
- File logging is done using a BufferedWriter so that Java efficiently buffers the writes and doesn't block any threads on file I/O.
- LogBlock lookups are done in the asynchronous Block thread, but they are further cached in a circular buffer so that multiple lookups on the same block (as happens with ChestAccess logging) does not hit the database more than once.
As you can see, I take the performance of my plugins very seriously, primarily because the humble VPS that my server is hosted on doesn't have a lot of extra power for wasteful processing, so I choose my plugins very carefully and write my plugins with performance in mind from the get-go.
评论 0
登录后参与评分
还没有评论,来抢沙发吧