GithubHelp home page GithubHelp logo

draesia / protocolize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exceptionflug/protocolize

0.0 1.0 0.0 601 KB

A lightweight BungeeCord protocol framework supporting items

Java 100.00%

protocolize's Introduction

Build Status GH Downloads Twitter

Protocolize

A lightweight BungeeCord protocol framework supporting items.

Purpose

Protocolize had been developed to raise the amount of game changing possibilities on BungeeCord platforms. With Protocolize it is possible to create custom inventories or interact with the player inventory itself. Protocolize is also ready for future upscaling! It is easy to self-implement custom packets using the de.exceptionflug.protocolize.AbstractPacket class.

Compatibility

Protocolize has no currently known compatibility issues yet.

How To Use

Please take a look at the examples which I made: https://github.com/Exceptionflug/protocolize/tree/master/protocolize-examples/src/main/java/de/exceptionflug/protocolize/example

Maven

Add the following repository to your pom.xml:

<repository>
  <id>exceptionflug</id>
  <url>https://mvn.exceptionflug.de/repository/exceptionflug-public/</url>
</repository>

This is the full portfolio of protocolize dependencies:

<dependency>
  <groupId>de.exceptionflug</groupId>
  <artifactId>protocolize-api</artifactId>
  <version>1.6.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>de.exceptionflug</groupId>
  <artifactId>protocolize-items</artifactId>
  <version>1.6.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>de.exceptionflug</groupId>
  <artifactId>protocolize-inventory</artifactId>
  <version>1.6.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>de.exceptionflug</groupId>
  <artifactId>protocolize-world</artifactId>
  <version>1.6.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

Listen for incoming and outgoing packets

At first you need to create a new PacketListener (eg. when you want to interact with chat messages)

public class MyPacketAdapter extends PacketAdapter<Chat> {  
  public MyPacketListener() {  
    super(Stream.UPSTREAM, Chat.class);  
  }
}

and register it.

ProtocolAPI.getEventManager().registerListener(new MyPacketAdapter());

Now you can override the following methods to access the packets.

@Override  
public void receive(PacketReceiveEvent<Chat> event) {  
  // Receive on UPSTREAM means receiving a packet from a player  
  // Receive on DOWNSTREAM means receiving a packet from a server a player is connected to
}  
  
@Override  
public void send(PacketSendEvent<Chat> event) {  
  // Sending on UPSTREAM means sending a packet to a player  
  // Sending on DOWNSTREAM means sending a packet to a server a player is connected with
}

For example if we want all actionbar messages printing in the chat instead we can use the following logic on Stream.DOWNSTREAM:

public class MyPacketListener extends PacketAdapter<Chat> {  
 
  public MyPacketListener() {  
    super(Stream.DOWNSTREAM, Chat.class);  
  }  
 
  @Override  
  public void receive(PacketReceiveEvent<Chat> event) {  
    Chat packet = event.getPacket();  
    if(packet.getPosition() == 2) { // Position 2 means actionbar  
      packet.setPosition((byte) 0); // Set to normal chat  
      event.markForRewrite(); // We need to mark the packet for rewriting after we changed fields in the packet class. This is only necessary when receiving packets.  
    }  
  }  
}

protocolize's People

Contributors

dependabot[bot] avatar exceptionflug avatar loggits avatar

Watchers

 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.