1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Collect action should be defined by what we collect and not with what we

interact

sweet_berries
glow_berries
bonemeal
honeybottle
honeycomb
This commit is contained in:
Zrips 2021-09-15 17:03:00 +03:00
parent 2c5602ab8b
commit bd009f78f4
3 changed files with 48 additions and 16 deletions

View File

@ -5,24 +5,36 @@ import org.bukkit.block.Block;
import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.BaseActionInfo; import com.gamingmesh.jobs.container.BaseActionInfo;
import net.Zrips.CMILib.Items.CMIMaterial;
public class BlockCollectInfo extends BaseActionInfo { public class BlockCollectInfo extends BaseActionInfo {
private Block block; private CMIMaterial material;
private int ageOrLevel; private int ageOrLevel = 0;
@Deprecated
public BlockCollectInfo(Block block, ActionType type, int ageOrLevel) { public BlockCollectInfo(Block block, ActionType type, int ageOrLevel) {
this(CMIMaterial.get(block), type, ageOrLevel);
}
public BlockCollectInfo(CMIMaterial material, ActionType type, int ageOrLevel) {
super(type); super(type);
this.block = block; this.material = material;
this.ageOrLevel = ageOrLevel; this.ageOrLevel = ageOrLevel;
} }
public BlockCollectInfo(CMIMaterial material, ActionType type) {
super(type);
this.material = material;
}
@Override @Override
public String getName() { public String getName() {
return block.getType().name(); return material.toString();
} }
@Override @Override
public String getNameWithSub() { public String getNameWithSub() {
return getName() + ":" + ageOrLevel; return getName() + (ageOrLevel == 0 ? "" : ":" + ageOrLevel);
} }
} }

View File

@ -125,6 +125,7 @@ import net.Zrips.CMILib.Container.CMILocation;
import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
public final class JobsPaymentListener implements Listener { public final class JobsPaymentListener implements Listener {
@ -1625,6 +1626,7 @@ public final class JobsPaymentListener implements Listener {
return; return;
CMIMaterial cmat = CMIMaterial.get(block); CMIMaterial cmat = CMIMaterial.get(block);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
Material hand = CMIItemStack.getItemInMainHand(p).getType(); 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(); org.bukkit.block.data.Levelled level = (org.bukkit.block.data.Levelled) block.getBlockData();
if (level.getLevel() == level.getMaximumLevel()) { 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() if (beehive.getHoneyLevel() == beehive.getMaximumHoneyLevel() && (hand == CMIMaterial.SHEARS.getMaterial()
|| hand == CMIMaterial.GLASS_BOTTLE.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);
}
} }
} }
} }

View File

@ -263,19 +263,23 @@ exampleJob:
experience: 1.0 experience: 1.0
# Payment for collecting things like sweet berry bush, composter or honey # Payment for collecting things like sweet berry bush, composter or honey
Collect: Collect:
sweet_berry_bush-3: sweet_berries-2:
income: 0.2
points: 0.2
experience: 0.2
sweet_berries-3:
income: 0.5 income: 0.5
points: 0.5 points: 0.5
experience: 0.5 experience: 0.5
composter: bonemeal:
income: 1.5 income: 1.5
points: 1.5 points: 1.5
experience: 1.5 experience: 1.5
beehive-5: honeybottle:
income: 2.5 income: 2.5
points: 2.5 points: 2.5
experience: 2.5 experience: 2.5
bee_nest-5: honeycomb:
income: 2.5 income: 2.5
points: 2.5 points: 2.5
experience: 2.5 experience: 2.5