Until v5, possibly, we will have more major breaking changes. Update it carefully.
// /docs/examples/ReadmeExample.java
public class ReadmeExample extends SinkPlugin {
@Override
public ComponentLoader[] components() {
// A helper method to create a component loader array based on reflection
// Can be written as `new ComponentLoader[] { () -> new MyListener(this) }`
return reflect(this, MyListener.class);
}
}
// A simple class to be our listener
class MyListener implements SinkListener {
// Getters and Setters...
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
// On every player join event, get the player and send a message
event.getPlayer().sendMessage("Hello World!");
}
}
This library is hosted by JitPack.
Replace
VERSION
with the latest Github release.
<!-- Maven -->
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.ArthurFiorette</groupId>
<artifactId>sink-library</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
// Gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.ArthurFiorette:sink-library:VERSION'
}
While the documentation is not done, you can look at the examples, the inline documentation present or our generated javadoc.
This exception is thrown when you try to register a component or service, in your class that extends SinkPlugin, which is generic. Since the ComponentManager manages its objects with the key being their classes, two classes with different generic types would be recognized as the same component.
Here is an example of how to solve this problem with this simple component
public class MyGenericClass<T> implements BaseComponent {
...
}
Create a new class that extends the designed class with the correct type
public class MyStringClass extends MyGenericClass<String> {}
And then you can register the MyStringClass
normally.
If you are willing to contribute in any manner. Checking out this list can be helpful
- Documentation (Urgent haha)
- English revision. (My english is really bad)
- Testing this code under other spigot versions
Licensed under the MIT. See LICENSE
for more informations.
See my contact information on my github profile or open a new issue.