Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ngx;
- import API.APIconfig;
- import Core.MainClass;
- import Loader.NGXaddon;
- import ngx.Commands.Quests;
- import ngx.Commands.SetNPC;
- import ngx.Listeners.onInteract;
- import org.bukkit.Chunk;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Villager;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.UUID;
- public class Addon extends NGXaddon {
- public MainClass core;
- public Addon m;
- public APIconfig Messages;
- public APIconfig EntityData;
- public APIconfig Quests;
- public List<LivingEntity> villagers = new ArrayList<LivingEntity>();
- public void preLoad() {
- core = MainClass.getCore();
- m = this;
- setupConfigs();
- }
- public void onLoad() {
- preLoad();
- spawnVillagers();
- loadVillagers();
- registerListener(new onInteract(m, core));
- registerCommand(new SetNPC(m, core));
- registerCommand(new Quests(m, core));
- }
- public void onUnload() {
- PrintConsole("Fire");
- try {
- for (LivingEntity e : villagers) {
- e.getLocation().getWorld().loadChunk(e.getLocation().getChunk());
- e.damage(999999);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- PrintConsole("Fire");
- villagers.clear();
- core = null;
- m = null;
- }
- public void setupConfigs() {
- EntityData = core.APIcfgm.getNewConfig("Entitydata.yml");
- Quests = core.APIcfgm.getNewConfig("Quests.yml");
- }
- @SuppressWarnings("deprecation")
- public void spawnVillagers() {
- if (EntityData.getConfigurationSection("villagers") == null)
- return;
- if (EntityData.getConfigurationSection("villagers").getKeys(false).isEmpty())
- return;
- for (String s : EntityData.getConfigurationSection("villagers").getKeys(false)) {
- PrintConsole("" + UUID.fromString(s));
- World world = core.getServer().getWorld(EntityData.getString("villagers." + UUID.fromString(s) + ".loc." + "world"));
- double x = EntityData.getDouble("villagers." + UUID.fromString(s) + ".loc." + "x");
- double y = EntityData.getDouble("villagers." + UUID.fromString(s) + ".loc." + "y");
- double z = EntityData.getDouble("villagers." + UUID.fromString(s) + ".loc." + "z");
- float yaw = EntityData.getInt("villagers." + UUID.fromString(s) + ".loc." + "yaw");
- float pitch = EntityData.getInt("villagers." + UUID.fromString(s) + ".loc." + "pitch");
- Location loc = new Location(world, x, y, z, yaw, pitch);
- Villager villager = loc.getWorld().spawn(loc, Villager.class);
- villager.setProfession(Villager.Profession.getProfession(EntityData.getInt("villagers." + s + ".type")));
- villager.setCustomName(EntityData.getString("villagers." + s + ".name"));
- villager.setCustomNameVisible(false);
- m.villagers.add(villager);
- core.APIrAI.removeAI(villager.getUniqueId());
- }
- }
- public void loadVillagers() {
- for (String s : EntityData.getStringList("villagers")) {
- villagers.add(core.APIefuuid.getLivingEntity(UUID.fromString(s)));
- }
- }
- public String PLAYER_ONLY = "Error: You can't use this command inside the console!";
- public String USAGE = "&4Error&f: &cProper usage is: ";
- public String INVALID_ARGS = "&4Error&f: &cInvalid arguments.";
- public String NO_PERMISSION = "&4Error&f: &cNo permission!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement