Skip to content

Commit

Permalink
New Skill ANyone?
Browse files Browse the repository at this point in the history
Rift Vissage, Prevents Enderman from attacking/aggroing on you if you have pearls in your inventory
  • Loading branch information
NextdoorPsycho committed Aug 4, 2024
1 parent f3b9c5a commit 6970cab
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public SkillRift() {
registerAdaptation(new RiftGate());
registerAdaptation(new RiftBlink());
registerAdaptation(new RiftDescent());
registerAdaptation(new RiftVisage());
lasttp = new HashMap<>();
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
"title": "Legendary Miner",
"description": "Break 5,000,000 Blocks"
}

},
"items": {
"boundenderperal": {
Expand Down Expand Up @@ -1000,6 +999,11 @@
"description": "Gain Resistance when using Ender Items & Abilities",
"lore1": "+ Passive: Provides resistance when you use rift abilities, or Ender Items",
"lore2": "NOT Including Portable Enderchest, only things you can Consume"
},
"visage": {
"name": "Rift Visage",
"description": "Prevents Endermen from becoming aggressive if you have Enderpearls in your inventory.",
"lore1": "Endermen will not become aggressive if you have Enderpearls in your inventory."
}
},
"seaborn": {
Expand Down

0 comments on commit 6970cab

Please sign in to comment.