Migrates the entire package nomenclature to be more direct and straightforward. (#17)

Signed-off-by: Paul Reilly <pawereus@gmail.com>
This commit is contained in:
Paldiu
2023-08-01 22:34:18 -05:00
committed by GitHub
parent e1a6b5e587
commit 21463c50fe
146 changed files with 595 additions and 608 deletions
@@ -0,0 +1,54 @@
package fns.datura.features;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandSpy implements Listener
{
private final Set<UUID> commandWatchers;
public CommandSpy()
{
this.commandWatchers = new HashSet<>();
}
public void spy(final UUID uuid)
{
this.commandWatchers.add(uuid);
}
public void stop(final UUID uuid)
{
this.commandWatchers.remove(uuid);
}
public void clear()
{
this.commandWatchers.clear();
}
public boolean isSpying(final UUID uuid)
{
return this.commandWatchers.contains(uuid);
}
@EventHandler
public void commandProcess(final PlayerCommandPreprocessEvent event)
{
Bukkit.getOnlinePlayers().stream()
.filter(player -> isSpying(player.getUniqueId()))
.forEach(player -> player.sendMessage(Component.text(event.getPlayer().getName(), NamedTextColor.GRAY)
.append(Component.text(": ", NamedTextColor.GRAY))
.append(Component.text(event.getMessage(), NamedTextColor.GRAY))
)
);
}
}
@@ -0,0 +1,61 @@
package fns.datura.features;
import fns.patchwork.service.Service;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class Fuckoff extends Service
{
private final Map<UUID, Integer> players = new ConcurrentHashMap<>();
public Fuckoff()
{
super("fuckoff-service");
}
public void add(final Player player, final int radius)
{
players.put(player.getUniqueId(), radius);
}
public void remove(final Player player)
{
players.remove(player.getUniqueId());
}
@Override
public void tick()
{
for (final Map.Entry<UUID, Integer> entry : players.entrySet())
{
final var player = Bukkit.getPlayer(entry.getKey());
if (player == null)
{
players.remove(entry.getKey());
continue;
}
pushPlayers(player, entry.getValue());
}
}
private void pushPlayers(@NotNull final Player player, final int radius)
{
Bukkit.getOnlinePlayers()
.stream()
.filter(onlinePlayer -> onlinePlayer.getLocation()
.clone()
.distanceSquared(player.getLocation()) < Math.pow(radius, 2))
.forEach(onlinePlayer ->
onlinePlayer.setVelocity(player.getLocation()
.toVector()
.add(onlinePlayer.getLocation().toVector())
.normalize()
.multiply(radius)));
}
}