Search in sources :

Example 1 with MassiveMap

use of com.massivecraft.massivecore.collections.MassiveMap in project MassiveCore by MassiveCraft.

the class EngineMassiveCoreGank method getPlayerQuotients.

public Map<Player, Double> getPlayerQuotients(Entity entity) {
    // Get PlayerDamages
    Map<Player, Double> playerDamages = getPlayerDamages(entity);
    // Calculate Total
    double total = 0;
    for (Double damage : playerDamages.values()) {
        total += damage;
    }
    // Create Ret
    Map<Player, Double> ret = new MassiveMap<>(playerDamages.size());
    // Fill Ret
    for (Entry<Player, Double> playerDamage : playerDamages.entrySet()) {
        Player player = playerDamage.getKey();
        Double damage = playerDamage.getValue();
        ret.put(player, damage / total);
    }
    // Return Ret
    return ret;
}
Also used : Player(org.bukkit.entity.Player) MassiveMap(com.massivecraft.massivecore.collections.MassiveMap)

Example 2 with MassiveMap

use of com.massivecraft.massivecore.collections.MassiveMap in project MassiveCore by MassiveCraft.

the class Accessor method getFieldMap.

public static Map<String, Field> getFieldMap(Class<?> clazz) {
    Map<String, Field> ret = new MassiveMap<>();
    for (Field field : getFieldList(clazz)) {
        if (Modifier.isTransient(field.getModifiers()))
            continue;
        if (Modifier.isFinal(field.getModifiers()))
            continue;
        String fieldName = field.getName();
        if (ret.containsKey(fieldName))
            continue;
        ret.put(fieldName, field);
    }
    return ret;
}
Also used : Field(java.lang.reflect.Field) MassiveMap(com.massivecraft.massivecore.collections.MassiveMap)

Example 3 with MassiveMap

use of com.massivecraft.massivecore.collections.MassiveMap in project MassiveCore by MassiveCraft.

the class BoardUtil method updatePlayers.

public static void updatePlayers() {
    // Create
    Map<String, Player> players = new MassiveMap<>();
    // Fill
    for (Player player : MUtil.getOnlinePlayers()) {
        players.put(player.getName(), player);
    }
    players = Collections.unmodifiableMap(players);
    // Set
    BoardUtil.players = players;
}
Also used : Player(org.bukkit.entity.Player) MassiveMap(com.massivecraft.massivecore.collections.MassiveMap)

Example 4 with MassiveMap

use of com.massivecraft.massivecore.collections.MassiveMap in project MassiveCore by MassiveCraft.

the class BoardUtil method getTeamOptions.

// -------------------------------------------- //
// TEAM > OPTIONS
// -------------------------------------------- //
public static Map<TeamOptionKey, TeamOptionValue> getTeamOptions(Team team) {
    // Create
    Map<TeamOptionKey, TeamOptionValue> ret = new MassiveMap<>();
    // Fill
    for (TeamOptionKey key : TeamOptionKey.values()) {
        TeamOptionValue value = getTeamOption(team, key);
        if (value == null)
            continue;
        ret.put(key, value);
    }
    // Return
    return ret;
}
Also used : TeamOptionValue(com.massivecraft.massivecore.nms.TeamOptionValue) MassiveMap(com.massivecraft.massivecore.collections.MassiveMap) TeamOptionKey(com.massivecraft.massivecore.nms.TeamOptionKey)

Example 5 with MassiveMap

use of com.massivecraft.massivecore.collections.MassiveMap in project MassiveCore by MassiveCraft.

the class DataItemStack method fromBukkitContents.

public static Map<Integer, DataItemStack> fromBukkitContents(ItemStack[] contents) {
    // Catch NullEmpty
    if (contents == null || contents.length == 0)
        return null;
    // Create
    Map<Integer, DataItemStack> ret = new MassiveMap<>();
    // Fill
    for (int i = 0; i < contents.length; i++) {
        ItemStack itemStack = contents[i];
        if (InventoryUtil.isNothing(itemStack))
            continue;
        ret.put(i, DataItemStack.fromBukkit(itemStack));
    }
    // Return
    return ret;
}
Also used : TypeInteger(com.massivecraft.massivecore.command.type.primitive.TypeInteger) MassiveMap(com.massivecraft.massivecore.collections.MassiveMap) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

MassiveMap (com.massivecraft.massivecore.collections.MassiveMap)5 Player (org.bukkit.entity.Player)2 TypeInteger (com.massivecraft.massivecore.command.type.primitive.TypeInteger)1 TeamOptionKey (com.massivecraft.massivecore.nms.TeamOptionKey)1 TeamOptionValue (com.massivecraft.massivecore.nms.TeamOptionValue)1 Field (java.lang.reflect.Field)1 ItemStack (org.bukkit.inventory.ItemStack)1