Skip to content

Commit a7a9873

Browse files
committed
feat(list data): Added default lists file for default lists, added updater to remove default listst from lists_1_21.nbt on startup.
fix(ItemTemplate): added tooltip display component to buildItem() to hide extra tooltip info like bundle contents.
1 parent 4c26051 commit a7a9873

File tree

8 files changed

+83
-26
lines changed

8 files changed

+83
-26
lines changed

BingoReloaded/src/main/java/io/github/steaf23/bingoreloaded/BingoReloaded.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import io.github.steaf23.bingoreloaded.data.BingoMessage;
99
import io.github.steaf23.bingoreloaded.data.BingoStatData;
1010
import io.github.steaf23.bingoreloaded.data.BingoStatType;
11-
import io.github.steaf23.bingoreloaded.data.DataUpdaterV1;
11+
import io.github.steaf23.bingoreloaded.data.DataUpdaterV3_2_0;
1212
import io.github.steaf23.bingoreloaded.data.TeamData;
1313
import io.github.steaf23.bingoreloaded.data.TexturedMenuData;
1414
import io.github.steaf23.bingoreloaded.data.config.BingoConfigurationData;
@@ -101,9 +101,9 @@ public void onEnable() {
101101
saveResource("bingoreloaded.zip", true);
102102
saveResource("bingoreloaded_lite.zip", true);
103103

104-
// Data file updaters
104+
// Data file updater (backwards compatibility)
105105
{
106-
DataUpdaterV1 updater = new DataUpdaterV1(this);
106+
DataUpdaterV3_2_0 updater = new DataUpdaterV3_2_0(this);
107107
updater.update();
108108
}
109109

@@ -123,6 +123,7 @@ public void onEnable() {
123123
addDataAccessor(new TagDataAccessor(this, "data/cards", false));
124124
addDataAccessor(new TagDataAccessor(this, "data/textures", false));
125125
addDataAccessor(new TagDataAccessor(this, "data/kits", false));
126+
addDataAccessor(new TagDataAccessor(this, "data/default_lists", true));
126127
addDataAccessor(new TagDataAccessor(this, "data/" + getDefaultTasksVersion(), false));
127128
addDataAccessor(new TagDataAccessor(this, "data/presets", false));
128129
addDataAccessor(new TagDataAccessor(this, "data/player_stats", false));
@@ -296,6 +297,7 @@ public void reloadData() {
296297
getDataAccessor("data/cards").load();
297298
getDataAccessor("data/textures").load();
298299
getDataAccessor("data/kits").load();
300+
getDataAccessor("data/default_lists").load();
299301
getDataAccessor("data/" + getDefaultTasksVersion()).load();
300302
getDataAccessor("data/presets").load();
301303
getDataAccessor("data/player_stats").load();

BingoReloaded/src/main/java/io/github/steaf23/bingoreloaded/data/DataUpdaterV1.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
public class DataUpdaterV1
5757
{
58-
private final BingoReloaded plugin;
58+
protected final BingoReloaded plugin;
5959

6060
public DataUpdaterV1(BingoReloaded plugin) {
6161
this.plugin = plugin;
@@ -249,7 +249,7 @@ public void update() {
249249
updatePlaceholders();
250250
}
251251

252-
private void updateConfig() {
252+
protected void updateConfig() {
253253
File configFile = new File(plugin.getDataFolder(), "config.yml");
254254
if (!configFile.exists()) {
255255
return;
@@ -295,7 +295,7 @@ private void updateConfig() {
295295
ConsoleMessenger.log(Component.text("Found outdated config.yml file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
296296
}
297297

298-
private void updatePresets() {
298+
protected void updatePresets() {
299299
if (!new File(plugin.getDataFolder(), "data/presets.yml").exists() || new File(plugin.getDataFolder(), "data/presets.nbt").exists()) {
300300
return;
301301
}
@@ -337,7 +337,7 @@ private void updatePresets() {
337337
ConsoleMessenger.log(Component.text("Found outdated settings preset configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
338338
}
339339

340-
private void updatePlayers() {
340+
protected void updatePlayers() {
341341
if (!new File(plugin.getDataFolder(), "data/players.yml").exists() || new File(plugin.getDataFolder(), "data/players.nbt").exists()) {
342342
return;
343343
}
@@ -376,7 +376,7 @@ private void updatePlayers() {
376376
ConsoleMessenger.log(Component.text("Found outdated stored-players configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
377377
}
378378

379-
private void updateStats() {
379+
protected void updateStats() {
380380
if (!new File(plugin.getDataFolder(), "data/player_stats.yml").exists() || new File(plugin.getDataFolder(), "data/player_stats.nbt").exists()) {
381381
return;
382382
}
@@ -393,7 +393,7 @@ private void updateStats() {
393393
ConsoleMessenger.log(Component.text("Found outdated player stats configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
394394
}
395395

396-
private void updateLists(String filename) {
396+
protected void updateLists(String filename) {
397397
if (!new File(plugin.getDataFolder(), filename + ".yml").exists() || new File(plugin.getDataFolder(), filename + ".nbt").exists()) {
398398
return;
399399
}
@@ -444,7 +444,7 @@ private void updateLists(String filename) {
444444
ConsoleMessenger.log(Component.text("Found outdated list configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
445445
}
446446

447-
private void updateCards() {
447+
protected void updateCards() {
448448
if (!new File(plugin.getDataFolder(), "data/cards.yml").exists() || new File(plugin.getDataFolder(), "data/cards.nbt").exists()) {
449449
return;
450450
}
@@ -465,7 +465,7 @@ private void updateCards() {
465465
ConsoleMessenger.log(Component.text("Found outdated card configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
466466
}
467467

468-
private void updateKits() {
468+
protected void updateKits() {
469469
if (!new File(plugin.getDataFolder(), "data/kits.yml").exists() || new File(plugin.getDataFolder(), "data/kits.nbt").exists()) {
470470
return;
471471
}
@@ -498,7 +498,7 @@ private void updateKits() {
498498
ConsoleMessenger.log(Component.text("Found outdated kit configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
499499
}
500500

501-
private void updateTeams() {
501+
protected void updateTeams() {
502502
if (!new File(plugin.getDataFolder(), "data/teams.yml").exists() || new File(plugin.getDataFolder(), "data/teams.nbt").exists()) {
503503
return;
504504
}
@@ -525,7 +525,7 @@ private void updateTeams() {
525525
ConsoleMessenger.log(Component.text("Found outdated teams configuration file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
526526
}
527527

528-
private void updateTextures() {
528+
protected void updateTextures() {
529529
YamlDataAccessor yamlData = new YamlDataAccessor(plugin, "data/textures", false);
530530
TagDataAccessor tagData = new TagDataAccessor(plugin, "data/textures", false);
531531

@@ -543,7 +543,7 @@ private void updateTextures() {
543543
tagData.saveChanges();
544544
}
545545

546-
private void updateScoreboards() {
546+
protected void updateScoreboards() {
547547
YamlDataAccessor yamlData = new YamlDataAccessor(plugin, "scoreboards", false);
548548
yamlData.load();
549549

@@ -561,7 +561,7 @@ private void updateScoreboards() {
561561
ConsoleMessenger.log(Component.text("Found outdated scoreboards file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
562562
}
563563

564-
private @NotNull String updateConfigString(@NotNull String input) {
564+
protected @NotNull String updateConfigString(@NotNull String input) {
565565
input = input.replace("&", "§");
566566
Component legacyComponent = LegacyComponentSerializer.legacySection().deserialize(input);
567567
String legacyMini = MiniMessage.miniMessage().serialize(legacyComponent);
@@ -574,7 +574,7 @@ private void updateScoreboards() {
574574
return legacyMini;
575575
}
576576

577-
private void updateBoard(String boardName, YamlDataAccessor data) {
577+
protected void updateBoard(String boardName, YamlDataAccessor data) {
578578
String title = data.getString(boardName + ".title", "");
579579
List<String> sideBar = data.getList(boardName + ".sidebar", TagDataType.STRING);
580580

@@ -584,7 +584,7 @@ private void updateBoard(String boardName, YamlDataAccessor data) {
584584
data.setList(boardName + ".sidebar", TagDataType.STRING, sideBar);
585585
}
586586

587-
private void updatePlaceholders() {
587+
protected void updatePlaceholders() {
588588
YamlDataAccessor yamlData = new YamlDataAccessor(plugin, "placeholders", false);
589589
yamlData.load();
590590

@@ -619,7 +619,7 @@ private void updatePlaceholders() {
619619
ConsoleMessenger.log(Component.text("Found outdated placeholders file and updated it to new format (V2 -> V3)").color(NamedTextColor.GOLD));
620620
}
621621

622-
private boolean isNewerOrEqual(@Nullable String version, String pluginVersion) {
622+
protected boolean isNewerOrEqual(@Nullable String version, String pluginVersion) {
623623
if (pluginVersion.isEmpty() || version == null) {
624624
return false;
625625
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.steaf23.bingoreloaded.data;
2+
3+
import io.github.steaf23.bingoreloaded.BingoReloaded;
4+
import io.github.steaf23.bingoreloaded.data.core.tag.TagDataAccessor;
5+
6+
public class DataUpdaterV3_2_0 extends DataUpdaterV1 {
7+
8+
public DataUpdaterV3_2_0(BingoReloaded plugin) {
9+
super(plugin);
10+
}
11+
12+
@Override
13+
protected void updateLists(String filename) {
14+
super.updateLists(filename);
15+
16+
TagDataAccessor tagData = new TagDataAccessor(plugin, filename, false);
17+
tagData.load();
18+
tagData.erase("default_items");
19+
tagData.erase("default_advancements");
20+
tagData.erase("default_statistics");
21+
tagData.erase("default_items_hardcore");
22+
tagData.erase("default_advancements_hardcore");
23+
tagData.erase("default_statistics_hardcore");
24+
tagData.saveChanges();
25+
}
26+
}

BingoReloaded/src/main/java/io/github/steaf23/bingoreloaded/data/TaskListData.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import io.github.steaf23.bingoreloaded.BingoReloaded;
44
import io.github.steaf23.bingoreloaded.data.core.DataAccessor;
5+
import io.github.steaf23.bingoreloaded.data.core.DataStorage;
56
import io.github.steaf23.bingoreloaded.tasks.data.TaskData;
67
import io.github.steaf23.bingoreloaded.tasks.data.AdvancementTask;
78
import io.github.steaf23.bingoreloaded.tasks.data.StatisticTask;
89
import io.github.steaf23.playerdisplay.util.ConsoleMessenger;
910

1011
import java.util.ArrayList;
12+
import java.util.Collection;
1113
import java.util.HashSet;
1214
import java.util.List;
1315
import java.util.Set;
@@ -28,22 +30,33 @@ public class TaskListData
2830
"default_statistics_hardcore"
2931
);
3032

33+
private final DataAccessor defaultData = BingoReloaded.getDataAccessor("data/default_lists");
3134
private final DataAccessor data = BingoReloaded.getDataAccessor("data/" + BingoReloaded.getDefaultTasksVersion());
3235

3336
public Set<TaskData> getTasks(String listName, boolean withStatistics, boolean withAdvancements)
3437
{
35-
if (!data.contains(listName + ".tasks"))
38+
Collection<TaskData> tasks;
39+
if (defaultData.contains(listName + ".tasks")) {
40+
tasks = defaultData.getSerializableList(listName + ".tasks", TaskData.class);
41+
} else if (data.contains(listName + ".tasks")) {
42+
tasks = data.getSerializableList(listName + ".tasks", TaskData.class);
43+
} else {
3644
return new HashSet<>();
45+
}
3746

38-
return data.getSerializableList(listName + ".tasks", TaskData.class).stream().filter((i ->
47+
return tasks.stream().filter((i ->
3948
(i != null) && // don't parse empty (invalid) tasks
4049
!(i instanceof StatisticTask && !withStatistics) &&
4150
!(i instanceof AdvancementTask && !withAdvancements))).collect(Collectors.toSet());
4251
}
4352

4453
public int getTaskCount(String listName)
4554
{
46-
return data.getInt(listName + ".size", 0);
55+
if (DEFAULT_LIST_NAMES.contains(listName)) {
56+
return defaultData.getInt(listName + ".size", 0);
57+
} else {
58+
return data.getInt(listName + ".size", 0);
59+
}
4760
}
4861

4962
public void saveTasksFromGroup(String listName, List<TaskData> group, List<TaskData> tasksToSave)
@@ -90,10 +103,16 @@ public boolean removeList(String listName)
90103

91104
public boolean duplicateList(String listName)
92105
{
93-
if (!data.contains(listName))
106+
if (!data.contains(listName) && !defaultData.contains(listName))
94107
return false;
95108

96-
var list = data.getStorage(listName);
109+
DataStorage list;
110+
if (DEFAULT_LIST_NAMES.contains(listName)) {
111+
list = defaultData.getStorage(listName);
112+
} else {
113+
list = data.getStorage(listName);
114+
}
115+
97116
String newName = listName + "_copy";
98117
if (data.contains(newName)) // Card with newName already exists
99118
return false;
@@ -124,6 +143,8 @@ public boolean renameList(String oldName, String newName)
124143
*/
125144
public Set<String> getListNames()
126145
{
127-
return data.getKeys();
146+
var names = new HashSet<>(defaultData.getKeys());
147+
names.addAll(data.getKeys());
148+
return names;
128149
}
129150
}
2.71 KB
Binary file not shown.
-2.76 KB
Binary file not shown.

BingoReloaded/src/main/resources/plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: BingoReloaded # the plugins name as it should appear in the plugin list /pl
2-
version: 3.1.0 # the plugin's version
2+
version: 3.2.0 # the plugin's version
33
author: Steven
44
main: io.github.steaf23.bingoreloaded.BingoReloaded
5-
api-version: 1.21.4
5+
api-version: 1.21.7
66

77
softdepend: [PlaceholderAPI]
88
depend: [packetevents]

PlayerDisplay/src/main/java/io/github/steaf23/playerdisplay/inventory/item/ItemTemplate.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import io.github.steaf23.playerdisplay.PlayerDisplay;
55
import io.github.steaf23.playerdisplay.inventory.item.action.MenuAction;
66
import io.github.steaf23.playerdisplay.util.PDCHelper;
7+
import io.papermc.paper.datacomponent.DataComponentType;
8+
import io.papermc.paper.datacomponent.DataComponentTypes;
9+
import io.papermc.paper.datacomponent.item.TooltipDisplay;
710
import net.kyori.adventure.text.Component;
811
import net.kyori.adventure.text.format.NamedTextColor;
912
import net.kyori.adventure.text.format.TextColor;
@@ -437,6 +440,11 @@ private ItemStack buildItem(boolean hideAttributes, boolean textured) {
437440
stackMeta.addEnchant(enchantment, enchantments.get(enchantment), true);
438441
}
439442
stack.setItemMeta(stackMeta);
443+
stack.setData(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplay.tooltipDisplay().addHiddenComponents(
444+
DataComponentTypes.TRIM,
445+
DataComponentTypes.BUNDLE_CONTENTS,
446+
DataComponentTypes.ENCHANTMENTS,
447+
DataComponentTypes.STORED_ENCHANTMENTS).build());
440448

441449
return stack;
442450
}

0 commit comments

Comments
 (0)