Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package su.nightexpress.sunlight.module.vanish;

import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.sunlight.SunLightPlugin;
import su.nightexpress.sunlight.core.user.settings.Setting;
Expand Down Expand Up @@ -31,29 +32,30 @@ protected void gatherInfo(@NotNull ModuleInfo moduleInfo) {
@Override
protected void onModuleLoad() {
VanishCommand.load(this.plugin, this);

this.addListener(new VanishListener(this.plugin, this));
}

@Override
protected void onModuleUnload() {

}
protected void onModuleUnload() {}

public boolean isVanished(@NotNull Player player) {
SunUser user = this.plugin.getUserManager().getUserData(player);
return user.getSettings().get(VANISH);
}

public void vanish(@NotNull Player player, boolean isVanished) {
// Update vanish status for other players
for (Player other : this.plugin.getServer().getOnlinePlayers()) {
if (isVanished) {
if (!other.hasPermission(VanishPerms.BYPASS_SEE)) {
other.hidePlayer(this.plugin, player);
}
}
else {
// Set metadata for vanish status
player.setMetadata("vanished", new FixedMetadataValue(this.plugin, true));
} else {
other.showPlayer(this.plugin, player);
// Remove metadata when no longer vanished
player.removeMetadata("vanished", this.plugin);
}
}
}
Expand Down