Skip to content

Commit

Permalink
Merge pull request #107 from MultiChat/v19
Browse files Browse the repository at this point in the history
Version 1.9.2
  • Loading branch information
OllieMartin authored May 10, 2020
2 parents dc01e74 + 0e4a27c commit 58cca41
Show file tree
Hide file tree
Showing 22 changed files with 338 additions and 64 deletions.
18 changes: 17 additions & 1 deletion multichat/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.9-snapshot.20.5.1</version>
<version>1.9.2</version>
<build>
<plugins>
<plugin>
Expand All @@ -23,6 +23,10 @@
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>xyz.olivermartin.shadedlib.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>xyz.olivermartin.shadedlib.slf4j</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
Expand Down Expand Up @@ -276,6 +280,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.MyzelYam</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>jsr305</artifactId>
<groupId>com.google.code.findbugs</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

19 changes: 18 additions & 1 deletion multichat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.9.1</version>
<version>1.9.2</version>

<repositories>

Expand Down Expand Up @@ -58,6 +58,10 @@
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>xyz.olivermartin.shadedlib.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>xyz.olivermartin.shadedlib.slf4j</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down Expand Up @@ -90,6 +94,12 @@
<version>2.6.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down Expand Up @@ -148,6 +158,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.MyzelYam</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
*/
public class MultiChat extends Plugin implements Listener {

public static final String LATEST_VERSION = "1.9.1";
public static final String LATEST_VERSION = "1.9.2";

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

LATEST_VERSION,
"1.9.1",
"1.9",
"1.8.2",
"1.8.1",
Expand Down Expand Up @@ -92,6 +93,10 @@ public class MultiChat extends Plugin implements Listener {

private static MultiChat instance;

public static boolean premiumVanish = false;
public static boolean hideVanishedStaffInMsg = true;
public static boolean hideVanishedStaffInStaffList = true;

public static MultiChat getInstance() {
return instance;
}
Expand Down Expand Up @@ -132,9 +137,10 @@ public void run() {

if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

getProxy();
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
if (player.getServer() != null) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
}
}

}
Expand Down Expand Up @@ -170,7 +176,9 @@ public void run() {
if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

ProxiedPlayer player = getProxy().getPlayer(playername);
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
if (player.getServer() != null) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
}

}
} catch (NullPointerException ex) { /* EMPTY */ }
Expand All @@ -188,7 +196,9 @@ public void run() {
if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

ProxiedPlayer player = getProxy().getPlayer(playername);
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
if (player.getServer() != null) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
}

}
}
Expand All @@ -207,7 +217,9 @@ public void run() {
if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

ProxiedPlayer player = getProxy().getPlayer(playername);
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
if (player.getServer() != null) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
}

}

Expand All @@ -226,7 +238,9 @@ public void run() {
if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

ProxiedPlayer player = getProxy().getPlayer(playername);
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
if (player.getServer() != null) {
BungeeComm.sendMessage(player.getName(), player.getServer().getInfo());
}

}

Expand Down Expand Up @@ -348,6 +362,17 @@ public void onEnable() {
// Fetch display names of all players
fetchDisplayNames();

// Manage premiumVanish dependency
if (ProxyServer.getInstance().getPluginManager().getPlugin("PremiumVanish") != null) {
premiumVanish = true;

if (configYML.contains("premium_vanish")) {
hideVanishedStaffInMsg = configYML.getBoolean("premium_vanish.prevent_message");
hideVanishedStaffInStaffList = configYML.getBoolean("premium_vanish.prevent_staff_list");
}

}

} else {
getLogger().info("Config incorrect version! Please repair or delete it!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public static String getMessageFromArgs(String[] args, int start, int end) {
String message = "";
for (String arg : args) {
if (counter >= start && counter <= end) {
message = message + arg + " ";
if (counter != end) {
message = message + arg + " ";
} else {
message = message + arg;
}
}
counter++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.config.Configuration;
import xyz.olivermartin.multichat.bungee.ChatControl;
import xyz.olivermartin.multichat.bungee.ConfigManager;
import xyz.olivermartin.multichat.bungee.ConsoleManager;
import xyz.olivermartin.multichat.bungee.MessageManager;
import xyz.olivermartin.multichat.bungee.MultiChatUtil;
Expand Down Expand Up @@ -45,9 +47,15 @@ public void execute(CommandSender sender, String[] args) {
public static void displayMessage(String message) {

message = ChatControl.applyChatRules(message, "display_command", "").get();
Configuration config = ConfigManager.getInstance().getHandler("config.yml").getConfig();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)));
if (onlineplayer.getServer() != null) {
if (!config.getStringList("no_global").contains(
onlineplayer.getServer().getInfo().getName())) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)));
}
}
}

// Trigger PostBroadcastEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;
import java.util.Set;

import de.myzelyam.api.vanish.BungeeVanishAPI;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
Expand All @@ -15,6 +16,7 @@
import xyz.olivermartin.multichat.bungee.ConfigManager;
import xyz.olivermartin.multichat.bungee.Events;
import xyz.olivermartin.multichat.bungee.MessageManager;
import xyz.olivermartin.multichat.bungee.MultiChat;
import xyz.olivermartin.multichat.bungee.MultiChatUtil;
import xyz.olivermartin.multichat.bungee.PrivateMessageManager;

