Workaround for CoreProtect logging

This commit is contained in:
Jesse Boyd 2016-04-21 09:40:14 +10:00
parent aa02b34d7c
commit 652a983907
3 changed files with 20 additions and 2 deletions

View File

@ -57,7 +57,7 @@ public class MainUtil {
public void run(File file) {
long age = now - file.lastModified();
if (age > timeDiff) {
System.out.println("Deleting file: " + file);
Fawe.debug("Deleting file: " + file);
file.delete();
}
}
@ -73,7 +73,7 @@ public class MainUtil {
if (file.isDirectory()) {
deleteDirectory(files[i]);
} else {
System.out.println("Deleting file: " + file);
Fawe.debug("Deleting file: " + file);
file.delete();
}
}

View File

@ -40,6 +40,10 @@ public class WorldWrapper extends AbstractWorld {
this.parent = parent;
}
public AbstractWorld getParent() {
return parent instanceof WorldWrapper ? ((WorldWrapper) parent).getParent() : parent;
}
@Override
public boolean useItem(Vector position, BaseItem item, Direction face) {
return parent.useItem(position, item, face);

View File

@ -118,6 +118,7 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.lang.reflect.Field;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
@ -235,6 +236,19 @@ public class EditSession implements Extent {
}
this.actor = event.getActor();
this.queue = SetQueue.IMP.getNewQueue(world.getName(), true);
// Set the world of the event to the actual world (workaround for CoreProtect)
try {
Class<? extends EditSessionEvent> eventClass = event.getClass();
Field fieldWorld = eventClass.getDeclaredField("world");
fieldWorld.setAccessible(true);
if (world instanceof WorldWrapper) {
fieldWorld.set(event, ((WorldWrapper) world).getParent());
} else {
fieldWorld.set(event, world);
}
} catch (Throwable e) {
e.printStackTrace();
}
this.world = (world = new WorldWrapper((AbstractWorld) world));
this.wrapper = Fawe.imp().getEditSessionWrapper(this);
// Not a player; bypass history