Skip to content

Commit

Permalink
Merge pull request #30 from MultiChat/version-1.6.1
Browse files Browse the repository at this point in the history
Version 1.6.1
  • Loading branch information
OllieMartin authored Oct 18, 2018
2 parents dd84948 + bd5463c commit 520e34f
Show file tree
Hide file tree
Showing 34 changed files with 1,323 additions and 53 deletions.
2 changes: 1 addition & 1 deletion multichat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.6</version>
<version>1.6.1</version>

<repositories>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import xyz.olivermartin.multichat.bungee.events.PostBroadcastEvent;

/**
* Announcements Management
Expand All @@ -33,12 +34,15 @@ public static boolean startAnnouncement(final String name, Integer minutes) {
@Override
public void run() {
String message = announcements.get(name.toLowerCase());

message = ChatControl.applyChatRules(message, "announcements", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
}

// Trigger PostBroadcastEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("announcement", message));
}

}, 0, minutes, TimeUnit.MINUTES);
Expand Down Expand Up @@ -124,12 +128,15 @@ public static void playAnnouncement(String name) {
if (announcements.containsKey(name.toLowerCase())) {

String message = announcements.get(name.toLowerCase());

message = ChatControl.applyChatRules(message, "announcements", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
}

// Trigger PostBroadcastEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("announcement", message));

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import xyz.olivermartin.multichat.bungee.events.PostBroadcastEvent;

/**
* Bulletins Management
Expand Down Expand Up @@ -106,12 +107,15 @@ public void run() {
} else {

message = bulletin.get(nextBulletin);

message = ChatControl.applyChatRules(message, "bulletins", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
}

// Trigger PostBroadcastEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("bulletin", message));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ public static void sendCommandMessage(String command, ServerInfo server) {
server.sendData("multichat:action", stream.toByteArray());

}

public static void sendPlayerCommandMessage(String command, String playerRegex, ServerInfo server) {

ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(stream);

try {

// Command
out.writeUTF(playerRegex);
out.writeUTF(command);

} catch (IOException e) {
e.printStackTrace();
}

server.sendData("multichat:paction", stream.toByteArray());

}

@EventHandler
public static void onPluginMessage(PluginMessageEvent ev) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,58 @@ public String replaceMsgVars(String messageFormat, String message, ProxiedPlayer

}

public String replaceMsgConsoleTargetVars(String messageFormat, String message, ProxiedPlayer sender) {

messageFormat = messageFormat.replace("%MESSAGE%", message);
messageFormat = messageFormat.replace("%DISPLAYNAME%", sender.getDisplayName());
messageFormat = messageFormat.replace("%NAME%", sender.getName());

Optional<PlayerMeta> opm = PlayerMetaManager.getInstance().getPlayer(sender.getUniqueId());
if (opm.isPresent()) {
messageFormat = messageFormat.replace("%PREFIX%", opm.get().prefix);
messageFormat = messageFormat.replace("%SUFFIX%", opm.get().suffix);
messageFormat = messageFormat.replace("%NICK%", opm.get().nick);
}

messageFormat = messageFormat.replace("%DISPLAYNAMET%", "CONSOLE");
messageFormat = messageFormat.replace("%NAMET%", "CONSOLE");

messageFormat = messageFormat.replace("%PREFIXT%", "");
messageFormat = messageFormat.replace("%SUFFIXT%", "");
messageFormat = messageFormat.replace("%NICKT%", "CONSOLE");

messageFormat = messageFormat.replace("%SERVER%", sender.getServer().getInfo().getName());
messageFormat = messageFormat.replace("%SERVERT%", "CONSOLE");
return messageFormat;

}

public String replaceMsgConsoleSenderVars(String messageFormat, String message, ProxiedPlayer target) {

messageFormat = messageFormat.replace("%MESSAGE%", message);
messageFormat = messageFormat.replace("%DISPLAYNAME%", "CONSOLE");
messageFormat = messageFormat.replace("%NAME%", "CONSOLE");

messageFormat = messageFormat.replace("%PREFIX%", "");
messageFormat = messageFormat.replace("%SUFFIX%", "");
messageFormat = messageFormat.replace("%NICK%", "CONSOLE");

messageFormat = messageFormat.replace("%DISPLAYNAMET%", target.getDisplayName());
messageFormat = messageFormat.replace("%NAMET%", target.getName());

Optional<PlayerMeta> opmt = PlayerMetaManager.getInstance().getPlayer(target.getUniqueId());
if (opmt.isPresent()) {
messageFormat = messageFormat.replace("%PREFIXT%", opmt.get().prefix);
messageFormat = messageFormat.replace("%SUFFIXT%", opmt.get().suffix);
messageFormat = messageFormat.replace("%NICKT%", opmt.get().nick);
}

messageFormat = messageFormat.replace("%SERVER%", "CONSOLE");
messageFormat = messageFormat.replace("%SERVERT%", target.getServer().getInfo().getName());
return messageFormat;

}

public String replaceModChatVars(String messageFormat, String playername, String displayname, String server, String message, ProxiedPlayer target) {

messageFormat = messageFormat.replace("%DISPLAYNAME%", displayname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import xyz.olivermartin.multichat.bungee.events.PostBroadcastEvent;
import xyz.olivermartin.multichat.bungee.events.PostGlobalChatEvent;

/**
* Chat Stream
Expand Down Expand Up @@ -102,12 +104,16 @@ public void sendMessage(ProxiedPlayer sender, String message) {
}
}
}

// Trigger PostGlobalChatEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostGlobalChatEvent(sender, message, format));

ProxyServer.getInstance().getConsole().sendMessage(buildFormatConsole(sender,format,message));

}

public void sendMessage(String message) {

for (ProxiedPlayer receiver : ProxyServer.getInstance().getPlayers()) {
if ( (whitelistMembers && members.contains(receiver.getUniqueId())) || (!whitelistMembers && !members.contains(receiver.getUniqueId()))) {
if ( (whitelistServers && servers.contains(receiver.getServer().getInfo().getName())) || (!whitelistServers && !servers.contains(receiver.getServer().getInfo().getName()))) {
Expand All @@ -119,6 +125,10 @@ public void sendMessage(String message) {
}
}
}

// Trigger PostBroadcastEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("cast", message));

//TODO
System.out.println("\033[33m[MultiChat][CHAT]" + message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import xyz.olivermartin.multichat.bungee.commands.MsgCommand;
import xyz.olivermartin.multichat.bungee.commands.MultiChatBypassCommand;
import xyz.olivermartin.multichat.bungee.commands.MultiChatCommand;
import xyz.olivermartin.multichat.bungee.commands.MultiChatExecuteCommand;
import xyz.olivermartin.multichat.bungee.commands.MuteCommand;
import xyz.olivermartin.multichat.bungee.commands.ReplyCommand;
import xyz.olivermartin.multichat.bungee.commands.SocialSpyCommand;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class CommandManager {
msg = new MsgCommand();
multichat = new MultiChatCommand();
multichatbypass = new MultiChatBypassCommand();
multichatexecute = new MultiChatExecuteCommand();
mute = new MuteCommand();
reply = new ReplyCommand();
socialspy = new SocialSpyCommand();
Expand Down Expand Up @@ -79,6 +81,20 @@ public class CommandManager {
private static Command msg;
private static Command multichat;
private static Command multichatbypass;
private static Command multichatexecute;
/**
* @return the multichatexecute
*/
public static Command getMultiChatExecute() {
return multichatexecute;
}
/**
* @param multichatexecute the multichatexecute to set
*/
public static void setMultiChatExecute(Command multichatexecute) {
CommandManager.multichatexecute = multichatexecute;
}

