Java Code Examples for com.earth2me.essentials.User#setHidden()

The following examples show how to use com.earth2me.essentials.User#setHidden() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EssentialsHook.java    From SuperVanish with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void run() {
    try {
        if (!Bukkit.getPluginManager().isPluginEnabled("Essentials")) return;
        for (UUID uuid : superVanish.getVanishStateMgr().getOnlineVanishedPlayers()) {
            Player p = Bukkit.getPlayer(uuid);
            User user = essentials.getUser(p);
            if (user == null) continue;
            if (!user.isHidden())
                user.setHidden(true);
        }
    } catch (Exception e) {
        cancel();
        superVanish.logException(e);
    }
}
 
Example 2
Source File: EssentialsHook.java    From SuperVanish with Mozilla Public License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommand(final PlayerCommandPreprocessEvent e) {
    if (!CommandAction.VANISH_SELF.checkPermission(e.getPlayer(), superVanish)) return;
    if (superVanish.getVanishStateMgr().isVanished(e.getPlayer().getUniqueId())) return;
    String command = e.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "")
            .toLowerCase(Locale.ENGLISH);
    if (command.split(":").length > 1) command = command.split(":")[1];
    if (command.equals("supervanish") || command.equals("sv")
            || command.equals("v") || command.equals("vanish")) {
        final User user = essentials.getUser(e.getPlayer());
        if (user == null || !user.isAfk()) return;
        user.setHidden(true);
        preVanishHiddenPlayers.add(e.getPlayer().getUniqueId());
        superVanish.getServer().getScheduler().runTaskLater(superVanish, new Runnable() {
            @Override
            public void run() {
                if (preVanishHiddenPlayers.remove(e.getPlayer().getUniqueId())) {
                    user.setHidden(false);
                }
            }
        }, 1);
    }
}
 
Example 3
Source File: EssentialsHook.java    From SuperVanish with Mozilla Public License 2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onJoin(PlayerJoinEvent e) {
    User user = essentials.getUser(e.getPlayer());
    if (user == null) return;
    if (superVanish.getVanishStateMgr().isVanished(e.getPlayer().getUniqueId()) && !user.isHidden())
        user.setHidden(true);
    else user.setHidden(false);
}
 
Example 4
Source File: EssentialsHook.java    From SuperVanish with Mozilla Public License 2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVanish(PlayerHideEvent e) {
    User user = essentials.getUser(e.getPlayer());
    if (user == null) return;
    if (user.isVanished()) user.setVanished(false);
    preVanishHiddenPlayers.remove(e.getPlayer().getUniqueId());
    user.setHidden(true);
}
 
Example 5
Source File: EssentialsHook.java    From SuperVanish with Mozilla Public License 2.0 4 votes vote down vote up
@EventHandler
public void onReappear(PostPlayerShowEvent e) {
    User user = essentials.getUser(e.getPlayer());
    if (user == null) return;
    user.setHidden(false);
}