mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-09-30 07:27:28 +02:00
Handle prism rollbacks from console.
This commit is contained in:
parent
3b2be57efd
commit
ed3b728223
@ -23,6 +23,7 @@ import me.botsko.prism.events.PrismBlocksDrainEvent;
|
|||||||
import me.botsko.prism.events.PrismBlocksExtinguishEvent;
|
import me.botsko.prism.events.PrismBlocksExtinguishEvent;
|
||||||
import me.botsko.prism.events.PrismBlocksRollbackEvent;
|
import me.botsko.prism.events.PrismBlocksRollbackEvent;
|
||||||
import me.botsko.prism.events.PrismCustomPlayerActionEvent;
|
import me.botsko.prism.events.PrismCustomPlayerActionEvent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
@ -49,8 +50,13 @@ public class PrismListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPrismBlocksRollbackEvent(PrismBlocksRollbackEvent event) {
|
public void onPrismBlocksRollbackEvent(PrismBlocksRollbackEvent event) {
|
||||||
plugin.logDebug("onPrismBlocksRollbackEvent caught");
|
plugin.logDebug("onPrismBlocksRollbackEvent caught");
|
||||||
|
Player player = event.onBehalfOf();
|
||||||
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
public void gamePrismDrainOrExtinguish(String template, Player player, int radius, ArrayList<BlockStateChange> blockStateChange) {
|
||||||
if (!this.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user