-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/commands
- Loading branch information
Showing
10 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
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
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
83 changes: 83 additions & 0 deletions
83
src/main/java/dev/sefiraat/netheopoiesis/implementation/commands/NetheoCommands.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,83 @@ | ||
package dev.sefiraat.netheopoiesis.implementation.commands; | ||
|
||
import co.aikar.commands.BaseCommand; | ||
import co.aikar.commands.annotation.CommandAlias; | ||
import co.aikar.commands.annotation.CommandCompletion; | ||
import co.aikar.commands.annotation.CommandPermission; | ||
import co.aikar.commands.annotation.Default; | ||
import co.aikar.commands.annotation.Description; | ||
import co.aikar.commands.annotation.Subcommand; | ||
import dev.sefiraat.netheopoiesis.Netheopoiesis; | ||
import dev.sefiraat.netheopoiesis.api.mobs.MobCap; | ||
import dev.sefiraat.netheopoiesis.api.mobs.MobCapType; | ||
import dev.sefiraat.netheopoiesis.managers.MobManager; | ||
import dev.sefiraat.netheopoiesis.utils.TextUtils; | ||
import dev.sefiraat.netheopoiesis.utils.Theme; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@CommandAlias("netheopoiesis|netheo") | ||
public class NetheoCommands extends BaseCommand { | ||
|
||
@Default | ||
public void onDefault(CommandSender sender) { | ||
sender.sendMessage(Theme.ERROR + "Please provide a valid subcommand."); | ||
} | ||
|
||
@Subcommand("MobCaps") | ||
@Description("Displays information about the various MobCaps") | ||
@CommandPermission("netheopoiesis.admin.mobcaps") | ||
public void viewMobCaps(CommandSender sender) { | ||
final MobCapType[] mobCapTypes = MobCapType.values(); | ||
final String[] messages = new String[mobCapTypes.length]; | ||
|
||
for (int i = 0; i < mobCapTypes.length; i++) { | ||
final MobCapType type = mobCapTypes[i]; | ||
final MobCap mobCap = MobManager.getInstance().getMobCap(type); | ||
messages[i] = TextUtils.toTitleCase(type.name()) + ": " + mobCap.count() + "/" + mobCap.getMaxAmount(); | ||
} | ||
|
||
for (String message : messages) { | ||
if (sender instanceof Player player) { | ||
player.sendMessage(Theme.CLICK_INFO.apply(message)); | ||
} else { | ||
Netheopoiesis.logInfo(message); | ||
} | ||
} | ||
} | ||
|
||
@Subcommand("PurgeMobCap") | ||
@Description("Kills all mobs from a specific Mob Cap") | ||
@CommandPermission("netheopoiesis.admin.mobcaps") | ||
@CommandCompletion("@MOB_CAPS") | ||
public void purgeMobCap(CommandSender sender, String mobCapType) { | ||
final MobCap mobCap = MobManager.getInstance().getMobCap(MobCapType.valueOf(mobCapType)); | ||
final String message = "Mob Cap Purged"; | ||
|
||
mobCap.killAllMobs(); | ||
if (sender instanceof Player player) { | ||
player.sendMessage(Theme.SUCCESS.apply(message)); | ||
} else { | ||
Netheopoiesis.logInfo(message); | ||
} | ||
} | ||
|
||
@Subcommand("PurgeAllMobCap") | ||
@Description("Kills all mobs from all Mob Caps") | ||
@CommandPermission("netheopoiesis.admin.mobcaps") | ||
public void purgeMobCap(CommandSender sender) { | ||
final String message = "All Mob Caps Purged"; | ||
|
||
for (MobCapType type : MobCapType.values()) { | ||
MobManager.getInstance().getMobCap(type).killAllMobs(); | ||
} | ||
|
||
if (sender instanceof Player player) { | ||
player.sendMessage(Theme.SUCCESS.apply(message)); | ||
} else { | ||
Netheopoiesis.logInfo(message); | ||
} | ||
} | ||
|
||
} | ||
|
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
3 changes: 0 additions & 3 deletions
3
src/main/java/dev/sefiraat/netheopoiesis/listeners/ManagedMobListener.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
31 changes: 31 additions & 0 deletions
31
src/main/java/dev/sefiraat/netheopoiesis/managers/DispatchManager.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,31 @@ | ||
package dev.sefiraat.netheopoiesis.managers; | ||
|
||
import co.aikar.commands.PaperCommandManager; | ||
import com.google.common.base.Preconditions; | ||
import dev.sefiraat.netheopoiesis.api.mobs.MobCapType; | ||
import dev.sefiraat.netheopoiesis.implementation.commands.NetheoCommands; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public final class DispatchManager extends PaperCommandManager { | ||
|
||
private static DispatchManager instance; | ||
|
||
public DispatchManager(Plugin plugin) { | ||
super(plugin); | ||
|
||
Preconditions.checkArgument(instance == null, "Cannot create a new instance of the DispatchManager"); | ||
instance = this; | ||
|
||
registerCommand(new NetheoCommands()); | ||
|
||
getCommandCompletions().registerCompletion( | ||
"MOB_CAPS", | ||
context -> Arrays.stream(MobCapType.values()) | ||
.map(Enum::name) | ||
.collect(Collectors.toSet()) | ||
); | ||
} | ||
} |
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
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