mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 08:29:35 +00:00
2.0-r9
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '2.0-r8-hotfix'
|
version = '2.0-r9'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -23,15 +23,13 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class CrowAttackEvent extends Event implements Cancellable {
|
public class CrowAttackEvent extends Event {
|
||||||
|
|
||||||
private final Location location;
|
private final Location location;
|
||||||
private boolean cancelled;
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public CrowAttackEvent(Location location) {
|
public CrowAttackEvent(Location location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.cancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,16 +37,6 @@ public class CrowAttackEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
cancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ public class MainConfig {
|
|||||||
public static boolean preventPlantVanilla;
|
public static boolean preventPlantVanilla;
|
||||||
public static Material[] preventPlantVanillaArray;
|
public static Material[] preventPlantVanillaArray;
|
||||||
public static boolean enableConvert;
|
public static boolean enableConvert;
|
||||||
|
public static boolean enableSkillBonus;
|
||||||
|
public static double bonusPerLevel;
|
||||||
public static HashMap<Material, String> vanilla2Crops;
|
public static HashMap<Material, String> vanilla2Crops;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
@@ -235,6 +237,9 @@ public class MainConfig {
|
|||||||
waterBarEmpty = config.getString("watering-can-lore.water-bar.empty", "뀁뀄");
|
waterBarEmpty = config.getString("watering-can-lore.water-bar.empty", "뀁뀄");
|
||||||
waterBarRight = config.getString("watering-can-lore.water-bar.right", "뀁뀅</font>");
|
waterBarRight = config.getString("watering-can-lore.water-bar.right", "뀁뀅</font>");
|
||||||
|
|
||||||
|
enableSkillBonus = config.getBoolean("mechanics.skill-bonus.enable", false);
|
||||||
|
bonusPerLevel = config.getDouble("mechanics.skill-bonus.bonus-per-level", 0.001);
|
||||||
|
|
||||||
rightHarvestVanilla = config.getBoolean("mechanics.vanilla-crops.right-click-harvest", false);
|
rightHarvestVanilla = config.getBoolean("mechanics.vanilla-crops.right-click-harvest", false);
|
||||||
preventPlantVanilla = config.getBoolean("mechanics.vanilla-crops.prevent-plant.enable", false);
|
preventPlantVanilla = config.getBoolean("mechanics.vanilla-crops.prevent-plant.enable", false);
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ public interface SkillXP {
|
|||||||
|
|
||||||
void addXp(Player player, double amount);
|
void addXp(Player player, double amount);
|
||||||
|
|
||||||
|
int getLevel(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,4 +32,9 @@ public class AureliumsHook implements SkillXP {
|
|||||||
public void addXp(Player player, double amount) {
|
public void addXp(Player player, double amount) {
|
||||||
leveler.addXp(player, skill, amount);
|
leveler.addXp(player, skill, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLevel(Player player) {
|
||||||
|
return AureliumAPI.getSkillLevel(player, skill);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,9 @@ public class EcoSkillsHook implements SkillXP {
|
|||||||
public void addXp(Player player, double amount) {
|
public void addXp(Player player, double amount) {
|
||||||
EcoSkillsAPI.getInstance().giveSkillExperience(player, Skills.FARMING, amount);
|
EcoSkillsAPI.getInstance().giveSkillExperience(player, Skills.FARMING, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLevel(Player player) {
|
||||||
|
return EcoSkillsAPI.getInstance().getSkillLevel(player, Skills.FARMING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,27 @@ public class JobsRebornHook implements SkillXP {
|
|||||||
@Override
|
@Override
|
||||||
public void addXp(Player player, double amount) {
|
public void addXp(Player player, double amount) {
|
||||||
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
|
||||||
if (jobsPlayer != null) {
|
if (jobsPlayer != null) {
|
||||||
List<JobProgression> jobs = jobsPlayer.getJobProgression();
|
List<JobProgression> jobs = jobsPlayer.getJobProgression();
|
||||||
|
|
||||||
Job job = Jobs.getJob("Farmer");
|
Job job = Jobs.getJob("Farmer");
|
||||||
|
|
||||||
for (JobProgression progression : jobs)
|
for (JobProgression progression : jobs)
|
||||||
if (progression.getJob().equals(job)){
|
if (progression.getJob().equals(job)){
|
||||||
progression.addExperience(amount);
|
progression.addExperience(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLevel(Player player) {
|
||||||
|
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
if (jobsPlayer != null) {
|
||||||
|
List<JobProgression> jobs = jobsPlayer.getJobProgression();
|
||||||
|
Job job = Jobs.getJob("Farmer");
|
||||||
|
for (JobProgression progression : jobs)
|
||||||
|
if (progression.getJob().equals(job)){
|
||||||
|
return progression.getLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,9 @@ public class MMOCoreHook implements SkillXP {
|
|||||||
Profession profession = MMOCore.plugin.professionManager.get("farming");
|
Profession profession = MMOCore.plugin.professionManager.get("farming");
|
||||||
profession.giveExperience(MMOCore.plugin.dataProvider.getDataManager().get(player), amount, null ,EXPSource.OTHER);
|
profession.giveExperience(MMOCore.plugin.dataProvider.getDataManager().get(player), amount, null ,EXPSource.OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLevel(Player player) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customcrops.integrations.skill;
|
package net.momirealms.customcrops.integrations.skill;
|
||||||
|
|
||||||
import com.gmail.nossr50.api.ExperienceAPI;
|
import com.gmail.nossr50.api.ExperienceAPI;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import net.momirealms.customcrops.integrations.SkillXP;
|
import net.momirealms.customcrops.integrations.SkillXP;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -27,4 +28,9 @@ public class mcMMOHook implements SkillXP {
|
|||||||
public void addXp(Player player, double amount) {
|
public void addXp(Player player, double amount) {
|
||||||
ExperienceAPI.addRawXP(player, "Herbalism", (float) amount, "UNKNOWN");
|
ExperienceAPI.addRawXP(player, "Herbalism", (float) amount, "UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLevel(Player player) {
|
||||||
|
return ExperienceAPI.getLevel(player, PrimarySkillType.HERBALISM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class CropManager extends Function {
|
public class CropManager extends Function {
|
||||||
@@ -364,10 +365,14 @@ public class CropManager extends Function {
|
|||||||
qualityRatio = qualityCrop.getQualityRatio();
|
qualityRatio = qualityCrop.getQualityRatio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MainConfig.enableSkillBonus) {
|
||||||
|
double bonus_chance = MainConfig.skillXP.getLevel(player) * MainConfig.bonusPerLevel;
|
||||||
|
amount *= (bonus_chance + 1);
|
||||||
|
}
|
||||||
dropQualityLoots(qualityLoot, amount, location.getBlock().getLocation(), qualityRatio);
|
dropQualityLoots(qualityLoot, amount, location.getBlock().getLocation(), qualityRatio);
|
||||||
}
|
}
|
||||||
OtherLoot[] otherLoots = crop.getOtherLoots();
|
OtherLoot[] otherLoots = crop.getOtherLoots();
|
||||||
if (otherLoots != null) dropOtherLoots(otherLoots, location.getBlock().getLocation());
|
if (otherLoots != null) dropOtherLoots(otherLoots, location.getBlock().getLocation(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performActions(ActionInterface[] actions, Player player) {
|
public void performActions(ActionInterface[] actions, Player player) {
|
||||||
@@ -376,10 +381,14 @@ public class CropManager extends Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropOtherLoots(OtherLoot[] otherLoots, Location location) {
|
public void dropOtherLoots(OtherLoot[] otherLoots, Location location, Player player) {
|
||||||
for (OtherLoot otherLoot : otherLoots) {
|
for (OtherLoot otherLoot : otherLoots) {
|
||||||
if (Math.random() < otherLoot.getChance()) {
|
if (Math.random() < otherLoot.getChance()) {
|
||||||
int random = ThreadLocalRandom.current().nextInt(otherLoot.getMin(), otherLoot.getMax() + 1);
|
int random = ThreadLocalRandom.current().nextInt(otherLoot.getMin(), otherLoot.getMax() + 1);
|
||||||
|
if (MainConfig.enableSkillBonus) {
|
||||||
|
double bonus_chance = MainConfig.skillXP.getLevel(player) * MainConfig.bonusPerLevel;
|
||||||
|
random *= (bonus_chance + 1);
|
||||||
|
}
|
||||||
ItemStack drop = getLoot(otherLoot.getItemID());
|
ItemStack drop = getLoot(otherLoot.getItemID());
|
||||||
if (drop == null) continue;
|
if (drop == null) continue;
|
||||||
drop.setAmount(random);
|
drop.setAmount(random);
|
||||||
@@ -435,13 +444,9 @@ public class CropManager extends Function {
|
|||||||
public boolean crowJudge(Location location) {
|
public boolean crowJudge(Location location) {
|
||||||
if (Math.random() < MainConfig.crowChance && !hasScarecrow(location)) {
|
if (Math.random() < MainConfig.crowChance && !hasScarecrow(location)) {
|
||||||
|
|
||||||
CrowAttackEvent crowAttackEvent = new CrowAttackEvent(location);
|
|
||||||
Bukkit.getPluginManager().callEvent(crowAttackEvent);
|
|
||||||
if (crowAttackEvent.isCancelled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||||
|
CrowAttackEvent crowAttackEvent = new CrowAttackEvent(location);
|
||||||
|
Bukkit.getPluginManager().callEvent(crowAttackEvent);
|
||||||
for (Player player : location.getNearbyPlayers(48)) {
|
for (Player player : location.getNearbyPlayers(48)) {
|
||||||
CrowTask crowTask = new CrowTask(player, location.clone().add(0.4,0,0.4), getArmorStandUtil());
|
CrowTask crowTask = new CrowTask(player, location.clone().add(0.4,0,0.4), getArmorStandUtil());
|
||||||
crowTask.runTaskTimerAsynchronously(CustomCrops.plugin, 1, 1);
|
crowTask.runTaskTimerAsynchronously(CustomCrops.plugin, 1, 1);
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ public class CustomWorld {
|
|||||||
|
|
||||||
public void unloadSeason() {
|
public void unloadSeason() {
|
||||||
if (!SeasonConfig.enable) return;
|
if (!SeasonConfig.enable) return;
|
||||||
|
if (MainConfig.realisticSeasonHook) return;
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
JsonPrimitive jsonPrimitive = new JsonPrimitive(SeasonUtils.getSeason(world).name());
|
JsonPrimitive jsonPrimitive = new JsonPrimitive(SeasonUtils.getSeason(world).name());
|
||||||
jsonObject.add("season", jsonPrimitive);
|
jsonObject.add("season", jsonPrimitive);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Don't change
|
#Don't change
|
||||||
config-version: '14'
|
config-version: '15'
|
||||||
|
|
||||||
# lang: english / spanish / chinese
|
# lang: english / spanish / chinese
|
||||||
lang: english
|
lang: english
|
||||||
@@ -150,6 +150,11 @@ mechanics:
|
|||||||
POTATO: potato
|
POTATO: potato
|
||||||
BEETROOT_SEEDS: beetroot
|
BEETROOT_SEEDS: beetroot
|
||||||
|
|
||||||
|
# This option requires a skill-plugin hook
|
||||||
|
# Which would increase the amount of crops player get
|
||||||
|
skill-bonus:
|
||||||
|
enable: false
|
||||||
|
bonus-per-level: 0.001
|
||||||
|
|
||||||
sounds:
|
sounds:
|
||||||
water-pot:
|
water-pot:
|
||||||
|
|||||||
Reference in New Issue
Block a user