Update player list on (un)vanish

#120
This commit is contained in:
Norbi Peti 2020-02-18 17:18:17 +01:00
parent ffdf5a2f18
commit 454265cd6f
2 changed files with 12 additions and 3 deletions

View file

@ -170,6 +170,12 @@
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.spigotmc.</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.discord4j/Discord4J --> <!-- https://mvnrepository.com/artifact/com.discord4j/Discord4J -->
<dependency> <dependency>
<groupId>com.discord4j</groupId> <groupId>com.discord4j</groupId>

View file

@ -14,6 +14,7 @@ import lombok.val;
import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.AfkStatusChangeEvent;
import net.ess3.api.events.MuteStatusChangeEvent; import net.ess3.api.events.MuteStatusChangeEvent;
import net.ess3.api.events.NickChangeEvent; import net.ess3.api.events.NickChangeEvent;
import net.ess3.api.events.VanishStatusChangeEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -165,21 +166,23 @@ class MCListener implements Listener {
public void onTabComplete(TabCompleteEvent event) { public void onTabComplete(TabCompleteEvent event) {
int i = event.getBuffer().lastIndexOf(' '); int i = event.getBuffer().lastIndexOf(' ');
String t = event.getBuffer().substring(i + 1); //0 if not found String t = event.getBuffer().substring(i + 1); //0 if not found
//System.out.println("Last token: " + t);
if (!t.startsWith("@")) if (!t.startsWith("@"))
return; return;
String token = t.substring(1); String token = t.substring(1);
//System.out.println("Token: " + token);
val x = DiscordPlugin.mainServer.getMembers() val x = DiscordPlugin.mainServer.getMembers()
.flatMap(m -> Flux.just(m.getUsername(), m.getNickname().orElse(""))) .flatMap(m -> Flux.just(m.getUsername(), m.getNickname().orElse("")))
.filter(s -> s.startsWith(token)) .filter(s -> s.startsWith(token))
.map(s -> "@" + s) .map(s -> "@" + s)
.doOnNext(event.getCompletions()::add).blockLast(); .doOnNext(event.getCompletions()::add).blockLast();
//System.out.println("Finished - last: " + x);
} }
@EventHandler @EventHandler
public void onCommandSend(PlayerCommandSendEvent event) { public void onCommandSend(PlayerCommandSendEvent event) {
event.getCommands().add("g"); event.getCommands().add("g");
} }
@EventHandler
public void onVanish(VanishStatusChangeEvent event) {
MCChatUtils.updatePlayerList();
}
} }