mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 19:45:54 +01:00
Fix game-pchat-response for /irc smsg.
This commit is contained in:
parent
d8e6f0acca
commit
c8629381d8
@ -82,7 +82,7 @@ public class Msg implements IRCCommandInterface {
|
|||||||
ircBot.consoleMsgPlayer(nick, msg.substring(1));
|
ircBot.consoleMsgPlayer(nick, msg.substring(1));
|
||||||
}
|
}
|
||||||
if (!template.isEmpty()) {
|
if (!template.isEmpty()) {
|
||||||
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(nick, msg.substring(1), template));
|
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(sender, nick, msg.substring(1), template));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,17 +77,17 @@ public class SMsg implements IRCCommandInterface {
|
|||||||
msg = msg.trim();
|
msg = msg.trim();
|
||||||
|
|
||||||
if (plugin.getServer().getPlayer(target) instanceof Player) {
|
if (plugin.getServer().getPlayer(target) instanceof Player) {
|
||||||
Player player = plugin.getServer().getPlayer(target);
|
Player targetPlayer = plugin.getServer().getPlayer(target);
|
||||||
String template = plugin.getMsgTemplate("MAIN", "", TemplateName.GAME_PCHAT);
|
String template = plugin.getMsgTemplate("MAIN", "", TemplateName.GAME_PCHAT);
|
||||||
String targetMsg = plugin.tokenizer.gameChatTokenizer(player, template, msg);
|
String targetMsg = plugin.tokenizer.gameChatTokenizer(sender, target, template, msg);
|
||||||
String responseTemplate = plugin.getMsgTemplate("MAIN", "", TemplateName.GAME_PCHAT_RESPONSE);
|
String responseTemplate = plugin.getMsgTemplate("MAIN", "", TemplateName.GAME_PCHAT_RESPONSE);
|
||||||
if (!responseTemplate.isEmpty()) {
|
if (!responseTemplate.isEmpty()) {
|
||||||
String responseMsg = plugin.tokenizer.msgChatResponseTokenizer(player, msg, responseTemplate);
|
String responseMsg = plugin.tokenizer.msgChatResponseTokenizer(sender, targetPlayer, msg, responseTemplate);
|
||||||
sender.sendMessage(responseMsg);
|
sender.sendMessage(responseMsg);
|
||||||
}
|
}
|
||||||
plugin.logDebug("Tokenized message: " + targetMsg);
|
plugin.logDebug("Tokenized message: " + targetMsg);
|
||||||
player.sendMessage(targetMsg);
|
targetPlayer.sendMessage(targetMsg);
|
||||||
plugin.privateMsgReply.put(player.getName(), sender.getName());
|
plugin.privateMsgReply.put(targetPlayer.getName(), sender.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,13 +119,9 @@ public class SMsg implements IRCCommandInterface {
|
|||||||
|
|
||||||
if (ircBot.botLinkingEnabled) {
|
if (ircBot.botLinkingEnabled) {
|
||||||
final String template = plugin.getMsgTemplate(ircBot.botNick, "", TemplateName.GAME_PCHAT_RESPONSE);
|
final String template = plugin.getMsgTemplate(ircBot.botNick, "", TemplateName.GAME_PCHAT_RESPONSE);
|
||||||
if (sender instanceof Player) {
|
|
||||||
ircBot.msgRemotePlayer((Player) sender, remoteBot, remotePlayer, msg);
|
|
||||||
} else {
|
|
||||||
ircBot.msgRemotePlayer(sender, remoteBot, remotePlayer, msg);
|
ircBot.msgRemotePlayer(sender, remoteBot, remotePlayer, msg);
|
||||||
}
|
|
||||||
if (!template.isEmpty()) {
|
if (!template.isEmpty()) {
|
||||||
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(target, msg, template));
|
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(sender, target, msg, template));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,13 @@ public class ChatTokenizer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param template
|
||||||
|
* @param user
|
||||||
|
* @param ircBot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String ircUserTokenizer(String template, User user, PurpleBot ircBot) {
|
public String ircUserTokenizer(String template, User user, PurpleBot ircBot) {
|
||||||
String host = user.getHostmask();
|
String host = user.getHostmask();
|
||||||
String server = user.getServer();
|
String server = user.getServer();
|
||||||
@ -96,6 +103,14 @@ public class ChatTokenizer {
|
|||||||
.replace("%AWAY%", away);
|
.replace("%AWAY%", away);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param template
|
||||||
|
* @param recipient
|
||||||
|
* @param kicker
|
||||||
|
* @param ircBot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String ircUserTokenizer(String template, User recipient, User kicker, PurpleBot ircBot) {
|
public String ircUserTokenizer(String template, User recipient, User kicker, PurpleBot ircBot) {
|
||||||
String host = kicker.getHostmask();
|
String host = kicker.getHostmask();
|
||||||
String server = kicker.getServer();
|
String server = kicker.getServer();
|
||||||
@ -333,16 +348,19 @@ public class ChatTokenizer {
|
|||||||
* Game chat to game (private messages)
|
* Game chat to game (private messages)
|
||||||
*
|
*
|
||||||
* @param sender
|
* @param sender
|
||||||
|
* @param target
|
||||||
* @param template
|
* @param template
|
||||||
* @param message
|
* @param message
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String gameChatTokenizer(CommandSender sender, String template, String message) {
|
public String gameChatTokenizer(CommandSender sender, String target, String template, String message) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return playerTokenizer((Player) sender, template)
|
return playerTokenizer((Player) sender, template)
|
||||||
|
.replace("%TARGET%", target)
|
||||||
.replace("%MESSAGE%", message);
|
.replace("%MESSAGE%", message);
|
||||||
} else {
|
} else {
|
||||||
return template.replace("%NAME%", sender.getName())
|
return template.replace("%NAME%", sender.getName())
|
||||||
|
.replace("%TARGET%", target)
|
||||||
.replace("%MESSAGE%", message);
|
.replace("%MESSAGE%", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,6 +493,14 @@ public class ChatTokenizer {
|
|||||||
.replace("%CHANNEL%", hChannel);
|
.replace("%CHANNEL%", hChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param townyChannel
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String chatTownyChannelTokenizer(Player player, Channel townyChannel, String message, String template) {
|
public String chatTownyChannelTokenizer(Player player, Channel townyChannel, String message, String template) {
|
||||||
|
|
||||||
return gameChatToIRCTokenizer(player, template, message)
|
return gameChatToIRCTokenizer(player, template, message)
|
||||||
@ -576,10 +602,23 @@ public class ChatTokenizer {
|
|||||||
.replace("%RTSWORLD%", world));
|
.replace("%RTSWORLD%", world));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String reportRTSTokenizer(CommandSender sender, String message, String template) {
|
public String reportRTSTokenizer(CommandSender sender, String message, String template) {
|
||||||
return gameChatToIRCTokenizer(sender.getName(), template, message);
|
return gameChatToIRCTokenizer(sender.getName(), template, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String playerTokenizer(Player player, String message) {
|
public String playerTokenizer(Player player, String message) {
|
||||||
String pName = player.getName();
|
String pName = player.getName();
|
||||||
plugin.logDebug("Tokenizing " + pName + "(O: " + player.isOnline() + ")");
|
plugin.logDebug("Tokenizing " + pName + "(O: " + player.isOnline() + ")");
|
||||||
@ -753,6 +792,13 @@ public class ChatTokenizer {
|
|||||||
.replace("%PARAMS%", params));
|
.replace("%PARAMS%", params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param target
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String targetChatResponseTokenizer(String target, String message, String template) {
|
public String targetChatResponseTokenizer(String target, String message, String template) {
|
||||||
return plugin.colorConverter.gameColorsToIrc(template
|
return plugin.colorConverter.gameColorsToIrc(template
|
||||||
.replace("%TARGET%", target)
|
.replace("%TARGET%", target)
|
||||||
@ -760,6 +806,36 @@ public class ChatTokenizer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param target
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String msgChatResponseTokenizer(CommandSender sender, String target, String message, String template) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
return plugin.colorConverter.ircColorsToGame(
|
||||||
|
playerTokenizer((Player) sender, template)
|
||||||
|
.replace("%TARGET%", target)
|
||||||
|
.replace("%MESSAGE%", message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return plugin.colorConverter.ircColorsToGame(template
|
||||||
|
.replace("%NAME%", sender.getName())
|
||||||
|
.replace("%TARGET%", target)
|
||||||
|
.replace("%MESSAGE%", message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param target
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String msgChatResponseTokenizer(String target, String message, String template) {
|
public String msgChatResponseTokenizer(String target, String message, String template) {
|
||||||
return plugin.colorConverter.ircColorsToGame(template
|
return plugin.colorConverter.ircColorsToGame(template
|
||||||
.replace("%TARGET%", target)
|
.replace("%TARGET%", target)
|
||||||
@ -767,9 +843,16 @@ public class ChatTokenizer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String msgChatResponseTokenizer(Player player, String message, String template) {
|
/**
|
||||||
return template
|
*
|
||||||
.replace("%TARGET%", player.getName())
|
* @param targetPlayer
|
||||||
|
* @param message
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String msgChatResponseTokenizer(CommandSender sender, Player targetPlayer, String message, String template) {
|
||||||
|
return template.replace("%NAME%", sender.getName())
|
||||||
|
.replace("%TARGET%", targetPlayer.getName())
|
||||||
.replace("%MESSAGE%", message);
|
.replace("%MESSAGE%", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user