9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 09: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;
}

View File

@@ -130,6 +130,10 @@ other-settings:
# Disable this would improve performance
legacy-color-code-support: true
# Requires PlaceholderAPI to work
placeholder-register:
'{skill-level}': '%levelplugin_farming%'
# Thread pool settings
thread-pool-settings:
corePoolSize: 10

View File

@@ -158,6 +158,7 @@ tomato:
# But you can set some special crops' loots here
99:
model: {0}tomato_stage_golden
# You can set interact/break requirements for each stage
requirements:
break:
requirement_1:

View File

@@ -31,7 +31,7 @@ sprinkler_1:
# The amount of water to add
amount: 3
method_2:
item: WATER
item: POTION
return: GLASS_BOTTLE
amount: 1
# Water bar image settings
@@ -119,7 +119,7 @@ sprinkler_2:
return: BUCKET
amount: 3
method_2:
item: WATER
item: POTION
return: GLASS_BOTTLE
amount: 1
water-bar:
@@ -207,7 +207,7 @@ sprinkler_3:
return: BUCKET
amount: 3
method_2:
item: WATER
item: POTION
return: GLASS_BOTTLE
amount: 1
water-bar: