Java Examples for org.bukkit.entity.Item

The following java examples will help you to understand the usage of org.bukkit.entity.Item. These source code samples are taken from different open source projects.

Example 1
Project: MRPG-master  File: ExpListener.java View source code
@EventHandler(priority = EventPriority.LOWEST)
public void onBagPickup(PlayerPickupItemEvent event) {
    final Item item = event.getItem();
    double exp = ExpBag.getExp(item);
    // If the bag is actually a bag
    if (exp != -1.0D) {
        event.setCancelled(true);
        final MPlayer player = MRPG.getPlayer(event.getPlayer());
        if (player == null)
            return;
        player.addExp(exp);
        this.displayExpMessage(player, exp);
        item.remove();
        player.getPlayer().getWorld().playSound(item.getLocation(), Sound.ORB_PICKUP, 1.2f, 1.2f);
    }
}
Example 2
Project: TDM-master  File: Warzone.java View source code
private void initZone() {
    // reset monuments
    for (Monument monument : this.monuments) {
        monument.getVolume().resetBlocks();
        monument.addMonumentBlocks();
    }
    // reset bombs
    for (Bomb bomb : this.bombs) {
        bomb.getVolume().resetBlocks();
        bomb.addBombBlocks();
    }
    // reset cakes
    for (Cake cake : this.cakes) {
        cake.getVolume().resetBlocks();
        cake.addCakeBlocks();
    }
    // reset lobby (here be demons)
    if (this.lobby != null) {
        if (this.lobby.getVolume() != null) {
            this.lobby.getVolume().resetBlocks();
        }
        this.lobby.initialize();
    }
    this.flagThieves.clear();
    this.bombThieves.clear();
    this.cakeThieves.clear();
    if (this.getScoreboardType() != ScoreboardType.NONE) {
        this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
        scoreboard.registerNewObjective(this.getScoreboardType().getDisplayName(), "dummy");
        Objective obj = scoreboard.getObjective(this.getScoreboardType().getDisplayName());
        Validate.isTrue(obj.isModifiable(), "Cannot modify players' scores on the " + this.name + " scoreboard.");
        for (Team team : this.getTeams()) {
            String teamName = team.getKind().getColor() + team.getName() + ChatColor.RESET;
            if (this.getScoreboardType() == ScoreboardType.POINTS) {
                obj.getScore(Bukkit.getOfflinePlayer(teamName)).setScore(team.getPoints());
            } else if (this.getScoreboardType() == ScoreboardType.LIFEPOOL) {
                obj.getScore(Bukkit.getOfflinePlayer(teamName)).setScore(team.getRemainingLifes());
            }
        }
        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
        for (Team team : this.getTeams()) {
            for (Player player : team.getPlayers()) {
                player.setScoreboard(scoreboard);
            }
        }
    }
    // nom drops
    for (Entity entity : (this.getWorld().getEntities())) {
        if (!(entity instanceof Item)) {
            continue;
        }
        // validate position
        if (!this.getVolume().contains(entity.getLocation())) {
            continue;
        }
        // omnomnomnom
        entity.remove();
    }
}
Example 3
Project: war-master  File: Warzone.java View source code
private void initZone() {
    // reset monuments
    for (Monument monument : this.monuments) {
        monument.getVolume().resetBlocks();
        monument.addMonumentBlocks();
    }
    // reset bombs
    for (Bomb bomb : this.bombs) {
        bomb.getVolume().resetBlocks();
        bomb.addBombBlocks();
    }
    // reset cakes
    for (Cake cake : this.cakes) {
        cake.getVolume().resetBlocks();
        cake.addCakeBlocks();
    }
    // reset lobby (here be demons)
    if (this.lobby != null) {
        if (this.lobby.getVolume() != null) {
            this.lobby.getVolume().resetBlocks();
        }
        this.lobby.initialize();
    }
    this.flagThieves.clear();
    this.bombThieves.clear();
    this.cakeThieves.clear();
    if (this.getScoreboardType() != ScoreboardType.NONE) {
        this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
        scoreboard.registerNewObjective(this.getScoreboardType().getDisplayName(), "dummy");
        Objective obj = scoreboard.getObjective(this.getScoreboardType().getDisplayName());
        Validate.isTrue(obj.isModifiable(), "Cannot modify players' scores on the " + this.name + " scoreboard.");
        for (Team team : this.getTeams()) {
            String teamName = team.getKind().getColor() + team.getName() + ChatColor.RESET;
            if (this.getScoreboardType() == ScoreboardType.POINTS) {
                obj.getScore(Bukkit.getOfflinePlayer(teamName)).setScore(team.getPoints());
            } else if (this.getScoreboardType() == ScoreboardType.LIFEPOOL) {
                obj.getScore(Bukkit.getOfflinePlayer(teamName)).setScore(team.getRemainingLifes());
            }
        }
        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
        for (Team team : this.getTeams()) {
            for (Player player : team.getPlayers()) {
                player.setScoreboard(scoreboard);
            }
        }
    }
    // nom drops
    for (Entity entity : (this.getWorld().getEntities())) {
        if (!(entity instanceof Item)) {
            continue;
        }
        // validate position
        if (!this.getVolume().contains(entity.getLocation())) {
            continue;
        }
        // omnomnomnom
        entity.remove();
    }
}
Example 4
Project: xEssentials-master  File: PotatoMoveEvent.java View source code
@EventHandler
public void onPotatoMove(PlayerMoveEvent e) {
    if (pl.getManagers().getPlayerManager().isOnline(e.getPlayer().getName())) {
        XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
        if (xp.isPotato()) {
            if (e.getFrom().distanceSquared(e.getTo()) > 0) {
                Item item = xp.getPotato();
                Vector direction = e.getTo().toVector().subtract(item.getLocation().toVector()).normalize();
                item.setVelocity(direction.multiply(0.5));
            }
        }
    }
}
Example 5
Project: Cosmetics-master  File: PetChristmasElf.java View source code
@Override
public void onUpdate() {
    final Item ITEM = entity.getWorld().dropItem(((Villager) entity).getEyeLocation(), presents.get(r.nextInt(presents.size())));
    ITEM.setPickupDelay(30000);
    ITEM.setVelocity(new Vector(r.nextDouble() - 0.5, r.nextDouble() / 2.0 + 0.3, r.nextDouble() - 0.5).multiply(0.4));
    Bukkit.getScheduler().runTaskLater(getUltraCosmetics(), new Runnable() {

        @Override
        public void run() {
            ITEM.remove();
        }
    }, 5);
}
Example 6
Project: mcAssault-master  File: Grenade.java View source code
public void throwGrenade(final Player player) {
    Location loc = player.getEyeLocation().toVector().add(player.getLocation().getDirection().multiply(2)).toLocation(player.getWorld(), player.getLocation().getYaw(), player.getLocation().getPitch());
    ItemStack itemStack = super.getItemStack();
    ItemStack itemGrenade = new ItemStack(itemStack.getType());
    itemGrenade.setData(super.getItemStack().getData());
    final Item grenade = player.getWorld().dropItem(loc, itemGrenade);
    grenade.setVelocity(player.getLocation().getDirection().multiply(2));
    grenade.setPickupDelay(999999);
    if (player.getItemInHand().getAmount() == 1) {
        player.setItemInHand(new ItemStack(Material.AIR, 1));
    } else {
        ItemStack itemInHand = player.getItemInHand();
        itemInHand.setAmount(itemInHand.getAmount() - 1);
        player.setItemInHand(itemInHand);
    }
    // Makes a delay of the delay variable, and triggers the grenade
    McAssault.plugin.getServer().getScheduler().scheduleSyncDelayedTask(McAssault.plugin, new Runnable() {

        @Override
        public void run() {
            trigger(player, grenade);
        }
    }, delay);
}
Example 7
Project: NoGlint-master  File: ItemListener.java View source code
@Override
public void onPacketSending(PacketEvent event) {
    PacketContainer packet = event.getPacket();
    int entityID = packet.getIntegers().read(0);
    int type = packet.getIntegers().read(9);
    /*
        ItemStacks are ID'd as 2.
         */
    if (type == 2) {
        Entity entity = packet.getEntityModifier(event).read(0);
        //Lets just make sure
        if (entity instanceof Item) {
            ItemStack item = ((Item) entity).getItemStack();
            if (plugin.getGlintManager().isGlintDisabled(event.getPlayer().getUniqueId())) {
                GlintUtils.removeGlint(item);
            }
        }
    }
}
Example 8
Project: Zephyrus-II-master  File: ItemListener.java View source code
@SuppressWarnings("deprecation")
@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    ItemStack stack = player.getItemInHand();
    Item item = Zephyrus.getItemManager().getItem(player.getItemInHand());
    User user = Zephyrus.getUser(player);
    boolean didCast = false;
    if (item != null && !(event.getClickedBlock() != null && actionMaterials.contains(event.getClickedBlock().getType()))) {
        event.setCancelled(true);
        if (item != null && item instanceof LevelledItem && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && event.getClickedBlock().getData() == 10) {
            LevelledItem levelled = (LevelledItem) item;
            int level = levelled.getLevel(stack.getItemMeta().getLore());
            if (level < levelled.getMaxLevel()) {
                level++;
                UpgradeTrade trade = Zephyrus.getNMSManager().getItemUpgradeTrade();
                ItemStack input = stack.clone();
                input.setAmount(1);
                ItemStack output = input.clone();
                ItemMeta meta = output.getItemMeta();
                meta.setLore(levelled.getLevelledLore(level));
                output.setItemMeta(meta);
                trade.setOffer(input, new ItemStack(levelled.getMaterialCost(), level), output);
                trade.openTrade(player);
                this.traders.put(player.getName(), trade);
            } else {
                Language.sendError("item.arcane.max", player);
            }
        } else if (item != null && item instanceof ActionItem) {
            ActionItem action = (ActionItem) item;
            if (action.getActions().contains(event.getAction())) {
                if (action.getClass().isAnnotationPresent(Targeted.class)) {
                    Targeted targeted = action.getClass().getAnnotation(Targeted.class);
                    user.setTarget(item, targeted.type(), targeted.range(), targeted.friendly());
                }
                action.onInteract(event);
            }
        } else if (item != null && item instanceof Wand) {
            Wand wand = (Wand) item;
            String bound = wand.getSpell(player.getItemInHand());
            // Spell Crafting
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.BOOKSHELF && !ConfigOptions.DISABLE_SPELL_CRAFTING) {
                List<ItemStack> items;
                BukkitRunnable removalTask;
                if (event.getClickedBlock().getRelative(BlockFace.UP).getType() != Material.CHEST) {
                    final Set<org.bukkit.entity.Item> itemEntity = getEntities(event.getClickedBlock().getLocation().add(0.5, 1.5, 0.5));
                    items = getItems(itemEntity);
                    removalTask = new BukkitRunnable() {

                        @Override
                        public void run() {
                            for (org.bukkit.entity.Item item : itemEntity) {
                                item.remove();
                            }
                        }
                    };
                } else {
                    final Chest chest = (Chest) event.getClickedBlock().getRelative(BlockFace.UP).getState();
                    items = new ArrayList<ItemStack>();
                    for (ItemStack i : chest.getInventory().getContents()) {
                        if (i != null) {
                            items.add(i);
                        }
                    }
                    removalTask = new BukkitRunnable() {

                        @Override
                        public void run() {
                            for (int i = 0; i < chest.getInventory().getSize(); i++) {
                                ItemStack item = chest.getInventory().getItem(i);
                                if (item != null) {
                                    item.setAmount(0);
                                    chest.getInventory().setItem(i, item);
                                }
                            }
                            chest.update(true);
                        }
                    };
                }
                List<Spell> possibleSpells = Zephyrus.getSpell(items);
                List<Spell> spells = new ArrayList<Spell>();
                for (Spell spell : possibleSpells) {
                    if (wand.getCraftingAbilityLevel() < spell.getRequiredLevel()) {
                        Language.sendError("crafting.reqwandlevel", player, "[SPELL]", spell.getName());
                        continue;
                    }
                    if (user.getLevel() < spell.getRequiredLevel()) {
                        Language.sendError("crafting.reqplayerlevel", player, "[SPELL]", spell.getName());
                        continue;
                    }
                    spells.add(spell);
                }
                if (spells.size() == 1) {
                    Spell spell = spells.get(0);
                    UserCraftSpellEvent craftEvent = new UserCraftSpellEvent(player, spell);
                    Bukkit.getPluginManager().callEvent(craftEvent);
                    if (!craftEvent.isCancelled()) {
                        Location loc = event.getClickedBlock().getLocation().add(0.5, 1.5, 0.5);
                        loc.getWorld().dropItem(loc, SpellTome.createSpellTome(spell)).setVelocity(new Vector(0, 0, 0));
                        int amount = 1;
                        if (user.getLevel() < 7) {
                            amount = 1;
                        } else if (user.getLevel() < 15) {
                            amount = 2;
                        } else {
                            amount = 3;
                        }
                        event.getClickedBlock().setType(Material.AIR);
                        removalTask.run();
                        loc.getWorld().dropItem(loc, new ItemStack(Material.BOOK, amount)).setVelocity(new Vector(0, 0, 0));
                        ParticleEffects.sendParticle(Particle.ENCHANTMENT_TABLE, loc, 0.25F, 0.1F, 0.25F, 0, 50);
                        player.playSound(loc, Sound.ORB_PICKUP, 3, 12);
                    }
                } else if (spells.size() > 1) {
                    InventoryGUI gui = new InventoryGUI(Language.get("crafting.selectionname", "Craft which spell?"));
                    for (int i = 0; i < spells.size(); i++) {
                        gui.setSlot(i + 1, SpellTome.createSpellTome(spells.get(i)), getButton(spells.get(i), event.getClickedBlock(), removalTask));
                    }
                    gui.open(player);
                } else {
                    Language.sendError("crafting.nospell", player);
                }
            // Checking Bound Spell
            } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE) {
                event.getClickedBlock().setData((byte) 10);
                Language.sendMessage("item.arcane.create", player);
                return;
            } else if (player.isSneaking() && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
                Language.sendMessage("item.wand.bound", player, "[SPELL]", bound != null ? bound : "none");
            // Casting Bound Spell
            } else if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (user.isCastingSpell()) {
                    user.stopCasting();
                } else if (bound != null) {
                    Spell spell = Zephyrus.getSpell(bound);
                    didCast = true;
                    user.castSpell(spell, 1 + wand.getPowerIncrease(spell), null);
                } else {
                    Language.sendError("item.wand.nobound", player);
                }
            }
        }
    }
    if (user.isCastingSpell() && !didCast) {
        user.stopCasting();
    }
}
Example 9
Project: ChestPlate-master  File: CP_Sorter.java View source code
public CP_Return interact(Block plate, Entity entity) {
    if (!(/*entity instanceof ExperienceOrb || */
    entity instanceof Item)) {
        return CP_Return.pass;
    }
    Block block = find(plate);
    if (block == null)
        return CP_Return.pass;
    BlockState blockstate = block.getState();
    if (!(blockstate instanceof Sign))
        return CP_Return.pass;
    Item item = (Item) entity;
    ItemStack stack = item.getItemStack();
    Byte data = block.getData();
    double srad = Math.PI * (((2F / 16F * data.doubleValue())) + 0.5);
    //double srad = Math.toRadians(((360F/16F)*(data.doubleValue()))+90);
    //System.out.println("angle "+srad+" "+Math.cos(srad)+", "+Math.sin(srad));
    Sign sign = (Sign) block.getState();
    Vector a = item.getVelocity();
    double angle = Math.atan2(a.getZ(), a.getX());
    boolean pulse = false;
    boolean redirect = false;
    String[] lines = sign.getLines();
    for (String line : lines) {
        for (String str : line.split(",")) {
            str = str.trim();
            boolean negate = false;
            if (str.startsWith("-")) {
                negate = true;
                str = str.substring(1);
            }
            boolean match = cp.itemmatch.Type_Match(str.toUpperCase(), stack.getTypeId(), stack.getData().getData());
            if (match) {
                redirect = !negate;
            }
        }
    }
    Block container = findContainer(block);
    if (container != null && redirect == true) {
        return pickup(plate, container, item);
    }
    if (redirect == true) {
        angle = srad;
        pulse = true;
    }
    /*{
            Location loc = item.getLocation();
            double nx = block.getX()-0.5+Math.cos(angle);
            double ny = block.getY()-0.5+Math.sin(angle);
            angle = Math.atan2(ny-loc.getY(), nx-loc.getX());
        }*/
    a.setX(Math.cos(angle) * 0.25);
    a.setZ(Math.sin(angle) * 0.25);
    a.setY(0.05);
    item.setVelocity(a);
    if (pulse == true) {
        depressPlate(plate);
        return CP_Return.done;
    }
    return CP_Return.cancel;
}
Example 10
Project: DDCustomPlugin-master  File: DirectionBook.java View source code
public boolean checkExisting() {
    try {
        for (Entity thing : loc.getChunk().getEntities()) {
            if (thing instanceof Item) {
                if (thing.getLocation().distance(loc) < 2 && ((Item) thing).getItemStack().getType() == Material.WRITTEN_BOOK) {
                    //						log("Found items. No need to respawn");
                    return true;
                }
            }
        }
    } catch (Exception e) {
        log("Couldn't find the items before spawning!");
    }
    return false;
}
Example 11
Project: EpicSpleef-master  File: SuperModesTask.java View source code
@Override
public void run() {
    for (SpleefArena arena : SpleefArena.getSpleefArenas()) {
        if (arena.getConfiguration().getMode() == SpleefMode.SUPER_SPLEEF && arena.getStatus() == GameStatus.ACTIVE && !arena.countdownIsActive()) {
            // grenade
            if (Math.random() < 0.05) {
                ArrayList<SpleefBlock> blocks = arena.getBlocks();
                SpleefBlock block = blocks.get((int) (Math.random() * blocks.size()));
                int counter = blocks.size() / 2;
                while (block.toBlock(arena.getWorld()).getType() != block.getType() && !block.getType().isSolid() && counter > 0) {
                    block = blocks.get((int) (Math.random() * blocks.size()));
                    counter--;
                }
                if (counter > 0) {
                    Item item = arena.getWorld().dropItem(block.toBlock(arena.getWorld()).getLocation().add(0, 1, 0), SuperModeItems.GRENADE.getItemStack());
                    item.setMetadata("EpicSpleef:" + arena.getName() + ":Grenade", new FixedMetadataValue(SpleefMain.getInstance(), 1));
                }
            }
            // speed boost
            if (Math.random() < 0.05) {
                ArrayList<SpleefBlock> blocks = arena.getBlocks();
                SpleefBlock block = blocks.get((int) (Math.random() * blocks.size()));
                int counter = blocks.size() / 2;
                while (block.toBlock(arena.getWorld()).getType() != block.getType() && !block.getType().isSolid() && counter > 0) {
                    block = blocks.get((int) (Math.random() * blocks.size()));
                    counter--;
                }
                if (counter > 0) {
                    Item item = arena.getWorld().dropItem(block.toBlock(arena.getWorld()).getLocation().add(0, 1, 0), SuperModeItems.SPEED_BOOST.getItemStack());
                    item.setMetadata("EpicSpleef:" + arena.getName() + ":Speed", new FixedMetadataValue(SpleefMain.getInstance(), 1));
                }
            }
            // jump boost
            if (Math.random() < 0.05) {
                ArrayList<SpleefBlock> blocks = arena.getBlocks();
                SpleefBlock block = blocks.get((int) (Math.random() * blocks.size()));
                int counter = blocks.size() / 2;
                while (block.toBlock(arena.getWorld()).getType() != block.getType() && !block.getType().isSolid() && counter > 0) {
                    block = blocks.get((int) (Math.random() * blocks.size()));
                    counter--;
                }
                if (counter > 0) {
                    Item item = arena.getWorld().dropItem(block.toBlock(arena.getWorld()).getLocation().add(0, 1, 0), SuperModeItems.JUMP_BOOST.getItemStack());
                    item.setMetadata("EpicSpleef:" + arena.getName() + ":Jump", new FixedMetadataValue(SpleefMain.getInstance(), 1));
                }
            }
            // invisibility
            if (Math.random() < 0.05) {
                ArrayList<SpleefBlock> blocks = arena.getBlocks();
                SpleefBlock block = blocks.get((int) (Math.random() * blocks.size()));
                int counter = blocks.size() / 2;
                while (block.toBlock(arena.getWorld()).getType() != block.getType() && !block.getType().isSolid() && counter > 0) {
                    block = blocks.get((int) (Math.random() * blocks.size()));
                    counter--;
                }
                if (counter > 0) {
                    Item item = arena.getWorld().dropItem(block.toBlock(arena.getWorld()).getLocation().add(0, 1, 0), SuperModeItems.INVISIBILITY.getItemStack());
                    item.setMetadata("EpicSpleef:" + arena.getName() + ":Invisibility", new FixedMetadataValue(SpleefMain.getInstance(), 1));
                }
            }
        }
    }
}
Example 12
Project: MagicSpells-master  File: ProjectileSpell.java View source code
@Override
public PostCastAction castSpell(Player player, SpellCastState state, float power, String[] args) {
    if (state == SpellCastState.NORMAL) {
        if (projectileClass != null) {
            Projectile projectile = player.launchProjectile(projectileClass);
            projectile.setBounce(false);
            if (velocity > 0) {
                projectile.setVelocity(player.getLocation().getDirection().multiply(velocity));
            }
            if (horizSpread > 0 || vertSpread > 0) {
                Vector v = projectile.getVelocity();
                v.add(new Vector((random.nextDouble() - .5) * horizSpread, (random.nextDouble() - .5) * vertSpread, (random.nextDouble() - .5) * horizSpread));
                projectile.setVelocity(v);
            }
            if (applySpellPowerToVelocity) {
                projectile.setVelocity(projectile.getVelocity().multiply(power));
            }
            projectile.setMetadata("MagicSpellsSource", new FixedMetadataValue(MagicSpells.plugin, "ProjectileSpell_" + internalName));
            projectiles.put(projectile, new ProjectileInfo(player, power, (effectInterval > 0 ? new RegularProjectileMonitor(projectile) : null)));
            playSpellEffects(EffectPosition.CASTER, projectile);
        } else if (projectileItem != null) {
            Item item = player.getWorld().dropItem(player.getEyeLocation(), projectileItem.clone());
            Vector v = player.getLocation().getDirection().multiply(velocity > 0 ? velocity : 1);
            if (horizSpread > 0 || vertSpread > 0) {
                v.add(new Vector((random.nextDouble() - .5) * horizSpread, (random.nextDouble() - .5) * vertSpread, (random.nextDouble() - .5) * horizSpread));
            }
            if (applySpellPowerToVelocity) {
                v.multiply(power);
            }
            item.setVelocity(v);
            item.setPickupDelay(10);
            itemProjectiles.put(item, new ProjectileInfo(player, power, new ItemProjectileMonitor(item)));
            playSpellEffects(EffectPosition.CASTER, item);
        }
    }
    return PostCastAction.HANDLE_NORMALLY;
}
Example 13
Project: mcMMO-master  File: FishingManager.java View source code
/**
     * Process the results from a successful fishing trip
     *
     * @param fishingCatch The {@link Item} initially caught
     */
public void handleFishing(Item fishingCatch) {
    this.fishingCatch = fishingCatch;
    int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
    int treasureXp = 0;
    Player player = getPlayer();
    FishingTreasure treasure = null;
    if (Config.getInstance().getFishingDropsEnabled() && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHING_TREASURE_HUNTER)) {
        treasure = getFishingTreasure();
        this.fishingCatch = null;
    }
    if (treasure != null) {
        // Not cloning is bad, m'kay?
        ItemStack treasureDrop = treasure.getDrop().clone();
        Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
        if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MAGIC_HUNTER) && ItemUtils.isEnchantable(treasureDrop)) {
            enchants = handleMagicHunter(treasureDrop);
        }
        McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
        if (!event.isCancelled()) {
            treasureDrop = event.getTreasure();
            treasureXp = event.getXp();
        } else {
            treasureDrop = null;
            treasureXp = 0;
        }
        // Drop the original catch at the feet of the player and set the treasure as the real catch
        if (treasureDrop != null) {
            boolean enchanted = false;
            if (!enchants.isEmpty()) {
                treasureDrop.addUnsafeEnchantments(enchants);
                enchanted = true;
            }
            if (enchanted) {
                player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
            }
            if (Config.getInstance().getFishingExtraFish()) {
                Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
            }
            fishingCatch.setItemStack(treasureDrop);
        }
    }
    applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
}
Example 14
Project: McMMOPlus-master  File: FishingManager.java View source code
/**
     * Process the results from a successful fishing trip
     *
     * @param fishingCatch The {@link Item} initially caught
     */
public void handleFishing(Item fishingCatch) {
    this.fishingCatch = fishingCatch;
    int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
    int treasureXp = 0;
    Player player = getPlayer();
    FishingTreasure treasure = null;
    if (Config.getInstance().getFishingDropsEnabled() && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHING_TREASURE_HUNTER)) {
        treasure = getFishingTreasure();
        this.fishingCatch = null;
    }
    if (treasure != null) {
        // Not cloning is bad, m'kay?
        ItemStack treasureDrop = treasure.getDrop().clone();
        Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
        if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MAGIC_HUNTER) && ItemUtils.isEnchantable(treasureDrop)) {
            enchants = handleMagicHunter(treasureDrop);
        }
        McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
        if (!event.isCancelled()) {
            treasureDrop = event.getTreasure();
            treasureXp = event.getXp();
        } else {
            treasureDrop = null;
            treasureXp = 0;
        }
        // Drop the original catch at the feet of the player and set the treasure as the real catch
        if (treasureDrop != null) {
            boolean enchanted = false;
            if (!enchants.isEmpty()) {
                treasureDrop.addUnsafeEnchantments(enchants);
                enchanted = true;
            }
            if (enchanted) {
                player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
            }
            if (Config.getInstance().getFishingExtraFish()) {
                Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
            }
            fishingCatch.setItemStack(treasureDrop);
        }
    }
    applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
}
Example 15
Project: MyWolf-master  File: Wolves.java View source code
public void run() {
    if (isThere == false || isDead == true || getPlayer() == null) {
        cb.Plugin.getServer().getScheduler().cancelTask(DropTimer);
    } else {
        if (getPlayer() != null) {
            try {
                for (Entity e : MyWolf.getWorld().getEntities()) {
                    if (e instanceof Item) {
                        Item item = (Item) e;
                        Vector distance = getLocation().toVector().add(new Vector(0.5, 0, 0.5)).subtract(item.getLocation().toVector());
                        if (distance.lengthSquared() < 1.0 * cb.cv.WolfPickupRange * cb.cv.WolfPickupRange + 1) {
                            int amountleft = Inventory.addItem(item);
                            if (amountleft == 0) {
                                e.remove();
                            } else {
                                if (item.getItemStack().getAmount() > amountleft) {
                                    item.getItemStack().setAmount(amountleft);
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                System.out.println("Warning! An error occured!");
                e.printStackTrace();
            }
        } else {
            cb.Plugin.getServer().getScheduler().cancelTask(DropTimer);
        }
    }
}
Example 16
Project: NBTEditor-master  File: GenericBomb.java View source code
private void trigger(final Item item) {
    item.setPickupDelay(Integer.MAX_VALUE);
    onTrigger(item);
    Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() {

        @Override
        public void run() {
            if (!item.isDead()) {
                onExplode(item, item.getLocation());
                item.remove();
            }
        }
    }, _fuse);
}
Example 17
Project: PerWorldInventory-master  File: EntityPortalEventListenerTest.java View source code
@Test
public void shouldTeleportBecauseSameGroup() {
    // given
    Group group = mockGroup("test_group", GameMode.SURVIVAL, false);
    Item entity = mock(Item.class);
    World world = mock(World.class);
    given(world.getName()).willReturn("test_group");
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    given(worldNether.getName()).willReturn("test_group_nether");
    Location to = new Location(worldNether, 1, 2, 3);
    given(groupManager.getGroupFromWorld("test_group")).willReturn(group);
    given(groupManager.getGroupFromWorld("test_group_nether")).willReturn(group);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));
    // when
    listener.onEntityPortalTeleport(event);
    // then
    assertThat(event.isCancelled(), equalTo(false));
}
Example 18
Project: UHCRun-master  File: StackListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemSpawn(ItemSpawnEvent event) {
    if (event.getEntityType() != EntityType.DROPPED_ITEM) {
        return;
    }
    Item newEntity = event.getEntity();
    int maxSize = newEntity.getItemStack().getMaxStackSize();
    List<Entity> entityList = newEntity.getNearbyEntities(radius, 1, radius);
    for (Entity anEntityList : entityList) {
        if (anEntityList instanceof Item) {
            Item curEntity = (Item) anEntityList;
            if (!curEntity.isDead()) {
                if (curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType())) {
                    if (curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData()) {
                        if (curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability()) {
                            if (Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= radius && Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= radius && Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= radius) {
                                int newAmount = newEntity.getItemStack().getAmount();
                                int curAmount = curEntity.getItemStack().getAmount();
                                int more = Math.min(newAmount, maxSize - curAmount);
                                curAmount += more;
                                newAmount -= more;
                                curEntity.getItemStack().setAmount(curAmount);
                                newEntity.getItemStack().setAmount(newAmount);
                                if (newAmount <= 0) {
                                    event.setCancelled(true);
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Example 19
Project: Ultra-Hardcore-master  File: Spectator.java View source code
/**
	 * Enable spectator mode for the given player.
	 * 
	 * @param player the player enabling for.
	 * @param force force the enabling.
	 */
public void enableSpecmode(Player player, boolean force) {
    if (force) {
        player.sendMessage(Main.PREFIX + "You are now in spectator mode, do not spoil.");
    } else {
        if (isSpectating(player)) {
            player.sendMessage(Main.PREFIX + "Your spectator mode is already enabled.");
            return;
        }
        player.sendMessage(Main.PREFIX + "You are now in spectator mode, do not spoil.");
    }
    ItemStack compass = new ItemStack(Material.COMPASS);
    ItemMeta compassMeta = compass.getItemMeta();
    compassMeta.setDisplayName(ChatColor.GREEN + "Teleporter");
    compassMeta.setLore(Arrays.asList(ChatColor.GRAY + "Left click to teleport to a random player.", ChatColor.GRAY + "Right click to open a player teleporter."));
    compass.setItemMeta(compassMeta);
    ItemStack vision = new ItemStack(Material.INK_SACK, 1, (short) 12);
    ItemMeta visionMeta = vision.getItemMeta();
    visionMeta.setDisplayName(ChatColor.GREEN + "Toggle Night Vision");
    visionMeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to toggle the night vision effect."));
    vision.setItemMeta(visionMeta);
    ItemStack nether = new ItemStack(Material.LAVA_BUCKET, 1);
    ItemMeta netherMeta = nether.getItemMeta();
    netherMeta.setDisplayName(ChatColor.GREEN + "Players in the nether");
    netherMeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to get a list of players in the nether."));
    nether.setItemMeta(netherMeta);
    ItemStack tp = new ItemStack(Material.FEATHER);
    ItemMeta tpMeta = tp.getItemMeta();
    tpMeta.setDisplayName(ChatColor.GREEN + "Teleport to 0,0");
    tpMeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to teleport to 0,0."));
    tp.setItemMeta(tpMeta);
    player.getInventory().remove(compass);
    player.getInventory().remove(vision);
    player.getInventory().remove(nether);
    player.getInventory().remove(tp);
    for (ItemStack content : player.getInventory().getContents()) {
        if (content != null) {
            Item item = player.getWorld().dropItem(player.getLocation().getBlock().getLocation().add(0.5, 0.7, 0.5), content);
            item.setVelocity(new Vector(0, 0.2, 0));
        }
    }
    for (ItemStack armorContent : player.getInventory().getArmorContents()) {
        if (armorContent != null && armorContent.getType() != Material.AIR) {
            Item item = player.getWorld().dropItem(player.getLocation().getBlock().getLocation().add(0.5, 0.7, 0.5), armorContent);
            item.setVelocity(new Vector(0, 0.2, 0));
        }
    }
    if (player.getTotalExperience() > 0) {
        ExperienceOrb exp = player.getWorld().spawn(player.getLocation().getBlock().getLocation().add(0.5, 0.7, 0.5), ExperienceOrb.class);
        exp.setExperience(player.getTotalExperience());
        exp.setVelocity(new Vector(0, 0.2, 0));
    }
    player.getInventory().setArmorContents(null);
    player.getInventory().clear();
    player.setGameMode(GameMode.SPECTATOR);
    player.setWalkSpeed(0.2f);
    player.setFlySpeed(0.1f);
    Teams.getInstance().joinTeam("spec", player);
    if (!spectators.contains(player.getName())) {
        spectators.add(player.getName());
    }
    player.getInventory().setItem(1, tp);
    player.getInventory().setItem(3, compass);
    player.getInventory().setItem(5, nether);
    player.getInventory().setItem(7, vision);
    for (Player online : PlayerUtils.getPlayers()) {
        if (isSpectating(online)) {
            online.showPlayer(player);
        } else {
            online.hidePlayer(player);
        }
        player.showPlayer(online);
    }
}
Example 20
Project: BKCommonLib-master  File: ItemUtil.java View source code
/**
	 * Checks whether two item stacks equal, while ignoring the item amounts
	 * 
	 * @param item1 to check
	 * @param item2 to check
	 * @return True if the items have the same type, data and enchantments, False if not
	 */
public static boolean equalsIgnoreAmount(org.bukkit.inventory.ItemStack item1, org.bukkit.inventory.ItemStack item2) {
    if (MaterialUtil.getTypeId(item1) != MaterialUtil.getTypeId(item2) || MaterialUtil.getRawData(item1) != MaterialUtil.getRawData(item2)) {
        return false;
    }
    // Metadata checks
    boolean hasMeta = hasMetaTag(item1);
    if (hasMeta != hasMetaTag(item2)) {
        return false;
    } else if (!hasMeta) {
        // No further data to test
        return true;
    }
    if (!item1.getItemMeta().equals(item2.getItemMeta())) {
        return false;
    }
    // Not included in metadata checks: Item attributes (Bukkit needs to update)
    CommonTagList item1Attr = getMetaTag(item1).get("AttributeModifiers", CommonTagList.class);
    CommonTagList item2Attr = getMetaTag(item2).get("AttributeModifiers", CommonTagList.class);
    return LogicUtil.bothNullOrEqual(item1Attr, item2Attr);
}
Example 21
Project: AllArkhamPlugins-master  File: GunListener.java View source code
private static void special(final Player player, final GunData held, final boolean flash, final boolean fire) {
    PreFireEvent preFire = new PreFireEvent(player.getEyeLocation(), GunHolder.getHolder(player), (!flash && !fire));
    Bukkit.getPluginManager().callEvent(preFire);
    if (preFire.isCancelled())
        return;
    String preShoot = held.getDefaultAttribute("sound.use", "").getStringValue();
    if (preShoot != "")
        SoundUtil.playSound(player.getLocation(), preShoot, player);
    final double radius = held.getDefaultAttribute("usage.radius", 2.0).getDoubleValue();
    final double damage = held.getAttribute("damage").getDoubleValue();
    final int flashDuration = held.getDefaultAttribute("usage.duration", 4).getIntValue();
    final double accuracy = held.getAttribute("accuracy").getDoubleValue();
    final double bulletSpeed = held.getDefaultAttribute("bulletspeed", 2.0).getDoubleValue();
    int $id = held.getDefaultAttribute("usage.drop.id", 1).getIntValue();
    byte $data = (byte) held.getDefaultAttribute("usage.drop.data", 0).getIntValue();
    if (fire) {
        final Projectile proj = player.launchProjectile(Snowball.class);
        SpecialFireEvent fireEvent = new SpecialFireEvent(proj.getLocation(), proj, null);
        Bukkit.getPluginManager().callEvent(fireEvent);
        Vector v = proj.getVelocity();
        v = v.multiply(bulletSpeed);
        v = v.add(new Vector((Math.random() * accuracy) - (accuracy / 2), (Math.random() * accuracy) - (accuracy / 2), (Math.random() * accuracy) - (accuracy / 2)));
        proj.setVelocity(v);
        molotov.put(proj, new Runnable() {

            public void run() {
                for (LivingEntity player : proj.getWorld().getLivingEntities()) {
                    if (player.getLocation().distance(proj.getLocation()) <= radius) {
                        player.setFireTicks(held.getDefaultAttribute("usage.fire", 10).getIntValue() * 20);
                    }
                }
                ParticleEffects.sendToLocation(ParticleEffects.FLAME, proj.getLocation(), (float) radius / 2, (float) radius / 3, (float) radius / 2, 0f, (int) (radius * 50));
                ParticleEffects.sendToLocation(ParticleEffects.LARGE_SMOKE, proj.getLocation(), (float) radius / 2, (float) radius / 3, (float) radius / 2, 0f, (int) (radius * 50));
                SoundUtil.playSound(proj.getLocation(), held.getDefaultAttribute("sounds.flash", "GLASS-1-0-0").getStringValue(), Bukkit.getOnlinePlayers());
            }
        });
        return;
    }
    ItemStack stack = new ItemStack($id, 1, (short) 0, $data);
    final Item proj = player.getWorld().dropItem(player.getEyeLocation(), stack);
    SpecialFireEvent fireEvent = new SpecialFireEvent(proj.getLocation(), null, proj);
    Bukkit.getPluginManager().callEvent(fireEvent);
    Vector v = player.getEyeLocation().getDirection();
    v.normalize();
    v = v.multiply(bulletSpeed);
    v = v.add(new Vector((Math.random() * accuracy) - (accuracy / 2), (Math.random() * accuracy) - (accuracy / 2), (Math.random() * accuracy) - (accuracy / 2)));
    ExplosionUtil.deny_pickup.add(proj);
    proj.setVelocity(v);
    Runnable explode = new Runnable() {

        public void run() {
            final Location current = proj.getLocation();
            proj.remove();
            if (flash) {
                SoundUtil.playSound(current, held.getDefaultAttribute("sounds.special", "FIREWORK_TWINKLE-1-2-0").getStringValue(), Bukkit.getOnlinePlayers());
                ParticleEffects.sendToLocation(ParticleEffects.CLOUD, current, (float) radius, (float) radius, (float) radius, 0.1f, 50);
            } else if (!fire) {
                SoundUtil.playSound(current, held.getDefaultAttribute("sounds.special", "EXPLODE-1-0-0").getStringValue(), Bukkit.getOnlinePlayers());
                ParticleEffects.sendToLocation(ParticleEffects.HUGE_EXPLOSION, current, 0f, 0f, 0f, 1f, 1);
                //compute kaboom
                ExplosionUtil.destroyBlocks(radius, current, 30);
            } else {
                ParticleEffects.sendToLocation(ParticleEffects.FLAME, current, (float) radius, 2f, (float) radius, 0f, (int) (radius * 50));
                SoundUtil.playSound(current, held.getDefaultAttribute("sounds.special", "GLASS-1-0-0").getStringValue(), Bukkit.getOnlinePlayers());
            }
            final List<LivingEntity> online = proj.getWorld().getLivingEntities();
            Runnable inRadius = new Runnable() {

                @Override
                public void run() {
                    List<LivingEntity> inRange = Lists.newArrayList();
                    for (LivingEntity player : online) {
                        if (player.getLocation().distance(current) <= radius)
                            inRange.add(player);
                    }
                    final List<LivingEntity> clone = new ArrayList<LivingEntity>(inRange);
                    Runnable sync = new Runnable() {

                        public void run() {
                            for (LivingEntity _player : clone) {
                                if (flash)
                                    _player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * flashDuration, 1));
                                else {
                                    PreFireEvent pfe = new PreFireEvent(_player.getLocation(), GunHolder.getHolder(player), true);
                                    Bukkit.getPluginManager().callEvent(pfe);
                                    if (!(pfe.isCancelled()))
                                        _player.damage(ArmorUtil.recomputeDamage(_player, damage - (_player.getLocation().distance(current) / 2)));
                                }
                            }
                        }
                    };
                    ExplosionUtil.deny_pickup.remove(proj);
                    Bukkit.getScheduler().scheduleSyncDelayedTask(GTAGuns.getInstnace(), sync);
                }
            };
            Bukkit.getScheduler().scheduleAsyncDelayedTask(GTAGuns.getInstnace(), inRadius);
        }
    };
    Bukkit.getScheduler().scheduleSyncDelayedTask(GTAGuns.getInstnace(), explode, held.getDefaultAttribute("usage.timer", 5).getIntValue() * 20);
}
Example 22
Project: Denizen-For-Bukkit-master  File: dNPC.java View source code
@Override
public void adjust(Mechanism mechanism) {
    Element value = mechanism.getValue();
    // -->
    if (mechanism.matches("set_assignment") && mechanism.requireObject(dScript.class)) {
        getAssignmentTrait().setAssignment(value.asType(dScript.class).getName(), null);
    }
    // -->
    if (mechanism.matches("remove_assignment")) {
        getAssignmentTrait().removeAssignment(null);
    }
    // -->
    if (mechanism.matches("set_nickname")) {
        getNicknameTrait().setNickname(value.asString());
    }
    // -->
    if (mechanism.matches("remove_nickname")) {
        getNicknameTrait().removeNickname();
    }
    // -->
    if (mechanism.matches("set_entity_type") && mechanism.requireObject(dEntity.class)) {
        getCitizen().setBukkitEntityType(value.asType(dEntity.class).getBukkitEntityType());
    }
    // -->
    if (mechanism.matches("name") || mechanism.matches("set_name")) {
        getCitizen().setName(value.asString().length() > 64 ? value.asString().substring(0, 64) : value.asString());
    }
    // -->
    if (mechanism.matches("owner")) {
        getCitizen().getTrait(Owner.class).setOwner(value.asString());
    }
    // -->
    if (mechanism.matches("skin_blob")) {
        if (!mechanism.hasValue()) {
            getCitizen().data().remove(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA);
            getCitizen().data().remove(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA);
        } else {
            String[] dat = mechanism.getValue().asString().split(";");
            getCitizen().data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, dat[0]);
            getCitizen().data().setPersistent(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA, dat.length > 0 ? dat[1] : null);
        }
        if (getCitizen().isSpawned()) {
            getCitizen().despawn(DespawnReason.PENDING_RESPAWN);
            getCitizen().spawn(getCitizen().getStoredLocation());
        }
    }
    // -->
    if (mechanism.matches("skin")) {
        if (!mechanism.hasValue()) {
            getCitizen().data().remove(NPC.PLAYER_SKIN_UUID_METADATA);
        } else {
            getCitizen().data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, mechanism.getValue().asString());
        }
        if (getCitizen().isSpawned()) {
            getCitizen().despawn(DespawnReason.PENDING_RESPAWN);
            getCitizen().spawn(getCitizen().getStoredLocation());
        }
    }
    // -->
    if (mechanism.matches("item_type") && mechanism.requireObject(dItem.class)) {
        dItem item = mechanism.getValue().asType(dItem.class);
        Material mat = item.getMaterial().getMaterial();
        int data = item.getMaterial().getData((byte) 0);
        switch(getEntity().getType()) {
            case DROPPED_ITEM:
                ((org.bukkit.entity.Item) getEntity()).getItemStack().setType(mat);
                //((ItemController.ItemNPC) getEntity()).setType(mat, data);
                break;
            case ITEM_FRAME:
                ((ItemFrame) getEntity()).getItem().setType(mat);
                //((ItemFrameController.ItemFrameNPC) getEntity()).setType(mat, data);
                break;
            case FALLING_BLOCK:
                //((FallingBlockController.FallingBlockNPC) getEntity()).setType(mat, data);
                break;
            default:
                dB.echoError("NPC is the not an item type!");
                break;
        }
        if (getCitizen().isSpawned()) {
            getCitizen().despawn();
            getCitizen().spawn(getCitizen().getStoredLocation());
        }
    }
    // -->
    if (mechanism.matches("spawn")) {
        if (mechanism.requireObject("Invalid dLocation specified. Assuming last known NPC location.", dLocation.class)) {
            getCitizen().spawn(value.asType(dLocation.class));
        } else {
            getCitizen().spawn(getCitizen().getStoredLocation());
        }
    }
    // -->
    if (mechanism.matches("range") && mechanism.requireFloat()) {
        getCitizen().getNavigator().getDefaultParameters().range(mechanism.getValue().asFloat());
    }
    // -->
    if (mechanism.matches("attack_range") && mechanism.requireFloat()) {
        getCitizen().getNavigator().getDefaultParameters().attackRange(mechanism.getValue().asFloat());
    }
    // -->
    if (mechanism.matches("speed") && mechanism.requireFloat()) {
        getCitizen().getNavigator().getDefaultParameters().speedModifier(mechanism.getValue().asFloat());
    }
    // -->
    if (mechanism.matches("despawn")) {
        getCitizen().despawn(DespawnReason.PLUGIN);
    }
    // -->
    if (mechanism.matches("set_protected") && mechanism.requireBoolean()) {
        getCitizen().setProtected(value.asBoolean());
    }
    // -->
    if (mechanism.matches("lookclose") && mechanism.requireBoolean()) {
        getLookCloseTrait().lookClose(value.asBoolean());
    }
    // -->
    if (mechanism.matches("set_examiner")) {
        if (mechanism.getValue().toString().equalsIgnoreCase("default")) {
            getNavigator().getLocalParameters().clearExaminers();
            getNavigator().getLocalParameters().examiner(new MinecraftBlockExaminer());
        } else if (mechanism.getValue().toString().equalsIgnoreCase("fly")) {
            getNavigator().getLocalParameters().clearExaminers();
            getNavigator().getLocalParameters().examiner(new FlyingBlockExaminer());
        } else if (mechanism.getValue().toString().equalsIgnoreCase("path")) {
            getNavigator().getLocalParameters().clearExaminers();
            getNavigator().getLocalParameters().examiner(new PathBlockExaminer(this, null));
        }
    }
    // -->
    if (mechanism.matches("teleport_on_stuck") && mechanism.requireBoolean()) {
        if (value.asBoolean()) {
            getNavigator().getDefaultParameters().stuckAction(TeleportStuckAction.INSTANCE);
        } else {
            getNavigator().getDefaultParameters().stuckAction(null);
        }
    }
    // -->
    if (mechanism.matches("set_distance") && mechanism.requireDouble()) {
        getNavigator().getDefaultParameters().distanceMargin(mechanism.getValue().asDouble());
    }
    // -->
    if (mechanism.matches("add_waypoint") && mechanism.requireObject(dLocation.class)) {
        if (!getCitizen().hasTrait(Waypoints.class)) {
            getCitizen().addTrait(Waypoints.class);
        }
        Waypoints wp = getCitizen().getTrait(Waypoints.class);
        if ((wp.getCurrentProvider() instanceof WaypointProvider.EnumerableWaypointProvider)) {
            ((List<Waypoint>) ((WaypointProvider.EnumerableWaypointProvider) wp.getCurrentProvider()).waypoints()).add(new Waypoint(value.asType(dLocation.class)));
        }
    }
    // Iterate through this object's properties' mechanisms
    for (Property property : PropertyParser.getProperties(this)) {
        property.adjust(mechanism);
        if (mechanism.fulfilled()) {
            break;
        }
    }
    // Pass along to dEntity mechanism handler if not already handled.
    if (!mechanism.fulfilled()) {
        if (isSpawned()) {
            new dEntity(getEntity()).adjust(mechanism);
        } else {
            mechanism.reportInvalid();
        }
    }
}
Example 23
Project: SparkTrail-master  File: ItemSpray.java View source code
@Override
public boolean play() {
    boolean shouldPlay = super.play();
    if (shouldPlay) {
        for (Location l : this.displayType.getLocations(this.getHolder().getEffectPlayLocation())) {
            for (int i = 1; i <= 5; i++) {
                Item item = this.getWorld().dropItemNaturally(l, new ItemStack(this.idValue, 1, (short) this.metaValue));
                item.setVelocity(item.getVelocity().normalize().multiply(0.4F));
                item.setPickupDelay(Integer.MAX_VALUE);
                new ItemSprayRemoveTask(item);
            }
        }
    }
    return shouldPlay;
}
Example 24
Project: TeamPlugin-master  File: TeamRoll.java View source code
@EventHandler
public void onPlayerPickup(PlayerPickupItemEvent event) {
    if (dropItems.contains(event.getItem().getEntityId())) {
        TeamRoll.dropItems.remove(event.getItem().getEntityId());
    } else if (TeamUtils.getPlayerLeader(event.getPlayer().getName()) != null) {
        Player player = rollPlayer(event.getPlayer());
        if (player != null) {
            Item getItem = event.getItem();
            ItemStack itemStack = getItem.getItemStack();
            HashMap<Integer, ItemStack> map = player.getInventory().addItem(itemStack);
            if (map.isEmpty()) {
                player.sendMessage(ChatColor.DARK_PURPLE + "�喜你获得了物�");
            } else {
                Location loc = player.getLocation();
                player.getWorld().dropItem(loc, itemStack);
            }
            getItem.remove();
            event.setCancelled(true);
        }
    }
}
Example 25
Project: Ablockalypse-master  File: AblockalypseUtility.java View source code
@Override
public void run() {
    Item i = from.getWorld().dropItem(from, item);
    i.setPickupDelay(Integer.MAX_VALUE);
    final ItemStack is = i.getItemStack();
    final Item finali = i;
    new DelayedTask(removalDelay, true) {

        @Override
        public void run() {
            finali.remove();
            Ablockalypse.getExternal().getItemFileManager().giveItem(player, is);
        }
    };
}
Example 26
Project: BleedingMobs-master  File: ParticleProtectionListener.java View source code
@EventHandler(priority = EventPriority.LOW)
public void onChunkUnload(final ChunkUnloadEvent event) {
    final Entity[] entities = event.getChunk().getEntities();
    final BloodStreamTask timer = plugin.getTimer();
    for (Entity entity : entities) {
        if (entity instanceof Item) {
            plugin.getStorage().getItems().restore((Item) entity);
        }
        if (entity instanceof LivingEntity) {
            timer.remove((LivingEntity) entity);
        }
    }
    plugin.getStorage().getUnbreakables().removeByChunk(event.getChunk());
}
Example 27
Project: bukkit-caminus-master  File: VomitCommand.java View source code
public void run() {
    for (int i = 0; i < m_qty; i++) {
        Location vomitLocation = m_target.getEyeLocation();
        double speed = 0.5;
        double pitch = vomitLocation.getPitch() + 90;
        double yaw = vomitLocation.getYaw() + 90;
        double xSpeed = Math.cos(Math.toRadians(yaw)) * Math.sin(Math.toRadians(pitch));
        double zSpeed = Math.sin(Math.toRadians(pitch)) * Math.sin(Math.toRadians(yaw));
        double ySpeed = Math.cos(Math.toRadians(pitch));
        Vector vomitVelocity = new Vector(xSpeed * speed, ySpeed * speed, zSpeed * speed);
        Item item = m_target.getWorld().dropItem(vomitLocation, m_stack);
        item.setPickupDelay(3);
        item.setVelocity(vomitVelocity);
        try {
            Thread.currentThread().sleep(10);
        } catch (InterruptedException e) {
        }
    }
}
Example 28
Project: CraftFX-master  File: EffectRegistry.java View source code
private void initDefaults() {
    register(EffectSpec.builder().aliases("debug").effect( c -> {
        MessageUtil.message(c.getInitiator(), "Triggered %s!", c.getTriggerSpec());
        c.forTargets( t -> MessageUtil.message(c.getInitiator(), "  - %s", t));
    }).build());
    register(EffectSpec.builder().aliases("fly").data(new SpeedData()).data(new ExtentData(null)).effect(START,  c -> {
        final SpeedData speedData = c.getData(SpeedData.class).get();
        c.forTargets( t -> t.getPlayer().ifPresent( p -> {
            p.setAllowFlight(true);
            p.setVelocity(p.getVelocity().setY(1f));
            p.setFlySpeed(speedData.getSpeed());
            c.run(() -> {
                if (p.getAllowFlight())
                    p.setFlying(true);
            });
        }));
    }).effect(END,  c -> c.forTargets( t -> t.getPlayer().ifPresent( p -> {
        p.setAllowFlight(false);
        p.setFlying(false);
    }))).build());
    register(EffectSpec.builder().aliases("message", "msg").effect( c -> {
        final Optional<String> message = c.getData(ConfigData.class).get().get("message", String.class);
        message.ifPresent( m -> c.forTargets( t -> t.getPlayer().ifPresent( p -> MessageUtil.message(p, m))));
    }).build());
    register(EffectSpec.builder().aliases("burn").data(new DurationData(20L)).effect( c -> {
        final DurationData data = c.getData(DurationData.class).get();
        c.forTargets( t -> {
            t.getEntity().ifPresent( e -> e.setFireTicks((int) data.getDurationTicks()));
            t.getBlock().ifPresent( b -> {
                Block b1 = b.getRelative(BlockFace.UP);
                if (b1.isEmpty())
                    b1.setType(Material.FIRE);
            });
            t.getLocation().ifPresent( l -> l.getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 2, true, false));
        });
    }).build());
    register(EffectSpec.builder().aliases("bound armor").data(new ExtentData(null)).build());
    register(EffectSpec.builder().aliases("bukkit effect", "effect").data(new EffectTypeData(0)).effect( c -> {
        final EffectTypeData data = c.getData(EffectTypeData.class).get();
        if (data.getEffect() == null)
            return;
        c.forTargets( t -> t.getAsLocation().ifPresent( l -> l.getWorld().playEffect(l, data.getEffect(), data.getEffectData())));
    }).build());
    register(EffectSpec.builder().aliases("disarm").data(new DurationData(40L)).effect( c -> {
        final DurationData data = c.getData(DurationData.class).get();
        c.forTargets( t -> {
            t.getPlayer().ifPresent( p -> {
                final ItemStack item = p.getItemInHand();
                if (item == null)
                    return;
                final Item i = p.getWorld().dropItemNaturally(p.getLocation(), item);
                p.setItemInHand(null);
                i.setPickupDelay((int) data.getDurationTicks());
            });
            t.getEntity(Creature.class).ifPresent( e -> {
                final EntityEquipment equipment = e.getEquipment();
                final ItemStack item = equipment.getItemInHand();
                if (item == null)
                    return;
                final Item i = e.getWorld().dropItemNaturally(e.getLocation(), item);
                equipment.setItemInHand(null);
                i.setPickupDelay((int) data.getDurationTicks());
            });
        });
    }).build());
    register(EffectSpec.builder().aliases("lightning").effect( c -> c.forTargets( t -> t.getAsLocation().ifPresent( l -> l.getWorld().strikeLightning(l)))).build());
    register(EffectSpec.builder().aliases("sound").data(new SoundData()).effect( c -> {
        final SoundData data = c.getData(SoundData.class).get();
        c.forTargets( t -> t.getPlayer().ifPresent( p -> p.playSound(p.getLocation(), data.getSound(), data.getVolume(), data.getPitch())));
    }).build());
    register(EffectSpec.builder().aliases("spawn entity").data(new EntityTypeData()).effect( c -> {
        final EntityTypeData data = c.getData(EntityTypeData.class).get();
        if (!data.getEntityType().isPresent())
            return;
        c.forTargets( t -> t.getAsLocation().ifPresent( l -> l.getWorld().spawnEntity(l, data.getEntityType().get())));
    }).build());
    register(EffectSpec.builder().aliases("explosion").data(new ExplosionData(4f, false, false)).effect( c -> {
        final ExplosionData data = c.getData(ExplosionData.class).get();
        c.forTargets( t -> t.getAsLocation().ifPresent( l -> l.getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), data.getPower(), data.isSetsFire(), data.isBlockDamage())));
    }).build());
    register(EffectSpec.builder().aliases("invisibility").data(new ExtentData(null)).effect(START,  c -> c.forTargets( t -> t.getPlayer().ifPresent( p -> {
        for (Player p1 : Bukkit.getOnlinePlayers()) {
            if (p1 == p)
                continue;
            p1.hidePlayer(p);
        }
    }))).effect(END,  c -> c.forTargets( t -> t.getPlayer().ifPresent( p -> {
        for (Player p1 : Bukkit.getOnlinePlayers()) {
            if (p1 == p)
                continue;
            p1.showPlayer(p);
        }
    }))).build());
    register(EffectSpec.builder().aliases("modify health", "change health").data(// +ve damages the entity
    new ModifyHealthData(5)).effect( c -> {
        final ModifyHealthData data = c.getData(ModifyHealthData.class).get();
        c.forTargets( t -> t.getEntity(LivingEntity.class).ifPresent( e -> {
            final double newHealth = e.getHealth() - data.getHealthAmount();
            e.setHealth(newHealth < 0 ? 0 : newHealth > e.getMaxHealth() ? e.getMaxHealth() : newHealth);
        }));
    }).build());
    register(EffectSpec.builder().aliases("modify food level", "satiate").data(new ModifyFoodData(20)).effect( c -> {
        final ModifyFoodData data = c.getData(ModifyFoodData.class).get();
        c.forTargets( t -> t.getPlayer().ifPresent( p -> {
            final int newFoodLevel = p.getFoodLevel() + data.getFeedAmount();
            final float saturation = p.getFoodLevel() > newFoodLevel ? p.getSaturation() : p.getFoodLevel();
            p.setFoodLevel(newFoodLevel > 20 ? 20 : newFoodLevel < 0 ? 0 : newFoodLevel);
            p.setSaturation(saturation);
        }));
    }).build());
    register(EffectSpec.builder().aliases("modify walk speed", "speed").data(new ExtentData(null)).data(new SpeedData()).effect(START,  c -> {
        final SpeedData data = c.getData(SpeedData.class).get();
        c.forTargets( t -> t.getPlayer().ifPresent( p -> p.setWalkSpeed(data.getSpeed())));
    }).effect(END,  c -> c.forTargets( t -> t.getPlayer().ifPresent( p -> p.setWalkSpeed(0.2f)))).build());
}
Example 29
Project: CraftZ-master  File: FireplaceModule.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    final Player p = event.getPlayer();
    final Item item = event.getItemDrop();
    if (isWorld(item.getWorld())) {
        new BukkitRunnable() {

            @Override
            public void run() {
                if (item.isDead()) {
                    cancel();
                    return;
                }
                List<Entity> ents = EntityChecker.getNearbyEntities(item, 2);
                for (Entity ent : ents) {
                    MetadataValue meta;
                    if (ent instanceof ArmorStand && (meta = EntityChecker.getMeta(ent, "isFireplace")) != null && meta.asBoolean()) {
                        ItemStack result = item.getItemStack();
                        item.remove();
                        Material type = result.getType();
                        switch(type) {
                            case RAW_CHICKEN:
                                result.setType(Material.COOKED_CHICKEN);
                                break;
                            case RAW_BEEF:
                                result.setType(Material.COOKED_BEEF);
                                break;
                            case RAW_FISH:
                                result.setType(Material.COOKED_FISH);
                                break;
                            case PORK:
                                result.setType(Material.GRILLED_PORK);
                                break;
                            case POTATO_ITEM:
                                result.setType(Material.BAKED_POTATO);
                                break;
                            default:
                                break;
                        }
                        cancel();
                        if (p.isOnline()) {
                            p.getWorld().dropItem(p.getLocation(), result).setPickupDelay(0);
                        } else {
                            p.getWorld().dropItem(item.getLocation(), result).setPickupDelay(0);
                        }
                        break;
                    }
                }
            }
        }.runTaskTimer(getCraftZ(), 10, 10);
    }
}
Example 30
Project: DropChest-master  File: EntityWatcher.java View source code
@Override
public void run() {
    try {
        for (World w : plugin.getServer().getWorlds()) {
            for (Entity e : w.getEntities()) {
                if (e instanceof Item) {
                    Item item = (Item) e;
                    for (int i = 0; i < plugin.getChestCount(); i++) {
                        DropChestItem dci = plugin.getChests().get(i);
                        Date date = new Date();
                        if (date.getTime() / 1000 - plugin.config.getIdleTimeAfterRedstone() < dci.getLastRedstoneDrop()) {
                            //skip chest because it hasn't been waiting so long.
                            continue;
                        }
                        Location loc = dci.getLocation();
                        World world = loc.getWorld();
                        Block block = loc.getBlock();
                        int x, z;
                        x = loc.getBlockX() / 16;
                        z = loc.getBlockZ() / 16;
                        if (!world.isChunkLoaded(x, z)) {
                            //Try to load the chunk.
                            world.loadChunk(x, z);
                            continue;
                        }
                        if (!DropChestItem.acceptsBlockType(block.getType())) {
                            //Try to load the chunk.
                            world.loadChunk(x, z);
                            continue;
                        }
                        Vector distance = dci.getBlock().getLocation().toVector().add(new Vector(0.5, 0, 0.5)).subtract(item.getLocation().toVector());
                        if (distance.lengthSquared() < 1.0 * dci.getRadius() * dci.getRadius() + 1) {
                            if (timers.containsKey(item.getEntityId())) {
                                if ((date.getTime() - timers.get(item.getEntityId())) > dci.getDelay()) {
                                    timers.remove(item.getEntityId());
                                    ItemStack stack = item.getItemStack();
                                    DropChestSuckEvent event = new DropChestSuckEvent(dci, item);
                                    Bukkit.getPluginManager().callEvent(event);
                                    if (!event.isCancelled()) {
                                        HashMap<Integer, ItemStack> ret = dci.addItem(stack, FilterType.SUCK);
                                        boolean allin = false;
                                        if (ret.size() == 0) {
                                            item.remove();
                                            allin = true;
                                        } else {
                                            for (ItemStack s : ret.values()) {
                                                stack.setAmount(s.getAmount());
                                            }
                                            item.setItemStack(stack);
                                        }
                                        if (dci.getPercentFull() >= plugin.config.getWarnFillStatus() / 100.0)
                                            dci.warnNearlyFull();
                                        if (allin) {
                                            break;
                                        }
                                        continue;
                                    }
                                }
                            } else {
                                timers.put(item.getEntityId(), date.getTime());
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        System.out.println("Warning! An error occured!");
        e.printStackTrace();
    }
}
Example 31
Project: Skript-master  File: DefaultComparators.java View source code
@Override
public Relation compare(final EntityData e, final ItemType i) {
    if (e instanceof Item)
        return Relation.get(i.isOfType(((Item) e).getItemStack()));
    if (e instanceof ThrownPotion)
        return Relation.get(i.isOfType(Material.POTION.getId(), PotionEffectUtils.guessData((ThrownPotion) e)));
    if (Skript.classExists("org.bukkit.entity.WitherSkull") && e instanceof WitherSkull)
        return Relation.get(i.isOfType(Material.SKULL_ITEM.getId(), (short) 1));
    if (entityMaterials.containsKey(e.getType()))
        return Relation.get(i.isOfType(entityMaterials.get(e.getType()).getId(), (short) 0));
    for (final Entry<Class<? extends Entity>, Material> m : entityMaterials.entrySet()) {
        if (m.getKey().isAssignableFrom(e.getType()))
            return Relation.get(i.isOfType(m.getValue().getId(), (short) 0));
    }
    return Relation.NOT_EQUAL;
}
Example 32
Project: SwornGuns-master  File: PlayerListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    Item dropped = event.getItemDrop();
    GunPlayer gp = plugin.getGunPlayer(event.getPlayer());
    ItemStack lastHold = gp.getLastHeldItem();
    if (lastHold != null) {
        Gun gun = gp.getGun(dropped.getItemStack());
        if (gun != null) {
            if (lastHold.getType() == dropped.getItemStack().getType()) {
                if (gun.isHasClip() && gun.isChanged() && gun.isReloadGunOnDrop()) {
                    gun.reloadGun();
                    event.setCancelled(true);
                }
            }
        }
    }
}
Example 33
Project: UltimateGames-master  File: ThrowableGameItem.java View source code
@Override
public boolean click(Arena arena, PlayerInteractEvent event) {
    if (arena.getStatus() == ArenaStatus.RUNNING) {
        Player player = event.getPlayer();
        Item dropped = player.getWorld().dropItem(player.getEyeLocation(), item.clone());
        dropped.setVelocity(player.getEyeLocation().getDirection().clone().multiply(velocity));
        onItemThrow(arena, dropped);
        return true;
    } else {
        return false;
    }
}
Example 34
Project: DemigodsRPG-master  File: ShrineListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityExplode(final EntityExplodeEvent event) {
    if (event.getEntity() == null || ZoneUtil.inNoDGZone(event.getEntity().getLocation()))
        return;
    final List<ShrineModel> saves = Lists.newArrayList(DGData.SHRINE_R.getShrines(event.getLocation(), 10));
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DGGame.getPlugin(), () -> {
        // Remove all drops from explosion zone
        for (final ShrineModel save : saves) event.getLocation().getWorld().getEntitiesByClass(Item.class).stream().filter( drop -> drop.getLocation().distance(save.getLocation()) <= save.getShrineType().getGroundRadius()).forEach(org.bukkit.entity.Item::remove);
    }, 1);
    if (DGData.SERVER_R.contains("explode-structure", "blaam"))
        return;
    DGData.SERVER_R.put("explode-structure", "blaam", true, 2, TimeUnit.SECONDS);
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DGGame.getPlugin(), () -> {
        for (final ShrineModel save : saves) save.getShrineType().generate(save.getLocation());
    }, 30);
}
Example 35
Project: AutoReferee-master  File: AutoRefMatch.java View source code
@Override
public void run() {
    for (Entity e : getWorld().getEntitiesByClasses(Item.class)) {
        Item item = (Item) e;
        UUID uuid = item.getUniqueId();
        Location prev = itemLocations.get(uuid);
        Location curr = e.getLocation();
        Location stop = lastStoppedLocation.get(uuid);
        if (prev == null)
            continue;
        boolean pass = TeleportationUtil.isBlockPassable(curr.getBlock());
        // if the item is moving upwards and is currently in a passable
        double ydelta = curr.getY() - prev.getY();
        if (ydelta > YDELTA_THRESHOLD && !pass && !elevatedItem.containsKey(uuid))
            elevatedItem.put(uuid, false);
        double dy = stop == null ? 0.0 : curr.getY() - stop.getY();
        if (elevatedItem.containsKey(uuid) && dy >= DISTANCE_THRESHOLD)
            elevatedItem.put(uuid, true);
        if (ydelta < 0.001) {
            // record the last location it was stopped at
            lastStoppedLocation.put(uuid, curr);
            boolean atrest = !TeleportationUtil.isBlockPassable(curr.getBlock().getRelative(0, -1, 0));
            if (elevatedItem.containsKey(uuid) && elevatedItem.get(uuid) && atrest) {
                // if the item didn't elevate high enough, don't worry about it
                if (dy < DISTANCE_THRESHOLD) {
                    elevatedItem.remove(uuid);
                    continue;
                }
                setLastNotificationLocation(curr);
                String coords = LocationUtil.toBlockCoords(curr);
                String msg = ChatColor.DARK_GRAY + String.format("Possible Item Elevator @ (%s) [y%+d] %s", coords, Math.round(dy), new BlockData(item.getItemStack()).getDisplayName());
                for (Player ref : getReferees()) ref.sendMessage(msg);
                AutoReferee.log(msg);
            }
        }
    }
    itemLocations.clear();
    for (Entity e : getWorld().getEntitiesByClasses(Item.class)) itemLocations.put(e.getUniqueId(), e.getLocation());
}
Example 36
Project: BetonQuest-master  File: ConfigUpdater.java View source code
@SuppressWarnings("unused")
private void update_from_v44() {
    try {
        Debug.info("Translating items in 'potion' objectives");
        for (ConfigPackage pack : Config.getPackages().values()) {
            String packName = pack.getName();
            Debug.info("  Handling " + packName + " package");
            FileConfiguration objectives = pack.getObjectives().getConfig();
            FileConfiguration items = pack.getItems().getConfig();
            for (String key : objectives.getKeys(false)) {
                String instruction = objectives.getString(key);
                if (!instruction.startsWith("potion ")) {
                    continue;
                }
                Debug.info("    Found potion objective: '" + instruction + "'");
                String[] parts = instruction.split(" ");
                if (parts.length < 2) {
                    Debug.info("    It's incorrect.");
                    continue;
                }
                int data;
                try {
                    data = Integer.parseInt(parts[1]);
                } catch (NumberFormatException e) {
                    Debug.info("    It's incorrect");
                    continue;
                }
                ItemStack itemStack = new QuestItem("potion data:" + data).generate(1);
                {
                    // it doesn't work without actually spawning the item in-game...
                    World world = Bukkit.getWorlds().get(0);
                    Location loc = new Location(world, 0, 254, 0);
                    Item item = world.dropItem(loc, itemStack);
                    itemStack = item.getItemStack();
                    item.remove();
                }
                String updatedInstruction = QuestItem.itemToString(itemStack);
                Debug.info("    Potion instruction: '" + updatedInstruction + "'");
                String item = null;
                for (String itemKey : items.getKeys(false)) {
                    if (items.getString(itemKey).equals(updatedInstruction)) {
                        item = itemKey;
                    }
                }
                if (item == null) {
                    if (items.contains("potion")) {
                        int index = 2;
                        while (items.contains("potion" + index)) {
                            index++;
                        }
                        item = "potion" + index;
                    } else {
                        item = "potion";
                    }
                }
                Debug.info("    The item with this instruction has key " + item);
                items.set(item, updatedInstruction);
                objectives.set(key, instruction.replace(String.valueOf(data), item));
            }
            pack.getItems().saveConfig();
            pack.getObjectives().saveConfig();
        }
    } catch (Exception e) {
        e.printStackTrace();
        Debug.error(ERROR);
    }
    Debug.broadcast("Translated items in 'potion' objective");
    config.set("display_chat_after_conversation", "false");
    Debug.broadcast("Added an option to display chat messages after the conversation");
    config.set("version", "v45");
    instance.saveConfig();
}
Example 37
Project: Buck---It-master  File: CraftWorld.java View source code
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) {
    net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
    EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), stack);
    entity.c = 10;
    world.a(entity);
    // However, this entity is not at the moment backed by a server entity class so it may be left.
    return new CraftItem(world.getServer(), entity);
}
Example 38
Project: ce-master  File: PiranhaTrap.java View source code
@Override
public void run() {
    if (maxTime >= 0) {
        for (Item fish : fishList) {
            EffectManager.playSound(fish.getLocation(), "BLOCK_WATER_AMBIENT", 0.1f, 0.5f);
            Vector vel = new Vector(0.02 * (rand.nextInt(2) == 1 ? -1 : 1), 0.4, 0.02 * (rand.nextInt(2) == 1 ? -1 : 1));
            fish.setVelocity(vel);
        }
        maxTime--;
    } else {
        for (Item fish : fishList) {
            fish.remove();
        }
        this.cancel();
    }
}
Example 39
Project: ChestHarvester-master  File: JItems.java View source code
public static JItems findItem(Item search) {
    if (search == null || search.getItemStack() == null) {
        return null;
    }
    int id = search.getItemStack().getTypeId();
    byte dat = search.getItemStack().getData().getData();
    for (JItems i : JItems.values()) {
        if (i.ID() == id && i.Data() == dat) {
            return i;
        }
    }
    return null;
}
Example 40
Project: ExperienceMod-master  File: RewardEconomy.java View source code
@Override
public void reward(World world, Location point, ResourceHolder resource) {
    if (world == null)
        throw new NullArgumentException("world");
    if (point == null)
        throw new NullArgumentException("point");
    if (!(resource instanceof CurrencyHolder))
        throw new IllegalArgumentException("Can only award currency.");
    ItemStack stack = economyItem != null ? economyItem : defaultItem;
    Integer worth = economyWorth != null ? economyWorth : defaultWorth;
    // Support negative rewards
    int amount = Math.abs(resource.getAmount());
    int sign = resource.getAmount() < 0 ? -1 : 1;
    // Make sure it's valid too
    if (worth < 1) {
        worth = defaultWorth;
    }
    stack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, -1);
    // Create the proper amount of items
    for (; amount > 0; amount -= worth) {
        int thisAmount = sign * Math.min(amount, worth);
        ItemStack thisStack = stack.clone();
        ItemMeta meta = thisStack.getItemMeta();
        meta.setDisplayName(Integer.toString(thisAmount));
        thisStack.setItemMeta(meta);
        Item spawned = world.dropItemNaturally(point, thisStack);
        listener.pinReward(spawned, thisAmount);
    }
}
Example 41
Project: HyperConomy-master  File: ItemDisplayFactory.java View source code
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
    try {
        Item droppedItem = event.getItemDrop();
        for (ItemDisplay display : displays.values()) {
            if (display.blockItemDrop(droppedItem)) {
                event.setCancelled(true);
                return;
            }
        }
    } catch (Exception e) {
        hc.gDB().writeError(e);
    }
}
Example 42
Project: Lupi-master  File: WolfUtil.java View source code
/**
     * Do the nearby entity check.
     */