private static Command mute;
private static Command reply;
private static Command socialspy;
Expand Down Expand Up @@ -410,6 +426,7 @@ public static void reload() {
msg = new MsgCommand();
multichat = new MultiChatCommand();
multichatbypass = new MultiChatBypassCommand();
multichatexecute = new MultiChatExecuteCommand();
mute = new MuteCommand();
reply = new ReplyCommand();
socialspy = new SocialSpyCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ public class MessageManager {
+ "&c&oThis command causes your chat messages to bypass MultiChat and be handled directly by spigot.");
defaultMessages.put("command_multichatbypass_enabled", "&aMultiChat BYPASS Enabled");
defaultMessages.put("command_multichatbypass_disabled", "&bMultiChat BYPASS Disabled");

defaultMessages.put("command_execute_usage", "&2Usage: /mce [-s <server-regex>] [-p <player-regex>] <command>\n"
+ "&a&oThis command allows you to execute a command over all your spigot servers (&lwhich have at least 1 player online!&a&o)\n"
+ "By default the command will be executed by console, you can instead make players execute the command using the -p flag\n"
+ "By default the command will be executed on all servers, you can limit which servers using the -s flag.");
defaultMessages.put("command_execute_sent", "&2The command has been sent");

defaultMessages.put("command_reply_usage", "&bUsage: /r <message>");
defaultMessages.put("command_reply_desc", "&bReply to the person who you private messaged most recently");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@
*/
public class MultiChat extends Plugin implements Listener {

public static final String LATEST_VERSION = "1.6";
public static final String LATEST_VERSION = "1.6.1";

public static final String[] ALLOWED_VERSIONS = new String[] {

LATEST_VERSION,
"1.6",
"1.5.2",
"1.5.1",
"1.5",
Expand Down Expand Up @@ -244,15 +245,22 @@ public void onEnable() {
configversion = configYML.getString("version");

if (Arrays.asList(ALLOWED_VERSIONS).contains(configversion)) {

// TODO - Remove for future 1.6.X versions!
if (!configversion.equals(LATEST_VERSION)) {
if ( !( configversion.equals(LATEST_VERSION) || configversion.equals("1.6") ) ) {

getLogger().info("[!!!] [WARNING] YOUR CONFIG FILE IS NOT THE LATEST VERSION");
getLogger().info("[!!!] [WARNING] MULTICHAT 1.6 INTRODUCES SEVERAL NEW FEATURES WHICH ARE NOT IN YOUR OLD FILE");
getLogger().info("[!!!] [WARNING] THE PLUGIN SHOULD WORK WITH THE OLDER FILE, BUT IS NOT SUPPORTED!");
getLogger().info("[!!!] [WARNING] PLEASE BACKUP YOUR OLD CONFIG FILES (config.yml & joinmessages.yml) AND DELETE THEM FROM THE MULTICHAT FOLDER SO NEW ONES CAN BE GENERATED!");
getLogger().info("[!!!] [WARNING] THANK YOU");

} else if (!configversion.equals(LATEST_VERSION)) {

getLogger().info("[!!!] [WARNING] YOUR CONFIG FILE IS NOT THE LATEST VERSION");
getLogger().info("[!!!] [WARNING] MULTICHAT 1.6.1 HAS SOME NEW FEATURES NOT IN YOUR 1.6 FILE");
getLogger().info("[!!!] [WARNING] PLEASE BACKUP YOUR OLD CONFIG FILE (config.yml) AND DELETE FROM THE MULTICHAT FOLDER TO ACCESS THE NEW FEATURES");
getLogger().info("[!!!] [WARNING] THANK YOU");

}

Expand All @@ -266,6 +274,7 @@ public void onEnable() {
getProxy().registerChannel("multichat:suffix");
getProxy().registerChannel("multichat:nick");
getProxy().registerChannel("multichat:action");
getProxy().registerChannel("multichat:paction");
getProxy().getPluginManager().registerListener(this, new BungeeComm());

// Register commands
Expand Down Expand Up @@ -326,6 +335,7 @@ public void registerCommands(Configuration configYML, Configuration chatcontrolY
getProxy().getPluginManager().registerCommand(this, CommandManager.getGrouplist());
getProxy().getPluginManager().registerCommand(this, CommandManager.getMultichat());
getProxy().getPluginManager().registerCommand(this, CommandManager.getMultichatBypass());
getProxy().getPluginManager().registerCommand(this, CommandManager.getMultiChatExecute());
getProxy().getPluginManager().registerCommand(this, CommandManager.getDisplay());
getProxy().getPluginManager().registerCommand(this, CommandManager.getFreezechat());
getProxy().getPluginManager().registerCommand(this, CommandManager.getHelpme());
Expand Down Expand Up @@ -377,6 +387,7 @@ public void unregisterCommands(Configuration configYML, Configuration chatcontro
getProxy().getPluginManager().unregisterCommand(CommandManager.getGrouplist());
getProxy().getPluginManager().unregisterCommand(CommandManager.getMultichat());
getProxy().getPluginManager().unregisterCommand(CommandManager.getMultichatBypass());
getProxy().getPluginManager().unregisterCommand(CommandManager.getMultiChatExecute());
getProxy().getPluginManager().unregisterCommand(CommandManager.getDisplay());
getProxy().getPluginManager().unregisterCommand(CommandManager.getFreezechat());
getProxy().getPluginManager().unregisterCommand(CommandManager.getHelpme());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import xyz.olivermartin.multichat.bungee.events.PostStaffChatEvent;

/**
* Staff Chat Manager
Expand Down Expand Up @@ -53,6 +54,15 @@ public void sendModMessage(String username, String displayname, String server, S
}
}

// Trigger PostStaffChatEvent
if (username.equalsIgnoreCase("console")) {
ProxyServer.getInstance().getPluginManager().callEvent(new PostStaffChatEvent("mod", ProxyServer.getInstance().getConsole() , original));
} else {
if (ProxyServer.getInstance().getPlayer(username) != null) {
ProxyServer.getInstance().getPluginManager().callEvent(new PostStaffChatEvent("mod", ProxyServer.getInstance().getPlayer(username) , original));
}
}

System.out.println("\033[36m[StaffChat] /mc {" + username + "} " + original);

}
Expand Down Expand Up @@ -93,6 +103,15 @@ public void sendAdminMessage(String username, String displayname, String server,
}
}

// Trigger PostStaffChatEvent
if (username.equalsIgnoreCase("console")) {
ProxyServer.getInstance().getPluginManager().callEvent(new PostStaffChatEvent("admin", ProxyServer.getInstance().getConsole() , original));
} else {
if (ProxyServer.getInstance().getPlayer(username) != null) {
ProxyServer.getInstance().getPluginManager().callEvent(new PostStaffChatEvent("admin", ProxyServer.getInstance().getPlayer(username) , original));
}
}

System.out.println("\033[35m[StaffChat] /ac {" + username + "} " + original);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.md_5.bungee.api.plugin.Command;
import xyz.olivermartin.multichat.bungee.ChatControl;
import xyz.olivermartin.multichat.bungee.MessageManager;
import xyz.olivermartin.multichat.bungee.events.PostBroadcastEvent;

/**
* Display Command
Expand Down Expand Up @@ -50,6 +51,9 @@ public static void displayMessage(String message) {
for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)));
}

// Trigger PostBroadcastEvent
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("display", message));

System.out.println("\033[33m[MultiChat][Display] " + message);
}
Expand Down
Loading

0 comments on commit 520e34f

Please sign in to comment.