This commit is contained in:
Business Goose 2022-03-31 01:58:04 +01:00
parent 912ae7d0e3
commit 85296bd864
No known key found for this signature in database
GPG key ID: 77DCA801362E9645

View file

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.commands; package me.StevenLawson.TotalFreedomMod.commands;
import java.util.UUID;
import me.StevenLawson.TotalFreedomMod.admin.AdminList; import me.StevenLawson.TotalFreedomMod.admin.AdminList;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -7,19 +8,23 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.UUID;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME) @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
public class Command_myadmin extends FreedomCommand { public class Command_myadmin extends FreedomCommand {
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
final UUID uuid = sender_p.getUniqueId(); // Get the sender's uuid as a variable.
if(args.length == 1) {
if ("clearloginmsg".equalsIgnoreCase(args[0])) {
playerMsg(sender, ChatColor.GRAY + "Cleared your custom login message."); // Notify player that the login message has been set.
AdminList.getEntry(uuid).setCustomLoginMessage(""); // Set the custom login message to the value. @Override
AdminList.save(AdminList.getEntry(uuid)); // Save the modified value to the super admin configuration. public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel,
String[] args, boolean senderIsConsole) {
final UUID uuid = sender_p.getUniqueId(); // Get the sender's uuid as a variable.
if (args.length == 1) {
if ("clearloginmsg".equalsIgnoreCase(args[0])) {
playerMsg(sender, ChatColor.GRAY
+ "Cleared your custom login message."); // Notify player that the login message has been set.
AdminList.getEntry(uuid)
.setCustomLoginMessage(""); // Set the custom login message to the value.
AdminList.save(AdminList.getEntry(
uuid)); // Save the modified value to the super admin configuration.
AdminList.updateIndexLists(); // Update and refresh configuration. AdminList.updateIndexLists(); // Update and refresh configuration.
return true; return true;
@ -28,11 +33,23 @@ public class Command_myadmin extends FreedomCommand {
} }
} else if (args.length >= 2) { } else if (args.length >= 2) {
if ("setlogin".equalsIgnoreCase(args[0])) { if ("setlogin".equalsIgnoreCase(args[0])) {
final String inputMessage = StringUtils.join(args, " ", 1, args.length); // Parse the input provided. if (AdminList.getEntry(uuid)
playerMsg(sender, ChatColor.GRAY + "Set your custom login message."); // Notify player that the login message has been set. == null) { // This means they're not actually in the super config. It will throw an exception if we don't return here.
playerMsg(sender, ChatColor.GRAY + "Your login message will show up as: \n" + ChatColor.AQUA + sender_p.getPlayer().getName() + " is " + ChatColor.translateAlternateColorCodes('&', inputMessage)); return true;
AdminList.getEntry(uuid).setCustomLoginMessage(inputMessage); // Set the custom login message to the value. }
AdminList.save(AdminList.getEntry(uuid)); // Save the modified value to the super admin configuration.
final String inputMessage = StringUtils.join(args, " ", 1,
args.length); // Parse the input provided.
playerMsg(sender, ChatColor.GRAY
+ "Set your custom login message."); // Notify player that the login message has been set.
playerMsg(sender,
ChatColor.GRAY + "Your login message will show up as: \n" + ChatColor.AQUA
+ sender_p.getPlayer().getName() + " is "
+ ChatColor.translateAlternateColorCodes('&', inputMessage));
AdminList.getEntry(uuid).setCustomLoginMessage(
inputMessage); // Set the custom login message to the value.
AdminList.save(AdminList.getEntry(
uuid)); // Save the modified value to the super admin configuration.
AdminList.updateIndexLists(); // Update and refresh configuration. AdminList.updateIndexLists(); // Update and refresh configuration.
return true; return true;