mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2024-11-25 01:55:00 +00:00
updates
This commit is contained in:
parent
09699ccabb
commit
fb97a8e65b
@ -1,12 +1,19 @@
|
|||||||
package me.totalfreedom.datura.cmd;
|
package me.totalfreedom.datura.cmd;
|
||||||
|
|
||||||
|
import me.totalfreedom.base.Patchwork;
|
||||||
import me.totalfreedom.command.Commander;
|
import me.totalfreedom.command.Commander;
|
||||||
import me.totalfreedom.command.annotation.Base;
|
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.command.CommandSender;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@Info(name = "")
|
||||||
|
@Permissive(perm = "")
|
||||||
public class AdminChatCommand extends Commander
|
public class AdminChatCommand extends Commander
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -25,7 +32,33 @@ public class AdminChatCommand extends Commander
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Base
|
@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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package me.totalfreedom.datura.cmd;
|
package me.totalfreedom.datura.cmd;
|
||||||
|
|
||||||
|
import me.totalfreedom.base.Shortcuts;
|
||||||
import me.totalfreedom.command.Commander;
|
import me.totalfreedom.command.Commander;
|
||||||
import me.totalfreedom.command.annotation.Completion;
|
import me.totalfreedom.command.annotation.Completion;
|
||||||
import me.totalfreedom.command.annotation.Info;
|
import me.totalfreedom.command.annotation.Info;
|
||||||
@ -68,12 +69,14 @@ public class CageCommand extends Commander
|
|||||||
{
|
{
|
||||||
if (string.equalsIgnoreCase("on"))
|
if (string.equalsIgnoreCase("on"))
|
||||||
{
|
{
|
||||||
((Datura) getPlugin()).getCager()
|
Shortcuts.provideModule(Datura.class)
|
||||||
|
.getCager()
|
||||||
.cagePlayer(player.getUniqueId(), material);
|
.cagePlayer(player.getUniqueId(), material);
|
||||||
sender.sendPlainMessage("Caged " + player.getName() + ".");
|
sender.sendPlainMessage("Caged " + player.getName() + ".");
|
||||||
} else if (string.equalsIgnoreCase("off"))
|
} else if (string.equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
((Datura) getPlugin()).getCager()
|
Shortcuts.provideModule(Datura.class)
|
||||||
|
.getCager()
|
||||||
.uncagePlayer(player.getUniqueId());
|
.uncagePlayer(player.getUniqueId());
|
||||||
sender.sendPlainMessage("Liberated " + player.getName() + ".");
|
sender.sendPlainMessage("Liberated " + player.getName() + ".");
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.datura.cmd;
|
|||||||
|
|
||||||
import me.totalfreedom.base.Shortcuts;
|
import me.totalfreedom.base.Shortcuts;
|
||||||
import me.totalfreedom.command.Commander;
|
import me.totalfreedom.command.Commander;
|
||||||
|
import me.totalfreedom.command.annotation.Completion;
|
||||||
import me.totalfreedom.command.annotation.Info;
|
import me.totalfreedom.command.annotation.Info;
|
||||||
import me.totalfreedom.command.annotation.Permissive;
|
import me.totalfreedom.command.annotation.Permissive;
|
||||||
import me.totalfreedom.command.annotation.Subcommand;
|
import me.totalfreedom.command.annotation.Subcommand;
|
||||||
@ -18,8 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
@Permissive(perm = "datura.halt")
|
@Permissive(perm = "datura.halt")
|
||||||
public class HaltCommand extends Commander
|
public class HaltCommand extends Commander
|
||||||
{
|
{
|
||||||
private final Datura plugin = Shortcuts.provideModule(Datura.class)
|
private final Datura plugin = Shortcuts.provideModule(Datura.class);
|
||||||
.getModule();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this command object. The provided {@link JavaPlugin} should be the plugin which contains the
|
* 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})
|
@Subcommand(permission = "datura.halt", args = {Player.class, String.class})
|
||||||
public void haltPlayer(final CommandSender sender, final Player target, final String toggle)
|
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})
|
@Subcommand(permission = "datura.halt.all", args = {String.class, String.class})
|
||||||
public void haltAll(final CommandSender sender, final String all, final String toggle)
|
public void haltAll(final CommandSender sender, final String all, final String toggle)
|
||||||
{
|
{
|
||||||
@ -65,11 +68,8 @@ public class HaltCommand extends Commander
|
|||||||
{
|
{
|
||||||
Bukkit.getServer()
|
Bukkit.getServer()
|
||||||
.getOnlinePlayers()
|
.getOnlinePlayers()
|
||||||
.forEach(player ->
|
.forEach(player -> plugin.getHalter()
|
||||||
{
|
.halt(player.getUniqueId()));
|
||||||
plugin.getHalter()
|
|
||||||
.halt(player.getUniqueId());
|
|
||||||
});
|
|
||||||
|
|
||||||
final Component message = sender.name()
|
final Component message = sender.name()
|
||||||
.append(Component.text(": Freezing all players"))
|
.append(Component.text(": Freezing all players"))
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,8 @@ public class Halter implements Listener
|
|||||||
this.haltedPlayers.remove(uuid);
|
this.haltedPlayers.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear()
|
||||||
|
{
|
||||||
this.haltedPlayers.clear();
|
this.haltedPlayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,16 +230,16 @@ public class SimpleUserData implements UserData
|
|||||||
return hasCustomACFormat;
|
return hasCustomACFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AdminChatFormat getCustomACFormat()
|
||||||
|
{
|
||||||
|
return AdminChatFormat.deserialize(customACFormat);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomACFormat(final String format)
|
public void setCustomACFormat(final String format)
|
||||||
{
|
{
|
||||||
this.hasCustomACFormat = format.equals(AdminChatFormat.DEFAULT.serialize());
|
this.hasCustomACFormat = format.equals(AdminChatFormat.DEFAULT.serialize());
|
||||||
this.customACFormat = format;
|
this.customACFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AdminChatFormat getCustomACFormat()
|
|
||||||
{
|
|
||||||
return AdminChatFormat.deserialize(customACFormat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.base;
|
package me.totalfreedom.base;
|
||||||
|
|
||||||
|
import me.totalfreedom.display.adminchat.AdminChatDisplay;
|
||||||
import me.totalfreedom.event.EventBus;
|
import me.totalfreedom.event.EventBus;
|
||||||
import me.totalfreedom.service.FreedomExecutor;
|
import me.totalfreedom.service.FreedomExecutor;
|
||||||
import me.totalfreedom.service.SubscriptionProvider;
|
import me.totalfreedom.service.SubscriptionProvider;
|
||||||
@ -23,6 +24,10 @@ public class Patchwork extends JavaPlugin
|
|||||||
* The {@link FreedomExecutor} for this plugin.
|
* The {@link FreedomExecutor} for this plugin.
|
||||||
*/
|
*/
|
||||||
private final FreedomExecutor executor = new FreedomExecutor();
|
private final FreedomExecutor executor = new FreedomExecutor();
|
||||||
|
/**
|
||||||
|
* The {@link AdminChatDisplay} for this plugin.
|
||||||
|
*/
|
||||||
|
private final AdminChatDisplay acdisplay = new AdminChatDisplay();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides this plugin instance through a safe static method. This is effectively the same thing as using
|
* Provides this plugin instance through a safe static method. This is effectively the same thing as using
|
||||||
@ -89,4 +94,15 @@ public class Patchwork extends JavaPlugin
|
|||||||
{
|
{
|
||||||
return eventBus;
|
return eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link AdminChatDisplay} for this plugin. The AdminChatDisplay is used to display messages sent in
|
||||||
|
* adminchat.
|
||||||
|
*
|
||||||
|
* @return the {@link AdminChatDisplay}
|
||||||
|
*/
|
||||||
|
public AdminChatDisplay getAdminChatDisplay()
|
||||||
|
{
|
||||||
|
return acdisplay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
package me.totalfreedom.base;
|
package me.totalfreedom.base;
|
||||||
|
|
||||||
import me.totalfreedom.provider.ModuleProvider;
|
import me.totalfreedom.api.Context;
|
||||||
|
import me.totalfreedom.user.User;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class Shortcuts
|
public final class Shortcuts
|
||||||
{
|
{
|
||||||
private Shortcuts() {
|
private Shortcuts()
|
||||||
|
{
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends JavaPlugin> ModuleProvider<T> provideModule(final Class<T> pluginClass) {
|
public static <T extends JavaPlugin> T provideModule(final Class<T> pluginClass)
|
||||||
return Patchwork.getInstance().getRegistrations().getModuleRegistry().getProvider(pluginClass);
|
{
|
||||||
|
return Patchwork.getInstance()
|
||||||
|
.getRegistrations()
|
||||||
|
.getModuleRegistry()
|
||||||
|
.getProvider(pluginClass)
|
||||||
|
.getModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User getUser(final Player player)
|
||||||
|
{
|
||||||
|
return Patchwork.getInstance()
|
||||||
|
.getRegistrations()
|
||||||
|
.getUserRegistry()
|
||||||
|
.getUser(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public final class BukkitDelegate extends Command implements PluginIdentifiableC
|
|||||||
@NotNull final String commandLabel,
|
@NotNull final String commandLabel,
|
||||||
@NotNull final String[] args)
|
@NotNull final String[] args)
|
||||||
{
|
{
|
||||||
if (sender instanceof ConsoleCommandSender && noConsole)
|
if (!(sender instanceof Player) && noConsole)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("This command can only be run by players."));
|
sender.sendMessage(Component.text("This command can only be run by players."));
|
||||||
return true;
|
return true;
|
||||||
@ -101,8 +101,13 @@ public final class BukkitDelegate extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (noConsole) {
|
||||||
|
command.getBaseMethod()
|
||||||
|
.invoke(command, (Player)sender);
|
||||||
|
} else {
|
||||||
command.getBaseMethod()
|
command.getBaseMethod()
|
||||||
.invoke(command, sender);
|
.invoke(command, sender);
|
||||||
|
}
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
FreedomLogger.getLogger("Patchwork")
|
FreedomLogger.getLogger("Patchwork")
|
||||||
@ -154,9 +159,15 @@ public final class BukkitDelegate extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (noConsole) {
|
||||||
|
command.getSubcommands()
|
||||||
|
.get(node)
|
||||||
|
.invoke(command, (Player)sender, objects);
|
||||||
|
} else {
|
||||||
command.getSubcommands()
|
command.getSubcommands()
|
||||||
.get(node)
|
.get(node)
|
||||||
.invoke(command, sender, objects);
|
.invoke(command, sender, objects);
|
||||||
|
}
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
FreedomLogger.getLogger("Patchwork")
|
FreedomLogger.getLogger("Patchwork")
|
||||||
|
@ -3,9 +3,11 @@ package me.totalfreedom.display.adminchat;
|
|||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import me.totalfreedom.base.Patchwork;
|
import me.totalfreedom.base.Patchwork;
|
||||||
import me.totalfreedom.base.Shortcuts;
|
import me.totalfreedom.base.Shortcuts;
|
||||||
import me.totalfreedom.data.UserRegistry;
|
import me.totalfreedom.security.Groups;
|
||||||
import me.totalfreedom.user.UserData;
|
import me.totalfreedom.user.UserData;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -19,10 +21,12 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class AdminChatDisplay
|
public class AdminChatDisplay
|
||||||
{
|
{
|
||||||
|
protected static final String ACPERM = "patchwork.adminchat";
|
||||||
private final Map<UUID, AdminChatFormat> adminChatFormat = new HashMap<>();
|
private final Map<UUID, AdminChatFormat> adminChatFormat = new HashMap<>();
|
||||||
private final Set<UUID> toggledChat = new HashSet<>();
|
private final Set<UUID> toggledChat = new HashSet<>();
|
||||||
|
|
||||||
public AdminChatDisplay() {
|
public AdminChatDisplay()
|
||||||
|
{
|
||||||
new ACListener(this);
|
new ACListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +65,39 @@ public class AdminChatDisplay
|
|||||||
return adminChatFormat;
|
return adminChatFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isToggled(final Player player)
|
||||||
|
{
|
||||||
|
return toggledChat.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleChat(final Player player)
|
||||||
|
{
|
||||||
|
if (toggledChat.contains(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
toggledChat.remove(player.getUniqueId());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
toggledChat.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChatMessage(final CommandSender sender, final Component message)
|
||||||
|
{
|
||||||
|
Bukkit.getOnlinePlayers()
|
||||||
|
.forEach(player ->
|
||||||
|
{
|
||||||
|
if (player.hasPermission(ACPERM))
|
||||||
|
{
|
||||||
|
final Component formatted = Component.empty();
|
||||||
|
formatted.append(getFormat(player).format(sender.getName(), Groups.fromSender(sender)))
|
||||||
|
.append(Component.space())
|
||||||
|
.append(message);
|
||||||
|
|
||||||
|
player.sendMessage(formatted);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static final class ACListener implements Listener
|
public static final class ACListener implements Listener
|
||||||
{
|
{
|
||||||
private final AdminChatDisplay display;
|
private final AdminChatDisplay display;
|
||||||
@ -69,26 +106,34 @@ public class AdminChatDisplay
|
|||||||
{
|
{
|
||||||
this.display = display;
|
this.display = display;
|
||||||
Bukkit.getPluginManager()
|
Bukkit.getPluginManager()
|
||||||
.registerEvents(this, Shortcuts.provideModule(Patchwork.class)
|
.registerEvents(this, Shortcuts.provideModule(Patchwork.class));
|
||||||
.getModule());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerChat(final AsyncChatEvent event) {
|
public void playerChat(final AsyncChatEvent event)
|
||||||
if (display.getPlayers().contains(event.getPlayer().getUniqueId())) {
|
{
|
||||||
|
if (display.isToggled(event.getPlayer()))
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
display.adminChatMessage(event.getPlayer(), event.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerJoin(final PlayerJoinEvent event) {
|
public void playerJoin(final PlayerJoinEvent event)
|
||||||
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player.hasPermission("patchwork.adminchat")) {
|
if (player.hasPermission(ACPERM))
|
||||||
final UserData data = Patchwork.getInstance().getRegistrations().getUserRegistry().fromPlayer(player);
|
{
|
||||||
if (data.hasCustomACFormat()) {
|
final UserData data = Patchwork.getInstance()
|
||||||
|
.getRegistrations()
|
||||||
|
.getUserRegistry()
|
||||||
|
.fromPlayer(player);
|
||||||
|
if (data.hasCustomACFormat())
|
||||||
|
{
|
||||||
display.addPlayer(player, data.getCustomACFormat());
|
display.addPlayer(player, data.getCustomACFormat());
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
display.addPlayer(player, AdminChatFormat.DEFAULT);
|
display.addPlayer(player, AdminChatFormat.DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,25 @@ public final class AdminChatFormat
|
|||||||
this.rank = Component.text(builder.openBracket(), builder.bracketColor())
|
this.rank = Component.text(builder.openBracket(), builder.bracketColor())
|
||||||
.append(Component.text("%rank%", builder.rankColor()))
|
.append(Component.text("%rank%", builder.rankColor()))
|
||||||
.append(Component.text(builder.closeBracket(), builder.bracketColor()));
|
.append(Component.text(builder.closeBracket(), builder.bracketColor()));
|
||||||
this.chatSplitter = Component.text(builder.chatSplitter(), NamedTextColor.WHITE);
|
|
||||||
|
|
||||||
this.fullFormat = prefix.append(Component.space())
|
// Nice formatting :(
|
||||||
|
if (builder.chatSplitter()
|
||||||
|
.equals(":"))
|
||||||
|
{
|
||||||
|
this.chatSplitter = Component.text(":", NamedTextColor.WHITE);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
this.chatSplitter = Component.space()
|
||||||
|
.append(Component.text(builder.chatSplitter(), NamedTextColor.WHITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatting because []: is cleaner than [] :, but anything else such as [] >> or [] -> looks better with the space between.
|
||||||
|
this.fullFormat = prefix.appendSpace()
|
||||||
.append(userName)
|
.append(userName)
|
||||||
.append(Component.space())
|
.appendSpace()
|
||||||
.append(rank)
|
.append(rank)
|
||||||
.append(Component.space())
|
|
||||||
.append(chatSplitter)
|
.append(chatSplitter)
|
||||||
.append(Component.space());
|
.appendSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdminChatFormat deserialize(final String serialized)
|
public static AdminChatFormat deserialize(final String serialized)
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
package me.totalfreedom.security;
|
package me.totalfreedom.security;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public enum Groups
|
public enum Groups
|
||||||
{
|
{
|
||||||
NON_OP("patchwork.group.non-op"),
|
NON_OP("patchwork.group.non-op", "Non-OP"),
|
||||||
OP("patchwork.group.op"),
|
OP("patchwork.group.op", "OP"),
|
||||||
SUPER_ADMIN("patchwork.group.super"),
|
SUPER_ADMIN("patchwork.group.super", "Super Admin"),
|
||||||
SENIOR_ADMIN("patchwork.group.senior"),
|
SENIOR_ADMIN("patchwork.group.senior", "Senior Admin"),
|
||||||
DEVELOPER("patchwork.group.dev"),
|
DEVELOPER("patchwork.group.dev", "Developer"),
|
||||||
EXECUTIVE("patchwork.group.exec"),
|
EXECUTIVE("patchwork.group.exec", "Executive"),
|
||||||
OWNER("patchwork.group.owner");
|
OWNER("patchwork.group.owner", "Owner");
|
||||||
|
|
||||||
private final String permission;
|
private final String permission;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
Groups(final String permission)
|
Groups(final String permission, final String name)
|
||||||
{
|
{
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermission()
|
public String getPermission()
|
||||||
@ -27,4 +37,19 @@ public enum Groups
|
|||||||
{
|
{
|
||||||
return this.permission;
|
return this.permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String fromPlayer(final Player player) {
|
||||||
|
for (final Groups group : values()) {
|
||||||
|
if (player.hasPermission(group.getPermission())) {
|
||||||
|
return group.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Groups.NON_OP.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String fromSender(final CommandSender sender) {
|
||||||
|
if (!(sender instanceof Player)) return "CONSOLE";
|
||||||
|
|
||||||
|
return fromPlayer((Player) sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user