package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; import java.util.Set; import com.google.common.collect.Sets; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.FlagContext; import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; import com.sk89q.worldguard.protection.flags.SetFlag; public class CustomSetFlag extends SetFlag { public CustomSetFlag(String name, Flag subFlag) { super(name, subFlag); } @Override public Set parseInput(FlagContext context) throws InvalidFlagFormat { String input = context.getUserInput(); if (input.isEmpty()) { return Sets.newHashSet(); } else { Set items = Sets.newHashSet(); for (String str : input.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1)) { if (str.startsWith("\"") && str.endsWith("\"")) { str = str.substring(1, str.length() - 1); } FlagContext copy = context.copyWith(null, str, null); items.add(this.getType().parseInput(copy)); } return items; } } }