Git Product home page Git Product logo

notify's Introduction

🔔notify

We don't want to create mixins for each project over and over again for the same events we could just use in the good old paper days. This is why we created this spectacular library/mod, where we just have to add the events once and can use them in every other project!

For this we use alert, a blazing fast event listening utility. See alert's documentation on how to listen to events.

How to use

Add the following to your mod's build.gradle.kts file:

repositories {
    mavenCentral()
}

dependencies {
    // ...
    
    modImplementation("de.hglabor:notify:1.1.3")
}

Then put the built jar file of notify into your mods folder. You should be able to subscribe to the events like this:

// (On the server)
subscribeToEvent<PlayerJoinEvent> {
    logger.info("Player ${it.player.name.string} joined")
}

Events currently implemented

Client-sided events are unstable! (server/common events should work on the server)

Common
  • PlayerAttackEntityEvent
  • PlayerHungerChangeEvent
  • PlayerItemPickupEvent
  • PlayerPlaceBlockEvent
  • PlayerSlotClickEvent (also called when player attempts to drop an item in the inventory)
  • PlayerItemCraftEvent
  • EntityDamageEvent
Server
  • PlayerBreakBlockEvent
  • PlayerDeathEvent
  • PlayerInteractItemEvent
  • PlayerInteractBlockEvent
  • PlayerItemDropEvent: called when a player attempts to drop an item
  • PlayerItemDroppedEvent: called after an item was dropped
  • PrePlayerJoinEvent: called before a player joins the server
  • PlayerJoinEvent: called when a player joins the server. Allows modification of the join message
  • PostPlayerJoinEvent: called after a player joins the server
  • PlayerRemoveEvent: called after a player got removed from the player list
  • PlayerQuitEvent: called when a player quits the server. Allows modification of the quit message
  • PlayerSwapHandItemsEvent
  • PlayerTickEvent
  • PlayerSetSettingsEvent: called e.g. when player changes client language
  • EntitySpawnEvent
  • ProjectileHitEvent: called when a projectile hits another entity
Client
  • EntityOnTrackedDataSetEvent
  • EntityInitDataTrackerEvent
  • MouseButtonEvent
  • MouseScrollEvent
  • MouseCursorEvent
  • KeyPressedOnceEvent
  • PumpkinOverlayRenderEvent
  • ClientStopEvent
  • PreTickEvent
  • PostTickEvent
  • GameDisconnectEvent
  • GameJoinEvent
  • PlayerEntityRendererScaleEvent: adds a scale factor to the player entity renderer
Every entity (and player) event implements the EntityEvent interface and additionally every player event implements the PlayerEvent interface. That way we can easily add custom event listeners, e.g. like this:
inline fun <reified T : Event> customSubscribeToEvent(
    noinline isActiveCallback: () -> Boolean = { true },
    priority: Int = -1,
    noinline handleCallback: (T) -> Unit,
) = subscribeToEvent<T>(isActiveCallback, priority) {
    if (it is EntityEvent && it.entity is PlayerEntity && it.entity.customProperty == "foo") {
        handleCallback(it)
    }
}

In this example, when we e.g. use customSubscribeToEvent<PlayerDeathEvent> {...} we only listen to player death events where the player has the customProperty set to "foo".

notify's People

Contributors

krxwallo avatar mooziii avatar copyandexecute avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.