Guest User

Untitled

a guest
Dec 18th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. package ru.lsrvbungeecore;
  2.  
  3.  
  4.  
  5. import net.md_5.bungee.api.ProxyServer;
  6. import net.md_5.bungee.api.connection.ProxiedPlayer;
  7. import net.md_5.bungee.api.plugin.*;
  8. import java.nio.file.*;
  9.  
  10. import net.md_5.bungee.config.*;
  11. import ru.lsrvbungeecore.CommandPack.findcmd;
  12. import ru.lsrvbungeecore.CommandPack.pingcmd;
  13. import ru.lsrvbungeecore.tab.Tab;
  14.  
  15. import java.io.*;
  16.  
  17. public class main extends Plugin {
  18. public Configuration config;
  19. public File f;
  20. public static main instance;
  21. @SuppressWarnings("unchecked")
  22. public void onEnable(){
  23. instance = this;
  24. Tab.tabset();
  25. getProxy().getPluginManager().registerCommand(this, new pingcmd());
  26. getProxy().getPluginManager().registerCommand(this, new findcmd());
  27. getProxy().getPluginManager().registerListener(this, new Listeners());
  28.  
  29.  
  30.  
  31. this.getDataFolder().mkdirs();
  32. this.f = new File(this.getDataFolder(), "config.yml");
  33. if (!this.f.exists()) {
  34. try {
  35. Files.copy(this.getResourceAsStream("config.yml"), this.f.toPath(), new CopyOption[0]);
  36. }
  37. catch (Exception ex) {}
  38. }
  39. try {
  40. this.config = ConfigurationProvider.getProvider((Class)YamlConfiguration.class).load(this.f);
  41. }
  42. catch (IOException ex2) {}
  43. File db = new File(getDataFolder() + File.separator + "base.db");
  44. if(!db.exists()) {
  45. try {
  46. db.createNewFile();
  47. } catch (IOException e) {
  48. // TODO Auto-generated catch block
  49. e.printStackTrace();
  50. }
  51. }
  52. }
  53. public String getObject(final ProxiedPlayer p, final String object) {
  54. try {
  55. int i = 0;
  56. String object2 = "";
  57. for (final String a : this.config.getStringList(object)) {
  58. if (++i > 1) {
  59. object2 = String.valueOf(object2) + "\n";
  60. }
  61. object2 = String.valueOf(object2) + a;
  62. }
  63. final int online = ProxyServer.getInstance().getOnlineCount();
  64. final int ping = p.getPing();
  65. final String nick = p.getName();
  66. String server = "§aLoading..";
  67. try {
  68. server = p.getServer().getInfo().getName();
  69. }
  70. catch (Exception var8) {
  71. System.out.println("\u0418\u0433\u0440\u043e\u043a " + p.getName() + " \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043d\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443?!");
  72. }
  73. return object2.replace("null", "").replaceAll("&", "§").replaceAll("%online%", String.valueOf(online)).replaceAll("%server%", String.valueOf(server)).replaceAll("%ping%", String.valueOf(ping)).replaceAll("%name%", String.valueOf(nick));
  74. }
  75. catch (Exception var7) {
  76. var7.printStackTrace();
  77. return null;
  78. }
  79. }
  80. }
  81.  
  82.  
  83.  
Advertisement
Add Comment
Please, Sign In to add comment