Search in sources :

Example 1 with Field

use of net.sacredlabyrinth.Phaed.PreciousStones.field.Field in project MagicPlugin by elBukkit.

the class PreciousStonesAPI method getFieldLocations.

@Nullable
public Map<String, Location> getFieldLocations(Player player) {
    if (preciousStones == null || player == null || !canGetFields)
        return null;
    ForceFieldManager manager = preciousStones.getForceFieldManager();
    if (manager == null)
        return null;
    Collection<Field> fields = manager.getAllPlayerFields(player.getName());
    if (fields == null)
        return null;
    Map<String, Location> fieldLocations = new HashMap<>();
    for (Field field : fields) {
        String fieldName = field.getName();
        String fieldType = field.getSettings().getTitle();
        String fieldOwner = field.getOwner();
        List<String> renters = field.getRenters();
        if (fieldName == null || fieldName.isEmpty()) {
            fieldName = fieldType;
        }
        if (!fieldOwner.equalsIgnoreCase(player.getName())) {
            if (renters.contains(player.getName().toLowerCase())) {
                fieldName = fieldName + ChatColor.GRAY + " (Renting)";
            } else {
                fieldName = fieldName + ChatColor.LIGHT_PURPLE + " (" + fieldOwner + ")";
            }
        }
        fieldLocations.put(fieldName, field.getLocation());
    }
    return fieldLocations;
}
Also used : Field(net.sacredlabyrinth.Phaed.PreciousStones.field.Field) ForceFieldManager(net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager) HashMap(java.util.HashMap) Location(org.bukkit.Location) Nullable(javax.annotation.Nullable)

Example 2 with Field

use of net.sacredlabyrinth.Phaed.PreciousStones.field.Field in project MagicPlugin by elBukkit.

the class PreciousStonesAPI method getFieldLocations.

@Nullable
public List<PlayerWarp> getFieldLocations(String playerName) {
    if (preciousStones == null || playerName == null)
        return null;
    ForceFieldManager manager = preciousStones.getForceFieldManager();
    if (manager == null)
        return null;
    List<PlayerWarp> fieldLocations = new ArrayList<>();
    for (World world : Bukkit.getWorlds()) {
        Collection<Field> fields = manager.getFields(playerName, world);
        if (fields == null)
            continue;
        for (Field field : fields) {
            String fieldName = field.getName();
            String fieldType = field.getSettings().getTitle();
            String fieldOwner = field.getOwner();
            List<String> renters = field.getRenters();
            if (fieldName == null || fieldName.isEmpty()) {
                fieldName = fieldType;
            }
            if (!fieldOwner.equalsIgnoreCase(playerName)) {
                if (renters.contains(playerName.toLowerCase())) {
                    fieldName = fieldName + ChatColor.GRAY + " (Renting)";
                } else {
                    fieldName = fieldName + ChatColor.LIGHT_PURPLE + " (" + fieldOwner + ")";
                }
            }
            fieldLocations.add(new PlayerWarp(fieldName, field.getLocation()));
        }
    }
    return fieldLocations.isEmpty() ? null : fieldLocations;
}
Also used : Field(net.sacredlabyrinth.Phaed.PreciousStones.field.Field) ForceFieldManager(net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager) PlayerWarp(com.elmakers.mine.bukkit.api.protection.PlayerWarp) ArrayList(java.util.ArrayList) World(org.bukkit.World) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)2 Field (net.sacredlabyrinth.Phaed.PreciousStones.field.Field)2 ForceFieldManager (net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager)2 PlayerWarp (com.elmakers.mine.bukkit.api.protection.PlayerWarp)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1