Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example plugin for LightAPI 1.4.1
package ru.BeYkeRYkt.LightTest;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import ru.BeYkeRYkt.LightAPI.ChunkCoord;
import ru.BeYkeRYkt.LightAPI.LightAPI;
import ru.BeYkeRYkt.LightAPI.LightRegistry;
public class LightTest extends JavaPlugin implements Listener {
private LightRegistry registry;
private int ticks = 5;
private int level = 15;
@Override
public void onEnable() {
this.registry = LightAPI.getRegistry(this);
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
String message = event.getMessage();
Player player = event.getPlayer();
if (message.equals("start")) {
registry.startAutoUpdate(ticks);
player.sendMessage("Runnable started!");
} else if (message.equals("stop")) {
registry.stopAutoUpdate();
player.sendMessage("Runnable stoped!");
} else if (message.equals("create")) {
registry.createLight(player.getLocation(), level);
List<ChunkCoord> list = registry.collectChunks(player.getLocation());
if (!registry.isAutoUpdate()) {
registry.updateChunks(list);
}
} else if (message.equals("delete")) {
registry.deleteLight(player.getLocation());
List<ChunkCoord> list = registry.collectChunks(player.getLocation());
if (!registry.isAutoUpdate()) {
registry.updateChunks(list);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.