forked from Upstream/mmocore
Fixes craftitem experience source providing XP when non-stackable is clicked
This commit is contained in:
parent
0749398e35
commit
09ebde5676
@ -11,6 +11,7 @@ import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
|
||||||
public class CraftItemExperienceSource extends SpecificExperienceSource<Material> {
|
public class CraftItemExperienceSource extends SpecificExperienceSource<Material> {
|
||||||
public final Material material;
|
public final Material material;
|
||||||
@ -25,9 +26,9 @@ public class CraftItemExperienceSource extends SpecificExperienceSource<Material
|
|||||||
@Override
|
@Override
|
||||||
public ExperienceManager<CraftItemExperienceSource> newManager() {
|
public ExperienceManager<CraftItemExperienceSource> newManager() {
|
||||||
return new ExperienceManager<CraftItemExperienceSource>() {
|
return new ExperienceManager<CraftItemExperienceSource>() {
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
|
||||||
public void a(CraftItemEvent event) {
|
public void a(CraftItemEvent event) {
|
||||||
|
if(event.getAction() == InventoryAction.NOTHING) return;
|
||||||
PlayerData data = PlayerData.get((Player) event.getWhoClicked());
|
PlayerData data = PlayerData.get((Player) event.getWhoClicked());
|
||||||
for (CraftItemExperienceSource source : getSources())
|
for (CraftItemExperienceSource source : getSources())
|
||||||
if (source.matches(data, event.getInventory().getResult().getType()))
|
if (source.matches(data, event.getInventory().getResult().getType()))
|
||||||
@ -36,6 +37,10 @@ public class CraftItemExperienceSource extends SpecificExperienceSource<Material
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void debug(Object s1, Object s2) {
|
||||||
|
System.out.println("[DEBUG] " + s1 + ": " + s2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(PlayerData player, Material obj) {
|
public boolean matches(PlayerData player, Material obj) {
|
||||||
return material == obj && hasRightClass(player);
|
return material == obj && hasRightClass(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user