Created
September 4, 2012 21:11
-
-
Save volgar1x/3626553 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.shivas.server.core.plugins.Plugin | |
import org.shivas.server.core.plugins.Startable | |
import com.google.common.collect.Lists | |
import javax.swing.Timer | |
class PubManagerPlugin extends Plugin { | |
final String author = "Blackrush" | |
final String version = "alpha1" | |
final String help = "Sends pub message in global channel" | |
Collection<Startable> getServices() { | |
return Lists.newArrayList(new PubManagerService()) | |
} | |
} | |
class PubManagerService implements Startable { | |
static final int RATE = 2 * 60 | |
private Timer timer | |
String pubMessage | |
public PubManagerService() { | |
timer = new Timer( | |
RATE * 1000, | |
evt -> send() | |
) | |
} | |
private void send() { | |
Shivas.getGservice().system().send(null, pubMessage) | |
} | |
void start() { | |
timer.start() | |
} | |
void stop() { | |
timer.stop() | |
} | |
} | |
plugin = new PubManagerPlugin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment