use of org.bukkit.event.Listener in project BKCommonLib by bergerhealer.
the class EntityAddRemoveHandler_1_14_to_1_16_5 method onEnabled.
@Override
public void onEnabled(CommonPlugin plugin) {
super.onEnabled(plugin);
plugin.register(new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkLoad(ChunkLoadEvent event) {
notifyChunkEntitiesLoaded(event.getChunk());
}
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkUnload(ChunkUnloadEvent event) {
notifyChunkEntitiesUnloaded(event.getChunk());
}
});
}
use of org.bukkit.event.Listener in project BKCommonLib by bergerhealer.
the class PortalHandler_1_9 method enable.
@Override
public void enable(CommonPlugin plugin) {
// Listener to disable player portal events pre-emptively while players are viewing credits
// This is required, otherwise other plugins get very confused and teleport players out of the
// credits screen.
plugin.register(new Listener() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalEvent(PlayerPortalEvent event) {
if (EntityPlayerHandle.fromBukkit(event.getPlayer()).isViewingCredits()) {
event.setCancelled(true);
}
}
});
// While the player is inside the end portal, it continuously fires a portal enter event.
// This causes a horrible sound effect to play, because that effect is sent every tick.
// This is obviously very unwanted while viewing the credits!
plugin.register(new PacketListener() {
@Override
public void onPacketReceive(PacketReceiveEvent event) {
}
@Override
public void onPacketSend(PacketSendEvent event) {
if (EntityPlayerHandle.fromBukkit(event.getPlayer()).isViewingCredits()) {
event.setCancelled(true);
}
}
}, PacketType.OUT_WORLD_EVENT);
}
use of org.bukkit.event.Listener in project BKCommonLib by bergerhealer.
the class PortalHandler_1_8 method enable.
@Override
public void enable(CommonPlugin plugin) {
// Cleans up players ignored for a single tick. If something broke, this
// prevents a memory leak.
_ignorePortalEventPlayersCleanup = RunOnceTask.create(plugin, () -> _ignorePortalEventPlayers.clear());
// Listener to disable player portal events pre-emptively while players are viewing credits
// This is required, otherwise other plugins get very confused and teleport players out of the
// credits screen.
plugin.register(new Listener() {
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityPortalEnter(EntityPortalEnterEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (EntityPlayerHandle.fromBukkit(player).isViewingCredits()) {
_ignorePortalEventPlayers.add(player);
_ignorePortalEventPlayersCleanup.start();
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPortalEvent(PlayerPortalEvent event) {
if (_ignorePortalEventPlayers.remove(event.getPlayer())) {
event.setCancelled(true);
}
}
});
}
use of org.bukkit.event.Listener in project Essentials by EssentialsX.
the class EssentialsSpawn method onEnable.
@Override
public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
return;
}
spawns = new SpawnStorage(ess);
ess.addReloadListener(spawns);
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
if (respawnPriority != null) {
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
}
}, this);
}
EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
if (joinPriority != null) {
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
}
}, this);
}
}
use of org.bukkit.event.Listener in project AuthMeReloaded by AuthMe.
the class ListenerConsistencyTest method collectListenerClasses.
@BeforeClass
public static void collectListenerClasses() {
ClassCollector collector = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT + "listener");
classes = collector.collectClasses(Listener.class);
if (classes.isEmpty()) {
throw new IllegalStateException("Did not find any Listener classes. Is the folder correct?");
}
}
Aggregations