Grammar fixes and update dependencies

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

View file

@ -1,24 +1,37 @@
For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when contributing however.
For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when
contributing however.
## Steps
1. Make an issue and get feedback. It's important to know if your idea will be accepted before writing any code.
- If it is a feature request, describe the feature and be extremely specific.
- If it is a bug report, ensure you include how to reproduce the bug and the expected outcome
- If it is an enhancement, describe your proposed changes. Ensure you are extremely specific.
2. Fork this project
3. Create a new branch that describes the new feature, enhancement, or bug fix. For example, this is good: `feature/add-xyz`. This is bad: `fix-this-lol`.
3. Create a new branch that describes the new feature, enhancement, or bug fix. For example, this is
good: `feature/add-xyz`. This is bad: `fix-this-lol`.
4. Write the code that addresses your change.
- Keep in mind that it **must** be formatted correctly. If you are using IntelliJ, there is a `codeStyle.xml` file that tells IntelliJ how to format your code. Check this link for information on how to use the file: https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes
- If you are not using IntelliJ, that is fine. We use the Plexus Code Style (which is almost the same as Allman) so please format your code accordingly.
- Keep in mind that it **must** be formatted correctly. If you are using IntelliJ, there is a `codeStyle.xml` file that
tells IntelliJ how to format your code. Check this link for information on how to use the
file: https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes
- If you are not using IntelliJ, that is fine. We use the Plexus Code Style (which is almost the same as Allman) so
please format your code accordingly.
6. Push your changes to your new branch and make a PR based off of that branch.
## Requirements for a PR
- The issue must be marked as approved
- It must only address each specific issue. Don't make one PR for multiple issues.
- Your PR must compile and work. If it does not compile or work, your PR will most likely be rejected.
## Code requirements
- Most importantly, your code must be efficient. Your pull request may be rejected if your code is deemed inefficient or sloppy.
- Most importantly, your code must be efficient. Your pull request may be rejected if your code is deemed inefficient or
sloppy.
- Do not repeat yourself. Create functions as needed if you're using large blocks of code over and over again.
- Do not use an excessive amount of commits when making your PR. It makes the master branch look messy.
- Your code must be consistent with Plex's codebase. If a function already exists, use it.

View file

@ -1,4 +1,6 @@
# Module-TFMExtras [![Build Status](https://ci.plex.us.org/job/Module-TFMExtras/badge/icon)](https://ci.plex.us.org/job/Module-TFMExtras/)
Adds extra commands to Plex which makes it behave more like TotalFreedomMod.
**Note:** Please do not use any code licensed under the TotalFreedom General License for this project. It is not allowed.
**Note:** Please do not use any code licensed under the TotalFreedom General License for this project. It is not
allowed.

View file

@ -16,16 +16,15 @@ repositories {
}
dependencies {
compileOnly("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24")
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
compileOnly("org.projectlombok:lombok:1.18.26")
annotationProcessor("org.projectlombok:lombok:1.18.26")
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
implementation("org.apache.commons:commons-lang3:3.12.0")
compileOnly("dev.plex:server:1.2-SNAPSHOT")
compileOnly("dev.plex:api:1.2-SNAPSHOT")
compileOnly("dev.plex:server:1.3-SNAPSHOT")
}
group = "dev.plex"
version = "1.2-SNAPSHOT"
version = "1.3-SNAPSHOT"
description = "Module-TFMExtras"
java {

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

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.