-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
MemoryCheckingExtent.java
37 lines (31 loc) · 1.21 KB
/
MemoryCheckingExtent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.fastasyncworldedit.core.extent;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.util.MemUtil;
import com.fastasyncworldedit.core.util.Permission;
import com.fastasyncworldedit.core.util.WEManager;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
public final class MemoryCheckingExtent extends PassthroughExtent {
private final Actor actor;
public MemoryCheckingExtent(Actor actor, Extent extent) {
super(extent);
this.actor = actor;
}
@Override
public Extent getExtent() {
if (MemUtil.isMemoryLimited()) {
if (this.actor != null) {
actor.print(Caption.of(
"fawe.cancel.reason",
Caption.of("fawe.cancel.reason.low.memory")
));
if (Permission.hasPermission(this.actor, "worldedit.fast")) {
this.actor.print(Caption.of("fawe.info.worldedit.oom.admin"));
}
}
WEManager.weManager().cancelEdit(this, FaweCache.LOW_MEMORY);
}
return super.getExtent();
}
}