Handle prism rollbacks from console.

This commit is contained in:
cnaude 2016-07-03 09:39:23 -07:00
parent 3b2be57efd
commit ed3b728223
2 changed files with 47 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import me.botsko.prism.events.PrismBlocksDrainEvent;
import me.botsko.prism.events.PrismBlocksExtinguishEvent;
import me.botsko.prism.events.PrismBlocksRollbackEvent;
import me.botsko.prism.events.PrismCustomPlayerActionEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -49,8 +50,13 @@ public class PrismListener implements Listener {
@EventHandler
public void onPrismBlocksRollbackEvent(PrismBlocksRollbackEvent event) {
plugin.logDebug("onPrismBlocksRollbackEvent caught");
Player player = event.onBehalfOf();
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gamePrismRollback(event.onBehalfOf(), event.getQueryParameters(), event.getResult().getBlockStateChanges());
if (player == null) {
ircBot.gamePrismRollback("CONSOLE", event.getQueryParameters(), event.getResult().getBlockStateChanges());
} else {
ircBot.gamePrismRollback(event.onBehalfOf(), event.getQueryParameters(), event.getResult().getBlockStateChanges());
}
}
}

View File

@ -3588,6 +3588,46 @@ public final class PurpleBot {
}
}
}
public void gamePrismRollback(String name, QueryParameters queryParams, ArrayList<BlockStateChange> blockStateChange) {
if (!this.isConnected()) {
return;
}
String keyword = queryParams.getKeyword();
String sortDirection = queryParams.getSortDirection();
String worldName = queryParams.getWorld();
String id = String.valueOf(queryParams.getId());
String radius = String.valueOf(queryParams.getRadius());
if (keyword == null) {
keyword = "";
}
if (sortDirection == null) {
sortDirection = "";
}
if (worldName == null) {
worldName = "";
}
if (id == null) {
id = "";
}
if (radius == null) {
radius = "";
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName, TemplateName.PRISM_ROLLBACK)) {
asyncIRCMessage(channelName, prismBlockStateChangeTokens(plugin.tokenizer
.gameChatToIRCTokenizer(name, plugin.getMessageTemplate(botNick, channelName, TemplateName.PRISM_ROLLBACK))
.replace("%NAME%", name)
.replace("%COMMAND%", queryParams.getOriginalCommand())
.replace("%KEYWORD%", keyword)
.replace("%SORTDIRECTION%", sortDirection)
.replace("%PARAMWORLD%", worldName)
.replace("%ID%", id)
.replace("%RADIUS%", radius), blockStateChange
));
}
}
}
public void gamePrismDrainOrExtinguish(String template, Player player, int radius, ArrayList<BlockStateChange> blockStateChange) {
if (!this.isConnected()) {