Grammar fixes and update dependencies

This commit is contained in:
2023-03-08 13:30:51 -06:00
parent 91fd30495f
commit 4f779eecf6
20 changed files with 108 additions and 68 deletions

View File

@ -2,7 +2,7 @@ package dev.plex;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import dev.plex.command.*;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.config.ModuleConfig;
@ -12,20 +12,17 @@ import dev.plex.listener.PlayerListener;
import dev.plex.listener.PlexListener;
import dev.plex.module.PlexModule;
import dev.plex.util.PlexLog;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.World;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import dev.plex.util.ReflectionsUtil;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.World;
public class TFMExtras extends PlexModule
{
@Getter
@ -49,29 +46,36 @@ public class TFMExtras extends PlexModule
@Override
public void enable()
{
registerListener(new JumpPadsListener());
registerListener(new PlayerListener());
getClassesFrom("dev.plex.command").forEach(aClass -> {
getClassesFrom("dev.plex.command").forEach(aClass ->
{
if (aClass.getSuperclass() == PlexCommand.class && aClass.isAnnotationPresent(CommandParameters.class) && aClass.isAnnotationPresent(CommandPermissions.class))
{
try {
try
{
PlexCommand plexCommand = (PlexCommand) aClass.getConstructors()[0].newInstance();
registerCommand(plexCommand);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
}
catch (InstantiationException | IllegalAccessException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
});
getClassesFrom("dev.plex.listener").forEach(aClass -> {
getClassesFrom("dev.plex.listener").forEach(aClass ->
{
if (aClass.getSuperclass() == PlexListener.class)
{
try {
try
{
PlexListener plexListener = (PlexListener) aClass.getConstructors()[0].newInstance();
registerListener(plexListener);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
}
catch (InstantiationException | IllegalAccessException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
@ -83,7 +87,7 @@ public class TFMExtras extends PlexModule
addDefaultMessage("chatCleared", "<red>{0} - Cleared the chat", "0 - The command sender");
addDefaultMessage("attributeList", "<gold>All possible attributes: <yellow>{0}", "0 - The attribute list, each split by a new line");
addDefaultMessage("modifiedAutoClear", "<gold>{0} will {1} have their inventory cleared when they join.", "0 - The player who will have their inventory cleared on join", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
addDefaultMessage("modifiedAutoTeleport", "<gold>{0} will {1} have be teleported automatically when they join.", "0 - The player to be tp'd automatically", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
addDefaultMessage("modifiedAutoTeleport", "<gold>{0} will {1} be teleported automatically when they join.", "0 - The player to be teleported automatically", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
}
@Override
@ -96,26 +100,34 @@ public class TFMExtras extends PlexModule
{
double x = ThreadLocalRandom.current().nextDouble(-100000, 100000);
double z = ThreadLocalRandom.current().nextDouble(-100000, 100000);
double y = world.getHighestBlockYAt((int)x, (int)z) + 1;
double y = world.getHighestBlockYAt((int) x, (int) z) + 1;
return new Location(world, x, y, z);
}
private Set<Class<?>> getClassesFrom(String packageName) {
private Set<Class<?>> getClassesFrom(String packageName)
{
Set<Class<?>> classes = new HashSet();
try {
try
{
ClassPath path = ClassPath.from(TFMExtras.class.getClassLoader());
ImmutableSet<ClassPath.ClassInfo> infoSet = path.getTopLevelClasses(packageName);
infoSet.forEach((info) -> {
try {
infoSet.forEach((info) ->
{
try
{
Class<?> clazz = Class.forName(info.getName());
classes.add(clazz);
} catch (ClassNotFoundException var4) {
}
catch (ClassNotFoundException var4)
{
PlexLog.error("Unable to find class " + info.getName() + " in " + packageName);
}
});
} catch (IOException var4) {
}
catch (IOException var4)
{
PlexLog.error("Something went wrong while fetching classes from " + packageName);
throw new RuntimeException(var4);
}

View File

@ -4,7 +4,6 @@ import dev.plex.TFMExtras;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.CommandSender;
@ -12,6 +11,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandParameters(name = "admininfo", description = "Information on how to apply for admin", aliases = "ai,si,staffinfo")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.admininfo")
public class AdminInfoCommand extends PlexCommand

View File

@ -3,7 +3,6 @@ package dev.plex.command;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import java.util.Arrays;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.attribute.Attribute;
@ -12,6 +11,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@CommandParameters(name = "attributes", description = "Lists all possible attributes", aliases = "attributelist,attrlist")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.attrlist")
public class AttributeListCommand extends PlexCommand

View File

@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import java.util.List;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandParameters(name = "autoclear", description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>", aliases = "aclear,ac")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tfmextras.autoclear")
public class AutoClearCommand extends PlexCommand

View File

@ -7,7 +7,6 @@ import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import java.util.List;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@ -15,6 +14,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandParameters(name = "autoteleport", description = "If a player is specified, it will toggle whether or not the player is automatically teleported when they join. If no player is specified, you will be randomly teleported", usage = "/<command> [player]", aliases = "autotp,rtp,randomtp,tpr")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.autotp")
public class AutoTeleportCommand extends PlexCommand

View File

@ -4,7 +4,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.punishment.Punishment;
import dev.plex.rank.enums.Rank;
import java.util.stream.Collectors;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
@ -12,6 +11,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.stream.Collectors;
@CommandParameters(name = "banlist", description = "Manages the banlist", usage = "/<command> [purge]")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tfmextras.banlist")
public class BanListCommand extends PlexCommand

View File

@ -4,9 +4,6 @@ import dev.plex.Plex;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
@ -17,6 +14,10 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@CommandParameters(name = "cartsit", description = "Sit in nearest minecart. If target is in a minecart already, they will be ejected", aliases = "minecartsit")
@CommandPermissions(level = Rank.NONOP, permission = "plex.tfmextras.cartsit")
public class CartSitCommand extends PlexCommand

View File

@ -4,8 +4,6 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
@ -16,6 +14,9 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
@CommandParameters(name = "cloudclear", description = "Clears lingering potion area effect clouds", aliases = "clearcloud,aeclear")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tfmextras.cloudclear")
public class CloudClearCommand extends PlexCommand

View File

@ -1,6 +1,5 @@
package dev.plex.command;
import dev.plex.TFMExtras;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
@ -12,13 +11,13 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandParameters(name = "eject", description = "Removes all passengers from a player")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.eject", source = RequiredCommandSource.IN_GAME)
public class EjectCommand extends PlexCommand {
public class EjectCommand extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args) {
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
{
final int passengers = player.getPassengers().size();
player.eject();
return MiniMessage.miniMessage().deserialize("<gray>Ejected " + passengers + " passengers.");

View File

@ -22,9 +22,11 @@ import java.util.List;
@CommandParameters(name = "enchant", description = "Enchants an item", usage = "/<command> <add | reset | list | addall | remove>", aliases = "enchantment")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.enchant", source = RequiredCommandSource.IN_GAME)
public class EnchantCommand extends PlexCommand {
public class EnchantCommand extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args) {
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
{
if (args.length == 0)
{
return usage();
@ -58,13 +60,15 @@ public class EnchantCommand extends PlexCommand {
return null;
}
private List<Enchantment> getEnchantments(ItemStack item) {
private List<Enchantment> getEnchantments(ItemStack item)
{
List<Enchantment> enchants = Lists.newArrayList();
Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).forEach(enchants::add);
return enchants;
}
private String[] getEnchantmentNames(ItemStack item) {
private String[] getEnchantmentNames(ItemStack item)
{
return getEnchantments(item).stream().map(enchantment -> enchantment.key().value()).toArray(String[]::new);
}
}

View File

@ -8,9 +8,6 @@ import dev.plex.jumppads.JumpPads;
import dev.plex.jumppads.Mode;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
@ -20,7 +17,11 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "jumppads", usage = "/jumppads <mode> [player]", description = "Enables jump pads for yourself or another player. Mode types available: none, regular, enhanced, extreme, ultimate", aliases = "jp, pads, launchpads")
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@CommandParameters(name = "jumppads", usage = "/jumppads <mode> [player]", description = "Enables jump pads for yourself or another player. Mode types available: none, regular, enhanced, extreme, ultimate", aliases = "jp,pads,launchpads")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.jumppads", source = RequiredCommandSource.ANY)
public class JumpPadsCommand extends PlexCommand
{

View File

@ -4,9 +4,6 @@ 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 java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.block.Block;
@ -16,6 +13,10 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
@CommandParameters(name = "randomfish", description = "Spawns a random type of fish at your location", aliases = "rfish,bird")
@CommandPermissions(level = Rank.OP, permission = "plex.tfmextras.randomfish", source = RequiredCommandSource.IN_GAME)
public class RandomFishCommand extends PlexCommand

View File

@ -1,11 +1,6 @@
package dev.plex.jumppads;
import dev.plex.TFMExtras;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Block;
@ -13,6 +8,11 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
public class JumpPads
{
public final Map<UUID, Mode> playerModeMap = new HashMap<>();

View File

@ -59,7 +59,9 @@ public class JumpPadsListener extends PlexListener
if (jumpPads.wool.getValues().contains(b.getType()))
{
if (!(event.getFrom().getY() > block.getY() + 0.1 && ((int) event.getTo().getY() == block.getY())))
{
return;
}
if (w.y() == -1)
{
playerVector.add(new Vector(0.0, jumpPads.SCALAR * jumpPads.STRENGTH, 0.0));

View File

@ -1,4 +1,4 @@
name: Module-TFMExtras
main: dev.plex.TFMExtras
description: TFM extras for Plex
version: 1.2-SNAPSHOT
version: 1.3-SNAPSHOT

View File

@ -1,4 +1,4 @@
# TFM Extras Configuration File #
# TFM Extras Configuration File #
server:
# The strength of the Jump Pads. Must be a positive whole number. Not recommended being greater than 10.