-
Notifications
You must be signed in to change notification settings - Fork 219
Add rainbow commands #2061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lemonsked
wants to merge
6
commits into
TotalFreedom:devel
Choose a base branch
from
lemonsked:devel
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add rainbow commands #2061
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbownick.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package me.totalfreedom.totalfreedommod.command; | ||
|
|
||
| import me.totalfreedom.totalfreedommod.rank.Rank; | ||
| import me.totalfreedom.totalfreedommod.util.FUtil; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.bukkit.Bukkit; | ||
| 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 = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>") | ||
| public class Command_rainbownick extends FreedomCommand | ||
| { | ||
|
|
||
| @Override | ||
| public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
| { | ||
| 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 + "]+$")) | ||
| { | ||
| msg("That nickname contains invalid characters."); | ||
Wild1145 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return true; | ||
| } | ||
|
|
||
| if (nickPlain.length() < 4 || nickPlain.length() > 30) | ||
| { | ||
| msg("Your nickname must be between 4 and 30 characters long."); | ||
Wild1145 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return true; | ||
| } | ||
|
|
||
| for (Player player : Bukkit.getOnlinePlayers()) | ||
| { | ||
| if (player == playerSender) | ||
| { | ||
| continue; | ||
| } | ||
| if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) | ||
| { | ||
| msg("That nickname is already in use."); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| final String newNick = FUtil.rainbowify(ChatColor.stripColor(FUtil.colorize(nickPlain))); | ||
|
|
||
| plugin.esb.setNickname(sender.getName(), newNick); | ||
|
|
||
| msg("Your nickname is now: " + newNick); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package me.totalfreedom.totalfreedommod.command; | ||
|
|
||
| import java.util.Iterator; | ||
| import me.totalfreedom.totalfreedommod.rank.Rank; | ||
| import me.totalfreedom.totalfreedommod.util.FUtil; | ||
| 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; | ||
|
|
||
| @CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) | ||
| @CommandParameters(description = "Gives you a rainbow tag", usage = "/<command> <tag>") | ||
| public class Command_rainbowtag extends FreedomCommand | ||
| { | ||
|
|
||
| @Override | ||
| public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
| { | ||
| if (args.length < 1) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| final String tag = ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))); | ||
|
|
||
| if(tag.length() > 20) | ||
| { | ||
| msg("That tag is too long (Max is 20 characters)."); | ||
| return true; | ||
| } | ||
|
|
||
| for (String word : Command_tag.FORBIDDEN_WORDS) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will need to be changed, assuming there is a merge of the 5.0.2 release as the forbidden tags system has changed. That's something I can change though once the PR goes in. |
||
| { | ||
| if (tag.contains(word)) | ||
| { | ||
| msg("That tag contains a forbidden word."); | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| plugin.pl.getPlayer(playerSender).setTag(FUtil.rainbowify(tag)); | ||
|
|
||
| msg("Set tag to " + tag); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.