use of com.earth2me.essentials.User in project Essentials by drtshock.
the class Commandbroadcastworld method sendToWorld.
private void sendToWorld(World world, String message) {
IText broadcast = new SimpleTextInput(message);
final Collection<Player> players = ess.getOnlinePlayers();
for (Player player : players) {
if (player.getWorld().equals(world)) {
final User user = ess.getUser(player);
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), ess, false);
for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText);
}
}
}
}
use of com.earth2me.essentials.User in project Essentials by drtshock.
the class Economy method deleteNPC.
private static void deleteNPC(String name) {
User user = ess.getUser(name);
user.reset();
}
use of com.earth2me.essentials.User in project Essentials by drtshock.
the class Economy method removeNPC.
/**
* Deletes a user, if it is marked as npc.
*
* @param name Name of the player
*
* @throws UserDoesNotExistException
*/
public static void removeNPC(String name) throws UserDoesNotExistException {
User user = getUserByName(name);
if (user == null) {
throw new UserDoesNotExistException(name);
}
deleteNPC(name);
}
use of com.earth2me.essentials.User in project Essentials by drtshock.
the class Economy method setMoney.
public static void setMoney(String name, BigDecimal balance) throws UserDoesNotExistException, NoLoanPermittedException {
User user = getUserByName(name);
if (user == null) {
throw new UserDoesNotExistException(name);
}
if (balance.compareTo(ess.getSettings().getMinMoney()) < 0) {
throw new NoLoanPermittedException();
}
if (balance.signum() < 0 && !user.isAuthorized("essentials.eco.loan")) {
throw new NoLoanPermittedException();
}
try {
user.setMoney(balance);
} catch (MaxMoneyException ex) {
//TODO: Update API to show max balance errors
}
Trade.log("API", "Set", "API", name, new Trade(balance, ess), null, null, null, ess);
}
use of com.earth2me.essentials.User in project Essentials by drtshock.
the class Commandafk method run.
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
if (args.length > 0 && user.isAuthorized("essentials.afk.others")) {
// if no player found, but message specified, set command executor to target user
User afkUser = user;
String message;
try {
afkUser = getPlayer(server, user, args, 0);
message = args.length > 1 ? getFinalArg(args, 1) : null;
} catch (PlayerNotFoundException e) {
// If only one arg is passed, assume the command executor is targeting another player.
if (args.length == 1) {
throw e;
}
message = getFinalArg(args, 0);
}
toggleAfk(user, afkUser, message);
} else {
String message = args.length > 0 ? getFinalArg(args, 0) : null;
toggleAfk(user, user, message);
}
}
Aggregations