Update TFMExtras for 2.0

This commit is contained in:
2026-05-19 13:42:51 -04:00
parent e503ee721d
commit b1ac03d044
19 changed files with 112 additions and 138 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000 networkTimeout=10000
retries=0 retries=0
retryBackOffMs=500 retryBackOffMs=500
+9 -5
View File
@@ -2,7 +2,7 @@ package dev.plex.extras;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath; import com.google.common.reflect.ClassPath;
import dev.plex.Plex; import dev.plex.api.PlexApi;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
@@ -10,7 +10,6 @@ import dev.plex.config.ModuleConfig;
import dev.plex.extras.jumppads.JumpPads; import dev.plex.extras.jumppads.JumpPads;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import dev.plex.util.PlexLog;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Collections; import java.util.Collections;
@@ -31,6 +30,11 @@ public class TFMExtras extends PlexModule
@Getter @Getter
private ModuleConfig config; private ModuleConfig config;
public static PlexApi plexApi()
{
return module.api();
}
@Override @Override
public void load() public void load()
{ {
@@ -38,7 +42,7 @@ public class TFMExtras extends PlexModule
config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml"); config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml");
config.load(); config.load();
jumpPads = new JumpPads(); jumpPads = new JumpPads();
// PlexLog.debug(String.valueOf(config.getInt("server.jumppad_strength"))); // plexApi().logging().debug(String.valueOf(config.getInt("server.jumppad_strength")));
} }
@Override @Override
@@ -131,14 +135,14 @@ public class TFMExtras extends PlexModule
} }
catch (ClassNotFoundException var4) catch (ClassNotFoundException var4)
{ {
PlexLog.error("Unable to find class " + info.getName() + " in " + packageName); plexApi().logging().error("Unable to find class {0} in {1}", info.getName(), packageName);
} }
}); });
} }
catch (IOException var4) catch (IOException var4)
{ {
PlexLog.error("Something went wrong while fetching classes from " + packageName); plexApi().logging().error("Something went wrong while fetching classes from {0}", packageName);
throw new RuntimeException(var4); throw new RuntimeException(var4);
} }
@@ -1,14 +1,12 @@
package dev.plex.extras.command; package dev.plex.extras.command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.cache.DataUtils; import dev.plex.api.player.PlexPlayerView;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.extras.TFMExtras; import dev.plex.extras.TFMExtras;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -27,31 +25,27 @@ public class AutoClearCommand extends PlexCommand
{ {
return usage(); return usage();
} }
PlexPlayer target = DataUtils.getPlayer(args[0]); PlexPlayerView target = TFMExtras.plexApi().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
if (target == null)
{
throw new PlayerNotFoundException();
}
List<String> names = TFMExtras.getModule().getConfig().getStringList("server.clear-on-join"); List<String> names = TFMExtras.getModule().getConfig().getStringList("server.clear-on-join");
boolean isEnabled = names.contains(target.getName()); boolean isEnabled = names.contains(target.name());
if (!isEnabled) if (!isEnabled)
{ {
names.add(target.getName()); names.add(target.name());
} }
else else
{ {
names.remove(target.getName()); names.remove(target.name());
} }
TFMExtras.getModule().getConfig().set("server.clear-on-join", names); TFMExtras.getModule().getConfig().set("server.clear-on-join", names);
TFMExtras.getModule().getConfig().save(); TFMExtras.getModule().getConfig().save();
isEnabled = !isEnabled; isEnabled = !isEnabled;
return messageComponent("modifiedAutoClear", target.getName(), isEnabled ? "now" : "no longer"); return messageComponent("modifiedAutoClear", target.name(), isEnabled ? "now" : "no longer");
} }
@Override @Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{ {
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? onlinePlayerNames() : ImmutableList.of();
} }
} }
@@ -1,14 +1,12 @@
package dev.plex.extras.command; package dev.plex.extras.command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.cache.DataUtils; import dev.plex.api.player.PlexPlayerView;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.extras.TFMExtras; import dev.plex.extras.TFMExtras;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -30,34 +28,30 @@ public class AutoTeleportCommand extends PlexCommand
{ {
return usage(); return usage();
} }
player.teleportAsync(TFMExtras.getRandomLocation(player.getWorld())); TFMExtras.plexApi().scheduler().runEntity(player, () -> player.teleportAsync(TFMExtras.getRandomLocation(player.getWorld())));
return null; return null;
} }
checkPermission(sender, "plex.tfmextras.autotp.other"); checkPermission(sender, "plex.tfmextras.autotp.other");
PlexPlayer target = DataUtils.getPlayer(args[0]); PlexPlayerView target = TFMExtras.plexApi().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
if (target == null)
{
throw new PlayerNotFoundException();
}
List<String> names = TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join"); List<String> names = TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join");
boolean isEnabled = names.contains(target.getName()); boolean isEnabled = names.contains(target.name());
if (!isEnabled) if (!isEnabled)
{ {
names.add(target.getName()); names.add(target.name());
} }
else else
{ {
names.remove(target.getName()); names.remove(target.name());
} }
TFMExtras.getModule().getConfig().set("server.teleport-on-join", names); TFMExtras.getModule().getConfig().set("server.teleport-on-join", names);
TFMExtras.getModule().getConfig().save(); TFMExtras.getModule().getConfig().save();
isEnabled = !isEnabled; isEnabled = !isEnabled;
return messageComponent("modifiedAutoTeleport", target.getName(), isEnabled ? "now" : "no longer"); return messageComponent("modifiedAutoTeleport", target.name(), isEnabled ? "now" : "no longer");
} }
@Override @Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{ {
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? onlinePlayerNames() : ImmutableList.of();
} }
} }
@@ -3,8 +3,7 @@ package dev.plex.extras.command;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import dev.plex.util.item.ItemBuilder;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -14,6 +13,7 @@ import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -21,21 +21,25 @@ import org.jetbrains.annotations.Nullable;
@CommandPermissions(permission = "plex.tfmextras.cake") @CommandPermissions(permission = "plex.tfmextras.cake")
public class CakeCommand extends PlexCommand public class CakeCommand extends PlexCommand
{ {
private static final ItemStack CAKE = new ItemBuilder(Material.CAKE) private static final ItemStack CAKE = cake();
.displayName(MiniMessage.miniMessage().deserialize("<!italic><white>The <dark_gray>Lie"))
.build();
@Override @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)
{ {
Bukkit.getOnlinePlayers().forEach(p -> Bukkit.getOnlinePlayers().forEach(p -> TFMExtras.plexApi().scheduler().runEntity(p, () -> p.getInventory().addItem(CAKE.clone())));
{ broadcast(messageComponent("cakeLyrics"));
p.getInventory().addItem(CAKE);
});
PlexUtils.broadcast(messageComponent("cakeLyrics"));
return null; return null;
} }
private static ItemStack cake()
{
ItemStack cake = new ItemStack(Material.CAKE);
ItemMeta meta = cake.getItemMeta();
meta.displayName(MiniMessage.miniMessage().deserialize("<!italic><white>The <dark_gray>Lie"));
cake.setItemMeta(meta);
return cake;
}
@Override @Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{ {
@@ -1,17 +1,15 @@
package dev.plex.extras.command; package dev.plex.extras.command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.Plex;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@@ -42,10 +40,8 @@ public class CartSitCommand extends PlexCommand
{ {
return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart!"); return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart!");
} }
findNearestEntity(player, minecart).whenComplete((entity, throwable) -> Entity entity = findNearestEntity(player, minecart);
{ TFMExtras.plexApi().scheduler().runEntity(entity, () -> entity.addPassenger(player));
Bukkit.getScheduler().runTask(Plex.get(), () -> entity.addPassenger(player));
});
return null; return null;
} }
Player target = getNonNullPlayer(args[0]); Player target = getNonNullPlayer(args[0]);
@@ -58,31 +54,22 @@ public class CartSitCommand extends PlexCommand
{ {
return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart near " + target.getName() + "!"); return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart near " + target.getName() + "!");
} }
findNearestEntity(target, minecart).whenComplete((entity, throwable) -> Entity entity = findNearestEntity(target, minecart);
{ TFMExtras.plexApi().scheduler().runEntity(entity, () -> entity.addPassenger(target));
Bukkit.getScheduler().runTask(Plex.get(), () -> entity.addPassenger(target));
});
return null; return null;
} }
public CompletableFuture<Entity> findNearestEntity(Player player, List<Entity> entities) public Entity findNearestEntity(Player player, List<Entity> entities)
{ {
return CompletableFuture.supplyAsync(() -> return entities.stream()
{ .min(Comparator.comparingDouble(entity -> player.getLocation().distanceSquared(entity.getLocation())))
Entity nearest = entities.getFirst(); .orElseThrow();
for (Entity e : entities) {
if (player.getLocation().distance(e.getLocation()) < player.getLocation().distance(nearest.getLocation())) {
nearest = e;
}
}
return nearest;
});
} }
@Override @Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{ {
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? onlinePlayerNames() : ImmutableList.of();
} }
} }
@@ -3,7 +3,7 @@ package dev.plex.extras.command;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -23,12 +23,15 @@ public class ClearChatCommand extends PlexCommand
Bukkit.getOnlinePlayers().stream().filter(p -> !silentCheckPermission(p, "plex.tfmextras.clearchat")) Bukkit.getOnlinePlayers().stream().filter(p -> !silentCheckPermission(p, "plex.tfmextras.clearchat"))
.forEach(p -> .forEach(p ->
{ {
for (int i = 0; i < 100; i++) TFMExtras.plexApi().scheduler().runEntity(p, () ->
{ {
send(p, ""); for (int i = 0; i < 100; i++)
} {
send(p, "");
}
});
}); });
PlexUtils.broadcast(messageComponent("chatCleared", sender.getName())); broadcast(messageComponent("chatCleared", sender.getName()));
return null; return null;
} }
@@ -3,7 +3,7 @@ package dev.plex.extras.command;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -26,12 +26,12 @@ public class CloudClearCommand extends PlexCommand
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args) protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
{ {
AtomicInteger removed = new AtomicInteger(); AtomicInteger removed = new AtomicInteger();
Bukkit.getWorlds().stream().map(World::getEntities).flatMap(Collection::stream).filter(entity -> entity.getType() == EntityType.AREA_EFFECT_CLOUD).peek(entity -> Bukkit.getWorlds().stream().map(World::getEntities).flatMap(Collection::stream).filter(entity -> entity.getType() == EntityType.AREA_EFFECT_CLOUD).forEach(entity ->
{ {
entity.remove();
removed.incrementAndGet(); removed.incrementAndGet();
TFMExtras.plexApi().scheduler().runEntity(entity, entity::remove);
}); });
PlexUtils.broadcast(messageComponent("areaEffectCloudClear", sender.getName())); broadcast(messageComponent("areaEffectCloudClear", sender.getName()));
return MiniMessage.miniMessage().deserialize("<gray>" + removed.get() + " area effect clouds removed."); return MiniMessage.miniMessage().deserialize("<gray>" + removed.get() + " area effect clouds removed.");
} }
@@ -1,13 +1,11 @@
package dev.plex.extras.command; package dev.plex.extras.command;
import dev.plex.cache.DataUtils; import dev.plex.api.player.PlexPlayerView;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.extras.TFMExtras; import dev.plex.extras.TFMExtras;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Material; import org.bukkit.Material;
@@ -37,7 +35,7 @@ public class ClownfishCommand extends PlexCommand
meta.displayName(Component.text("Clownfish")); meta.displayName(Component.text("Clownfish"));
clownfish.setItemMeta(meta); clownfish.setItemMeta(meta);
player.getInventory().addItem(clownfish); TFMExtras.plexApi().scheduler().runEntity(player, () -> player.getInventory().addItem(clownfish));
return MiniMessage.miniMessage().deserialize("<rainbow>blub blub... ><_>"); return MiniMessage.miniMessage().deserialize("<rainbow>blub blub... ><_>");
} }
else if (args[0].equals("toggle")) else if (args[0].equals("toggle"))
@@ -63,28 +61,24 @@ public class ClownfishCommand extends PlexCommand
{ {
if (silentCheckPermission(commandSender, "plex.tfmextras.clownfish.restrict")) if (silentCheckPermission(commandSender, "plex.tfmextras.clownfish.restrict"))
{ {
PlexPlayer target = DataUtils.getPlayer(args[1]); PlexPlayerView target = TFMExtras.plexApi().players().byName(args[1]).orElseThrow(PlayerNotFoundException::new);
if (target == null)
{
throw new PlayerNotFoundException();
}
List<String> restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted"); List<String> restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted");
boolean isRestricted = restrictedPlayers.contains(target.getUuid().toString()); boolean isRestricted = restrictedPlayers.contains(target.uuid().toString());
if (isRestricted) if (isRestricted)
{ {
restrictedPlayers.remove(target.getUuid().toString()); restrictedPlayers.remove(target.uuid().toString());
} }
else else
{ {
restrictedPlayers.add(target.getUuid().toString()); restrictedPlayers.add(target.uuid().toString());
} }
TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers); TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers);
TFMExtras.getModule().getConfig().save(); TFMExtras.getModule().getConfig().save();
return messageComponent("restrictClownfish", target.getName(), isRestricted ? "now" : "no longer"); return messageComponent("restrictClownfish", target.name(), isRestricted ? "now" : "no longer");
} }
else else
{ {
@@ -107,7 +101,7 @@ public class ClownfishCommand extends PlexCommand
} }
else if (args.length == 2 && args[0].equals("restrict")) else if (args.length == 2 && args[0].equals("restrict"))
{ {
return PlexUtils.getPlayerNameList(); return onlinePlayerNames();
} }
} }
else if (args.length == 1) else if (args.length == 1)
@@ -4,6 +4,7 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.extras.TFMExtras;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -21,7 +22,7 @@ public class EjectCommand extends PlexCommand
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(); final int passengers = player.getPassengers().size();
player.eject(); TFMExtras.plexApi().scheduler().runEntity(player, player::eject);
return MiniMessage.miniMessage().deserialize("<gray>Ejected " + passengers + " passengers."); return MiniMessage.miniMessage().deserialize("<gray>Ejected " + passengers + " passengers.");
} }
@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -29,16 +29,19 @@ public class EnglishMfCommand extends PlexCommand
return usage(); return usage();
} }
Player target = getNonNullPlayer(args[0]); Player target = getNonNullPlayer(args[0]);
target.sendMessage(mmString("<red>ENGLISH MOTHERFUCKER, Do you speak it!?")); TFMExtras.plexApi().scheduler().runEntity(target, () ->
PlexUtils.broadcast("<red>" + sender.getName() + " is sick of " + target.getName() + " not speaking English!"); {
target.setHealth(0); target.sendMessage(mmString("<red>ENGLISH MOTHERFUCKER, Do you speak it!?"));
target.getWorld().strikeLightningEffect(target.getLocation()); target.setHealth(0);
target.getWorld().strikeLightningEffect(target.getLocation());
});
broadcast("<red>" + sender.getName() + " is sick of " + target.getName() + " not speaking English!");
return null; return null;
} }
@Override @Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{ {
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? onlinePlayerNames() : ImmutableList.of();
} }
} }
@@ -7,7 +7,6 @@ import dev.plex.command.source.RequiredCommandSource;
import dev.plex.extras.TFMExtras; import dev.plex.extras.TFMExtras;
import dev.plex.extras.jumppads.JumpPads; import dev.plex.extras.jumppads.JumpPads;
import dev.plex.extras.jumppads.Mode; import dev.plex.extras.jumppads.Mode;
import dev.plex.util.PlexUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -130,7 +129,7 @@ public class JumpPadsCommand extends PlexCommand
} }
else if (args.length == 2) else if (args.length == 2)
{ {
return PlexUtils.getPlayerNameList(); return onlinePlayerNames();
} }
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.util.PlexUtils; import dev.plex.extras.TFMExtras;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -15,15 +15,15 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@CommandParameters(name = "orbit", description = "Accelerates the player at a super fast rate", usage = "/<command> <target> [<<power> | stop>]") @CommandParameters(name = "orbit", description = "Accelerates the player at a super fast rate", usage = "/<command> <target> [<<power> | stop>]")
@CommandPermissions(permission = "plex.tfmextras.orbit") @CommandPermissions(permission = "plex.tfmextras.orbit")
public class OrbitCommand extends PlexCommand public class OrbitCommand extends PlexCommand
{ {
private static final Map<UUID, Integer> isOrbited = new HashMap<>(); private static final Map<UUID, Integer> isOrbited = new ConcurrentHashMap<>();
@Override @Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args) protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
@@ -61,7 +61,7 @@ public class OrbitCommand extends PlexCommand
} }
startOrbiting(targetPlayer, strength); startOrbiting(targetPlayer, strength);
PlexUtils.broadcast(messageComponent("playerOrbited", sender.getName(), targetPlayer.getName())); broadcast(messageComponent("playerOrbited", sender.getName(), targetPlayer.getName()));
return null; return null;
} }
@@ -70,7 +70,7 @@ public class OrbitCommand extends PlexCommand
{ {
if (args.length == 1 && silentCheckPermission(sender, this.getPermission())) if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
{ {
return PlexUtils.getPlayerNameList(); return onlinePlayerNames();
} }
else if (args.length == 2 && silentCheckPermission(sender, this.getPermission())) else if (args.length == 2 && silentCheckPermission(sender, this.getPermission()))
{ {
@@ -81,15 +81,18 @@ public class OrbitCommand extends PlexCommand
private void startOrbiting(Player player, int strength) private void startOrbiting(Player player, int strength)
{ {
player.setGameMode(org.bukkit.GameMode.SURVIVAL); TFMExtras.plexApi().scheduler().runEntity(player, () ->
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false)); {
isOrbited.put(player.getUniqueId(), strength); player.setGameMode(org.bukkit.GameMode.SURVIVAL);
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false));
isOrbited.put(player.getUniqueId(), strength);
});
} }
private void stopOrbiting(Player player) private void stopOrbiting(Player player)
{ {
player.removePotionEffect(PotionEffectType.LEVITATION);
isOrbited.remove(player.getUniqueId()); isOrbited.remove(player.getUniqueId());
TFMExtras.plexApi().scheduler().runEntity(player, () -> player.removePotionEffect(PotionEffectType.LEVITATION));
} }
public static boolean isPlayerOrbited(UUID playerId) public static boolean isPlayerOrbited(UUID playerId)
@@ -4,12 +4,14 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.extras.TFMExtras;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@@ -31,7 +33,8 @@ public class RandomFishCommand extends PlexCommand
{ {
return MiniMessage.miniMessage().deserialize("<red>There is no block within 15 blocks of you."); return MiniMessage.miniMessage().deserialize("<red>There is no block within 15 blocks of you.");
} }
player.getWorld().spawnEntity(block.getLocation().add(0, 1, 0), randomFish()); Location location = block.getLocation().add(0, 1, 0);
TFMExtras.plexApi().scheduler().runRegion(location, () -> location.getWorld().spawnEntity(location, randomFish()));
return MiniMessage.miniMessage().deserialize(":goodbird:"); return MiniMessage.miniMessage().deserialize(":goodbird:");
} }
@@ -4,6 +4,7 @@ import dev.plex.extras.TFMExtras;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
@@ -14,7 +15,7 @@ import org.bukkit.util.Vector;
public class JumpPads public class JumpPads
{ {
public final Map<UUID, Mode> playerModeMap = new HashMap<>(); public final Map<UUID, Mode> playerModeMap = new ConcurrentHashMap<>();
public final double SCALAR = 0.8; public final double SCALAR = 0.8;
public final double STRENGTH = TFMExtras.getModule().getConfig().getInt("server.jumppad_strength", 1) + 0.1F; public final double STRENGTH = TFMExtras.getModule().getConfig().getInt("server.jumppad_strength", 1) + 0.1F;
public final double EXTREME = STRENGTH + 0.5; public final double EXTREME = STRENGTH + 0.5;
@@ -60,4 +61,4 @@ public class JumpPads
public record Wrap(int x, int y, int z) public record Wrap(int x, int y, int z)
{ {
} }
} }
@@ -4,7 +4,6 @@ import dev.plex.extras.TFMExtras;
import dev.plex.extras.jumppads.JumpPads; import dev.plex.extras.jumppads.JumpPads;
import dev.plex.extras.jumppads.Mode; import dev.plex.extras.jumppads.Mode;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.util.PlexLog;
import java.util.Map; import java.util.Map;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@@ -44,7 +43,7 @@ public class JumpPadsListener extends PlexListener
{ {
vector = vector.multiply(new Vector(0, -1, 0)); vector = vector.multiply(new Vector(0, -1, 0));
} }
PlexLog.debug("New Velocity: {0}", vector.toString()); TFMExtras.plexApi().logging().debug("New Velocity: {0}", vector.toString());
player.setFallDistance(0); player.setFallDistance(0);
player.setVelocity(vector); player.setVelocity(vector);
} }
@@ -1,8 +1,7 @@
package dev.plex.extras.listener; package dev.plex.extras.listener;
import dev.plex.Plex; import dev.plex.extras.TFMExtras;
import dev.plex.extras.command.OrbitCommand; import dev.plex.extras.command.OrbitCommand;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -23,7 +22,7 @@ public class OrbitEffectListener extends PlexListener
if ((event.getAction() == EntityPotionEffectEvent.Action.CLEARED || event.getAction() == EntityPotionEffectEvent.Action.REMOVED) if ((event.getAction() == EntityPotionEffectEvent.Action.CLEARED || event.getAction() == EntityPotionEffectEvent.Action.REMOVED)
&& event.getModifiedType() == PotionEffectType.LEVITATION) && event.getModifiedType() == PotionEffectType.LEVITATION)
{ {
Bukkit.getScheduler().runTaskLater(Plex.get(), () -> TFMExtras.plexApi().scheduler().runEntityLater(player, () ->
{ {
if (OrbitCommand.isPlayerOrbited(player.getUniqueId())) if (OrbitCommand.isPlayerOrbited(player.getUniqueId()))
{ {
@@ -40,12 +39,13 @@ public class OrbitEffectListener extends PlexListener
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
Bukkit.getScheduler().runTaskLater(Plex.get(), () -> GameMode newGameMode = event.getNewGameMode();
TFMExtras.plexApi().scheduler().runEntityLater(player, () ->
{ {
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()) && event.getNewGameMode() != GameMode.SURVIVAL) if (OrbitCommand.isPlayerOrbited(player.getUniqueId()) && newGameMode != GameMode.SURVIVAL)
{ {
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
} }
}, 2); }, 2);
} }
} }
@@ -1,11 +1,9 @@
package dev.plex.extras.listener; package dev.plex.extras.listener;
import dev.plex.Plex;
import dev.plex.extras.TFMExtras; import dev.plex.extras.TFMExtras;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class PlayerListener extends PlexListener public class PlayerListener extends PlexListener
{ {
@@ -14,25 +12,11 @@ public class PlayerListener extends PlexListener
{ {
if (TFMExtras.getModule().getConfig().getStringList("server.clear-on-join").contains(event.getPlayer().getName())) if (TFMExtras.getModule().getConfig().getStringList("server.clear-on-join").contains(event.getPlayer().getName()))
{ {
new BukkitRunnable() TFMExtras.plexApi().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().getInventory().clear(), 1);
{
@Override
public void run()
{
event.getPlayer().getInventory().clear();
}
}.runTaskLater(Plex.get(), 1);
} }
if (TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join").contains(event.getPlayer().getName())) if (TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join").contains(event.getPlayer().getName()))
{ {
new BukkitRunnable() TFMExtras.plexApi().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().teleportAsync(TFMExtras.getRandomLocation(event.getPlayer().getWorld())), 1);
{
@Override
public void run()
{
event.getPlayer().teleportAsync(TFMExtras.getRandomLocation(event.getPlayer().getWorld()));
}
}.runTaskLater(Plex.get(), 1);
} }
} }
+2 -1
View File
@@ -1,4 +1,5 @@
name: Module-TFMExtras name: Module-TFMExtras
main: dev.plex.extras.TFMExtras main: dev.plex.extras.TFMExtras
description: TFM extras for Plex description: TFM extras for Plex
version: 1.6 version: 1.6
apiCompatibility: 1