Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.90 KB | None | 0 0
  1. public class PartyCraft implements PartyCraftAPI {
  2.  
  3.     private Configuration configuration;
  4.     private PartyCraft instance;
  5.     private final Map<Guild, List<String>> ignoredChannelsMap = new HashMap<>();
  6.  
  7.     private boolean running;
  8.     private TextChannelManager textChannelManager = new TextChannelManager();
  9.     private TextChannelsUtil textChannelsUtil = new TextChannelsUtil(textChannelManager);
  10.     private Logger logger;
  11.     private JDA jda;
  12.  
  13.  
  14.     public PartyCraft(Configuration configuration)
  15.     {
  16.         this.configuration = configuration;
  17.     }
  18.     private FileManager fileManager = new FileManager(textChannelManager, instance);
  19.  
  20.     @Override
  21.     public void start() throws LoginException, InterruptedException {
  22.         SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
  23.         this.running = true;
  24.  
  25.         this.jda = new JDABuilder(AccountType.BOT)
  26.                 .setToken(configuration.getDiscordToken())
  27.                 .setAutoReconnect(true)
  28.                 .setAudioEnabled(false)
  29.                 .setEventManager(new AnnotatedEventManager())
  30.                 .setGame(Game.playing(this.configuration.getGame()))
  31.                 .buildBlocking();
  32.  
  33.         jda.addEventListener(new onTextChannelCreated(configuration,textChannelManager));
  34.         jda.addEventListener(new onTextChannelRemoved(configuration,textChannelManager));
  35.  
  36.         CommandRegistry commandRegistry = new CommandRegistry(this);
  37.  
  38.         commandRegistry.register(
  39.                 new ProfileCommand(),
  40.                 new HelpCommand(),
  41.                 new KittyCommand(),
  42.                 new SetGameCommand(this),
  43.                 new IgnoreCommand(this),
  44.                 new KickCommand()
  45.         );
  46.         textChannelsUtil.printAllTextChannels(jda, configuration.getServerName());
  47.         textChannelsUtil.registerAllTextChannels(jda, configuration.getServerName());
  48.         fileManager.checkFiles();
  49.         fileManager.makeNewLogFiles();
  50.  
  51.         try
  52.         {
  53.             logger = new Logger(fileManager.makeNewLogFilesForPlugin());
  54.         } catch (FileNotFoundException e)
  55.         {
  56.             e.printStackTrace();
  57.         }
  58.  
  59.         logger.info("Loaded Bot! =)");
  60.         fileManager.test();
  61.         logger.saveLogs();
  62.  
  63.     }
  64.  
  65.     @Override
  66.     public Configuration getConfiguration()
  67.     {
  68.         return configuration;
  69.     }
  70.  
  71.     @Override
  72.     public JDA getJDA()
  73.     {
  74.         return jda;
  75.     }
  76.  
  77.     @Override
  78.     public boolean isRunning()
  79.     {
  80.         return running;
  81.     }
  82.  
  83.     @Override
  84.     public Map<Guild, List<String>> getIgnoredChannelsMap()
  85.     {
  86.         return ignoredChannelsMap;
  87.     }
  88.  
  89.     public Logger getLogger()
  90.     {
  91.         return logger;
  92.     }
  93.  
  94.     public TextChannelManager getTextChannelManager()
  95.     {
  96.         return this.textChannelManager;
  97.     }
  98.  
  99.  
  100.     public PartyCraft getInstance()
  101.     {
  102.         return instance;
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement