Search in sources :

Example 1 with SenderPresence

use of com.massivecraft.massivecore.SenderPresence in project MassiveCore by MassiveCraft.

the class IdUtil method playerLeaveMonitor.

// Can't be cancelled
@EventHandler(priority = EventPriority.HIGHEST)
public void playerLeaveMonitor(EventMassiveCorePlayerLeave event) {
    Player player = event.getPlayer();
    if (MUtil.isntPlayer(player))
        return;
    UUID uuid = player.getUniqueId();
    String id = uuid.toString();
    String name = player.getName();
    // Leaving? Is it an actuall leave?
    SenderPresence presence;
    if (MixinActual.get().isActualLeave(event)) {
        // They actually left.
        // They are offline.
        presence = SenderPresence.OFFLINE;
    } else {
        // They didn't actually leave.
        // They are online, but not local.
        presence = SenderPresence.ONLINE;
    }
    update(id, name, presence);
}
Also used : Player(org.bukkit.entity.Player) SenderPresence(com.massivecraft.massivecore.SenderPresence) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 2 with SenderPresence

use of com.massivecraft.massivecore.SenderPresence in project MassiveCore by MassiveCraft.

the class TypeSenderIdAbstract method getTabList.

@Override
public Collection<String> getTabList(CommandSender sender, String arg) {
    // Step 1: Calculate presence.
    SenderPresence presence = this.presence;
    if (presence == SenderPresence.ANY)
        presence = SenderPresence.ONLINE;
    // Special step: We don't tab complete offline players.
    if (presence == SenderPresence.OFFLINE)
        return Collections.emptySet();
    // Step 2: Calculate type.
    SenderType type = this.type;
    // Step 3: Get Ids
    Set<String> ids = IdUtil.getIds(presence, type);
    // Step 4: Create Ret with visible names
    boolean addIds = (arg.length() >= TAB_LIST_UUID_THRESHOLD);
    int size = ids.size();
    if (addIds)
        size *= 2;
    Set<String> ret = new MassiveSet<>(size);
    for (String id : ids) {
        if (!MixinVisibility.get().isVisible(id, sender))
            continue;
        if (addIds)
            ret.add(id);
        String name = IdUtil.getName(id);
        if (name == null)
            continue;
        ret.add(name);
    }
    // Step 5: Return the ret.
    return ret;
}
Also used : SenderType(com.massivecraft.massivecore.SenderType) SenderPresence(com.massivecraft.massivecore.SenderPresence) MassiveSet(com.massivecraft.massivecore.collections.MassiveSet)

Example 3 with SenderPresence

use of com.massivecraft.massivecore.SenderPresence in project MassiveCore by MassiveCraft.

the class SenderMap method addValue.

public void addValue(String value, List<SenderPresence> presences, List<SenderType> types) {
    if (value == null)
        throw new NullPointerException("value");
    if (presences == null)
        throw new NullPointerException("presences");
    if (types == null)
        throw new NullPointerException("types");
    for (SenderPresence presence : presences) {
        Map<SenderType, Set<String>> map = innerMap.get(presence);
        for (SenderType type : types) {
            Set<String> set = map.get(type);
            set.add(value);
        }
    }
}
Also used : ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) Set(java.util.Set) SenderType(com.massivecraft.massivecore.SenderType) SenderPresence(com.massivecraft.massivecore.SenderPresence)

Aggregations

SenderPresence (com.massivecraft.massivecore.SenderPresence)3 SenderType (com.massivecraft.massivecore.SenderType)2 MassiveSet (com.massivecraft.massivecore.collections.MassiveSet)1 Set (java.util.Set)1 UUID (java.util.UUID)1 ConcurrentSkipListSet (java.util.concurrent.ConcurrentSkipListSet)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1