diff --git a/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java b/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java index 9fcfe49c..0f296c56 100644 --- a/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java +++ b/src/main/java/com/gamingmesh/jobs/actions/BlockCollectInfo.java @@ -5,24 +5,36 @@ import org.bukkit.block.Block; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.BaseActionInfo; +import net.Zrips.CMILib.Items.CMIMaterial; + public class BlockCollectInfo extends BaseActionInfo { - private Block block; - private int ageOrLevel; + private CMIMaterial material; + private int ageOrLevel = 0; + @Deprecated public BlockCollectInfo(Block block, ActionType type, int ageOrLevel) { + this(CMIMaterial.get(block), type, ageOrLevel); + } + + public BlockCollectInfo(CMIMaterial material, ActionType type, int ageOrLevel) { super(type); - this.block = block; + this.material = material; this.ageOrLevel = ageOrLevel; } + public BlockCollectInfo(CMIMaterial material, ActionType type) { + super(type); + this.material = material; + } + @Override public String getName() { - return block.getType().name(); + return material.toString(); } @Override public String getNameWithSub() { - return getName() + ":" + ageOrLevel; + return getName() + (ageOrLevel == 0 ? "" : ":" + ageOrLevel); } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 7c8c7a68..beab53cd 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -125,6 +125,7 @@ import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; public final class JobsPaymentListener implements Listener { @@ -1113,10 +1114,10 @@ public final class JobsPaymentListener implements Listener { if (Jobs.getGCManager().blockOwnershipRange > 0 && Util.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange) return; - + if (!Jobs.getPermissionHandler().hasWorldPermission(player)) return; - + // check if player is riding if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) return; @@ -1625,6 +1626,7 @@ public final class JobsPaymentListener implements Listener { return; CMIMaterial cmat = CMIMaterial.get(block); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p); Material hand = CMIItemStack.getItemInMainHand(p).getType(); @@ -1635,11 +1637,20 @@ public final class JobsPaymentListener implements Listener { org.bukkit.block.data.Levelled level = (org.bukkit.block.data.Levelled) block.getBlockData(); if (level.getLevel() == level.getMaximumLevel()) { - Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.COLLECT), block); + Jobs.action(jPlayer, new BlockCollectInfo(CMIMaterial.BONE_MEAL, ActionType.COLLECT), block); + } + } else if ((cmat == CMIMaterial.SWEET_BERRY_BUSH || cmat == CMIMaterial.CAVE_VINES_PLANT) && hand != CMIMaterial.BONE_MEAL.getMaterial()) { + + if (cmat == CMIMaterial.SWEET_BERRY_BUSH) { + Ageable age = (Ageable) block.getBlockData(); + if (age.getAge() >= 2) + Jobs.action(jPlayer, new BlockCollectInfo(CMIMaterial.SWEET_BERRIES, ActionType.COLLECT, age.getAge()), block); + } else if (cmat == CMIMaterial.CAVE_VINES_PLANT) { + org.bukkit.block.data.type.CaveVinesPlant caveVines = (org.bukkit.block.data.type.CaveVinesPlant) block.getBlockData(); + if (caveVines.isBerries()) { + Jobs.action(jPlayer, new BlockCollectInfo(CMIMaterial.GLOW_BERRIES, ActionType.COLLECT), block); + } } - } else if ((cmat == CMIMaterial.SWEET_BERRY_BUSH || cmat == CMIMaterial.GLOW_BERRIES) && hand != CMIMaterial.BONE_MEAL.getMaterial()) { - Ageable age = (Ageable) block.getBlockData(); - Jobs.action(jPlayer, new BlockCollectInfo(block, ActionType.COLLECT, age.getAge()), block); } } @@ -1648,7 +1659,12 @@ public final class JobsPaymentListener implements Listener { if (beehive.getHoneyLevel() == beehive.getMaximumHoneyLevel() && (hand == CMIMaterial.SHEARS.getMaterial() || hand == CMIMaterial.GLASS_BOTTLE.getMaterial())) { - Jobs.action(jPlayer, new BlockCollectInfo(block, ActionType.COLLECT, beehive.getHoneyLevel()), block); + + if (hand == CMIMaterial.SHEARS.getMaterial()) { + Jobs.action(jPlayer, new BlockCollectInfo(CMIMaterial.HONEYCOMB, ActionType.COLLECT), block); + } else { + Jobs.action(jPlayer, new BlockCollectInfo(CMIMaterial.HONEY_BOTTLE, ActionType.COLLECT), block); + } } } } diff --git a/src/main/resources/jobs/_EXAMPLE.yml b/src/main/resources/jobs/_EXAMPLE.yml index 4bb96ca3..96774dea 100644 --- a/src/main/resources/jobs/_EXAMPLE.yml +++ b/src/main/resources/jobs/_EXAMPLE.yml @@ -263,19 +263,23 @@ exampleJob: experience: 1.0 # Payment for collecting things like sweet berry bush, composter or honey Collect: - sweet_berry_bush-3: + sweet_berries-2: + income: 0.2 + points: 0.2 + experience: 0.2 + sweet_berries-3: income: 0.5 points: 0.5 experience: 0.5 - composter: + bonemeal: income: 1.5 points: 1.5 experience: 1.5 - beehive-5: + honeybottle: income: 2.5 points: 2.5 experience: 2.5 - bee_nest-5: + honeycomb: income: 2.5 points: 2.5 experience: 2.5