-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rift Vissage, Prevents Enderman from attacking/aggroing on you if you have pearls in your inventory
- Loading branch information
1 parent
f3b9c5a
commit 6970cab
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/main/java/com/volmit/adapt/content/adaptation/rift/RiftVisage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.volmit.adapt.content.adaptation.rift; | ||
|
||
import com.volmit.adapt.api.adaptation.SimpleAdaptation; | ||
import com.volmit.adapt.util.C; | ||
import com.volmit.adapt.util.Element; | ||
import com.volmit.adapt.util.Localizer; | ||
import lombok.NoArgsConstructor; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Enderman; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.entity.EntityTargetEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class RiftVisage extends SimpleAdaptation<RiftVisage.Config> { | ||
public RiftVisage() { | ||
super("rift-visage"); | ||
registerConfiguration(Config.class); | ||
setDescription(Localizer.dLocalize("rift", "visage", "description")); | ||
setDisplayName(Localizer.dLocalize("rift", "visage", "name")); | ||
setIcon(Material.POPPED_CHORUS_FRUIT); | ||
setBaseCost(getConfig().baseCost); | ||
setCostFactor(getConfig().costFactor); | ||
setMaxLevel(getConfig().maxLevel); | ||
setInitialCost(getConfig().initialCost); | ||
setInterval(1000); | ||
} | ||
|
||
@Override | ||
public void addStats(int level, Element v) { | ||
v.addLore(C.ITALIC + Localizer.dLocalize("rift", "visage", "lore1")); | ||
} | ||
|
||
@EventHandler | ||
public void onEntityTarget(EntityTargetEvent event) { | ||
Entity entity = event.getEntity(); | ||
if (entity instanceof Enderman) { | ||
if (event.getTarget() instanceof Player player) { | ||
if (hasAdaptation(player) && hasEnderPearl(player)) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private boolean hasEnderPearl(Player player) { | ||
for (ItemStack item : player.getInventory().getContents()) { | ||
if (item != null && item.getType() == Material.ENDER_PEARL) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void onTick() { | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return getConfig().enabled; | ||
} | ||
|
||
@Override | ||
public boolean isPermanent() { | ||
return getConfig().permanent; | ||
} | ||
|
||
@NoArgsConstructor | ||
protected static class Config { | ||
boolean permanent = true; | ||
boolean enabled = true; | ||
int baseCost = 8; | ||
double costFactor = 0; | ||
int maxLevel = 1; | ||
int initialCost = 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters