我只需要最后一 block 拼图来完成我的插件。目前,我遇到了如何为登录到服务器的所有 alt 帐户设置 MySQL 表的问题。我知道我要么需要一个超高的设置数字并将 uuid 添加到下一个空单元格,要么只为每个 uuid 添加一个新列,但我只需要知道将所有 UUID 添加到的最有效方法单个 IP(主键)。看起来我现在很喜欢:
IP |
Row #1
Row #2
等等
最佳答案
不要使用 IP 作为主键。事实上,主键是唯一的,并且多次出现具有不同 UUID 的 IP 地址,这使得很难完成您所需要的任务。
尝试这样的事情:
id (PK)| ip_address | uuid | date -------------------------------------- 1 | 1.2.3.4 | as-df-gh | 12345 2 | 1.2.3.4 | df-as-gh | 12346 3 | 2.3.4.5 | as-gh-df | 12347 4 | 3.4.5.6 | as-df-gh | 12348
Whenever someone logs in you can then add another row (or if you don't need the login date column, first check if there's already one with the IP / UUID pair and skip it).
Now you can select all UUIDs from a certain IP address:
SELECT uuid FROM your_table WHERE ip_address = '1.2.3.4'
结果
uuid -------- as-df-gh df-as-gh
Or the other way around:
SELECT ip_address FROM your_table WHERE uuid = 'as-df-gh'
结果
ip_address ---------- 1.2.3.4 3.4.5.6
关于java - 如何获取从单个 IP 登录的所有 UUID(MySQL 数据库 [Minecraft]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51978511/