本文整理汇总了Java中com.earth2me.essentials.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.earth2me.essentials包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: broadcastMessage
import com.earth2me.essentials.User; //导入依赖的package包/类
private void broadcastMessage(IUser sender, final String permission, final String message) {
if(essentialsHook != null) {
IText broadcast = new SimpleTextInput(message);
final Collection<Player> players = (Collection<Player>) Bukkit.getOnlinePlayers();
for (Player player : players) {
final User user = essentialsHook.getUser(player);
if ((permission == null && (sender == null || !user.isIgnoredPlayer(sender))) || (permission != null && user.isAuthorized(permission))) {
for (String messageText : broadcast.getLines()) {
UnifiedUser unifiedUser = new UnifiedUser(player);
if (unifiedUser.isSynced())
messenger.sendMessageToDM(unifiedUser.getMcbUser().getUser(), messageText);
}
}
}
}
}
示例2: deSerialize
import com.earth2me.essentials.User; //导入依赖的package包/类
/**
* Gets the essentials kit from the config as ItemStacks.
* @param items The items in the kit.
* @param user The player in the form of Essentials User.
* @return The ItemStacks.
*/
private CompletableFuture<ItemStack[]> deSerialize(final List<String> items, final User user) {
final Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
final CompletableFuture<ItemStack[]> finalList = new CompletableFuture<>();
final List<ItemStack> itemList = new ArrayList<>();
final IText input = new SimpleTextInput(items);
final IText output = new KeywordReplacer(input, user.getSource(), ess);
for (final String kitItem : output.getLines()) {
final String[] parts = kitItem.split(" +");
try {
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
if (parseStack != null && parseStack.getType() != Material.AIR) {
final MetaItemStack metaStack = new MetaItemStack(parseStack);//NOPMD
if (parts.length > 2) {
metaStack.parseStringMeta(null, true, parts, 2, ess);
}
itemList.add(metaStack.getItemStack());
}
} catch (Exception e) {
RandomCoords.logger.log(Level.SEVERE, "There was an error serializing the essentials kit! (RandomCoords)");
}
}
finalList.complete(itemList.toArray(new ItemStack[itemList.size()]));
return finalList;
}
示例3: changeVipKit
import com.earth2me.essentials.User; //导入依赖的package包/类
private void changeVipKit(String uuid, String oldVip, String newVip){
if (plugin.ess != null){
String oldKit = this.getString("", "groups."+oldVip+".essentials-kit");
User user = plugin.ess.getUser(UUID.fromString(uuid));
if (!oldKit.isEmpty() && user != null){
long oldTime = user.getKitTimestamp(oldKit.toLowerCase());
dataManager.setVipKitCooldown(uuid, oldVip, oldTime);
}
String newKit = this.getString("", "groups."+newVip+".essentials-kit");
if (!newKit.isEmpty() && user != null){
long newTime = dataManager.getVipCooldown(uuid, newVip);
if (newTime > 0){
user.setKitTimestamp(newKit.toLowerCase(), newTime);
}
}
}
}
示例4: run
import com.earth2me.essentials.User; //导入依赖的package包/类
@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);
}
}
示例5: onCommand
import com.earth2me.essentials.User; //导入依赖的package包/类
@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.contains(":")) 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);
}
}
示例6: updateTime
import com.earth2me.essentials.User; //导入依赖的package包/类
/**
* Updates play time if all conditions are met and awards achievements if necessary.
*
* @param player
*/
private void updateTime(Player player) {
// If player is in restricted game mode or is in a blocked world, don't update played time.
if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) {
return;
}
if (configIgnoreAFKPlayedTime) {
User user = essentials.getUser(player);
// If player is AFK, don't update played time.
if (user != null && user.isAfk()) {
return;
}
}
// Do not register any times if player does not have permission.
if (!player.hasPermission(NormalAchievements.PLAYEDTIME.toPermName())) {
return;
}
long playedTime = plugin.getCacheManager().getAndIncrementStatisticAmount(NormalAchievements.PLAYEDTIME,
player.getUniqueId(), (int) (System.currentTimeMillis() - previousRunMillis));
checkThresholdsAndAchievements(player, NormalAchievements.PLAYEDTIME.toString(), playedTime);
}
示例7: process
import com.earth2me.essentials.User; //导入依赖的package包/类
private void process(ProtectedRegion r){
DefaultDomain owners = r.getOwners();
boolean found = false;
for (String s : owners.getPlayers()) {
User u = e.getOfflineUser(s);
if(u != null){
long time = System.currentTimeMillis() - u.getLastLogout();
System.out.println("Milliseconds since last played: " + time);
if (time < WorldRestore.month) {
System.out.println("Found an owner played within last month.");
found = true;
break;
}
}
}
if(!found){
rm.removeRegion(r.getId());
}
}
示例8: getEssentialsUser
import com.earth2me.essentials.User; //导入依赖的package包/类
public User getEssentialsUser(String username)
{
try
{
final Essentials essentials = getEssentialsPlugin();
if (essentials != null)
{
return essentials.getUserMap().getUser(username);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
示例9: setNickname
import com.earth2me.essentials.User; //导入依赖的package包/类
public void setNickname(String username, String nickname)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
user.setNickname(nickname);
user.setDisplayNick();
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
示例10: getLastActivity
import com.earth2me.essentials.User; //导入依赖的package包/类
public long getLastActivity(String username)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
return TFM_Util.<Long>getField(user, "lastActivity"); // This is weird
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return 0L;
}
示例11: shouldSetSocialSpyStatus
import com.earth2me.essentials.User; //导入依赖的package包/类
@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);
}
示例12: sendMail
import com.earth2me.essentials.User; //导入依赖的package包/类
public final boolean sendMail(Player player, String mail)
{
if (! isEnabled())
return false;
try
{
User user = getDependency().getUser(player);
user.addMail(mail);
return true;
}
catch (Throwable ex)
{
handler.getLogHandler().debug(Level.WARNING,
Util.getUsefulStack(ex, String.format("sendMail(%s, %s)", player.getName(), mail)));
}
return false;
}
示例13: getKit
import com.earth2me.essentials.User; //导入依赖的package包/类
/**
* Grabs the kit from the config name.
* @param p The player we're getting the kit for.
* @param c The Chest that is being generated.
* @param name The name of the kit.
*/
public void getKit(final Player p, final Chest c, final String name) {
if (Bukkit.getPluginManager().getPlugin("Essentials") == null) {
} else {
final IEssentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
ForkJoinPool.commonPool().execute(() -> {
if (ess != null) {
// Map<String, Object> kit = ess.getSettings().getKit(name.toLowerCase());
final User u = ess.getUser(p);
List<String> items;
try {
final Kit kitMe = new Kit(name, ess);
items = kitMe.getItems();
final Inventory inv = c.getInventory();
inv.addItem(deSerialize(items, u).get());
} catch (Exception e) {
e.printStackTrace();
RandomCoords.logger.severe("Essnetials unable to deserialize kit (RandomCoords)");
}
} else {
RandomCoords.logger.severe("Essnetials was null when getting kit. (RandomCoords)");
}
});
}
}
示例14: getEssentialsKits
import com.earth2me.essentials.User; //导入依赖的package包/类
public List<ItemStack> getEssentialsKits(Player p, String name) {
List<ItemStack> itemStacks = new ArrayList<>();
if (Bukkit.getPluginManager().getPlugin("Essentials") == null) {
} else {
final IEssentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
if (ess != null) {
// Map<String, Object> kit = ess.getSettings().getKit(name.toLowerCase());
final User u = ess.getUser(p);
List<String> items;
try {
final Kit kitMe = new Kit(name, ess);
items = kitMe.getItems();
for(ItemStack item : deSerialize(items, u).get()) {
itemStacks.add(item);
}
} catch (Exception e) {
e.printStackTrace();
RandomCoords.logger.severe("Essnetials unable to deserialize kit.");
}
} else {
RandomCoords.logger.severe("Essnetials was null when getting kit.");
}
}
return itemStacks;
}
示例15: getBalance
import com.earth2me.essentials.User; //导入依赖的package包/类
@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;
}