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