Expand Down Expand Up @@ -54,24 +56,39 @@ public void execute(CommandSender sender, String[] args) {

if ((sender instanceof ProxiedPlayer)) {

ProxiedPlayer player = (ProxiedPlayer)sender;
toggleresult = Events.togglePM(player.getUniqueId(), target.getUniqueId());
boolean permittedToMessage = true;

if (toggleresult == true) {
if (MultiChat.premiumVanish && MultiChat.hideVanishedStaffInMsg) {
if (BungeeVanishAPI.isInvisible(target) && !sender.hasPermission("multichat.chat.msg.vanished")) {
permittedToMessage = false;
}
}

if (permittedToMessage) {

ProxiedPlayer player = (ProxiedPlayer)sender;
toggleresult = Events.togglePM(player.getUniqueId(), target.getUniqueId());

Configuration config = ConfigManager.getInstance().getHandler("config.yml").getConfig();
if (toggleresult == true) {

if (config.contains("toggle_pm") ? config.getBoolean("toggle_pm") == false : false) {
Configuration config = ConfigManager.getInstance().getHandler("config.yml").getConfig();

toggleresult = Events.togglePM(player.getUniqueId(), target.getUniqueId());
MessageManager.sendMessage(sender, "command_msg_no_toggle");
if (config.contains("toggle_pm") ? config.getBoolean("toggle_pm") == false : false) {

toggleresult = Events.togglePM(player.getUniqueId(), target.getUniqueId());
MessageManager.sendMessage(sender, "command_msg_no_toggle");

} else {
MessageManager.sendSpecialMessage(sender, "command_msg_toggle_on", target.getName());
}

} else {
MessageManager.sendSpecialMessage(sender, "command_msg_toggle_on", target.getName());
MessageManager.sendMessage(sender, "command_msg_toggle_off");
}

} else {
MessageManager.sendMessage(sender, "command_msg_toggle_off");
// Vanished staff member
MessageManager.sendMessage(sender, "command_msg_not_online");
}

} else {
Expand Down Expand Up @@ -120,30 +137,45 @@ public void execute(CommandSender sender, String[] args) {

ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);

if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

BungeeComm.sendMessage(sender.getName(), ((ProxiedPlayer)sender).getServer().getInfo());
BungeeComm.sendMessage(target.getName(), target.getServer().getInfo());
boolean permittedToMessage = true;

if (MultiChat.premiumVanish && MultiChat.hideVanishedStaffInMsg) {
if (BungeeVanishAPI.isInvisible(target) && !sender.hasPermission("multichat.chat.msg.vanished")) {
permittedToMessage = false;
}
}

if (!ConfigManager.getInstance().getHandler("config.yml").getConfig().getStringList("no_pm").contains(((ProxiedPlayer)sender).getServer().getInfo().getName())) {
if (permittedToMessage) {

if (!ConfigManager.getInstance().getHandler("config.yml").getConfig().getStringList("no_pm").contains(target.getServer().getInfo().getName())) {
if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true) {

if (ChatControl.ignores(((ProxiedPlayer)sender).getUniqueId(), target.getUniqueId(), "private_messages")) {
ChatControl.sendIgnoreNotifications(target, sender, "private_messages");
return;
}
BungeeComm.sendMessage(sender.getName(), ((ProxiedPlayer)sender).getServer().getInfo());
BungeeComm.sendMessage(target.getName(), target.getServer().getInfo());

}

if (!ConfigManager.getInstance().getHandler("config.yml").getConfig().getStringList("no_pm").contains(((ProxiedPlayer)sender).getServer().getInfo().getName())) {

if (!ConfigManager.getInstance().getHandler("config.yml").getConfig().getStringList("no_pm").contains(target.getServer().getInfo().getName())) {

if (ChatControl.ignores(((ProxiedPlayer)sender).getUniqueId(), target.getUniqueId(), "private_messages")) {
ChatControl.sendIgnoreNotifications(target, sender, "private_messages");
return;
}

PrivateMessageManager.getInstance().sendMessage(message, (ProxiedPlayer)sender, target);
PrivateMessageManager.getInstance().sendMessage(message, (ProxiedPlayer)sender, target);

} else {
MessageManager.sendMessage(sender, "command_msg_disabled_target");
}

} else {
MessageManager.sendMessage(sender, "command_msg_disabled_target");
MessageManager.sendMessage(sender, "command_msg_disabled_sender");
}

} else {
MessageManager.sendMessage(sender, "command_msg_disabled_sender");
// Vanished staff member
MessageManager.sendMessage(sender, "command_msg_not_online");
}

} else if (args[0].equalsIgnoreCase("console")) {
Expand Down Expand Up @@ -214,9 +246,17 @@ public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
for ( ProxiedPlayer player : ProxyServer.getInstance().getPlayers() ) {

if ( player.getName().toLowerCase().startsWith( search ) ) {

if (!Events.hiddenStaff.contains(player.getUniqueId())) {
matches.add( player.getName() );
if (MultiChat.premiumVanish) {
if (!BungeeVanishAPI.isInvisible(player)) {
matches.add(player.getName());
}
} else {
matches.add(player.getName());
}
}

}

}
Expand Down
Loading

0 comments on commit 58cca41

Please sign in to comment.