1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Changed protection check (untested)

This commit is contained in:
Seggan 2020-10-05 17:02:09 -04:00
parent 4b3e31a8c7
commit a4dc1428bc

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
@ -17,6 +18,7 @@ import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Optional;
/**
* The {@link Listener} for the {@link ElytraCap}.
@ -41,8 +43,14 @@ public class ElytraCrashListener implements Listener {
SlimefunItem item = SlimefunItem.getByItem(stack);
if (!Slimefun.hasUnlocked(p, item, true)) return;
if (item instanceof ProtectiveArmor) {
if (!Arrays.asList(((ProtectiveArmor) item).getProtectionTypes())
.contains(ProtectionType.FLYING_INTO_WALL)) return;
Optional<PlayerProfile> optional = PlayerProfile.find(p);
if (!optional.isPresent()) {
PlayerProfile.request(p);
return;
}
PlayerProfile profile = optional.get();
if (profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) {
e.setDamage(0);
p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1);
if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) {
@ -51,4 +59,5 @@ public class ElytraCrashListener implements Listener {
}
}
}
}
}