mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 20:47:37 +00:00
minor fixing
This commit is contained in:
parent
d1569cb3c0
commit
b29a176fa9
@ -1,97 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.api.Interpolator;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "nickgradient", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
||||
public class Command_nickgradient extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||
{
|
||||
msg("Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String nick = args[2].trim();
|
||||
|
||||
if (nick.length() < 3 || nick.length() > 30)
|
||||
{
|
||||
msg("Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player == playerSender)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player.getName().equalsIgnoreCase(nick) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nick))
|
||||
{
|
||||
msg("That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String from = "", to = "";
|
||||
java.awt.Color awt1, awt2;
|
||||
try
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("random") ||
|
||||
args[0].equalsIgnoreCase("r"))
|
||||
{
|
||||
awt1 = FUtil.getRandomAWTColor();
|
||||
from = " (From: " + FUtil.getHexStringOfAWTColor(awt1) + ")";
|
||||
} else
|
||||
{
|
||||
awt1 = java.awt.Color.decode(args[0]);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("random") ||
|
||||
args[1].equalsIgnoreCase("r"))
|
||||
{
|
||||
awt2 = FUtil.getRandomAWTColor();
|
||||
to = " (To: " + FUtil.getHexStringOfAWTColor(awt2) + ")";
|
||||
} else
|
||||
{
|
||||
awt2 = java.awt.Color.decode(args[1]);
|
||||
}
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid hex values.");
|
||||
return true;
|
||||
}
|
||||
Color c1 = FUtil.fromAWT(awt1);
|
||||
Color c2 = FUtil.fromAWT(awt2);
|
||||
List<Color> gradient = FUtil.createColorGradient(c1, c2, nick.length());
|
||||
String[] splitNick = nick.split("");
|
||||
for (int i = 0; i < splitNick.length; i++)
|
||||
{
|
||||
splitNick[i] = net.md_5.bungee.api.ChatColor.of(FUtil.toAWT(gradient.get(i))) + splitNick[i];
|
||||
}
|
||||
nick = StringUtils.join(splitNick, "");
|
||||
final String outputNick = FUtil.colorize(nick);
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), outputNick);
|
||||
|
||||
msg("Your nickname is now: '" + outputNick + ChatColor.GRAY + "'" + from + to);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -9,7 +9,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(permission = "nickmm", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Colorify your nickname.", usage = "/<command>")
|
||||
@CommandParameters(description = """
|
||||
Essentials Interface Command - Colorify your nickname.
|
||||
For Example: /nickmm <red><name> will color your name red.
|
||||
You can also use tags like <gradient> and <rainbow>.
|
||||
For example: /nickmm <gradient:red:green:blue><name>""", usage = "/<command> <nickname>")
|
||||
public class Command_nickmm extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -1,64 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(permission = "nickrainbow", source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
||||
public class Command_nickrainbow extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
||||
{
|
||||
msgNew("<red>Essentials is not enabled on this server.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String nickPlain = ChatColor.stripColor(FUtil.colorize(args[0].trim()));
|
||||
|
||||
if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$"))
|
||||
{
|
||||
msgNew("<red>That nickname contains invalid characters.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nickPlain.length() < 3 || nickPlain.length() > 30)
|
||||
{
|
||||
msgNew("<red>Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player == playerSender)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
|
||||
{
|
||||
msgNew("<red>That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final String newNick = FUtil.rainbowify(ChatColor.stripColor(FUtil.colorize(nickPlain)));
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), newNick);
|
||||
|
||||
msgNew("Your nickname is now: <new>", Placeholder.component("new", FUtil.colorizeAsComponent(newNick)));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import net.kyori.adventure.text.format.TextColor;
|
||||
|
||||
public enum Title implements Displayable
|
||||
{
|
||||
|
||||
MASTER_BUILDER(Component.text("a"),
|
||||
Component.text("Master Builder"),
|
||||
Component.text("Master Builders"),
|
||||
|
@ -88,6 +88,7 @@ public class FUtil
|
||||
StandardTags.color(),
|
||||
StandardTags.rainbow(),
|
||||
StandardTags.gradient(),
|
||||
StandardTags.newline(),
|
||||
StandardTags.decorations(TextDecoration.ITALIC),
|
||||
StandardTags.decorations(TextDecoration.BOLD),
|
||||
StandardTags.decorations(TextDecoration.STRIKETHROUGH),
|
||||
|
@ -129,33 +129,35 @@ public class AdminChatListener
|
||||
// Server Owner
|
||||
if (server == null) throw new IllegalStateException();
|
||||
|
||||
return member.getRoles().map(role ->
|
||||
{
|
||||
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.OWNER;
|
||||
} else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.DEVELOPER;
|
||||
} else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.EXECUTIVE;
|
||||
} else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.ASST_EXEC;
|
||||
} else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.SENIOR_ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.MASTER_BUILDER.getGroup();
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).blockFirst();
|
||||
return member.getRoles()
|
||||
.filter(role -> SnowflakeEntry.acceptableRoleIDs().contains(role.getId()))
|
||||
.map(role ->
|
||||
{
|
||||
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.OWNER;
|
||||
} else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.DEVELOPER;
|
||||
} else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.EXECUTIVE;
|
||||
} else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return Title.ASST_EXEC;
|
||||
} else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.SENIOR_ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.ADMIN.getGroup();
|
||||
} else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||
{
|
||||
return GroupProvider.MASTER_BUILDER.getGroup();
|
||||
} else
|
||||
{
|
||||
return GroupProvider.OP.getGroup(); // This should only be reached when a user doesn't
|
||||
}
|
||||
}).blockFirst();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package me.totalfreedom.discord.util;
|
||||
import discord4j.common.util.Snowflake;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum SnowflakeEntry
|
||||
{
|
||||
ADMIN_CHAT_CHANNEL_ID(ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID),
|
||||
@ -32,4 +35,16 @@ public enum SnowflakeEntry
|
||||
{
|
||||
return Snowflake.of(entry.getString());
|
||||
}
|
||||
|
||||
public static Set<Snowflake> acceptableRoleIDs() {
|
||||
Set<Snowflake> acceptableRoleIDs = new HashSet<>();
|
||||
acceptableRoleIDs.add(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake());
|
||||
acceptableRoleIDs.add(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake());
|
||||
return acceptableRoleIDs;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user