Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add FastAsyncWorldEdit support on Spigot 1.13
- FastAsyncWorldEdit now supported on Spigot 1.13
- Improved support for the beta-01 versions of WorldGuard and WorldEdit
- Resolves #436
  • Loading branch information
NLthijs48 committed Jan 7, 2019
1 parent b4efe7d commit 0aea914
Show file tree
Hide file tree
Showing 13 changed files with 625 additions and 69 deletions.
37 changes: 21 additions & 16 deletions AreaShop/pom.xml
Expand Up @@ -38,6 +38,22 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>

<!-- WorldEdit/WorldGuard -->
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/worldedit-bukkit-7.0.0-beta-04.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/worldguard-legacy-7.0.0-beta-02.jar</systemPath>
</dependency>

<!-- Interfaces that specific WorldGuard and WorldEdit versions are built against -->
<dependency>
<groupId>me.wiefferink</groupId>
Expand Down Expand Up @@ -84,22 +100,6 @@
<scope>compile</scope>
</dependency>

<!-- WorldEdit/WorldGuard -->
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/worldedit-bukkit-7.0.0-beta-04.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/worldguard-legacy-7.0.0-beta-02.jar</systemPath>
</dependency>

<!-- WorldEdit implementations -->
<dependency>
<groupId>me.wiefferink</groupId>
Expand All @@ -126,6 +126,11 @@
<groupId>me.wiefferink</groupId>
<artifactId>areashop-worldedit-7_beta_4</artifactId>
<version>latest</version>
</dependency>
<dependency>
<groupId>me.wiefferink</groupId>
<artifactId>areashop-fastasyncworldedit</artifactId>
<version>latest</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Expand Down
83 changes: 60 additions & 23 deletions AreaShop/src/main/java/me/wiefferink/areashop/AreaShop.java
Expand Up @@ -34,6 +34,7 @@
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -147,7 +148,7 @@ public void onEnable() {
managers = new HashSet<>();
boolean error = false;

// Check if WorldEdit is present
// Find WorldEdit integration version to load
String weVersion = null;
String rawWeVersion = null;
String weBeta = null;
Expand Down Expand Up @@ -177,20 +178,11 @@ public void onEnable() {
// beta-02 and beta-03 also have the new vector system already
weVersion = "7_beta_4";
}
try {
final Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers.WorldEditHandler" + weVersion);
// Check if we have a NMSHandler class at that location.
if(WorldEditInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldEditInterface
worldEditInterface = (WorldEditInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler
}
} catch(final Exception e) {
error("Could not load the handler for WorldEdit (tried to load " + weVersion + "), report this problem to the author: " + ExceptionUtils.getStackTrace(e));
error = true;
weVersion = null;
}

weVersion = "WorldEditHandler" + weVersion;
}

// Check if WorldGuard is present
// Find WorldGuard integration version to load
String wgVersion = null;
String rawWgVersion = null;
int major = 0;
Expand Down Expand Up @@ -266,18 +258,63 @@ public void onEnable() {
warn("Parsing the WorldGuard version failed, assuming version 7_beta_2:", rawWgVersion);
wgVersion = "7_beta_2";
}
// Load chosen implementation
try {
final Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers.WorldGuardHandler" + wgVersion);
// Check if we have a NMSHandler class at that location.
if(WorldGuardInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldGuardInterface
worldGuardInterface = (WorldGuardInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler

wgVersion = "WorldGuardHandler" + wgVersion;
}

// Check if FastAsyncWorldEdit is installed
boolean fawe;
try {
Class.forName("com.boydti.fawe.Fawe" );
fawe = true;
} catch (ClassNotFoundException ignore) {
fawe = false;
}

if (fawe) {
boolean useNewIntegration = true;
List<String> standardIntegrationVersions = Arrays.asList("1.7", "1.8", "1.9", "1.10", "1.11", "1.12");
for(String standardIntegrationVersion : standardIntegrationVersions) {
String version = Bukkit.getBukkitVersion();
// Detects '1.8', '1.8.3', '1.8-pre1' style versions
if(version.equals(standardIntegrationVersion)
|| version.startsWith(standardIntegrationVersion + ".")
|| version.startsWith(standardIntegrationVersion + "-")) {
useNewIntegration = false;
break;
}
} catch(final Exception e) {
error("Could not load the handler for WorldGuard (tried to load " + wgVersion + "), report this problem to the author:" + ExceptionUtils.getStackTrace(e));
error = true;
wgVersion = null;
}

if (useNewIntegration) {
weVersion = "FastAsyncWorldEditHandler";
wgVersion = "FastAsyncWorldEditWorldGuardHandler";
}
}

// Load WorldEdit
try {
final Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + weVersion);
// Check if we have a NMSHandler class at that location.
if(WorldEditInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldEditInterface
worldEditInterface = (WorldEditInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler
}
} catch(final Exception e) {
error("Could not load the handler for WorldEdit (tried to load " + weVersion + "), report this problem to the author: " + ExceptionUtils.getStackTrace(e));
error = true;
weVersion = null;
}

// Load WorldGuard
try {
final Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + wgVersion);
// Check if we have a NMSHandler class at that location.
if(WorldGuardInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldGuardInterface
worldGuardInterface = (WorldGuardInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler
}
} catch(final Exception e) {
error("Could not load the handler for WorldGuard (tried to load " + wgVersion + "), report this problem to the author:" + ExceptionUtils.getStackTrace(e));
error = true;
wgVersion = null;
}

// Check if Vault is present
Expand Down
2 changes: 1 addition & 1 deletion AreaShop/src/main/resources/plugin.yml
Expand Up @@ -3,7 +3,7 @@ main: me.wiefferink.areashop.AreaShop
version: "${project.version}${build.number}"
description: "Selling and renting WorldGuard regions to your players, highly configurable."
depend: [Vault, WorldGuard, WorldEdit]
softdepend: [Multiverse-Core]
softdepend: [Multiverse-Core, FastAsyncWorldEdit]
author: NLThijs48
website: https://github.com/NLthijs48/AreaShop
commands:
Expand Down
1 change: 1 addition & 0 deletions areashop-fastasyncworldedit/.gitignore
@@ -0,0 +1 @@
/target
46 changes: 46 additions & 0 deletions areashop-fastasyncworldedit/pom.xml
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>areashop-fastasyncworldedit</artifactId>
<packaging>jar</packaging>
<name>AreaShop FastAsyncWorldEdit</name>
<version>latest</version>

<parent>
<groupId>me.wiefferink</groupId>
<artifactId>areashop-parent</artifactId>
<version>parent</version>
</parent>

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<type>jar</type>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/FastAsyncWorldEdit-bukkit-1.13.132.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<scope>system</scope>
<version>any</version>
<systemPath>${project.basedir}/../dependencies/FastAsyncWorldEdit-worldguard-legacy-7.0.0-SNAPSHOT-dist.jar</systemPath>
</dependency>

<dependency>
<groupId>me.wiefferink</groupId>
<artifactId>areashop-interface</artifactId>
<version>latest</version>
<type>jar</type>
</dependency>

</dependencies>
</project>

0 comments on commit 0aea914

Please sign in to comment.