Skip to content

Commit 9ceecf5

Browse files
committed
Add DataPack Report to track active DataPacks
1 parent 20044a7 commit 9ceecf5

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

config/checkstyle/import-control.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<allow pkg="org.bstats.charts"/>
3131
<allow pkg="io.papermc.lib"/>
3232
<allow pkg="com.destroystokyo.paper"/>
33+
<allow pkg="io.papermc.paper"/>
3334
<allow pkg="co.aikar.timings.lib" />
3435
<allow pkg="org.spigotmc" />
3536
</subpackage>

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldGuardPlatform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.sk89q.worldguard.util.profile.resolver.PaperPlayerService;
3535
import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent;
3636
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
37+
import com.sk89q.worldguard.bukkit.util.report.DatapackReport;
3738
import com.sk89q.worldguard.bukkit.util.report.PerformanceReport;
3839
import com.sk89q.worldguard.bukkit.util.report.PluginReport;
3940
import com.sk89q.worldguard.bukkit.util.report.SchedulerReport;
@@ -239,6 +240,7 @@ public void addPlatformReports(ReportList report) {
239240
report.add(new ServicesReport());
240241
report.add(new WorldReport());
241242
report.add(new PerformanceReport());
243+
if (PaperLib.isPaper()) report.add(new DatapackReport());
242244
}
243245

244246
@Override
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* WorldGuard, a suite of tools for Minecraft
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldGuard team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published by the
8+
* Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14+
* for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldguard.bukkit.util.report;
21+
22+
import com.sk89q.worldedit.util.report.DataReport;
23+
import io.papermc.paper.datapack.Datapack;
24+
import org.bukkit.Bukkit;
25+
26+
import java.util.Collection;
27+
28+
/**
29+
* A report for current datapacks with some information. Only available on Paper
30+
*/
31+
public class DatapackReport extends DataReport {
32+
public DatapackReport() {
33+
super("DataPacks");
34+
35+
Collection<Datapack> packs = Bukkit.getDatapackManager().getPacks();
36+
37+
append("Datapack Count", packs.size());
38+
append("Datapack Enabled Count", Bukkit.getDatapackManager().getEnabledPacks().size());
39+
40+
for (Datapack pack : packs) {
41+
DataReport report = new DataReport("DataPack: " + pack.getName());
42+
report.append("Enabled?", pack.isEnabled());
43+
report.append("Name", pack.getName());
44+
report.append("Compatibility", pack.getCompatibility().name());
45+
append(report.getTitle(), report);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)