mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Lets start working on Cook action
This commit is contained in:
parent
d740b534c3
commit
c36df666be
@ -22,6 +22,7 @@ import com.gamingmesh.jobs.CMILib.ActionBarTitleMessages;
|
||||
import com.gamingmesh.jobs.CMILib.ItemManager;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.CMILib.VersionChecker;
|
||||
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.McMMO.McMMO1_X_listener;
|
||||
import com.gamingmesh.jobs.McMMO.McMMO2_X_listener;
|
||||
@ -47,6 +48,7 @@ import com.gamingmesh.jobs.dao.JobsManager;
|
||||
import com.gamingmesh.jobs.economy.*;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPayment14Listener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
@ -648,6 +650,9 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
pm.registerEvents(new JobsListener(instance), instance);
|
||||
pm.registerEvents(new JobsPaymentListener(instance), instance);
|
||||
if (versionCheckManager.getVersion().isEqualOrHigher(Version.v1_14_R1)) {
|
||||
pm.registerEvents(new JobsPayment14Listener(), instance);
|
||||
}
|
||||
|
||||
if (GconfigManager.useBlockProtection)
|
||||
pm.registerEvents(PistonProtectionListener, instance);
|
||||
@ -913,6 +918,9 @@ public class Jobs extends JavaPlugin {
|
||||
// register the listeners
|
||||
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
||||
if (versionCheckManager.getVersion().isEqualOrHigher(Version.v1_14_R1)) {
|
||||
getServer().getPluginManager().registerEvents(new JobsPayment14Listener(), this);
|
||||
}
|
||||
|
||||
if (getMcMMOManager().CheckmcMMO())
|
||||
setMcMMOlistener();
|
||||
|
@ -201,6 +201,7 @@ public class ConfigManager {
|
||||
case ENCHANT:
|
||||
case DYE:
|
||||
case CRAFT:
|
||||
case COOK:
|
||||
case BREW:
|
||||
case BREAK:
|
||||
case STRIPLOGS:
|
||||
@ -349,7 +350,8 @@ public class ConfigManager {
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
CMIEnchantment enchant = CMIEnchantment.get(myKey);
|
||||
type = enchant == null ? myKey : enchant.toString();
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL)
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.COLLECT || actionType == ActionType.COOK)
|
||||
type = myKey;
|
||||
else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
@ -364,9 +366,6 @@ public class ConfigManager {
|
||||
Jobs.getExplore().setPlayerAmount(amount);
|
||||
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!"))
|
||||
type = myKey.substring(1, myKey.length());
|
||||
else if (actionType == ActionType.COLLECT) {
|
||||
type = myKey;
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
@ -988,6 +987,7 @@ public class ConfigManager {
|
||||
case ENCHANT:
|
||||
case DYE:
|
||||
case CRAFT:
|
||||
case COOK:
|
||||
case BREW:
|
||||
case BREAK:
|
||||
case STRIPLOGS:
|
||||
@ -1139,7 +1139,7 @@ public class ConfigManager {
|
||||
}
|
||||
type = enchant == null ? myKey : enchant.toString();
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.COLLECT || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.SHEAR)
|
||||
|| actionType == ActionType.SHEAR || actionType == ActionType.COOK)
|
||||
type = myKey;
|
||||
else if (actionType == ActionType.EXPLORE) {
|
||||
type = myKey;
|
||||
|
@ -435,6 +435,8 @@ public class LanguageManager {
|
||||
c.get("command.info.output.custom-kill.none", "%jobname% does not get money from custom player kills.");
|
||||
c.get("command.info.output.collect.info", "&eCollect");
|
||||
c.get("command.info.output.collect.none", "%jobname% does not get money for collecting blocks.");
|
||||
c.get("command.info.output.cook.info", "&eCook");
|
||||
c.get("command.info.output.cook.none", "%jobname% does not get money for cooking foods.");
|
||||
|
||||
c.get("command.playerinfo.help.info", "Show how much each job is getting paid and for what on another player.");
|
||||
c.get("command.playerinfo.help.args", "[playername] [jobname] [action]");
|
||||
@ -526,7 +528,7 @@ public class LanguageManager {
|
||||
c.get("command.employ.error.fullslots", "You cannot join the job %jobname%, there are no slots available.");
|
||||
c.get("command.employ.output.target", "You have been employed as a %jobname%.");
|
||||
|
||||
c.get("command.top.help.info", "Shows top %amount% players by jobs name.");
|
||||
c.get("command.top.help.info", "Shows top players by jobs name.");
|
||||
c.get("command.top.help.args", "[jobname]");
|
||||
Jobs.getGCManager().getCommandArgs().put("top", Arrays.asList("[jobname]"));
|
||||
c.get("command.top.error.nojob", "Can't find any job with this name.");
|
||||
|
@ -40,7 +40,8 @@ public enum ActionType {
|
||||
EXPLORE("Explore"),
|
||||
EAT("Eat"),
|
||||
CUSTOMKILL("custom-kill"),
|
||||
COLLECT("Collect");
|
||||
COLLECT("Collect"),
|
||||
COOK("Cook");
|
||||
|
||||
private String name;
|
||||
|
||||
|
23
src/main/java/com/gamingmesh/jobs/container/PlayerCamp.java
Normal file
23
src/main/java/com/gamingmesh/jobs/container/PlayerCamp.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerCamp {
|
||||
|
||||
private ItemStack item;
|
||||
private Block block;
|
||||
|
||||
public PlayerCamp(ItemStack item, Block block) {
|
||||
this.item = item;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.block.Campfire;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockCookEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.PlayerCamp;
|
||||
|
||||
public class JobsPayment14Listener implements Listener {
|
||||
|
||||
private Map<Player, PlayerCamp> campPlayers = new HashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onCook(BlockCookEvent event) {
|
||||
if (!Jobs.getInstance().isEnabled())
|
||||
return;
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
if (!(event.getBlock().getState() instanceof Campfire))
|
||||
return;
|
||||
|
||||
for (Iterator<Map.Entry<Player, PlayerCamp>> it = campPlayers.entrySet().iterator(); it.hasNext();) {
|
||||
Map.Entry<Player, PlayerCamp> camps = it.next();
|
||||
if (camps == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!camps.getValue().getBlock().getLocation().equals(event.getBlock().getLocation())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(camps.getKey());
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.COOK));
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onCampPlace(PlayerInteractEvent ev) {
|
||||
if (!Jobs.getInstance().isEnabled())
|
||||
return;
|
||||
|
||||
org.bukkit.block.Block click = ev.getClickedBlock();
|
||||
if (click == null || !click.getType().isBlock() || !click.getType().equals(org.bukkit.Material.CAMPFIRE))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(click.getWorld()))
|
||||
return;
|
||||
|
||||
if (!(click.getState() instanceof Campfire))
|
||||
return;
|
||||
|
||||
if (!ev.hasItem())
|
||||
return;
|
||||
|
||||
Player p = ev.getPlayer();
|
||||
|
||||
if (!JobsPaymentListener.payIfCreative(p))
|
||||
return;
|
||||
|
||||
campPlayers.put(p, new PlayerCamp(ev.getItem(), click));
|
||||
}
|
||||
}
|
@ -1703,7 +1703,7 @@ public class JobsPaymentListener implements Listener {
|
||||
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE));
|
||||
}
|
||||
|
||||
private static boolean payIfCreative(Player player) {
|
||||
static boolean payIfCreative(Player player) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative() && !player.hasPermission("jobs.paycreative"))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -233,6 +233,14 @@ Jobs:
|
||||
income: 1.5
|
||||
points: 1.5
|
||||
experience: 1.5
|
||||
# Payment for cooking raw foods
|
||||
Cook:
|
||||
beef:
|
||||
income: 1.0
|
||||
experience: 1.0
|
||||
porkchop:
|
||||
income: 0.5
|
||||
points: 0.4
|
||||
# payment for stripping wood logs, only for 1.13+ servers
|
||||
StripLogs:
|
||||
stripped_acacia_log:
|
||||
|
Loading…
Reference in New Issue
Block a user