This commit is contained in:
Paul Reilly
2023-06-21 15:45:55 -05:00
parent 09699ccabb
commit fb97a8e65b
12 changed files with 267 additions and 56 deletions

View File

@ -1,12 +1,19 @@
package me.totalfreedom.datura.cmd;
import me.totalfreedom.base.Patchwork;
import me.totalfreedom.command.Commander;
import me.totalfreedom.command.annotation.Base;
import me.totalfreedom.command.annotation.Info;
import me.totalfreedom.command.annotation.Permissive;
import me.totalfreedom.command.annotation.Subcommand;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@Info(name = "")
@Permissive(perm = "")
public class AdminChatCommand extends Commander
{
@ -25,7 +32,33 @@ public class AdminChatCommand extends Commander
}
@Base
public void onAdminChat(final CommandSender sender) {
public void onAdminChat(final CommandSender sender)
{
if (!(sender instanceof Player)) return;
final Player player = (Player) sender;
Patchwork.getInstance()
.getAdminChatDisplay()
.toggleChat(player);
final boolean toggled = Patchwork.getInstance()
.getAdminChatDisplay()
.isToggled(player);
String message = "Toggled adminchat ";
message += toggled ? "on" : "off";
player.sendPlainMessage(message + ".");
}
// String here will automatically have all additional args appended to it :)
@Subcommand(permission = "patchwork.adminchat", args = {String.class})
public void sendMessage(final CommandSender sender, final String message)
{
Patchwork.getInstance()
.getAdminChatDisplay()
.adminChatMessage(sender, Component.text(message));
}
}

View File

@ -21,6 +21,7 @@
package me.totalfreedom.datura.cmd;
import me.totalfreedom.base.Shortcuts;
import me.totalfreedom.command.Commander;
import me.totalfreedom.command.annotation.Completion;
import me.totalfreedom.command.annotation.Info;
@ -68,13 +69,15 @@ public class CageCommand extends Commander
{
if (string.equalsIgnoreCase("on"))
{
((Datura) getPlugin()).getCager()
.cagePlayer(player.getUniqueId(), material);
Shortcuts.provideModule(Datura.class)
.getCager()
.cagePlayer(player.getUniqueId(), material);
sender.sendPlainMessage("Caged " + player.getName() + ".");
} else if (string.equalsIgnoreCase("off"))
{
((Datura) getPlugin()).getCager()
.uncagePlayer(player.getUniqueId());
Shortcuts.provideModule(Datura.class)
.getCager()
.uncagePlayer(player.getUniqueId());
sender.sendPlainMessage("Liberated " + player.getName() + ".");
}
}

View File

@ -2,6 +2,7 @@ package me.totalfreedom.datura.cmd;
import me.totalfreedom.base.Shortcuts;
import me.totalfreedom.command.Commander;
import me.totalfreedom.command.annotation.Completion;
import me.totalfreedom.command.annotation.Info;
import me.totalfreedom.command.annotation.Permissive;
import me.totalfreedom.command.annotation.Subcommand;
@ -18,8 +19,7 @@ import org.jetbrains.annotations.NotNull;
@Permissive(perm = "datura.halt")
public class HaltCommand extends Commander
{
private final Datura plugin = Shortcuts.provideModule(Datura.class)
.getModule();
private final Datura plugin = Shortcuts.provideModule(Datura.class);
/**
* Initializes this command object. The provided {@link JavaPlugin} should be the plugin which contains the
@ -36,6 +36,8 @@ public class HaltCommand extends Commander
}
@Completion(index = 0, args = {"%player%", "all"})
@Completion(index = 1, args = {"on", "off"})
@Subcommand(permission = "datura.halt", args = {Player.class, String.class})
public void haltPlayer(final CommandSender sender, final Player target, final String toggle)
{
@ -56,6 +58,7 @@ public class HaltCommand extends Commander
}
}
// No completion needed here since it's already registered.
@Subcommand(permission = "datura.halt.all", args = {String.class, String.class})
public void haltAll(final CommandSender sender, final String all, final String toggle)
{
@ -65,11 +68,8 @@ public class HaltCommand extends Commander
{
Bukkit.getServer()
.getOnlinePlayers()
.forEach(player ->
{
plugin.getHalter()
.halt(player.getUniqueId());
});
.forEach(player -> plugin.getHalter()
.halt(player.getUniqueId()));
final Component message = sender.name()
.append(Component.text(": Freezing all players"))

View File

@ -0,0 +1,51 @@
package me.totalfreedom.datura.cmd;
import me.totalfreedom.command.Commander;
import me.totalfreedom.command.annotation.Completion;
import me.totalfreedom.command.annotation.Info;
import me.totalfreedom.command.annotation.Permissive;
import me.totalfreedom.command.annotation.Subcommand;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@Info(name = "smite", description = "Smite a player.", usage = "/smite <player>", aliases = {"sm"})
@Permissive(perm = "datura.smite")
public class SmiteCommand extends Commander
{
/**
* Initializes this command object. The provided {@link JavaPlugin} should be the plugin which contains the
* command.
* <p>
* This constructor will automatically register all subcommands and completions for this command. It will also
* automatically infer all required information from the provided {@link Info} and {@link Permissive} annotations.
*
* @param plugin The plugin which contains this command.
*/
protected SmiteCommand(@NotNull final JavaPlugin plugin)
{
super(plugin);
}
@Subcommand(permission = "datura.smite", args = {Player.class})
@Completion(index = 0, args = {"%player%"})
public void smite(final CommandSender sender, final Player player)
{
final double size = 5D;
for (int i = 0; i < size * size * size; i++)
{
final double x = i % size;
final double y = (i / size) % size;
final double z = (i / size / size) % size;
final Location location = player.getLocation()
.clone()
.add(x - size / 2, y - size / 2, z - size / 2);
player.getWorld()
.strikeLightning(location);
}
}
}

View File

@ -27,7 +27,8 @@ public class Halter implements Listener
this.haltedPlayers.remove(uuid);
}
public void clear() {
public void clear()
{
this.haltedPlayers.clear();
}

View File

@ -230,16 +230,16 @@ public class SimpleUserData implements UserData
return hasCustomACFormat;
}
@Override
public AdminChatFormat getCustomACFormat()
{
return AdminChatFormat.deserialize(customACFormat);
}
@Override
public void setCustomACFormat(final String format)
{
this.hasCustomACFormat = format.equals(AdminChatFormat.DEFAULT.serialize());
this.customACFormat = format;
}
@Override
public AdminChatFormat getCustomACFormat()
{
return AdminChatFormat.deserialize(customACFormat);
}
}