mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 12:05:16 +01:00
Implement new actiontype: Collect, #484
To collect sweet berries from bush, and collect from composter
This commit is contained in:
parent
deba8e6f45
commit
9ed6ed59ee
@ -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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -40,7 +40,8 @@ public enum ActionType {
|
||||
MILK("Milk"),
|
||||
EXPLORE("Explore"),
|
||||
EAT("Eat"),
|
||||
CUSTOMKILL("custom-kill");
|
||||
CUSTOMKILL("custom-kill"),
|
||||
COLLECT("Collect");
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user