Skip to content

Commit

Permalink
Edited SelfDestruct and /elementals enchant should now override previ…
Browse files Browse the repository at this point in the history
…ous ones.
  • Loading branch information
Ankoki committed Jan 15, 2021
1 parent 8ef9068 commit ee38b90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Regrowth is a Prolonged Generic Spell which heals all players in the shown radiu
Rise is a Generic Spell which causes you to levitate on a cloud of particles for 10 seconds. This can be useful
when escaping enemies.
#### Self Destruct
Self Destruct is a Generic Spell which freezes you and causes an explosion around you with a high force.
Self Destruct is a Generic Spell which freezes you and causes an explosion around you with a high force. This most
likely will kill you.
#### Travel
Travel is a Generic Spell which allows you to teleport to the location you are looking at.
### Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public void elementalsHook(Player sender) {
public void enchantHook(Player player, Spell spell, ItemStack heldItem) {
if (heldItem.getType().isItem()) {
ItemManager wand = new ItemManager(heldItem);
wand.removeSpells();
wand.addSpell(spell);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), wand.getItem());
ItemStack item = wand.removeSpells().getItem();
ItemManager newWand = new ItemManager(item);
newWand.addSpell(spell);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newWand.getItem());
player.sendMessage(Messages.msg("on-enchant").replace("%spell%", spell.getSpellName()));
} else {
player.sendMessage(Messages.msg("enchant-blocks"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
Expand All @@ -16,22 +17,20 @@
@RequiredArgsConstructor
public class CastSelfDestruct implements GenericSpell {
private final Elementals plugin;
private final Spell spell = new Spell("Self Destruct", 3738, false);
private final Spell spell = new Spell("SelfDestruct", 3738, false);

@Override
public boolean onCast(Player player) {
new ParticlesManager(player, plugin).drawDome(Color.ORANGE, Color.RED, Color.YELLOW);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, Integer.MAX_VALUE));
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 40, 1));
new BukkitRunnable() {
final Location loc = player.getLocation();
final World world = loc.getWorld();
@Override
public void run() {
assert world != null; //There is no way world can be null in this situation
world.createExplosion(loc, 5L, true);
world.createExplosion(loc, 5L, true, true, player);
player.removePotionEffect(PotionEffectType.SLOW);
player.removePotionEffect(PotionEffectType.LEVITATION);
}
}.runTaskLater(plugin, 40L);
return true;
Expand Down

0 comments on commit ee38b90

Please sign in to comment.