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(); int size = msgin.read();
// System.out.println(size);
for(int a = 0; a < size; a++) { for(int a = 0; a < size; a++) {
String ch = msgin.readUTF(); String ch = msgin.readUTF();
if(ChatChannel.isChannel(ch)) { if(ChatChannel.isChannel(ch)) {
ChatChannel cha = ChatChannel.getChannel(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); p.addListening(ch);
} }
} }
@ -828,18 +827,20 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
p.addIgnore(UUID.fromString(i)); p.addIgnore(UUID.fromString(i));
} }
if(!p.hasPlayed()) { if(!p.hasPlayed()) {
boolean isThereABungeeChannel = false;
for(ChatChannel ch : ChatChannel.getAutojoinList()) { for(ChatChannel ch : ChatChannel.getAutojoinList()) {
if(ch.hasPermission()) { if(!ch.hasPermission() || p.getPlayer().hasPermission(ch.getPermission())) {
if(p.getPlayer().hasPermission(ch.getPermission())) {
p.addListening(ch.getName());
}
}
else {
p.addListening(ch.getName()); p.addListening(ch.getName());
if(ch.getBungee()) {
isThereABungeeChannel = true;
}
} }
} }
p.setHasPlayed(true); 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")) { if(subchannel.equals("Ignore")) {

View File

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