Skip to content

A Minecraft library that links objects in the world with Java objects

License

Notifications You must be signed in to change notification settings

tksimeji/wobject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wobject

A Minecraft library that links objects in the world with Java objects

Version Licence

Get Started

Add Wobject to your plugin's dependencies.

Wobject is available on Maven Central.

Gradle (Groovy DSL)

dependencies {
    compileOnly 'com.tksimeji:wobject:x.y.z'
}

Gradle (Kotlin DSL)

dependencies {
    compileOnly("com.tksimeji:wobject:x.y.z")
}

Maven

<dependency>
    <groupId>com.tksimeji</groupId>
    <artifactId>wobject</artifactId>
    <version>x.y.z</version>
    <scope>provided</scope>
</dependency>

Next, specify the plugin dependencies. Write the following in plugin.yml.

depend:
  - Wobject

However, the case of paper-plugin.yml seems to be slightly different.

For a plugin that uses Wobject to work, Wobject must be installed as a plugin on the server along with the plugin.

Installing it on the server is no different from a normal plugin. Just download the jar file from "Releases" and place it in the plugins directory on your server.

Commands

All commands are provided as subcommands of /wobject.

/wobject <subcommand> [args...]

/wobject class-list

Lists the wobject classes known to Wobject.

permission: wobject.class-list

/wobject new <class>

Create a new wobject.

permission: wobject.new

/wobject wobject-list

Lists the wobjects present on the server.

permission: wobject.wobject-list

Usage

1. Define the Wobject class.

Define a class with the com.tksimeji.wobject.api.Wobject annotation.

@Wobject("namespace:key")
public class MyWobject {
}

2. Declare the component

Components are the building blocks of objects.

Block or entity is supported.

// Note: The field name will be the comopnent name.

// Multiple types can be specified for the block component.
@com.tksimeji.wobject.api.BlockComponent({Material.BLOCK_1, Material.BLOCK_2})
private Block blockComponent;

@com.tksimeji.wobject.api.EntityComponent(EntityType.ENTITY)
private Entity entityComponent;

Entity components can also be customized with optional properties.

@com.tksimeji.wobject.api.EntityComopnent(value = EntityType.ENTITY, ai = true, collidable = true, gravity = true, silent = false)
private Entity customizedEntityComponent;

3. Declare the handler

The handler is special method that is called when a specific event occurs. It is declared with the com.tksimeji.wobject.event.Handler annotation.

@Handler
public void onBlockBreak(@NotNull com.tksimeji.wobject.event.BlockBreakEvent event) {
    // Called when a block component is destroyed
    // Important: If you do not cancel the event, the wobject will be killed
}

@Handler
public void onBlockInteracted(@NotNull com.tksimeji.wobject.event.BlockInteractedEvent event) {
    // Called when a block component is interacted with
}

@Handler
public void onBlockRedstone(@NotNull com.tksimeji.wobject.event.BlockRedstoneEvent event) {
    // Called when the regstone signal supplied to a block component changes
}

@Handler
public void onEntityDamage(@NotNull com.tksimeji.wobject.event.EntityDamageEvent event) {
    // Called when an entity component takes damage
}

@Handler
public void onEntityInteracted(@NotNull com.tksimeji.wobject.event.EntityInteractedEvent event) {
    // Called when an entity component is interacted with
}

@Handler
public void onEntityMove(@NotNull com.tksimeji.wobject.event.EntityMoveEvent event) {
    // Called when an entity component moves
}

@Handler
public void onKill(@NotNull com.tksimeji.wobject.event.KillEvent event) {
    // Called when the wobject is killed for some reason
}

@Handler
public void onTick(@NotNull com.tksimeji.wobject.event.TickEvent event) {
    // Called every server tick
}

@com.tksimeji.wobject.api.Initializer
public void init() {
    // Called after the injection of the components is completed
}

Annotations can be used to restrict or prioritize components.

@Handler(component = {"component1", "component2", "..."}, priority = 1)
public void onEvent(@NotNull Event event) {
}

4. Register the Wobject class

Classes must be registered before the server is full started, after which no changes will be accepted.

@Override
public void onEnable() {
    Wobject.register(MyWobject.class);
}

About

A Minecraft library that links objects in the world with Java objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages