use of org.spongepowered.api.entity.ExperienceOrb in project Skree by Skelril.
the class CursedMineListener method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Player player) {
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
CursedMineInstance inst = optInst.get();
Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optHeldItem.isPresent()) {
event.setCancelled(true);
return;
}
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
BlockType originalType = block.getOriginal().getState().getType();
if (cursedOres.contains(originalType)) {
// we were having some multi-firing problems
if (inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()))) {
/*if (Probability.getChance(3000)) {
ChatUtil.send(player, "You feel as though a spirit is trying to tell you something...");
player.getInventory().addItem(BookUtil.Lore.Areas.theGreatMine());
}*/
ExperienceOrb xpOrb = (ExperienceOrb) player.getWorld().createEntity(EntityTypes.EXPERIENCE_ORB, block.getOriginal().getLocation().get().getPosition());
xpOrb.offer(Keys.CONTAINED_EXPERIENCE, (70 - player.getLocation().getBlockY()) / 2);
inst.eatFood(player);
inst.poison(player, 6);
inst.ghost(player, originalType);
}
} else if (stealableFluids.contains(originalType)) {
inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()));
} else {
block.setCustom(block.getOriginal());
}
}
}
use of org.spongepowered.api.entity.ExperienceOrb in project ClearMob by axle2005.
the class EntityLimiter method handle.
@Listener(beforeModifications = true)
public void handle(SpawnEntityEvent event) throws Exception {
List<Entity> entity = event.getEntities();
Integer count = 0;
Integer xpcount = 0;
for (World w : plugin.getWorlds()) {
for (Entity e : w.getEntities()) {
if (e instanceof Monster && !(e instanceof Boss)) {
count++;
}
if (e instanceof ExperienceOrb) {
xpcount++;
}
}
}
for (int i = 0; i < entity.size(); i++) {
if (entity.get(i) instanceof Monster && (count > plugin.getMobLimit()) && !(entity.get(i) instanceof Boss)) {
event.setCancelled(true);
}
if ((entity.get(i) instanceof ExperienceOrb && entity.get(i).getNearbyEntities(10).size() > 20)) {
event.setCancelled(true);
}
}
}
use of org.spongepowered.api.entity.ExperienceOrb in project ClearMob by axle2005.
the class ClearEntity method run.
public static void run(ClearMob plugin, EntityType tile, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
Collection<Entity> e = new ArrayList<Entity>();
for (World world : worlds) {
for (Entity entity : world.getEntities()) {
e.add(entity);
}
}
if (!e.isEmpty()) {
for (Entity entity : e) {
if (!(entity instanceof Item) && !(entity instanceof Player) && !(entity instanceof ExperienceOrb)) {
if ((entity.getType().equals(tile))) {
entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
removedentities++;
}
}
}
}
feedback(plugin, src, removedentities);
}
use of org.spongepowered.api.entity.ExperienceOrb in project ClearMob by axle2005.
the class ClearXP method run.
public static int run(ClearMob plugin, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
Collection<Entity> e = new ArrayList<Entity>();
for (World world : worlds) {
for (Entity entity : world.getEntities()) {
e.add(entity);
}
}
if (!e.isEmpty()) {
for (Entity entity : e) {
if ((entity instanceof ExperienceOrb)) {
entity.remove();
removedentities++;
}
}
}
feedback(plugin, src, removedentities);
return removedentities;
}
Aggregations