mirror of
				https://github.com/proxiodev/RedisBungee.git
				synced 2025-10-29 23:08:02 +00:00 
			
		
		
		
	Detect inconsistency of players who are online but not registered in Redis.
This commit is contained in:
		
							parent
							
								
									9d392a32e5
								
							
						
					
					
						commit
						75939ef661
					
				| @ -10,12 +10,12 @@ import com.google.common.base.Functions; | |||||||
| import com.google.common.collect.*; | import com.google.common.collect.*; | ||||||
| import com.google.common.io.ByteStreams; | import com.google.common.io.ByteStreams; | ||||||
| import com.google.gson.Gson; | import com.google.gson.Gson; | ||||||
|  | import com.imaginarycode.minecraft.redisbungee.consumerevents.PlayerLoggedInConsumerEvent; | ||||||
| import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; | import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; | ||||||
| import com.imaginarycode.minecraft.redisbungee.util.UUIDTranslator; | import com.imaginarycode.minecraft.redisbungee.util.UUIDTranslator; | ||||||
| 
 | 
 | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
| import lombok.NonNull; | import lombok.NonNull; | ||||||
| import net.md_5.bungee.api.config.ServerInfo; |  | ||||||
| import net.md_5.bungee.api.connection.ProxiedPlayer; | import net.md_5.bungee.api.connection.ProxiedPlayer; | ||||||
| import net.md_5.bungee.api.plugin.Plugin; | import net.md_5.bungee.api.plugin.Plugin; | ||||||
| import net.md_5.bungee.config.Configuration; | import net.md_5.bungee.config.Configuration; | ||||||
| @ -281,8 +281,10 @@ public final class RedisBungee extends Plugin { | |||||||
|                 public void run() { |                 public void run() { | ||||||
|                     Jedis tmpRsc = pool.getResource(); |                     Jedis tmpRsc = pool.getResource(); | ||||||
|                     try { |                     try { | ||||||
|                         Collection<String> players = getLocalPlayersAsUuidStrings(); |                         Set<String> players = new HashSet<>(getLocalPlayersAsUuidStrings()); | ||||||
|                         for (String member : tmpRsc.smembers("proxy:" + serverId + ":usersOnline")) |                         Set<String> redisCollection = tmpRsc.smembers("proxy:" + serverId + ":usersOnline"); | ||||||
|  | 
 | ||||||
|  |                         for (String member : redisCollection) { | ||||||
|                             if (!players.contains(member)) { |                             if (!players.contains(member)) { | ||||||
|                                 // Are they simply on a different proxy? |                                 // Are they simply on a different proxy? | ||||||
|                                 boolean found = false; |                                 boolean found = false; | ||||||
| @ -302,11 +304,21 @@ public final class RedisBungee extends Plugin { | |||||||
|                                     getLogger().warning("Player found in set that was not found locally, but is on another proxy: " + member); |                                     getLogger().warning("Player found in set that was not found locally, but is on another proxy: " + member); | ||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
|  |                         } | ||||||
|  | 
 | ||||||
|  |                         for (String player : players) { | ||||||
|  |                             if (redisCollection.contains(player)) | ||||||
|  |                                 continue; | ||||||
|  | 
 | ||||||
|  |                             // Player not online according to Redis but not BungeeCord. Fire another consumer event. | ||||||
|  |                             getLogger().warning("Player " + player + " is on the proxy but not in Redis."); | ||||||
|  |                             consumer.queue(new PlayerLoggedInConsumerEvent(getProxy().getPlayer(UUID.fromString(player)))); | ||||||
|  |                         } | ||||||
|                     } finally { |                     } finally { | ||||||
|                         pool.returnResource(tmpRsc); |                         pool.returnResource(tmpRsc); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }, 0, 3, TimeUnit.MINUTES); |             }, 0, 1, TimeUnit.MINUTES); | ||||||
|         } |         } | ||||||
|         getProxy().registerChannel("RedisBungee"); |         getProxy().registerChannel("RedisBungee"); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Tux
						Tux