Skip to content

Commit 5eb10e2

Browse files
committed
fix: config issues + 1.21.8 support
1 parent e85af61 commit 5eb10e2

File tree

17 files changed

+73
-93
lines changed

17 files changed

+73
-93
lines changed

pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.refracdevelopment</groupId>
88
<artifactId>SimpleTags</artifactId>
9-
<version>1.6.0</version>
9+
<version>1.7.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SimpleTags</name>
@@ -67,10 +67,6 @@
6767
<pattern>org.bstats</pattern>
6868
<shadedPattern>me.refracdevelopment.libs.bstats</shadedPattern>
6969
</relocation>
70-
<relocation>
71-
<pattern>dev.dejvokep.boostedyaml</pattern>
72-
<shadedPattern>me.refracdevelopment.libs.boostedyaml</shadedPattern>
73-
</relocation>
7470
<relocation>
7571
<pattern>com.tcoded.folialib</pattern>
7672
<shadedPattern>me.refracdevelopment.libs.folialib</shadedPattern>
@@ -127,7 +123,7 @@
127123
<dependency>
128124
<groupId>io.papermc.paper</groupId>
129125
<artifactId>paper-api</artifactId>
130-
<version>1.21-R0.1-SNAPSHOT</version>
126+
<version>1.21.5-R0.1-SNAPSHOT</version>
131127
<scope>provided</scope>
132128
</dependency>
133129
<dependency>
@@ -207,12 +203,6 @@
207203
<version>3.1.0</version>
208204
<scope>compile</scope>
209205
</dependency>
210-
<dependency>
211-
<groupId>dev.dejvokep</groupId>
212-
<artifactId>boosted-yaml</artifactId>
213-
<version>1.3.7</version>
214-
<scope>compile</scope>
215-
</dependency>
216206
<dependency>
217207
<groupId>com.github.LoneDev6</groupId>
218208
<artifactId>api-itemsadder</artifactId>

src/main/java/me/refracdevelopment/simpletags/SimpleTags.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public void onEnable() {
112112
public void onDisable() {
113113
// Plugin shutdown logic
114114
try {
115-
if (Objects.requireNonNull(dataType) == DataType.MYSQL)
115+
if (dataType == DataType.MYSQL)
116116
getMySQLManager().shutdown();
117-
else if (Objects.requireNonNull(dataType) == DataType.SQLITE)
117+
else if (dataType == DataType.SQLITE)
118118
getSqLiteManager().shutdown();
119119

120120
getFoliaLib().getScheduler().cancelAllTasks();
@@ -128,7 +128,7 @@ public void loadFiles() {
128128
tagsFile = new ConfigFile("tags.yml");
129129
menusFile = new ConfigFile("menus.yml");
130130
commandsFile = new ConfigFile("commands/tags.yml");
131-
localeFile = new ConfigFile("locale/" + getConfigFile().getString("locale") + ".yml");
131+
localeFile = new ConfigFile("locale/" + configFile.getString("locale") + ".yml");
132132

133133
// Cache
134134
settings = new Config();
@@ -171,8 +171,8 @@ private void loadManagers() {
171171

172172
private void loadCommands() {
173173
try {
174-
CommandManager.createCoreCommand(this, getCommands().TAGS_COMMAND_NAME,
175-
getLocaleFile().getString("command-tags-description"),
174+
CommandManager.createCoreCommand(this, commands.TAGS_COMMAND_NAME,
175+
localeFile.getString("command-tags-description"),
176176
"/" + getCommands().TAGS_COMMAND_NAME, (commandSender, list) -> {
177177
commandsList = list;
178178

@@ -193,7 +193,7 @@ private void loadCommands() {
193193
RyMessageUtils.sendPluginError("THE MENU MANAGER HAS NOT BEEN CONFIGURED. CALL MENUMANAGER.SETUP()");
194194
}
195195
},
196-
getCommands().TAGS_COMMAND_ALIASES,
196+
commands.TAGS_COMMAND_ALIASES,
197197
CreateCommand.class,
198198
DeleteCommand.class,
199199
EditCommand.class,

src/main/java/me/refracdevelopment/simpletags/commands/DeleteCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void perform(CommandSender commandSender, String[] args) {
8383
.build();
8484

8585
ConfigFile tagsFile = SimpleTags.getInstance().getTagsFile();
86-
tagsFile.remove("tags." + configName);
86+
tagsFile.set("tags." + configName, null);
8787
tagsFile.save();
8888
tagsFile.reload();
8989
SimpleTags.getInstance().getTags().loadConfig();

src/main/java/me/refracdevelopment/simpletags/manager/TagManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class TagManager {
2020
public void loadTags() {
2121
getLoadedTags().clear();
2222

23-
SimpleTags.getInstance().getTags().TAGS.getRoutesAsStrings(false).forEach(tag ->
23+
SimpleTags.getInstance().getTags().TAGS.getKeys(false).forEach(tag ->
2424
addTag(new Tag(tag, SimpleTags.getInstance().getTagsFile().getString("tags." + tag + ".name"),
2525
SimpleTags.getInstance().getTagsFile().getString("tags." + tag + ".prefix"),
2626
SimpleTags.getInstance().getTagsFile().getString("tags." + tag + ".item.material")
Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
package me.refracdevelopment.simpletags.manager.configuration;
22

3-
import dev.dejvokep.boostedyaml.YamlDocument;
4-
import dev.dejvokep.boostedyaml.block.implementation.Section;
5-
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
6-
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
3+
import lombok.Getter;
74
import me.refracdevelopment.simpletags.SimpleTags;
85
import me.refracdevelopment.simpletags.utilities.chat.RyMessageUtils;
96
import org.bukkit.Bukkit;
7+
import org.bukkit.configuration.ConfigurationSection;
8+
import org.bukkit.configuration.file.FileConfiguration;
9+
import org.bukkit.configuration.file.YamlConfiguration;
1010

1111
import java.io.File;
12-
import java.io.IOException;
1312
import java.util.List;
1413

14+
@Getter
1515
public class ConfigFile {
1616

17-
private YamlDocument configFile;
17+
private File configFile;
18+
private FileConfiguration config;
1819

1920
public ConfigFile(String name) {
2021
try {
21-
configFile = YamlDocument.create(new File(SimpleTags.getInstance().getDataFolder(), name),
22-
getClass().getResourceAsStream("/" + name),
23-
GeneralSettings.builder().setUseDefaults(false).build(),
24-
LoaderSettings.builder().setAutoUpdate(false).build()
25-
);
26-
27-
configFile.update();
28-
configFile.save();
29-
} catch (IOException e) {
22+
configFile = new File(SimpleTags.getInstance().getDataFolder(), name);
23+
24+
if (!configFile.exists())
25+
SimpleTags.getInstance().saveResource(name, false);
26+
27+
config = YamlConfiguration.loadConfiguration(configFile);
28+
} catch (Exception e) {
3029
RyMessageUtils.sendConsole(true, "&cFailed to load " + name + " file! The plugin will now shutdown.");
3130
e.printStackTrace();
3231
Bukkit.getPluginManager().disablePlugin(SimpleTags.getInstance());
@@ -35,62 +34,62 @@ public ConfigFile(String name) {
3534

3635
public void save() {
3736
try {
38-
configFile.save();
39-
} catch (IOException e) {
37+
config.save(configFile);
38+
} catch (Exception e) {
4039
e.printStackTrace();
4140
}
4241
}
4342

4443
public void reload() {
4544
try {
46-
configFile.reload();
47-
} catch (IOException e) {
45+
config = YamlConfiguration.loadConfiguration(configFile);
46+
} catch (Exception e) {
4847
e.printStackTrace();
4948
}
5049
}
5150

5251
public int getInt(String path) {
53-
return configFile.getInt(path, 0);
52+
return config.getInt(path, 0);
5453
}
5554

5655
public double getDouble(String path) {
57-
return configFile.getDouble(path, 0.0);
56+
return config.getDouble(path, 0.0);
5857
}
5958

6059
public boolean getBoolean(String path) {
61-
return configFile.getBoolean(path, false);
60+
return config.getBoolean(path, false);
6261
}
6362

6463
public String getString(String path, boolean check) {
65-
return configFile.getString(path, null);
64+
return config.getString(path, null);
6665
}
6766

6867
public String getString(String path) {
69-
if (configFile.contains(path)) {
70-
return configFile.getString(path, "String at path '" + path + "' not found.").replace("|", "\u2503");
68+
if (config.contains(path)) {
69+
return config.getString(path, "String at path '" + path + "' not found.").replace("|", "\u2503");
7170
}
7271

7372
return null;
7473
}
7574

7675
public List<String> getStringList(String path) {
77-
return configFile.getStringList(path);
76+
return config.getStringList(path);
7877
}
7978

8079
public List<String> getStringList(String path, boolean check) {
81-
if (!configFile.contains(path)) return null;
80+
if (!config.contains(path)) return null;
8281
return getStringList(path);
8382
}
8483

85-
public Section getSection(String path) {
86-
return configFile.getSection(path);
84+
public ConfigurationSection getConfigurationSection(String path) {
85+
return config.getConfigurationSection(path);
8786
}
8887

8988
public void set(String path, Object value) {
90-
configFile.set(path, value);
89+
config.set(path, value);
9190
}
9291

9392
public void remove(String path) {
94-
configFile.remove(path);
93+
config.set(path, null);
9594
}
9695
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package me.refracdevelopment.simpletags.manager.configuration.cache;
22

3-
import dev.dejvokep.boostedyaml.block.implementation.Section;
43
import me.refracdevelopment.simpletags.SimpleTags;
4+
import org.bukkit.configuration.ConfigurationSection;
55

66
public class Menus {
77

88
public String TAGS_TITLE;
9-
public Section TAGS_ITEMS;
9+
public ConfigurationSection TAGS_ITEMS;
1010

1111
public Menus() {
1212
loadConfig();
1313
}
1414

1515
public void loadConfig() {
1616
TAGS_TITLE = SimpleTags.getInstance().getMenusFile().getString("tags.title");
17-
TAGS_ITEMS = SimpleTags.getInstance().getMenusFile().getSection("tags.items");
17+
TAGS_ITEMS = SimpleTags.getInstance().getMenusFile().getConfigurationSection("tags.items");
1818
}
1919
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package me.refracdevelopment.simpletags.manager.configuration.cache;
22

3-
import dev.dejvokep.boostedyaml.block.implementation.Section;
43
import me.refracdevelopment.simpletags.SimpleTags;
4+
import org.bukkit.configuration.ConfigurationSection;
55

66
public class Tags {
77

8-
public Section TAGS;
8+
public ConfigurationSection TAGS;
99

1010
public Tags() {
1111
loadConfig();
1212
}
1313

1414
public void loadConfig() {
15-
TAGS = SimpleTags.getInstance().getTagsFile().getSection("tags");
15+
TAGS = SimpleTags.getInstance().getTagsFile().getConfigurationSection("tags");
1616
}
1717
}

src/main/java/me/refracdevelopment/simpletags/menu/TagsItem.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ca.tweetzy.skulls.Skulls;
44
import ca.tweetzy.skulls.api.interfaces.Skull;
55
import com.cryptomorin.xseries.XEnchantment;
6+
import com.cryptomorin.xseries.XItemFlag;
67
import de.tr7zw.nbtapi.NBTItem;
78
import dev.lone.itemsadder.api.CustomStack;
89
import lombok.Getter;
@@ -101,8 +102,11 @@ public ItemStack getItem(Player player, Tag tag) {
101102
lore.forEach(s -> finalItem.addLoreLine(RyMessageUtils.translate(player, s.replace("%tag-prefix%", tag.getTagPrefix()))));
102103
} else {
103104
// Add Glow effect for equipped tag
104-
finalItem.addEnchant(XEnchantment.POWER.getEnchant(), 1);
105-
finalItem.setItemFlags(ItemFlag.HIDE_ENCHANTS);
105+
finalItem.addEnchant(XEnchantment.POWER.get(), 1);
106+
107+
// Remove additional tooltip lore
108+
finalItem.setItemFlags(XItemFlag.HIDE_ENCHANTS.get());
109+
finalItem.setItemFlags(XItemFlag.HIDE_ADDITIONAL_TOOLTIP.get());
106110

107111
List<String> equippedLore = SimpleTags.getInstance().getMenus().TAGS_ITEMS.getStringList("tag-item.equipped-lore");
108112
equippedLore.forEach(s -> finalItem.addLoreLine(RyMessageUtils.translate(player, s.replace("%tag-prefix%", tag.getTagPrefix()))));

src/main/java/me/refracdevelopment/simpletags/menu/TagsMenu.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
import me.refracdevelopment.simpletags.utilities.exceptions.MenuManagerNotSetupException;
1313
import me.refracdevelopment.simpletags.utilities.paginated.PaginatedMenu;
1414
import me.refracdevelopment.simpletags.utilities.paginated.PlayerMenuUtil;
15-
import net.kyori.adventure.text.Component;
1615
import org.bukkit.entity.Player;
1716
import org.bukkit.event.inventory.InventoryClickEvent;
1817
import org.bukkit.inventory.ItemStack;
19-
import org.jetbrains.annotations.Nullable;
2018

2119
import java.util.HashMap;
2220
import java.util.List;
@@ -32,7 +30,6 @@ public List<Tag> dataToItems() {
3230
return SimpleTags.getInstance().getTagManager().getLoadedTags();
3331
}
3432

35-
@Nullable
3633
@Override
3734
public HashMap<Integer, ItemStack> getCustomMenuBorderItems() {
3835
return null;

src/main/java/me/refracdevelopment/simpletags/utilities/DownloadUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public static void downloadAndEnable(JavaPlugin plugin) {
1414
Library lib = Library.builder()
1515
.groupId("org{}mariadb{}jdbc") // "{}" is replaced with ".", useful to avoid unwanted changes made by maven-shade-plugin
1616
.artifactId("mariadb-java-client")
17-
.version("3.4.1")
17+
.version("3.5.6")
1818
.build();
1919
Library lib2 = Library.builder()
2020
.groupId("org{}slf4j") // "{}" is replaced with ".", useful to avoid unwanted changes made by maven-shade-plugin
2121
.artifactId("slf4j-reload4j")
22-
.version("2.0.16")
22+
.version("2.0.17")
2323
.build();
2424
Library lib3 = Library.builder()
2525
.groupId("org{}xerial") // "{}" is replaced with ".", useful to avoid unwanted changes made by maven-shade-plugin
2626
.artifactId("sqlite-jdbc")
27-
.version("3.46.1.0")
27+
.version("3.50.3.0")
2828
.build();
2929
Library lib4 = Library.builder()
3030
.groupId("com{}zaxxer") // "{}" is replaced with ".", useful to avoid unwanted changes made by maven-shade-plugin

0 commit comments

Comments
 (0)