Skip to content

Commit 0f537ed

Browse files
committed
Remove local dependencies
I am not going to maintain support for things that require me to do additional manual work and reduce the ability of others to contribute. While pretty much all of the various supported plugins are open source, anything requiring manual setup ruins the point of using a tool like Maven for dependency management. - Removed Feudal support. - Feudal is inactive in a buggy state on 1.13, and previous versions contained a force-op. - Removed Kingdoms and UltimateClaims support. - In addition to the lack of build system support, Songoda appears to have questionable business practices. If you want support for their plugins, you can ask their staff to add their own PluginHooks to Regionerator. At worst, my old hooks are always available via version control and can be copied verbatim. - Removed LandLord support. - LandLord has not been updated since Minecraft 1.8 and does not have build system support. - Civs, Residence, and MassiveCraft Factions are only available via reflection as they are not available via a build system. FactionsUUID already was only supported via reflection.
1 parent 8e2cee1 commit 0f537ed

18 files changed

+134
-263
lines changed

lib/Factions.jar

-538 KB
Binary file not shown.

lib/Landlord.jar

-85.5 KB
Binary file not shown.

lib/MassiveCore.jar

-2.33 MB
Binary file not shown.

lib/Towny.jar

-702 KB
Binary file not shown.

lib/civs.jar

-3.5 MB
Binary file not shown.

pom.xml

Lines changed: 20 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>com.github.jikoo</groupId>
44
<artifactId>regionerator</artifactId>
55
<name>Regionerator</name>
6-
<version>2.1.3-SNAPSHOT</version>
6+
<version>2.2.0</version>
77

88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.sk89q.worldguard</groupId>
3939
<artifactId>worldguard-bukkit</artifactId>
40-
<version>7.0.4-SNAPSHOT</version>
40+
<version>7.0.4</version>
4141
<scope>provided</scope>
4242
<exclusions>
4343
<exclusion>
@@ -50,24 +50,6 @@
5050
</exclusion>
5151
</exclusions>
5252
</dependency>
53-
<dependency>
54-
<groupId>com.github.TechFortress</groupId>
55-
<artifactId>GriefPrevention</artifactId>
56-
<version>16.15.0</version>
57-
<scope>provided</scope>
58-
<exclusions>
59-
<exclusion>
60-
<groupId>com.sk89q.worldguard</groupId>
61-
<artifactId>worldguard-legacy</artifactId>
62-
</exclusion>
63-
</exclusions>
64-
</dependency>
65-
<dependency>
66-
<groupId>com.github.marcelo-mason</groupId>
67-
<artifactId>PreciousStones</artifactId>
68-
<version>24e3d4bf67</version>
69-
<scope>provided</scope>
70-
</dependency>
7153
<dependency>
7254
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
7355
<artifactId>RedProtect-Core</artifactId>
@@ -80,82 +62,37 @@
8062
<version>7.7.2</version>
8163
<scope>provided</scope>
8264
</dependency>
65+
<!-- JitPack -->
8366
<dependency>
84-
<groupId>com.github.bloodmc</groupId>
85-
<artifactId>GriefDefenderAPI</artifactId>
86-
<version>33bd795ad4</version>
67+
<groupId>com.github.angeschossen</groupId>
68+
<artifactId>LandsAPI</artifactId>
69+
<version>4.9.4</version>
8770
<scope>provided</scope>
8871
</dependency>
8972
<dependency>
90-
<groupId>com.massivecraft</groupId>
91-
<artifactId>Factions</artifactId>
92-
<version>2.8.1</version>
93-
<scope>system</scope>
94-
<systemPath>${project.basedir}/lib/Factions.jar</systemPath>
73+
<groupId>com.github.elBukkit</groupId>
74+
<artifactId>PreciousStones</artifactId>
75+
<version>-SNAPSHOT</version>
76+
<scope>provided</scope>
9577
</dependency>
9678
<dependency>
97-
<groupId>com.massivecraft</groupId>
98-
<artifactId>MassiveCore</artifactId>
99-
<version>2.8.1</version>
100-
<scope>system</scope>
101-
<systemPath>${project.basedir}/lib/MassiveCore.jar</systemPath>
79+
<groupId>com.github.bloodmc</groupId>
80+
<artifactId>GriefDefenderAPI</artifactId>
81+
<version>-SNAPSHOT</version>
82+
<scope>provided</scope>
10283
</dependency>
10384
<dependency>
104-
<groupId>com.jcdesimp</groupId>
105-
<artifactId>Landlord</artifactId>
106-
<version>1.3</version>
107-
<scope>system</scope>
108-
<systemPath>${project.basedir}/lib/Landlord.jar</systemPath>
85+
<groupId>com.github.TechFortress</groupId>
86+
<artifactId>GriefPrevention</artifactId>
87+
<version>16.15.0</version>
88+
<scope>provided</scope>
10989
</dependency>
11090
<dependency>
111-
<groupId>com.palmergames</groupId>
91+
<groupId>com.github.TownyAdvanced</groupId>
11292
<artifactId>Towny</artifactId>
113-
<version>0.91.4.3</version>
114-
<scope>system</scope>
115-
<systemPath>${project.basedir}/lib/Towny.jar</systemPath>
116-
</dependency>
117-
<dependency>
118-
<groupId>org.redcastlemedia.multitallented</groupId>
119-
<artifactId>civs</artifactId>
120-
<version>1.6.7</version>
121-
<scope>system</scope>
122-
<systemPath>${project.basedir}/lib/civs.jar</systemPath>
123-
</dependency>
124-
<!-- Premium dependencies -->
125-
<dependency>
126-
<groupId>org.kingdoms</groupId>
127-
<artifactId>Kingdoms</artifactId>
128-
<version>7.9.5</version>
129-
<scope>system</scope>
130-
<systemPath>${project.basedir}/premium/Kingdoms.jar</systemPath>
131-
</dependency>
132-
<dependency>
133-
<groupId>us.forseth11</groupId>
134-
<artifactId>Feudal</artifactId>
135-
<version>Lite-1.0</version>
136-
<scope>system</scope>
137-
<systemPath>${project.basedir}/premium/FeudalLite.jar</systemPath>
138-
</dependency>
139-
<dependency>
140-
<groupId>com.bekvon.bukkit</groupId>
141-
<artifactId>Residence</artifactId>
142-
<version>4.5.13.3</version>
143-
<scope>system</scope>
144-
<systemPath>${project.basedir}/premium/Residence.jar</systemPath>
145-
</dependency>
146-
<dependency>
147-
<groupId>com.github.angeschossen</groupId>
148-
<artifactId>LandsAPI</artifactId>
149-
<version>4.9.4</version>
93+
<version>0.96.2.19</version>
15094
<scope>provided</scope>
15195
</dependency>
152-
<dependency>
153-
<groupId>com.songoda</groupId>
154-
<artifactId>UltimateClaims</artifactId>
155-
<version>1.1.0</version>
156-
<scope>system</scope>
157-
<systemPath>${project.basedir}/premium/UltimateClaims.jar</systemPath>
158-
</dependency>
15996
</dependencies>
16097

16198
<repositories>

src/main/java/com/github/jikoo/regionerator/Regionerator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,19 @@ public void reloadFeatures() {
136136
if (!getConfig().getBoolean("hooks." + hookName, true)) {
137137
continue;
138138
}
139+
Class<?> clazz;
139140
try {
140-
Class<?> clazz = Class.forName("com.github.jikoo.regionerator.hooks." + hookName + "Hook");
141+
clazz = Class.forName("com.github.jikoo.regionerator.hooks." + hookName + "Hook");
141142
if (!Hook.class.isAssignableFrom(clazz)) {
142143
// What.
143144
continue;
144145
}
146+
} catch (ClassNotFoundException e) {
147+
// No hook by the name specified.
148+
continue;
149+
}
150+
151+
try {
145152
Hook hook = (Hook) clazz.getDeclaredConstructor().newInstance();
146153
if (!hook.areDependenciesPresent()) {
147154
debug(DebugLevel.LOW, () -> String.format("Dependencies not found for %s hook, skipping.", hookName));
@@ -154,8 +161,6 @@ public void reloadFeatures() {
154161
getLogger().warning("Protection hook for " + hookName + " failed usability check! Deletion is paused.");
155162
setPaused(true);
156163
}
157-
} catch (ClassNotFoundException e) {
158-
getLogger().severe("No hook found for " + hookName + "! Please request compatibility!");
159164
} catch (ReflectiveOperationException e) {
160165
getLogger().log(Level.SEVERE, "Unable to enable hook for " + hookName + "! Deletion is paused.", e);
161166
setPaused(true);
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.github.jikoo.regionerator.hooks;
22

33
import com.github.jikoo.regionerator.Coords;
4+
import java.lang.reflect.Constructor;
5+
import java.lang.reflect.Method;
6+
import java.util.Collection;
47
import org.bukkit.Location;
58
import org.bukkit.World;
6-
import org.redcastlemedia.multitallented.civs.regions.RegionManager;
7-
import org.redcastlemedia.multitallented.civs.regions.RegionPoints;
89

910
/**
1011
* PluginHook for <a href=https://www.spigotmc.org/resources/civs.67350/>Civs</a>.
@@ -13,15 +14,28 @@
1314
*/
1415
public class CivsHook extends PluginHook {
1516

16-
public CivsHook() {
17+
private final Method regionManagerSingleton, regionManagerGetRegionsXYZ;
18+
private final Constructor<?> regionPointsConstructor;
19+
20+
public CivsHook() throws ReflectiveOperationException {
1721
super("Civs");
22+
23+
Class<?> regionManagerClass = Class.forName("org.redcastlemedia.multitallented.civs.regions.RegionManager");
24+
regionManagerSingleton = regionManagerClass.getDeclaredMethod("getInstance");
25+
Class<?> regionPointsClass = Class.forName("org.redcastlemedia.multitallented.civs.regions.RegionPoints");
26+
regionManagerGetRegionsXYZ = regionManagerClass.getDeclaredMethod("getRegionsXYZ", Location.class, regionPointsClass, boolean.class);
27+
regionPointsConstructor = regionPointsClass.getConstructor(int.class, int.class, int.class, int.class, int.class, int.class);
1828
}
1929

2030
@Override
2131
public boolean isChunkProtected(World chunkWorld, int chunkX, int chunkZ) {
22-
return RegionManager.getInstance().getRegionsXYZ(
23-
new Location(chunkWorld, Coords.chunkToBlock(chunkX), 0, Coords.chunkToBlock(chunkZ)),
24-
new RegionPoints(16, 0, 255, 0, 16, 0), false).size() > 0;
32+
try {
33+
return ((Collection<?>) regionManagerGetRegionsXYZ.invoke(regionManagerSingleton.invoke(null),
34+
new Location(chunkWorld, Coords.chunkToBlock(chunkX), 0, Coords.chunkToBlock(chunkZ)),
35+
regionPointsConstructor.newInstance(16, 0, 255, 0, 16, 0), false)).size() > 0;
36+
} catch (ReflectiveOperationException e) {
37+
throw new RuntimeException(e);
38+
}
2539
}
2640

2741
}
Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
package com.github.jikoo.regionerator.hooks;
22

33
import java.lang.reflect.Constructor;
4-
import java.lang.reflect.InvocationTargetException;
54
import java.lang.reflect.Method;
6-
7-
import com.massivecraft.factions.entity.BoardColl;
8-
import com.massivecraft.factions.entity.Faction;
9-
import com.massivecraft.massivecore.ps.PS;
10-
115
import org.bukkit.World;
126

137
/**
@@ -18,51 +12,56 @@
1812
*/
1913
public class FactionsHook extends PluginHook {
2014

21-
private boolean isFactionsUUID;
22-
private Object board;
23-
private Constructor<?> factionLocationConstructor;
24-
private Method boardGetFaction, factionIsWilderness;
15+
private Method boardSingleton, boardGetFaction, factionIsWilderness;
16+
private Constructor<?> locationConstructor = null;
17+
private Method locationValueOf = null;
2518

26-
public FactionsHook() {
19+
public FactionsHook() throws ReflectiveOperationException {
2720
super("Factions");
21+
22+
// Set up FactionsUUID.
2823
try {
2924
Class<?> boardClazz = Class.forName("com.massivecraft.factions.Board");
30-
Method boardSingleton = boardClazz.getMethod("getInstance");
31-
this.board = boardSingleton.invoke(null);
25+
boardSingleton = boardClazz.getMethod("getInstance");
3226
Class<?> factionLocationClazz = Class.forName("com.massivecraft.factions.FLocation");
33-
this.boardGetFaction = boardClazz.getMethod("getFactionAt", factionLocationClazz);
34-
this.factionLocationConstructor = factionLocationClazz.getConstructor(String.class, int.class, int.class);
27+
boardGetFaction = boardClazz.getMethod("getFactionAt", factionLocationClazz);
28+
locationConstructor = factionLocationClazz.getConstructor(String.class, int.class, int.class);
3529
Class<?> factionClazz = Class.forName("com.massivecraft.factions.Faction");
36-
this.factionIsWilderness = factionClazz.getMethod("isWilderness");
37-
this.isFactionsUUID = true;
38-
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException
39-
| IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
40-
this.isFactionsUUID = false;
30+
factionIsWilderness = factionClazz.getMethod("isWilderness");
31+
32+
// FactionsUUID set up successfully, we're done.
33+
return;
34+
} catch (ReflectiveOperationException e) {
35+
// Eat first reflection error - throw on second.
4136
}
37+
38+
// MassiveCraft's (discontinued) Factions
39+
Class<?> massiveBoard = Class.forName("com.massivecraft.factions.entity.BoardColl");
40+
boardSingleton = massiveBoard.getDeclaredMethod("get");
41+
Class<?> massivePS = Class.forName("com.massivecraft.massivecore.ps.PS");
42+
boardGetFaction = massiveBoard.getDeclaredMethod("getFactionAt", massivePS);
43+
locationValueOf = massivePS.getDeclaredMethod("valueOf", String.class, int.class, int.class);
44+
Class<?> massiveFaction = Class.forName("com.massivecraft.factions.entity.Faction");
45+
factionIsWilderness = massiveFaction.getDeclaredMethod("isNone");
46+
4247
}
4348

4449
@Override
4550
public boolean isChunkProtected(World chunkWorld, int chunkX, int chunkZ) {
46-
if (isFactionsUUID) {
47-
return isFactionsUUIDProtected(chunkWorld, chunkX, chunkZ);
51+
try {
52+
Object faction = boardGetFaction.invoke(boardSingleton.invoke(null),
53+
getFactionLocation(chunkWorld.getName(), chunkX, chunkZ));
54+
return faction != null && !(boolean) factionIsWilderness.invoke(faction);
55+
} catch (ReflectiveOperationException e) {
56+
throw new RuntimeException(e);
4857
}
49-
return isFactionsProtected(chunkWorld, chunkX, chunkZ);
50-
}
51-
52-
private boolean isFactionsProtected(World chunkWorld, int chunkX, int chunkZ) {
53-
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(chunkWorld.getName(), chunkX, chunkZ));
54-
return faction != null && !faction.isNone();
5558
}
5659

57-
private boolean isFactionsUUIDProtected(World chunkWorld, int chunkX, int chunkZ) {
58-
try {
59-
Object factionLocation = factionLocationConstructor.newInstance(chunkWorld.getName(), chunkX, chunkZ);
60-
Object faction = boardGetFaction.invoke(board, factionLocation);
61-
return faction != null && !(boolean) factionIsWilderness.invoke(faction);
62-
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
63-
| InvocationTargetException e) {
64-
return false;
60+
private Object getFactionLocation(String worldName, int chunkX, int chunkZ) throws ReflectiveOperationException {
61+
if (locationConstructor != null) {
62+
return locationConstructor.newInstance(worldName, chunkX, chunkZ);
6563
}
64+
return locationValueOf.invoke(null, worldName, chunkX, chunkZ);
6665
}
6766

6867
}

src/main/java/com/github/jikoo/regionerator/hooks/FeudalHook.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)