Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.lisenochek.npc;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.LivingEntity;
- import java.io.File;
- import java.io.IOException;
- public class Register {
- public static void init() {
- File f = new File(API.getInstance().getDataFolder(), "NPCbase.yml");
- Bukkit.getPluginCommand("npc").setExecutor(new CommandAPI());
- Bukkit.getPluginManager().registerEvents(new InteractListener(), API.getInstance());
- Bukkit.getPluginManager().registerEvents(new ChunkEntityListener(), API.getInstance());
- Bukkit.getScheduler().runTaskTimer(API.getInstance(), new RunnableClass(), 1, 20);
- if (!f.exists()) {
- try {
- f.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- YamlConfiguration y = ConfigManager.y;
- API.getInstance().saveDefaultConfig();
- if (!y.isConfigurationSection("NPC")) return;
- for (String s : y.getConfigurationSection("NPC").getKeys(false)) {
- World w = Bukkit.getWorld(y.getString("NPC." + s + ".world"));
- double x = y.getDouble("NPC." + s + ".x");
- double Y = y.getDouble("NPC." + s + ".y");
- double z = y.getDouble("NPC." + s + ".z");
- String cmd = y.getString("NPC." + s + ".command");
- Location loc = new Location(w, x, Y, z);
- loc.getChunk().load();
- ChunkEntityListener.addEntity(new CustomEntity(loc, s, cmd), ChatColor.stripColor(s));
- LivingEntity ent = (LivingEntity) ChunkEntityListener.getEntityByLocation(loc);
- ent.setCollidable(false);
- ent.setGravity(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement