2022-03-22 18:21:07 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.commands;
|
|
|
|
|
|
|
|
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
|
|
|
public class Command_myadmin extends FreedomCommand {
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
2022-03-22 20:48:01 +00:00
|
|
|
final UUID uuid = sender_p.getUniqueId(); // Get the sender's uuid as a variable.
|
2022-03-23 19:23:35 +00:00
|
|
|
if(args.length == 1) {
|
|
|
|
if ("clearloginmsg".equalsIgnoreCase(args[0])) {
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, ChatColor.GRAY + "Cleared your custom login message."); // Notify player that the login message has been set.
|
2022-03-23 19:23:35 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (args.length >= 2) {
|
2022-03-22 20:48:01 +00:00
|
|
|
if ("setlogin".equalsIgnoreCase(args[0])) {
|
2022-03-22 18:21:07 +00:00
|
|
|
final String inputMessage = StringUtils.join(args, " ", 1, args.length); // Parse the input provided.
|
|
|
|
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, ChatColor.GRAY + "Set your custom login message."); // Notify player that the login message has been set.
|
2022-03-22 18:21:07 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
return true;
|
2022-03-23 19:23:35 +00:00
|
|
|
} else {
|
2022-03-22 20:55:57 +00:00
|
|
|
return false;
|
2022-03-22 18:21:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|