Search in sources :

Example 1 with TeamFilter

use of tc.oc.pgm.filters.TeamFilter in project PGM by PGMDev.

the class SpawnParser method parseAttributes.

public SpawnAttributes parseAttributes(Element el, SpawnAttributes parent) throws InvalidXMLException {
    PointProviderAttributes providerAttributes = pointParser.parseAttributes(el, parent.providerAttributes);
    Kit kit = factory.getKits().parseKitProperty(el, "kit", parent.kit);
    boolean sequential = XMLUtils.parseBoolean(el.getAttribute("sequential"), parent.sequential);
    boolean spread = XMLUtils.parseBoolean(el.getAttribute("spread"), parent.spread);
    boolean exclusive = XMLUtils.parseBoolean(el.getAttribute("exclusive"), parent.exclusive);
    boolean persistent = XMLUtils.parseBoolean(el.getAttribute("persistent"), parent.persistent);
    boolean newFilters = false;
    List<Filter> filters = new ArrayList<>();
    if (parent.filter != StaticFilter.ABSTAIN) {
        filters.add(parent.filter);
    }
    Node nodeTeam = Node.fromAttr(el, "team");
    if (nodeTeam != null) {
        if (!this.factory.hasModule(TeamModule.class)) {
            throw new InvalidXMLException("no teams defined", nodeTeam);
        }
        filters.add(new TeamFilter(Teams.getTeamRef(nodeTeam, this.factory)));
        newFilters = true;
    }
    Filter filter = this.factory.getFilters().parseFilterProperty(el, "filter");
    if (filter != null) {
        filters.add(filter);
        newFilters = true;
    }
    if (providerAttributes == parent.providerAttributes && kit == parent.kit && sequential == parent.sequential && spread == parent.spread && exclusive == parent.exclusive && persistent == parent.persistent && !newFilters) {
        return parent;
    } else {
        return new SpawnAttributes(AllFilter.of(filters), providerAttributes, kit, sequential, spread, exclusive, persistent);
    }
}
Also used : PointProviderAttributes(tc.oc.pgm.points.PointProviderAttributes) Filter(tc.oc.pgm.api.filter.Filter) AllFilter(tc.oc.pgm.filters.AllFilter) TeamFilter(tc.oc.pgm.filters.TeamFilter) StaticFilter(tc.oc.pgm.filters.StaticFilter) Kit(tc.oc.pgm.kits.Kit) Node(tc.oc.pgm.util.xml.Node) ArrayList(java.util.ArrayList) InvalidXMLException(tc.oc.pgm.util.xml.InvalidXMLException) TeamFilter(tc.oc.pgm.filters.TeamFilter) TeamModule(tc.oc.pgm.teams.TeamModule)

Example 2 with TeamFilter

use of tc.oc.pgm.filters.TeamFilter in project PGM by PGMDev.

the class RegionFilterApplicationParser method parseLane.

public void parseLane(Element el) throws InvalidXMLException {
    final Filter filter = new DenyFilter(new TeamFilter(Teams.getTeamRef(new Node(XMLUtils.getRequiredAttribute(el, "team")), factory)));
    final Region region = parseRegion(el);
    final Component message = translatable("match.laneExit");
    prepend(el, new RegionFilterApplication(RFAScope.PLAYER_ENTER, region, filter, message, false));
    prepend(el, new RegionFilterApplication(RFAScope.BLOCK_PLACE, new NegativeRegion(region), filter, message, false));
}
Also used : TeamFilter(tc.oc.pgm.filters.TeamFilter) DenyFilter(tc.oc.pgm.filters.DenyFilter) Filter(tc.oc.pgm.api.filter.Filter) StaticFilter(tc.oc.pgm.filters.StaticFilter) DenyFilter(tc.oc.pgm.filters.DenyFilter) Node(tc.oc.pgm.util.xml.Node) FilterNode(tc.oc.pgm.filters.FilterNode) Region(tc.oc.pgm.api.region.Region) TeamFilter(tc.oc.pgm.filters.TeamFilter) Component(net.kyori.adventure.text.Component)

Aggregations

Filter (tc.oc.pgm.api.filter.Filter)2 StaticFilter (tc.oc.pgm.filters.StaticFilter)2 TeamFilter (tc.oc.pgm.filters.TeamFilter)2 Node (tc.oc.pgm.util.xml.Node)2 ArrayList (java.util.ArrayList)1 Component (net.kyori.adventure.text.Component)1 Region (tc.oc.pgm.api.region.Region)1 AllFilter (tc.oc.pgm.filters.AllFilter)1 DenyFilter (tc.oc.pgm.filters.DenyFilter)1 FilterNode (tc.oc.pgm.filters.FilterNode)1 Kit (tc.oc.pgm.kits.Kit)1 PointProviderAttributes (tc.oc.pgm.points.PointProviderAttributes)1 TeamModule (tc.oc.pgm.teams.TeamModule)1 InvalidXMLException (tc.oc.pgm.util.xml.InvalidXMLException)1