A Minecraft library that links objects in the world with Java objects
Add Wobject to your plugin's dependencies.
Wobject is available on Maven Central.
dependencies {
compileOnly 'com.tksimeji:wobject:x.y.z'
}
dependencies {
compileOnly("com.tksimeji:wobject:x.y.z")
}
<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.
All commands are provided as subcommands of /wobject
.
/wobject <subcommand> [args...]
Lists the wobject classes known to Wobject.
permission: wobject.class-list
Create a new wobject.
permission: wobject.new
Lists the wobjects present on the server.
permission: wobject.wobject-list
Define a class with the com.tksimeji.wobject.api.Wobject
annotation.
@Wobject("namespace:key")
public class MyWobject {
}
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;
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) {
}
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);
}