mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
soft depends seperated from main RTP class
This commit is contained in:
parent
77a94812d5
commit
211d3609d4
@ -26,6 +26,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class RTP {
|
||||
|
||||
private final RTPTeleport teleport = new RTPTeleport();
|
||||
private final RTPSoftDepends softDepends = new RTPSoftDepends();
|
||||
//Cache
|
||||
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
||||
public HashMap<String, String> overriden = new HashMap<>();
|
||||
@ -362,20 +363,8 @@ public class RTP {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private boolean checkDepends(Location loc) {
|
||||
try {
|
||||
if (getPl().getSettings().getsDepends().isWorldguard()) {
|
||||
WorldGuardPlugin plugin = WGBukkit.getPlugin();
|
||||
RegionContainer container = plugin.getRegionContainer();
|
||||
RegionManager regions = container.get(loc.getWorld());
|
||||
// Check to make sure that "regions" is not null
|
||||
return regions.getApplicableRegions(loc).size() == 0;
|
||||
}
|
||||
return !getPl().getSettings().getsDepends().isGriefprevention() || GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return true;
|
||||
}
|
||||
return softDepends.checkLocation(loc);
|
||||
}
|
||||
|
||||
// Bad blocks, or bad biome
|
||||
|
@ -0,0 +1,46 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.WGBukkit;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class RTPSoftDepends { //Safe locations depending on enabled dependencies
|
||||
|
||||
boolean checkLocation(Location loc) {
|
||||
boolean worldguard = getWorlguard(loc);
|
||||
boolean griefPrevention = getGriefprevention(loc);
|
||||
return worldguard && griefPrevention;
|
||||
}
|
||||
|
||||
private boolean getWorlguard(Location loc) {
|
||||
if (getPl().getSettings().getsDepends().isWorldguard())
|
||||
try {
|
||||
WorldGuardPlugin plugin = WGBukkit.getPlugin();
|
||||
RegionContainer container = plugin.getRegionContainer();
|
||||
RegionManager regions = container.get(loc.getWorld());
|
||||
// Check to make sure that "regions" is not null
|
||||
return (regions != null ? regions.getApplicableRegions(loc).size() : 0) == 0;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean getGriefprevention(Location loc) {
|
||||
if (getPl().getSettings().getsDepends().isGriefprevention())
|
||||
try {
|
||||
return GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Main getPl() {
|
||||
return Main.getInstance();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user