Skip to content

Commit 4dbf118

Browse files
committed
minor improvements
1 parent d931351 commit 4dbf118

File tree

9 files changed

+28
-23
lines changed

9 files changed

+28
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Run the command again to disable the message channel.
6565
***
6666

6767
### `/ignore <player>`
68-
Ignore a player—you will stop seeing all of their private messages to you.
68+
Ignore a player—you will stop seeing all of their messages (including public chat messages).
6969

7070
<dl>
7171
<dt>Aliases:</dt> <dd><code>/block</code></dd>
@@ -75,7 +75,7 @@ Ignore a player—you will stop seeing all of their private messages to you.
7575
***
7676

7777
### `/unignore <player>`
78-
You will stop ignoring the player and will be able to receive their private messages again.
78+
You will stop ignoring the player and will be able to see their messages again.
7979

8080
<dl>
8181
<dt>Aliases:</dt> <dd><code>/unblock</code></dd>

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static boolean sendMessage(final @NotNull Audience recipient, final @NotN
1414
return true;
1515
}
1616

17-
public abstract boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String[] args);
17+
public abstract boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String @NotNull [] args);
1818

1919
@Override
2020
public final boolean onCommand(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, @NotNull String @NotNull [] args) {

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MainCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private boolean reload(final @NotNull CommandSender sender) {
4040
}
4141

4242
@Override
43-
public @NotNull List<@NotNull String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String @NotNull [] args) {
43+
public @NotNull List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final @NotNull org.bukkit.command.Command command, final @NotNull String label, final @NotNull String @NotNull [] args) {
4444
final @NotNull List<@NotNull String> completions = new ArrayList<>();
4545
if (args.length == 1)
4646
if (sender.hasPermission(Permission.RELOAD) && "reload".startsWith(args[0].toLowerCase())) completions.add("reload");

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ public final class MessageCommand extends Command {
2626
@Override
2727
public boolean run(final @NotNull CommandSender sender, final @NotNull String label, @NotNull String @NotNull [] args) {
2828
if (!sender.hasPermission(Permission.USE)) return new NoPermissionError().send(sender);
29-
if (args.length == 0) {
29+
if (args.length == 0)
3030
return sendMessage(sender, CloudnodeMSG.getInstance().config().usage(label, sender instanceof Player ? usage : usageConsole));
31-
}
3231
if (args.length == 1 && !(sender instanceof Player)) return sendMessage(sender, CloudnodeMSG.getInstance().config()
3332
.usage(label, usageConsole.replace("<player>", args[0])));
3433

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/TeamMessageCommand.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@
1010
import pro.cloudnode.smp.cloudnodemsg.Message;
1111
import pro.cloudnode.smp.cloudnodemsg.Permission;
1212
import pro.cloudnode.smp.cloudnodemsg.error.NoPermissionError;
13+
import pro.cloudnode.smp.cloudnodemsg.error.NotInTeamError;
1314
import pro.cloudnode.smp.cloudnodemsg.error.NotPlayerError;
1415

1516
import java.util.ArrayList;
16-
import java.util.HashSet;
1717
import java.util.List;
1818
import java.util.Optional;
19-
import java.util.Set;
2019

2120
public class TeamMessageCommand extends Command {
2221
@Override
23-
public boolean run(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
22+
public boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String @NotNull [] args) {
2423
if (!sender.hasPermission(Permission.USE_TEAM)) return new NoPermissionError().send(sender);
25-
if (!(sender instanceof Player player)) return new NotPlayerError().send(sender);
24+
if (!(sender instanceof final @NotNull Player player)) return new NotPlayerError().send(sender);
2625
final @NotNull Optional<@NotNull Team> team = Optional.ofNullable(player.getScoreboard().getPlayerTeam(player));
27-
if (team.isEmpty()) return sendMessage(player, CloudnodeMSG.getInstance().config().notInTeam());
26+
if (team.isEmpty()) return new NotInTeamError().send(player);
2827
if (args.length == 0) {
2928
if (Message.hasTeamChannel(player)) {
3029
Message.exitTeamChannel(player);
@@ -39,7 +38,7 @@ public boolean run(@NotNull CommandSender sender, @NotNull String label, @NotNul
3938
}
4039

4140
@Override
42-
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
41+
public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final org.bukkit.command.@NotNull Command command, final @NotNull String label, final @NotNull String @NotNull [] args) {
4342
return new ArrayList<>();
4443
}
4544

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ToggleMessageCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public final class ToggleMessageCommand extends Command {
2020
@Override
21-
public boolean run(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
21+
public boolean run(final @NotNull CommandSender sender, final @NotNull String label, final @NotNull String @NotNull [] args) {
2222
if (!sender.hasPermission(Permission.TOGGLE) || (args.length == 1 && !sender.hasPermission(Permission.TOGGLE_OTHER)))
2323
return new NoPermissionError().send(sender);
2424
if (args.length == 1) {
@@ -47,7 +47,7 @@ public boolean run(@NotNull CommandSender sender, @NotNull String label, @NotNul
4747
}
4848

4949
@Override
50-
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String s, @NotNull String[] strings) {
50+
public @Nullable List<@NotNull String> onTabComplete(final @NotNull CommandSender sender, final org.bukkit.command.@NotNull Command command, final @NotNull String s, final @NotNull String @NotNull [] strings) {
5151
if (sender.hasPermission(Permission.TOGGLE_OTHER))
5252
return null;
5353
return new ArrayList<>();

src/main/java/pro/cloudnode/smp/cloudnodemsg/error/NotInTeamError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import pro.cloudnode.smp.cloudnodemsg.CloudnodeMSG;
44

55
/**
6-
* Only players can use this command
6+
* You are not in a team
77
*/
88
public final class NotInTeamError extends Error {
99
/**
10-
* Only players can use this command
10+
* You are not in a team
1111
*/
1212
public NotInTeamError() {
1313
super(CloudnodeMSG.getInstance().config().notInTeam());

src/main/java/pro/cloudnode/smp/cloudnodemsg/listener/AsyncChatListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pro.cloudnode.smp.cloudnodemsg.Permission;
1616
import pro.cloudnode.smp.cloudnodemsg.command.TeamMessageCommand;
1717
import pro.cloudnode.smp.cloudnodemsg.error.InvalidPlayerError;
18+
import pro.cloudnode.smp.cloudnodemsg.error.NotInTeamError;
1819

1920
import java.util.HashSet;
2021
import java.util.Iterator;
@@ -27,11 +28,11 @@ public void ignore(final @NotNull AsyncChatEvent event) {
2728
final @NotNull Set<@NotNull Audience> audience = event.viewers();
2829
final @NotNull Iterator<@NotNull Audience> iterator = audience.iterator();
2930
final @NotNull Player sender = event.getPlayer();
31+
final @NotNull Server server = CloudnodeMSG.getInstance().getServer();
3032

3133
while (iterator.hasNext()) {
3234
final @NotNull Audience a = iterator.next();
3335
if (a instanceof final @NotNull Player player) {
34-
final @NotNull Server server = CloudnodeMSG.getInstance().getServer();
3536
final @NotNull HashSet<@NotNull OfflinePlayer> ignored = Message.getIgnored(player).stream().map(server::getOfflinePlayer).collect(HashSet::new, HashSet::add, HashSet::addAll);
3637

3738
if (ignored.contains(sender) && !sender.hasPermission(Permission.IGNORE_BYPASS)) iterator.remove();
@@ -61,7 +62,7 @@ public void teamChannel(final @NotNull AsyncChatEvent event) {
6162
final @NotNull Optional<@NotNull Team> team = Optional.ofNullable(sender.getScoreboard().getPlayerTeam(sender));
6263
if (team.isEmpty()) {
6364
Message.exitTeamChannel(sender);
64-
sender.sendMessage(CloudnodeMSG.getInstance().config().notInTeam());
65+
new NotInTeamError().send(sender);
6566
return;
6667
}
6768
TeamMessageCommand.sendTeamMessage(sender, team.get(), event.message());

src/main/resources/plugin.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,34 @@ author: Cloudnode
66
commands:
77
message:
88
description: Send a private message
9-
usage: /<command> <player> <message>
9+
usage: /<command> <player> [message]
1010
aliases: [ "msg", "tell", "t", "whisper", "dm", "m", "pm" ]
11+
permission: cloudnodemsg.use
1112
reply:
12-
description: Reply to a private message
13+
description: Privately reply to the last message your received
1314
usage: /<command> <message>
1415
aliases: [ "r", "re" ]
16+
permission: cloudnodemsg.use
1517
cloudnodemsg:
1618
description: CloudnodeMSG
1719
usage: /<command>
1820
ignore:
1921
description: Ignore a player
2022
usage: /<command> <player>
2123
aliases: [ "block" ]
24+
permission: cloudnodemsg.ignore
2225
unignore:
2326
description: Unignore a player
2427
usage: /<command> <player>
2528
aliases: [ "unblock" ]
29+
permission: cloudnodemsg.ignore
2630
togglemsg:
27-
description: Toggles private messages from a player
28-
usage: /<command> <player>
31+
description: Toggle receiving private messages
32+
usage: /<command> [player]
2933
aliases: [ "toggledms", "togglepms" ]
34+
permission: cloudnodemsg.toggle
3035
teammsg:
3136
description: Send a private message to your teammates
32-
usage: /<command> <message>
37+
usage: /<command> [message]
3338
aliases: [ "tmsg", "teamchat" , "tm" ]
39+
permission: cloudnodemsg.use.team

0 commit comments

Comments
 (0)