Coder Social home page Coder Social logo

inia's Introduction

Inia

Inia is a framework for cross-version plugin support in Minecraft servers.

Features

  • Packets
    • Playout
      • Chat
      • EntityDestroy
      • EntityTeleport
      • PlayerlistHeaderFooter
      • SpawnEntityLiving
      • Title
    • Handshaking
    • Login
    • Playin
    • Status
  • Entities
    • ArmorStand
    • EntityLiving
    • Entity
    • Player
  • Components
    • ChatBaseComponent
    • ChatSerializer
    • PlayerlistHeaderFooter
    • Materials:
    • Sounds, supports before and above 1.9 sound names
  • Packet Gadgets
    • Actionbar
  • Utils
    • Reflection, Server Package
    • Version Utils
    • Packet Utils

Solutions

Method 1: importing package

Relative short code, but version depended and repetive code.

import v1_8;

//...

int ping = ((CraftPlayer) player).getHandle().ping;

Method 2: using Reflection

Version independed, but relative giant and repetive code.

try {
    String bukkitversion = Bukkit.getServer()
        .getClass()
        .getPackage()
        .getName()
        .substring(23);
    Class<?> craftPlayer = Class.forName("org.bukkit.craftbukkit."
        + bukkitversion + ".entity.CraftPlayer");
    Object handle = craftPlayer.getMethod("getHandle")
        .invoke(player);
    Integer ping = (Integer) handle.getClass()
        .getDeclaredField("ping")
        .get(handle);
    
    return ping.intValue();
} catch (ClassNotFoundException | IllegalAccessException
        | IllegalArgumentException | InvocationTargetException
        | NoSuchMethodException | SecurityException
        | NoSuchFieldException e) {
    return -1;
}

Method 3: using interface and importing respectively to implementation

Repetitive code.

Method 4: using library Inia

Short code and version independed.

import inia.ent.PlayerWrapper;

PlayerWrapper wPlayer = new PlayerWrapper(player);
int ping = wPlayer.getPing();

Minecraft Version Support

Server Version Client Version Features Supported Features Not Supported
1.7.10 " mat holo (natively), title (natively)
1.8.4 1.8.9 message, actionbar, holo, title
1.9.4 " actionbar, holo, mat
1.10.2 " actionbar, mat
1.11.2 " actionbar, mat
1.12.2 " mat actionbar
1.13.2 " not-tested
1.14.4 " not-tested
1.15.2 " not-tested
1.16.5 " not-tested
1.17.1 " not-tested
1.18.2 " mat

Inspired by

inia's People

Contributors

luisfuturist 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.