9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-26 10:29:10 +00:00
This commit is contained in:
XiaoMoMi
2023-12-23 13:26:49 +08:00
parent ee2b2c8e49
commit 73b090ec40
7 changed files with 57 additions and 12 deletions

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.api.object.action;
import net.momirealms.customcrops.api.object.ItemMode;
import net.momirealms.customcrops.api.object.world.SimpleLocation;
import net.momirealms.customcrops.util.AdventureUtils;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
public record ActionBarImpl(String message, double chance) implements Action {
@Override
public void doOn(@Nullable Player player, @Nullable SimpleLocation cropLoc, ItemMode itemMode) {
if (player == null || Math.random() > chance) return;
AdventureUtils.playerActionbar(player,
message.replace("{player}", player.getName())
.replace("{world}", player.getWorld().getName())
.replace("{x}", cropLoc == null ? "" : String.valueOf(cropLoc.getX()))
.replace("{y}", cropLoc == null ? "" : String.valueOf(cropLoc.getY()))
.replace("{z}", cropLoc == null ? "" : String.valueOf(cropLoc.getZ()))
);
}
}

View File

@@ -18,6 +18,7 @@
package net.momirealms.customcrops.integration.skill;
import com.willfp.ecoskills.api.EcoSkillsAPI;
import com.willfp.ecoskills.skills.Skill;
import com.willfp.ecoskills.skills.Skills;
import net.momirealms.customcrops.integration.SkillInterface;
import org.bukkit.entity.Player;
@@ -26,7 +27,7 @@ public class EcoSkillsImpl implements SkillInterface {
@Override
public void addXp(Player player, double amount) {
EcoSkillsAPI.giveSkillXP(player, Skills.INSTANCE.getByID("farming"), amount);
EcoSkillsAPI.gainSkillXP(player, Skills.INSTANCE.getByID("farming"), amount);
}
@Override

View File

@@ -252,6 +252,10 @@ public class ConfigUtils {
actionSec.getStringList("value").toArray(new String[0]),
actionSec.getDouble("chance", 1))
);
case "actionbar" -> actions.add(new ActionBarImpl(
actionSec.getString("value"),
actionSec.getDouble("chance", 1))
);
case "command" -> actions.add(new CommandActionImpl(
actionSec.getStringList("value").toArray(new String[0]),
actionSec.getDouble("chance", 1))