Java源码示例:com.earth2me.essentials.User

示例1
@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);
    }
}
 
示例2
@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);
    }
}
 
示例3
@Test
public void shouldSetSocialSpyStatus() {
    // given
    Player player = mock(Player.class);

    Essentials ess = mock(Essentials.class);
    User user = mock(User.class);
    given(ess.getUser(player)).willReturn(user);

    PluginManager pluginManager = mock(PluginManager.class);
    setPluginAvailable(pluginManager, ESSENTIALS, ess);
    PluginHookService pluginHookService = new PluginHookService(pluginManager);

    // when
    pluginHookService.setEssentialsSocialSpyStatus(player, true);

    // then
    verify(ess).getUser(player);
    verify(user).setSocialSpyEnabled(true);
}
 
示例4
@Override
public double getBalance(UUID playerId) {
    User user;
    try {
        user = essentials.getUser(playerId);
    } catch (NullPointerException e) {
        return 0;
    }

    if (user != null) {
        return user.getMoney().doubleValue();
    }
    return 0;
}
 
示例5
private void handleValue(Player player, State state)
{
	if (state != null)
	{
		this.isGodmodeEnabled = (state == State.ALLOW ? true : false);
	}
	else
	{
		this.isGodmodeEnabled = null;
	}
	
	//For now at least
	Plugin essentials = this.getPlugin().getServer().getPluginManager().getPlugin("Essentials");
	if (essentials != null)
	{
		User user = ((Essentials)essentials).getUser(player);
		
		if (this.isGodmodeEnabled != null)
		{
			if (this.isGodmodeEnabled != user.isGodModeEnabled())
			{
				if (this.originalEssentialsGodmode == null)
				{
					this.originalEssentialsGodmode = user.isGodModeEnabled();
				}
				
				user.setGodModeEnabled(this.isGodmodeEnabled);
			}
		}
		else
		{
			if (this.originalEssentialsGodmode != null)
			{
				user.setGodModeEnabled(this.originalEssentialsGodmode);
				
				this.originalEssentialsGodmode = null;
			}
		}
	}
}
 
示例6
private void doBack(Player p, User iu, Location curLoc, Location lastLoc) {
    if (iu.getWorld() != lastLoc.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !iu.isAuthorized("essentials.worlds." + lastLoc.getWorld().getName())) {
        msg(p, "internal.error.no_required_permission", "essentials.worlds." + lastLoc.getWorld().getName());
        return;
    }

    double fee = plugin.cfg.backBase;
    if (curLoc.getWorld() != lastLoc.getWorld()) {
        fee += plugin.cfg.backWorld;
        fee += lastLoc.distance(PlayerSpawn(p, lastLoc.getWorld())) * (double) plugin.cfg.backIncrement / plugin.cfg.backDistance;
    } else {
        fee += lastLoc.distance(curLoc) * (double) plugin.cfg.backIncrement / plugin.cfg.backDistance;
    }
    if (fee > plugin.cfg.backMax) fee = plugin.cfg.backMax;
    fee = new BigDecimal(fee).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue();
    if (!VaultUtils.withdraw(p, fee)) {
        msg(p, "user.teleport.money_insufficient", fee);
        return;
    }
    try {
        iu.getTeleport().back(new Trade(0, ess));
        msg(p, "user.teleport.ok", fee, I18n.format("user.teleport.back"));
        if (plugin.systemBalance != null) {
            plugin.systemBalance.deposit(fee, plugin);
        }
    } catch (Exception e) {
        VaultUtils.deposit(p, fee);
        p.sendMessage(e.getMessage());
    }
}
 
