use of org.spongepowered.api.world.World in project ClearMob by axle2005.
the class ClearTileEntity method run.
public static void run(ClearMob plugin, List<TileEntityType> list, Collection<World> worlds, CommandSource src) {
int removedentities = 0;
Collection<TileEntity> e = new ArrayList<TileEntity>();
for (World world : worlds) {
for (TileEntity entity : world.getTileEntities()) {
e.add(entity);
}
}
if (!e.isEmpty()) {
for (TileEntity entity : e) {
for (int i = 0; i <= list.size() - 1; i++) {
if ((entity.getType().equals(list.get(i)))) {
entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
removedentities++;
}
}
}
}
feedback(plugin, src, removedentities);
}
use of org.spongepowered.api.world.World in project HuskyCrates-Sponge by codeHusky.
the class HuskyCrates method placeBlock.
@Listener
public void placeBlock(ChangeBlockEvent event) {
if (event.getCause().root() instanceof Player) {
Player plr = (Player) event.getCause().root();
if (event instanceof ChangeBlockEvent.Place || event instanceof ChangeBlockEvent.Break) {
BlockType t = event.getTransactions().get(0).getOriginal().getLocation().get().getBlock().getType();
Location<World> location = event.getTransactions().get(0).getOriginal().getLocation().get();
location.getBlock().toContainer().set(DataQuery.of("rock"), 1);
//location.getBlock().with()
if (validCrateBlocks.contains(t)) {
//crateUtilities.recognizeChest(event.getTransactions().get(0).getOriginal().getLocation().get());
if (event instanceof ChangeBlockEvent.Place) {
if (plr.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
Optional<Object> tt = plr.getItemInHand(HandTypes.MAIN_HAND).get().toContainer().get(DataQuery.of("UnsafeData", "crateID"));
if (tt.isPresent()) {
String crateID = tt.get().toString();
if (!plr.hasPermission("huskycrates.tester")) {
event.setCancelled(true);
return;
}
if (!crateUtilities.physicalCrates.containsKey(location))
crateUtilities.physicalCrates.put(location, new PhysicalCrate(location, crateID, this));
crateUtilities.physicalCrates.get(location).createHologram();
updatePhysicalCrates();
}
}
}
} else {
if (crateUtilities.physicalCrates.containsKey(location)) {
if (!plr.hasPermission("huskycrates.tester")) {
event.setCancelled(true);
return;
}
crateUtilities.flag = true;
crateUtilities.physicalCrates.get(location).as.remove();
crateUtilities.physicalCrates.remove(location);
updatePhysicalCrates();
}
}
}
}
}
use of org.spongepowered.api.world.World in project HuskyCrates-Sponge by codeHusky.
the class HuskyCrates method gameReloaded.
@Listener
public void gameReloaded(GameReloadEvent event) {
for (World bit : Sponge.getServer().getWorlds()) {
for (Entity ent : bit.getEntities()) {
if (ent instanceof ArmorStand) {
ArmorStand arm = (ArmorStand) ent;
if (arm.getCreator().isPresent()) {
if (arm.getCreator().get().equals(UUID.fromString(armorStandIdentifier))) {
arm.remove();
}
}
}
}
}
langData = new SharedLangData("", "You won %a %R&rfrom a %C&r!", "&e%p just won %a %R&r&e from a %C&r!", "You need a %K&r to open this crate.");
CommentedConfigurationNode conf = null;
try {
conf = crateConfig.load();
if (!conf.getNode("lang").isVirtual())
langData = new SharedLangData(conf.getNode("lang"));
else
logger.info("Using default lang settings.");
} catch (IOException e) {
e.printStackTrace();
logger.warn("Lang load failed, using defaults.");
}
crateUtilities.generateVirtualCrates(crateConfig);
CommentedConfigurationNode root = null;
try {
root = crateConfig.load();
for (CommentedConfigurationNode node : root.getNode("positions").getChildrenList()) {
Location<World> ee;
try {
ee = node.getNode("location").getValue(TypeToken.of(Location.class));
} catch (InvalidDataException err2) {
logger.warn("Bug sponge developers about world UUIDs!");
ee = new Location<World>(Sponge.getServer().getWorld(node.getNode("location", "WorldName").getString()).get(), node.getNode("location", "X").getDouble(), node.getNode("location", "Y").getDouble(), node.getNode("location", "Z").getDouble());
}
if (!crateUtilities.physicalCrates.containsKey(ee))
crateUtilities.physicalCrates.put(ee, new PhysicalCrate(ee, node.getNode("crateID").getString(), HuskyCrates.instance));
}
} catch (IOException e) {
e.printStackTrace();
} catch (ObjectMappingException e) {
e.printStackTrace();
}
crateUtilities.startParticleEffects();
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class VelocityEntitySpawner method sendRadial.
public static List<Entity> sendRadial(EntityType type, Living living, int amt, float speed, Cause cause) {
Location<World> livingLocation = living.getLocation();
Optional<EyeLocationProperty> optEyeLoc = living.getProperty(EyeLocationProperty.class);
if (optEyeLoc.isPresent()) {
Vector3d eyePosition = optEyeLoc.get().getValue();
livingLocation = livingLocation.setPosition(eyePosition);
}
return sendRadial(type, livingLocation, amt, speed, cause);
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class JungleRaidEffectProcessor method distributor.
private static void distributor(JungleRaidInstance inst) {
FlagEffectData data = inst.getFlagData();
boolean isSuddenDeath = inst.isSuddenDeath();
if (isSuddenDeath) {
data.amt = 100;
}
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || inst.isFlagEnabled(JungleRaidFlag.GRENADES) || inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET) || isSuddenDeath) {
Vector3i bvMax = inst.getRegion().getMaximumPoint();
Vector3i bvMin = inst.getRegion().getMinimumPoint();
for (int i = 0; i < Probability.getRangedRandom(data.amt / 3, data.amt); i++) {
Location<World> testLoc = new Location<>(inst.getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY(), Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
if (testLoc.getBlockType() != BlockTypes.AIR)
continue;
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || isSuddenDeath) {
PrimedTNT explosive = (PrimedTNT) inst.getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, testLoc.getPosition());
explosive.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, random.nextDouble() * 2 * -1, random.nextDouble() * 2.0 - 1));
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
// TODO used to have a 1/4 chance of creating fire
inst.getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
if (inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET)) {
PotionEffectType type = Probability.pickOneOf(Sponge.getRegistry().getAllOf(PotionEffectType.class));
for (int ii = Probability.getRandom(5); ii > 0; --ii) {
ThrownPotion potion = (ThrownPotion) inst.getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, testLoc.getPosition());
potion.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, 0, random.nextDouble() * 2.0 - 1));
potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(PotionEffect.of(type, 1, type.isInstant() ? 1 : 20 * 10)));
inst.getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
}
if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
new ItemDropper(testLoc).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.SNOWBALL, Probability.getRandom(3))), SpawnTypes.PLUGIN);
}
}
if (data.amt < 150 && Probability.getChance(inst.isFlagEnabled(JungleRaidFlag.SUPER) ? 9 : 25))
++data.amt;
}
}
Aggregations