forked from MagicBane/Server
Helper method for slot lookup added.
This commit is contained in:
@@ -27,6 +27,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public enum BuildingManager {
|
public enum BuildingManager {
|
||||||
@@ -36,6 +37,17 @@ public enum BuildingManager {
|
|||||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations;
|
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations;
|
||||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations;
|
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations;
|
||||||
|
|
||||||
|
public static int getAvailableSlot(Building building) {
|
||||||
|
|
||||||
|
int numOfSlots = _slotLocations.get(building.meshUUID).size();
|
||||||
|
|
||||||
|
for (int i = 1; i < numOfSlots; i++) {
|
||||||
|
if (!building.getHirelings().containsValue(i))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean playerCanManage(PlayerCharacter player, Building building) {
|
public static boolean playerCanManage(PlayerCharacter player, Building building) {
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user