public static void doNearbyEntityCheck() {
    for (World world : Bukkit.getServer().getWorlds()) {
        for (Entity entity : world.getEntities()) {
            if (entity instanceof org.bukkit.entity.Wolf) {
                org.bukkit.entity.Wolf bukkitWolf = (org.bukkit.entity.Wolf) entity;
                if (bukkitWolf.isTamed() && wolfManager.hasWolf(bukkitWolf)) {
                    Wolf wolf = wolfManager.getWolf(bukkitWolf);
                    for (Entity nearbyEntity : bukkitWolf.getNearbyEntities(1, 1, 1)) {
                        // Make wolf pickup item, remove the dropped item and add it to wolf's inventory.
                        if (nearbyEntity instanceof Item) {
                            WolfInventory wi = wolf.getInventory();
                            LupiWolfPickupItemEvent event = EventFactory.callLupiWolfPickupItemEvent(wolf, wi);
                            if (!event.isCancelled()) {
                                Item item = (Item) nearbyEntity;
                                wi.addItem(item.getItemStack());
                                item.remove();
                            }
                        }
                    }
                }
            }
        }
    }
}
Example 43
Project: Minecraft-UAPI-master  File: UItemListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
    User user = API.to(event.getPlayer());
    if (user == null)
        return;
    Item entity = event.getItemDrop();
    ItemStack item = entity.getItemStack().clone();
    UItem object = UItemManager.getInstance().getItem(item);
    if (object == null)
        return;
    UItemEvent result = object.call(new UItemEventDrop(user, object, item));
    if (result.isCancelled())
        event.setCancelled(true);
    item = result.getItem();
    if (item == null)
        entity.remove();
    else
        entity.setItemStack(item.clone());
}
Example 44
Project: MonsterTamer-master  File: PlayerListen.java View source code
public static void spawnFromItemDrop(Tamer tamer, PlayerDropItemEvent event, Item item) {
    if (!tamer.hasMonsters() || !tamer.hasStoredMonsters())
        return;
    boolean succeeded = spawnFromLocation(tamer, event.getPlayer(), item.getItemStack().getType(), item.getLocation());
    if (succeeded && Constant.ConsumeItems.getBoolean()) {
        event.getPlayer().sendMessage(ChatColor.GRAY + StringUtils.pluralise("One of the ", "The ", "item", item.getItemStack().getAmount()) + " disappeared.");
        InventoryUtils.decrementItem(item);
    }
}
Example 45
Project: NoCheat-master  File: InventoryListener.java View source code
/**
     * We listen to DropItem events for the Drop check.
     * 
     * @param event
     *            the event
     */
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
protected void onPlayerDropItem(final PlayerDropItemEvent event) {
    final Player player = event.getPlayer();
    // Illegal enchantments hotfix check.
    final Item item = event.getItemDrop();
    if (item != null) {
        // No cancel here.
        Items.checkIllegalEnchantments(player, item.getItemStack());
    }
    // If the player died, all their items are dropped so ignore them.
    if (event.getPlayer().isDead())
        return;
    if (drop.isEnabled(event.getPlayer())) {
        if (drop.check(event.getPlayer())) {
            // TODO: Is the following command still correct? If so, adapt actions.
            /*
                 * Cancelling drop events is not save (in certain circumstances
                 * items will disappear completely). So don't
                 */
            // do it and kick players instead by default.
            event.setCancelled(true);
        }
    }
}
Example 46
Project: NoCheatPlus-master  File: InventoryListener.java View source code
/**
     * We listen to DropItem events for the Drop check.
     * 
     * @param event
     *            the event
     */
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
protected void onPlayerDropItem(final PlayerDropItemEvent event) {
    final Player player = event.getPlayer();
    // Illegal enchantments hotfix check.
    final Item item = event.getItemDrop();
    if (item != null) {
        // No cancel here.
        Items.checkIllegalEnchantments(player, item.getItemStack());
    }
    // If the player died, all their items are dropped so ignore them.
    if (event.getPlayer().isDead())
        return;
    if (drop.isEnabled(event.getPlayer())) {
        if (drop.check(event.getPlayer())) {
            // TODO: Is the following command still correct? If so, adapt actions.
            /*
                 * Cancelling drop events is not save (in certain circumstances
                 * items will disappear completely). So don't
                 */
            // do it and kick players instead by default.
            event.setCancelled(true);
        }
    }
}
Example 47
Project: PickupMoney-master  File: PickupMoney.java View source code
public void spawnMoney(Player p, float money, Location l) {
    if (dropMulti.containsKey(p.getUniqueId()))
        money *= dropMulti.get(p.getUniqueId());
    Item item = l.getWorld().dropItemNaturally(l, getItem(Float.valueOf(money).intValue()));
    String m = String.valueOf(money);
    if (!m.contains("."))
        m = m + ".0";
    item.setCustomName(language.get("nameSyntax").replace("{money}", m));
    item.setCustomNameVisible(true);
}
Example 48
Project: ProjectAres-master  File: ItemTransferListener.java View source code
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    // When this event is fired, the ItemStack in the Item being picked up is temporarily
    // set to the amount that will actually be picked up, while the difference from the
    // actual amount in the stack is available from getRemaining(). When the event returns,
    // the original amount is restored to the stack, meaning that we can't change the amount
    // from inside the event, so instead we replace the entire stack.
    int initialQuantity = event.getItem().getItemStack().getAmount();
    PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(event, ItemTransferEvent.Type.PICKUP, event.getPlayer(), Optional.empty(), Optional.of(new InventorySlot<>(event.getPlayer().getInventory())), event.getItem().getItemStack(), event.getItem(), initialQuantity, event.getPlayer().getOpenInventory().getCursor());
    this.callEvent(transferEvent);
    int quantity = Math.min(transferEvent.getQuantity(), initialQuantity);
    if (!event.isCancelled() && quantity < initialQuantity) {
        event.setCancelled(true);
        if (quantity > 0) {
            ItemStack stack = event.getItem().getItemStack().clone();
            stack.setAmount(stack.getAmount() - quantity);
            event.getItem().setItemStack(stack);
            stack = stack.clone();
            stack.setAmount(quantity);
            event.getPlayer().getInventory().addItem(stack);
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
        }
    }
}
Example 49
Project: RacesAndClasses-master  File: ThrowItemsAroundSpellTrait.java View source code
@Override
public void run() {
    Iterator<Item> itemIt = flying.iterator();
    while (itemIt.hasNext()) {
        Item item = itemIt.next();
        if (!item.isValid() || //laying still.
        item.getVelocity().length() <= 0.1) {
            item.remove();
            itemIt.remove();
            continue;
        }
        List<Entity> nearList = SearchEntity.inCircleAround(item, 2);
        for (Entity near : nearList) {
            if (!(near instanceof LivingEntity))
                continue;
            if (!item.hasMetadata(DELETE_ON_DROP))
                continue;
            //check for near middle of character.
            if (near.getLocation().add(0, 1, 0).distanceSquared(item.getLocation()) > 1)
                continue;
            RaCPlayer thrower = (RaCPlayer) item.getMetadata(DELETE_ON_DROP).get(0).value();
            if (thrower.getPlayer() == near)
                continue;
            entityGotHitByItem(thrower, (LivingEntity) near);
            item.remove();
            itemIt.remove();
            break;
        }
    }
}
Example 50
Project: RoyalCommands-master  File: CmdErase.java View source code
@Override
public boolean runCommand(final CommandSender cs, final Command cmd, final String label, final String[] args) {
    if (!(cs instanceof Player)) {
        cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!");
        return true;
    }
    if (args.length < 1) {
        cs.sendMessage(cmd.getDescription());
        return false;
    }
    Player p = (Player) cs;
    String command = args[0];
    int radius = -1;
    if (args.length > 1) {
        try {
            radius = Integer.valueOf(args[1]);
            if (radius < 0) {
                cs.sendMessage(MessageColor.NEGATIVE + "Invalid radius!");
                return true;
            }
        } catch (Exception e) {
            cs.sendMessage(MessageColor.NEGATIVE + "Invalid radius!");
            return true;
        }
    }
    List<Entity> entlist = (radius < 0) ? p.getWorld().getEntities() : p.getNearbyEntities(radius, radius, radius);
    int count = 0;
    if (command.equalsIgnoreCase("mobs")) {
        for (Entity e : entlist) {
            if (!(e instanceof LivingEntity))
                continue;
            if (e instanceof Player)
                continue;
            e.remove();
            count++;
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "mobs" : "mob") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("monsters")) {
        for (Entity e : entlist) {
            if (!(e instanceof Monster))
                continue;
            e.remove();
            count++;
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "monsters" : "monster") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("animals")) {
        for (Entity e : entlist) {
            if (!(e instanceof Animals))
                continue;
            e.remove();
            count++;
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "animals" : "animal") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("arrows")) {
        for (Entity e : entlist) {
            if (e instanceof Arrow) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "arrows" : "arrow") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("boats")) {
        for (Entity e : entlist) {
            if (e instanceof Boat) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "boats" : "boat") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("littnt")) {
        for (Entity e : entlist) {
            if (e instanceof TNTPrimed) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " tnt" + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("all")) {
        for (Entity e : entlist) {
            if (e instanceof Player)
                continue;
            e.remove();
            count++;
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "entities" : "entity") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("minecarts")) {
        for (Entity e : entlist) {
            if (e instanceof Minecart) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "minecarts" : "minecart") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("xp")) {
        for (Entity e : entlist) {
            if (e instanceof ExperienceOrb) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "orbs" : "orb") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("paintings")) {
        for (Entity e : entlist) {
            if (e instanceof Painting) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "paintings" : "painting") + MessageColor.POSITIVE + ".");
    } else if (command.equalsIgnoreCase("drops")) {
        for (Entity e : entlist) {
            if (e instanceof Item) {
                e.remove();
                count++;
            }
        }
        cs.sendMessage(MessageColor.POSITIVE + "Removed " + MessageColor.NEUTRAL + count + " " + ((count != 1) ? "drops" : "drop") + MessageColor.POSITIVE + ".");
    } else {
        cs.sendMessage(cmd.getDescription());
        return false;
    }
    return true;
}
Example 51
Project: yt-battle-master  File: InvincibilityListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemCombust(EntityCombustEvent event) {
    if (BattlePlugin.configurationHelper().getConfigFile().getBoolean(ConfigurationHelper.GAME_INVINCIBILITY_LOSEONITEMPICKUP)) {
        if (event.getEntityType() == EntityType.DROPPED_ITEM) {
            ItemStack itemStack = ((Item) event.getEntity()).getItemStack();
            BattlePlugin.instance().deadPlayersItems.remove(itemStack.hashCode());
        }
    }
}
Example 52
Project: Torch-master  File: CraftWorld.java View source code
@Override
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) {
    Validate.notNull(item, "Cannot drop a Null item.");
    Validate.isTrue(item.getTypeId() != 0, "Cannot drop AIR.");
    EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), CraftItemStack.asNMSCopy(item));
    entity.pickupDelay = 10;
    world.addEntity(entity, SpawnReason.CUSTOM);
    // However, this entity is not at the moment backed by a server entity class so it may be left.
    return new CraftItem(world.getServer(), entity);
}
Example 53
Project: AntiShare-master  File: StressTest.java View source code
private Item item() {
    ItemStack stack = itemStack();
    final Item item = block().getWorld().dropItemNaturally(block().getLocation(), stack);
    plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

        @Override
        public void run() {
            if (!item.isDead())
                item.remove();
        }
    }, 5L);
    return item;
}
Example 54
Project: bFundamentals-master  File: bCreative.java View source code
/* 
	 * Called when a player picks up an item
	 */
@EventHandler
public void onPlayerItemPickup(PlayerPickupItemEvent event) {
    final Player player = event.getPlayer();
    // If the player has this permission, let them pick things up
    if (hasPermission(player, "bcreative.player.item.pickup")) {
        return;
    }
    // We only care about creative mode
    if (player.getGameMode() != GameMode.CREATIVE) {
        return;
    }
    // Is bCreative active in this world?
    if (!activeWorlds.contains(player.getWorld().getName().toLowerCase())) {
        return;
    }
    // Cancel the pickup event
    event.setCancelled(true);
    // Get the item and the last item the player tried to pickup
    final Item item = event.getItem();
    final Location lastKnown = playersLastPickupItem.get(player);
    if (lastKnown == null || lastKnown.distanceSquared(item.getLocation()) > 25) {
        sendMessage(getName(), player, "You cannot pickup items whilst in creative mode.");
        sendMessage(getName(), player, "Item removed from world.");
        if (lastKnown != null) {
            playersLastPickupItem.remove(player);
        }
        playersLastPickupItem.put(player, item.getLocation());
    }
    item.remove();
}
Example 55
Project: Cardinal-Plus-master  File: Snowflakes.java View source code
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    if (!event.isCancelled() && TeamUtils.getTeamByPlayer(event.getPlayer()) != null && event.getItemDrop().getItemStack().getType().equals(Material.WOOL)) {
        for (TeamModule team : TeamUtils.getTeams()) {
            if (!team.isObserver() && TeamUtils.getTeamByPlayer(event.getPlayer()) != team) {
                for (GameObjective obj : TeamUtils.getShownObjectives(team)) {
                    if (obj instanceof WoolObjective && event.getItemDrop().getItemStack().getData().getData() == ((WoolObjective) obj).getColor().getData()) {
                        if (!items.containsKey(event.getPlayer())) {
                            items.put(event.getPlayer(), new ArrayList<Item>());
                        }
                        List<Item> list = items.get(event.getPlayer());
                        list.add(event.getItemDrop());
                        items.put(event.getPlayer(), list);
                    }
                }
            }
        }
    }
}
Example 56
Project: CrossGaming-BukkitPlugins-master  File: ChestRandomizer.java View source code
public void emptyChests() {
    setLists();
    String world = g.getNext();
    if (world == null)
        //No chest locations set yet
        return;
    int x1 = customConfig.getInt(world + ".corner1.x");
    int y1 = customConfig.getInt(world + ".corner1.y");
    int z1 = customConfig.getInt(world + ".corner1.z");
    int x2 = customConfig.getInt(world + ".corner2.x");
    int y2 = customConfig.getInt(world + ".corner2.y");
    int z2 = customConfig.getInt(world + ".corner2.z");
    int temp;
    if (x1 < x2) {
        temp = x2;
        x2 = x1;
        x1 = temp;
    }
    if (y1 < y2) {
        temp = y2;
        y2 = y1;
        y1 = temp;
    }
    if (z1 < z2) {
        temp = z2;
        z2 = z1;
        z1 = temp;
    }
    World w = Bukkit.getWorld(world);
    if (w == null) {
        Bukkit.createWorld(new WorldCreator(world));
        w = Bukkit.getWorld(world);
    }
    int chestNum = 0;
    int x, y, z;
    for (String path : customConfLocs.getKeys(true)) {
        if (path.toUpperCase().startsWith(world.toUpperCase())) {
            x = customConfLocs.getInt(world + ".c" + Integer.toString(chestNum) + ".x");
            y = customConfLocs.getInt(world + ".c" + Integer.toString(chestNum) + ".y");
            z = customConfLocs.getInt(world + ".c" + Integer.toString(chestNum) + ".z");
            Block b = w.getBlockAt(x, y, z);
            if (b.getState() instanceof Chest) {
                Chest c = (Chest) b.getState();
                Inventory inv = c.getBlockInventory();
                if (inv != null)
                    for (int i = 0; i < 27; i++) inv.setItem(i, new ItemStack(Material.AIR, 1));
            }
            chestNum++;
        }
    }
    List<Entity> entList = w.getEntities();
    for (Entity current : entList) if (current instanceof Item && (current.getLocation().getBlockX() >= x2 && current.getLocation().getBlockX() <= x1 && current.getLocation().getBlockZ() >= z2 && current.getLocation().getBlockZ() <= z1))
        current.remove();
}
Example 57
Project: LWC-master  File: Statistics.java View source code
/**
     * Send a performance report to a Console Sender
     *
     * @param sender
     */
