use of org.spongepowered.api.event.Listener in project Skree by Skelril.
the class RespawnServiceImpl method onPlayerRespawn.
@Listener
public void onPlayerRespawn(RespawnPlayerEvent event) {
Player player = event.getTargetEntity();
event.setToTransform(new Transform<>(pop(player).orElse(getDefault(player))));
}
use of org.spongepowered.api.event.Listener in project Skree by Skelril.
the class RegionMarker method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player) {
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
return;
}
RegionService service = optService.get();
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
if (!block.isValid()) {
continue;
}
if (block.getOriginal().getState().getType() != this) {
continue;
}
Optional<Location<World>> optLoc = block.getOriginal().getLocation();
if (optLoc.isPresent()) {
Optional<Region> optRef = service.getMarkedRegion(optLoc.get());
if (optRef.isPresent()) {
Region ref = optRef.get();
if (ref.isMember(player)) {
ref.remPoint(new RegionPoint(optLoc.get().getPosition()));
player.sendMessage(Text.of(TextColors.YELLOW, "Region marker deleted!"));
}
}
}
}
}
use of org.spongepowered.api.event.Listener in project Skree by Skelril.
the class RegionMaster method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player) {
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
return;
}
RegionService service = optService.get();
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
if (!block.isValid()) {
continue;
}
if (block.getOriginal().getState().getType() != this) {
continue;
}
Optional<Location<World>> optLoc = block.getOriginal().getLocation();
if (!optLoc.isPresent()) {
continue;
}
Optional<Region> optRef = service.getMarkedRegion(optLoc.get());
if (!optRef.isPresent()) {
continue;
}
Region ref = optRef.get();
if (!ref.getFullPoints().isEmpty()) {
block.setValid(false);
player.sendMessage(Text.of(TextColors.RED, "You must first delete all markers!"));
} else {
service.rem(optLoc.get());
player.sendMessage(Text.of(TextColors.YELLOW, "Region deleted!"));
}
}
}
use of org.spongepowered.api.event.Listener in project Skree by Skelril.
the class JungleRaidEffectListener method onBlockBurn.
@Listener
public void onBlockBurn(ChangeBlockEvent event) {
if (event.getCause().root() instanceof Player) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
BlockType finalType = transaction.getFinal().getState().getType();
if (finalType != BlockTypes.FIRE) {
continue;
}
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(transaction.getOriginal().getLocation().get());
if (optInst.isPresent()) {
JungleRaidInstance inst = optInst.get();
if (inst.isFlagEnabled(JungleRaidFlag.NO_FIRE_SPREAD)) {
event.setCancelled(true);
}
break;
}
}
}
use of org.spongepowered.api.event.Listener in project Skree by Skelril.
the class JungleRaidEffectListener method onPlayerInteract.
@Listener(order = Order.LATE)
public void onPlayerInteract(InteractBlockEvent.Primary.MainHand event, @First Player player) {
Optional<Location<World>> optBlockLoc = event.getTargetBlock().getLocation();
if (!optBlockLoc.isPresent()) {
return;
}
Location<World> blockLoc = optBlockLoc.get();
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(blockLoc);
if (!optInst.isPresent()) {
return;
}
JungleRaidInstance inst = optInst.get();
if (inst.isFlagEnabled(JungleRaidFlag.TITAN_MODE) && player.getUniqueId().equals(inst.getFlagData().titan)) {
if (blockLoc.getBlockType() == BlockTypes.BEDROCK) {
return;
}
// TODO Convert to the Sponge API
((net.minecraft.world.World) blockLoc.getExtent()).destroyBlock(new BlockPos(blockLoc.getX(), blockLoc.getY(), blockLoc.getZ()), true);
}
}
Aggregations