Skip to content
Permalink
Browse files

remove non-module dependency on nms

  • Loading branch information...
mcmonkey4eva committed Feb 6, 2019
1 parent e787f6b commit ea22f2bd2538a76f12ad7e427eb0af10d7c786ca
@@ -73,6 +73,8 @@ public boolean isCorrectMappingsCode() {
return true;
}

public abstract void disableAsyncCatcher();

public abstract Sidebar createSidebar(Player player);

public abstract BlockLight createBlockLight(Location location, int lightLevel, long ticks);
@@ -22,13 +22,6 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${craftbukkit.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.aufdemrand</groupId>
<artifactId>denizen-nmshandler</artifactId>
@@ -358,10 +358,11 @@ public void onEnable() {
}

try {
org.spigotmc.AsyncCatcher.enabled = false;
NMSHandler.getInstance().disableAsyncCatcher();
}
catch (Throwable e) {
dB.echoError("Running not-Spigot?!");
catch (Throwable ex) {
dB.echoError("Running not-Spigot?! AsyncCatcher disable failed!");
dB.echoError(ex);
}

try {
@@ -1707,7 +1708,7 @@ public boolean allowedToWebget() {
@Override
public void preTagExecute() {
try {
org.spigotmc.AsyncCatcher.enabled = false;
NMSHandler.getInstance().disableAsyncCatcher();
}
catch (Throwable e) {
dB.echoError("Running not-Spigot?!");
@@ -1,14 +1,14 @@
package net.aufdemrand.denizen.objects;

import net.aufdemrand.denizen.Settings;
import net.aufdemrand.denizen.utilities.Utilities;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.apache.commons.io.FileUtils;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -1044,7 +1044,7 @@ public void adjust(Mechanism mechanism) {
File folder = new File(getWorld().getName());
Bukkit.getServer().unloadWorld(getWorld(), false);
try {
FileUtils.deleteDirectory(folder);
Utilities.deleteDirectory(folder);
}
catch (Exception ex) {
dB.echoError(ex);
@@ -10,9 +10,9 @@
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.nio.file.Files;

public class FileCopyCommand extends AbstractCommand {

@@ -103,10 +103,10 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
d.mkdirs();
}
if (o.isDirectory()) {
FileUtils.copyDirectory(o, d);
Utilities.copyDirectory(o, d);
}
else {
FileUtils.copyFile(o, d);
Files.copy(o.toPath(), (disdir ? d.toPath().resolve(o.toPath().getFileName()) : d.toPath()));
}
scriptEntry.addObject("success", new Element("true"));
}
@@ -1,13 +1,13 @@
package net.aufdemrand.denizen.scripts.commands.world;

import net.aufdemrand.denizen.utilities.Utilities;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.exceptions.CommandExecutionException;
import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@@ -100,7 +100,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dB.echoError(scriptEntry.getResidingQueue(), "Invalid copy from world folder - does not exist!");
return;
}
FileUtils.copyDirectory(folder, newFolder);
Utilities.copyDirectory(folder, newFolder);
File file = new File(worldName.asString() + "/uid.dat");
if (file.exists()) {
file.delete();
@@ -26,6 +26,11 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -37,6 +42,38 @@

public static final TagContext noDebugContext = new BukkitTagContext(null, null, false, null, false, null);

public static void deleteDirectory(File directory) throws IOException {
Files.walkFileTree(directory.toPath(),
new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
});
}

public static void copyDirectory(File source, File destination) throws IOException {
copyDirectory(source.toPath(), destination.toPath());
}

public static void copyDirectory(Path source, Path destination) throws IOException {
Files.walk(source).forEach(file -> {
try {
Files.copy(file, destination.resolve(source.relativize(file)));
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
});
}

public static boolean canReadFile(File f) {
if (Settings.allowStupids()) {
return true;
@@ -49,6 +49,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_10_R1();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public Thread getMainThread() {
return ((CraftServer) Bukkit.getServer()).getServer().primaryThread;
@@ -49,6 +49,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_11_R1();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public Thread getMainThread() {
return ((CraftServer) Bukkit.getServer()).getServer().primaryThread;
@@ -55,6 +55,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_12_R1();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public Thread getMainThread() {
return ((CraftServer) Bukkit.getServer()).getServer().primaryThread;
@@ -59,6 +59,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_13_R2();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public boolean isCorrectMappingsCode() {
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals("00ed8e5c39debc3ed194ad7c5645cc45");
@@ -49,6 +49,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_8_R3();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public Thread getMainThread() {
return ((CraftServer) Bukkit.getServer()).getServer().primaryThread;
@@ -49,6 +49,11 @@

private final ProfileEditor profileEditor = new ProfileEditor_v1_9_R2();

@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}

@Override
public int getPort() {
return ((CraftServer) Bukkit.getServer()).getServer().P();

0 comments on commit ea22f2b

Please sign in to comment.
You can’t perform that action at this time.