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));
}
}
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);
}
}
}
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);
}
}
Aggregations