Home›Java›Mods›Jibe
ModsJava

Jibe

Minecraft Java mod. Download on the author's site.

⬇ Download on Spigot
Sending events through Redis has never been easier!

Repository
Code (XML):
<repositories >
  <repository >
    <id > jibe </id >
    <url > https://dl.bintray.com/simpleauthority/jibe </url >
  </repository >
</repositories >
Dependency
Code (XML):
<dependencies >
  <dependency >
    <groupId > com.algorithmjunkie </groupId >
    <artifactId > jibe </artifactId >
    <version > 1.0.0 </version >
  </dependency >
</dependencies >
Example :
Create a new plugin and instantiate Jibe.
Code (Java):
public class TestPlugin extends JavaPlugin {
    private Jibe jibe ;

    @Override
    public void onEnable ( ) {
        jibe = new Jibe (
                "MY_CHANNEL" ,
                new RedisAuthAdapter (
                        "localhost" ,
                        6379
                )
        ) ;

//        Alternatively, use a password:
//        jibe = new Jibe(
//                "MY_CHANNEL",
//                new SecureRedisAuthAdapter(
//                        "localhost",
//                        "password",
//                        6379
//                )
//        );
    }
}
The channel you chose is the channel on which messages will be dispatched. All your clients must use the same channel to send and receive messages to each other.

Assume a JibeMessage like so:
Code (Java):
// A JibeMessage that has a sender and a list of affected players.
public class TestJibeMessage extends Jibe. JibeMessage {
    private final UUID sender ;
    private final List < UUID > players ;

    public TestJibeMessage ( UUID sender, List < UUID > players ) {
        this . sender = sender ;
        this . players = players ;
    }

    public UUID getSender ( ) {
        return sender ;
    }

    public List < UUID > getPlayers ( ) {
        return players ;
    }
}
As an example, here is dispatch a "TestJibeMessage" in reaction to an AsyncPlayerChatEvent :
Code (Java):
public class TestListener implements Listener {
    private Jibe jibe ;
 
    public TestListener ( Jibe jibe ) {
        this . jibe = jibe ;
    }
 
    @EventHandler
    public void onChat ( AsyncPlayerChatEvent event ) {
        jibe. post ( new TestJibeMessage (
                event. getPlayer ( ) . getUniqueId ( ) ,
                event. getRecipients ( ) . stream ( )
                        . map ( Player :: getUniqueId )
                        . collect ( Collectors. toList ( ) )
        ) ) ;
    }
}
Now, to catch the "TestJibeMessage" on any Jibe instance for the same channel, just create a listener class:
Code (Java):
public class TestJibeListener {
    @Subscribe
    public void onTestJibe ( TestJibeMessage message ) {
        System . out . println ( String . format (
                "Test Jibe received for %s" ,
                message. getSender ( ) . toString ( )
        ) ) ;

        message. getPlayers ( ) . forEach ( player ->
                System . out . println ( String . format (
                        ">>>> Received by %s" ,
                        player. toString ( )
                ) )
        ) ;
    }
}
Then register it with Jibe's Event Bus:
Code (Java):
@Override
public void onEnable ( ) {
  jibe. getEventBus ( ) . register ( new TestJibeListener ( ) ) ;
}
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Jibe is a free Minecraft Java mod. Downloaded 224 times (via Spigot). Download it and open it directly in the game.

Explore more