Search in sources :

Example 71 with User

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);
            }
        }
    }
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) Player(org.bukkit.entity.Player) User(com.earth2me.essentials.User) SimpleTextInput(com.earth2me.essentials.textreader.SimpleTextInput) IText(com.earth2me.essentials.textreader.IText) CommandSource(com.earth2me.essentials.CommandSource)

Example 72 with User

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();
}
Also used : User(com.earth2me.essentials.User)

Example 73 with User

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);
}
Also used : User(com.earth2me.essentials.User)

Example 74 with User

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);
}
Also used : Trade(com.earth2me.essentials.Trade) User(com.earth2me.essentials.User) MaxMoneyException(net.ess3.api.MaxMoneyException)

Example 75 with User

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);
    }
}
Also used : User(com.earth2me.essentials.User)

Aggregations

User (com.earth2me.essentials.User)113 Player (org.bukkit.entity.Player)18 Location (org.bukkit.Location)16 EventHandler (org.bukkit.event.EventHandler)14 World (org.bukkit.World)9 Trade (com.earth2me.essentials.Trade)7 ItemStack (org.bukkit.inventory.ItemStack)6 UUID (java.util.UUID)4 Teleport (com.earth2me.essentials.Teleport)3 IText (com.earth2me.essentials.textreader.IText)3 List (java.util.List)3 Material (org.bukkit.Material)3 IUser (com.earth2me.essentials.IUser)2 Kit (com.earth2me.essentials.Kit)2 OfflinePlayer (com.earth2me.essentials.OfflinePlayer)2 PlayerList (com.earth2me.essentials.PlayerList)2 UserMap (com.earth2me.essentials.UserMap)2 IMessageRecipient (com.earth2me.essentials.messaging.IMessageRecipient)2 KeywordReplacer (com.earth2me.essentials.textreader.KeywordReplacer)2 SimpleTextInput (com.earth2me.essentials.textreader.SimpleTextInput)2