コード例 #1
0
ファイル: IRCanary.java プロジェクト: mbax/IRCanary2
 @Override
 public void enable() {
   this.log = Logger.getLogger("Minecraft");
   final File dir = new File("IRCanary");
   if (!dir.exists()) {
     dir.mkdir();
   }
   try {
     final ConfigurationFile ircProperties = Configuration.getPluginConfig("IRCanary");
     this.serverHost = ircProperties.getString("server-host", "localhost");
     this.serverPort = ircProperties.getInt("server-port", 6667);
     this.nickname = ircProperties.getString("bot-nickname", "aMinecraftBot");
     this.ircChannel = ircProperties.getString("irc-channel", "#minecraftbot");
     this.ircUserColor = ircProperties.getString("irc-usercolor", "f");
     this.ircNameSeparator = ircProperties.getString("irc-separator", "<,>").split(",");
     this.characterLimit = ircProperties.getInt("charlimit", 390);
     this.msgCommandRequired = ircProperties.getBoolean("msg-command-required", false);
     this.echoIRCMessages = ircProperties.getBoolean("repeat-relay-back", false);
     this.debugMode = ircProperties.getBoolean("debug-spam-mode", false);
     this.botAuthLine = ircProperties.getString("auth-message", "");
     this.commandPrefix = ircProperties.getString("irc-command-prefix", ".").charAt(0);
     this.allowJoinQuitUpdates = ircProperties.getBoolean("send-join-quit-to-IRC", true);
     this.allowKickBanUpdates = ircProperties.getBoolean("send-kick-ban-to-IRC", true);
     this.kickMessage =
         ircProperties.getString("kick-formatting", "%player kicked (\"%reason%\")");
     this.banMessage = ircProperties.getString("ban-formatting", "%player banned (\"%reason%\")");
   } catch (final Exception e) {
     this.log.log(Level.SEVERE, "[IRCanary] Exception while reading from irc.properties", e);
   }
   this.botEnabled = true;
   this.bot =
       new IRCBot(
           this.nickname,
           this.msgCommandRequired,
           this.characterLimit,
           this.ircUserColor,
           this.echoIRCMessages,
           this.ircNameSeparator,
           this,
           this.commandPrefix);
   if (this.debugMode) {
     this.bot.setVerbose(true);
   }
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.CHAT);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.COMMAND);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.LOGIN);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.PLAYER_DISCONNECT);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.KICK);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.BAN);
   this.resetBot();
   this.loadAdmins();
   this.log.log(Level.INFO, "[IRCanary] Version " + this.version + " enabled!");
 }