2015-01-01 20:38:43 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 cnaude
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package com.cnaude.purpleirc;
|
|
|
|
|
|
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
|
|
|
|
|
|
/**
|
2015-11-23 00:01:58 +01:00
|
|
|
* This thread checks each for users and updates the
|
2015-01-01 20:38:43 +01:00
|
|
|
* internal lists.
|
2015-11-23 00:01:58 +01:00
|
|
|
*
|
|
|
|
* @author Chris Naude
|
2015-01-01 20:38:43 +01:00
|
|
|
*/
|
|
|
|
public class ChannelWatcher {
|
|
|
|
|
|
|
|
private final PurpleIRC plugin;
|
|
|
|
private final BukkitTask bt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2015-11-23 00:01:58 +01:00
|
|
|
* @param plugin the PurpleIRC plugin
|
2015-01-01 20:38:43 +01:00
|
|
|
*/
|
|
|
|
public ChannelWatcher(final PurpleIRC plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
|
|
|
bt = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
|
|
|
ircBot.updateNickList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, plugin.ircChannelCheckInterval, plugin.ircChannelCheckInterval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-23 00:01:58 +01:00
|
|
|
* Cancel the scheduled BukkitTask. Call this when
|
|
|
|
* shutting down.
|
2015-01-01 20:38:43 +01:00
|
|
|
*/
|
|
|
|
public void cancel() {
|
|
|
|
bt.cancel();
|
|
|
|
}
|
2015-05-20 03:13:18 +02:00
|
|
|
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|