-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
73 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/me/usainsrht/uhomes/claim_interfaces/ClaimAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package me.usainsrht.uhomes.claim_interfaces; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
|
||
public interface ClaimAPI { | ||
|
||
boolean canEnter(Player player, Location location); | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/me/usainsrht/uhomes/claim_interfaces/GriefPrevention.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package me.usainsrht.uhomes.claim_interfaces; | ||
|
||
import me.ryanhamshire.GriefPrevention.Claim; | ||
import me.ryanhamshire.GriefPrevention.ClaimPermission; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
|
||
public class GriefPrevention implements ClaimAPI { | ||
|
||
private me.ryanhamshire.GriefPrevention.GriefPrevention instance; | ||
|
||
public GriefPrevention(me.ryanhamshire.GriefPrevention.GriefPrevention instance) { | ||
this.instance = instance; | ||
} | ||
|
||
@Override | ||
public boolean canEnter(Player player, Location location) { | ||
Claim claim = instance.dataStore.getClaimAt(location, true, null); | ||
if (claim == null) return true; | ||
return claim.hasExplicitPermission(player, ClaimPermission.Manage); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/me/usainsrht/uhomes/claim_interfaces/Lands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package me.usainsrht.uhomes.claim_interfaces; | ||
|
||
import me.angeschossen.lands.api.LandsIntegration; | ||
import me.angeschossen.lands.api.land.Area; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
|
||
public class Lands implements ClaimAPI { | ||
|
||
private LandsIntegration landsIntegration; | ||
|
||
public Lands(LandsIntegration landsIntegration) { | ||
this.landsIntegration = landsIntegration; | ||
} | ||
|
||
@Override | ||
public boolean canEnter(Player player, Location location) { | ||
Area area = landsIntegration.getArea(location); | ||
if (area == null) return true; | ||
return (area.isTrusted(player.getUniqueId())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 8 additions & 25 deletions
33
src/main/java/me/usainsrht/uhomes/manager/ClaimManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,28 @@ | ||
package me.usainsrht.uhomes.manager; | ||
|
||
import me.angeschossen.lands.api.LandsIntegration; | ||
import me.angeschossen.lands.api.land.Area; | ||
import me.ryanhamshire.GriefPrevention.Claim; | ||
import me.ryanhamshire.GriefPrevention.ClaimPermission; | ||
import me.ryanhamshire.GriefPrevention.GriefPrevention; | ||
import me.usainsrht.uhomes.UHomes; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import me.usainsrht.uhomes.claim_interfaces.ClaimAPI; | ||
|
||
public class ClaimManager { | ||
|
||
private UHomes plugin; | ||
private Object claimAPI; | ||
private ClaimAPI claimAPI; | ||
|
||
public ClaimManager(UHomes plugin, Object claimAPI) { | ||
public ClaimManager(UHomes plugin, ClaimAPI claimAPI) { | ||
this.plugin = plugin; | ||
this.claimAPI = claimAPI; | ||
} | ||
|
||
public void setClaimAPI(ClaimAPI claimAPI) { | ||
this.claimAPI = claimAPI; | ||
} | ||
|
||
public UHomes getPlugin() { | ||
return plugin; | ||
} | ||
|
||
public Object getClaimAPI() { | ||
public ClaimAPI getClaimAPI() { | ||
return claimAPI; | ||
} | ||
|
||
public boolean canEnter(Player player, Location location) { | ||
if (claimAPI == null) return true; | ||
//todo stops code silently when class is undefined | ||
else if (claimAPI instanceof LandsIntegration api) { | ||
Area area = api.getArea(location); | ||
if (area == null) return true; | ||
return (area.isTrusted(player.getUniqueId())); | ||
} else if (claimAPI instanceof GriefPrevention api) { | ||
Claim claim = api.dataStore.getClaimAt(location, true, null); | ||
if (claim == null) return true; | ||
return claim.hasExplicitPermission(player, ClaimPermission.Manage); | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters