studio.magemonkey.divinity.utils.actions.params.PartyMemberParam Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of divinity Show documentation
Show all versions of divinity Show documentation
Custom items, combat, and more!
The newest version!
package studio.magemonkey.divinity.utils.actions.params;
import studio.magemonkey.codex.util.actions.params.IAutoValidated;
import studio.magemonkey.codex.util.actions.params.IParamValue;
import studio.magemonkey.codex.util.actions.params.defaults.IParamBoolean;
import studio.magemonkey.divinity.api.PartyAPI;
import studio.magemonkey.divinity.modules.list.party.PartyManager;
import studio.magemonkey.divinity.modules.list.party.PartyManager.Party;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class PartyMemberParam extends IParamBoolean implements IAutoValidated {
public PartyMemberParam() {
super("PARTY_MEMBER", "party-member");
}
@Override
public void autoValidate(@NotNull Entity exe, @NotNull Set targets, @NotNull IParamValue val) {
if (!(exe instanceof Player)) return;
PartyManager manager = PartyAPI.getPartyManager();
if (manager == null) return;
Player executor = (Player) exe;
Party party = manager.getPlayerParty(executor);
if (party == null) return;
boolean b = val.getBoolean();
for (Entity e : new HashSet<>(targets)) {
if (e.getType() != EntityType.PLAYER) continue;
Player p = (Player) e;
boolean member = party.isMember(p);
if (member != b) {
targets.remove(e);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy