diff --git a/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java b/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java new file mode 100644 index 00000000..cf2c9807 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java @@ -0,0 +1,28 @@ +package com.gamingmesh.jobs.actions; + +import org.bukkit.block.Block; + +import com.gamingmesh.jobs.container.ActionInfo; +import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.BaseActionInfo; + +public class BlockCollectInfo extends BaseActionInfo implements ActionInfo { + private Block block; + private int age; + + public BlockCollectInfo(Block block, ActionType type, int age) { + super(type); + this.block = block; + this.age = age; + } + + @Override + public String getName() { + return block.getType().name(); + } + + @Override + public String getNameWithSub() { + return getName() + ":" + age; + } +} diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index f50a7d20..789201cd 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -370,6 +370,8 @@ public class ConfigManager { type = potion.toString(); id = potion.getId(); } + } else if (actionType == ActionType.COLLECT) { + type = myKey; } if (type == null) { @@ -1151,6 +1153,8 @@ public class ConfigManager { type = potion.toString(); id = potion.getId(); } + } else if (actionType == ActionType.COLLECT) { + type = myKey; } if (type == null) { diff --git a/src/main/java/com/gamingmesh/jobs/container/ActionType.java b/src/main/java/com/gamingmesh/jobs/container/ActionType.java index 8c7ccedf..872f1969 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ActionType.java +++ b/src/main/java/com/gamingmesh/jobs/container/ActionType.java @@ -40,7 +40,8 @@ public enum ActionType { MILK("Milk"), EXPLORE("Explore"), EAT("Eat"), - CUSTOMKILL("custom-kill"); + CUSTOMKILL("custom-kill"), + COLLECT("Collect"); private String name; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 46f48065..10981973 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -33,6 +33,8 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BrewingStand; import org.bukkit.block.Furnace; +import org.bukkit.block.data.Ageable; +import org.bukkit.block.data.Levelled; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; @@ -89,6 +91,7 @@ import com.gamingmesh.jobs.CMILib.CMIEnchantment; import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; import com.gamingmesh.jobs.CMILib.VersionChecker.Version; import com.gamingmesh.jobs.actions.BlockActionInfo; +import com.gamingmesh.jobs.actions.BlockCollectInfo; import com.gamingmesh.jobs.actions.CustomKillInfo; import com.gamingmesh.jobs.actions.EnchantActionInfo; import com.gamingmesh.jobs.actions.EntityActionInfo; @@ -435,6 +438,7 @@ public class JobsPaymentListener implements Listener { } } } + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; @@ -1572,6 +1576,26 @@ public class JobsPaymentListener implements Listener { if (block == null) return; CMIMaterial cmat = CMIMaterial.get(block); + + if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); + if (jPlayer != null) { + if (cmat.equals(CMIMaterial.COMPOSTER)) { + Levelled level = (Levelled) block.getBlockData(); + if (level.getLevel() == level.getMaximumLevel()) { + Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.COLLECT), block); + } + } + + if (cmat.equals(CMIMaterial.SWEET_BERRY_BUSH)) { + Ageable age = (Ageable) block.getBlockData(); + if (!Jobs.getNms().getItemInMainHand(event.getPlayer()).getType().equals(CMIMaterial.BONE_MEAL.getMaterial())) { + Jobs.action(jPlayer, new BlockCollectInfo(block, ActionType.COLLECT, age.getAge()), block); + } + } + } + } + if (cmat.equals(CMIMaterial.FURNACE) || cmat.equals(CMIMaterial.LEGACY_BURNING_FURNACE) || cmat.equals(CMIMaterial.SMOKER) || cmat.equals(CMIMaterial.BLAST_FURNACE)) { if (!Jobs.getGCManager().isFurnacesReassign()) return; diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index a827379c..61d429f2 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -223,6 +223,16 @@ Jobs: # you can use minuses to take away money if the player break this block income: -1.0 experience: -1.0 + # Payment for collecting sweet berries or collect from composter + Collect: + sweet_berry_bush-3: + income: 0.5 + points: 0.5 + experience: 0.5 + composter: + income: 1.5 + points: 1.5 + experience: 1.5 # payment for stripping wood logs, only for 1.13+ servers StripLogs: stripped_acacia_log: