mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 09:59:20 +00:00
2.2.7.2
This commit is contained in:
@@ -111,6 +111,7 @@ public class CropConfig {
|
||||
switch (action) {
|
||||
case "xp" -> actions.add(new ActionXP(config.getInt(key + ".harvest-actions." + action), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
|
||||
case "skill-xp" -> actions.add(new ActionSkillXP(config.getDouble(key + ".harvest-actions." + action), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
|
||||
case "job-xp" -> actions.add(new ActionJobXP(config.getDouble(key + ".harvest-actions." + action), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
|
||||
case "commands" -> actions.add(new ActionCommand(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0]), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
|
||||
case "messages" -> actions.add(new ActionMessage(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0]), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ package net.momirealms.customcrops.config;
|
||||
|
||||
import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customcrops.integrations.CCAntiGrief;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.JobInterface;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import net.momirealms.customcrops.integrations.job.EcoJobsHook;
|
||||
import net.momirealms.customcrops.integrations.job.JobsRebornHook;
|
||||
import net.momirealms.customcrops.integrations.protection.*;
|
||||
import net.momirealms.customcrops.integrations.skill.*;
|
||||
import net.momirealms.customcrops.objects.QualityRatio;
|
||||
@@ -47,7 +50,8 @@ public class MainConfig {
|
||||
public static boolean cropMode;
|
||||
public static List<CCAntiGrief> internalAntiGriefs = new ArrayList<>();
|
||||
public static List<CCAntiGrief> externalAntiGriefs = new ArrayList<>();
|
||||
public static SkillXP skillXP;
|
||||
public static SkillInterface skillInterface;
|
||||
public static JobInterface jobInterface;
|
||||
public static double dryGrowChance;
|
||||
public static boolean limitation;
|
||||
public static int wireAmount;
|
||||
@@ -362,24 +366,28 @@ public class MainConfig {
|
||||
|
||||
if (config.getBoolean("integration.AureliumSkills")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("AureliumSkills") == null) Log.warn("Failed to initialize AureliumSkills!");
|
||||
else skillXP = new AureliumsHook();
|
||||
else skillInterface = new AureliumsHook();
|
||||
}
|
||||
if (config.getBoolean("integration.mcMMO")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("mcMMO") == null) Log.warn("Failed to initialize mcMMO!");
|
||||
else skillXP = new mcMMOHook();
|
||||
else skillInterface = new mcMMOHook();
|
||||
}
|
||||
if (config.getBoolean("integration.MMOCore")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("MMOCore") == null) Log.warn("Failed to initialize MMOCore!");
|
||||
else skillXP = new MMOCoreHook();
|
||||
else skillInterface = new MMOCoreHook();
|
||||
}
|
||||
if (config.getBoolean("integration.EcoSkills")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("EcoSkills") == null) Log.warn("Failed to initialize EcoSkills!");
|
||||
else skillXP = new EcoSkillsHook();
|
||||
else skillInterface = new EcoSkillsHook();
|
||||
}
|
||||
if (config.getBoolean("integration.JobsReborn")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("Jobs") == null) Log.warn("Failed to initialize JobsReborn!");
|
||||
else skillXP = new JobsRebornHook();
|
||||
else jobInterface = new JobsRebornHook();
|
||||
} else if (config.getBoolean("integration.EcoJobs")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("EcoJobs") == null) Log.warn("Failed to initialize EcoJobs!");
|
||||
else jobInterface = new EcoJobsHook();
|
||||
}
|
||||
|
||||
realisticSeasonHook = false;
|
||||
if (config.getBoolean("integration.RealisticSeasons")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("RealisticSeasons") == null) Log.warn("Failed to initialize RealisticSeasons!");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.momirealms.customcrops.integrations;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface JobInterface {
|
||||
void addXp(Player player, double amount);
|
||||
int getLevel(Player player);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customcrops.integrations;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface SkillXP {
|
||||
public interface SkillInterface {
|
||||
|
||||
void addXp(Player player, double amount);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class OraxenHook implements CustomInterface {
|
||||
|
||||
@Override
|
||||
public void removeBlock(Location location) {
|
||||
location.getBlock().setType(Material.AIR);
|
||||
OraxenBlocks.remove(location, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.integrations.job;
|
||||
|
||||
import com.willfp.ecojobs.api.EcoJobsAPI;
|
||||
import com.willfp.ecojobs.jobs.Job;
|
||||
import com.willfp.ecojobs.jobs.Jobs;
|
||||
import net.momirealms.customcrops.integrations.JobInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EcoJobsHook implements JobInterface {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
Job job = EcoJobsAPI.getInstance().getActiveJob(player);
|
||||
if (job == null) return;
|
||||
if (job.getId().equals("farmer")) {
|
||||
EcoJobsAPI.getInstance().giveJobExperience(player, job, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel(Player player) {
|
||||
Job job = Jobs.getByID("farmer");
|
||||
if (job == null) return 0;
|
||||
return EcoJobsAPI.getInstance().getJobLevel(player, job);
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,19 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.integrations.skill;
|
||||
package net.momirealms.customcrops.integrations.job;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.JobInterface;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JobsRebornHook implements SkillXP {
|
||||
public class JobsRebornHook implements JobInterface {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
@@ -20,10 +20,10 @@ package net.momirealms.customcrops.integrations.skill;
|
||||
import com.archyx.aureliumskills.api.AureliumAPI;
|
||||
import com.archyx.aureliumskills.leveler.Leveler;
|
||||
import com.archyx.aureliumskills.skills.Skill;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AureliumsHook implements SkillXP {
|
||||
public class AureliumsHook implements SkillInterface {
|
||||
|
||||
private static final Leveler leveler = AureliumAPI.getPlugin().getLeveler();
|
||||
private static final Skill skill = AureliumAPI.getPlugin().getSkillRegistry().getSkill("farming");
|
||||
|
||||
@@ -19,10 +19,10 @@ package net.momirealms.customcrops.integrations.skill;
|
||||
|
||||
import com.willfp.ecoskills.api.EcoSkillsAPI;
|
||||
import com.willfp.ecoskills.skills.Skills;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EcoSkillsHook implements SkillXP {
|
||||
public class EcoSkillsHook implements SkillInterface {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
|
||||
@@ -20,10 +20,10 @@ package net.momirealms.customcrops.integrations.skill;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MMOCoreHook implements SkillXP {
|
||||
public class MMOCoreHook implements SkillInterface {
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
Profession profession = MMOCore.plugin.professionManager.get("farming");
|
||||
|
||||
@@ -19,10 +19,10 @@ package net.momirealms.customcrops.integrations.skill;
|
||||
|
||||
import com.gmail.nossr50.api.ExperienceAPI;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
import net.momirealms.customcrops.integrations.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class mcMMOHook implements SkillXP {
|
||||
public class mcMMOHook implements SkillInterface {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.momirealms.customcrops.api.event.CropHarvestEvent;
|
||||
import net.momirealms.customcrops.api.event.CrowAttackEvent;
|
||||
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||
import net.momirealms.customcrops.config.*;
|
||||
import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.ItemsAdderFrameHandler;
|
||||
@@ -346,8 +345,8 @@ public class CropManager extends Function {
|
||||
qualityRatio = qualityCrop.getQualityRatio();
|
||||
}
|
||||
}
|
||||
if (MainConfig.enableSkillBonus && MainConfig.skillXP != null) {
|
||||
double bonus_chance = MainConfig.skillXP.getLevel(player) * MainConfig.bonusPerLevel;
|
||||
if (MainConfig.enableSkillBonus && MainConfig.skillInterface != null) {
|
||||
double bonus_chance = MainConfig.skillInterface.getLevel(player) * MainConfig.bonusPerLevel;
|
||||
amount *= (bonus_chance + 1);
|
||||
}
|
||||
dropQualityLoots(qualityLoot, amount, location.getBlock().getLocation(), qualityRatio);
|
||||
@@ -368,8 +367,8 @@ public class CropManager extends Function {
|
||||
for (OtherLoot otherLoot : otherLoots) {
|
||||
if (Math.random() < otherLoot.getChance()) {
|
||||
int random = ThreadLocalRandom.current().nextInt(otherLoot.getMin(), otherLoot.getMax() + 1);
|
||||
if (MainConfig.enableSkillBonus && MainConfig.skillXP != null) {
|
||||
double bonus_chance = MainConfig.skillXP.getLevel(player) * MainConfig.bonusPerLevel;
|
||||
if (MainConfig.enableSkillBonus && MainConfig.skillInterface != null) {
|
||||
double bonus_chance = MainConfig.skillInterface.getLevel(player) * MainConfig.bonusPerLevel;
|
||||
random *= (bonus_chance + 1);
|
||||
}
|
||||
ItemStack drop = getLoot(otherLoot.getItemID());
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.momirealms.customcrops.objects.actions;
|
||||
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActionJobXP implements ActionInterface {
|
||||
|
||||
private final double xp;
|
||||
private final double chance;
|
||||
|
||||
public ActionJobXP(double xp, double chance) {
|
||||
this.xp = xp;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performOn(Player player) {
|
||||
if (MainConfig.jobInterface != null) {
|
||||
MainConfig.jobInterface.addXp(player, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class ActionSkillXP implements ActionInterface {
|
||||
|
||||
@Override
|
||||
public void performOn(Player player) {
|
||||
if (MainConfig.skillXP != null) {
|
||||
MainConfig.skillXP.addXp(player, xp);
|
||||
if (MainConfig.skillInterface != null) {
|
||||
MainConfig.skillInterface.addXp(player, xp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Don't change
|
||||
# 请不要修改
|
||||
config-version: '23'
|
||||
config-version: '24'
|
||||
metrics: true
|
||||
# lang: english / spanish / chinese
|
||||
lang: english
|
||||
@@ -25,7 +25,10 @@ integration:
|
||||
mcMMO: false
|
||||
MMOCore: false
|
||||
EcoSkills: false
|
||||
# Job xp
|
||||
# Don't forget to config job-xp for each crop if you enabled job xp integration
|
||||
JobsReborn: false
|
||||
EcoJobs: false
|
||||
# Season
|
||||
# Synchronize season with other plugins
|
||||
RealisticSeasons: false
|
||||
|
||||
@@ -44,6 +44,7 @@ tomato:
|
||||
- 'say {player} harvested a tomato! lol'
|
||||
xp: 10
|
||||
# skill-xp: 100 (You need to enable any skill plugin compatibility in config.yml)
|
||||
# job-xp: 10 (You need to enable any job plugin compatibility in config.yml)
|
||||
|
||||
# When you harvest with a single right click, the crop would return to a certain stage. If not set, crops would be removed when harvesting
|
||||
return: customcrops:tomato_stage_1
|
||||
|
||||
@@ -27,6 +27,7 @@ softdepend:
|
||||
- GriefPrevention
|
||||
- CrashClaim
|
||||
- BentoBox
|
||||
- EcoJobs
|
||||
commands:
|
||||
customcrops:
|
||||
usage: /customcrops <args>
|
||||
|
||||
Reference in New Issue
Block a user