Fixed issue with sync system not working for autojoin: false channels.

This commit is contained in:
Aust1n46 2021-02-14 18:05:29 -06:00
parent 9b04925c35
commit 22662a6872
2 changed files with 22 additions and 9 deletions

View File

@ -788,12 +788,11 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
}
}
int size = msgin.read();
// System.out.println(size);
for(int a = 0; a < size; a++) {
String ch = msgin.readUTF();
if(ChatChannel.isChannel(ch)) {
ChatChannel cha = ChatChannel.getChannel(ch);
if(cha.hasPermission() && p.getPlayer().hasPermission(cha.getPermission())) {
if(!cha.hasPermission() || p.getPlayer().hasPermission(cha.getPermission())) {
p.addListening(ch);
}
}
@ -828,18 +827,20 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
p.addIgnore(UUID.fromString(i));
}
if(!p.hasPlayed()) {
boolean isThereABungeeChannel = false;
for(ChatChannel ch : ChatChannel.getAutojoinList()) {
if(ch.hasPermission()) {
if(p.getPlayer().hasPermission(ch.getPermission())) {
p.addListening(ch.getName());
if(!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) {
p.addListening(ch.getName());
if(ch.getBungee()) {
isThereABungeeChannel = true;
}
}
else {
p.addListening(ch.getName());
}
}
p.setHasPlayed(true);
this.synchronize(p, true);
// Only run a sync update if the player joined a BungeeCord channel
if(isThereABungeeChannel) {
this.synchronize(p, true);
}
}
}
if(subchannel.equals("Ignore")) {

View File

@ -173,12 +173,18 @@ public class CommandListener implements CommandExecutor, Listener {
}
mcp.addListening(channel.getName());
mcp.setCurrentChannel(channel);
if(channel.getBungee()) {
MineverseChat.getInstance().synchronize(mcp, true);
}
event.setCancelled(true);
return;
}
if(message.toLowerCase().startsWith("/" + channel.getAlias() + " ")) {
message = message.substring(channel.getAlias().length() + 1);
mcp.addListening(channel.getName());
if(channel.getBungee()) {
MineverseChat.getInstance().synchronize(mcp, true);
}
mcp.setQuickChannel(channel);
/*String format = "";
if(plugin.getConfig().getConfigurationSection("channels." + channel.getName()).getString("format").equalsIgnoreCase("Default")) {
@ -211,6 +217,9 @@ public class CommandListener implements CommandExecutor, Listener {
}
}
/**
* Unused
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
@ -227,6 +236,9 @@ public class CommandListener implements CommandExecutor, Listener {
mcp.setQuickChat(true);
mcp.setQuickChannel(channel);
mcp.addListening(channel.getName());
if(channel.getBungee()) {
MineverseChat.getInstance().synchronize(mcp, true);
}
String msg = "";
for(int x = 0; x < args.length; x++) {
if(args[x].length() > 0) msg += " " + args[x];