本文整理汇总了Java中org.cubeengine.libcube.service.command.parser.PlayerList类的典型用法代码示例。如果您正苦于以下问题:Java PlayerList类的具体用法?Java PlayerList怎么用?Java PlayerList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerList类属于org.cubeengine.libcube.service.command.parser包,在下文中一共展示了PlayerList类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hide
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Hides the account of a given player")
public void hide(CommandSource context, @Label("*|<players>") PlayerList users)
{
for (User user : users.list())
{
BaseAccount.Unique target = getAccount(context, user);
if (target != null)
{
if (target.isHidden())
{
i18n.send(context, NEUTRAL, "{user}'s account is already hidden!", user);
}
else
{
target.setHidden(true);
i18n.send(context, POSITIVE, "{user}'s account is now hidden!", user);
}
}
}
}
示例2: unhide
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Unhides the account of a given player")
public void unhide(CommandSource context, @Label("*|<players>") PlayerList users)
{
for (User user : users.list())
{
BaseAccount.Unique target = getAccount(context, user);
if (target != null)
{
if (target.isHidden())
{
target.setHidden(false);
i18n.send(context, POSITIVE, "{user}'s account is no longer hidden!", user);
}
else
{
i18n.send(context, NEUTRAL, "{user}'s account was not hidden!", user);
}
}
}
}
示例3: kick
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Kicks a player from the server")
public void kick(CommandSource context, PlayerList players, @Optional @Greed(INFINITE) String reason)
{
reason = parseReason(reason, module.perms().COMMAND_KICK_NOREASON, context);
if (players.isAll())
{
ensurePermission(context, module.perms().COMMAND_KICK_ALL);
for (Player toKick : Sponge.getServer().getOnlinePlayers())
{
if (!context.equals(toKick))
{
toKick.kick(Text.of(NEGATIVE,i18n.getTranslation(toKick, kickMessage),"\n\n", reason));
}
}
return;
}
for (Player user : players.list())
{
user.kick(Text.of(NEGATIVE, i18n.getTranslation(user, kickMessage),"\n\n", reason));
bc.broadcastTranslatedWithPerm(NEGATIVE, "{user} was kicked from the server by {user}!",
module.perms().KICK_RECEIVEMESSAGE.getId(), user, context);
}
bc.broadcastMessageWithPerm(NONE, reason, module.perms().KICK_RECEIVEMESSAGE.getId());
}
示例4: give
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(alias = "grant", desc = "Gives money to one or all players.")
public void give(CommandSource context,
@Label("*|<players>") PlayerList users,
Double amount)
{
for (User user : users.list())
{
UniqueAccount target = getAccount(context, user);
if (target != null)
{
Currency cur = service.getDefaultCurrency();
TransactionResult result = target.deposit(cur, new BigDecimal(amount), causeOf(context));
Text formatAmount = cur.format(result.getAmount());
switch (result.getResult())
{
case SUCCESS:
i18n.send(context, POSITIVE, "You gave {txt} to {user}!", formatAmount, user.getName());
if (!context.equals(user) && user.isOnline())
{
i18n.send(user.getPlayer().get(), POSITIVE, "You were granted {txt}.", formatAmount);
}
break;
default:
i18n.send(context, NEGATIVE, "Could not give the money to {user}!", user);
break;
}
}
}
}
示例5: take
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(alias = "remove", desc = "Takes money from given user")
public void take(CommandSource context, @Label("*|<players>") PlayerList users, Double amount)
{
for (User user : users.list())
{
UniqueAccount target = getAccount(context, user);
if (target != null)
{
Currency cur = service.getDefaultCurrency();
TransactionResult result = target.withdraw(cur, new BigDecimal(amount), causeOf(context));
Text formatAmount = cur.format(result.getAmount());
switch (result.getResult())
{
case SUCCESS:
i18n.send(context, POSITIVE, "You took {txt} from {user}!", formatAmount, user);
if (!context.equals(user) && user.isOnline())
{
i18n.send(user.getPlayer().get(), NEUTRAL, "Withdrew {txt} from your account.", formatAmount);
}
break;
default:
i18n.send(context, NEGATIVE, "Could not take the money from {user}!", user);
break;
}
}
}
}
示例6: reset
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Reset the money from given user")
public void reset(CommandSource context, @Label("*|<players>") PlayerList users)
{
for (User user : users.list())
{
UniqueAccount target = getAccount(context, user);
if (target != null)
{
Currency cur = service.getDefaultCurrency();
TransactionResult result = target.resetBalance(cur, causeOf(context));
Text formatAmount = cur.format(result.getAmount());
switch (result.getResult())
{
case SUCCESS:
i18n.send(context, POSITIVE, "{user} account reset to {txt}!", user, formatAmount);
if (!context.equals(user) && user.isOnline())
{
i18n.send(user.getPlayer().get(), NEUTRAL, "Your balance got reset to {txt}.", formatAmount);
}
break;
default:
i18n.send(context, NEGATIVE, "Could not reset the money from {user}!", user);
break;
}
}
}
}
示例7: set
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Sets the money of a given player")
public void set(CommandSource context, @Label("*|<players>") PlayerList users, Double amount)
{
for (User user : users.list())
{
UniqueAccount target = getAccount(context, user);
if (target != null)
{
Currency cur = service.getDefaultCurrency();
TransactionResult result = target.setBalance(cur, new BigDecimal(amount), causeOf(context));
Text formatAmount = cur.format(result.getAmount());
switch (result.getResult())
{
case SUCCESS:
i18n.send(context, POSITIVE, "{user} account set to {txt}!", user, formatAmount);
if (!context.equals(user) && user.isOnline())
{
i18n.send(user.getPlayer().get(), NEUTRAL, "Your balance got set to {txt}.", formatAmount);
}
break;
default:
i18n.send(context, NEGATIVE, "Could not reset the money from {user}!", user);
break;
}
}
}
}
示例8: kill
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(alias = "slay", desc = "Kills a player")
public void kill(CommandSource context, @Default(UserListInSight.class) PlayerList players,
@Flag boolean force, @Flag boolean quiet, @Flag boolean lightning)
{
lightning = lightning && context.hasPermission(COMMAND_KILL_LIGHTNING.getId());
force = force && context.hasPermission(COMMAND_KILL_FORCE.getId());
quiet = quiet && context.hasPermission(COMMAND_KILL_QUIET.getId());
List<String> killed = new ArrayList<>();
Collection<Player> userList = players.list();
if (players.isAll())
{
if (!context.hasPermission(COMMAND_KILL_ALL.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to kill everyone!");
return;
}
if (context instanceof Player)
{
userList.remove(context);
}
}
for (Player user : userList)
{
if (this.kill(user, lightning, context, false, force, quiet))
{
killed.add(user.getName());
}
}
if (killed.isEmpty())
{
i18n.send(context, NEUTRAL, "No one was killed!");
return;
}
i18n.send(context, POSITIVE, "You killed {user#list}!", StringUtils.implode(",", killed));
}
示例9: clearPassword
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(alias = "clearpw", desc = "Clears your password.")
public void clearPassword(CommandSource context,
@Optional @Desc("* or a list of Players delimited by ,") PlayerList players)
{
if (players == null)
{
if (!(context instanceof Player))
{
throw new TooFewArgumentsException();
}
module.resetPassword(((Player)context).getUniqueId());
i18n.send(context, POSITIVE, "Your password has been reset!");
return;
}
if (players.isAll())
{
if (!context.hasPermission(module.perms().COMMAND_CLEARPASSWORD_ALL.getId()))
{
throw new PermissionDeniedException(module.perms().COMMAND_CLEARPASSWORD_ALL);
}
module.resetAllPasswords();
i18n.send(context, POSITIVE, "All passwords reset!");
return;
}
if (!context.hasPermission(module.perms().COMMAND_CLEARPASSWORD_OTHER.getId()))
{
throw new PermissionDeniedException(module.perms().COMMAND_CLEARPASSWORD_OTHER);
}
for (Player user : players.list())
{
module.resetPassword(user.getUniqueId());
i18n.send(context, POSITIVE, "{user}'s password has been reset!", user.getName());
}
}
示例10: pay
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Alias(value = "pay")
@Command(alias = "give", desc = "Transfer the given amount to another account.")
public void pay(CommandSource context, @Label("*|<players>") PlayerList users, Double amount, @Default @Named("as") BaseAccount.Unique source)
{
if (amount < 0)
{
i18n.send(context, NEGATIVE, "What are you trying to do?");
return;
}
boolean asSomeOneElse = false;
if (!source.getIdentifier().equals(context.getIdentifier()))
{
if (!context.hasPermission(module.perms().ACCESS_WITHDRAW.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to pay money as someone else!");
return;
}
asSomeOneElse = true;
}
for (User user : users.list())
{
if (user.equals(source))
{
i18n.send(context, NEGATIVE, "Source and target are the same!", user);
continue;
}
Account target = getUserAccount(user);
if (target == null)
{
i18n.send(context, NEGATIVE, "{user} does not have an account!", user);
continue;
}
Currency cur = service.getDefaultCurrency();
TransferResult result = source.transfer(target, cur, new BigDecimal(amount), causeOf(context));
Text formatAmount = cur.format(result.getAmount());
switch (result.getResult())
{
case SUCCESS:
if (asSomeOneElse)
{
i18n.send(context, POSITIVE, "{txt#amount} transferred from {account}'s to {user}'s account!", formatAmount, source, user);
}
else
{
i18n.send(context, POSITIVE, "{txt#amount} transferred to {user}'s account!", formatAmount, user);
}
if (user.isOnline())
{
i18n.send(user.getPlayer().get(), POSITIVE, "{account} just paid you {txt#amount}!", source, formatAmount);
}
break;
case ACCOUNT_NO_FUNDS:
if (asSomeOneElse)
{
i18n.send(context, NEGATIVE, "{account} cannot afford {txt#amount}!", source, formatAmount);
}
else
{
i18n.send(context, NEGATIVE, "You cannot afford {txt#amount}!", formatAmount);
}
break;
default:
i18n.send(context, NEGATIVE, "The Transaction was not successful!");
break;
}
}
}
示例11: feed
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Refills your hunger bar")
public void feed(CommandSource context, @Optional PlayerList players)
{
if (players == null)
{
if (!(context instanceof Player))
{
i18n.send(context, NEGATIVE, "Don't feed the troll!");
return;
}
User sender = (User)context;
sender.offer(Keys.FOOD_LEVEL, 20);
sender.offer(Keys.SATURATION, 20.0);
sender.offer(Keys.EXHAUSTION, 0.0);
i18n.send(context, POSITIVE, "You are now fed!");
return;
}
if (!context.hasPermission(COMMAND_FEED_OTHER.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to feed other players!");
return;
}
Collection<Player> userList = players.list();
if (players.isAll())
{
if (userList.isEmpty())
{
i18n.send(context, NEGATIVE, "There are no players online at the moment!");
}
i18n.send(context, POSITIVE, "You made everyone fat!");
bc.broadcastStatus(NONE.color(GREEN), "shared food with everyone.", context);
}
else
{
i18n.send(context, POSITIVE, "Fed {amount} players!", userList.size());
}
for (Player user : userList)
{
if (!players.isAll())
{
i18n.send(user, POSITIVE, "You got fed by {user}!", context);
}
user.offer(Keys.FOOD_LEVEL, 20);
user.offer(Keys.SATURATION, 20.0);
user.offer(Keys.EXHAUSTION, 0.0);
}
}
示例12: starve
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Empties the hunger bar")
public void starve(CommandSource context, @Optional PlayerList players)
{
if (players == null)
{
if (!(context instanceof Player))
{
context.sendMessage(Text.of("\n\n\n\n\n\n\n\n\n\n\n\n\n"));
i18n.send(context, NEGATIVE, "I'll give you only one line to eat!");
return;
}
User sender = (User)context;
sender.offer(Keys.FOOD_LEVEL, 0);
sender.offer(Keys.SATURATION, 0.0);
sender.offer(Keys.EXHAUSTION, 4.0);
i18n.send(context, NEGATIVE, "You are now starving!");
return;
}
if (!context.hasPermission(COMMAND_STARVE_OTHER.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to let other players starve!");
return;
}
Collection<Player> userList = players.list();
if (players.isAll())
{
if (userList.isEmpty())
{
i18n.send(context, NEGATIVE, "There are no players online at the moment!");
return;
}
i18n.send(context, NEUTRAL, "You let everyone starve to death!");
bc.broadcastStatus(ChatFormat.YELLOW + "took away all food.", context);
}
else
{
i18n.send(context, POSITIVE, "Starved {amount} players!", userList.size());
}
for (Player user : userList)
{
if (!players.isAll())
{
i18n.send(user, NEUTRAL, "You are suddenly starving!");
}
user.offer(Keys.FOOD_LEVEL, 0);
user.offer(Keys.SATURATION, 0.0);
user.offer(Keys.EXHAUSTION, 4.0);
}
}
示例13: heal
import org.cubeengine.libcube.service.command.parser.PlayerList; //导入依赖的package包/类
@Command(desc = "Heals a player")
public void heal(CommandSource context, @Optional PlayerList players)
{
if (players == null)
{
if (!(context instanceof Player))
{
i18n.send(context, NEGATIVE, "Only time can heal your wounds!");
return;
}
Player sender = (Player)context;
sender.offer(Keys.HEALTH, sender.get(Keys.MAX_HEALTH).get());
i18n.send(sender, POSITIVE, "You are now healed!");
return;
}
if (!context.hasPermission(COMMAND_HEAL_OTHER.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to heal other players!");
return;
}
Collection<Player> userList = players.list();
if (players.isAll())
{
if (userList.isEmpty())
{
i18n.send(context, NEGATIVE, "There are no players online at the moment!");
return;
}
i18n.send(context, POSITIVE, "You healed everyone!");
bc.broadcastStatus(ChatFormat.BRIGHT_GREEN + "healed every player.", context);
}
else
{
i18n.send(context, POSITIVE, "Healed {amount} players!", userList.size());
}
for (Player user : userList)
{
if (!players.isAll())
{
i18n.send(user, POSITIVE, "You got healed by {sender}!", context);
}
user.offer(Keys.HEALTH, user.get(Keys.MAX_HEALTH).get());
}
}