Login messages for players. Still need to come up with login messaghes

This commit is contained in:
Seth
2020-10-02 02:27:06 -07:00
parent f8304aecd7
commit 533e4fe369
16 changed files with 228 additions and 134 deletions
@@ -0,0 +1,52 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Change your login message", usage = "/<command> [message]")
public class Command_loginmessage extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isStaff(playerSender))
{
msg("You did not purchase the ability to use login messages! Purchase the ability from the shop.", ChatColor.RED);
return true;
}
if (args.length == 0)
{
playerSender.openInventory(plugin.sh.generateLoginMessageGUI(playerSender));
return true;
}
checkRank(Rank.ADMIN);
String message = StringUtils.join(args, " ");
if (!message.contains("%rank%") && !message.contains("%coloredrank%"))
{
msg("Your login message must contain your rank. Use either %rank% or %coloredrank% to specify where you want the rank", ChatColor.RED);
return true;
}
int length = message.replace("%name%", "").replace("%rank%", "").replace("%coloredrank%", "").replace("%det%", "").length();
if (length > 100)
{
msg("Your login message cannot be more than 100 characters (excluding your rank and your name)", ChatColor.RED);
return true;
}
PlayerData data = getData(playerSender);
data.setLoginMessage(message);
plugin.pl.save(data);
msg("Your login message is now the following:\n" + plugin.rm.craftLoginMessage(playerSender, message), ChatColor.GREEN);
return true;
}
}
@@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Manage your staff entry.", usage = "/<command> [-o <staff member>] <clearips | clearip <ip> | setlogin <message> | clearlogin | setscformat <format> | clearscformat> | oldtags | logstick | syncroles>")
public class Command_mystaff extends FreedomCommand
public class Command_myadmin extends FreedomCommand
{
@Override
@@ -139,46 +139,6 @@ public class Command_mystaff extends FreedomCommand
return true;
}
case "setlogin":
{
checkRank(Rank.ADMIN);
if (args.length < 2)
{
return false;
}
String message = StringUtils.join(args, " ", 1, args.length);
if (!message.contains("%rank%") && !message.contains("%coloredrank%"))
{
msg("Your login message must contain your rank. Use either %rank% or %coloredrank% to specify where you want the rank", ChatColor.RED);
return true;
}
int length = message.replace("%name%", "").replace("%rank%", "").replace("%coloredrank%", "").length();
if (length > 100)
{
msg("Your login message cannot be more than 100 characters (excluding your rank and your name)", ChatColor.RED);
return true;
}
FUtil.staffAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
target.setLoginMessage(message);
String previewMessage = plugin.rm.craftLoginMessage(targetPlayer, message);
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
msg("> " + previewMessage);
plugin.sl.save(target);
plugin.sl.updateTables();
return true;
}
case "clearlogin":
{
checkRank(Rank.ADMIN);
FUtil.staffAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
target.setLoginMessage(null);
plugin.sl.save(target);
plugin.sl.updateTables();
return true;
}
case "setscformat":
{
String format = StringUtils.join(args, " ", 1, args.length);
@@ -229,10 +189,6 @@ public class Command_mystaff extends FreedomCommand
return true;
}
case "genbackupcodes":
msg("Moved to /pv genbackupcodes", ChatColor.RED);
return true;
default:
{
return false;
@@ -248,8 +204,8 @@ public class Command_mystaff extends FreedomCommand
return Collections.emptyList();
}
List<String> singleArguments = Arrays.asList("clearips", "setlogin", "setscformat");
List<String> doubleArguments = Arrays.asList("clearip", "clearlogin", "clearscformat", "oldtags", "syncroles");
List<String> singleArguments = Arrays.asList("clearips", "setscformat");
List<String> doubleArguments = Arrays.asList("clearip", "clearscformat", "syncroles");
if (args.length == 1)
{
List<String> options = new ArrayList<>();