Fixed result amount issue

Fixed an issue where results only gave one item for crafting regardless of how many were set during the initial recipe creation.
This commit is contained in:
Paul Reilly 2020-07-12 20:02:57 -05:00
parent a5c024ee76
commit a084d42eb9
13 changed files with 90 additions and 17 deletions

View File

@ -2,8 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b7e3dfbd-dfc6-4dd5-b2c6-f110c120ecb3" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/main/java/dev/coomware/Craftable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/dev/coomware/Craftable.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/dev/coomware/CraftingListener.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/dev/coomware/Uncraftables.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/dev/coomware/Uncraftables.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/Uncraftables-1.0.0.jar" beforeDir="false" afterPath="$PROJECT_DIR$/target/Uncraftables-1.0.0.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/dev/coomware/Uncraftables.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/dev/coomware/Uncraftables.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -60,26 +67,26 @@
<screen x="0" y="0" width="1280" height="720" />
</state>
<state x="446" y="70" key="#com.intellij.ide.util.MemberChooser/0.0.1280.720@0.0.1280.720" timestamp="1594491647536" />
<state width="1236" height="176" key="GridCell.Tab.0.bottom" timestamp="1594597775340">
<state width="1236" height="176" key="GridCell.Tab.0.bottom" timestamp="1594602136658">
<screen x="0" y="0" width="1280" height="720" />
</state>
<state width="1236" height="176" key="GridCell.Tab.0.bottom/0.0.1280.720@0.0.1280.720" timestamp="1594597775340" />
<state width="1236" height="176" key="GridCell.Tab.0.center" timestamp="1594597775340">
<state width="1236" height="176" key="GridCell.Tab.0.bottom/0.0.1280.720@0.0.1280.720" timestamp="1594602136658" />
<state width="1236" height="176" key="GridCell.Tab.0.center" timestamp="1594602136657">
<screen x="0" y="0" width="1280" height="720" />
</state>
<state width="1236" height="176" key="GridCell.Tab.0.center/0.0.1280.720@0.0.1280.720" timestamp="1594597775340" />
<state width="1236" height="176" key="GridCell.Tab.0.left" timestamp="1594597775340">
<state width="1236" height="176" key="GridCell.Tab.0.center/0.0.1280.720@0.0.1280.720" timestamp="1594602136657" />
<state width="1236" height="176" key="GridCell.Tab.0.left" timestamp="1594602136657">
<screen x="0" y="0" width="1280" height="720" />
</state>
<state width="1236" height="176" key="GridCell.Tab.0.left/0.0.1280.720@0.0.1280.720" timestamp="1594597775340" />
<state width="1236" height="176" key="GridCell.Tab.0.right" timestamp="1594597775340">
<state width="1236" height="176" key="GridCell.Tab.0.left/0.0.1280.720@0.0.1280.720" timestamp="1594602136657" />
<state width="1236" height="176" key="GridCell.Tab.0.right" timestamp="1594602136657">
<screen x="0" y="0" width="1280" height="720" />
</state>
<state width="1236" height="176" key="GridCell.Tab.0.right/0.0.1280.720@0.0.1280.720" timestamp="1594597775340" />
<state x="337" y="185" key="com.intellij.ide.util.TipDialog" timestamp="1594597702808">
<state width="1236" height="176" key="GridCell.Tab.0.right/0.0.1280.720@0.0.1280.720" timestamp="1594602136657" />
<state x="337" y="185" key="com.intellij.ide.util.TipDialog" timestamp="1594601247830">
<screen x="0" y="0" width="1280" height="720" />
</state>
<state x="337" y="185" key="com.intellij.ide.util.TipDialog/0.0.1280.720@0.0.1280.720" timestamp="1594597702808" />
<state x="337" y="185" key="com.intellij.ide.util.TipDialog/0.0.1280.720@0.0.1280.720" timestamp="1594601247830" />
<state x="303" y="41" width="672" height="678" key="search.everywhere.popup" timestamp="1594590229840">
<screen x="0" y="0" width="1280" height="720" />
</state>

View File

@ -6,7 +6,7 @@
<groupId>dev.coomware</groupId>
<artifactId>Uncraftables</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<repositories>
<repository>

View File

@ -0,0 +1,61 @@
package dev.coomware;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.plugin.Plugin;
public class CraftingListener implements Listener {
public CraftingListener(Plugin instance) {
instance.getServer().getPluginManager().registerEvents(this, instance);
}
@EventHandler
public void preCraftEvent(PrepareItemCraftEvent e) {
final Recipe recipe = e.getRecipe();
if (recipe == null) { return; }
final ItemStack result = recipe.getResult();
final CraftingInventory inv = e.getInventory();
if (e.isRepair()) { return; }
if (result.getType().equals(Material.NETHER_WART)) {
result.setAmount(9);
inv.setResult(result);
}
if (result.getType().equals(Material.CRYING_OBSIDIAN)) {
result.setAmount(2);
inv.setResult(result);
}
if (result.getType().equals(Material.BEDROCK)) {
result.setAmount(4);
inv.setResult(result);
}
}
@EventHandler
public void craftEvent(CraftItemEvent e) {
final ItemStack result = e.getRecipe().getResult();
final CraftingInventory inv = e.getInventory();
if (result.getType().equals(Material.NETHER_WART)) {
result.setAmount(9);
inv.setResult(result);
}
if (result.getType().equals(Material.CRYING_OBSIDIAN)) {
result.setAmount(2);
inv.setResult(result);
}
if (result.getType().equals(Material.BEDROCK)) {
result.setAmount(4);
inv.setResult(result);
}
}
}

View File

@ -1,5 +1,6 @@
package dev.coomware;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;
@ -18,10 +19,12 @@ public class Uncraftables extends JavaPlugin {
@Override
public void onEnable() {
new Craftable(this).craftables();
new CraftingListener(this);
Bukkit.getLogger().info("[Uncraftables] successfully loaded all recipes.");
}
@Override
public void onDisable() {
//
}
}

View File

@ -1,6 +1,6 @@
name: Uncraftables
main: dev.coomware.Uncraftables
version: 1.0.0
version: 1.0.1
author: CoomWare
description: Adds in crafting recipes for all uncraftable items.
api-version: 1.16

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: Uncraftables
main: dev.coomware.Uncraftables
version: 1.0.0
version: 1.0.1
author: CoomWare
description: Adds in crafting recipes for all uncraftable items.
api-version: 1.16

View File

@ -1,5 +1,5 @@
#Generated by Maven
#Sun Jul 12 18:27:05 CDT 2020
version=1.0.0
#Sun Jul 12 20:02:20 CDT 2020
version=1.0.1
groupId=dev.coomware
artifactId=Uncraftables

View File

@ -1,3 +1,4 @@
dev\coomware\Uncraftables.class
dev\coomware\Craftable.class
dev\coomware\CraftingListener.class
dev\coomware\CraftingUtils.class

View File

@ -1,3 +1,4 @@
C:\Users\Nilbog\Documents\NetBeansProjects\Uncraftables\src\main\java\dev\coomware\Uncraftables.java
C:\Users\Nilbog\Documents\NetBeansProjects\Uncraftables\src\main\java\dev\coomware\CraftingListener.java
C:\Users\Nilbog\Documents\NetBeansProjects\Uncraftables\src\main\java\dev\coomware\CraftingUtils.java
C:\Users\Nilbog\Documents\NetBeansProjects\Uncraftables\src\main\java\dev\coomware\Craftable.java