mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Add tag messages to messages.yml
This commit is contained in:
parent
3b2566039d
commit
5b8854b7fe
@ -157,9 +157,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
send(sender, component);
|
send(sender, component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (PlayerNotFoundException | CommandFailException
|
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
|
||||||
| ConsoleOnlyException | ConsoleMustDefinePlayerException
|
|
||||||
| PlayerNotBannedException ex)
|
|
||||||
{
|
{
|
||||||
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
|
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
|
||||||
}
|
}
|
||||||
@ -294,7 +292,6 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a player has enough permissions or is high enough a rank
|
* Checks whether a player has enough permissions or is high enough a rank
|
||||||
*
|
*
|
||||||
@ -414,17 +411,29 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a message entry from the "messages.yml" to a component
|
* Converts a message entry from the "messages.yml" to a Component
|
||||||
*
|
*
|
||||||
* @param s The message entry
|
* @param s The message entry
|
||||||
* @param objects Any objects to replace in order
|
* @param objects Any objects to replace in order
|
||||||
* @return A kyori component
|
* @return A Kyori component
|
||||||
*/
|
*/
|
||||||
protected Component messageComponent(String s, Object... objects)
|
protected Component messageComponent(String s, Object... objects)
|
||||||
{
|
{
|
||||||
return PlexUtils.messageComponent(s, objects);
|
return PlexUtils.messageComponent(s, objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a message entry from the "messages.yml" to a String
|
||||||
|
*
|
||||||
|
* @param s The message entry
|
||||||
|
* @param objects Any objects to replace in order
|
||||||
|
* @return A String
|
||||||
|
*/
|
||||||
|
protected String messageString(String s, Object... objects)
|
||||||
|
{
|
||||||
|
return PlexUtils.messageString(s, objects);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts usage to a component
|
* Converts usage to a component
|
||||||
*
|
*
|
||||||
@ -489,10 +498,10 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string to a legacy kyori component
|
* Converts a string to a legacy Kyori component
|
||||||
*
|
*
|
||||||
* @param s The string to convert
|
* @param s The string to convert
|
||||||
* @return A kyori component
|
* @return A Kyori component
|
||||||
*/
|
*/
|
||||||
protected Component componentFromString(String s)
|
protected Component componentFromString(String s)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -17,7 +16,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
//TODO: Redo Messages and have customizable messages
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.tag", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.tag", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "tag", aliases = "prefix", description = "Manages your prefix", usage = "/<command> <set | clear> <prefix | player>")
|
@CommandParameters(name = "tag", aliases = "prefix", description = "Manages your prefix", usage = "/<command> <set | clear> <prefix | player>")
|
||||||
public class TagCMD extends PlexCommand
|
public class TagCMD extends PlexCommand
|
||||||
@ -48,10 +46,10 @@ public class TagCMD extends PlexCommand
|
|||||||
String prefix = StringUtils.join(args, " ", 1, args.length);
|
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||||
if (ChatColor.stripColor(prefix).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
if (ChatColor.stripColor(prefix).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
||||||
{
|
{
|
||||||
return componentFromString("The maximum length for a tag may only be " + plugin.config.getInt("chat.max-tag-length", 16));
|
return messageComponent("maximumPrefixLength", plugin.config.getInt("chat.max-tag-length", 16));
|
||||||
}
|
}
|
||||||
player.setPrefix(prefix);
|
player.setPrefix(prefix);
|
||||||
return Component.text("Your prefix has been set to ").color(NamedTextColor.AQUA).append(componentFromString(prefix));
|
return messageComponent("prefixSetTo", prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("clear"))
|
if (args[0].equalsIgnoreCase("clear"))
|
||||||
@ -65,15 +63,14 @@ public class TagCMD extends PlexCommand
|
|||||||
|
|
||||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||||
player.setPrefix("");
|
player.setPrefix("");
|
||||||
return Component.text("Your prefix has been cleared.").color(NamedTextColor.AQUA);
|
return messageComponent("prefixCleared");
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRank(sender, Rank.ADMIN, "plex.tag.clear.others");
|
checkRank(sender, Rank.ADMIN, "plex.tag.clear.others");
|
||||||
|
|
||||||
Player target = getNonNullPlayer(args[1]);
|
Player target = getNonNullPlayer(args[1]);
|
||||||
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
||||||
plexTarget.setPrefix("");
|
plexTarget.setPrefix("");
|
||||||
return Component.text("You have cleared " + target.getName() + "'s prefix.").color(NamedTextColor.AQUA);
|
messageComponent("otherPrefixCleared");
|
||||||
}
|
}
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ banning:
|
|||||||
|
|
||||||
chat:
|
chat:
|
||||||
max-tag-length: 16
|
max-tag-length: 16
|
||||||
name-color: 'f' #Color code for name color
|
# Color code for name color
|
||||||
|
name-color: 'f'
|
||||||
|
|
||||||
# Settings for commands relating to Plex
|
# Settings for commands relating to Plex
|
||||||
commands:
|
commands:
|
||||||
|
@ -101,4 +101,8 @@ teleportedToWorldSpawn: "<aqua>Teleporting to the local spawn"
|
|||||||
toggleCommandSpy: "CommandSpy has been"
|
toggleCommandSpy: "CommandSpy has been"
|
||||||
enabled: "enabled."
|
enabled: "enabled."
|
||||||
disabled: "disabled."
|
disabled: "disabled."
|
||||||
adminChatFormat: '&8[&9AdminChat&8] &4<v> &7» &6<v>'
|
adminChatFormat: '&8[&9AdminChat&8] &4<v> &7» &6<v>'
|
||||||
|
maximumPrefixLength: "<red>The maximum length for a tag may only be <v>."
|
||||||
|
prefixCleared: "<aqua>Your prefix has been cleared."
|
||||||
|
otherPrefixCleared: "<aqua>You have cleared <v>'s prefix."
|
||||||
|
prefixSetTo: "<aqua>Your prefix has been set to <v>"
|
Loading…
Reference in New Issue
Block a user