Guest User

Untitled

a guest
Jan 3rd, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. package ru.lymonmine.lsrvbungeevkpost;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.nio.file.CopyOption;
  6. import java.nio.file.Files;
  7.  
  8. import com.vk.api.sdk.client.TransportClient;
  9. import com.vk.api.sdk.client.VkApiClient;
  10. import com.vk.api.sdk.client.actors.GroupActor;
  11. import com.vk.api.sdk.exceptions.ApiException;
  12. import com.vk.api.sdk.exceptions.ClientException;
  13. import com.vk.api.sdk.httpclient.HttpTransportClient;
  14. import net.md_5.bungee.api.plugin.Plugin;
  15. import net.md_5.bungee.config.Configuration;
  16. import net.md_5.bungee.config.ConfigurationProvider;
  17. import net.md_5.bungee.config.YamlConfiguration;
  18.  
  19. public final class main extends Plugin {
  20. public Configuration config;
  21. public File f;
  22. public static main instance;
  23.  
  24.  
  25. @Override
  26. public void onEnable(){
  27. this.getDataFolder().mkdirs();
  28. this.f = new File(this.getDataFolder(), "config.yml");
  29. if (!this.f.exists()) {
  30. try {
  31. Files.copy(this.getResourceAsStream("config.yml"), this.f.toPath(), new CopyOption[0]);
  32. } catch (Exception ex) {
  33. }
  34. }
  35. try {
  36. this.config = ConfigurationProvider.getProvider((Class) YamlConfiguration.class).load(this.f);
  37. } catch (IOException e) {
  38. e.printStackTrace();
  39. }
  40.  
  41.  
  42. TransportClient transportClient = new HttpTransportClient();
  43. VkApiClient vk = new VkApiClient(transportClient);
  44. GroupActor actor = new GroupActor(config.getInt("vk-settings.groupid"), config.getString("vk-settings.groupToken"));
  45. vk.groups().setLongPollSettings(actor, config.getInt("vk-settings.groupid")).enabled(true).wallPostNew(true);
  46. longpollevent handler = new longpollevent(vk, actor);
  47. try {
  48. handler.run();
  49. } catch (ClientException e) {
  50. e.printStackTrace();
  51. } catch (ApiException e) {
  52. e.printStackTrace();
  53. }
  54. instance = this;
  55.  
  56. }
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment