Skip to content

Commit

Permalink
Fixed /team title
Browse files Browse the repository at this point in the history
Issue Reference: #221
  • Loading branch information
booksaw committed Aug 30, 2021
1 parent d9a64d8 commit 8339a8c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ Bug Fixes:
Features:
- Added Mexican Spanish translations (es_mx) (#222)

Improvements:
- Fixed a typo in messages.yml

Bug Fixes:

- Fixed a bug causing /team title to not work (#221)

TODO (any TODO which is not specifically code), mainly used for reminders to update documentation

Headings:
Expand Down
2 changes: 1 addition & 1 deletion messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ notTeam: '&6&4That team does not exist try &b/team create <name>'
needSameTeam: '&6You are not in the same team as that person'
noPerm: '&4You do not have permission to do that'
prefixSyntax: '&7[%s&7] &r%s'
bannedChar: '&4A character you tried to use is banned"'
bannedChar: '&4A character you tried to use is banned'
noTeam: '&4That team does not exist'
loading: '&6Loading'
cooldown.wait: '&4You need to wait another %s seconds before running that!'
Expand Down
17 changes: 10 additions & 7 deletions src/com/booksaw/betterTeams/commands/team/TitleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ public CommandResponse onCommand(TeamPlayer player, String label, String[] args,
args = new String[] { "me", args[0] };
}

Player toTitlePlayer = Bukkit.getPlayer(args[0]);
Player toTitlePlayer;

if (args[0].equals("me")) {
// player is online so this should not cause any issues
toTitlePlayer = player.getPlayer().getPlayer();
} else {
toTitlePlayer = Bukkit.getPlayer(args[0]);
}

if (toTitlePlayer == null) {
return new CommandResponse("noPlayer");
}

if (args[0].equals("me")) {
toTitle = player;
} else {
toTitle = team.getTeamPlayer(toTitlePlayer);
}
toTitle = team.getTeamPlayer(toTitlePlayer);

if (toTitle == null) {
return new CommandResponse("noPlayer");
Expand All @@ -54,7 +57,7 @@ public CommandResponse onCommand(TeamPlayer player, String label, String[] args,
return new CommandResponse("title.tooLong");
}

if (Team.isValidTeamName(args[1])) {
if (!Team.isValidTeamName(args[1])) {
return new CommandResponse("bannedChar");
}

Expand Down
6 changes: 2 additions & 4 deletions src/com/booksaw/betterTeams/commands/teama/TitleTeama.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public CommandResponse onCommand(CommandSender sender, String label, String[] ar
return new CommandResponse("title.tooLong");
}

for (char bannedChar : bannedChars) {
if (args[1].contains(bannedChar + "")) {
return new CommandResponse("bannedChar");
}
if (!Team.isValidTeamName(args[1])) {
return new CommandResponse("bannedChar");
}

args[1] = ChatColor.translateAlternateColorCodes('&', args[1]);
Expand Down

0 comments on commit 8339a8c

Please sign in to comment.