Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for slotted attributes #1447

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/tc/oc/pgm/flag/state/Carried.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
import tc.oc.pgm.flag.event.FlagCaptureEvent;
import tc.oc.pgm.flag.event.FlagStateChangeEvent;
import tc.oc.pgm.goals.events.GoalEvent;
import tc.oc.pgm.kits.ArmorType;
import tc.oc.pgm.kits.Kit;
import tc.oc.pgm.score.ScoreMatchModule;
import tc.oc.pgm.scoreboard.SidebarMatchModule;
import tc.oc.pgm.spawns.events.ParticipantDespawnEvent;
import tc.oc.pgm.teams.TeamFactory;
import tc.oc.pgm.teams.TeamMatchModule;
import tc.oc.pgm.util.inventory.ArmorType;
import tc.oc.pgm.util.named.NameStyle;

/** State of a flag when a player has picked it up and is wearing the banner on their head. */
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/java/tc/oc/pgm/itemmeta/ItemRule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tc.oc.pgm.itemmeta;

import static tc.oc.pgm.util.attribute.AttributeUtils.ATTRIBUTE_UTILS;
import static tc.oc.pgm.util.inventory.InventoryUtils.INVENTORY_UTILS;

import java.util.EnumSet;
Expand Down Expand Up @@ -43,14 +44,12 @@ public void apply(ItemStack stack) {

InventoryUtils.addEnchantments(meta, this.meta.getEnchants());

INVENTORY_UTILS.copyAttributeModifiers(meta, this.meta);
ATTRIBUTE_UTILS.copyAttributeModifiers(meta, this.meta);

Set<Material> canDestroy =
unionMaterials(
INVENTORY_UTILS.getCanDestroy(meta), INVENTORY_UTILS.getCanDestroy(this.meta));
Set<Material> canPlaceOn =
unionMaterials(
INVENTORY_UTILS.getCanPlaceOn(meta), INVENTORY_UTILS.getCanPlaceOn(this.meta));
Set<Material> canDestroy = unionMaterials(
INVENTORY_UTILS.getCanDestroy(meta), INVENTORY_UTILS.getCanDestroy(this.meta));
Set<Material> canPlaceOn = unionMaterials(
INVENTORY_UTILS.getCanPlaceOn(meta), INVENTORY_UTILS.getCanPlaceOn(this.meta));

if (!canDestroy.isEmpty()) INVENTORY_UTILS.setCanDestroy(meta, canDestroy);
if (!canPlaceOn.isEmpty()) INVENTORY_UTILS.setCanPlaceOn(meta, canPlaceOn);
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.*;
import org.bukkit.inventory.ItemStack;
import tc.oc.pgm.api.player.MatchPlayer;
import tc.oc.pgm.util.inventory.Slot;

/**
* Fired when an {@link ItemKit} is applied to a player. The kit can be modified through the
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/tc/oc/pgm/kits/ArmorKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.inventory.ItemStack;
import tc.oc.pgm.api.player.MatchPlayer;
import tc.oc.pgm.kits.tag.ItemModifier;
import tc.oc.pgm.util.inventory.ArmorType;

public class ArmorKit extends AbstractKit {
public static class ArmorItem {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/tc/oc/pgm/kits/ItemKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import tc.oc.pgm.api.player.MatchPlayer;
import tc.oc.pgm.kits.tag.ItemModifier;
import tc.oc.pgm.util.inventory.InventoryUtils;
import tc.oc.pgm.util.inventory.Slot;

public class ItemKit implements KitDefinition {
public static final int INFINITE_STACK_SIZE = 99;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/tc/oc/pgm/kits/KitMatchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import tc.oc.pgm.kits.tag.Grenade;
import tc.oc.pgm.kits.tag.ItemTags;
import tc.oc.pgm.util.event.ItemTransferEvent;
import tc.oc.pgm.util.inventory.Slot;

@ListenerScope(MatchScope.RUNNING)
public class KitMatchModule implements MatchModule, Listener {
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/java/tc/oc/pgm/kits/KitParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tc.oc.pgm.kits;

import static tc.oc.pgm.util.attribute.AttributeUtils.ATTRIBUTE_UTILS;
import static tc.oc.pgm.util.inventory.InventoryUtils.INVENTORY_UTILS;
import static tc.oc.pgm.util.nms.NMSHacks.NMS_HACKS;

Expand Down Expand Up @@ -59,8 +60,10 @@
import tc.oc.pgm.teams.TeamFactory;
import tc.oc.pgm.teams.Teams;
import tc.oc.pgm.util.bukkit.BukkitUtils;
import tc.oc.pgm.util.inventory.ArmorType;
import tc.oc.pgm.util.inventory.InventoryUtils;
import tc.oc.pgm.util.inventory.ItemMatcher;
import tc.oc.pgm.util.inventory.Slot;
import tc.oc.pgm.util.material.ItemMaterialData;
import tc.oc.pgm.util.material.MaterialData;
import tc.oc.pgm.util.material.Materials;
Expand Down Expand Up @@ -344,7 +347,7 @@ public SetMultimap<Attribute, AttributeModifier> parseAttributeModifiers(Element
if (attr != null) {
for (String modifierText : Splitter.on(";").split(attr.getValue())) {
var mod = XMLUtils.parseCompactAttributeModifier(attr, modifierText);
modifiers.put(mod.getKey(), mod.getValue());
modifiers.put(mod.getLeft(), mod.getRight());
}
}

Expand Down Expand Up @@ -536,7 +539,7 @@ public void parseItemMeta(Element el, ItemMeta meta) throws InvalidXMLException
}
}

INVENTORY_UTILS.applyAttributeModifiers(parseAttributeModifiers(el), meta);
ATTRIBUTE_UTILS.applyAttributeModifiers(parseAttributeModifiers(el), meta);

String customName = el.getAttributeValue("name");
if (customName != null) {
Expand Down
276 changes: 0 additions & 276 deletions core/src/main/java/tc/oc/pgm/kits/Slot.java

This file was deleted.

Loading