Skip to content

Commit

Permalink
Added true itemcondition support hopefully?
Browse files Browse the repository at this point in the history
  • Loading branch information
Xemorr committed Sep 25, 2021
1 parent e204bd2 commit c5f3b83
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.xemor</groupId>
<artifactId>skillslibrary</artifactId>
<version>2.4.4</version>
<version>2.5.0</version>
<packaging>jar</packaging>

<name>SkillsLibrary</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -64,6 +65,11 @@ else if (condition instanceof LocationCondition && otherObject instanceof Locati
boolean result = locationCondition.isTrue(entity, (Location) objects[0]);
if (!result) return false;
}
else if (condition instanceof ItemStackCondition && otherObject instanceof ItemStackCondition && condition.getMode().runs(Mode.ITEM)) {
ItemStackCondition itemStackCondition = (ItemStackCondition) condition;
boolean result = itemStackCondition.isTrue(entity, (ItemStack) objects[0]);
if (!result) return false;
}
}
return true;
}
Expand All @@ -84,7 +90,12 @@ public boolean ORConditions(Entity entity, boolean exact, Object... objects) {
else if (condition instanceof LocationCondition && otherObject instanceof Location && condition.getMode().runs(Mode.LOCATION)) {
LocationCondition locationCondition = (LocationCondition) condition;
boolean result = locationCondition.isTrue(entity, (Location) objects[0]);
if (!result) return true;
if (result) return true;
}
else if (condition instanceof ItemStackCondition && otherObject instanceof ItemStackCondition && condition.getMode().runs(Mode.ITEM)) {
ItemStackCondition itemStackCondition = (ItemStackCondition) condition;
boolean result = itemStackCondition.isTrue(entity, (ItemStack) objects[0]);
if (result) return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;

public class ItemComparisonCondition extends Condition implements EntityCondition, TargetCondition {
public class ItemComparisonCondition extends Condition implements EntityCondition, TargetCondition, ItemStackCondition {

private EquipmentSlot equipmentSlot;
private int slot;
Expand Down Expand Up @@ -61,4 +61,8 @@ else if (entity instanceof Player) {
return false;
}

@Override
public boolean isTrue(Entity entity, ItemStack itemStack) {
return itemComparison.matches(itemStack);
}
}

0 comments on commit c5f3b83

Please sign in to comment.