Skip to content

Commit

Permalink
Added /foxymachines killall command
Browse files Browse the repository at this point in the history
  • Loading branch information
GallowsDove committed Apr 7, 2021
1 parent e0424fc commit d2d14cd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/me/gallowsdove/foxymachines/FoxyMachines.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.mooy1.infinitylib.commands.AbstractCommand;
import lombok.SneakyThrows;
import me.gallowsdove.foxymachines.abstracts.CustomBoss;
import me.gallowsdove.foxymachines.commands.KillallCommand;
import me.gallowsdove.foxymachines.commands.QuestCommand;
import me.gallowsdove.foxymachines.commands.SacrificialAltarCommand;
import me.gallowsdove.foxymachines.commands.SummonCommand;
Expand Down Expand Up @@ -66,6 +67,7 @@ protected List<AbstractCommand> getSubCommands() {
ArrayList<AbstractCommand> commands = new ArrayList<AbstractCommand>(Arrays.asList(new QuestCommand(), new SacrificialAltarCommand()));
if (getConfig().getBoolean("custom-mobs")) {
commands.add(new SummonCommand());
commands.add(new KillallCommand());
}
return commands;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package me.gallowsdove.foxymachines.commands;

import io.github.mooy1.infinitylib.commands.AbstractCommand;
import me.gallowsdove.foxymachines.abstracts.CustomMob;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

import javax.annotation.Nonnull;
import java.util.List;

public class KillallCommand extends AbstractCommand {
public KillallCommand() {
super("killall", "Kills all Custom Mobs from FoxyMachines.", "foxymachines.admin");
}

@Override
public void onExecute(@Nonnull CommandSender commandSender, @Nonnull String[] strings) {
if (!(commandSender instanceof Player) || strings.length != 1) {
return;
}

Player p = (Player) commandSender;

for (LivingEntity entity : p.getWorld().getLivingEntities()) {
CustomMob mob = CustomMob.getByEntity(entity);
if (mob != null) {
entity.remove();
}
}
}

@Override
public void onTab(@Nonnull CommandSender commandSender, @Nonnull String[] strings, @Nonnull List<String> list) { }
}

0 comments on commit d2d14cd

Please sign in to comment.