mirror of
https://github.com/plexusorg/Module-Guilds.git
synced 2024-10-31 18:17:11 +00:00
allow spaces in warp names
make warp names only alphanumeric
This commit is contained in:
parent
2b3f146dbb
commit
1e43e49604
@ -65,6 +65,7 @@ public class Guilds extends PlexModule
|
|||||||
this.addDefaultMessage("guildNotOwner", "<red>You're not the owner of this guild!");
|
this.addDefaultMessage("guildNotOwner", "<red>You're not the owner of this guild!");
|
||||||
this.addDefaultMessage("guildPrefixSet", "<green>You have changed the guild prefix to '<gold>{0}</gold><green>'", "0 - The new prefix");
|
this.addDefaultMessage("guildPrefixSet", "<green>You have changed the guild prefix to '<gold>{0}</gold><green>'", "0 - The new prefix");
|
||||||
this.addDefaultMessage("guildPrefixCleared", "<green>Your guild's prefix has been cleared.");
|
this.addDefaultMessage("guildPrefixCleared", "<green>Your guild's prefix has been cleared.");
|
||||||
|
this.addDefaultMessage("guildWarpAlphanumeric", "<red>Warp names may only contain alphabetical and/or numerical characters.");
|
||||||
this.addDefaultMessage("guildWarpExists", "<red>'<gold>{0}</gold>'<red> is already an existing warp!", "0 - The warp name");
|
this.addDefaultMessage("guildWarpExists", "<red>'<gold>{0}</gold>'<red> is already an existing warp!", "0 - The warp name");
|
||||||
this.addDefaultMessage("guildWarpNotFound", "<red>'<gold>{0}</gold>'<red> is not a valid warp!", "0 - The warp name");
|
this.addDefaultMessage("guildWarpNotFound", "<red>'<gold>{0}</gold>'<red> is not a valid warp!", "0 - The warp name");
|
||||||
this.addDefaultMessage("guildWarpCreated", "<green>You have created a warp called '<dark_green>{0}</dark_green><green>'", "0 - The warp name");
|
this.addDefaultMessage("guildWarpCreated", "<green>You have created a warp called '<dark_green>{0}</dark_green><green>'", "0 - The warp name");
|
||||||
|
@ -15,10 +15,14 @@ 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;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>")
|
@CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>")
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp")
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp")
|
||||||
public class SetWarpSubCommand extends PlexCommand
|
public class SetWarpSubCommand extends PlexCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
public SetWarpSubCommand()
|
public SetWarpSubCommand()
|
||||||
{
|
{
|
||||||
super(false);
|
super(false);
|
||||||
@ -37,18 +41,24 @@ public class SetWarpSubCommand extends PlexCommand
|
|||||||
send(player, messageComponent("guildNotOwner"));
|
send(player, messageComponent("guildNotOwner"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args[0].length() > 16)
|
String warpName = StringUtils.join(args, " ");
|
||||||
|
if (warpName.length() > 16)
|
||||||
{
|
{
|
||||||
send(player, mmString("<red>The max length of a warp name is 16 characters!"));
|
send(player, mmString("<red>The max length of a warp name is 16 characters!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (guild.getWarps().containsKey(args[0].toLowerCase()))
|
if (guild.getWarps().containsKey(warpName.toLowerCase()))
|
||||||
{
|
{
|
||||||
send(player, messageComponent("guildWarpExists", args[0]));
|
send(player, messageComponent("guildWarpExists", warpName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
guild.getWarps().put(args[0].toLowerCase(), CustomLocation.fromLocation(player.getLocation()));
|
if (!StringUtils.isAlphanumericSpace(warpName.toLowerCase(Locale.ROOT)))
|
||||||
send(player, messageComponent("guildWarpCreated", args[0]));
|
{
|
||||||
|
send(player, messageComponent("guildWarpAlphanumeric"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
guild.getWarps().put(warpName.toLowerCase(), CustomLocation.fromLocation(player.getLocation()));
|
||||||
|
send(player, messageComponent("guildWarpCreated", warpName));
|
||||||
}, () -> send(player, messageComponent("guildNotFound")));
|
}, () -> send(player, messageComponent("guildNotFound")));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.CustomLocation;
|
import dev.plex.util.CustomLocation;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -30,12 +31,13 @@ public class WarpSubCommand extends PlexCommand
|
|||||||
}
|
}
|
||||||
assert player != null;
|
assert player != null;
|
||||||
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> {
|
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> {
|
||||||
if (!guild.getWarps().containsKey(args[0].toLowerCase()))
|
String warpName = StringUtils.join(args, " ");
|
||||||
|
if (!guild.getWarps().containsKey(warpName.toLowerCase()))
|
||||||
{
|
{
|
||||||
send(player, messageComponent("guildWarpNotFound", args[0]));
|
send(player, messageComponent("guildWarpNotFound", warpName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.teleportAsync(guild.getWarps().get(args[0].toLowerCase()).toLocation());
|
player.teleportAsync(guild.getWarps().get(warpName.toLowerCase()).toLocation());
|
||||||
}, () -> send(player, messageComponent("guildNotFound")));
|
}, () -> send(player, messageComponent("guildNotFound")));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user