Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,23 @@ public void loadVersionFile() {
}
}

public void reload() {
config.load();
loadTokens();
loadVoteReceiver();
}
public void reload() {
if (voteReceiver != null) {
voteReceiver.shutdown();
voteReceiver = null;
}
config.load();
loadTokens();
loadVoteReceiver();
}

@Override
public void onDisable() {
if (voteReceiver != null) {
voteReceiver.shutdown();
voteReceiver = null;
}
}

private void loadVoteReceiver() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void execute(CommandSender sender, String[] args) {
}
sender.sendMessage(new TextComponent("New keys generated"));
}
if (args[0].equalsIgnoreCase("vote") && args.length > 2) {
if ((args[0].equalsIgnoreCase("test") || args[0].equalsIgnoreCase("vote")) && args.length > 2) {
try {
PublicKey publicKey = bungee.getKeyPair().getPublic();
String serverIP = bungee.getConfig().getHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ public VotifierPlusVelocity(ProxyServer server, Logger logger, Metrics.Factory m
this.metricsFactory = metricsFactory;
}

@Subscribe
public void onProxyDisable(ProxyShutdownEvent event) {
voteReceiver.shutdown();
@Subscribe
public void onProxyDisable(ProxyShutdownEvent event) {
if (voteReceiver != null) {
voteReceiver.shutdown();
voteReceiver = null;
}
}

private HashMap<String, Key> tokens = new HashMap<String, Key>();
Expand Down Expand Up @@ -184,8 +187,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
// Specify other aliases (optional)
.aliases("votifierplus", "votifierplusvelocity").build();
server.getCommandManager().register(meta, new VotifierPlusVelocityCommand(this));
loadVoteReceiver();
File rsaDirectory = new File(dataDirectory.toFile(), "rsa");
File rsaDirectory = new File(dataDirectory.toFile(), "rsa");
/*
* Create RSA directory and keys if it does not exist; otherwise, read keys.
*/
Expand All @@ -197,10 +199,11 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
} else {
keyPair = RSAIO.load(rsaDirectory);
}
} catch (Exception ex) {
logger.error("Error reading configuration file or RSA keys");
return;
}
} catch (Exception ex) {
logger.error("Error reading configuration file or RSA keys");
return;
}
loadVoteReceiver();

try {
getVersionFile();
Expand All @@ -224,9 +227,9 @@ public void onProxyInitialization(ProxyInitializeEvent event) {

}

private void loadVoteReceiver() {
try {
voteReceiver = new VoteReceiver(config.getHost(), config.getPort()) {
private boolean loadVoteReceiver() {
try {
VoteReceiver receiver = new VoteReceiver(config.getHost(), config.getPort()) {

@Override
public void logWarning(String warn) {
Expand Down Expand Up @@ -353,17 +356,24 @@ public ThrottleConfig getThrottleConfig() {
}

};
voteReceiver.start();

logger.info("Votifier enabled.");
} catch (Exception ex) {
return;
}
}

public void reload() {
config.reload();
loadTokens();
loadVoteReceiver();
}
}
receiver.start();
voteReceiver = receiver;

logger.info("Votifier enabled.");
return true;
} catch (Exception ex) {
logger.error("Unable to start Votifier vote receiver.", ex);
return false;
}
}

public boolean reload() {
if (voteReceiver != null) {
voteReceiver.shutdown();
voteReceiver = null;
}
config.reload();
loadTokens();
return loadVoteReceiver();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ public void execute(final Invocation invocation) {
if (hasPermission(invocation)) {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
plugin.reload();
source.sendMessage(Component.text("Reloading VotifierPlus").color(NamedTextColor.AQUA));
if (plugin.reload()) {
source.sendMessage(Component.text("Reloaded VotifierPlus").color(NamedTextColor.AQUA));
} else {
source.sendMessage(Component.text("Failed to reload VotifierPlus; check the proxy log.")
.color(NamedTextColor.RED));
}
}
if (args[0].equalsIgnoreCase("GenerateKeys")) {
File rsaDirectory = new File(plugin.getDataDirectory() + File.separator + "rsa");
Expand All @@ -52,7 +56,7 @@ public void execute(final Invocation invocation) {
}
source.sendMessage(Component.text("New keys generated"));
}
if (args[0].equalsIgnoreCase("vote") && args.length > 2) {
if ((args[0].equalsIgnoreCase("test") || args[0].equalsIgnoreCase("vote")) && args.length > 2) {
try {
PublicKey publicKey = plugin.getKeyPair().getPublic();
String serverIP = plugin.getConfig().getHost();
Expand Down
Loading