From 9004ce8ea15add155a4c5e5750c062c49fb7b2eb Mon Sep 17 00:00:00 2001 From: Indyuce Date: Fri, 17 Jun 2022 18:33:24 +0200 Subject: [PATCH] Guild module works with ability targets --- .../java/net/Indyuce/mmocore/MMOCore.java | 1 - .../mmocore/guild/GuildModuleType.java | 3 ++- .../party/MMOCoreTargetRestriction.java | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index 6c9c9454..72845b4c 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -124,7 +124,6 @@ public class MMOCore extends LuminePlugin { MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction()); MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject)); - // Register extra objective, drop items... if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) loadManager.registerLoader(new WorldGuardMMOLoader()); diff --git a/src/main/java/net/Indyuce/mmocore/guild/GuildModuleType.java b/src/main/java/net/Indyuce/mmocore/guild/GuildModuleType.java index dab5c398..cfbbaf25 100644 --- a/src/main/java/net/Indyuce/mmocore/guild/GuildModuleType.java +++ b/src/main/java/net/Indyuce/mmocore/guild/GuildModuleType.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.guild; import net.Indyuce.mmocore.guild.compat.GuildsGuildModule; +import net.Indyuce.mmocore.guild.compat.KingdomsXGuildModule; import net.Indyuce.mmocore.guild.compat.UltimateClansGuildModule; import net.Indyuce.mmocore.guild.provided.MMOCoreGuildModule; import org.bukkit.Bukkit; @@ -11,7 +12,7 @@ public enum GuildModuleType { // Useless since MythicLib already supports FactionBridge // FACTIONS("Factions", FactionsGuildModule::new), GUILDS("Guilds", GuildsGuildModule::new), - KINGDOMSX("Guilds", GuildsGuildModule::new), + KINGDOMSX("KingdomsX", KingdomsXGuildModule::new), MMOCORE("MMOCore", MMOCoreGuildModule::new), ULTIMATE_CLANS("UltimateClans", UltimateClansGuildModule::new), ; diff --git a/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java b/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java index e3603461..0e67bf43 100644 --- a/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java +++ b/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java @@ -4,6 +4,7 @@ import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.TargetRestriction; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.guild.AbstractGuild; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -11,11 +12,21 @@ public class MMOCoreTargetRestriction implements TargetRestriction { @Override public boolean canTarget(Player player, LivingEntity livingEntity, InteractionType interactionType) { - if (!interactionType.isOffense() || !(livingEntity instanceof Player) || livingEntity.hasMetadata("NPC")) + if (!interactionType.isOffense() || !(livingEntity instanceof Player)) return true; - AbstractParty party = MMOCore.plugin.partyModule.getParty(PlayerData.get(player)); - // TODO check for guild - return party == null || !party.hasMember((Player) livingEntity); + PlayerData data = PlayerData.get(player); + + // Check for party + AbstractParty party = MMOCore.plugin.partyModule.getParty(data); + if (party != null && party.hasMember((Player) livingEntity)) + return false; + + // Check for guild + AbstractGuild guild = MMOCore.plugin.guildModule.getGuild(data); + if (guild != null && guild.hasMember((Player) livingEntity)) + return false; + + return true; } }