public static void sendReport(CommandSender sender) {
    LWC lwc = LWC.getInstance();
    sender.sendMessage(" ");
    sender.sendMessage(Colors.Red + "LWC Report");
    sender.sendMessage("  Version: " + Colors.Green + LWCInfo.FULL_VERSION);
    sender.sendMessage("  Running time: " + Colors.Green + TimeUtil.timeToString(getTimeRunningSeconds()));
    sender.sendMessage("  Players: " + Colors.Green + Bukkit.getServer().getOnlinePlayers().size() + "/" + Bukkit.getServer().getMaxPlayers());
    sender.sendMessage("  Item entities: " + Colors.Green + getEntityCount(Item.class) + "/" + getEntityCount(null));
    sender.sendMessage("  Permissions API: " + Colors.Green + lwc.getPermissions().getClass().getSimpleName());
    sender.sendMessage("  Currency API: " + Colors.Green + lwc.getCurrency().getClass().getSimpleName());
    sender.sendMessage(" ");
    sender.sendMessage(Colors.Red + " ==== Modules ====");
    for (Map.Entry<Plugin, List<MetaData>> entry : lwc.getModuleLoader().getRegisteredModules().entrySet()) {
        Plugin plugin = entry.getKey();
        List<MetaData> modules = entry.getValue();
        // Why?
        if (plugin == null) {
            continue;
        }
        sender.sendMessage("  " + Colors.Green + plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion() + Colors.Yellow + " -> " + Colors.Green + modules.size() + Colors.Yellow + " registered modules");
    }
    sender.sendMessage(" ");
    sender.sendMessage(Colors.Red + " ==== Database ====");
    sender.sendMessage("  Engine: " + Colors.Green + Database.DefaultType);
    sender.sendMessage("  Protections: " + Colors.Green + formatNumber(lwc.getPhysicalDatabase().getProtectionCount()));
    sender.sendMessage("  Queries: " + Colors.Green + formatNumber(queries) + " | " + String.format("%.2f", getAverage(queries)) + " / second");
    sender.sendMessage(" ");
    sender.sendMessage(Colors.Red + " ==== Cache ==== ");
    ProtectionCache cache = lwc.getProtectionCache();
    double cachePercentFilled = ((double) cache.size() / cache.totalCapacity()) * 100;
    String cacheColour = Colors.Green;
    if (cachePercentFilled > 75 && cachePercentFilled < 85) {
        cacheColour = Colors.Yellow;
    } else if (cachePercentFilled > 85 && cachePercentFilled < 95) {
        cacheColour = Colors.Rose;
    } else if (cachePercentFilled > 95) {
        cacheColour = Colors.Red;
    }
    sender.sendMessage("  Usage: " + cacheColour + String.format("%.2f", cachePercentFilled) + "% " + Colors.White + " ( " + cache.size() + "/" + cache.totalCapacity() + " [" + cache.capacity() + "+" + cache.adaptiveCapacity() + "] )");
    sender.sendMessage("  Profile: ");
    sendMethodCounter(sender, cache.getMethodCounter());
// sender.sendMessage("  Reads: " + formatNumber(cache.getReads()) + " | " + String.format("%.2f", getAverage(cache.getReads())) + " / second");
// sender.sendMessage("  Writes: " + formatNumber(cache.getWrites()) + " | " + String.format("%.2f", getAverage(cache.getWrites())) + " / second");
}
Example 58
Project: MCCasino-master  File: SlotMachine.java View source code
private List<Integer> spinReels() {
    int i = 0;
    List<Integer> results = new ArrayList<Integer>();
    for (Reel reel : reels) {
        Location loc1 = reelLocations.get(i);
        ItemStack item = reel.getRandomItem();
        byte data = getDataFromSign(loc1);
        Location loc2 = getOffsetLocation(data, loc1);
        Item droppedItem = loc2.getWorld().dropItem(loc2, item);
        Vector vect = getVelocity(data);
        droppedItem.setVelocity(vect);
        results.add(item.getTypeId());
        itemsToRemove.add(droppedItem);
        i++;
    }
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new DropCleaner(this), 100L);
    return results;
}
Example 59
Project: MyPet-master  File: EntityMyPet.java View source code
public void dropEquipment() {
    if (myPet instanceof MyPetEquipment) {
        org.bukkit.World world = getBukkitEntity().getWorld();
        Location loc = getBukkitEntity().getLocation();
        for (org.bukkit.inventory.ItemStack is : ((MyPetEquipment) myPet).getEquipment()) {
            if (is != null) {
                org.bukkit.entity.Item i = world.dropItem(loc, is);
                if (i != null) {
                    i.setPickupDelay(10);
                }
            }
        }
    }
}
Example 60
Project: NucleusFramework-master  File: FloatingItem.java View source code
@Override
public boolean spawn(Location location) {
    PreCon.notNull(location);
    if (_isDisposed)
        throw new RuntimeException("Cannot spawn a disposed item.");
    // clone: prevent external changes from affecting the location
    location = location.clone();
    FloatingItemSpawnEvent event = new FloatingItemSpawnEvent(this);
    Nucleus.getEventManager().callBukkit(this, event);
    if (event.isCancelled())
        return false;
    if (!despawn())
        return false;
    _isSpawned = true;
    _currentLocation = location;
    // get corrected location
    final Location spawnLocation = _isCentered ? // add y 0.5 to prevent falling through surface block
    LocationUtils.getCenteredLocation(location, CENTERED_LOCATION).add(0, 0.5, 0) : LocationUtils.add(location, 0, 0.5, 0);
    if (!location.getChunk().isLoaded()) {
        _listener.registerPendingSpawn(this);
        return true;
    }
    // spawn item entity
    Entity entity = location.getWorld().dropItem(spawnLocation, _item.clone());
    _trackedEntity = EntityUtils.trackEntity(entity);
    _entityId = entity.getUniqueId();
    entity.setVelocity(new Vector(0, 0, 0));
    // register entity
    _listener.register(this);
    // prevent stack merging
    Item item = (Item) entity;
    ItemMeta meta = item.getItemStack().getItemMeta();
    meta.setDisplayName(_entityId.toString());
    item.getItemStack().setItemMeta(meta);
    _dataNode.set("location", location);
    _dataNode.set("is-spawned", true);
    _dataNode.set("entity-id", _entityId);
    _dataNode.save();
    _agents.update("onSpawn", entity);
    return true;
}
Example 61
Project: PlotSquared-master  File: ChunkListener.java View source code
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    Item entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == this.lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        this.lastChunk = chunk;
    } else {
        this.lastChunk = null;
    }
}
Example 62
Project: PwnChickenLay-master  File: PwnChickenLayItemSpawnListener.java View source code
// List for the ItemSpawnEvent and then do stuff with it
@EventHandler(priority = EventPriority.HIGHEST)
public void onSpawn(ItemSpawnEvent event) {
    World eworld = event.getLocation().getWorld();
    Location eLoc = event.getLocation();
    // If plugin is not enabled in this world, return
    if (!PwnChickenLay.isEnabledIn(eworld.getName()))
        return;
    Item test = (Item) event.getEntity();
    ItemStack is = test.getItemStack();
    // if item is anything other than an egg, return
    if (is.getType() != Material.EGG)
        return;
    List<Entity> nearby = test.getNearbyEntities(0.01, 0.3, 0.01);
    // check if a player entity is at the same location as the ItemSpawnEvent - if so, probably not a chicken lay and return
    for (int i = 0; i < nearby.size(); i++) {
        if (nearby.get(i) instanceof Player)
            return;
    }
    String world = eworld.getName();
    // check per world settings
    if (plugin.getConfig().getBoolean("perWorld." + world + ".enabled")) {
        // check for biome specific settings in this world
        String ebiome = event.getLocation().getWorld().getBiome(event.getLocation().getBlockX(), event.getLocation().getBlockZ()).toString();
        if (plugin.getConfig().getBoolean("perWorld." + world + ".perBiome." + ebiome + ".enabled")) {
            if (PwnChickenLay.random(plugin.getConfig().getInt("perWorld." + world + ".perBiome." + ebiome + ".layChance"))) {
                List<String> repWith = new ArrayList<String>();
                for (String key : plugin.getConfig().getConfigurationSection("perWorld." + world + ".perBiome." + ebiome + ".replaceWith").getKeys(false)) {
                    Integer loop = plugin.getConfig().getInt("perWorld." + world + ".perBiome." + ebiome + ".replaceWith." + key, 1);
                    for (int x = 0; x < loop; x = x + 1) {
                        repWith.add(key);
                    }
                }
                // Pick an item from the replacement list randomly
                String randomReplacement = repWith.get(PwnChickenLay.randomNumberGenerator.nextInt(repWith.size()));
                // Cancel event and remove the egg
                event.getEntity().remove();
                event.setCancelled(true);
                // doReplacement func
                this.doReplacement(eworld, eLoc, randomReplacement);
            }
        } else // not biome specific so do world default
        {
            if (PwnChickenLay.random(plugin.getConfig().getInt("perWorld." + world + ".layChance"))) {
                List<String> repWith = new ArrayList<String>();
                for (String key : plugin.getConfig().getConfigurationSection("perWorld." + world + ".replaceWith").getKeys(false)) {
                    Integer loop = plugin.getConfig().getInt("perWorld." + world + ".replaceWith." + key, 1);
                    for (int x = 0; x < loop; x = x + 1) {
                        repWith.add(key);
                    }
                }
                // Pick an item from the replacement list randomly
                String randomReplacement = repWith.get(PwnChickenLay.randomNumberGenerator.nextInt(repWith.size()));
                // Cancel event and remove the egg
                event.getEntity().remove();
                event.setCancelled(true);
                // doReplacement func
                this.doReplacement(eworld, eLoc, randomReplacement);
            }
        }
    } else // use global default replacement configurations
    if (PwnChickenLay.random(PwnChickenLay.layChance)) {
        List<String> repWith = new ArrayList<String>();
        for (String key : plugin.getConfig().getConfigurationSection("replaceWith").getKeys(false)) {
            Integer loop = plugin.getConfig().getInt("replaceWith." + key, 1);
            for (int x = 0; x < loop; x = x + 1) {
                repWith.add(key);
            }
        }
        // Pick an item from the replacement list randomly
        String randomReplacement = repWith.get(PwnChickenLay.randomNumberGenerator.nextInt(repWith.size()));
        // Cancel event and remove the egg
        event.getEntity().remove();
        event.setCancelled(true);
        // doReplacement func
        this.doReplacement(eworld, eLoc, randomReplacement);
    } else {
        // log if debug_log is enabled
        if (PwnChickenLay.logEnabled) {
            PwnChickenLay.logToFile("Chicken laid: Default egg, in world: " + world);
        }
    }
}
Example 63
Project: SimplyVanish-master  File: Utils.java View source code
public static void dropItemInHand(Player player) {
    ItemStack stack = player.getItemInHand();
    if (stack == null)
        return;
    if (stack.getType() == Material.AIR)
        return;
    ItemStack newStack = stack.clone();
    Item item = player.getWorld().dropItem(player.getLocation().add(new Vector(0.0, 1.0, 0.0)), newStack);
    if (item != null && !item.isDead()) {
        item.setVelocity(player.getLocation().getDirection().normalize().multiply(0.05));
        player.setItemInHand(null);
    }
}
Example 64
Project: WorldEdit-master  File: BukkitUtil.java View source code
public static BukkitEntity toLocalEntity(Entity e) {
    switch(e.getType()) {
        case EXPERIENCE_ORB:
            return new BukkitExpOrb(toLocation(e.getLocation()), e.getUniqueId(), ((ExperienceOrb) e).getExperience());
        case PAINTING:
            Painting paint = (Painting) e;
            return new BukkitPainting(toLocation(e.getLocation()), paint.getArt(), paint.getFacing(), e.getUniqueId());
        case DROPPED_ITEM:
            return new BukkitItem(toLocation(e.getLocation()), ((Item) e).getItemStack(), e.getUniqueId());
        default:
            return new BukkitEntity(toLocation(e.getLocation()), e.getType(), e.getUniqueId());
    }
}
Example 65
Project: BukkitBridge-master  File: BridgeWorld.java View source code
@Override
public Item dropItem(Location location, ItemStack item) {
    Point pos = BukkitUtil.toPoint(location);
    org.spout.api.inventory.ItemStack is = BukkitUtil.toItemStack(item);
    org.spout.vanilla.component.entity.substance.Item i = org.spout.vanilla.component.entity.substance.Item.drop(pos, is, Vector3f.ZERO);
    return new BridgeItem(i.getOwner());
}
Example 66
Project: CardinalPGM-master  File: Snowflakes.java View source code
@EventHandler
public void onItemDespawnInVoid(EntityDespawnInVoidEvent event) {
    if (!(event.getEntity() instanceof Item) || !event.getEntity().hasMetadata(ITEM_THROWER_META))
        return;
    Player player = Bukkit.getPlayer((UUID) event.getEntity().getMetadata(ITEM_THROWER_META).get(0).value());
    Item item = (Item) event.getEntity();
    if (testDestroy(player, item.getItemStack())) {
        addDestroyed(player, ((Wool) item.getItemStack().getData()).getColor());
    }
}
Example 67
Project: ChunkClaim-master  File: PlayerEventHandler.java View source code
//when a player drops an item
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDrop(PlayerDropItemEvent event) {
    if (!ChunkClaim.plugin.config_worlds.contains(event.getPlayer().getWorld().getName()))
        return;
    Item item = event.getItemDrop();
    Material material = item.getItemStack().getType();
    //allow dropping books
    if (material == Material.WRITTEN_BOOK || material == Material.BOOK_AND_QUILL) {
        return;
    } else {
        //ChunkClaim.addLogEntry("Item drop cancelled.");
        event.setCancelled(true);
    }
}
Example 68
Project: essentials-master  File: Trade.java View source code
public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) throws MaxMoneyException {
    if (getMoney() != null && getMoney().signum() > 0) {
        if (ess.getSettings().isDebug()) {
            ess.getLogger().log(Level.INFO, "paying user " + user.getName() + " via trade " + getMoney().toPlainString());
        }
        user.giveMoney(getMoney());
    }
    if (getItemStack() != null) {
        // This stores the would be overflow
        Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getBase().getInventory(), getItemStack());
        if (overFlow != null) {
            switch(type) {
                case ABORT:
                    if (ess.getSettings().isDebug()) {
                        ess.getLogger().log(Level.INFO, "abort paying " + user.getName() + " itemstack " + getItemStack().toString() + " due to lack of inventory space ");
                    }
                    return overFlow;
                case RETURN:
                    // Pay the user the items, and return overflow
                    final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
                    user.getBase().updateInventory();
                    if (ess.getSettings().isDebug()) {
                        ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " with overflow " + returnStack.get(0).toString());
                    }
                    return returnStack;
                case DROP:
                    // Pay the users the items directly, and drop the rest, will always return no overflow.
                    final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
                    final Location loc = user.getBase().getLocation();
                    for (ItemStack loStack : leftOver.values()) {
                        final int maxStackSize = loStack.getType().getMaxStackSize();
                        final int stacks = loStack.getAmount() / maxStackSize;
                        final int leftover = loStack.getAmount() % maxStackSize;
                        final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
                        for (int i = 0; i < stacks; i++) {
                            final ItemStack stack = loStack.clone();
                            stack.setAmount(maxStackSize);
                            itemStacks[i] = loc.getWorld().dropItem(loc, stack);
                        }
                        if (leftover > 0) {
                            final ItemStack stack = loStack.clone();
                            stack.setAmount(leftover);
                            itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
                        }
                    }
                    if (ess.getSettings().isDebug()) {
                        ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " and dropping overflow " + leftOver.get(0).toString());
                    }
            }
        } else if (ess.getSettings().isDebug()) {
            ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
        }
        user.getBase().updateInventory();
    }
    if (getExperience() != null) {
        SetExpFix.setTotalExperience(user.getBase(), SetExpFix.getTotalExperience(user.getBase()) + getExperience());
    }
    return null;
}
Example 69
Project: libelula-master  File: Round.java View source code
private void roundConditioner() {
    g.closeCages();
    List<Entity> entList = g.getArena().capturePoint.getWorld().getEntities();
    for (Entity current : entList) {
        if ((current instanceof Item) || current.getType() == EntityType.CREEPER || current.getType() == EntityType.WITCH) {
            current.remove();
            System.out.println("Eliminada entidad: " + current.getType());
        }
    }
}
Example 70
Project: PopulationDensity-master  File: EntityEventHandler.java View source code
//when an item despawns
//FEATURE: in the newest region only, regrow trees from fallen saplings
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true)
public void onItemDespawn(ItemDespawnEvent event) {
    //respect config option
    if (!PopulationDensity.instance.regrowTrees)
        return;
    //only care about dropped items
    Entity entity = event.getEntity();
    if (entity.getType() != EntityType.DROPPED_ITEM)
        return;
    if (!(entity instanceof Item))
        return;
    //get info about the dropped item
    ItemStack item = ((Item) entity).getItemStack();
    //only care about saplings
    if (item.getType() != Material.SAPLING)
        return;
    //only care about the newest region
    if (!PopulationDensity.instance.dataStore.getOpenRegion().equals(RegionCoordinates.fromLocation(entity.getLocation())))
        return;
    //only replace these blocks with saplings
    Block block = entity.getLocation().getBlock();
    if (block.getType() != Material.AIR && block.getType() != Material.LONG_GRASS && block.getType() != Material.SNOW)
        return;
    //don't plant saplings next to other saplings or logs
    Block[] neighbors = new Block[] { block.getRelative(BlockFace.EAST), block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH), block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST), block.getRelative(BlockFace.NORTH_WEST) };
    for (int i = 0; i < neighbors.length; i++) {
        if (neighbors[i].getType() == Material.SAPLING || neighbors[i].getType() == Material.LOG)
            return;
    }
    //only plant trees in grass or dirt
    Block underBlock = block.getRelative(BlockFace.DOWN);
    if (underBlock.getType() == Material.GRASS || underBlock.getType() == Material.DIRT) {
        block.setTypeIdAndData(item.getTypeId(), item.getData().getData(), false);
    }
}
Example 71
Project: SupaCommons-master  File: Players.java View source code
public static void dropItem(@Nonnull Player player, @Nonnull Item item, boolean death) {
    Location l = player.getLocation();
    Vector v;
    Random random = RandomUtils.getRandom();
    if (death) {
        double d = random.nextDouble() * 0.5;
        double d1 = random.nextDouble() * PI * 2.0;
        v = new Vector(-Math.sin(d1) * d, 0.2, Math.cos(d1) * d);
    } else {
        double d = 0.3F;
        v = new Vector((-Math.sin(l.getYaw() / 180.0 * PI)) * Math.cos(l.getPitch() / 180.0 * PI * d), -Math.sin(l.getPitch() / 180.0 * PI) * d + 0.1, (Math.cos(l.getYaw() / 180.0 * PI)) * Math.cos(l.getPitch() / 180.0 * PI * d));
        double d1 = random.nextDouble() * PI * 2.0;
        d = 0.02 * random.nextDouble();
        v.setX(v.getX() + (Math.cos(d1) * d));
        v.setY(v.getY() + (random.nextDouble() - random.nextDouble()) * 0.1F);
        v.setZ(v.getZ() + (Math.sin(d1) * d));
    }
    item.setVelocity(v);
}
Example 72
Project: TARDIS-master  File: TARDISFullThemeRunnable.java View source code
@Override
@SuppressWarnings("deprecation")
public void run() {
    // initialise
    if (!running) {
        set = new HashMap<String, Object>();
        where = new HashMap<String, Object>();
        String directory = (tud.getSchematic().isCustom()) ? "user_schematics" : "schematics";
        String path = plugin.getDataFolder() + File.separator + directory + File.separator + tud.getSchematic().getPermission() + ".tschm";
        File file = new File(path);
        if (!file.exists()) {
            plugin.debug(plugin.getPluginName() + "Could not find a schematic with that name!");
            return;
        }
        // get JSON
        JSONObject obj = TARDISSchematicGZip.unzip(path);
        // get dimensions
        JSONObject dimensions = (JSONObject) obj.get("dimensions");
        h = dimensions.getInt("height");
        w = dimensions.getInt("width");
        c = dimensions.getInt("length");
        // calculate startx, starty, startz
        HashMap<String, Object> wheret = new HashMap<String, Object>();
        wheret.put("uuid", uuid.toString());
        ResultSetTardis rs = new ResultSetTardis(plugin, wheret, "", false, 0);
        if (!rs.resultSet()) {
            // abort and return energy
            HashMap<String, Object> wherea = new HashMap<String, Object>();
            wherea.put("uuid", uuid.toString());
            int amount = plugin.getArtronConfig().getInt("upgrades." + tud.getSchematic().getPermission());
            qf.alterEnergyLevel("tardis", amount, wherea, player);
        }
        Tardis tardis = rs.getTardis();
        slot = tardis.getTIPS();
        id = tardis.getTardis_id();
        chunk = getChunk(tardis.getChunk());
        if (tud.getPrevious().getPermission().equals("ender")) {
            // remove ender crystal
            for (Entity end : chunk.getEntities()) {
                if (end.getType().equals(EntityType.ENDER_CRYSTAL)) {
                    end.remove();
                }
            }
        }
        chunks = getChunks(chunk, tud.getSchematic());
        // remove the charged creeper
        Location creeper = getCreeperLocation(tardis.getCreeper());
        Entity ent = creeper.getWorld().spawnEntity(creeper, EntityType.EGG);
        for (Entity e : ent.getNearbyEntities(1.5d, 1.5d, 1.5d)) {
            if (e instanceof Creeper) {
                e.remove();
            }
        }
        ent.remove();
        if (slot != -1) {
            // default world - use TIPS
            TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin);
            TARDISTIPSData pos = tintpos.getTIPSData(slot);
            startx = pos.getCentreX();
            resetx = pos.getCentreX();
            startz = pos.getCentreZ();
            resetz = pos.getCentreZ();
        } else {
            int gsl[] = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id());
            startx = gsl[0];
            resetx = gsl[1];
            startz = gsl[2];
            resetz = gsl[3];
        }
        starty = (tud.getSchematic().getPermission().equals("redstone")) ? 65 : 64;
        downgrade = compare(tud.getPrevious(), tud.getSchematic());
        String[] split = tardis.getChunk().split(":");
        world = plugin.getServer().getWorld(split[0]);
        own_world = plugin.getConfig().getBoolean("creation.create_worlds");
        wg1 = new Location(world, startx, starty, startz);
        wg2 = new Location(world, startx + (w - 1), starty + (h - 1), startz + (c - 1));
        // wall/floor block prefs
        String wall[] = tud.getWall().split(":");
        String floor[] = tud.getFloor().split(":");
        wall_type = Material.valueOf(wall[0]);
        floor_type = Material.valueOf(floor[0]);
        wall_data = TARDISNumberParsers.parseByte(wall[1]);
        floor_data = TARDISNumberParsers.parseByte(floor[1]);
        // get input array
        arr = (JSONArray) obj.get("input");
        // clear existing lamp blocks
        HashMap<String, Object> whered = new HashMap<String, Object>();
        whered.put("tardis_id", id);
        qf.doDelete("lamps", whered);
        // clear existing precious blocks
        HashMap<String, Object> wherep = new HashMap<String, Object>();
        wherep.put("tardis_id", id);
        wherep.put("police_box", 0);
        qf.doDelete("blocks", wherep);
        // set running
        running = true;
        player = plugin.getServer().getPlayer(uuid);
        // remove upgrade data
        plugin.getTrackerKeeper().getUpgrades().remove(uuid);
        // teleport player to safe location
        TARDISMessage.send(player, "UPGRADE_TELEPORT");
        Location loc;
        if (tud.getSchematic().getPermission().equals("twelfth") || tud.getPrevious().getPermission().equals("twelfth")) {
            loc = chunk.getBlock(9, 69, 3).getLocation();
        } else {
            loc = chunk.getBlock(8, 69, 4).getLocation();
        }
        player.teleport(loc);
        // clear lamps table as we'll be adding the new lamp positions later
        HashMap<String, Object> wherel = new HashMap<String, Object>();
        wherel.put("tardis_id", id);
        qf.doDelete("lamps", wherel);
    }
    if (level == (h - 1) && row == (w - 1)) {
        // remove items
        for (Chunk chink : chunks) {
            // remove dropped items
            for (Entity e : chink.getEntities()) {
                if (e instanceof Item) {
                    e.remove();
                }
            }
        }
        // put on the door, redstone torches, signs, and the repeaters
        for (Map.Entry<Block, Byte> entry : postDoorBlocks.entrySet()) {
            Block pdb = entry.getKey();
            byte pddata = entry.getValue();
            pdb.setType(Material.IRON_DOOR_BLOCK);
            pdb.setData(pddata, true);
        }
        // TODO fix redstone blocks falling off
        for (Map.Entry<Block, Byte> entry : postRedstoneTorchBlocks.entrySet()) {
            Block prtb = entry.getKey();
            byte ptdata = entry.getValue();
            prtb.setTypeIdAndData(76, ptdata, true);
        }
        for (Map.Entry<Block, Byte> entry : postLeverBlocks.entrySet()) {
            Block plb = entry.getKey();
            byte pldata = entry.getValue();
            plb.setType(Material.LEVER);
            plb.setData(pldata, true);
        }
        for (Map.Entry<Block, Byte> entry : postTorchBlocks.entrySet()) {
            Block ptb = entry.getKey();
            byte ptdata = entry.getValue();
            ptb.setTypeIdAndData(50, ptdata, true);
        }
        for (Map.Entry<Block, Byte> entry : postRepeaterBlocks.entrySet()) {
            Block prb = entry.getKey();
            byte ptdata = entry.getValue();
            prb.setType(Material.DIODE_BLOCK_OFF);
            prb.setData(ptdata, true);
        }
        for (Map.Entry<Block, Byte> entry : postStickyPistonBaseBlocks.entrySet()) {
            Block pspb = entry.getKey();
            plugin.getGeneralKeeper().getDoorPistons().add(pspb);
            byte pspdata = entry.getValue();
            pspb.setType(Material.PISTON_STICKY_BASE);
            pspb.setData(pspdata, true);
        }
        for (Map.Entry<Block, Byte> entry : postPistonBaseBlocks.entrySet()) {
            Block ppb = entry.getKey();
            plugin.getGeneralKeeper().getDoorPistons().add(ppb);
            byte ppbdata = entry.getValue();
            ppb.setType(Material.PISTON_BASE);
            ppb.setData(ppbdata, true);
        }
        for (Map.Entry<Block, Byte> entry : postPistonExtensionBlocks.entrySet()) {
            Block ppeb = entry.getKey();
            byte ppedata = entry.getValue();
            ppeb.setType(Material.PISTON_EXTENSION);
            ppeb.setData(ppedata, true);
        }
        int s = 0;
        for (Map.Entry<Block, Byte> entry : postSignBlocks.entrySet()) {
            if (s == 0) {
                final Block psb = entry.getKey();
                byte psdata = entry.getValue();
                psb.setType(Material.WALL_SIGN);
                psb.setData(psdata, true);
                if (psb.getType().equals(Material.WALL_SIGN)) {
                    Sign cs = (Sign) psb.getState();
                    cs.setLine(0, "");
                    cs.setLine(1, plugin.getSigns().getStringList("control").get(0));
                    cs.setLine(2, plugin.getSigns().getStringList("control").get(1));
                    cs.setLine(3, "");
                    cs.update();
                    String controlloc = psb.getLocation().toString();
                    qf.insertSyncControl(id, 22, controlloc, 0);
                }
            }
            s++;
        }
        for (Block lamp : lampblocks) {
            Material l = (tud.getSchematic().hasLanterns()) ? Material.SEA_LANTERN : Material.REDSTONE_LAMP_ON;
            lamp.setType(l);
        }
        lampblocks.clear();
        if (postBedrock != null) {
            postBedrock.setType(Material.GLASS);
        }
        if (plugin.isWorldGuardOnServer() && plugin.getConfig().getBoolean("preferences.use_worldguard")) {
            if (slot == -1) {
                plugin.getWorldGuardUtils().addWGProtection(player, wg1, wg2);
            }
        }
        if (ender != null) {
            Entity ender_crystal = world.spawnEntity(ender, EntityType.ENDER_CRYSTAL);
            ((EnderCrystal) ender_crystal).setShowingBottom(false);
        }
        // finished processing - update tardis table!
        where.put("tardis_id", id);
        qf.doUpdate("tardis", set, where);
        // jettison blocks if downgrading to smaller size
        if (downgrade) {
            List<TARDISARSJettison> jettisons = getJettisons(tud.getPrevious(), tud.getSchematic(), chunk);
            for (TARDISARSJettison jet : jettisons) {
                // remove the room
                setAir(jet.getX(), jet.getY(), jet.getZ(), jet.getChunk().getWorld(), 16);
            }
            // also tidy up the space directly above the ARS centre slot
            int tidy = starty + h;
            int plus = 16 - h;
            setAir(chunk.getBlock(0, 64, 0).getX(), tidy, chunk.getBlock(0, 64, 0).getZ(), chunk.getWorld(), plus);
            // remove dropped items
            for (Entity e : chunk.getEntities()) {
                if (e instanceof Item) {
                    e.remove();
                }
            }
            // give them back some energy (jettison % * difference in cost)
            int big = plugin.getArtronConfig().getInt("upgrades." + tud.getPrevious().getPermission());
            int small = plugin.getArtronConfig().getInt("upgrades." + tud.getSchematic().getPermission());
            int refund = Math.round((plugin.getArtronConfig().getInt("jettison") / 100F) * (big - small));
            HashMap<String, Object> setr = new HashMap<String, Object>();
            setr.put("tardis_id", id);
            qf.alterEnergyLevel("tardis", refund, setr, null);
            if (player.isOnline()) {
                TARDISMessage.send(player, "ENERGY_RECOVERED", String.format("%d", refund));
            }
        } else if (tud.getSchematic().getPermission().equals("coral") && tud.getPrevious().isTall()) {
            // clean up space above coral console
            int tidy = starty + h;
            int plus = 32 - h;
            for (Chunk chk : chunks) {
                setAir(chk.getBlock(0, 64, 0).getX(), tidy, chk.getBlock(0, 64, 0).getZ(), chk.getWorld(), plus);
            }
        }
        // add / remove chunks from the chunks table
        HashMap<String, Object> wherec = new HashMap<String, Object>();
        wherec.put("tardis_id", id);
        qf.doDelete("chunks", wherec);
        List<Chunk> chunkList = plugin.getInteriorBuilder().getChunks(world, wg1.getChunk().getX(), wg1.getChunk().getZ(), w, c);
        // update chunks list in DB
        for (Chunk hunk : chunkList) {
            HashMap<String, Object> setc = new HashMap<String, Object>();
            setc.put("tardis_id", id);
            setc.put("world", world.getName());
            setc.put("x", hunk.getX());
            setc.put("z", hunk.getZ());
            qf.doInsert("chunks", setc);
        }
        // cancel the task
        plugin.getServer().getScheduler().cancelTask(taskID);
        taskID = 0;
        TARDISMessage.send(player, "UPGRADE_FINISHED");
    } else {
        JSONArray floor = (JSONArray) arr.get(level);
        JSONArray r = (JSONArray) floor.get(row);
        // place a row of blocks
        for (int col = 0; col < c; col++) {
            JSONObject bb = (JSONObject) r.get(col);
            int x = startx + row;
            int y = starty + level;
            int z = startz + col;
            // if we're setting the biome to sky, do it now
            if (plugin.getConfig().getBoolean("creation.sky_biome") && level == 0) {
                world.setBiome(x, z, Biome.VOID);
            }
            Material type = Material.valueOf((String) bb.get("type"));
            byte data = bb.getByte("data");
            if (type.equals(Material.BEDROCK)) {
                // remember bedrock location to block off the beacon light
                String bedrocloc = world.getName() + ":" + x + ":" + y + ":" + z;
                set.put("beacon", bedrocloc);
                postBedrock = world.getBlockAt(x, y, z);
            }
            if (type.equals(Material.NOTE_BLOCK)) {
                // remember the location of this Disk Storage
                String storage = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 14, storage, 0);
            }
            if (type.equals(Material.WOOL)) {
                switch(data) {
                    case 1:
                        type = wall_type;
                        data = wall_data;
                        break;
                    case 8:
                        type = floor_type;
                        data = floor_data;
                        break;
                    default:
                        break;
                }
            }
            if (type.equals(Material.MOB_SPAWNER)) {
                // scanner button
                /*
                     * mob spawner will be converted to the correct id by
                     * setBlock(), but remember it for the scanner.
                     */
                String scanloc = world.getName() + ":" + x + ":" + y + ":" + z;
                set.put("scanner", scanloc);
            }
            if (type.equals(Material.CHEST)) {
                // remember the location of the condenser chest
                String chest = world.getName() + ":" + x + ":" + y + ":" + z;
                set.put("condenser", chest);
            }
            if (type.equals(Material.IRON_DOOR_BLOCK)) {
                if (data < (byte) 8) {
                    // iron door bottom
                    HashMap<String, Object> setd = new HashMap<String, Object>();
                    String doorloc = world.getName() + ":" + x + ":" + y + ":" + z;
                    setd.put("door_location", doorloc);
                    HashMap<String, Object> whered = new HashMap<String, Object>();
                    whered.put("tardis_id", id);
                    whered.put("door_type", 1);
                    qf.doUpdate("doors", setd, whered);
                    // if create_worlds is true, set the world spawn
                    if (own_world) {
                        if (plugin.isMVOnServer()) {
                            plugin.getMVHelper().setSpawnLocation(world, x, y, z);
                        } else {
                            world.setSpawnLocation(x, y, (z + 1));
                        }
                    }
                } else {
                    // iron door top
                    data = (byte) 9;
                }
            }
            if (type.equals(Material.STONE_BUTTON)) {
                // random button
                // remember the location of this button
                String button = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 1, button, 0);
            }
            if (type.equals(Material.JUKEBOX)) {
                // remember the location of this Advanced Console
                String advanced = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 15, advanced, 0);
            }
            if (type.equals(Material.CAKE_BLOCK)) {
                /*
                     * This block will be converted to a lever by setBlock(),
                     * but remember it so we can use it as the handbrake!
                     */
                String handbrakeloc = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 0, handbrakeloc, 0);
            }
            if (type.equals(Material.MONSTER_EGGS)) {
                // silverfish stone
                if (data == 2) {
                    // get current ARS json
                    HashMap<String, Object> wherer = new HashMap<String, Object>();
                    wherer.put("tardis_id", id);
                    ResultSetARS rsa = new ResultSetARS(plugin, wherer);
                    if (rsa.resultSet()) {
                        int[][][] existing = TARDISARSMethods.getGridFromJSON(rsa.getJson());
                        int control = tud.getSchematic().getSeedId();
                        existing[1][4][4] = control;
                        if (downgrade) {
                            // reset slots to stone
                            existing[2][4][4] = 1;
                            existing[2][4][5] = 1;
                            existing[2][5][4] = 1;
                            existing[2][5][5] = 1;
                            if (w <= 16) {
                                existing[1][4][5] = 1;
                                existing[1][5][4] = 1;
                                existing[1][5][5] = 1;
                            }
                        }
                        if (w > 16) {
                            existing[1][4][5] = control;
                            existing[1][5][4] = control;
                            existing[1][5][5] = control;
                            if (h > 16) {
                                existing[2][4][4] = control;
                                existing[2][4][5] = control;
                                existing[2][5][4] = control;
                                existing[2][5][5] = control;
                            }
                        } else if (h > 16) {
                            existing[2][4][4] = control;
                        }
                        JSONArray json = new JSONArray(existing);
                        HashMap<String, Object> seta = new HashMap<String, Object>();
                        seta.put("json", json.toString());
                        HashMap<String, Object> wheres = new HashMap<String, Object>();
                        wheres.put("tardis_id", id);
                        qf.doUpdate("ars", seta, wheres);
                    }
                }
            }
            if (type.equals(Material.REDSTONE_LAMP_ON) || type.equals(Material.SEA_LANTERN)) {
                // remember lamp blocks
                Block lamp = world.getBlockAt(x, y, z);
                lampblocks.add(lamp);
                // remember lamp block locations for malfunction and light switch
                HashMap<String, Object> setlb = new HashMap<String, Object>();
                String lloc = world.getName() + ":" + x + ":" + y + ":" + z;
                setlb.put("tardis_id", id);
                setlb.put("location", lloc);
                qf.doInsert("lamps", setlb);
            }
            if (type.equals(Material.COMMAND) || ((tud.getSchematic().getPermission().equals("bigger") || tud.getSchematic().getPermission().equals("coral") || tud.getSchematic().getPermission().equals("deluxe") || tud.getSchematic().getPermission().equals("twelfth")) && type.equals(Material.BEACON))) {
                /*
                     * command block - remember it to spawn the creeper on.
                     * could also be a beacon block, as the creeper sits over
                     * the beacon in the deluxe and bigger consoles.
                     */
                String creeploc = world.getName() + ":" + (x + 0.5) + ":" + y + ":" + (z + 0.5);
                set.put("creeper", creeploc);
                if (tud.getSchematic().getPermission().equals("bigger") || tud.getSchematic().getPermission().equals("coral") || tud.getSchematic().getPermission().equals("deluxe") || tud.getSchematic().getPermission().equals("twelfth")) {
                    type = Material.BEACON;
                } else {
                    type = Material.SMOOTH_BRICK;
                    if (tud.getSchematic().getPermission().equals("ender")) {
                        data = (byte) 3;
                    }
                }
            }
            if (type.equals(Material.WOOD_BUTTON)) {
                /*
                     * wood button will be coverted to the correct id by
                     * setBlock(), but remember it for the Artron Energy
                     * Capacitor.
                     */
                String woodbuttonloc = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 6, woodbuttonloc, 0);
            }
            if (type.equals(Material.DAYLIGHT_DETECTOR)) {
                /*
                     * remember the telepathic circuit.
                     */
                String telepathicloc = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                qf.insertSyncControl(id, 23, telepathicloc, 0);
            }
            if (type.equals(Material.BEACON) && tud.getSchematic().getPermission().equals("ender")) {
                /*
                        * get the ender crytal location
                     */
                ender = world.getBlockAt(x, y, z).getLocation().add(0.5d, 4d, 0.5d);
            }
            // if it's an iron/gold/diamond/emerald/beacon/redstone block put it in the blocks table
            if (precious.contains(type)) {
                HashMap<String, Object> setpb = new HashMap<String, Object>();
                String loc = TARDISLocationGetters.makeLocationStr(world, x, y, z);
                setpb.put("tardis_id", id);
                setpb.put("location", loc);
                setpb.put("police_box", 0);
                qf.doInsert("blocks", setpb);
                plugin.getGeneralKeeper().getProtectBlockMap().put(loc, id);
            }
            // if it's the door, don't set it just remember its block then do it at the end
            if (type.equals(Material.IRON_DOOR_BLOCK)) {
                // doors
                postDoorBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.LEVER)) {
                postLeverBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.REDSTONE_TORCH_ON)) {
                postRedstoneTorchBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.TORCH)) {
                postTorchBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.PISTON_STICKY_BASE)) {
                postStickyPistonBaseBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.PISTON_BASE)) {
                postPistonBaseBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.PISTON_EXTENSION)) {
                postPistonExtensionBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.WALL_SIGN)) {
                postSignBlocks.put(world.getBlockAt(x, y, z), data);
            } else if (type.equals(Material.MONSTER_EGGS)) {
                // legacy monster egg stone for controls
                TARDISBlockSetters.setBlock(world, x, y, z, 0, (byte) 0);
            } else if (type.equals(Material.HUGE_MUSHROOM_2) && data == 15) {
                // save repeater location
                if (j < 6) {
                    String repeater = world.getName() + ":" + x + ":" + y + ":" + z;
                    switch(j) {
                        case 2:
                            postRepeaterBlocks.put(world.getBlockAt(x, y, z), (byte) 1);
                            qf.insertSyncControl(id, 3, repeater, 0);
                            break;
                        case 3:
                            postRepeaterBlocks.put(world.getBlockAt(x, y, z), (byte) 2);
                            qf.insertSyncControl(id, 2, repeater, 0);
                            break;
                        case 4:
                            postRepeaterBlocks.put(world.getBlockAt(x, y, z), (byte) 0);
                            qf.insertSyncControl(id, 5, repeater, 0);
                            break;
                        default:
                            postRepeaterBlocks.put(world.getBlockAt(x, y, z), (byte) 3);
                            qf.insertSyncControl(id, 4, repeater, 0);
                            break;
                    }
                    j++;
                }
            } else if (type.equals(Material.SPONGE)) {
                TARDISBlockSetters.setBlock(world, x, y, z, Material.AIR, (byte) 0);
            } else {
                TARDISBlockSetters.setBlock(world, x, y, z, type, data);
            }
        }
        // remove items
        for (Chunk chink : chunks) {
            // remove dropped items
            for (Entity e : chink.getEntities()) {
                if (e instanceof Item) {
                    e.remove();
                }
            }
        }
        if (row < w) {
            row++;
        }
        if (row == w && level < h) {
            row = 0;
            level++;
        }
    }
}
Example 73
Project: UltimateArena-master  File: PlayerListener.java View source code
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    ArenaPlayer ap = plugin.getArenaPlayer(event.getPlayer());
    if (ap != null) {
        Arena arena = ap.getArena();
        if (!arena.getConfig().isCanModifyWorld()) {
            event.setCancelled(true);
            // Dynamically clean up items
            Item item = event.getItem();
            if (arena.isInside(item.getLocation()))
                item.remove();
        }
    }
}
Example 74
Project: WorldGuard-master  File: RegionProtectionListener.java View source code
@EventHandler(ignoreCancelled = true)
public void onSpawnEntity(SpawnEntityEvent event) {
    // Don't care about events that have been pre-allowed
    if (event.getResult() == Result.ALLOW)
        return;
    // Region support disabled
    if (!isRegionSupportEnabled(event.getWorld()))
        return;
    // Whitelisted cause
    if (isWhitelisted(event.getCause(), event.getWorld(), false))
        return;
    Location target = event.getTarget();
    EntityType type = event.getEffectiveType();
    RegionQuery query = getPlugin().getRegionContainer().createQuery();
    RegionAssociable associable = createRegionAssociable(event.getCause());
    boolean canSpawn;
    String what;
    /* Vehicles */
    if (Entities.isVehicle(type)) {
        canSpawn = query.testBuild(target, associable, combine(event, DefaultFlag.PLACE_VEHICLE));
        what = "place vehicles";
    /* Item pickup */
    } else if (event.getEntity() instanceof Item) {
        canSpawn = query.testBuild(target, associable, combine(event, DefaultFlag.ITEM_DROP));
        what = "drop items";
    /* XP drops */
    } else if (type == EntityType.EXPERIENCE_ORB) {
        canSpawn = query.testBuild(target, associable, combine(event, DefaultFlag.EXP_DROPS));
        what = "drop XP";
    } else if (Entities.isAoECloud(type)) {
        canSpawn = query.testBuild(target, associable, combine(event, DefaultFlag.POTION_SPLASH));
        what = "use lingering potions";
    /* Everything else */
    } else {
        canSpawn = query.testBuild(target, associable, combine(event));
        if (event.getEntity() instanceof Item) {
            what = "drop items";
        } else {
            what = "place things";
        }
    }
    if (!canSpawn) {
        tellErrorMessage(event, event.getCause(), target, what);
        event.setCancelled(true);
    }
}
Example 75
Project: Jobs-master  File: JobsPaymentListener.java View source code
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Player player = event.getPlayer();
    // check if in creative
    if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
        return;
    if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
        return;
    // restricted area multiplier
    double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
    if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) {
        JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
        ItemStack items = ((Item) event.getCaught()).getItemStack();
        Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH), multiplier);
    }
}
Example 76
Project: ReActions-master  File: EventManager.java View source code
public static boolean raiseDropEvent(PlayerDropItemEvent event) {
    Item item = event.getItemDrop();
    double pickupDelay = BukkitCompatibilityFix.getItemPickupDelay(item);
    DropEvent e = new DropEvent(event.getPlayer(), event.getItemDrop(), pickupDelay);
    Bukkit.getServer().getPluginManager().callEvent(e);
    BukkitCompatibilityFix.setItemPickupDelay(item, e.getPickupDelay());
    return e.isCancelled();
}
Example 77
Project: UltraLogger-master  File: FileLogger.java View source code
@EventHandler(priority = EventPriority.MONITOR)
public void player_drop_item(PlayerDropItemEvent event) {
    if (!EventManager.isEnabled(event.getClass(), events))
        return;
    if (plugin.isEventForbidden(event.getPlayer(), event.getClass()))
        return;
    Item i = event.getItemDrop();
    file.log(printPlayer(event.getPlayer()) + " has dropped " + i.getItemStack().toString() + " in " + printLoc(i.getLocation()));
}
Example 78
Project: GriefPrevention-master  File: PlayerEventHandler.java View source code
//when a player picks up an item...
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();
    //FEATURE: lock dropped items to player who dropped them
    //who owns this stack?
    Item item = event.getItem();
    List<MetadataValue> data = item.getMetadata("GP_ITEMOWNER");
    if (data != null && data.size() > 0) {
        UUID ownerID = (UUID) data.get(0).value();
        //has that player unlocked his drops?
        OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID);
        String ownerName = GriefPrevention.lookupPlayerName(ownerID);
        if (owner.isOnline() && !player.equals(owner)) {
            PlayerData playerData = this.dataStore.getPlayerData(ownerID);
            //if locked, don't allow pickup
            if (!playerData.dropsAreUnlocked) {
                event.setCancelled(true);
                //if hasn't been instructed how to unlock, send explanatory messages
                if (!playerData.receivedDropUnlockAdvertisement) {
                    GriefPrevention.sendMessage(owner.getPlayer(), TextMode.Instr, Messages.DropUnlockAdvertisement);
                    GriefPrevention.sendMessage(player, TextMode.Err, Messages.PickupBlockedExplanation, ownerName);
                    playerData.receivedDropUnlockAdvertisement = true;
                }
                return;
            }
        }
    }
    //the rest of this code is specific to pvp worlds
    if (!GriefPrevention.instance.pvpRulesApply(player.getWorld()))
        return;
    //if we're preventing spawn camping and the player was previously empty handed...
    if (GriefPrevention.instance.config_pvp_protectFreshSpawns && (GriefPrevention.instance.getItemInHand(player, EquipmentSlot.HAND).getType() == Material.AIR)) {
        //if that player is currently immune to pvp
        PlayerData playerData = this.dataStore.getPlayerData(event.getPlayer().getUniqueId());
        if (playerData.pvpImmune) {
            //if it's been less than 10 seconds since the last time he spawned, don't pick up the item
            long now = Calendar.getInstance().getTimeInMillis();
            long elapsedSinceLastSpawn = now - playerData.lastSpawn;
            if (elapsedSinceLastSpawn < 10000) {
                event.setCancelled(true);
                return;
            }
            //otherwise take away his immunity. he may be armed now.  at least, he's worth killing for some loot
            playerData.pvpImmune = false;
            GriefPrevention.sendMessage(player, TextMode.Warn, Messages.PvPImmunityEnd);
        }
    }
}
Example 79
Project: MC-Murder-master  File: Murder.java View source code
/**
	 * Remove every player from the arena
	 */
