-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Blue-Millennium/47-unoinban-module-fix
47 unoinban module fix
- Loading branch information
Showing
18 changed files
with
384 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
group = 'Blue-Millennium' | ||
version = '1.0.0' | ||
version = '1.0.1' | ||
|
||
idea { | ||
module { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
src/main/java/fun/blue_millennium/data/UnionBan/BanListChecker.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/java/fun/blue_millennium/data/UnionBan/LocalBanListImport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fun.blue_millennium.data.UnionBan; | ||
|
||
import fun.blue_millennium.config.Config; | ||
import fun.blue_millennium.data.UnionBan.LocalProcess.UnionBanDataGet; | ||
import org.bukkit.BanEntry; | ||
import org.bukkit.BanList; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ban.ProfileBanList; | ||
import org.bukkit.profile.PlayerProfile; | ||
|
||
import static fun.blue_millennium.Main.LOGGER; | ||
import static fun.blue_millennium.data.UnionBan.OnlineProcess.OnlinePush.reportRemoteBanList; | ||
|
||
public class LocalBanListImport { | ||
public static void importBanList() { | ||
try { | ||
ProfileBanList banlist = Bukkit.getBanList(BanList.Type.PROFILE); | ||
UnionBanDataGet dg = new UnionBanDataGet(); | ||
for (BanEntry<PlayerProfile> banEntry : banlist.getEntries()) { | ||
UnionBanData data = dg.getUnionBanData(banEntry.getBanTarget().getUniqueId()); | ||
if (data == null) { | ||
data = new UnionBanData(); | ||
data.playerName = banEntry.getBanTarget().getName(); | ||
data.playerUuid = banEntry.getBanTarget().getUniqueId(); | ||
data.time = banEntry.getExpiration().getTime(); | ||
data.reason = banEntry.getReason(); | ||
data.sourceServer = Config.ServerName; | ||
data.localTag = true; | ||
if (reportRemoteBanList(data)) { | ||
data.reportTag = true; | ||
} | ||
dg.setPlayerData(data.playerUuid, data); | ||
} | ||
} | ||
} catch (Exception e) { | ||
LOGGER.warning("导入本地封禁列表失败: " + e.getMessage()); | ||
} | ||
} | ||
} |
105 changes: 0 additions & 105 deletions
105
src/main/java/fun/blue_millennium/data/UnionBan/LocalCache.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/main/java/fun/blue_millennium/data/UnionBan/LocalProcess/BanDataProcess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fun.blue_millennium.data.UnionBan.LocalProcess; | ||
|
||
import fun.blue_millennium.data.UnionBan.UnionBanData; | ||
import org.bukkit.Bukkit; | ||
|
||
import java.util.List; | ||
|
||
import static fun.blue_millennium.commands.execute.vanilla.Ban.BanMessage; | ||
|
||
public class BanDataProcess { | ||
public static void LocalBanDataProcess() { | ||
UnionBanDataGet dg = new UnionBanDataGet(); | ||
List<UnionBanData> dataList = dg.returnAllData(); | ||
for (UnionBanData data : dataList) { | ||
if (!data.localTag) { | ||
String message = ""; | ||
if (data.reason.equals("Pardon")) { | ||
if (Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:pardon " + data.playerUuid)) { | ||
message = "玩家 " + data.playerName + " 已被服务器 " + data.sourceServer + "解除封禁"; | ||
} | ||
} else { | ||
if (Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:ban " + data.playerUuid + " " + data.reason)) { | ||
message = "玩家 " + data.playerName + " 已被服务器 " + data.sourceServer + "以" + data.reason + "的理由封禁"; | ||
} | ||
} | ||
data.reportTag = true; | ||
dg.setPlayerData(data.playerUuid, data); | ||
BanMessage(message); | ||
} | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/fun/blue_millennium/data/UnionBan/LocalProcess/OnlineDataMerge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fun.blue_millennium.data.UnionBan.LocalProcess; | ||
|
||
import fun.blue_millennium.data.UnionBan.OnlineProcess.OnlinePush; | ||
import fun.blue_millennium.data.UnionBan.UnionBanData; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static fun.blue_millennium.commands.execute.vanilla.Ban.BanMessage; | ||
import static fun.blue_millennium.data.UnionBan.LocalProcess.BanDataProcess.LocalBanDataProcess; | ||
import static fun.blue_millennium.data.UnionBan.OnlineProcess.OnlineGet.loadRemoteBanList; | ||
|
||
public class OnlineDataMerge { | ||
public static void mergeAndReportData() { | ||
UnionBanDataGet dgl = new UnionBanDataGet(); | ||
List<UnionBanData> remote = loadRemoteBanList(); | ||
List<String> namelist1 = new ArrayList<>(List.of()); | ||
List<String> namelist2 = new ArrayList<>(List.of()); | ||
for (UnionBanData banData : remote) { | ||
UnionBanData data = dgl.getUnionBanData(banData.playerUuid); | ||
if (data == null) { | ||
dgl.setPlayerData(banData.playerUuid, banData); | ||
} else { | ||
if (data.time < banData.time) { | ||
dgl.setPlayerData(banData.playerUuid, banData); | ||
namelist1.add(banData.playerName); | ||
} else if (data.time > banData.time) { | ||
if (OnlinePush.reportRemoteBanList(banData)) { | ||
namelist2.add(banData.playerName); | ||
} | ||
} | ||
} | ||
} | ||
if (!namelist1.isEmpty()) { | ||
StringBuilder msg = new StringBuilder().append(" "); | ||
for (String name : namelist2) { | ||
msg.append(name).append(" "); | ||
} | ||
LocalBanDataProcess(); | ||
BanMessage(msg + "的封禁数据已被同步至本地服务器"); | ||
} | ||
if (!namelist2.isEmpty()) { | ||
StringBuilder msg = new StringBuilder().append(" "); | ||
for (String name : namelist2) { | ||
msg.append(name).append(" "); | ||
} | ||
BanMessage(msg + "的封禁数据已被上报至UnionBan服务器"); | ||
} | ||
} | ||
} |
Oops, something went wrong.