Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions src/me/crafter/mc/lockettepro/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.palmergames.bukkit.towny.object.Nation;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
Expand All @@ -34,6 +39,7 @@ public class Dependency {
protected static Plugin residence = null;
protected static Plugin towny = null;
protected static Plugin factions = null;
protected static boolean factionsuuid = false;
protected static Plugin vault = null;
protected static Permission permission = null;
protected static Plugin askyblock = null;
Expand All @@ -54,6 +60,9 @@ public Dependency(Plugin plugin){
towny = plugin.getServer().getPluginManager().getPlugin("Towny");
// Factions
factions = plugin.getServer().getPluginManager().getPlugin("Factions");
if (factions != null) {
factionsuuid = (extractVersion(factions.getDescription().getVersion()) == 1.6);
}
// Vault
vault = plugin.getServer().getPluginManager().getPlugin("Vault");
if (vault != null){
Expand Down Expand Up @@ -96,18 +105,33 @@ public static boolean isProtectedFrom(Block block, Player player){
} catch (Exception e) {}
}
if (factions != null){
try {
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (faction != null && !faction.isNone()){
MPlayer mplayer = MPlayer.get(player);
if (mplayer != null && !mplayer.isOverriding()){
Faction playerfaction = mplayer.getFaction();
if (faction != playerfaction){
return true;
if (factionsuuid){
try{
Faction faction = Board.getFactionAt(new FLocation(block));
if (faction != null && !faction.isNone()){
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
if (fplayer != null && !fplayer.isAdminBypassing()){
Faction playerfaction = fplayer.getFaction();
if (faction != playerfaction){
return true;
}
}
}
}
} catch (Exception e){}
} catch (Exception e){}
}else{
try{
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (faction != null && !faction.isNone()){
MPlayer mplayer = MPlayer.get(player);
if (mplayer != null && !mplayer.isOverriding()){
Faction playerfaction = mplayer.getFaction();
if (faction != playerfaction){
return true;
}
}
}
} catch (Exception e){}
}
}
if (askyblock != null){
try {
Expand Down Expand Up @@ -184,5 +208,11 @@ public static boolean isScoreboardTeamOf(String line, Player player){
}
return false;
}


public static double extractVersion(String version){
version = version.replaceAll("[^0-9//.]", "");
String[] split = version.split("\\.");
if (split.length > 1) version = split[0] + "." + split[1];
return Double.parseDouble(version);
}
}