1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Implement new actiontype: Collect, #484

To collect sweet berries from bush, and collect from composter
This commit is contained in:
montlikadani 2019-07-18 09:58:09 +02:00
parent deba8e6f45
commit 9ed6ed59ee
5 changed files with 68 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -370,6 +370,8 @@ public class ConfigManager {
type = potion.toString(); type = potion.toString();
id = potion.getId(); id = potion.getId();
} }
} else if (actionType == ActionType.COLLECT) {
type = myKey;
} }
if (type == null) { if (type == null) {
@ -1151,6 +1153,8 @@ public class ConfigManager {
type = potion.toString(); type = potion.toString();
id = potion.getId(); id = potion.getId();
} }
} else if (actionType == ActionType.COLLECT) {
type = myKey;
} }
if (type == null) { if (type == null) {

View File

@ -40,7 +40,8 @@ public enum ActionType {
MILK("Milk"), MILK("Milk"),
EXPLORE("Explore"), EXPLORE("Explore"),
EAT("Eat"), EAT("Eat"),
CUSTOMKILL("custom-kill"); CUSTOMKILL("custom-kill"),
COLLECT("Collect");
private String name; private String name;

View File

@ -33,6 +33,8 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
import org.bukkit.block.Furnace; 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.enchantments.Enchantment;
import org.bukkit.entity.Damageable; import org.bukkit.entity.Damageable;
import org.bukkit.entity.Entity; 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.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version; import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.actions.BlockActionInfo; import com.gamingmesh.jobs.actions.BlockActionInfo;
import com.gamingmesh.jobs.actions.BlockCollectInfo;
import com.gamingmesh.jobs.actions.CustomKillInfo; import com.gamingmesh.jobs.actions.CustomKillInfo;
import com.gamingmesh.jobs.actions.EnchantActionInfo; import com.gamingmesh.jobs.actions.EnchantActionInfo;
import com.gamingmesh.jobs.actions.EntityActionInfo; import com.gamingmesh.jobs.actions.EntityActionInfo;
@ -435,6 +438,7 @@ public class JobsPaymentListener implements Listener {
} }
} }
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null) if (jPlayer == null)
return; return;
@ -1572,6 +1576,26 @@ public class JobsPaymentListener implements Listener {
if (block == null) if (block == null)
return; return;
CMIMaterial cmat = CMIMaterial.get(block); 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 (cmat.equals(CMIMaterial.FURNACE) || cmat.equals(CMIMaterial.LEGACY_BURNING_FURNACE) || cmat.equals(CMIMaterial.SMOKER) || cmat.equals(CMIMaterial.BLAST_FURNACE)) {
if (!Jobs.getGCManager().isFurnacesReassign()) if (!Jobs.getGCManager().isFurnacesReassign())
return; return;

View File

@ -223,6 +223,16 @@ Jobs:
# you can use minuses to take away money if the player break this block # you can use minuses to take away money if the player break this block
income: -1.0 income: -1.0
experience: -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 # payment for stripping wood logs, only for 1.13+ servers
StripLogs: StripLogs:
stripped_acacia_log: stripped_acacia_log: