Skip to content

Commit

Permalink
Use public build of Residence instead of reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicallyCoded committed Jan 4, 2024
1 parent 8598972 commit 78e6b12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,13 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>-->
<!-- CAN BE UNCOMMENTED IF YOU HAVE ACCESS TO THE PLUGIN -->
<!-- Private Repoed -->
<!-- This is uploaded to our private repo on https://repo.ronanplugins.com -->
<!--<dependency>
<groupId>com.ronanplugins</groupId>
<!-- Provided by repo: devmart-public -->
<dependency>
<groupId>com.bekvon.bukkit.residence</groupId>
<artifactId>Residence</artifactId>
<version>4.9.1.9</version>
<version>5.1.4.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>-->
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

public class RTP_Residence implements RegionPluginCheck {

// NOT TESTED (2.14.3)
// Residence (v4.9.1.9)
// NOT TESTED (3.6.12)
// Residence (v5.1.4.1)
// https://www.spigotmc.org/resources/residence.11480/
public boolean check(Location loc) {
boolean result = true;
if (REGIONPLUGINS.RESIDENCE.isEnabled())
try {
// Using reflection
Class<?> residenceClass = Class.forName("com.bekvon.bukkit.residence.api.ResidenceApi");
Object residenceManager = residenceClass.getMethod("getResidenceManager").invoke(null);
Class<?> residenceManagerClass = residenceManager.getClass();
Object claim = residenceManagerClass.getMethod("getByLoc", Location.class).invoke(residenceManager, loc);
// Don't import to avoid class loader issues
com.bekvon.bukkit.residence.Residence instance = com.bekvon.bukkit.residence.Residence.getInstance();
com.bekvon.bukkit.residence.protection.ClaimedResidence claim = instance.getResidenceManagerAPI().getByLoc(loc);
result = claim == null;
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 78e6b12

Please sign in to comment.