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);
}
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;
}
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);
}
}
}
Aggregations