Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/fr/openmc/core/OMCPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class OMCPlugin extends JavaPlugin {
@Getter
static FileConfiguration configs;

public static final String VANISH_META_KEY = "omcstaff.vanished";

public static void registerEvents(Listener... listeners) {
for (Listener listener : listeners) {
instance.getServer().getPluginManager().registerEvents(listener, instance);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.openmc.core.commands.autocomplete;

import fr.openmc.core.OMCPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand All @@ -15,6 +16,7 @@ public class OnlinePlayerAutoComplete implements SuggestionProvider<BukkitComman
public @NotNull List<String> getSuggestions(@NotNull ExecutionContext<BukkitCommandActor> context) {
return Bukkit.getOnlinePlayers().stream()
.map(Player::getName)
.filter(name -> !context.actor().requirePlayer().hasMetadata(OMCPlugin.VANISH_META_KEY))
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.openmc.core.features.friend.autocomplete;

import fr.openmc.core.OMCPlugin;
import fr.openmc.core.utils.cache.CacheOfflinePlayer;
import org.jetbrains.annotations.NotNull;
import revxrsal.commands.autocomplete.SuggestionProvider;
Expand All @@ -18,6 +19,7 @@ public class FriendsAutoComplete implements SuggestionProvider<BukkitCommandActo
List<UUID> friendsUUIDs = getFriendsAsync(context.actor().requirePlayer().getUniqueId()).join();
return friendsUUIDs.stream()
.map(uuid -> CacheOfflinePlayer.getOfflinePlayer(uuid).getName())
.filter(name -> !context.actor().requirePlayer().hasMetadata(OMCPlugin.VANISH_META_KEY))
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.openmc.core.features.friend.autocomplete;

import fr.openmc.core.OMCPlugin;
import fr.openmc.core.utils.cache.CacheOfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand All @@ -24,6 +25,7 @@ public class FriendsRequestAutoComplete implements SuggestionProvider<BukkitComm
.toList();
return requestUUIDs.stream()
.map(uuid -> CacheOfflinePlayer.getOfflinePlayer(uuid).getName())
.filter(name -> !sender.hasMetadata(OMCPlugin.VANISH_META_KEY))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
public class JoinQuitMessageListener implements Listener {
private final double balanceOnJoin;

public static final String VANISH_META_KEY = "omcstaff.vanished";
public static final String JOIN_MESSAGE = "§8[§a§l+§8] §r%s%s";
public static final String QUIT_MESSAGE = "§8[§c§l-§8] §r%s%s";

Expand All @@ -46,7 +45,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
FriendManager.getFriendsAsync(player.getUniqueId()).thenAccept(friendsUUIDS -> {
for (UUID friendUUID : friendsUUIDS) {
final Player friend = player.getServer().getPlayer(friendUUID);
if (friend != null && friend.isOnline()) {
if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) {
MessagesManager.sendMessage(friend, Component.text("§aVotre ami §r" + "§r" + LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName() +" §as'est connecté(e)"), Prefix.FRIEND, MessageType.NONE, true);
}
}
Expand Down Expand Up @@ -74,7 +73,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}
});

if (!player.hasMetadata(VANISH_META_KEY))
if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY))
event.joinMessage(Component.text(JOIN_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName())));

// Adjust player's spawn location
Expand Down Expand Up @@ -105,7 +104,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
FriendManager.getFriendsAsync(player.getUniqueId()).thenAccept(friendsUUIDS -> {
for (UUID friendUUID : friendsUUIDS) {
final Player friend = player.getServer().getPlayer(friendUUID);
if (friend != null && friend.isOnline()) {
if (friend != null && friend.isOnline() && !friend.hasMetadata(OMCPlugin.VANISH_META_KEY)) {
MessagesManager.sendMessage(friend, Component.text("§cVotre ami §e" + "§r" + LuckPermsHook.getFormattedPAPIPrefix(player) + player.getName() +" §cs'est déconnecté(e)"), Prefix.FRIEND, MessageType.NONE, true);
}
}
Expand All @@ -125,7 +124,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
}
}

if (!player.hasMetadata(VANISH_META_KEY))
if (!player.hasMetadata(OMCPlugin.VANISH_META_KEY))
event.quitMessage(Component.text(QUIT_MESSAGE.formatted(LuckPermsHook.getFormattedPAPIPrefix(player), player.getName())));
}

Expand Down
Loading