Fixed an issue with tool perm parents

This commit is contained in:
Indyuce 2022-02-12 12:23:30 +01:00
parent 0b734132e3
commit 9ddaa27360
3 changed files with 30 additions and 20 deletions

View File

@ -1,7 +1,10 @@
package net.Indyuce.mmocore.listener; package net.Indyuce.mmocore.listener;
import io.lumine.mythic.lib.api.event.PlayerAttackEvent; import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.skill.result.SkillResult;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent; import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent;
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
@ -15,6 +18,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import javax.annotation.Nullable;
import javax.inject.Provider;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,6 +33,7 @@ import java.util.Map;
* @author jules * @author jules
* @see {@link ClassTrigger} * @see {@link ClassTrigger}
*/ */
@Deprecated
public class ClassTriggers implements Listener { public class ClassTriggers implements Listener {
@Deprecated @Deprecated
@ -39,6 +45,7 @@ public class ClassTriggers implements Listener {
damageTriggers.put(DamageType.PROJECTILE, ClassTriggerType.PROJECTILE_DAMAGE); damageTriggers.put(DamageType.PROJECTILE, ClassTriggerType.PROJECTILE_DAMAGE);
damageTriggers.put(DamageType.WEAPON, ClassTriggerType.WEAPON_DAMAGE); damageTriggers.put(DamageType.WEAPON, ClassTriggerType.WEAPON_DAMAGE);
damageTriggers.put(DamageType.SKILL, ClassTriggerType.SKILL_DAMAGE); damageTriggers.put(DamageType.SKILL, ClassTriggerType.SKILL_DAMAGE);
damageTriggers.put(DamageType.UNARMED, ClassTriggerType.SKILL_DAMAGE);
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@ -68,25 +75,22 @@ public class ClassTriggers implements Listener {
applyTriggers(event.getPlayer(), ClassTriggerType.PLACE_BLOCK); applyTriggers(event.getPlayer(), ClassTriggerType.PLACE_BLOCK);
} }
private void applyTriggers(Player player, ClassTriggerType type) { private SkillResult applyTriggers(Player player, ClassTriggerType type) {
applyTriggers(PlayerData.get(player), type); return applyTriggers(PlayerData.get(player), type);
} }
private void applyTriggers(PlayerData player, ClassTriggerType type) { private SkillResult applyTriggers(PlayerData player, ClassTriggerType type) {
//return applyTriggers(player, type, () -> new TriggerMetadata(player.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND), null, null)); return applyTriggers(player, type, () -> new TriggerMetadata(player.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND), null, null));
}
@Nullable
private SkillResult applyTriggers(Player player, ClassTriggerType type, Provider<TriggerMetadata> triggerMetaProvider) {
return applyTriggers(PlayerData.get(player), type, triggerMetaProvider);
}
@Nullable
private SkillResult applyTriggers(PlayerData player, ClassTriggerType type, Provider<TriggerMetadata> triggerMetaProvider) {
ClassTrigger trigger = player.getProfess().getClassTrigger(type); ClassTrigger trigger = player.getProfess().getClassTrigger(type);
if (trigger != null) return trigger == null ? null : trigger.trigger(triggerMetaProvider.get());
trigger.trigger(player);
} }
// @Nullable
// private SkillResult applyTriggers(Player player, ClassTriggerType type, Provider<TriggerMetadata> triggerMetaProvider) {
// return applyTriggers(PlayerData.get(player), type, triggerMetaProvider);
// }
// @Nullable
// private SkillResult applyTriggers(PlayerData player, ClassTriggerType type, Provider<TriggerMetadata> triggerMetaProvider) {
// ClassTrigger trigger = player.getProfess().getClassTrigger(type);
// return trigger == null ? null : trigger.trigger(triggerMetaProvider.get());
// }
} }

View File

@ -113,8 +113,7 @@ public class RestrictionManager implements MMOCoreManager {
@Override @Override
protected void whenPostLoaded(ConfigurationSection config) { protected void whenPostLoaded(ConfigurationSection config) {
if (config.contains("parent")) parent = config.contains("parent") ? map.get(formatId(config.getString("parent"))) : null;
parent = map.get(UtilityMethods.enumName(config.getString("parent")));
for (String key : config.getStringList("can-mine")) for (String key : config.getStringList("can-mine"))
mineable.add(MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(key)).generateKey()); mineable.add(MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(key)).generateKey());
} }
@ -150,4 +149,8 @@ public class RestrictionManager implements MMOCoreManager {
return defaultSet; return defaultSet;
} }
} }
private String formatId(String str) {
return UtilityMethods.enumName(str.replace("?", ".").replace("%", "."));
}
} }

View File

@ -22,5 +22,8 @@ public enum ClassTriggerType {
WEAPON_DAMAGE, WEAPON_DAMAGE,
@Deprecated @Deprecated
SKILL_DAMAGE; SKILL_DAMAGE,
@Deprecated
UNARMED_DAMAGE;
} }