mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2024-12-22 17:27:36 +00:00
Implemented changes mentioned in PR
This commit is contained in:
parent
d6e2287b6a
commit
7e40a9ebd7
@ -93,9 +93,11 @@ public class TFMExtras extends PlexModule
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addDefaultMessage("playerOrbited", "<aqua>{0} - Orbiting {1}", "0 - The command sender, 1 - The person being orbited");
|
addDefaultMessage("playerOrbited", "<aqua>{0} - Orbiting {1}", "0 - The command sender", "1 - The person being orbited");
|
||||||
addDefaultMessage("stoppedOrbiting", "<aqua>No longer orbiting {0}", "0 - The person no longer being orbited");
|
addDefaultMessage("stoppedOrbiting", "<aqua>No longer orbiting {0}", "0 - The person no longer being orbited");
|
||||||
addDefaultMessage("alreadyOrbited", "<red>{0} is already being orbited!", "0 - The person that is already orbited");
|
addDefaultMessage("alreadyOrbited", "<red>{0} is already being orbited!", "0 - The person that is already orbited");
|
||||||
|
addDefaultMessage("restrictClownfish", "<gold>{0} will {1} be able to use the clownfish.", "0 - The player who will be restricted", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
||||||
|
addDefaultMessage("toggleClownfish", "<gray>You will {0} be affected by the clownfish.", "0 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
||||||
addDefaultMessage("emptyAdminInfo", "<red>The admin information section of the config.yml file has not been configured.");
|
addDefaultMessage("emptyAdminInfo", "<red>The admin information section of the config.yml file has not been configured.");
|
||||||
addDefaultMessage("cakeLyrics", "<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake.");
|
addDefaultMessage("cakeLyrics", "<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake.");
|
||||||
addDefaultMessage("areaEffectCloudClear", "<red>{0} - Removing all area effect clouds", "0 - The command sender");
|
addDefaultMessage("areaEffectCloudClear", "<red>{0} - Removing all area effect clouds", "0 - The command sender");
|
||||||
|
@ -17,7 +17,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "clownfish", description = "Gives a player a clownfish capable of knocking people back")
|
@CommandParameters(name = "clownfish", description = "Gives a player a clownfish capable of knocking people back", usage = "/<command> [<toggle>]")
|
||||||
@CommandPermissions(permission = "plex.tfmextras.clownfish")
|
@CommandPermissions(permission = "plex.tfmextras.clownfish")
|
||||||
public class ClownfishCommand extends PlexCommand
|
public class ClownfishCommand extends PlexCommand
|
||||||
{
|
{
|
||||||
@ -38,25 +38,25 @@ public class ClownfishCommand extends PlexCommand
|
|||||||
else if (args[0].equals("toggle"))
|
else if (args[0].equals("toggle"))
|
||||||
{
|
{
|
||||||
List<String> toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players");
|
List<String> toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players");
|
||||||
boolean isToggled = toggledPlayers.contains(player.getName());
|
|
||||||
|
|
||||||
|
boolean isToggled = toggledPlayers.contains(player.getUniqueId().toString());
|
||||||
if (isToggled)
|
if (isToggled)
|
||||||
{
|
{
|
||||||
toggledPlayers.remove(player.getName());
|
toggledPlayers.remove(player.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toggledPlayers.add(player.getName());
|
toggledPlayers.add(player.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TFMExtras.getModule().getConfig().set("server.clownfish.toggled_players", toggledPlayers);
|
TFMExtras.getModule().getConfig().set("server.clownfish.toggled_players", toggledPlayers);
|
||||||
TFMExtras.getModule().getConfig().save();
|
TFMExtras.getModule().getConfig().save();
|
||||||
|
|
||||||
return MiniMessage.miniMessage().deserialize("<gray>You " + (isToggled ? "<green>will" : "<red>will no longer") + "<gray> be affected by the clownfish");
|
return messageComponent("toggleClownfish", isToggled ? "now" : "no longer");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize("<red>Incorrect usage. Use either /clownfish or /clownfish toggle");
|
return usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
|
import dev.plex.extras.TFMExtras;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
|
||||||
|
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 = "toggleclownfish", description = "Toggles the ability to use the clownfish for a specified player", usage = "/<command> <player>")
|
||||||
|
@CommandPermissions(permission = "plex.tfmextras.toggleclownfish")
|
||||||
|
public class RestrictClownfishCommand extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlexPlayer target = DataUtils.getPlayer(args[0]);
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
throw new PlayerNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted");
|
||||||
|
|
||||||
|
boolean isRestricted = restrictedPlayers.contains(target.getUuid().toString());
|
||||||
|
if (isRestricted)
|
||||||
|
{
|
||||||
|
restrictedPlayers.remove(target.getUuid().toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
restrictedPlayers.add(target.getUuid().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers);
|
||||||
|
TFMExtras.getModule().getConfig().save();
|
||||||
|
|
||||||
|
return messageComponent("restrictClownfish", target.getName(), isRestricted ? "now" : "no longer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,10 @@ import dev.plex.extras.TFMExtras;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -20,6 +20,7 @@ import org.bukkit.util.Vector;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class ClownfishListener extends PlexListener
|
public class ClownfishListener extends PlexListener
|
||||||
{
|
{
|
||||||
@ -44,6 +45,13 @@ public class ClownfishListener extends PlexListener
|
|||||||
|
|
||||||
if (meta.hasDisplayName() && Objects.equals(meta.displayName(), Component.text("Clownfish")))
|
if (meta.hasDisplayName() && Objects.equals(meta.displayName(), Component.text("Clownfish")))
|
||||||
{
|
{
|
||||||
|
final List<String> restrictedPlayers = TFMExtras.getModule().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 radius = TFMExtras.getModule().getConfig().getInt("server.clownfish.radius");
|
||||||
double strength = TFMExtras.getModule().getConfig().getInt("server.clownfish.strength");
|
double strength = TFMExtras.getModule().getConfig().getInt("server.clownfish.strength");
|
||||||
|
|
||||||
@ -54,7 +62,7 @@ public class ClownfishListener extends PlexListener
|
|||||||
|
|
||||||
for (final Player target : players)
|
for (final Player target : players)
|
||||||
{
|
{
|
||||||
if (target.equals(player) || toggledPlayers.contains(target.getName()))
|
if (target.equals(player) || toggledPlayers.contains(target.getUniqueId().toString()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -64,8 +72,18 @@ public class ClownfishListener extends PlexListener
|
|||||||
|
|
||||||
if (targetPosVec.distanceSquared(senderPos) < (radius * radius))
|
if (targetPosVec.distanceSquared(senderPos) < (radius * radius))
|
||||||
{
|
{
|
||||||
target.playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
target.setFlying(false);
|
||||||
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation(), 1);
|
|
||||||
|
final Sound[] listOfSounds = Sound.values();
|
||||||
|
for (Sound sound : listOfSounds)
|
||||||
|
{
|
||||||
|
if (sound.toString().contains("HIT"))
|
||||||
|
{
|
||||||
|
target.playSound(target.getLocation(), sound, 100.0f, 0.5f + new Random().nextFloat() * 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.getWorld().spawnParticle(Particle.CLOUD, target.getLocation(), 5);
|
||||||
target.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
|
target.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
|
||||||
|
|
||||||
pushedPlayers.add(target.getName());
|
pushedPlayers.add(target.getName());
|
||||||
@ -74,7 +92,14 @@ public class ClownfishListener extends PlexListener
|
|||||||
|
|
||||||
if (!pushedPlayers.isEmpty())
|
if (!pushedPlayers.isEmpty())
|
||||||
{
|
{
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
final Sound[] listOfSounds = Sound.values();
|
||||||
|
for (Sound sound : listOfSounds)
|
||||||
|
{
|
||||||
|
if (sound.toString().contains("HIT"))
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), sound, 100.0f, 0.5f + new Random().nextFloat() * 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ server:
|
|||||||
radius: 5
|
radius: 5
|
||||||
strength: 2.5
|
strength: 2.5
|
||||||
toggled_players:
|
toggled_players:
|
||||||
- "shdwo"
|
- "9285ace6-7393-45c5-9420-00fc66374ff4"
|
||||||
|
restricted:
|
||||||
|
- "9285ace6-7393-45c5-9420-00fc66374ff4"
|
||||||
player-worlds:
|
player-worlds:
|
||||||
size: 500
|
size: 500
|
Loading…
Reference in New Issue
Block a user