Skip to content

Commit 5d94986

Browse files
committed
Added a bunch of abstraction to add support to WorldGuard 7 (still untested).
1 parent 3c9e724 commit 5d94986

24 files changed

Lines changed: 298 additions & 91 deletions

File tree

Abstraction/pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>ChunkBusterParent</artifactId>
7+
<groupId>codes.biscuit</groupId>
8+
<version>parent</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>Abstraction</artifactId>
13+
<version>Abstraction</version>
14+
<packaging>jar</packaging>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.spigotmc</groupId>
19+
<artifactId>spigot-api</artifactId>
20+
<version>1.8.8-R0.1-SNAPSHOT</version>
21+
<scope>provided</scope>
22+
</dependency>
23+
</dependencies>
24+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package codes.biscuit.chunkbuster.hooks;
2+
3+
import org.bukkit.Chunk;
4+
import org.bukkit.entity.Player;
5+
6+
public interface WorldGuardHook {
7+
8+
boolean checkLocationBreakFlag(Chunk chunk, Player p);
9+
}

ChunkBusterPlugin/pom.xml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>codes.biscuit</groupId>
9+
<artifactId>ChunkBusterPlugin</artifactId>
10+
<packaging>jar</packaging>
11+
<name>ChunkBusterPlugin</name>
12+
<version>2.1.2</version>
13+
14+
<repositories>
15+
<repository>
16+
<id>spigotmc-repo</id>
17+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
18+
</repository>
19+
</repositories>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.spigotmc</groupId>
24+
<artifactId>spigot-api</artifactId>
25+
<version>1.8.8-R0.1-SNAPSHOT</version>
26+
<scope>provided</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>com.massivecraft</groupId>
30+
<artifactId>savage-factions</artifactId>
31+
<version>1.4-BETA-6</version>
32+
<scope>provided</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>com.massivecraft.factions</groupId>
36+
<artifactId>Factions</artifactId>
37+
<version>2.14.0</version>
38+
<scope>provided</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.massivecraft.massivecore</groupId>
42+
<artifactId>MassiveCore</artifactId>
43+
<version>2.14.0</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>net.coreprotect</groupId>
48+
<artifactId>coreprotect</artifactId>
49+
<version>2.12.0</version>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.palmergames</groupId>
54+
<artifactId>Towny</artifactId>
55+
<version>0.93.0.0</version>
56+
<scope>provided</scope>
57+
</dependency>
58+
<dependency>
59+
<artifactId>WG_6</artifactId>
60+
<groupId>codes.biscuit</groupId>
61+
<version>WG_6</version>
62+
<scope>compile</scope>
63+
</dependency>
64+
<dependency>
65+
<artifactId>WG_7</artifactId>
66+
<groupId>codes.biscuit</groupId>
67+
<version>WG_7</version>
68+
<scope>compile</scope>
69+
</dependency>
70+
<dependency>
71+
<artifactId>Abstraction</artifactId>
72+
<groupId>codes.biscuit</groupId>
73+
<version>Abstraction</version>
74+
<scope>compile</scope>
75+
</dependency>
76+
</dependencies>
77+
78+
<build>
79+
<directory>../target</directory>
80+
<finalName>ChunkBuster-v${version}</finalName>
81+
<resources>
82+
<resource>
83+
<targetPath>.</targetPath>
84+
<filtering>true</filtering>
85+
<directory>src/main/resources</directory>
86+
<includes>
87+
<include>plugin.yml</include>
88+
</includes>
89+
</resource>
90+
</resources>
91+
<plugins>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-compiler-plugin</artifactId>
95+
<version>3.8.0</version>
96+
<configuration>
97+
<source>1.8</source>
98+
<target>1.8</target>
99+
</configuration>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.apache.maven.plugins</groupId>
103+
<artifactId>maven-shade-plugin</artifactId>
104+
<version>3.2.1</version>
105+
<executions>
106+
<execution>
107+
<phase>package</phase>
108+
<goals>
109+
<goal>shade</goal>
110+
</goals>
111+
<configuration>
112+
<filters>
113+
<filter>
114+
<artifact>*:*</artifact>
115+
<excludes>
116+
<exclude>META-INF/**</exclude>
117+
</excludes>
118+
</filter>
119+
</filters>
120+
</configuration>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
</project>

src/main/java/codes/biscuit/chunkbuster/ChunkBuster.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/ChunkBuster.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package codes.biscuit.chunkbuster;
22

3-
import org.bukkit.Bukkit;
4-
import org.bukkit.plugin.java.JavaPlugin;
53
import codes.biscuit.chunkbuster.commands.ChunkBusterCommand;
64
import codes.biscuit.chunkbuster.events.OtherEvents;
75
import codes.biscuit.chunkbuster.events.PlayerEvents;
86
import codes.biscuit.chunkbuster.hooks.HookUtils;
97
import codes.biscuit.chunkbuster.utils.ConfigValues;
108
import codes.biscuit.chunkbuster.utils.Utils;
9+
import org.bukkit.Bukkit;
10+
import org.bukkit.plugin.java.JavaPlugin;
1111

1212
public class ChunkBuster extends JavaPlugin {
1313

src/main/java/codes/biscuit/chunkbuster/commands/ChunkBusterCommand.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/commands/ChunkBusterCommand.java

File renamed without changes.

src/main/java/codes/biscuit/chunkbuster/events/OtherEvents.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/events/OtherEvents.java

File renamed without changes.

src/main/java/codes/biscuit/chunkbuster/events/PlayerEvents.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/events/PlayerEvents.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void onChunkBusterPlace(BlockPlaceEvent e) {
3939
if (e.getItemInHand().getType().equals(main.getConfigValues().getChunkBusterMaterial()) && e.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LURE) > 0) {
4040
e.setCancelled(true);
4141
Player p = e.getPlayer();
42+
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("Player-Stats.View-Stats").replace("%wins%", String.valueOf(main.getConfig().getInt("Players." + p.getUniqueId() + ".wins")))));
4243
if (p.hasPermission("chunkbuster.use")) {
4344
if (main.getHookUtils().hasFaction(p)) {
4445
if (main.getHookUtils().checkRole(p)) {

src/main/java/codes/biscuit/chunkbuster/hooks/CoreProtectHook.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/hooks/CoreProtectHook.java

File renamed without changes.

src/main/java/codes/biscuit/chunkbuster/hooks/FactionsUUIDHook.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/hooks/FactionsUUIDHook.java

File renamed without changes.

src/main/java/codes/biscuit/chunkbuster/hooks/HookUtils.java renamed to ChunkBusterPlugin/src/main/java/codes/biscuit/chunkbuster/hooks/HookUtils.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package codes.biscuit.chunkbuster.hooks;
22

33
import codes.biscuit.chunkbuster.ChunkBuster;
4+
import org.bukkit.Bukkit;
45
import org.bukkit.Location;
56
import org.bukkit.Material;
67
import org.bukkit.entity.Player;
@@ -29,12 +30,18 @@ public HookUtils(ChunkBuster main) {
2930
enabledHooks.put(HookType.FACTIONSUUID, new FactionsUUIDHook(main));
3031
}
3132
if (pm.getPlugin("WorldGuard") != null) {
32-
main.getLogger().info("Hooked into WorldGuard");
33-
enabledHooks.put(HookType.WORLDGUARD, new WorldGuardHook());
33+
String pluginVersion = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard").getDescription().getVersion();
34+
if (pluginVersion.startsWith("7") && pm.getPlugin("WorldEdit") != null) {
35+
enabledHooks.put(HookType.WORLDGUARD, new WorldGuard_7());
36+
main.getLogger().info("Hooked into WorldGuard 7");
37+
} else if (pluginVersion.startsWith("6")) {
38+
enabledHooks.put(HookType.WORLDGUARD, new WorldGuard_6());
39+
main.getLogger().info("Hooked into WorldGuard 6");
40+
}
3441
}
3542
if (pm.getPlugin("Towny") != null) {
3643
main.getLogger().info("Hooked into Towny");
37-
enabledHooks.put(HookType.TOWNY, new WorldGuardHook());
44+
enabledHooks.put(HookType.TOWNY, new TownyHook());
3845
}
3946
if (pm.getPlugin("CoreProtect") != null) {
4047
main.getLogger().info("Hooked into CoreProtect");

0 commit comments

Comments
 (0)