mirror of
https://github.com/Shimeo98/DiscordWhitelisterSpigot.git
synced 2024-12-01 07:03:36 +01:00
Merge pull request #9 from vacer25/Bugfix2
Fixed bug in player count when vanished and normal players join/leave.
This commit is contained in:
commit
36f81a2948
@ -1,5 +1,5 @@
|
||||
name: DiscordWhitelister
|
||||
version: 1.3.2
|
||||
version: 1.3.3
|
||||
author: Joe Shimell
|
||||
main: uk.co.angrybee.joe.DiscordWhitelister
|
||||
description: Discord whitelister bot.
|
||||
|
@ -386,7 +386,7 @@ public class DiscordClient extends ListenerAdapter {
|
||||
Member member = messageReceivedEvent.getMember();
|
||||
messageReceivedEvent.getGuild().addRoleToMember(member, whitelistRole).queue();
|
||||
} catch (Exception e) {
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not add role with name " + whitelistedRoleName + " to " + author.getName() + ", check that it has the correct name in the config");
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not add role with name " + whitelistedRoleName + " to " + author.getName() + ", check that it has the correct name in the config and the bot has the Manage Roles permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ public class DiscordClient extends ListenerAdapter {
|
||||
Member member = messageReceivedEvent.getMember();
|
||||
messageReceivedEvent.getGuild().addRoleToMember(member, whitelistRole).queue();
|
||||
} catch (Exception e) {
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not add role with name " + whitelistedRoleName + " to " + author.getName() + ", check that it has the correct name in the config");
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not add role with name " + whitelistedRoleName + " to " + author.getName() + ", check that it has the correct name in the config and the bot has the Manage Roles permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ public class DiscordClient extends ListenerAdapter {
|
||||
Member member = messageReceivedEvent.getMember();
|
||||
messageReceivedEvent.getGuild().removeRoleFromMember(member, whitelistRole).queue();
|
||||
} catch (Exception e) {
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not remove role with name " + whitelistedRoleName + " from " + author.getName() + ", check that it has the correct name in the config");
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not remove role with name " + whitelistedRoleName + " from " + author.getName() + ", check that it has the correct name in the config and the bot has the Manage Roles permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ public class DiscordClient extends ListenerAdapter {
|
||||
Member member = messageReceivedEvent.getMember();
|
||||
messageReceivedEvent.getGuild().removeRoleFromMember(member, whitelistRole).queue();
|
||||
} catch (Exception e) {
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not remove role with name " + whitelistedRoleName + " from " + author.getName() + ", check that it has the correct name in the config");
|
||||
DiscordWhitelister.getPlugin().getLogger().severe("Could not remove role with name " + whitelistedRoleName + " from " + author.getName() + ", check that it has the correct name in the config and the bot has the Manage Roles permission");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,9 @@ public class DiscordWhitelister extends JavaPlugin
|
||||
|
||||
private static JavaPlugin thisPlugin;
|
||||
|
||||
// For not counting vanished players when other players join/leave
|
||||
private static int vanishedPlayersCount;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
@ -49,6 +52,7 @@ public class DiscordWhitelister extends JavaPlugin
|
||||
whitelisterBotConfig = new YamlConfiguration();
|
||||
userList = new YamlConfiguration();
|
||||
removedList = new YamlConfiguration();
|
||||
vanishedPlayersCount = 0;
|
||||
|
||||
ConfigSetup();
|
||||
|
||||
@ -186,7 +190,11 @@ public class DiscordWhitelister extends JavaPlugin
|
||||
getUserList().save(getUserListFile().getPath());
|
||||
}
|
||||
|
||||
public static int getOnlineUsers() { return thisPlugin.getServer().getOnlinePlayers().size(); }
|
||||
public static void addVanishedPlayer() { vanishedPlayersCount++; }
|
||||
|
||||
public static void removeVanishedPlayer() { vanishedPlayersCount--; }
|
||||
|
||||
public static int getOnlineUsers() { return thisPlugin.getServer().getOnlinePlayers().size() - vanishedPlayersCount; }
|
||||
|
||||
public static int getMaximumAllowedPlayers() { return thisPlugin.getServer().getMaxPlayers(); }
|
||||
|
||||
|
@ -18,6 +18,7 @@ public class JoinLeaveEvents implements Listener
|
||||
event.getPlayer().hasPermission("discordsrv.silentquit") ||
|
||||
event.getPlayer().hasPermission("sv.joinvanished")) {
|
||||
DiscordWhitelister.getPlugin().getLogger().info("Player " + event.getPlayer().getDisplayName() + " joined with silent joining/quitting permission, not incrementing player count");
|
||||
DiscordWhitelister.addVanishedPlayer();
|
||||
return;
|
||||
}
|
||||
DiscordClient.SetPlayerCountStatus(DiscordWhitelister.getOnlineUsers());
|
||||
@ -30,6 +31,7 @@ public class JoinLeaveEvents implements Listener
|
||||
event.getPlayer().hasPermission("discordsrv.silentquit") ||
|
||||
event.getPlayer().hasPermission("sv.joinvanished")) {
|
||||
DiscordWhitelister.getPlugin().getLogger().info("Player " + event.getPlayer().getDisplayName() + " quit with silent joining/quitting permission, not decrementing player count");
|
||||
DiscordWhitelister.removeVanishedPlayer();
|
||||
return;
|
||||
}
|
||||
DiscordClient.SetPlayerCountStatus(DiscordWhitelister.getOnlineUsers() - 1);
|
||||
|
@ -9,5 +9,5 @@ public class VersionInfo {
|
||||
return "v." + getVersion();
|
||||
}
|
||||
|
||||
private static String version = "1.3.2";
|
||||
private static String version = "1.3.3";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user