mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-30 20:11:23 +01:00
Smithing table support
This commit is contained in:
parent
5bb3414ea7
commit
98b84287a4
@ -788,7 +788,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
// HACK! The API doesn't allow us to easily determine the resulting number of
|
||||
// crafted items, so we're forced to compare the inventory before and after.
|
||||
private void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) {
|
||||
public static void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) {
|
||||
final ItemStack[] preInv = player.getInventory().getContents();
|
||||
// Clone the array. The content may (was for me) be mutable.
|
||||
for (int i = 0; i < preInv.length; i++) {
|
||||
@ -821,7 +821,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private static boolean hasItems(ItemStack stack) {
|
||||
public static boolean hasItems(ItemStack stack) {
|
||||
return stack != null && stack.getAmount() > 0;
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
Objects.equal(a.getEnchantments(), b.getEnchantments());
|
||||
}
|
||||
|
||||
private static boolean isStackSumLegal(ItemStack a, ItemStack b) {
|
||||
public static boolean isStackSumLegal(ItemStack a, ItemStack b) {
|
||||
// See if we can create a new item stack with the combined elements of a and b
|
||||
if (a == null || b == null)
|
||||
return true;// Treat null as an empty stack
|
||||
@ -1601,6 +1601,9 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getGCManager().useBreederFinder || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if (event.getEntity().getType().equals(EntityType.TURTLE))
|
||||
CMIDebug.d(event.getSpawnReason());
|
||||
|
||||
if (!event.getSpawnReason().toString().equalsIgnoreCase("BREEDING") && !event.getSpawnReason().toString().equalsIgnoreCase("EGG"))
|
||||
return;
|
||||
|
||||
|
@ -5,13 +5,19 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.sign.SignSide;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.inventory.SmithItemEvent;
|
||||
import org.bukkit.event.player.PlayerSignOpenEvent;
|
||||
import org.bukkit.event.player.PlayerSignOpenEvent.Cause;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
@ -36,4 +42,56 @@ public class PlayerSignEdit1_20Listeners implements Listener {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryCraft(SmithItemEvent event) {
|
||||
|
||||
// If event is nothing or place, do nothing
|
||||
switch (event.getAction()) {
|
||||
case NOTHING:
|
||||
case PLACE_ONE:
|
||||
case PLACE_ALL:
|
||||
case PLACE_SOME:
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (event.getSlotType() != SlotType.CRAFTING)
|
||||
return;
|
||||
|
||||
if (!event.isLeftClick() && !event.isRightClick())
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
return;
|
||||
|
||||
if (!(event.getWhoClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
//Check if inventory is full and using shift click, possible money dupping fix
|
||||
if (player.getInventory().firstEmpty() == -1 && event.isShiftClick()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!JobsPaymentListener.payIfCreative(player))
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(event.getInventory().getResult(), ActionType.CRAFT));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user