use of io.github.nucleuspowered.nucleus.modules.vanish.datamodules.VanishUserDataModule in project Nucleus by NucleusPowered.
the class VanishCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
User ou = getUserFromArgs(User.class, src, player, args);
if (ou.getPlayer().isPresent()) {
return onPlayer(src, args, ou.getPlayer().get());
}
if (!permissions.testSuffix(ou, "persist")) {
throw new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.vanish.noperm", ou.getName()));
}
VanishUserDataModule uss = Nucleus.getNucleus().getUserDataManager().getUnchecked(ou).get(VanishUserDataModule.class);
uss.setVanished(args.<Boolean>getOne(b).orElse(!uss.isVanished()));
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.vanish.successuser", ou.getName(), uss.isVanished() ? plugin.getMessageProvider().getMessageWithFormat("command.vanish.vanished") : plugin.getMessageProvider().getMessageWithFormat("command.vanish.visible")));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.modules.vanish.datamodules.VanishUserDataModule in project Nucleus by NucleusPowered.
the class VanishService method vanishPlayerInternal.
private void vanishPlayerInternal(Player player) {
VanishUserDataModule service = Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(VanishUserDataModule.class);
if (service.isVanished()) {
player.offer(Keys.VANISH, true);
player.offer(Keys.VANISH_IGNORES_COLLISION, true);
player.offer(Keys.VANISH_PREVENTS_TARGETING, true);
if (this.isAlter) {
Sponge.getServer().getOnlinePlayers().stream().filter(x -> !player.equals(x) || !x.hasPermission(this.canseePerm)).forEach(x -> x.getTabList().removeEntry(player.getUniqueId()));
}
}
}
use of io.github.nucleuspowered.nucleus.modules.vanish.datamodules.VanishUserDataModule in project Nucleus by NucleusPowered.
the class VanishService method vanishPlayer.
public void vanishPlayer(Player player, boolean delay) {
VanishUserDataModule service = Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(VanishUserDataModule.class);
service.setVanished(true);
if (delay) {
Task.builder().execute(() -> vanishPlayerInternal(player)).delayTicks(0).name("Nucleus Vanish runnable").submit(Nucleus.getNucleus());
} else {
vanishPlayerInternal(player);
}
}
use of io.github.nucleuspowered.nucleus.modules.vanish.datamodules.VanishUserDataModule in project Nucleus by NucleusPowered.
the class VanishService method unvanishPlayer.
public void unvanishPlayer(Player player) {
VanishUserDataModule service = Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(VanishUserDataModule.class);
service.setVanished(false);
player.offer(Keys.VANISH, false);
player.offer(Keys.VANISH_IGNORES_COLLISION, false);
player.offer(Keys.VANISH_PREVENTS_TARGETING, false);
if (this.isAlter) {
Sponge.getServer().getOnlinePlayers().forEach(x -> {
if (!x.getTabList().getEntry(player.getUniqueId()).isPresent()) {
x.getTabList().addEntry(TabListEntry.builder().displayName(Text.of(player.getName())).profile(player.getProfile()).gameMode(player.gameMode().get()).latency(player.getConnection().getLatency()).list(x.getTabList()).build());
}
});
}
}
Aggregations