mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 10:29:10 +00:00
1.20.4
This commit is contained in:
@@ -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()))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user