Search in sources :

Example 96 with User

use of com.earth2me.essentials.User in project Essentials by drtshock.

the class EssentialsAntiBuildListener method onBlockBreak.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event) {
    final User user = ess.getUser(event.getPlayer());
    final Block block = event.getBlock();
    final int typeId = block.getTypeId();
    final Material type = block.getType();
    if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build") && !metaPermCheck(user, "break", block)) {
        if (ess.getSettings().warnOnBuildDisallow()) {
            user.sendMessage(tl("antiBuildBreak", type.toString()));
        }
        event.setCancelled(true);
        return;
    }
    if (prot.checkProtectionItems(AntiBuildConfig.blacklist_break, typeId) && !user.isAuthorized("essentials.protect.exemptbreak")) {
        if (ess.getSettings().warnOnBuildDisallow()) {
            user.sendMessage(tl("antiBuildBreak", type.toString()));
        }
        event.setCancelled(true);
        return;
    }
    if (prot.checkProtectionItems(AntiBuildConfig.alert_on_break, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
        prot.getEssentialsConnect().alert(user, type.toString(), tl("alertBroke"));
    }
}
Also used : User(com.earth2me.essentials.User) Block(org.bukkit.block.Block) Material(org.bukkit.Material) EventHandler(org.bukkit.event.EventHandler)

Example 97 with User

use of com.earth2me.essentials.User in project Essentials by drtshock.

the class EssentialsAntiBuildListener method onBlockPlace.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event) {
    final User user = ess.getUser(event.getPlayer());
    final Block block = event.getBlockPlaced();
    final int typeId = block.getTypeId();
    final Material type = block.getType();
    if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build") && !metaPermCheck(user, "place", block)) {
        if (ess.getSettings().warnOnBuildDisallow()) {
            user.sendMessage(tl("antiBuildPlace", type.toString()));
        }
        event.setCancelled(true);
        return;
    }
    if (prot.checkProtectionItems(AntiBuildConfig.blacklist_placement, typeId) && !user.isAuthorized("essentials.protect.exemptplacement")) {
        if (ess.getSettings().warnOnBuildDisallow()) {
            user.sendMessage(tl("antiBuildPlace", type.toString()));
        }
        event.setCancelled(true);
        return;
    }
    if (prot.checkProtectionItems(AntiBuildConfig.alert_on_placement, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
        prot.getEssentialsConnect().alert(user, type.toString(), tl("alertPlaced"));
    }
}
Also used : User(com.earth2me.essentials.User) Block(org.bukkit.block.Block) Material(org.bukkit.Material) EventHandler(org.bukkit.event.EventHandler)

Example 98 with User

use of com.earth2me.essentials.User in project Essentials by drtshock.

the class EssentialsLoopCommand method loopOfflinePlayers.

protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
    if (searchTerm.isEmpty()) {
        throw new PlayerNotFoundException();
    }
    if (matchWildcards && searchTerm.contentEquals("**")) {
        for (UUID sUser : ess.getUserMap().getAllUniqueUsers()) {
            final User matchedUser = ess.getUser(sUser);
            updatePlayer(server, sender, matchedUser, commandArgs);
        }
    } else if (matchWildcards && searchTerm.contentEquals("*")) {
        boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
        for (User onlineUser : ess.getOnlineUsers()) {
            if (skipHidden && onlineUser.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(onlineUser.getBase())) {
                continue;
            }
            updatePlayer(server, sender, onlineUser, commandArgs);
        }
    } else if (multipleStringMatches) {
        if (searchTerm.trim().length() < 3) {
            throw new PlayerNotFoundException();
        }
        final List<Player> matchedPlayers = server.matchPlayer(searchTerm);
        if (matchedPlayers.isEmpty()) {
            final User matchedUser = getPlayer(server, searchTerm, true, true);
            updatePlayer(server, sender, matchedUser, commandArgs);
        }
        for (Player matchPlayer : matchedPlayers) {
            final User matchedUser = ess.getUser(matchPlayer);
            updatePlayer(server, sender, matchedUser, commandArgs);
        }
    } else {
        final User user = getPlayer(server, searchTerm, true, true);
        updatePlayer(server, sender, user, commandArgs);
    }
}
Also used : Player(org.bukkit.entity.Player) User(com.earth2me.essentials.User) UUID(java.util.UUID)

Example 99 with User

use of com.earth2me.essentials.User in project Essentials by drtshock.

the class WorldNameComparator method getWorlds.

/**
     * Used to parse an argument of the type "world(s) selector"
     */
private Set<World> getWorlds(final Server server, final CommandSource sender, final String selector) throws Exception {
    final Set<World> worlds = new TreeSet<>(new WorldNameComparator());
    // If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
    if (selector == null) {
        if (sender.isPlayer()) {
            final User user = ess.getUser(sender.getPlayer());
            worlds.add(user.getWorld());
        } else {
            worlds.addAll(server.getWorlds());
        }
        return worlds;
    }
    // Try to find the world with name = selector
    final World world = server.getWorld(selector);
    if (world != null) {
        worlds.add(world);
    } else // If that fails, Is the argument something like "*" or "all"?
    if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all")) {
        worlds.addAll(server.getWorlds());
    } else // We failed to understand the world target...
    {
        throw new Exception(tl("invalidWorld"));
    }
    return worlds;
}
Also used : User(com.earth2me.essentials.User) World(org.bukkit.World)

Example 100 with User

use of com.earth2me.essentials.User in project Essentials by drtshock.

the class WorldNameComparator method setWorldsTime.

/**
     * Used to set the time and inform of the change
     */
private void setWorldsTime(final CommandSource sender, final Collection<World> worlds, final long ticks, final boolean add) throws Exception {
    User user = ess.getUser(sender.getPlayer());
    for (World world : worlds) {
        if (!canUpdateWorld(user, world)) {
            throw new Exception(tl("timeSetWorldPermission", user.getWorld().getName()));
        }
    }
    // Update the time
    for (World world : worlds) {
        long time = world.getTime();
        if (!add) {
            time -= time % 24000;
        }
        world.setTime(time + (add ? 0 : 24000) + ticks);
    }
    final StringBuilder output = new StringBuilder();
    for (World world : worlds) {
        if (output.length() > 0) {
            output.append(", ");
        }
        output.append(world.getName());
    }
    sender.sendMessage(tl("timeWorldSet", DescParseTickFormat.format(ticks), output.toString()));
}
Also used : User(com.earth2me.essentials.User) World(org.bukkit.World)

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