mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2026-06-04 07:36:54 +00:00
More refactoring
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package dev.plex.extras;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import dev.plex.api.PlexApi;
|
||||
import dev.plex.config.ModuleConfig;
|
||||
import dev.plex.extras.command.AdminInfoCommand;
|
||||
import dev.plex.extras.command.AutoClearCommand;
|
||||
@@ -20,14 +17,12 @@ import dev.plex.extras.command.JumpPadsCommand;
|
||||
import dev.plex.extras.command.OrbitCommand;
|
||||
import dev.plex.extras.command.RandomFishCommand;
|
||||
import dev.plex.extras.jumppads.JumpPads;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.extras.listener.ClownfishListener;
|
||||
import dev.plex.extras.listener.JumpPadsListener;
|
||||
import dev.plex.extras.listener.OrbitEffectListener;
|
||||
import dev.plex.extras.listener.PlayerListener;
|
||||
import dev.plex.module.PlexModule;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
@@ -36,65 +31,47 @@ import org.bukkit.World;
|
||||
public class TFMExtras extends PlexModule
|
||||
{
|
||||
@Getter
|
||||
private static TFMExtras module;
|
||||
|
||||
public JumpPads jumpPads;
|
||||
private JumpPads jumpPads;
|
||||
|
||||
@Getter
|
||||
private ModuleConfig config;
|
||||
|
||||
public static PlexApi plexApi()
|
||||
{
|
||||
return module.api();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
module = this;
|
||||
config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml");
|
||||
config.load();
|
||||
loadMessages("tfmextras/messages.yml");
|
||||
jumpPads = new JumpPads();
|
||||
jumpPads = new JumpPads(config.getInt("server.jumppad_strength", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
List.of(
|
||||
new AdminInfoCommand(),
|
||||
new AutoClearCommand(),
|
||||
new AutoTeleportCommand(),
|
||||
new AdminInfoCommand(this),
|
||||
new AutoClearCommand(this),
|
||||
new AutoTeleportCommand(this),
|
||||
new CakeCommand(),
|
||||
new CartSitCommand(),
|
||||
new ClearChatCommand(),
|
||||
new ClownfishCommand(),
|
||||
new ClownfishCommand(this),
|
||||
new CloudClearCommand(),
|
||||
new EjectCommand(),
|
||||
new EnchantCommand(),
|
||||
new EnglishMfCommand(),
|
||||
new ExpelCommand(),
|
||||
new JumpPadsCommand(),
|
||||
new JumpPadsCommand(this),
|
||||
new OrbitCommand(),
|
||||
new RandomFishCommand()
|
||||
).forEach(this::registerCommand);
|
||||
|
||||
getClassesFrom("dev.plex.extras.listener").forEach(aClass ->
|
||||
{
|
||||
if (PlexListener.class.isAssignableFrom(aClass))
|
||||
{
|
||||
try
|
||||
{
|
||||
PlexListener plexListener = (PlexListener)aClass.getConstructors()[0].newInstance();
|
||||
registerListener(plexListener);
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List.of(
|
||||
new ClownfishListener(this),
|
||||
new JumpPadsListener(this),
|
||||
new OrbitEffectListener(this),
|
||||
new PlayerListener(this)
|
||||
).forEach(this::registerListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,42 +80,11 @@ public class TFMExtras extends PlexModule
|
||||
// Unregistering listeners / commands is handled by Plex
|
||||
}
|
||||
|
||||
public static Location getRandomLocation(World world)
|
||||
public Location getRandomLocation(World world)
|
||||
{
|
||||
double x = ThreadLocalRandom.current().nextDouble(-100000, 100000);
|
||||
double z = ThreadLocalRandom.current().nextDouble(-100000, 100000);
|
||||
double y = world.getHighestBlockYAt((int)x, (int)z) + 1;
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
private Set<Class<?>> getClassesFrom(String packageName)
|
||||
{
|
||||
Set<Class<?>> classes = new HashSet<>();
|
||||
|
||||
try
|
||||
{
|
||||
ClassPath path = ClassPath.from(TFMExtras.class.getClassLoader());
|
||||
ImmutableSet<ClassPath.ClassInfo> infoSet = path.getTopLevelClasses(packageName);
|
||||
infoSet.forEach((info) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = Class.forName(info.getName());
|
||||
classes.add(clazz);
|
||||
}
|
||||
catch (ClassNotFoundException var4)
|
||||
{
|
||||
plexApi().logging().error("Unable to find class {0} in {1}", info.getName(), packageName);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (IOException var4)
|
||||
{
|
||||
plexApi().logging().error("Something went wrong while fetching classes from {0}", packageName);
|
||||
throw new RuntimeException(var4);
|
||||
}
|
||||
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,25 +13,28 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AdminInfoCommand extends SimplePlexCommand
|
||||
{
|
||||
public AdminInfoCommand()
|
||||
private final TFMExtras module;
|
||||
|
||||
public AdminInfoCommand(TFMExtras module)
|
||||
{
|
||||
super(command("admininfo")
|
||||
.description("Information on how to apply for admin")
|
||||
.aliases("ai,si,staffinfo")
|
||||
.permission("plex.tfmextras.admininfo")
|
||||
.build());
|
||||
this.module = module;
|
||||
}
|
||||
private static final List<Component> ADMIN_INFO = TFMExtras.getModule().getConfig().getStringList("server.admininfo")
|
||||
.stream().map(info -> MiniMessage.miniMessage().deserialize(info)).toList();
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
if (ADMIN_INFO.isEmpty())
|
||||
List<Component> adminInfo = module.getConfig().getStringList("server.admininfo")
|
||||
.stream().map(info -> MiniMessage.miniMessage().deserialize(info)).toList();
|
||||
if (adminInfo.isEmpty())
|
||||
{
|
||||
return messageComponent("emptyAdminInfo");
|
||||
}
|
||||
ADMIN_INFO.forEach(component -> send(sender, component));
|
||||
adminInfo.forEach(component -> send(sender, component));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AutoClearCommand extends SimplePlexCommand
|
||||
{
|
||||
public AutoClearCommand()
|
||||
private final TFMExtras module;
|
||||
|
||||
public AutoClearCommand(TFMExtras module)
|
||||
{
|
||||
super(command("autoclear")
|
||||
.description("Toggle whether or not a player has their inventory automatically cleared when they join")
|
||||
@@ -22,7 +24,9 @@ public class AutoClearCommand extends SimplePlexCommand
|
||||
.aliases("aclear,ac")
|
||||
.permission("plex.tfmextras.autoclear")
|
||||
.build());
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
@@ -30,8 +34,8 @@ public class AutoClearCommand extends SimplePlexCommand
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
PlexPlayerView target = TFMExtras.plexApi().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
|
||||
List<String> names = TFMExtras.getModule().getConfig().getStringList("server.clear-on-join");
|
||||
PlexPlayerView target = api().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
|
||||
List<String> names = module.getConfig().getStringList("server.clear-on-join");
|
||||
boolean isEnabled = names.contains(target.name());
|
||||
if (!isEnabled)
|
||||
{
|
||||
@@ -41,8 +45,8 @@ public class AutoClearCommand extends SimplePlexCommand
|
||||
{
|
||||
names.remove(target.name());
|
||||
}
|
||||
TFMExtras.getModule().getConfig().set("server.clear-on-join", names);
|
||||
TFMExtras.getModule().getConfig().save();
|
||||
module.getConfig().set("server.clear-on-join", names);
|
||||
module.getConfig().save();
|
||||
isEnabled = !isEnabled;
|
||||
return messageComponent("modifiedAutoClear", target.name(), isEnabled ? "now" : "no longer");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AutoTeleportCommand extends SimplePlexCommand
|
||||
{
|
||||
public AutoTeleportCommand()
|
||||
private final TFMExtras module;
|
||||
|
||||
public AutoTeleportCommand(TFMExtras module)
|
||||
{
|
||||
super(command("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")
|
||||
@@ -23,7 +25,9 @@ public class AutoTeleportCommand extends SimplePlexCommand
|
||||
.aliases("autotp,rtp,randomtp,tpr")
|
||||
.permission("plex.tfmextras.autotp")
|
||||
.build());
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
@@ -33,12 +37,12 @@ public class AutoTeleportCommand extends SimplePlexCommand
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
TFMExtras.plexApi().scheduler().runEntity(player, () -> player.teleportAsync(TFMExtras.getRandomLocation(player.getWorld())));
|
||||
api().scheduler().runEntity(player, () -> player.teleportAsync(module.getRandomLocation(player.getWorld())));
|
||||
return null;
|
||||
}
|
||||
checkPermission(sender, "plex.tfmextras.autotp.other");
|
||||
PlexPlayerView target = TFMExtras.plexApi().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
|
||||
List<String> names = TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join");
|
||||
PlexPlayerView target = api().players().byName(args[0]).orElseThrow(PlayerNotFoundException::new);
|
||||
List<String> names = module.getConfig().getStringList("server.teleport-on-join");
|
||||
boolean isEnabled = names.contains(target.name());
|
||||
if (!isEnabled)
|
||||
{
|
||||
@@ -48,8 +52,8 @@ public class AutoTeleportCommand extends SimplePlexCommand
|
||||
{
|
||||
names.remove(target.name());
|
||||
}
|
||||
TFMExtras.getModule().getConfig().set("server.teleport-on-join", names);
|
||||
TFMExtras.getModule().getConfig().save();
|
||||
module.getConfig().set("server.teleport-on-join", names);
|
||||
module.getConfig().save();
|
||||
isEnabled = !isEnabled;
|
||||
return messageComponent("modifiedAutoTeleport", target.name(), isEnabled ? "now" : "no longer");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.plex.extras.command;
|
||||
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -29,7 +28,7 @@ public class CakeCommand extends SimplePlexCommand
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
Bukkit.getOnlinePlayers().forEach(p -> TFMExtras.plexApi().scheduler().runEntity(p, () -> p.getInventory().addItem(CAKE.clone())));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> api().scheduler().runEntity(p, () -> p.getInventory().addItem(CAKE.clone())));
|
||||
broadcast(messageComponent("cakeLyrics"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex.extras.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -46,7 +45,7 @@ public class CartSitCommand extends SimplePlexCommand
|
||||
return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart!");
|
||||
}
|
||||
Entity entity = findNearestEntity(player, minecart);
|
||||
TFMExtras.plexApi().scheduler().runEntity(entity, () -> entity.addPassenger(player));
|
||||
api().scheduler().runEntity(entity, () -> entity.addPassenger(player));
|
||||
return null;
|
||||
}
|
||||
Player target = getNonNullPlayer(args[0]);
|
||||
@@ -60,7 +59,7 @@ public class CartSitCommand extends SimplePlexCommand
|
||||
return MiniMessage.miniMessage().deserialize("<red>Could not find a nearby minecart near " + target.getName() + "!");
|
||||
}
|
||||
Entity entity = findNearestEntity(target, minecart);
|
||||
TFMExtras.plexApi().scheduler().runEntity(entity, () -> entity.addPassenger(target));
|
||||
api().scheduler().runEntity(entity, () -> entity.addPassenger(target));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.plex.extras.command;
|
||||
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -27,7 +26,7 @@ public class ClearChatCommand extends SimplePlexCommand
|
||||
Bukkit.getOnlinePlayers().stream().filter(p -> !silentCheckPermission(p, "plex.tfmextras.clearchat"))
|
||||
.forEach(p ->
|
||||
{
|
||||
TFMExtras.plexApi().scheduler().runEntity(p, () ->
|
||||
api().scheduler().runEntity(p, () ->
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.plex.extras.command;
|
||||
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -33,7 +32,7 @@ public class CloudClearCommand extends SimplePlexCommand
|
||||
Bukkit.getWorlds().stream().map(World::getEntities).flatMap(Collection::stream).filter(entity -> entity.getType() == EntityType.AREA_EFFECT_CLOUD).forEach(entity ->
|
||||
{
|
||||
removed.incrementAndGet();
|
||||
TFMExtras.plexApi().scheduler().runEntity(entity, entity::remove);
|
||||
api().scheduler().runEntity(entity, entity::remove);
|
||||
});
|
||||
broadcast(messageComponent("areaEffectCloudClear", sender.getName()));
|
||||
return MiniMessage.miniMessage().deserialize("<gray>" + removed.get() + " area effect clouds removed.");
|
||||
|
||||
@@ -20,14 +20,18 @@ import java.util.List;
|
||||
|
||||
public class ClownfishCommand extends SimplePlexCommand
|
||||
{
|
||||
public ClownfishCommand()
|
||||
private final TFMExtras module;
|
||||
|
||||
public ClownfishCommand(TFMExtras module)
|
||||
{
|
||||
super(command("clownfish")
|
||||
.description("Gives a player a clownfish capable of knocking people back")
|
||||
.usage("/<command> [<toggle>]")
|
||||
.permission("plex.tfmextras.clownfish")
|
||||
.build());
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
@@ -39,12 +43,12 @@ public class ClownfishCommand extends SimplePlexCommand
|
||||
meta.displayName(Component.text("Clownfish"));
|
||||
clownfish.setItemMeta(meta);
|
||||
|
||||
TFMExtras.plexApi().scheduler().runEntity(player, () -> player.getInventory().addItem(clownfish));
|
||||
api().scheduler().runEntity(player, () -> player.getInventory().addItem(clownfish));
|
||||
return MiniMessage.miniMessage().deserialize("<rainbow>blub blub... ><_>");
|
||||
}
|
||||
else if (args[0].equals("toggle"))
|
||||
{
|
||||
List<String> toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players");
|
||||
List<String> toggledPlayers = module.getConfig().getStringList("server.clownfish.toggled_players");
|
||||
|
||||
boolean isToggled = toggledPlayers.contains(player.getUniqueId().toString());
|
||||
if (isToggled)
|
||||
@@ -56,8 +60,8 @@ public class ClownfishCommand extends SimplePlexCommand
|
||||
toggledPlayers.add(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
TFMExtras.getModule().getConfig().set("server.clownfish.toggled_players", toggledPlayers);
|
||||
TFMExtras.getModule().getConfig().save();
|
||||
module.getConfig().set("server.clownfish.toggled_players", toggledPlayers);
|
||||
module.getConfig().save();
|
||||
|
||||
return messageComponent("toggleClownfish", isToggled ? "now" : "no longer");
|
||||
}
|
||||
@@ -65,9 +69,9 @@ public class ClownfishCommand extends SimplePlexCommand
|
||||
{
|
||||
if (silentCheckPermission(commandSender, "plex.tfmextras.clownfish.restrict"))
|
||||
{
|
||||
PlexPlayerView target = TFMExtras.plexApi().players().byName(args[1]).orElseThrow(PlayerNotFoundException::new);
|
||||
PlexPlayerView target = api().players().byName(args[1]).orElseThrow(PlayerNotFoundException::new);
|
||||
|
||||
List<String> restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted");
|
||||
List<String> restrictedPlayers = module.getConfig().getStringList("server.clownfish.restricted");
|
||||
|
||||
boolean isRestricted = restrictedPlayers.contains(target.uuid().toString());
|
||||
if (isRestricted)
|
||||
@@ -79,8 +83,8 @@ public class ClownfishCommand extends SimplePlexCommand
|
||||
restrictedPlayers.add(target.uuid().toString());
|
||||
}
|
||||
|
||||
TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers);
|
||||
TFMExtras.getModule().getConfig().save();
|
||||
module.getConfig().set("server.clownfish.restricted", restrictedPlayers);
|
||||
module.getConfig().save();
|
||||
|
||||
return messageComponent("restrictClownfish", target.name(), isRestricted ? "now" : "no longer");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex.extras.command;
|
||||
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -26,7 +25,7 @@ public class EjectCommand extends SimplePlexCommand
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
final int passengers = player.getPassengers().size();
|
||||
TFMExtras.plexApi().scheduler().runEntity(player, player::eject);
|
||||
api().scheduler().runEntity(player, player::eject);
|
||||
return MiniMessage.miniMessage().deserialize("<gray>Ejected " + passengers + " passengers.");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex.extras.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -33,7 +32,7 @@ public class EnglishMfCommand extends SimplePlexCommand
|
||||
return usage();
|
||||
}
|
||||
Player target = getNonNullPlayer(args[0]);
|
||||
TFMExtras.plexApi().scheduler().runEntity(target, () ->
|
||||
api().scheduler().runEntity(target, () ->
|
||||
{
|
||||
target.sendMessage(mmString("<red>ENGLISH MOTHERFUCKER, Do you speak it!?"));
|
||||
target.setHealth(0);
|
||||
|
||||
@@ -18,7 +18,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JumpPadsCommand extends SimplePlexCommand
|
||||
{
|
||||
public JumpPadsCommand()
|
||||
private final JumpPads jumpPads;
|
||||
|
||||
public JumpPadsCommand(TFMExtras module)
|
||||
{
|
||||
super(command("jumppads")
|
||||
.description("Enables jump pads for yourself or another player. Mode types available: none, regular, enhanced, extreme")
|
||||
@@ -26,8 +28,8 @@ public class JumpPadsCommand extends SimplePlexCommand
|
||||
.aliases("jp,pads,launchpads")
|
||||
.permission("plex.tfmextras.jumppads")
|
||||
.build());
|
||||
this.jumpPads = module.getJumpPads();
|
||||
}
|
||||
JumpPads jumpPads = TFMExtras.getModule().jumpPads;
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex.extras.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -85,7 +84,7 @@ public class OrbitCommand extends SimplePlexCommand
|
||||
|
||||
private void startOrbiting(Player player, int strength)
|
||||
{
|
||||
TFMExtras.plexApi().scheduler().runEntity(player, () ->
|
||||
api().scheduler().runEntity(player, () ->
|
||||
{
|
||||
player.setGameMode(org.bukkit.GameMode.SURVIVAL);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false));
|
||||
@@ -96,7 +95,7 @@ public class OrbitCommand extends SimplePlexCommand
|
||||
private void stopOrbiting(Player player)
|
||||
{
|
||||
isOrbited.remove(player.getUniqueId());
|
||||
TFMExtras.plexApi().scheduler().runEntity(player, () -> player.removePotionEffect(PotionEffectType.LEVITATION));
|
||||
api().scheduler().runEntity(player, () -> player.removePotionEffect(PotionEffectType.LEVITATION));
|
||||
}
|
||||
|
||||
public static boolean isPlayerOrbited(UUID playerId)
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex.extras.command;
|
||||
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -39,7 +38,7 @@ public class RandomFishCommand extends SimplePlexCommand
|
||||
return MiniMessage.miniMessage().deserialize("<red>There is no block within 15 blocks of you.");
|
||||
}
|
||||
Location location = block.getLocation().add(0, 1, 0);
|
||||
TFMExtras.plexApi().scheduler().runRegion(location, () -> location.getWorld().spawnEntity(location, randomFish()));
|
||||
api().scheduler().runRegion(location, () -> location.getWorld().spawnEntity(location, randomFish()));
|
||||
return MiniMessage.miniMessage().deserialize(":goodbird:");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.plex.extras.jumppads;
|
||||
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -17,10 +16,16 @@ public class JumpPads
|
||||
{
|
||||
public final Map<UUID, Mode> playerModeMap = new ConcurrentHashMap<>();
|
||||
public final double SCALAR = 0.8;
|
||||
public final double STRENGTH = TFMExtras.getModule().getConfig().getInt("server.jumppad_strength", 1) + 0.1F;
|
||||
public final double EXTREME = STRENGTH + 0.5;
|
||||
public final double STRENGTH;
|
||||
public final double EXTREME;
|
||||
public final Tag<Material> wool = Tag.WOOL;
|
||||
|
||||
public JumpPads(double strength)
|
||||
{
|
||||
STRENGTH = strength + 0.1F;
|
||||
EXTREME = STRENGTH + 0.5;
|
||||
}
|
||||
|
||||
public Vector extreme(Vector vector)
|
||||
{
|
||||
return vector.multiply(STRENGTH * SCALAR * ThreadLocalRandom.current().nextInt(3, 6));
|
||||
|
||||
@@ -26,6 +26,12 @@ import java.util.Random;
|
||||
|
||||
public class ClownfishListener extends PlexListener
|
||||
{
|
||||
private final TFMExtras module;
|
||||
|
||||
public ClownfishListener(TFMExtras module)
|
||||
{
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
@@ -47,20 +53,20 @@ public class ClownfishListener extends PlexListener
|
||||
|
||||
if (meta.hasDisplayName() && Objects.equals(meta.displayName(), Component.text("Clownfish")))
|
||||
{
|
||||
final List<String> restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted");
|
||||
final List<String> restrictedPlayers = module.getConfig().getStringList("server.clownfish.restricted");
|
||||
if (restrictedPlayers.contains(player.getUniqueId().toString()))
|
||||
{
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize("<gray>You have been restricted from using the clownfish"));
|
||||
return;
|
||||
}
|
||||
|
||||
double radius = TFMExtras.getModule().getConfig().getInt("server.clownfish.radius");
|
||||
double strength = TFMExtras.getModule().getConfig().getInt("server.clownfish.strength");
|
||||
double radius = module.getConfig().getInt("server.clownfish.radius");
|
||||
double strength = module.getConfig().getInt("server.clownfish.strength");
|
||||
|
||||
List<String> pushedPlayers = new ArrayList<>();
|
||||
final Vector senderPos = player.getLocation().toVector();
|
||||
final List<Player> players = player.getWorld().getPlayers();
|
||||
final List<String> toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players");
|
||||
final List<String> toggledPlayers = module.getConfig().getStringList("server.clownfish.toggled_players");
|
||||
|
||||
for (final Player target : players)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,14 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class JumpPadsListener extends PlexListener
|
||||
{
|
||||
JumpPads jumpPads = TFMExtras.getModule().jumpPads;
|
||||
private final TFMExtras module;
|
||||
private final JumpPads jumpPads;
|
||||
|
||||
public JumpPadsListener(TFMExtras module)
|
||||
{
|
||||
this.module = module;
|
||||
this.jumpPads = module.getJumpPads();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void jumppadsAction(PlayerMoveEvent event)
|
||||
@@ -43,7 +50,7 @@ public class JumpPadsListener extends PlexListener
|
||||
{
|
||||
vector = vector.multiply(new Vector(0, -1, 0));
|
||||
}
|
||||
TFMExtras.plexApi().logging().debug("New Velocity: {0}", vector.toString());
|
||||
module.api().logging().debug("New Velocity: {0}", vector.toString());
|
||||
player.setFallDistance(0);
|
||||
player.setVelocity(vector);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class OrbitEffectListener extends PlexListener
|
||||
{
|
||||
private final TFMExtras module;
|
||||
|
||||
public OrbitEffectListener(TFMExtras module)
|
||||
{
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPotionEffectRemove(EntityPotionEffectEvent event)
|
||||
{
|
||||
@@ -22,7 +29,7 @@ public class OrbitEffectListener extends PlexListener
|
||||
if ((event.getAction() == EntityPotionEffectEvent.Action.CLEARED || event.getAction() == EntityPotionEffectEvent.Action.REMOVED)
|
||||
&& event.getModifiedType() == PotionEffectType.LEVITATION)
|
||||
{
|
||||
TFMExtras.plexApi().scheduler().runEntityLater(player, () ->
|
||||
module.api().scheduler().runEntityLater(player, () ->
|
||||
{
|
||||
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()))
|
||||
{
|
||||
@@ -40,7 +47,7 @@ public class OrbitEffectListener extends PlexListener
|
||||
Player player = event.getPlayer();
|
||||
|
||||
GameMode newGameMode = event.getNewGameMode();
|
||||
TFMExtras.plexApi().scheduler().runEntityLater(player, () ->
|
||||
module.api().scheduler().runEntityLater(player, () ->
|
||||
{
|
||||
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()) && newGameMode != GameMode.SURVIVAL)
|
||||
{
|
||||
|
||||
@@ -7,16 +7,23 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerListener extends PlexListener
|
||||
{
|
||||
private final TFMExtras module;
|
||||
|
||||
public PlayerListener(TFMExtras module)
|
||||
{
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAuto(PlayerJoinEvent event)
|
||||
{
|
||||
if (TFMExtras.getModule().getConfig().getStringList("server.clear-on-join").contains(event.getPlayer().getName()))
|
||||
if (module.getConfig().getStringList("server.clear-on-join").contains(event.getPlayer().getName()))
|
||||
{
|
||||
TFMExtras.plexApi().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().getInventory().clear(), 1);
|
||||
module.api().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().getInventory().clear(), 1);
|
||||
}
|
||||
if (TFMExtras.getModule().getConfig().getStringList("server.teleport-on-join").contains(event.getPlayer().getName()))
|
||||
if (module.getConfig().getStringList("server.teleport-on-join").contains(event.getPlayer().getName()))
|
||||
{
|
||||
TFMExtras.plexApi().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().teleportAsync(TFMExtras.getRandomLocation(event.getPlayer().getWorld())), 1);
|
||||
module.api().scheduler().runEntityLater(event.getPlayer(), () -> event.getPlayer().teleportAsync(module.getRandomLocation(event.getPlayer().getWorld())), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user