Skip to content

Commit

Permalink
Curmarnds
Browse files Browse the repository at this point in the history
Feature/commands
  • Loading branch information
Sefiraat authored Jun 19, 2022
2 parents eddcfe4 + 072c61c commit 5d52b5a
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 15 deletions.
11 changes: 10 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -152,9 +156,14 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.1-SNAPSHOT</version>
</dependency>

<!-- Supported Plugins -->

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/sefiraat/netheopoiesis/Netheopoiesis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import dev.sefiraat.netheopoiesis.api.plant.netheos.NetheoBalls;
import dev.sefiraat.netheopoiesis.implementation.Items;
import dev.sefiraat.netheopoiesis.managers.ConfigManager;
import dev.sefiraat.netheopoiesis.managers.DispatchManager;
import dev.sefiraat.netheopoiesis.managers.ListenerManager;
import dev.sefiraat.netheopoiesis.managers.MobManager;
import dev.sefiraat.netheopoiesis.managers.TaskManager;
import dev.sefiraat.netheopoiesis.managers.SupportedPluginManager;
import dev.sefiraat.netheopoiesis.managers.TaskManager;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
import org.bstats.bukkit.Metrics;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class Netheopoiesis extends JavaPlugin implements SlimefunAddon {
private ListenerManager listenerManager;
private TaskManager taskManager;
private MobManager mobManager;
private DispatchManager dispatchManager;
private Purification purification;
private Registry registry;

Expand All @@ -59,6 +61,7 @@ public void onEnable() {
this.listenerManager = new ListenerManager();
this.taskManager = new TaskManager();
this.mobManager = new MobManager();
this.dispatchManager = new DispatchManager(this);
this.purification = new Purification();
this.registry = new Registry();

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/dev/sefiraat/netheopoiesis/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import dev.sefiraat.netheopoiesis.api.plant.netheos.Trade;
import dev.sefiraat.netheopoiesis.utils.TextUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Piglin;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
Expand All @@ -25,11 +24,8 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;

public class Registry {

Expand Down
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);
}
}

}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.sefiraat.netheopoiesis.implementation.groups;

import dev.sefiraat.netheopoiesis.Registry;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import dev.sefiraat.netheopoiesis.api.plant.netheos.Trade;
import dev.sefiraat.netheopoiesis.implementation.Groups;
import dev.sefiraat.netheopoiesis.utils.StatisticUtils;
Expand All @@ -19,9 +18,7 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package dev.sefiraat.netheopoiesis.listeners;

import dev.sefiraat.netheopoiesis.managers.MobManager;
import dev.sefiraat.netheopoiesis.utils.Keys;
import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.ItemStack;
Expand Down
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())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void addMob(@Nonnull MobCapType type, @Nonnull LivingEntity livingEntity)
*
* @param type The {@link MobCapType} to add the mob to
* @param livingEntity The {@link LivingEntity} being added
* @param bypassCap True if the mob should be added regardless of a cap
* @param bypassCap True if the mob should be added regardless of a cap
*/
public void addMob(@Nonnull MobCapType type, @Nonnull LivingEntity livingEntity, boolean bypassCap) {
addMob(type, livingEntity.getUniqueId(), bypassCap);
Expand Down
14 changes: 13 additions & 1 deletion src/main/resources/gitbook-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ Every Slimefun Tick, this plant has a {GROWTH_RATE_PERCENTAGE}% chance to grow a

### Purification Value

When placed in the Nether, this plant will add {PURIFICATION_VALUE} to the nearby purification value.
When placed in the Nether, this plant will add {PURIFICATION_VALUE} to the nearby purification value.

### Flavour Profile

Each seed can be ground into a paste

| Flavour | Flavour Strength |
|---------|------------------|
| Sweet | {FLAVOUR_SWEET} |
| Sour | {FLAVOUR_SOUR} |
| Salty | {FLAVOUR_SALTY} |
| Bitter | {FLAVOUR_BITTER} |
| Umami | {FLAVOUR_UMAMI} |
16 changes: 15 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ depend:
commands:
netheopoiesis:
description: /netheopoiesis
usage: /netheopoiesis <sub>
usage: /netheopoiesis <sub>
permissions:
netheopoiesis.*:
description: Provides permissions for all Netheo functions
default: op
children:
netheopoiesis.admin: true
netheopoiesis.admin:
description: Provides access to all Netheo admin functions
default: op
children:
netheopoiesis.admin.mobcaps: true
netheopoiesis.admin.mobcaps:
description: Allows the user to see and manage Nethero MobCaps
default: op

0 comments on commit 5d52b5a

Please sign in to comment.