Guild module works with ability targets

This commit is contained in:
Indyuce 2022-06-17 18:33:24 +02:00
parent 88da562ebd
commit 9004ce8ea1
3 changed files with 17 additions and 6 deletions

View File

@ -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());

View File

@ -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),
;

View File

@ -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;
}
}