9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 00:19:24 +00:00
This commit is contained in:
Xiao-MoMi
2022-10-14 14:36:07 +08:00
parent 19de99dc3e
commit 3edf08f5b3
9 changed files with 40 additions and 29 deletions

View File

@@ -138,12 +138,23 @@ public class CropManager extends Function {
public void loadSeason() {
if (SeasonConfig.enable) {
for (CustomWorld customWorld : customWorlds.values()) {
customWorld.unloadSeason();
}
if (seasonInterface != null) {
seasonInterface.unload();
this.seasonInterface = null;
}
if (MainConfig.realisticSeasonHook) seasonInterface = new RealisticSeasonsHook();
else seasonInterface = new InternalSeason();
seasonInterface.load();
//empty when enabling
for (CustomWorld customWorld : customWorlds.values()) {
customWorld.loadSeason();
}
return;
}
else if (this.seasonInterface != null) {
this.seasonInterface.unload();
if (seasonInterface != null) {
seasonInterface.unload();
this.seasonInterface = null;
}
}
@@ -300,12 +311,12 @@ public class CropManager extends Function {
return customWorlds.get(world);
}
public void proceedHarvest(Crop crop, Player player, Location location, @Nullable Fertilizer fertilizer) {
public void proceedHarvest(Crop crop, Player player, Location location, @Nullable Fertilizer fertilizer, boolean isRightClick) {
//Call harvest event
CropHarvestEvent cropHarvestEvent = new CropHarvestEvent(player, crop, location, fertilizer);
Bukkit.getPluginManager().callEvent(cropHarvestEvent);
if (cropHarvestEvent.isCancelled()) return;
if (!isRightClick && player.getGameMode() == GameMode.CREATIVE) return;
ActionInterface[] actions = crop.getActions();
if (actions != null) performActions(actions, player);
@@ -317,9 +328,6 @@ public class CropManager extends Function {
1,1
);
}
if (player.getGameMode() == GameMode.CREATIVE) return;
QualityLoot qualityLoot = crop.getQualityLoot();
if (qualityLoot != null) {
int amount = ThreadLocalRandom.current().nextInt(qualityLoot.getMin(), qualityLoot.getMax() + 1);