@Override
public void onDisable() {
    for (Player p : playersList) {
        p.setGameMode(GameMode.ADVENTURE);
        p.getInventory().clear();
        p.teleport(mcmSpawn());
        p.removePotionEffect(PotionEffectType.BLINDNESS);
        p.removePotionEffect(PotionEffectType.SLOW);
        p.setExp(0);
        p.setLevel(0);
        List<Entity> entList = p.getWorld().getEntities();
        for (Entity current : entList) {
            if (current instanceof Item) {
                current.remove();
            }
        }
    }
    // Show everyone to everyone
    for (Player playersInMap : playersList) {
        for (Player playersInMap2 : playersList) {
            playersInMap.showPlayer(playersInMap2);
            playersInMap2.showPlayer(playersInMap);
        }
    }
}
Example 80
Project: ExtraHardMode-master  File: EntityEventHandler.java View source code
//when an item spawns
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    //FEATURE: fountain effect from dragon fireball explosions sometimes causes fire to drop as an item.  this is the fix for that.		
    Item item = event.getEntity();
    World world = item.getWorld();
    if (!ExtraHardMode.instance.config_enabled_worlds.contains(world) || world.getEnvironment() != Environment.THE_END)
        return;
    if (item.getItemStack().getType() == Material.FIRE) {
        event.setCancelled(true);
    }
}
Example 81
Project: UltimateSurvivalGames-master  File: Reset.java View source code
@Override
public Void call() {
    String[] split = chunk.split(",");
    Chunk c = world.getChunkAt(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
    boolean l = c.isLoaded();
    if (!l)
        c.load();
    for (Entity e : c.getEntities()) {
        if (e instanceof Item || e instanceof LivingEntity || e instanceof Arrow) {
            e.remove();
        }
    }
    if (!l)
        c.unload();
    return null;
}
Example 82
Project: askyblock-master  File: IslandCmd.java View source code
/*
     * (non-Javadoc)
     * @see
     * org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender
     * , org.bukkit.command.Command, java.lang.String, java.lang.String[])
     */
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) {
    if (!(sender instanceof Player)) {
        Util.sendMessage(sender, plugin.myLocale().errorUseInGame);
        return false;
    }
    final Player player = (Player) sender;
    // Basic permissions check to even use /island
    if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.create")) {
        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islanderrorYouDoNotHavePermission);
        return true;
    }
    /*
         * Grab data for this player - may be null or empty
         * playerUUID is the unique ID of the player who issued the command
         */
    final UUID playerUUID = player.getUniqueId();
    if (playerUUID == null) {
        plugin.getLogger().severe("Player " + sender.getName() + " has a null UUID - this should never happen!");
        sender.sendMessage(ChatColor.RED + plugin.myLocale().errorCommandNotReady + " (No UUID)");
        return true;
    }
    final UUID teamLeader = plugin.getPlayers().getTeamLeader(playerUUID);
    List<UUID> teamMembers = new ArrayList<UUID>();
    if (teamLeader != null) {
        teamMembers = plugin.getPlayers().getMembers(teamLeader);
    }
    // Island name (can have spaces)
    if (split.length > 1 && split[0].equalsIgnoreCase("name")) {
        // Naming of island
        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
            String name = split[1];
            for (int i = 2; i < split.length; i++) {
                name = name + " " + split[i];
            }
            if (name.length() < Settings.minNameLength) {
                Util.sendMessage(player, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooShort).replace("[length]", String.valueOf(Settings.minNameLength)));
                return true;
            }
            if (name.length() > Settings.maxNameLength) {
                Util.sendMessage(player, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).errorTooLong).replace("[length]", String.valueOf(Settings.maxNameLength)));
                return true;
            }
            plugin.getGrid().setIslandName(playerUUID, ChatColor.translateAlternateColorCodes('&', name));
            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).generalSuccess);
            return true;
        } else {
            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
            return true;
        }
    }
    // The target player's UUID
    UUID targetPlayer = null;
    // Check if a player has an island or is in a team
    switch(split.length) {
        // /island command by itself
        case 0:
            // New island
            if (plugin.getPlayers().getIslandLocation(playerUUID) == null && !plugin.getPlayers().inTeam(playerUUID)) {
                // Check if the max number of islands is made already
                if (Settings.maxIslands > 0 && plugin.getGrid().getIslandCount() > Settings.maxIslands) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMaxIslands);
                    return true;
                }
                // Check if player has resets left
                if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    return true;
                }
                // Create new island for player
                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandnew);
                chooseIsland(player);
                return true;
            } else {
                // Check if this should open the Control Panel or not
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel") && plugin.getPlayers().getControlPanel(playerUUID)) {
                    player.performCommand(Settings.ISLANDCOMMAND + " cp");
                } else {
                    // Check permission
                    if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                        return true;
                    }
                    if (!player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || Settings.allowTeleportWhenFalling || !PlayerEvents.isFalling(playerUUID) || (player.isOp() && !Settings.damageOps)) {
                        // Teleport home
                        plugin.getGrid().homeTeleport(player);
                        if (Settings.islandRemoveMobs) {
                            plugin.getGrid().removeMobs(player.getLocation());
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    }
                }
                return true;
            }
        case 1:
            if (split[0].equalsIgnoreCase("value")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.value")) {
                    // Check they are on their island
                    if (!plugin.getGrid().playerIsOnIsland(player)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNotOnIsland);
                        return true;
                    }
                    ItemStack item = player.getItemInHand();
                    double multiplier = 1;
                    if (item != null && item.getType().isBlock()) {
                        // Get permission multiplier                
                        for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                            if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.multiplier.")) {
                                String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.multiplier.");
                                // Get the max value should there be more than one
                                if (spl.length > 1) {
                                    if (!NumberUtils.isDigits(spl[1])) {
                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                    } else {
                                        multiplier = Math.max(multiplier, Integer.valueOf(spl[1]));
                                    }
                                }
                            }
                            // Do some sanity checking
                            if (multiplier < 1) {
                                multiplier = 1;
                            }
                        }
                        // Player height
                        if (player.getLocation().getBlockY() < Settings.seaHeight) {
                            multiplier *= Settings.underWaterMultiplier;
                        }
                        // Get the value. Try the specific item
                        int value = 0;
                        if (Settings.blockValues.containsKey(item.getData())) {
                            value = (int) ((double) Settings.blockValues.get(item.getData()) * multiplier);
                        } else if (Settings.blockValues.containsKey(new MaterialData(item.getType()))) {
                            value = (int) ((double) Settings.blockValues.get(new MaterialData(item.getType())) * multiplier);
                        }
                        if (value > 0) {
                            // [name] placed here may be worth [value]
                            Util.sendMessage(player, ChatColor.GREEN + (plugin.myLocale(player.getUniqueId()).islandblockValue.replace("[name]", Util.prettifyText(item.getType().name())).replace("[value]", String.valueOf(value))));
                        } else {
                            // [name] is worthless
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandblockWorthless.replace("[name]", Util.prettifyText(item.getType().name())));
                        }
                    } else {
                        // That is not a block
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNotABlock);
                    }
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("name")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " name <name>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpName);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("resetname")) {
                // Convert name to a UUID
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
                    // Has an island
                    plugin.getGrid().setIslandName(playerUUID, null);
                    Util.sendMessage(sender, plugin.myLocale().generalSuccess);
                }
                return true;
            }
            if (split[0].equalsIgnoreCase("coop")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("uncoop")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("expel")) {
                // Explain command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("teamchat") || split[0].equalsIgnoreCase("tc")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat")) {
                    // Check if this command is on or not
                    if (!Settings.teamChat) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale().errorUnknownCommand);
                        return false;
                    }
                    // Check if in team
                    if (plugin.getPlayers().inTeam(playerUUID)) {
                        // Check if team members are online
                        boolean online = false;
                        for (UUID teamMember : plugin.getPlayers().getMembers(playerUUID)) {
                            if (!teamMember.equals(playerUUID) && plugin.getServer().getPlayer(teamMember) != null) {
                                online = true;
                            }
                        }
                        if (!online) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeamAround);
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff);
                            plugin.getChatListener().unSetPlayer(playerUUID);
                            return true;
                        }
                        if (plugin.getChatListener().isTeamChat(playerUUID)) {
                            // Toggle
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOff);
                            plugin.getChatListener().unSetPlayer(playerUUID);
                        } else {
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).teamChatStatusOn);
                            plugin.getChatListener().setPlayer(playerUUID);
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).teamChatNoTeam);
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            }
            if (split[0].equalsIgnoreCase("banlist")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    // Show banned players
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).adminInfoBannedPlayers + ":");
                    List<UUID> bannedList = plugin.getPlayers().getBanList(playerUUID);
                    if (bannedList.isEmpty()) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).banNone);
                    } else {
                        for (UUID bannedPlayers : bannedList) {
                            Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + plugin.getPlayers().getName(bannedPlayers));
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("ban")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    // Just show ban help
                    Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpBan);
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("unban") && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    // Just show unban help
                    Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(playerUUID).islandhelpUnban);
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("make")) {
                //plugin.getLogger().info("DEBUG: /is make called");
                if (!pendingNewIslandSelection.contains(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale().errorUnknownCommand);
                    return false;
                }
                pendingNewIslandSelection.remove(playerUUID);
                Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId());
                newIsland(player);
                if (resettingIsland.contains(playerUUID)) {
                    resettingIsland.remove(playerUUID);
                    resetPlayer(player, oldIsland);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("lang")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) {
                    Util.sendMessage(player, "/" + label + " lang <#>");
                    displayLocales(player);
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("settings")) {
                // Show what the plugin settings are
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) {
                    try {
                        player.openInventory(plugin.getSettingsPanel().islandGuardPanel(player));
                    } catch (Exception e) {
                        if (DEBUG)
                            e.printStackTrace();
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("lock")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // plugin.getLogger().info("DEBUG: perms ok");
                // Find out which island they want to lock
                Island island = plugin.getGrid().getIsland(playerUUID);
                if (island == null) {
                    // plugin.getLogger().info("DEBUG: player has no island in grid");
                    // Player has no island in the grid
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                    return true;
                } else {
                    if (!island.isLocked()) {
                        // Remove any visitors
                        for (Player target : plugin.getServer().getOnlinePlayers()) {
                            // See if target is on this player's island, not a mod, no bypass, and not a coop player
                            if (!player.equals(target) && !target.isOp() && !VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect") && plugin.getGrid().isOnIsland(player, target) && !CoopPlay.getInstance().getCoopPlayers(island.getCenter()).contains(target.getUniqueId())) {
                                // Send them home
                                if (plugin.getPlayers().inTeam(target.getUniqueId()) || plugin.getPlayers().hasIsland(target.getUniqueId())) {
                                    plugin.getGrid().homeTeleport(target);
                                } else {
                                    // Just move target to spawn
                                    if (!target.performCommand(Settings.SPAWNCOMMAND)) {
                                        target.teleport(player.getWorld().getSpawnLocation());
                                    }
                                }
                                target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled);
                                plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island when locking.");
                                // Yes they are
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess.replace("[name]", target.getName()));
                            }
                        }
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).lockLocking);
                        plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getName()));
                        plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerLocked.replace("[name]", player.getName()));
                        island.setLocked(true);
                    } else {
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).lockUnlocking);
                        plugin.getMessages().tellOfflineTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getName()));
                        plugin.getMessages().tellTeam(playerUUID, plugin.myLocale(playerUUID).lockPlayerUnlocked.replace("[name]", player.getName()));
                        island.setLocked(false);
                    }
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("go")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) {
                    // Player has no island
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoIsland);
                    return true;
                }
                // Teleport home
                plugin.getGrid().homeTeleport(player);
                if (Settings.islandRemoveMobs) {
                    plugin.getGrid().removeMobs(player.getLocation());
                }
                return true;
            } else if (split[0].equalsIgnoreCase("about")) {
                Util.sendMessage(player, ChatColor.GOLD + "This plugin is free software: you can redistribute");
                Util.sendMessage(player, ChatColor.GOLD + "it and/or modify it under the terms of the GNU");
                Util.sendMessage(player, ChatColor.GOLD + "General Public License as published by the Free");
                Util.sendMessage(player, ChatColor.GOLD + "Software Foundation, either version 3 of the License,");
                Util.sendMessage(player, ChatColor.GOLD + "or (at your option) any later version.");
                Util.sendMessage(player, ChatColor.GOLD + "This plugin is distributed in the hope that it");
                Util.sendMessage(player, ChatColor.GOLD + "will be useful, but WITHOUT ANY WARRANTY; without");
                Util.sendMessage(player, ChatColor.GOLD + "even the implied warranty of MERCHANTABILITY or");
                Util.sendMessage(player, ChatColor.GOLD + "FITNESS FOR A PARTICULAR PURPOSE.  See the");
                Util.sendMessage(player, ChatColor.GOLD + "GNU General Public License for more details.");
                Util.sendMessage(player, ChatColor.GOLD + "You should have received a copy of the GNU");
                Util.sendMessage(player, ChatColor.GOLD + "General Public License along with this plugin.");
                Util.sendMessage(player, ChatColor.GOLD + "If not, see <http://www.gnu.org/licenses/>.");
                Util.sendMessage(player, ChatColor.GOLD + "Souce code is available on GitHub.");
                Util.sendMessage(player, ChatColor.GOLD + "(c) 2014 - 2015 by tastybento");
                return true;
            // Spawn enderman
            // Enderman enderman = (Enderman)
            // player.getWorld().spawnEntity(player.getLocation().add(new
            // Vector(5,0,5)), EntityType.ENDERMAN);
            // enderman.setCustomName("TastyBento's Ghost");
            // enderman.setCarriedMaterial(new
            // MaterialData(Material.GRASS));
            }
            if (split[0].equalsIgnoreCase("controlpanel") || split[0].equalsIgnoreCase("cp")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) {
                    player.openInventory(ControlPanel.controlPanel.get(ControlPanel.getDefaultPanelName()));
                    return true;
                }
            }
            if (split[0].equalsIgnoreCase("minishop") || split[0].equalsIgnoreCase("ms")) {
                if (Settings.useEconomy && Settings.useMinishop) {
                    // Check island
                    if (plugin.getGrid().getIsland(player.getUniqueId()) == null) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || player.getWorld().equals(ASkyBlock.getNetherWorld())) {
                        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) {
                            if (ControlPanel.miniShop != null) {
                                player.openInventory(ControlPanel.miniShop);
                            } else {
                                Util.sendMessage(player, plugin.myLocale(playerUUID).errorCommandNotReady);
                                plugin.getLogger().severe("Player tried to open the minishop, but it does not exist. Look for errors in the console about the minishop loading.");
                            }
                            return true;
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld);
                        return true;
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMinishopDisabled);
                }
            }
            // /island <command>
            if (split[0].equalsIgnoreCase("warp")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    Util.sendMessage(player, ChatColor.YELLOW + "/island warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("warps")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    // Step through warp table
                    Collection<UUID> warpList = plugin.getWarpSignsListener().listWarps();
                    if (warpList.isEmpty()) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) {
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                        }
                        return true;
                    } else {
                        if (Settings.useWarpPanel) {
                            // Try the warp panel
                            player.openInventory(plugin.getWarpPanel().getWarpPanel(0));
                        } else {
                            Boolean hasWarp = false;
                            String wlist = "";
                            for (UUID w : warpList) {
                                if (w == null)
                                    continue;
                                if (wlist.isEmpty()) {
                                    wlist = plugin.getPlayers().getName(w);
                                } else {
                                    wlist += ", " + plugin.getPlayers().getName(w);
                                }
                                if (w.equals(playerUUID)) {
                                    hasWarp = true;
                                }
                            }
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpswarpsAvailable + ": " + ChatColor.WHITE + wlist);
                            if (!hasWarp && (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) {
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                            }
                        }
                        return true;
                    }
                }
            } else if (split[0].equalsIgnoreCase("restart") || split[0].equalsIgnoreCase("reset")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.reset")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Check this player has an island
                if (!plugin.getPlayers().hasIsland(playerUUID)) {
                    // No so just start an island
                    player.performCommand(Settings.ISLANDCOMMAND);
                    return true;
                }
                if (plugin.getPlayers().inTeam(playerUUID)) {
                    if (!plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandresetOnlyOwner);
                    } else {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetMustRemovePlayers);
                    }
                    return true;
                }
                // Check if the player has used up all their resets
                if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    return true;
                }
                if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).resetYouHave.replace("[number]", String.valueOf(plugin.getPlayers().getResetsLeft(playerUUID))));
                }
                if (!onRestartWaitTime(player) || Settings.resetWait == 0 || player.isOp()) {
                    // Kick off the confirmation
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandresetConfirm.replace("[seconds]", String.valueOf(Settings.resetConfirmWait)));
                    if (!confirm.containsKey(playerUUID) || !confirm.get(playerUUID)) {
                        confirm.put(playerUUID, true);
                        plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

                            @Override
                            public void run() {
                                confirm.put(playerUUID, false);
                            }
                        }, (Settings.resetConfirmWait * 20));
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetWait.replace("[time]", String.valueOf(getResetWaitTime(player))));
                }
                return true;
            } else if (split[0].equalsIgnoreCase("confirm")) {
                // This is where the actual reset is done
                if (confirm.containsKey(playerUUID) && confirm.get(playerUUID)) {
                    confirm.remove(playerUUID);
                    // Actually RESET the island
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandresetPleaseWait);
                    if (plugin.getPlayers().getResetsLeft(playerUUID) == 0) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).islandResetNoMore);
                    }
                    if (plugin.getPlayers().getResetsLeft(playerUUID) > 0) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).resetYouHave.replace("[number]", String.valueOf(plugin.getPlayers().getResetsLeft(playerUUID))));
                    }
                    // Show a schematic panel if the player has a choice
                    // Get the schematics that this player is eligible to use
                    List<Schematic> schems = getSchematics(player, false);
                    //plugin.getLogger().info("DEBUG: size of schematics for this player = " + schems.size());
                    Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId());
                    if (schems.isEmpty()) {
                        // No schematics - use default island
                        newIsland(player);
                        resetPlayer(player, oldIsland);
                    } else if (schems.size() == 1) {
                        // Hobson's choice
                        newIsland(player, schems.get(0));
                        resetPlayer(player, oldIsland);
                    } else {
                        // A panel can only be shown if there is >1 viable schematic
                        if (Settings.useSchematicPanel) {
                            pendingNewIslandSelection.add(playerUUID);
                            resettingIsland.add(playerUUID);
                            player.openInventory(plugin.getSchematicsPanel().getPanel(player));
                        } else {
                            // No panel
                            // Check schematics for specific permission
                            schems = getSchematics(player, true);
                            if (schems.isEmpty()) {
                                newIsland(player);
                            } else if (Settings.chooseIslandRandomly) {
                                // Choose an island randomly from the list
                                newIsland(player, schems.get(random.nextInt(schems.size())));
                            } else {
                                // Do the first one in the list
                                newIsland(player, schems.get(0));
                            }
                            resetPlayer(player, oldIsland);
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/island restart: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("sethome")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) {
                    // Check island
                    if (plugin.getGrid().getIsland(player.getUniqueId()) == null) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    plugin.getGrid().homeSet(player);
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("help")) {
                Util.sendMessage(player, ChatColor.GREEN + plugin.getName() + " " + plugin.getDescription().getVersion() + " help:");
                if (Settings.useControlPanel) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel);
                } else {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + ": " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpIsland);
                }
                // Dynamic home sizes with permissions
                int maxHomes = Settings.maxHomes;
                for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                    if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) {
                        if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.*")) {
                            maxHomes = Settings.maxHomes;
                            break;
                        } else {
                            // Get the max value should there be more than one
                            String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes.");
                            if (spl.length > 1) {
                                // Check that it is a number
                                if (!NumberUtils.isDigits(spl[1])) {
                                    plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                } else {
                                    maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1]));
                                }
                            }
                        }
                    }
                    // Do some sanity checking
                    if (maxHomes < 1) {
                        maxHomes = 1;
                    }
                }
                if (maxHomes > 1 && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport);
                } else if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.go")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " go: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeleport);
                }
                if (plugin.getGrid() != null && plugin.getGrid().getSpawn() != null && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.spawn")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " spawn: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSpawn);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " controlpanel or cp [on/off]: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpControlPanel);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.reset")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " reset: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpRestart);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) {
                    if (maxHomes > 1) {
                        Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome <1 - " + maxHomes + ">: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome);
                    } else {
                        Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " sethome: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpSetHome);
                    }
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevel);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " level <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLevelPlayer);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " name <name>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpName);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " top: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTop);
                }
                if (Settings.useEconomy && VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.minishop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " minishop or ms: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMiniShop);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.value")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " value: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpValue);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warps: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarps);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " warp <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpWarp);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " team: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpTeam);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " invite <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpInvite);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " leave: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpLeave);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " kick <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpKick);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " <accept/reject>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpAcceptReject);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " makeleader <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpMakeLeader);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.chat") && plugin.getPlayers().inTeam(playerUUID)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " teamchat: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).teamChatHelp);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " biomes: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBiome);
                }
                // if (!Settings.allowPvP) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " expel <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpExpel);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " ban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBan);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " banlist <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpBanList);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " unban <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnban);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " uncoop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpUnCoop);
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " listcoops: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpListCoops);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lock")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lock: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpLock);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.name") && plugin.getPlayers().hasIsland(playerUUID)) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " resetname: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpResetName);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.settings")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " settings: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSettings);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.challenges")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + plugin.myLocale(player.getUniqueId()).islandHelpChallenges);
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "/" + label + " lang <#>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandHelpSelectLanguage);
                }
                /*
                if (player.getInventory().getItemInMainHand() != null) {
                    net.minecraft.server.v1_11_R1.ItemStack stack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
                    NBTTagCompound tagCompound = stack.getTag();
                    Bukkit.getLogger().info("DEBUG: tag = " + tagCompound);
                }
                 */
                return true;
            } else if (split[0].equalsIgnoreCase("listcoops")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    if (!plugin.getPlayers().hasIsland(playerUUID)) {
                        // Player has no island
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    Island island = plugin.getGrid().getIsland(playerUUID);
                    boolean none = true;
                    for (UUID uuid : CoopPlay.getInstance().getCoopPlayers(island.getCenter())) {
                        Util.sendMessage(player, ChatColor.GREEN + plugin.getPlayers().getName(uuid));
                        none = false;
                    }
                    if (none) {
                        Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + "/" + label + " coop <player>: " + ChatColor.WHITE + plugin.myLocale(player.getUniqueId()).islandhelpCoop);
                    } else {
                        Util.sendMessage(player, plugin.myLocale(playerUUID).helpColor + plugin.myLocale(playerUUID).coopUseExpel);
                    }
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("biomes")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.biomes")) {
                    // Only the team leader can do this
                    if (teamLeader != null && !teamLeader.equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland);
                        return true;
                    }
                    if (!plugin.getPlayers().hasIsland(playerUUID)) {
                        // Player has no island
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    if (!plugin.getGrid().playerIsOnIsland(player)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland);
                        return true;
                    }
                    // Not allowed in the nether
                    if (plugin.getPlayers().getIslandLocation(playerUUID).getWorld().getEnvironment().equals(Environment.NETHER)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorWrongWorld);
                        return true;
                    }
                    // Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).helpColor + "[Biomes]");
                    Inventory inv = plugin.getBiomes().getBiomePanel(player);
                    if (inv != null) {
                        player.openInventory(inv);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("spawn") && plugin.getGrid().getSpawn() != null) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.spawn")) {
                    // go to spawn
                    Location l = ASkyBlock.getIslandWorld().getSpawnLocation();
                    l.add(new Vector(0.5, 0, 0.5));
                    Island spawn = plugin.getGrid().getSpawn();
                    if (spawn != null && spawn.getSpawnPoint() != null) {
                        l = spawn.getSpawnPoint();
                    }
                    player.teleport(l);
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("top")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.topten")) {
                    TopTen.topTenShow(player);
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("level")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) {
                    if (!plugin.getPlayers().inTeam(playerUUID) && !plugin.getPlayers().hasIsland(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    } else {
                        if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "intopten")) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).topTenerrorExcluded.replace("[perm]", Settings.PERMPREFIX + "intopten"));
                        }
                        calculateIslandLevel(player, playerUUID);
                        return true;
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("invite")) {
                // player how many more people they can invite
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) {
                    Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).invitehelp);
                    // If the player who is doing the inviting has a team
                    if (plugin.getPlayers().inTeam(playerUUID)) {
                        // Check to see if the player is the leader
                        if (teamLeader.equals(playerUUID)) {
                            // Check to see if the team is already full
                            int maxSize = Settings.maxTeamSize;
                            // Dynamic team sizes with permissions
                            for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                                if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) {
                                    if (perms.getPermission().contains(Settings.PERMPREFIX + "team.maxsize.*")) {
                                        maxSize = Settings.maxTeamSize;
                                        break;
                                    } else {
                                        // Get the max value should there be more than one
                                        String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "team.maxsize.");
                                        if (spl.length > 1) {
                                            if (!NumberUtils.isDigits(spl[1])) {
                                                plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                            } else {
                                                maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                            }
                                        }
                                    }
                                }
                                // Do some sanity checking
                                if (maxSize < 1) {
                                    maxSize = 1;
                                }
                            }
                            // This avoids these permissions breaking on upgrades
                            if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip")) {
                                if (Settings.maxTeamSizeVIP > maxSize) {
                                    maxSize = Settings.maxTeamSizeVIP;
                                }
                            }
                            if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.vip2")) {
                                if (Settings.maxTeamSizeVIP2 > maxSize) {
                                    maxSize = Settings.maxTeamSizeVIP2;
                                }
                            }
                            if (teamMembers.size() < maxSize) {
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite.replace("[number]", String.valueOf(maxSize - teamMembers.size())));
                            } else {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                            }
                            return true;
                        }
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        return true;
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("accept")) {
                // Accept an invite command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) {
                    // one
                    if (!plugin.getPlayers().inTeam(playerUUID) && inviteList.containsKey(playerUUID)) {
                        // If the invitee has an island of their own
                        if (plugin.getPlayers().hasIsland(playerUUID)) {
                            plugin.getLogger().info(player.getName() + "'s island will be deleted because they joined a party.");
                            plugin.deletePlayerIsland(playerUUID, true);
                            plugin.getLogger().info("Island deleted.");
                        }
                        // Add the player to the team
                        addPlayertoTeam(playerUUID, inviteList.get(playerUUID));
                        // team (leader is not in a team yet)
                        if (!plugin.getPlayers().inTeam(inviteList.get(playerUUID))) {
                            // Add the leader to their own team
                            addPlayertoTeam(inviteList.get(playerUUID), inviteList.get(playerUUID));
                        }
                        setResetWaitTime(player);
                        if (Settings.teamJoinDeathReset) {
                            plugin.getPlayers().setDeaths(player.getUniqueId(), 0);
                        }
                        plugin.getGrid().homeTeleport(player);
                        plugin.resetPlayer(player);
                        if (!player.hasPermission(Settings.PERMPREFIX + "command.newteamexempt")) {
                            //plugin.getLogger().info("DEBUG: Executing new island commands");
                            runCommands(Settings.teamStartCommands, player);
                        }
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouHaveJoinedAnIsland);
                        if (plugin.getServer().getPlayer(inviteList.get(playerUUID)) != null) {
                            Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)), ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).invitehasJoinedYourIsland.replace("[name]", player.getName()));
                        }
                        // Remove the invite
                        inviteList.remove(player.getUniqueId());
                        plugin.getGrid().saveGrid();
                        return true;
                    }
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorCommandNotReady);
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("reject")) {
                // Reject /island reject
                if (inviteList.containsKey(player.getUniqueId())) {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).rejectyouHaveRejectedInvitation);
                    // about the rejection
                    if (Bukkit.getPlayer(inviteList.get(player.getUniqueId())) != null) {
                        Util.sendMessage(Bukkit.getPlayer(inviteList.get(player.getUniqueId())), ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectnameHasRejectedInvite.replace("[name]", player.getName()));
                    }
                    // Remove this player from the global invite list
                    inviteList.remove(player.getUniqueId());
                } else {
                    // Someone typed /island reject and had not been invited
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).rejectyouHaveNotBeenInvited);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("leave")) {
                // Leave team command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.join")) {
                    if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || (Settings.createNether && Settings.newNether && ASkyBlock.getNetherWorld() != null && player.getWorld().equals(ASkyBlock.getNetherWorld()))) {
                        if (plugin.getPlayers().inTeam(playerUUID)) {
                            if (plugin.getPlayers().getTeamLeader(playerUUID) != null && plugin.getPlayers().getTeamLeader(playerUUID).equals(playerUUID)) {
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveerrorYouAreTheLeader);
                                return true;
                            }
                            // Check for confirmation
                            if (!leavingPlayers.contains(playerUUID)) {
                                leavingPlayers.add(playerUUID);
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveWarning);
                                new BukkitRunnable() {

                                    @Override
                                    public void run() {
                                        // If the player is still on the list, remove them and cancel the leave
                                        if (leavingPlayers.contains(playerUUID)) {
                                            leavingPlayers.remove(playerUUID);
                                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveCanceled);
                                        }
                                    }
                                }.runTaskLater(plugin, Settings.resetConfirmWait * 20L);
                                return true;
                            }
                            // Remove from confirmation list
                            leavingPlayers.remove(playerUUID);
                            // Remove from team
                            if (!removePlayerFromTeam(playerUUID, teamLeader)) {
                                // If this is canceled, fail silently
                                return true;
                            }
                            // Clear any coop inventories
                            // CoopPlay.getInstance().returnAllInventories(player);
                            // Remove any of the target's coop invitees and grab
                            // their stuff
                            CoopPlay.getInstance().clearMyInvitedCoops(player);
                            CoopPlay.getInstance().clearMyCoops(player);
                            // Log the location that this player left so they
                            // cannot join again before the cool down ends
                            plugin.getPlayers().startInviteCoolDownTimer(playerUUID, plugin.getPlayers().getTeamIslandLocation(teamLeader));
                            // Remove any warps
                            plugin.getWarpSignsListener().removeWarp(playerUUID);
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).leaveyouHaveLeftTheIsland);
                            // Tell the leader if they are online
                            if (plugin.getServer().getPlayer(teamLeader) != null) {
                                plugin.getServer().getPlayer(teamLeader).sendMessage(ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland.replace("[name]", player.getName()));
                            } else {
                                // Leave them a message
                                plugin.getMessages().setMessage(teamLeader, ChatColor.RED + plugin.myLocale(teamLeader).leavenameHasLeftYourIsland.replace("[name]", player.getName()));
                            }
                            // teamMembers.remove(playerUUID);
                            if (teamMembers.size() < 2) {
                                // plugin.getLogger().info("DEBUG: Party is less than 2 - removing leader from team");
                                if (!removePlayerFromTeam(teamLeader, teamLeader)) {
                                    // If this is canceled, return silently.
                                    return true;
                                }
                            }
                            // Clear all player variables and save
                            plugin.resetPlayer(player);
                            if (!player.performCommand(Settings.SPAWNCOMMAND)) {
                                player.teleport(player.getWorld().getSpawnLocation());
                            }
                            return true;
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouCannotLeaveIsland);
                            return true;
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorYouMustBeInWorld);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("team")) {
                if (plugin.getPlayers().inTeam(playerUUID)) {
                    if (teamLeader.equals(playerUUID)) {
                        int maxSize = Settings.maxTeamSize;
                        for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                            if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) {
                                if (perms.getPermission().contains(Settings.PERMPREFIX + "team.maxsize.*")) {
                                    maxSize = Settings.maxTeamSize;
                                    break;
                                } else {
                                    // Get the max value should there be more than one
                                    String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "team.maxsize.");
                                    if (spl.length > 1) {
                                        if (!NumberUtils.isDigits(spl[1])) {
                                            plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                        } else {
                                            maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                        }
                                    }
                                }
                            }
                            // Do some sanity checking
                            if (maxSize < 1) {
                                maxSize = 1;
                            }
                        }
                        if (teamMembers.size() < maxSize) {
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteyouCanInvite.replace("[number]", String.valueOf(maxSize - teamMembers.size())));
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                        }
                    }
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).teamlistingMembers + ":");
                    // Display members in the list
                    for (UUID m : plugin.getPlayers().getMembers(teamLeader)) {
                        Util.sendMessage(player, ChatColor.WHITE + plugin.getPlayers().getName(m));
                    }
                } else if (inviteList.containsKey(playerUUID)) {
                    Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitenameHasInvitedYou.replace("[name]", plugin.getPlayers().getName(inviteList.get(playerUUID))));
                    Util.sendMessage(player, ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).invitetoAcceptOrReject);
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam);
                }
                return true;
            } else {
                // Incorrect syntax
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                return true;
            }
        /*
             * Commands that have two parameters
             */
        case 2:
            if (split[0].equalsIgnoreCase("controlpanel") || split[0].equalsIgnoreCase("cp")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.controlpanel")) {
                    if (split[1].equalsIgnoreCase("on")) {
                        plugin.getPlayers().setControlPanel(playerUUID, true);
                    } else if (split[1].equalsIgnoreCase("off")) {
                        plugin.getPlayers().setControlPanel(playerUUID, false);
                    }
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess);
                    return true;
                } else {
                    Util.sendMessage(player, plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("warps")) {
                if (Settings.useWarpPanel) {
                    if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                        // Step through warp table
                        Set<UUID> warpList = plugin.getWarpSignsListener().listWarps();
                        if (warpList.isEmpty()) {
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                            if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp") && plugin.getGrid().playerIsOnIsland(player)) {
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                            }
                            return true;
                        } else {
                            // Try the warp panel
                            int panelNum = 0;
                            try {
                                panelNum = Integer.valueOf(split[1]) - 1;
                            } catch (Exception e) {
                                panelNum = 0;
                            }
                            player.openInventory(plugin.getWarpPanel().getWarpPanel(panelNum));
                            return true;
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("make")) {
                //plugin.getLogger().info("DEBUG: /is make '" + split[1] + "' called");
                if (!pendingNewIslandSelection.contains(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                    return true;
                }
                pendingNewIslandSelection.remove(playerUUID);
                // Create a new island using schematic
                if (!schematics.containsKey(split[1])) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                    return true;
                } else {
                    Schematic schematic = schematics.get(split[1]);
                    // Check perm again
                    if (schematic.getPerm().isEmpty() || VaultHelper.checkPerm(player, schematic.getPerm())) {
                        Island oldIsland = plugin.getGrid().getIsland(player.getUniqueId());
                        newIsland(player, schematic);
                        if (resettingIsland.contains(playerUUID)) {
                            resettingIsland.remove(playerUUID);
                            resetPlayer(player, oldIsland);
                        }
                        return true;
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                        return true;
                    }
                }
            } else if (split[0].equalsIgnoreCase("lang")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.lang")) {
                    if (!NumberUtils.isDigits(split[1])) {
                        Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                        displayLocales(player);
                        return true;
                    } else {
                        try {
                            int index = Integer.valueOf(split[1]);
                            if (index < 1 || index > plugin.getAvailableLocales().size()) {
                                Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                                displayLocales(player);
                                return true;
                            }
                            for (ASLocale locale : plugin.getAvailableLocales().values()) {
                                if (locale.getIndex() == index) {
                                    plugin.getPlayers().setLocale(playerUUID, locale.getLocaleName());
                                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(playerUUID).generalSuccess);
                                    return true;
                                }
                            }
                            // Not in the list
                            Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                            displayLocales(player);
                        } catch (Exception e) {
                            Util.sendMessage(player, ChatColor.RED + "/" + label + " lang <#>");
                            displayLocales(player);
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorNoPermission);
                    return true;
                }
            } else // Multi home
            if (split[0].equalsIgnoreCase("go")) {
                if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) {
                    // Player has no island
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                    return true;
                }
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) {
                    int number = 1;
                    try {
                        number = Integer.valueOf(split[1]);
                        //plugin.getLogger().info("DEBUG: number = " + number);
                        if (number < 1) {
                            plugin.getGrid().homeTeleport(player, 1);
                        } else {
                            // Dynamic home sizes with permissions
                            int maxHomes = Settings.maxHomes;
                            for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                                if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) {
                                    if (perms.getPermission().contains(Settings.PERMPREFIX + "island.maxhomes.*")) {
                                        maxHomes = Settings.maxHomes;
                                        break;
                                    } else {
                                        // Get the max value should there be more than one
                                        String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes.");
                                        if (spl.length > 1) {
                                            if (!NumberUtils.isDigits(spl[1])) {
                                                plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                            } else {
                                                maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1]));
                                            }
                                        }
                                    }
                                }
                                // Do some sanity checking
                                if (maxHomes < 1) {
                                    maxHomes = 1;
                                }
                            }
                            if (number > maxHomes) {
                                if (maxHomes > 1) {
                                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes.replace("[max]", String.valueOf(maxHomes)));
                                } else {
                                    plugin.getGrid().homeTeleport(player, 1);
                                }
                            } else {
                                // Teleport home
                                plugin.getGrid().homeTeleport(player, number);
                            }
                        }
                    } catch (Exception e) {
                        plugin.getGrid().homeTeleport(player, 1);
                    }
                    if (Settings.islandRemoveMobs) {
                        plugin.getGrid().removeMobs(player.getLocation());
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("sethome")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.sethome")) {
                    Island island = plugin.getGrid().getIsland(playerUUID);
                    if (island == null) {
                        // plugin.getLogger().info("DEBUG: player has no island in grid");
                        // Player has no island in the grid
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
                        return true;
                    }
                    // Dynamic home sizes with permissions
                    int maxHomes = Settings.maxHomes;
                    for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                        if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.maxhomes.")) {
                            // Get the max value should there be more than one
                            if (perms.getPermission().contains(Settings.PERMPREFIX + "island.maxhomes.*")) {
                                maxHomes = Settings.maxHomes;
                                break;
                            } else {
                                String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.maxhomes.");
                                if (spl.length > 1) {
                                    if (!NumberUtils.isDigits(spl[1])) {
                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                    } else {
                                        maxHomes = Math.max(maxHomes, Integer.valueOf(spl[1]));
                                    }
                                }
                            }
                        }
                        // Do some sanity checking
                        if (maxHomes < 1) {
                            maxHomes = 1;
                        }
                    }
                    if (maxHomes > 1) {
                        // Check the number given is a number
                        int number = 0;
                        try {
                            number = Integer.valueOf(split[1]);
                            if (number < 1 || number > maxHomes) {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes.replace("[max]", String.valueOf(maxHomes)));
                            } else {
                                plugin.getGrid().homeSet(player, number);
                            }
                        } catch (Exception e) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).setHomeerrorNumHomes.replace("[max]", String.valueOf(maxHomes)));
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    }
                    return true;
                }
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                return true;
            } else if (split[0].equalsIgnoreCase("warp")) {
                // Warp somewhere command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.warp")) {
                    final Set<UUID> warpList = plugin.getWarpSignsListener().listWarps();
                    if (warpList.isEmpty()) {
                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).warpserrorNoWarpsYet);
                        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp")) {
                            Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale().warpswarpTip);
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                        }
                        return true;
                    } else {
                        // Check if this is part of a name
                        UUID foundWarp = null;
                        for (UUID warp : warpList) {
                            if (warp == null)
                                continue;
                            if (plugin.getPlayers().getName(warp).toLowerCase().equals(split[1].toLowerCase())) {
                                foundWarp = warp;
                                break;
                            } else if (plugin.getPlayers().getName(warp).toLowerCase().startsWith(split[1].toLowerCase())) {
                                foundWarp = warp;
                            }
                        }
                        if (foundWarp == null) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist);
                            return true;
                        } else {
                            // Warp exists!
                            final Location warpSpot = plugin.getWarpSignsListener().getWarp(foundWarp);
                            // Check if the warp spot is safe
                            if (warpSpot == null) {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotReadyYet);
                                plugin.getLogger().warning("Null warp found, owned by " + plugin.getPlayers().getName(foundWarp));
                                return true;
                            }
                            // Find out if island is locked
                            Island island = plugin.getGrid().getIslandAt(warpSpot);
                            // Check bans
                            if (island != null && plugin.getPlayers().isBanned(island.getOwner(), playerUUID)) {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).banBanned.replace("[name]", plugin.getPlayers().getName(island.getOwner())));
                                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock")) {
                                    return true;
                                }
                            }
                            if (island != null && island.isLocked() && !player.isOp() && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypasslock") && !VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
                                // Always inform that the island is locked
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).lockIslandLocked);
                                // Check if this is the owner, team member or coop
                                if (!plugin.getGrid().locationIsAtHome(player, true, warpSpot)) {
                                    //plugin.getLogger().info("DEBUG: not at home");
                                    return true;
                                }
                            }
                            boolean pvp = false;
                            if ((warpSpot.getWorld().equals(ASkyBlock.getIslandWorld()) && island.getIgsFlag(SettingsFlag.PVP)) || (warpSpot.getWorld().equals(ASkyBlock.getNetherWorld()) && island.getIgsFlag(SettingsFlag.NETHER_PVP))) {
                                pvp = true;
                            }
                            // Find out which direction the warp is facing
                            Block b = warpSpot.getBlock();
                            if (b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.WALL_SIGN)) {
                                Sign sign = (Sign) b.getState();
                                org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData();
                                BlockFace directionFacing = s.getFacing();
                                Location inFront = b.getRelative(directionFacing).getLocation();
                                Location oneDown = b.getRelative(directionFacing).getRelative(BlockFace.DOWN).getLocation();
                                if ((GridManager.isSafeLocation(inFront))) {
                                    warpPlayer(player, inFront, foundWarp, directionFacing, pvp);
                                    return true;
                                } else if (b.getType().equals(Material.WALL_SIGN) && GridManager.isSafeLocation(oneDown)) {
                                    // Try one block down if this is a wall sign
                                    warpPlayer(player, oneDown, foundWarp, directionFacing, pvp);
                                    return true;
                                }
                            } else {
                                // Warp has been removed
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDoesNotExist);
                                plugin.getWarpSignsListener().removeWarp(warpSpot);
                                return true;
                            }
                            if (!(GridManager.isSafeLocation(warpSpot))) {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotSafe);
                                // WALL_SIGN's will always be unsafe if the place in front is obscured.
                                if (b.getType().equals(Material.SIGN_POST)) {
                                    plugin.getLogger().warning("Unsafe warp found at " + warpSpot.toString() + " owned by " + plugin.getPlayers().getName(foundWarp));
                                }
                                return true;
                            } else {
                                final Location actualWarp = new Location(warpSpot.getWorld(), warpSpot.getBlockX() + 0.5D, warpSpot.getBlockY(), warpSpot.getBlockZ() + 0.5D);
                                player.teleport(actualWarp);
                                if (pvp) {
                                    Util.sendMessage(player, ChatColor.BOLD + "" + ChatColor.RED + plugin.myLocale(player.getUniqueId()).igs.get(SettingsFlag.PVP) + " " + plugin.myLocale(player.getUniqueId()).igsAllowed);
                                    if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                                        player.getWorld().playSound(player.getLocation(), Sound.valueOf("ARROW_HIT"), 1F, 1F);
                                    } else {
                                        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT, 1F, 1F);
                                    }
                                } else {
                                    if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                                        player.getWorld().playSound(player.getLocation(), Sound.valueOf("BAT_TAKEOFF"), 1F, 1F);
                                    } else {
                                        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
                                    }
                                }
                                return true;
                            }
                        }
                    }
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("level")) {
                // island level <name> command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.info")) {
                    // Find out if the target has an island
                    final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]);
                    // Invited player must be known
                    if (targetPlayerUUID == null) {
                        // plugin.getLogger().info("DEBUG: unknown player");
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                        return true;
                    }
                    // Check if this player has an island or not
                    if (plugin.getPlayers().hasIsland(targetPlayerUUID) || plugin.getPlayers().inTeam(targetPlayerUUID)) {
                        calculateIslandLevel(player, targetPlayerUUID);
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("invite")) {
                // Team invite a player command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.create")) {
                    // Only online players can be invited
                    Player invitedPlayer = plugin.getServer().getPlayer(split[1]);
                    if (invitedPlayer == null) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer);
                        return true;
                    }
                    UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
                    // Player issuing the command must have an island
                    if (!plugin.getPlayers().hasIsland(player.getUniqueId())) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        return true;
                    }
                    // Player cannot invite themselves
                    if (player.getName().equalsIgnoreCase(split[1])) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself);
                        return true;
                    }
                    // Check if this player can be invited to this island, or
                    // whether they are still on cooldown
                    long time = plugin.getPlayers().getInviteCoolDownTime(invitedPlayerUUID, plugin.getPlayers().getIslandLocation(playerUUID));
                    if (time > 0 && !player.isOp()) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorCoolDown.replace("[time]", String.valueOf(time)));
                        return true;
                    }
                    // the leader, etc
                    if (plugin.getPlayers().inTeam(player.getUniqueId())) {
                        // Leader?
                        if (teamLeader.equals(player.getUniqueId())) {
                            // Invited player is free and not in a team
                            if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) {
                                // Player has space in their team
                                int maxSize = Settings.maxTeamSize;
                                // Dynamic team sizes with permissions
                                for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
                                    if (perms.getPermission().startsWith(Settings.PERMPREFIX + "team.maxsize.")) {
                                        if (perms.getPermission().contains(Settings.PERMPREFIX + "team.maxsize.*")) {
                                            maxSize = Settings.maxTeamSize;
                                            break;
                                        } else {
                                            // Get the max value should there be more than one
                                            String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "team.maxsize.");
                                            if (spl.length > 1) {
                                                if (!NumberUtils.isDigits(spl[1])) {
                                                    plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                                } else {
                                                    maxSize = Math.max(maxSize, Integer.valueOf(spl[1]));
                                                }
                                            }
                                        }
                                    }
                                    // Do some sanity checking
                                    if (maxSize < 1) {
                                        maxSize = 1;
                                    }
                                }
                                if (teamMembers.size() < maxSize) {
                                    // time - interesting
                                    if (inviteList.containsValue(playerUUID)) {
                                        inviteList.remove(getKeyByValue(inviteList, player.getUniqueId()));
                                        Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                                    }
                                    // Put the invited player (key) onto the
                                    // list with inviter (value)
                                    // If someone else has invited a player,
                                    // then this invite will overwrite the
                                    // previous invite!
                                    inviteList.put(invitedPlayerUUID, player.getUniqueId());
                                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo.replace("[name]", split[1]));
                                    // Send message to online player
                                    Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou.replace("[name]", player.getName()));
                                    Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject);
                                    if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) {
                                        Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland);
                                    }
                                } else {
                                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYourIslandIsFull);
                                }
                            } else {
                                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam);
                            }
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                        }
                    } else {
                        // Check if invitee is in a team or not
                        if (!plugin.getPlayers().inTeam(invitedPlayerUUID)) {
                            // it
                            if (inviteList.containsValue(playerUUID)) {
                                inviteList.remove(getKeyByValue(inviteList, player.getUniqueId()));
                                Util.sendMessage(player, ChatColor.YELLOW + plugin.myLocale(player.getUniqueId()).inviteremovingInvite);
                            }
                            // Place the player and invitee on the invite list
                            inviteList.put(invitedPlayerUUID, player.getUniqueId());
                            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).inviteinviteSentTo.replace("[name]", split[1]));
                            Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), plugin.myLocale(invitedPlayerUUID).invitenameHasInvitedYou.replace("[name]", player.getName()));
                            Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.WHITE + "/" + label + " [accept/reject]" + ChatColor.YELLOW + " " + plugin.myLocale(invitedPlayerUUID).invitetoAcceptOrReject);
                            // + invitedPlayerUUID.toString());
                            if (plugin.getPlayers().hasIsland(invitedPlayerUUID)) {
                                // plugin.getLogger().info("DEBUG: invited player has island");
                                Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + plugin.myLocale(invitedPlayerUUID).invitewarningYouWillLoseIsland);
                            }
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorThatPlayerIsAlreadyInATeam);
                        }
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("coop")) {
                // Give a player coop privileges
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Only online players can be cooped
                Player target = plugin.getServer().getPlayer(split[1]);
                if (target == null) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorOfflinePlayer);
                    return true;
                }
                // Player issuing the command must have an island
                UUID targetPlayerUUID = target.getUniqueId();
                if (!plugin.getPlayers().hasIsland(playerUUID) && !plugin.getPlayers().inTeam(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouMustHaveIslandToInvite);
                    return true;
                }
                // Player cannot invite themselves
                if (playerUUID.equals(targetPlayerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).inviteerrorYouCannotInviteYourself);
                    return true;
                }
                // If target player is already on the team ignore
                if (plugin.getPlayers().getMembers(playerUUID).contains(targetPlayerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopOnYourTeam);
                    return true;
                }
                // Target has to have an island
                if (!plugin.getPlayers().inTeam(targetPlayerUUID)) {
                    if (!plugin.getPlayers().hasIsland(targetPlayerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIslandOther);
                        return true;
                    }
                }
                // Add target to coop list
                if (CoopPlay.getInstance().addCoopPlayer(player, target)) {
                    // Tell everyone what happened
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopSuccess.replace("[name]", target.getName()));
                    target.sendMessage(ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).coopMadeYouCoop.replace("[name]", player.getName()));
                // TODO: Give perms if the player is on the coop island
                }
                // else fail silently
                return true;
            } else if (split[0].equalsIgnoreCase("expel")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.expel")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Find out who they want to expel
                UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]);
                if (targetPlayerUUID == null) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotYourself);
                    return true;
                }
                // Target cannot be op
                Player target = plugin.getServer().getPlayer(targetPlayerUUID);
                if (target != null) {
                    if (target.isOp() || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassprotect") || VaultHelper.checkPerm(target, Settings.PERMPREFIX + "mod.bypassexpel")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelFail.replace("[name]", target.getName()));
                        return true;
                    }
                }
                // Remove them from the coop list
                boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, targetPlayerUUID);
                if (coop) {
                    if (target != null) {
                        target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                    } else {
                        plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getName()));
                    }
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess.replace("[name]", plugin.getPlayers().getName(targetPlayerUUID)));
                }
                // See if target is on this player's island
                if (target != null && plugin.getGrid().isOnIsland(player, target)) {
                    // helping out
                    if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers().hasIsland(targetPlayerUUID)) {
                        plugin.getGrid().homeTeleport(target);
                    } else {
                        // Just move target to spawn
                        if (!target.performCommand(Settings.SPAWNCOMMAND)) {
                            target.teleport(player.getWorld().getSpawnLocation());
                        /*
                                         * target.sendBlockChange(target.getWorld().
                                         * getSpawnLocation()
                                         * ,target.getWorld().getSpawnLocation().getBlock().
                                         * getType()
                                         * ,target.getWorld().getSpawnLocation().getBlock().
                                         * getData());
                                         */
                        }
                    }
                    target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).expelExpelled);
                    plugin.getLogger().info(player.getName() + " expelled " + target.getName() + " from their island.");
                    // Yes they are
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).expelSuccess.replace("[name]", target.getName()));
                } else if (!coop) {
                    // No they're not
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotOnIsland);
                }
                return true;
            } else if (split[0].equalsIgnoreCase("uncoop")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "coop")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Find out who they want to uncoop
                UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]);
                if (targetPlayerUUID == null) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).expelNotYourself);
                    return true;
                }
                OfflinePlayer target = plugin.getServer().getOfflinePlayer(targetPlayerUUID);
                // Remove them from the coop list
                boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, targetPlayerUUID);
                if (coop) {
                    if (target != null && target.isOnline()) {
                        Util.sendMessage(target.getPlayer(), ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                    } else {
                        plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).coopRemoved.replace("[name]", player.getName()));
                    }
                    Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess.replace("[name]", plugin.getPlayers().getName(targetPlayerUUID)));
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).coopNotInCoop.replace("[name]", plugin.getPlayers().getName(targetPlayerUUID)));
                }
                return true;
            } else if (split[0].equalsIgnoreCase("ban")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Find out who they want to ban
                final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]);
                // Player must be known
                if (targetPlayerUUID == null) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself);
                    return true;
                }
                // Target cannot be on the same team
                if (plugin.getPlayers().inTeam(playerUUID) && plugin.getPlayers().inTeam(targetPlayerUUID)) {
                    if (plugin.getPlayers().getTeamLeader(playerUUID).equals(plugin.getPlayers().getTeamLeader(targetPlayerUUID))) {
                        // Same team!
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotTeamMember);
                        return true;
                    }
                }
                // Check that the player is not banned already
                if (plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).banAlreadyBanned.replace("[name]", split[1]));
                    return true;
                }
                // Check online/offline status
                Player target = plugin.getServer().getPlayer(targetPlayerUUID);
                // Get offline player
                OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID);
                // Target cannot be op
                if (offlineTarget.isOp()) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail.replace("[name]", split[1]));
                    return true;
                }
                if (target != null) {
                    // Do not ban players with the mod.noban permission
                    if (VaultHelper.checkPerm(target, Settings.PERMPREFIX + "admin.noban")) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banFail.replace("[name]", split[1]));
                        return true;
                    }
                    // Remove them from the coop list
                    boolean coop = CoopPlay.getInstance().removeCoopPlayer(player, target);
                    if (coop) {
                        target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).coopRemoved.replace("[name]", player.getName()));
                        Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).coopRemoveSuccess.replace("[name]", target.getName()));
                    }
                    // See if target is on this player's island and if so send them away
                    if (plugin.getGrid().isOnIsland(player, target)) {
                        // helping out
                        if (plugin.getPlayers().inTeam(targetPlayerUUID) || plugin.getPlayers().hasIsland(targetPlayerUUID)) {
                            plugin.getGrid().homeTeleport(target);
                        } else {
                            // Just move target to spawn
                            if (!target.performCommand(Settings.SPAWNCOMMAND)) {
                                target.teleport(player.getWorld().getSpawnLocation());
                            }
                        }
                    }
                    // Notifications
                    // Target
                    target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getName()));
                } else {
                    // Offline notification
                    plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.RED + plugin.myLocale(targetPlayerUUID).banBanned.replace("[name]", player.getName()));
                }
                // Console
                plugin.getLogger().info(player.getName() + " banned " + split[1] + " from their island.");
                // Player
                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1]));
                // Tell team
                plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1]));
                plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banSuccess.replace("[name]", split[1]));
                // Ban the sucker
                plugin.getPlayers().ban(playerUUID, targetPlayerUUID);
                plugin.getGrid().saveGrid();
                return true;
            } else if (split[0].equalsIgnoreCase("unban")) {
                if (!VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.ban")) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
                // Find out who they want to unban
                final UUID targetPlayerUUID = plugin.getPlayers().getUUID(split[1]);
                // Player must be known
                if (targetPlayerUUID == null) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                    return true;
                }
                // Target should not be themselves
                if (targetPlayerUUID.equals(playerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotYourself);
                    return true;
                }
                // Check that the player is actually banned
                if (!plugin.getPlayers().isBanned(playerUUID, targetPlayerUUID)) {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).banNotBanned.replace("[name]", split[1]));
                    return true;
                }
                // Notifications
                // Online check
                Player target = plugin.getServer().getPlayer(targetPlayerUUID);
                // Target
                if (target != null) {
                    // Online
                    target.sendMessage(ChatColor.RED + plugin.myLocale(target.getUniqueId()).banLifted.replace("[name]", player.getName()));
                } else {
                    plugin.getMessages().setMessage(targetPlayerUUID, ChatColor.GREEN + plugin.myLocale(targetPlayerUUID).banLifted.replace("[name]", player.getName()));
                }
                //OfflinePlayer offlineTarget = plugin.getServer().getOfflinePlayer(targetPlayerUUID);
                // Player
                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1]));
                // Console
                plugin.getLogger().info(player.getName() + " unbanned " + split[1] + " from their island.");
                // Tell team
                plugin.getMessages().tellTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1]));
                plugin.getMessages().tellOfflineTeam(playerUUID, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).banLiftedSuccess.replace("[name]", split[1]));
                // Unban the redeemed one
                plugin.getPlayers().unBan(playerUUID, targetPlayerUUID);
                plugin.getGrid().saveGrid();
                return true;
            } else if (split[0].equalsIgnoreCase("kick") || split[0].equalsIgnoreCase("remove")) {
                // command
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.kick")) {
                    if (!plugin.getPlayers().inTeam(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNoTeam);
                        return true;
                    }
                    // Only leaders can kick
                    if (teamLeader != null && !teamLeader.equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorOnlyLeaderCan);
                        return true;
                    }
                    // The main thing to do is check if the player name to kick
                    // is in the list of players in the team.
                    targetPlayer = null;
                    for (UUID member : teamMembers) {
                        if (plugin.getPlayers().getName(member).equalsIgnoreCase(split[1])) {
                            targetPlayer = member;
                        }
                    }
                    if (targetPlayer == null) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam);
                        return true;
                    }
                    if (teamMembers.contains(targetPlayer)) {
                        // themselves
                        if (player.getUniqueId().equals(targetPlayer)) {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).leaveerrorLeadersCannotLeave);
                            return true;
                        }
                        // Try to kick player
                        if (!removePlayerFromTeam(targetPlayer, teamLeader)) {
                            // If this is canceled, fail silently
                            return true;
                        }
                        // Log the location that this player left so they
                        // cannot join again before the cool down ends
                        plugin.getPlayers().startInviteCoolDownTimer(targetPlayer, plugin.getPlayers().getIslandLocation(playerUUID));
                        if (Settings.resetChallenges) {
                            // Reset the player's challenge status
                            plugin.getPlayers().resetAllChallenges(targetPlayer, false);
                        }
                        // Reset the island level
                        plugin.getPlayers().setIslandLevel(targetPlayer, 0);
                        TopTen.topTenAddEntry(playerUUID, 0);
                        // If target is online
                        Player target = plugin.getServer().getPlayer(targetPlayer);
                        if (target != null) {
                            // plugin.getLogger().info("DEBUG: player is online");
                            target.sendMessage(ChatColor.RED + plugin.myLocale(targetPlayer).kicknameRemovedYou.replace("[name]", player.getName()));
                            // Clear any coop inventories
                            // CoopPlay.getInstance().returnAllInventories(target);
                            // Remove any of the target's coop invitees and
                            // anyone they invited
                            CoopPlay.getInstance().clearMyInvitedCoops(target);
                            CoopPlay.getInstance().clearMyCoops(target);
                            // leader
                            if (target.getWorld().equals(ASkyBlock.getIslandWorld())) {
                                if (!Settings.kickedKeepInv) {
                                    for (ItemStack i : target.getInventory().getContents()) {
                                        if (i != null) {
                                            try {
                                                // Fire an event to see if this item should be dropped or not
                                                // Some plugins may not want items to be dropped
                                                Item drop = player.getWorld().dropItemNaturally(player.getLocation(), i);
                                                PlayerDropItemEvent event = new PlayerDropItemEvent(target, drop);
                                                plugin.getServer().getPluginManager().callEvent(event);
                                            } catch (Exception e) {
                                            }
                                        }
                                    }
                                    // plugin.resetPlayer(target); <- no good if
                                    // reset inventory is false
                                    // Clear their inventory and equipment and set
                                    // them as survival
                                    // Javadocs are
                                    target.getInventory().clear();
                                    // wrong - this
                                    // does not
                                    // clear armor slots! So...
                                    // plugin.getLogger().info("DEBUG: Clearing kicked player's inventory");
                                    target.getInventory().setArmorContents(null);
                                    target.getInventory().setHelmet(null);
                                    target.getInventory().setChestplate(null);
                                    target.getInventory().setLeggings(null);
                                    target.getInventory().setBoots(null);
                                    target.getEquipment().clear();
                                    // Update the inventory
                                    target.updateInventory();
                                }
                            }
                            if (!target.performCommand(Settings.SPAWNCOMMAND)) {
                                target.teleport(ASkyBlock.getIslandWorld().getSpawnLocation());
                            }
                        } else {
                            // Offline
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: player is offline " + targetPlayer.toString());
                            // Tell offline player they were kicked
                            plugin.getMessages().setMessage(targetPlayer, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemovedYou.replace("[name]", player.getName()));
                        }
                        // Remove any warps
                        plugin.getWarpSignsListener().removeWarp(targetPlayer);
                        // Tell leader they removed the player
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kicknameRemoved.replace("[name]", split[1]));
                        //removePlayerFromTeam(targetPlayer, teamLeader);
                        teamMembers.remove(targetPlayer);
                        if (teamMembers.size() < 2) {
                            if (!removePlayerFromTeam(player.getUniqueId(), teamLeader)) {
                                // If cancelled, return silently
                                return true;
                            }
                        }
                        plugin.getPlayers().save(targetPlayer);
                    } else {
                        plugin.getLogger().warning("Player " + player.getName() + " failed to remove " + plugin.getPlayers().getName(targetPlayer));
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).kickerrorNotPartOfTeam);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else if (split[0].equalsIgnoreCase("makeleader")) {
                if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "team.makeleader")) {
                    targetPlayer = plugin.getPlayers().getUUID(split[1]);
                    if (targetPlayer == null) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorUnknownPlayer);
                        return true;
                    }
                    if (targetPlayer.equals(playerUUID)) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError);
                        return true;
                    }
                    if (!plugin.getPlayers().inTeam(player.getUniqueId())) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorYouMustBeInTeam);
                        return true;
                    }
                    if (plugin.getPlayers().getMembers(player.getUniqueId()).size() > 2) {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorRemoveAllPlayersFirst);
                        plugin.getLogger().info(player.getName() + " tried to transfer his island, but failed because >2 people in a team");
                        return true;
                    }
                    if (plugin.getPlayers().inTeam(player.getUniqueId())) {
                        if (teamLeader.equals(player.getUniqueId())) {
                            if (teamMembers.contains(targetPlayer)) {
                                // Remove the target player from the team
                                if (!removePlayerFromTeam(targetPlayer, teamLeader, true)) {
                                    // If cancelled, return silently
                                    return true;
                                }
                                // Remove the leader from the team
                                if (!removePlayerFromTeam(teamLeader, teamLeader, true)) {
                                    // If cancelled, return silently
                                    return true;
                                }
                                Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).makeLeadernameIsNowTheOwner.replace("[name]", plugin.getPlayers().getName(targetPlayer)));
                                // plugin.getLogger().info("DEBUG: " +
                                // plugin.getPlayers().getIslandLevel(teamLeader));
                                // Transfer the data from the old leader to the
                                // new one
                                plugin.getGrid().transferIsland(player.getUniqueId(), targetPlayer);
                                // Create a new team with
                                addPlayertoTeam(player.getUniqueId(), targetPlayer);
                                addPlayertoTeam(targetPlayer, targetPlayer);
                                // Check if online
                                Player target = plugin.getServer().getPlayer(targetPlayer);
                                if (target == null) {
                                    plugin.getMessages().setMessage(targetPlayer, plugin.myLocale(player.getUniqueId()).makeLeaderyouAreNowTheOwner);
                                } else {
                                    // Online
                                    Util.sendMessage(plugin.getServer().getPlayer(targetPlayer), ChatColor.GREEN + plugin.myLocale(targetPlayer).makeLeaderyouAreNowTheOwner);
                                    // Check if new leader has a lower range permission than the island size
                                    boolean hasARangePerm = false;
                                    int range = Settings.islandProtectionRange;
                                    // Check for zero protection range
                                    Island islandByOwner = plugin.getGrid().getIsland(targetPlayer);
                                    if (islandByOwner.getProtectionSize() == 0) {
                                        plugin.getLogger().warning("Player " + player.getName() + "'s island had a protection range of 0. Setting to default " + range);
                                        islandByOwner.setProtectionSize(range);
                                    }
                                    for (PermissionAttachmentInfo perms : target.getEffectivePermissions()) {
                                        if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.range.")) {
                                            if (perms.getPermission().contains(Settings.PERMPREFIX + "island.range.*")) {
                                                // Ignore
                                                break;
                                            } else {
                                                String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.range.");
                                                if (spl.length > 1) {
                                                    if (!NumberUtils.isDigits(spl[1])) {
                                                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
                                                    } else {
                                                        hasARangePerm = true;
                                                        range = Math.max(range, Integer.valueOf(spl[1]));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // Only set the island range if the player has a perm to override the default
                                    if (hasARangePerm) {
                                        // Do some sanity checking
                                        if (range % 2 != 0) {
                                            range--;
                                        }
                                        // Range can go up or down
                                        if (range != islandByOwner.getProtectionSize()) {
                                            Util.sendMessage(player, ChatColor.GOLD + plugin.myLocale(targetPlayer).adminSetRangeUpdated.replace("[number]", String.valueOf(range)));
                                            target.sendMessage(ChatColor.GOLD + plugin.myLocale(targetPlayer).adminSetRangeUpdated.replace("[number]", String.valueOf(range)));
                                            plugin.getLogger().info("Makeleader: Island protection range changed from " + islandByOwner.getProtectionSize() + " to " + range + " for " + player.getName() + " due to permission.");
                                        }
                                        islandByOwner.setProtectionSize(range);
                                    }
                                }
                                plugin.getGrid().saveGrid();
                                return true;
                            }
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorThatPlayerIsNotInTeam);
                        } else {
                            Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorNotYourIsland);
                        }
                    } else {
                        Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).makeLeadererrorGeneralError);
                    }
                    return true;
                } else {
                    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission);
                    return true;
                }
            } else {
                Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
                return true;
            }
            break;
    }
    Util.sendMessage(player, ChatColor.RED + plugin.myLocale(playerUUID).errorUnknownCommand);
    return true;
}
Example 83
Project: Bukkit-master  File: ItemDespawnEvent.java View source code
@Override
public Item getEntity() {
    return (Item) entity;
}
Example 84
Project: JukeIt-master  File: MachineStartButton.java View source code
private void tossItem(SpoutPlayer player, ItemStack dropItem) {
    Location loc = player.getLocation();
    loc.setY(loc.getY() + 1);
    Item item = loc.getWorld().dropItem(loc, dropItem);
    Vector v = loc.getDirection().multiply(0.2);
    v.setY(0.2);
    item.setVelocity(v);
}
Example 85
Project: LimitedCreative-master  File: FeatureBlockItemSpawn.java View source code
@EventHandler(ignoreCancelled = true)
public void onItemSpawn(ItemSpawnEvent event) {
    if (event.getEntity() instanceof Item) {
        if (this.isBlocked(event.getLocation().getBlock().getLocation(), ((Item) event.getEntity()).getItemStack().getType())) {
            event.setCancelled(true);
        }
    }
}
Example 86
Project: HigherExplosives-master  File: MockBukkitWorld.java View source code
@Override
public Item dropItem(Location arg0, ItemStack arg1) {
    // TODO Auto-generated method stub
    return null;
}
Example 87
Project: omc-lib-master  File: AbstractWorld.java View source code
@Override
public Item dropItem(final Location location, final ItemStack item) {
    return world.dropItem(location, item);
}
Example 88
Project: SpoutcraftPlugin-master  File: SpoutWorld.java View source code
@Override
public Item dropItem(Location location, ItemStack item) {
    return world.dropItem(location, item);
}