mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-19 16:55:27 +01:00
Restored compatibility with WorldGuard 5.9
AreaShop will detect if you use a 5.x version or something else, with 5.x it will add players to the regions by name, and otherwise by UUID. AreaShop will always save UUID's itself, so future upgrading to higher WorldGuard versions will be no problem.
This commit is contained in:
parent
9baf0b7eec
commit
9da31fed1f
@ -42,7 +42,6 @@ import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class FileManager {
|
||||
@ -587,8 +586,19 @@ public class FileManager {
|
||||
RegionManager manager = plugin.getWorldGuard().getRegionManager(bukkitWorld);
|
||||
if(manager != null) {
|
||||
try {
|
||||
String version = plugin.getWorldGuard().getDescription().getVersion();
|
||||
AreaShop.debug("WorldGuard version: " + version);
|
||||
// Detect WorldGuard version 5
|
||||
if(version.startsWith("5.")) {
|
||||
//AreaShop.debug(" Saved the old way");
|
||||
manager.save();
|
||||
}
|
||||
// Assume a newer version
|
||||
else {
|
||||
//AreaShop.debug(" Saved the new way");
|
||||
manager.saveChanges();
|
||||
} catch(StorageException e) {
|
||||
}
|
||||
} catch(Exception e) {
|
||||
plugin.getLogger().warning("WorldGuard regions in world " + world + " could not be saved");
|
||||
}
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ public abstract class GeneralRegion {
|
||||
// Split the string and parse all values
|
||||
String[] names = value.split(", ");
|
||||
DefaultDomain members = region.getMembers();
|
||||
members.clear();
|
||||
members.removeAll();
|
||||
for(String member : names) {
|
||||
if(member != null && !member.isEmpty()) {
|
||||
// Check for groups
|
||||
@ -1026,18 +1026,30 @@ public abstract class GeneralRegion {
|
||||
uuid = null;
|
||||
}
|
||||
if(uuid != null) {
|
||||
// Detect WorldGuard version 5
|
||||
if(plugin.getWorldGuard().getDescription().getVersion().startsWith("5.")) {
|
||||
AreaShop.debug(" Added player by name");
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
|
||||
if(offlinePlayer != null) {
|
||||
members.addPlayer(offlinePlayer.getName());
|
||||
}
|
||||
}
|
||||
// Assume a newer version
|
||||
else {
|
||||
AreaShop.debug(" Added player by UUID");
|
||||
members.addPlayer(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
region.setMembers(members);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + members.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("owners")) {
|
||||
// Split the string and parse all values
|
||||
String[] names = value.split(", ");
|
||||
DefaultDomain owners = region.getOwners();
|
||||
owners.clear();
|
||||
owners.removeAll();
|
||||
for(String owner : names) {
|
||||
if(owner != null && !owner.isEmpty()) {
|
||||
// Check for groups
|
||||
@ -1059,11 +1071,23 @@ public abstract class GeneralRegion {
|
||||
uuid = null;
|
||||
}
|
||||
if(uuid != null) {
|
||||
// Detect WorldGuard version 5
|
||||
if(plugin.getWorldGuard().getDescription().getVersion().startsWith("5.")) {
|
||||
//AreaShop.debug(" Added player by name");
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
|
||||
if(offlinePlayer != null) {
|
||||
owners.addPlayer(offlinePlayer.getName());
|
||||
}
|
||||
}
|
||||
// Assume a newer version
|
||||
else {
|
||||
//AreaShop.debug(" Added player by UUID");
|
||||
owners.addPlayer(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
region.setOwners(owners);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + owners.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("priority")) {
|
||||
|
Loading…
Reference in New Issue
Block a user