Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example plugin for LightAPI 1.4.2
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.ChunkInfo;
import ru.BeYkeRYkt.LightAPI.LightAPI;
import ru.BeYkeRYkt.LightAPI.LightRegistry;
/**
*
* Test plugin for LightAPI
* LightAPI version: 1.4.2
*
* @author BeYkeRYkt
*
*/
public class LightTest extends JavaPlugin implements Listener {
private LightRegistry registry;
private int ticks = 40;
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.startAutoSend(ticks);
player.sendMessage("Runnable started!");
} else if (message.equals("stop")) {
registry.stopAutoSend();
player.sendMessage("Runnable stoped!");
} else if (message.equals("create")) {
registry.createLight(player.getLocation(), level);
List<ChunkInfo> list = registry.collectChunks(player.getLocation());
if (!registry.isAutoSend()) {
registry.sendChunks(list);
}
} else if (message.equals("delete")) {
registry.deleteLight(player.getLocation());
List<ChunkInfo> list = registry.collectChunks(player.getLocation());
if (!registry.isAutoSend()) {
registry.sendChunks(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.