9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 10:59:20 +00:00

custom placeholder register

This commit is contained in:
XiaoMoMi
2024-03-09 08:06:14 +08:00
parent d646b23d70
commit 8d37290cff
6 changed files with 29 additions and 3 deletions

View File

@@ -4,7 +4,10 @@ import net.momirealms.customcrops.api.CustomCropsPlugin;
import net.momirealms.customcrops.api.manager.PlaceholderManager;
import net.momirealms.customcrops.compatibility.papi.CCPapi;
import net.momirealms.customcrops.compatibility.papi.ParseUtils;
import net.momirealms.customcrops.utils.ConfigUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
@@ -36,6 +39,7 @@ public class PlaceholderManagerImpl extends PlaceholderManager {
if (ccPapi != null) {
ccPapi.register();
}
this.loadCustomPlaceholders();
}
@Override
@@ -43,6 +47,17 @@ public class PlaceholderManagerImpl extends PlaceholderManager {
if (ccPapi != null) {
ccPapi.unregister();
}
this.customPlaceholderMap.clear();
}
public void loadCustomPlaceholders() {
YamlConfiguration config = ConfigUtils.getConfig("config.yml");
ConfigurationSection section = config.getConfigurationSection("other-settings.placeholder-register");
if (section != null) {
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
this.customPlaceholderMap.put(entry.getKey(), (String) entry.getValue());
}
}
}
@Override

View File

@@ -311,6 +311,12 @@ public class ItemManagerImpl implements ItemManager {
LogUtils.warn("Item " + sprinkler.get3DItemID() + " has more than one sprinkler config.");
return false;
}
if (sprinkler.get3DItemWithWater() != null) {
if (this.threeDItem2SprinklerMap.put(sprinkler.get3DItemWithWater(), sprinkler) != null) {
LogUtils.warn("Item " + sprinkler.get3DItemWithWater() + " has more than one sprinkler config.");
return false;
}
}
return true;
}