Fix older Builds of WorldGuard 7.0

Created a Brewery maven repo, use that for some of the dependencies
This commit is contained in:
Sn0wStorm 2019-01-17 12:30:12 +01:00
parent e1d68a03dc
commit 213ef13c0e
7 changed files with 85 additions and 50 deletions

View File

@ -1,14 +1,14 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[*.yml]
indent_style = spaces
indent_size = 2
trim_trailing_whitespace = true
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[*.yml]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

55
.gitignore vendored
View File

@ -1,27 +1,28 @@
# Eclipse stuff
/.classpath
/.project
/.settings
# NetBeans
/nbproject
/build.xml
# vim
.*.sw[a-p]
# IntelliJ
/.idea
/*.iml
# various other potential build files
/build
/bin
/dist
/*.jardesc
# Mac filesystem dust
.DS_Store
# maven
/target
# Eclipse stuff
/.classpath
/.project
/.settings
# NetBeans
/nbproject
/build.xml
# vim
.*.sw[a-p]
# IntelliJ
/.idea
/*.iml
# various other potential build files
/build
/bin
/dist
/*.jardesc
# Mac filesystem dust
.DS_Store
# maven
/target
/dependency-reduced-pom.xml

17
pom.xml
View File

@ -87,14 +87,16 @@
<url>http://maven.sk89q.com/repo/</url>
</repository>
<repository>
<!-- GriefPrevention -->
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>dre2n-rpo</id>
<url>http://erethon.de/repo/</url>
<id>brewery-repo</id>
<url>https://zebradrive.de/maven/</url>
</repository>
<repository>
<!-- Citadel -->
<id>devoted-repo</id>
<url>https://build.devotedmc.com/plugin/repository/everything/</url>
</repository>
@ -212,13 +214,13 @@
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.9</version>
<version>16.11.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.diddiz</groupId>
<artifactId>logblock</artifactId>
<version>1.13.1-SNAPSHOT</version>
<version>1.13.2-SNAPSHOT-391</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -234,4 +236,11 @@
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>file-repo</id>
<url>file:///var/tmp/MavenRepo</url>
</repository>
</distributionManagement>
</project>

View File

@ -1,5 +1,5 @@
name: Brewery
version: 1.7
version: 1.7.1
main: com.dre.brewery.P
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]

View File

@ -126,7 +126,7 @@ public class Barrel implements InventoryHolder {
}
} catch (Throwable e) {
P.p.errorLog("Failed to Check WorldGuard for Barrel Open Permissions!");
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
P.p.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
e.printStackTrace();
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
@ -143,7 +143,7 @@ public class Barrel implements InventoryHolder {
}
} catch (Throwable e) {
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
P.p.errorLog("Brewery was tested with GriefPrevention 14.5.4");
P.p.errorLog("Brewery was tested with GriefPrevention v14.5 - v16.9");
P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
e.printStackTrace();
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");

View File

@ -17,13 +17,38 @@ import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class WGBarrel7 implements WGBarrel {
private Method getWorldByName;
public WGBarrel7() {
try {
getWorldByName = WorldGuardPlatform.class.getDeclaredMethod("getWorldByName", String.class);
} catch (NoSuchMethodException e) {
getWorldByName = null;
}
}
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
World world = platform.getMatcher().getWorldByName(spigot.getWorld().getName());
World world;
if (getWorldByName == null) {
world = platform.getMatcher().getWorldByName(spigot.getWorld().getName());
} else {
// Workaround for an older Beta Version of WorldGuard 7.0
try {
world = ((World) getWorldByName.invoke(platform, spigot.getWorld().getName()));
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
P.p.msg(player, "Error in WorldGuard");
return false;
}
}
if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled
WorldEditPlugin we = JavaPlugin.getPlugin(WorldEditPlugin.class);
if (new RegionPermissionModel(we.wrapPlayer(player)).mayIgnoreRegionProtection(world)) return true; // Whitelisted cause

View File

@ -30,7 +30,7 @@ public class WGBarrelOld implements WGBarrel {
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
} catch (NoSuchMethodException e) {
P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
P.p.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
e.printStackTrace();
}