use of io.github.wysohn.triggerreactor.sponge.bridge.entity.SpongeEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method onJoin.
@Listener(order = Order.POST)
public void onJoin(ClientConnectionEvent.Join e) {
SimpleLocation currentSloc = LocationUtil.convertToSimpleLocation(e.getTargetEntity().getLocation());
getAreaForLocation(currentSloc).stream().map(Entry::getValue).forEach((trigger) -> trigger.addEntity(new SpongeEntity(e.getTargetEntity())));
}
use of io.github.wysohn.triggerreactor.sponge.bridge.entity.SpongeEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method onSpawn.
@Listener
public void onSpawn(RespawnPlayerEvent e) {
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(e.getTargetEntity().getLocation());
entityTrackMap.put(e.getTargetEntity().getUniqueId(), new WeakReference<IEntity>(new SpongeEntity(e.getTargetEntity())));
entityLocationMap.put(e.getTargetEntity().getUniqueId(), sloc);
getAreaForLocation(sloc).stream().map(Entry::getValue).forEach((trigger) -> trigger.addEntity(new SpongeEntity(e.getTargetEntity())));
}
use of io.github.wysohn.triggerreactor.sponge.bridge.entity.SpongeEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method onLocationChange.
@Listener(order = Order.POST)
public void onLocationChange(PlayerBlockLocationEvent e) {
List<Entry<Area, AreaTrigger>> from = getAreaForLocation(e.getFrom());
List<Entry<Area, AreaTrigger>> to = getAreaForLocation(e.getTo());
Map<String, Object> varMap = new HashMap<>();
varMap.put("player", e.getTargetEntity());
varMap.put("from", e.getFrom());
varMap.put("to", e.getTo());
from.stream().filter(// only for area leaving
(entry) -> !entry.getKey().isInThisArea(e.getTo())).map(Entry::getValue).forEach((trigger) -> {
trigger.removeEntity(e.getTargetEntity().getUniqueId());
trigger.activate(e, varMap, EventType.EXIT);
});
to.stream().filter(// only for entering area
(entry) -> !entry.getKey().isInThisArea(e.getFrom())).map(Entry::getValue).forEach((trigger) -> {
trigger.addEntity(new SpongeEntity(e.getTargetEntity()));
trigger.activate(e, varMap, EventType.ENTER);
});
}
use of io.github.wysohn.triggerreactor.sponge.bridge.entity.SpongeEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method reload.
@Override
public void reload() {
super.reload();
// re-register entities
for (World w : Sponge.getServer().getWorlds()) {
for (Entity e : w.getEntities()) {
UUID uuid = e.getUniqueId();
if (e.isRemoved() || !e.isLoaded())
continue;
SimpleLocation previous = null;
SimpleLocation current = LocationUtil.convertToSimpleLocation(e.getLocation());
entityLocationMap.put(uuid, current);
entityTrackMap.put(uuid, new WeakReference<IEntity>(new SpongeEntity(e)));
onEntityBlockMoveAsync(e, previous, current);
}
}
}
Aggregations