-
Notifications
You must be signed in to change notification settings - Fork 6
Development
Dev7ex edited this page Feb 29, 2024
·
17 revisions
MultiWorld has its own API which allows you to add your own generators or to override methods
GitHub: https://github.com/Dev7ex/MultiWorld
Discord: https://discord.gg/FXwsh2CWKp
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.dev7ex</groupId>
<artifactId>multiworld-api-bukkit</artifactId>
<version>1.5.1-SNAPSHOT</version>
</dependency>
Example Plugin.yml
api-version: 1.16
author: yourName
database: false
depend: [MultiWorld]
description: MyWorldPlugin
load: POSTWORLD
loadbefore: [ ]
main: your.plugin.main
name: MyWorldPlugin
prefix: MyWorldPlugin
softdepend: []
version: 1.0.0
website:
Create Main Class
public class MyWorldPlugin extends JavaPlugin {
private MultiWorldBukkitApi multiWorldApi;
@Override
public void onEnable() {
if (super.getServer().getPluginManager().isPluginEnabled("MultiWorld")) {
this.multiWorldApi = (MultiWorldBukkitApi) MultiWorldApiProvider.getMultiWorldApi();
}
}
@Override
public void onDisable() {
}
public static MyWorldPlugin getInstance() {
return JavaPlugin.getPlugin(MyWorldPlugin.class);
}
}
public class MyWorldListener extends MultiWorldListener {
public MyWorldListener(@NotNull final MultiWorldBukkitApi multiWorldApi) {
super(multiWorldApi);
}
@EventHandler(priority = EventPriority.NORMAL)
public void handleUserLogin(final WorldUserLoginEvent event) {
event.getUser().sendMessage("Hello from MyWorldPlugin!");
}
}
Events:
- MultiWorldStartupCompleteEvent
- WorldUserEnterPortalEvent
- WorldUserLoginEvent
- WorldUserLogoutEvent
- WorldUserTeleportWorldEvent
- WorldCloneEvent
- WorldCreateEvent
- WorldDeleteEvent
- WorldFlagChangeEvent
public class MyWorldListener extends MultiWorldListener {
public MyWorldListener(@NotNull final MultiWorldBukkitApi multiWorldApi) {
super(multiWorldApi);
}
@EventHandler(priority = EventPriority.NORMAL)
public void handlePlayerLevelChange(final PlayerLevelChangeEvent event) {
final Player player = event.getPlayer();
if (super.getUserProvider().getUser(player.getUniqueId()).isEmpty()) {
return;
}
final WorldUser user = super.getUserProvider().getUser(player.getUniqueId()).get();
if (event.getNewLevel() > 10) {
if (user.getLastLocation() == null) {
return;
}
player.teleport(BukkitWorldLocation.to(user.getLastLocation()));
}
}
}