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

New job action: StripLogs

This commit is contained in:
Zrips 2019-01-30 16:05:46 +02:00
parent 95f922e151
commit 1d897e9d3e
5 changed files with 43 additions and 5 deletions

View File

@ -206,6 +206,7 @@ public class ConfigManager {
case CRAFT: case CRAFT:
case BREW: case BREW:
case BREAK: case BREAK:
case STRIPLOGS:
material = CMIMaterial.get(myKey + (subType)); material = CMIMaterial.get(myKey + (subType));
if (material == null) if (material == null)
@ -254,7 +255,7 @@ public class ConfigManager {
} }
// Break and Place actions MUST be blocks // Break and Place actions MUST be blocks
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) { if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
if (!material.isBlock()) { if (!material.isBlock()) {
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material
+ "(" + myKey + ")! Material must be a block!"); + "(" + myKey + ")! Material must be a block!");
@ -969,6 +970,7 @@ public class ConfigManager {
case CRAFT: case CRAFT:
case BREW: case BREW:
case BREAK: case BREAK:
case STRIPLOGS:
material = CMIMaterial.get(myKey + (subType)); material = CMIMaterial.get(myKey + (subType));
if (material == null) if (material == null)
@ -1017,7 +1019,7 @@ public class ConfigManager {
} }
// Break and Place actions MUST be blocks // Break and Place actions MUST be blocks
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) { if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
if (!material.isBlock()) { if (!material.isBlock()) {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + material Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + material
+ " (" + key + ")! Material must be a block!"); + " (" + key + ")! Material must be a block!");
@ -1134,6 +1136,7 @@ public class ConfigManager {
} }
if (type == null) { if (type == null) {
Debug.D("type null");
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!"); Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!");
continue; continue;
} }

View File

@ -381,6 +381,8 @@ public class LanguageManager {
c.get("command.info.output.tntbreak.none", "%jobname% does not get money for breaking blocks with TNT."); c.get("command.info.output.tntbreak.none", "%jobname% does not get money for breaking blocks with TNT.");
c.get("command.info.output.place.info", "&ePlace"); c.get("command.info.output.place.info", "&ePlace");
c.get("command.info.output.place.none", "%jobname% does not get money for placing blocks."); c.get("command.info.output.place.none", "%jobname% does not get money for placing blocks.");
c.get("command.info.output.striplogs.info", "&eStrip logs");
c.get("command.info.output.striplogs.none", "%jobname% does not get money for stripping logs.");
c.get("command.info.output.kill.info", "&eKill"); c.get("command.info.output.kill.info", "&eKill");
c.get("command.info.output.kill.none", "%jobname% does not get money for killing monsters."); c.get("command.info.output.kill.none", "%jobname% does not get money for killing monsters.");
c.get("command.info.output.mmkill.info", "&eMMKill"); c.get("command.info.output.mmkill.info", "&eMMKill");

View File

@ -20,6 +20,7 @@ package com.gamingmesh.jobs.container;
public enum ActionType { public enum ActionType {
BREAK("Break"), BREAK("Break"),
STRIPLOGS("StripLogs"),
DRINK("Drink"), DRINK("Drink"),
TNTBREAK("TNTBreak"), TNTBREAK("TNTBreak"),
PLACE("Place"), PLACE("Place"),

View File

@ -47,6 +47,7 @@ import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.enchantment.EnchantItemEvent;
@ -83,6 +84,7 @@ import org.bukkit.projectiles.ProjectileSource;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
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.actions.BlockActionInfo; import com.gamingmesh.jobs.actions.BlockActionInfo;
import com.gamingmesh.jobs.actions.CustomKillInfo; import com.gamingmesh.jobs.actions.CustomKillInfo;
import com.gamingmesh.jobs.actions.EnchantActionInfo; import com.gamingmesh.jobs.actions.EnchantActionInfo;
@ -97,6 +99,7 @@ import com.gamingmesh.jobs.container.ExploreRespond;
import com.gamingmesh.jobs.container.FastPayment; import com.gamingmesh.jobs.container.FastPayment;
import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling; import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback; import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -1492,6 +1495,25 @@ public class JobsPaymentListener implements Listener {
"[current]", jPlayer.getBrewingStandCount(), "[current]", jPlayer.getBrewingStandCount(),
"[max]", jPlayer.getMaxBrewingStandsAllowed() == 0 ? "-" : jPlayer.getMaxBrewingStandsAllowed())); "[max]", jPlayer.getMaxBrewingStandsAllowed() == 0 ? "-" : jPlayer.getMaxBrewingStandsAllowed()));
} }
} else if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) &&
block.getType().toString().endsWith("_LOG") &&
!block.getType().toString().startsWith("STRIPPED_") &&
event.getAction() == Action.RIGHT_CLICK_BLOCK) {
ItemStack iih = Jobs.getNms().getItemInMainHand(event.getPlayer());
if (iih.getType().toString().endsWith("_AXE")) {
final Location loc = event.getClickedBlock().getLocation();
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
Block b = loc.getBlock();
if (b.getType().toString().startsWith("STRIPPED_")) {
Jobs.action(jPlayer, new BlockActionInfo(b, ActionType.STRIPLOGS), b);
}
return;
}
}, 1);
}
} }
} }

View File

@ -200,6 +200,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 stripping wood logs, only for 1.13+ servers
StripLogs:
STRIPPED_ACACIA_LOG:
income: 1.0
points: 1.0
experience: 1.0
STRIPPED_OAK_LOG:
income: 1.0
points: 1.0
experience: 1.0
# payment for drinking a potion # payment for drinking a potion
Drink: Drink:
potion: potion: