Search in sources :

Example 91 with MaterialData

use of org.bukkit.material.MaterialData in project acidisland by tastybento.

the class IslandGuard method onEndermanDeath.

/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
Also used : Enderman(org.bukkit.entity.Enderman) MaterialData(org.bukkit.material.MaterialData) EventHandler(org.bukkit.event.EventHandler)

Example 92 with MaterialData

use of org.bukkit.material.MaterialData in project acidisland by tastybento.

the class LevelCalcByChunk method checkBlock.

private void checkBlock(Material type, int blockData, boolean belowSeaLevel) {
    // Currently, there is no alternative to using block data (Feb 2018)
    @SuppressWarnings("deprecation") MaterialData md = new MaterialData(type, (byte) blockData);
    int count = limitCount(md);
    if (count > 0) {
        if (belowSeaLevel) {
            result.underWaterBlockCount += count;
            result.uwCount.add(md);
        } else {
            result.rawBlockCount += count;
            result.mdCount.add(md);
        }
    }
}
Also used : MaterialData(org.bukkit.material.MaterialData)

Example 93 with MaterialData

use of org.bukkit.material.MaterialData in project acidisland by tastybento.

the class LevelCalcByChunk method sendConsoleReport.

private void sendConsoleReport(CommandSender asker) {
    List<String> reportLines = new ArrayList<>();
    // provide counts
    reportLines.add("Level Log for island at " + island.getCenter());
    reportLines.add("Island owner UUID = " + island.getOwner());
    reportLines.add("Total block value count = " + String.format("%,d", result.rawBlockCount));
    reportLines.add("Level cost = " + Settings.levelCost);
    // reportLines.add("Level multiplier = " + levelMultiplier + " (Player must be online to get a permission multiplier)");
    // reportLines.add("Schematic level handicap = " + levelHandicap + " (level is reduced by this amount)");
    reportLines.add("Deaths handicap = " + result.deathHandicap);
    reportLines.add("Level calculated = " + result.score);
    reportLines.add("==================================");
    int total = 0;
    if (!result.uwCount.isEmpty()) {
        reportLines.add("Underwater block count (Multiplier = x" + Settings.underWaterMultiplier + ") value");
        reportLines.add("Total number of underwater blocks = " + String.format("%,d", result.uwCount.size()));
        reportLines.addAll(sortedReport(total, result.uwCount));
    }
    reportLines.add("Regular block count");
    reportLines.add("Total number of blocks = " + String.format("%,d", result.mdCount.size()));
    reportLines.addAll(sortedReport(total, result.mdCount));
    reportLines.add("Blocks not counted because they exceeded limits: " + String.format("%,d", result.ofCount.size()));
    // entriesSortedByCount = Multisets.copyHighestCountFirst(ofCount).entrySet();
    Iterable<Multiset.Entry<MaterialData>> entriesSortedByCount = result.ofCount.entrySet();
    Iterator<Entry<MaterialData>> it = entriesSortedByCount.iterator();
    while (it.hasNext()) {
        Entry<MaterialData> type = it.next();
        Integer limit = Settings.blockLimits.get(type.getElement());
        String explain = ")";
        if (limit == null) {
            MaterialData generic = new MaterialData(type.getElement().getItemType());
            limit = Settings.blockLimits.get(generic);
            explain = " - All types)";
        }
        reportLines.add(type.getElement().toString() + ": " + String.format("%,d", type.getCount()) + " blocks (max " + limit + explain);
    }
    reportLines.add("==================================");
    reportLines.add("Blocks on island that are not in config.yml");
    reportLines.add("Total number = " + String.format("%,d", result.ncCount.size()));
    // entriesSortedByCount = Multisets.copyHighestCountFirst(ncCount).entrySet();
    entriesSortedByCount = result.ncCount.entrySet();
    it = entriesSortedByCount.iterator();
    while (it.hasNext()) {
        Entry<MaterialData> type = it.next();
        reportLines.add(type.getElement().toString() + ": " + String.format("%,d", type.getCount()) + " blocks");
    }
    reportLines.add("=================================");
    for (String line : reportLines) {
        asker.sendMessage(line);
    }
}
Also used : Entry(com.google.common.collect.Multiset.Entry) ArrayList(java.util.ArrayList) MaterialData(org.bukkit.material.MaterialData)

Aggregations

MaterialData (org.bukkit.material.MaterialData)93 GlowBlockState (net.glowstone.block.GlowBlockState)20 ItemStack (org.bukkit.inventory.ItemStack)20 Material (org.bukkit.Material)13 Block (org.bukkit.block.Block)12 BlockState (org.bukkit.block.BlockState)12 GlowBlock (net.glowstone.block.GlowBlock)10 BlockFace (org.bukkit.block.BlockFace)10 MyPetBaby (de.Keyle.MyPet.api.entity.MyPetBaby)9 TagCompound (de.keyle.knbt.TagCompound)9 ArrayList (java.util.ArrayList)6 DoublePlant (org.bukkit.material.DoublePlant)6 Bed (org.bukkit.material.Bed)5 IOException (java.io.IOException)3 GlowDispenser (net.glowstone.block.state.GlowDispenser)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 CocoaPlant (org.bukkit.material.CocoaPlant)3 Dispenser (org.bukkit.material.Dispenser)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3