mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
add /mp, and refine /rd to only non-mobs by default
awesome
This commit is contained in:
parent
035b579fc1
commit
0b9f9d74ba
@ -23,7 +23,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.entitywipe", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name | -a]", aliases = "ew,rd")
|
||||
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name]", aliases = "ew,rd")
|
||||
public class EntityWipeCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
@ -62,12 +62,7 @@ public class EntityWipeCMD extends PlexCommand
|
||||
entity.teleportAsync(loc);
|
||||
entity.remove();
|
||||
|
||||
if (!entityCounts.containsKey(type))
|
||||
{
|
||||
entityCounts.put(type,0);
|
||||
}
|
||||
|
||||
entityCounts.put(type,entityCounts.get(type)+1);
|
||||
entityCounts.put(type,entityCounts.getOrDefault(type, 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
src/main/java/dev/plex/command/impl/MobPurgeCMD.java
Normal file
56
src/main/java/dev/plex/command/impl/MobPurgeCMD.java
Normal file
@ -0,0 +1,56 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||
public class MobPurgeCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
||||
{
|
||||
HashMap<String, Integer> entityCounts = new HashMap<>();
|
||||
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity instanceof Mob)
|
||||
{
|
||||
String type = entity.getType().name();
|
||||
|
||||
Location loc = entity.getLocation();
|
||||
loc.setY(-500);
|
||||
entity.teleportAsync(loc);
|
||||
entity.remove();
|
||||
|
||||
entityCounts.put(type,entityCounts.getOrDefault(type, 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int entityCount = entityCounts.values().stream().mapToInt(a -> a).sum();
|
||||
|
||||
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
||||
|
||||
entityCounts.forEach((entityName, numRemoved) -> {
|
||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
@ -64,8 +64,82 @@ global_gamerules:
|
||||
|
||||
# Mob limiter/Entity wiping config
|
||||
# All entities listed here will NOT be wiped upon wiping entities
|
||||
# By default this includes all mobs, as the mobpurge command can be used to purge mobs.
|
||||
entitywipe_list:
|
||||
- "item_frame"
|
||||
- "ITEM_FRAME"
|
||||
- "AXOLOTL"
|
||||
- "BAT"
|
||||
- "BEE"
|
||||
- "BLAZE"
|
||||
- "CAT"
|
||||
- "CAVE_SPIDER"
|
||||
- "CHICKEN"
|
||||
- "COD"
|
||||
- "COW"
|
||||
- "CREEPER"
|
||||
- "DOLPHIN"
|
||||
- "DONKEY"
|
||||
- "DROWNED"
|
||||
- "ELDER_GUARDIAN"
|
||||
- "ENDER_DRAGON"
|
||||
- "ENDERMAN"
|
||||
- "ENDERMITE"
|
||||
- "EVOKER"
|
||||
- "FOX"
|
||||
- "GHAST"
|
||||
- "GIANT"
|
||||
- "GLOW_SQUID"
|
||||
- "GOAT"
|
||||
- "GUARDIAN"
|
||||
- "HOGLIN"
|
||||
- "HORSE"
|
||||
- "HUSK"
|
||||
- "ILLUSIONER"
|
||||
- "IRON_GOLEM"
|
||||
- "LLAMA"
|
||||
- "MAGMA_CUBE"
|
||||
- "MULE"
|
||||
- "MUSHROOM_COW"
|
||||
- "OCELOT"
|
||||
- "PANDA"
|
||||
- "PARROT"
|
||||
- "PHANTOM"
|
||||
- "PIG"
|
||||
- "PIGLIN"
|
||||
- "PIGLIN_BRUTE"
|
||||
- "PILLAGER"
|
||||
- "POLAR_BEAR"
|
||||
- "RABBIT"
|
||||
- "RAVAGER"
|
||||
- "SALMON"
|
||||
- "SHEEP"
|
||||
- "SHULKER"
|
||||
- "SILVERFISH"
|
||||
- "SKELETON"
|
||||
- "SKELETON_HORSE"
|
||||
- "SLIME"
|
||||
- "SNOWMAN"
|
||||
- "SPIDER"
|
||||
- "SQUID"
|
||||
- "STRAY"
|
||||
- "STRIDER"
|
||||
- "TRADER_LLAMA"
|
||||
- "TROPICAL_FISH"
|
||||
- "TURTLE"
|
||||
- "VEX"
|
||||
- "VILLAGER"
|
||||
- "VINDICATOR"
|
||||
- "WANDERING_TRADER"
|
||||
- "WITCH"
|
||||
- "WITHER"
|
||||
- "WITHER_SKELETON"
|
||||
- "WOLF"
|
||||
- "ZOGLIN"
|
||||
- "ZOMBIE"
|
||||
- "ZOMBIE_HORSE"
|
||||
- "ZOMBIE_VILLAGER"
|
||||
- "ZOMBIFIED_PIGLIN"
|
||||
- "PUFFERFISH"
|
||||
|
||||
worlds:
|
||||
flatlands:
|
||||
|
@ -156,4 +156,7 @@ removedEntitiesOfTypes: "<red>{0} - Removed {1} entities of type(s) {2}"
|
||||
removedEntitiesOfType: "<gray>Removed {1} {2}"
|
||||
# 0 - Entity type that is invalid
|
||||
invalidEntityType: "<gray>Notice: Entity type {0} is invalid!"
|
||||
noRemovedEntities: "<gray>No entities were removed."
|
||||
noRemovedEntities: "<gray>No entities were removed."
|
||||
# 0 - The command sender
|
||||
# 1 - Number of mobs removed
|
||||
removedMobs: "<red>{0} - Removed {1} mobs"
|
Loading…
Reference in New Issue
Block a user