示例7
private void doHome(Player p, User iu, Location homeLoc, Location curLoc) {
    if (iu.getWorld() != homeLoc.getWorld() && ess.getSettings().isWorldHomePermissions() && !iu.isAuthorized("essentials.worlds." + homeLoc.getWorld().getName())) {
        msg(p, "internal.error.no_required_permission", "essentials.worlds." + homeLoc.getWorld().getName());
        return;
    }

    double fee = plugin.cfg.homeBase;
    if (homeLoc.getWorld() != curLoc.getWorld()) {
        fee += plugin.cfg.homeWorld;
        fee += homeLoc.distance(PlayerSpawn(p, homeLoc.getWorld())) * (double) plugin.cfg.homeIncrement / plugin.cfg.homeDistance;
    } else {
        fee += homeLoc.distance(curLoc) * (double) plugin.cfg.homeIncrement / plugin.cfg.homeDistance;
    }
    if (fee > plugin.cfg.homeMax) fee = plugin.cfg.homeMax;
    fee = new BigDecimal(fee).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue();
    if (!VaultUtils.withdraw(p, fee)) {
        msg(p, "user.teleport.money_insufficient", fee);
        return;
    }
    try {
        iu.getTeleport().teleport(homeLoc, new Trade(0, ess), PlayerTeleportEvent.TeleportCause.PLUGIN);
        msg(p, "user.teleport.ok", fee, I18n.format("user.teleport.home"));
        if (plugin.systemBalance != null) {
            plugin.systemBalance.deposit(fee, plugin);
        }
    } catch (Exception e) {
        VaultUtils.deposit(p, fee);
        p.sendMessage(e.getMessage());
    }
}
 
示例8
private int checkHomeLimit(final User user, String name) {
    if (!user.isAuthorized("essentials.sethome.multiple.unlimited")) {
        int limit = ess.getSettings().getHomeLimit(user);
        if (user.getHomes().size() == limit && user.getHomes().contains(name)) {
            return 0;
        }
        if (user.getHomes().size() >= limit) {
            return limit;
        }
        if (limit == 1) {
            return 1;
        }
    }
    return 0;
}
 
示例9
public static User getUser(Player player) {
    if(player == null) return null;

    IEssentials api = getAPI();
    if(api == null) return null;

    return api.getUser(player);
}
 
示例10
@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);
}
 
示例11
@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);
}
 
示例12
private void doSetHome(Player p, User iu, Location curLoc, String name) {
    int n = checkHomeLimit(iu, name);
    if (n == 1) {
        if (!name.equals("home"))
            msg(p, "user.teleport.home_limit_one");
        name = "home";
    } else if (n != 0) {
        msg(p, "user.teleport.home_limit", n);
        return;
    }
    if ("bed".equals(name) || NumberUtil.isInt(name)) {
        msg(p, "user.teleport.invalid_name");
        return;
    }
    if (!ess.getSettings().isTeleportSafetyEnabled() && LocationUtil.isBlockUnsafeForUser(iu, curLoc.getWorld(), curLoc.getBlockX(), curLoc.getBlockY(), curLoc.getBlockZ())) {
        msg(p, "user.teleport.unsafe");
        return;
    }

    double fee = plugin.cfg.setHomeMax;
    World defaultWorld = Bukkit.getWorld(plugin.cfg.setHomeDefaultWorld);
    if (defaultWorld == null) {
        defaultWorld = Bukkit.getWorlds().get(0);
    }
    if (curLoc.getWorld() != defaultWorld) {
        fee += plugin.cfg.setHomeWorld;
        fee -= curLoc.distance(PlayerSpawn(p, curLoc.getWorld())) * (double) plugin.cfg.setHomeDecrement / plugin.cfg.setHomeDistance;
    } else {
        fee -= curLoc.distance(PlayerSpawn(p, defaultWorld)) * (double) plugin.cfg.setHomeDecrement / plugin.cfg.setHomeDistance;
    }
    if (fee < plugin.cfg.setHomeMin) fee = plugin.cfg.setHomeMin;
    fee = new BigDecimal(fee).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue();
    if (!VaultUtils.withdraw(p, fee)) {
        msg(p, "user.teleport.money_insufficient", fee);
        return;
    }
    iu.setHome(name, curLoc);
    msg(p, "user.teleport.ok", fee, I18n.format("user.teleport.sethome"));
    if (plugin.systemBalance != null && fee > 0) {
        plugin.systemBalance.deposit(fee, plugin);
    }
}
 
示例13
public static boolean isVanished(Player player) {
    User user = getUser(player);
    if(user == null) return false;

    return user.isVanished();
}
 
示例14
@EventHandler
public void onReappear(PostPlayerShowEvent e) {
    User user = essentials.getUser(e.getPlayer());
    if (user == null) return;
    user.setHidden(false);
}