Skip to content

Commit

Permalink
Fix older Builds of WorldGuard 7.0
Browse files Browse the repository at this point in the history
Created a Brewery maven repo, use that for some of the dependencies
  • Loading branch information
Sn0wStorm committed Jan 17, 2019
1 parent e1d68a0 commit 213ef13
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 50 deletions.
28 changes: 14 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -234,4 +236,11 @@
<scope>compile</scope>
</dependency>
</dependencies>

<distributionManagement>
<repository>
<id>file-repo</id>
<url>file:///var/tmp/MavenRepo</url>
</repository>
</distributionManagement>
</project>
2 changes: 1 addition & 1 deletion resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/com/dre/brewery/Barrel.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
}
} 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!");
Expand All @@ -143,7 +143,7 @@ public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
}
} 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!");
Expand Down
27 changes: 26 additions & 1 deletion src/com/dre/brewery/integration/WGBarrel7.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,38 @@
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
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/brewery/integration/WGBarrelOld.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public WGBarrelOld() {
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();
}
Expand Down

0 comments on commit 213ef13

Please sign in to comment.