Skip to content

Instantly share code, notes, and snippets.

@BeYkeRYkt
Created August 25, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeYkeRYkt/3aac7384f6325fa436e0 to your computer and use it in GitHub Desktop.
Save BeYkeRYkt/3aac7384f6325fa436e0 to your computer and use it in GitHub Desktop.
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