use of net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager 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;
}
use of net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager in project MagicPlugin by elBukkit.
the class PreciousStonesAPI method createField.
public boolean createField(Location location, Player player) {
ForceFieldManager manager = preciousStones.getForceFieldManager();
Block targetBlock = location.getBlock();
BlockPlaceEvent event = new BlockPlaceEvent(targetBlock, targetBlock.getState(), targetBlock.getRelative(BlockFace.DOWN), new ItemStack(targetBlock.getType(), CompatibilityLib.getDeprecatedUtils().getData(targetBlock)), player, true, EquipmentSlot.HAND);
manager.add(location.getBlock(), player, event);
return !event.isCancelled();
}
use of net.sacredlabyrinth.Phaed.PreciousStones.managers.ForceFieldManager 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;
}
Aggregations