Skip to content

Commit 1bd6dab

Browse files
committed
reformat code
1 parent 4dbf118 commit 1bd6dab

File tree

9 files changed

+109
-77
lines changed

9 files changed

+109
-77
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# CloudnodeMSG
2+
23
A Minecraft Java plugin for private messages.
34

45
Supports message channels (so you don't have to use a command for every DM) and integrates with vanish plugins.
56

67
[See the default config](https://github.com/cloudnode-pro/CloudnodeMSG/blob/main/src/main/resources/config.yml)
78

89
## Commands
10+
911
The following are all commands from this plugin.
1012

1113
***
1214

1315
### `/msg <player> <message>`
16+
1417
Send a private message to another player.
1518

1619
<dl>
@@ -21,6 +24,7 @@ Send a private message to another player.
2124
***
2225

2326
### `/msg <player>`
27+
2428
Create a private message channel to a player;
2529
i.e. all of your chat messages will be sent as private messages to this player.
2630
Run the command again to disable the message channel.
@@ -33,6 +37,7 @@ Run the command again to disable the message channel.
3337
***
3438

3539
### `/reply <message>`
40+
3641
Send a private message to the last player that messaged you.
3742

3843
<dl>
@@ -43,6 +48,7 @@ Send a private message to the last player that messaged you.
4348
***
4449

4550
### `/teammsg <message>`
51+
4652
Send a private message to your [scoreboard team](https://minecraft.fandom.com/wiki/Scoreboard#Teams).
4753

4854
<dl>
@@ -53,6 +59,7 @@ Send a private message to your [scoreboard team](https://minecraft.fandom.com/wi
5359
***
5460

5561
### `/teammsg`
62+
5663
Create a private message channel to your [scoreboard team](https://minecraft.fandom.com/wiki/Scoreboard#Teams);
5764
i.e. all of your chat messages will be sent as private team messages.
5865
Run the command again to disable the message channel.
@@ -65,6 +72,7 @@ Run the command again to disable the message channel.
6572
***
6673

6774
### `/ignore <player>`
75+
6876
Ignore a player—you will stop seeing all of their messages (including public chat messages).
6977

7078
<dl>
@@ -75,6 +83,7 @@ Ignore a player—you will stop seeing all of their messages (including public c
7583
***
7684

7785
### `/unignore <player>`
86+
7887
You will stop ignoring the player and will be able to see their messages again.
7988

8089
<dl>
@@ -85,6 +94,7 @@ You will stop ignoring the player and will be able to see their messages again.
8594
***
8695

8796
### `/togglemsg`
97+
8898
Enable or disable receiving private messages.
8999
When your private messages are disabled, nobody can message you, but you can still send messages.
90100

@@ -96,6 +106,7 @@ When your private messages are disabled, nobody can message you, but you can sti
96106
***
97107

98108
### `/togglemsg <player>`
109+
99110
Enable or disable receiving private messages of another player.
100111

101112
<dl>
@@ -108,6 +119,7 @@ Enable or disable receiving private messages of another player.
108119
***
109120

110121
### `/cloudnodemsg reload`
122+
111123
Reload the plugin configuration.
112124

113125
<dl>
@@ -116,6 +128,7 @@ Reload the plugin configuration.
116128
</dl>
117129

118130
## Permissions
131+
119132
Here is a list of the permissions used by this plugin.
120133

121134
| Permission | Description | Recommended Group |
@@ -138,13 +151,16 @@ with new features or changes typically released every **Tuesday**.
138151
When we merge critical bug fixes, we may publish out-of-band releases on any day of the week.
139152

140153
## Report Issues
154+
141155
Please ensure
142156
that you are using the [latest version](https://modrinth.com/plugin/5Ce4fxJB/version/latest) of CloudnodeMSG.
143157
The newest bug fixes are only available in the most recent version,
144158
and support is provided exclusively for this version.
145159

146160
If you encounter any problems with the plugin,
147-
please first check the [list of known issues](https://github.com/cloudnode-pro/CloudnodeMSG/issues?q=is%3Aopen+is%3Aissue+label%3Abug) on our GitHub repository.
161+
please first check
162+
the [list of known issues](https://github.com/cloudnode-pro/CloudnodeMSG/issues?q=is%3Aopen+is%3Aissue+label%3Abug) on
163+
our GitHub repository.
148164
If you don’t find a similar fault listed there,
149165
we encourage you to [submit a new issue](https://github.com/cloudnode-pro/CloudnodeMSG/issues/new?labels=bug).
150166
Resolving bugs is the highest priority for this project.
@@ -158,14 +174,15 @@ To suggest a new feature, please [create a new issue](https://github.com/cloudno
158174
providing a detailed description of your idea.
159175

160176
## Contributing
161-
CloudnodeMSG is licensed under the [GPL-3.0 licence](https://github.com/cloudnode-pro/CloudnodeMSG/blob/main/LICENSE).
177+
178+
CloudnodeMSG is licensed under the [GPL-3.0 licence](https://github.com/cloudnode-pro/CloudnodeMSG/blob/main/LICENSE).
162179
The source code is available on [GitHub](https://github.com/cloudnode-pro/CloudnodeMSG).
163180

164181
New contributors are most welcome to the project. If you're interested in contributing, follow these steps:
165182

166-
1. [Fork the repository](https://github.com/cloudnode-pro/CloudnodeMSG/fork)
167-
2. Create a new branch for your contributions.
168-
3. Make your changes and ensure they align with the project’s goals.
169-
4. Commit your changes with clear and descriptive messages.
170-
5. Push your changes to your fork.
171-
6. Submit a pull request.
183+
1. [Fork the repository](https://github.com/cloudnode-pro/CloudnodeMSG/fork)
184+
2. Create a new branch for your contributions.
185+
3. Make your changes and ensure they align with the project’s goals.
186+
4. Commit your changes with clear and descriptive messages.
187+
5. Push your changes to your fork.
188+
6. Submit a pull request.

src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,19 @@ public void send(final boolean channel) throws InvalidPlayerError {
5555
final @NotNull Optional<@NotNull Player> senderPlayer = Optional.ofNullable(this.sender.getPlayer());
5656
final @NotNull Optional<@NotNull Player> recipientPlayer = Optional.ofNullable(this.recipient.getPlayer());
5757

58-
if (senderPlayer.isPresent() && (recipientPlayer.isEmpty() || (CloudnodeMSG.isVanished(recipientPlayer.get()) && !senderPlayer.get().hasPermission(Permission.SEND_VANISHED)))) {
58+
if (senderPlayer.isPresent() && (recipientPlayer.isEmpty() || (CloudnodeMSG.isVanished(recipientPlayer.get()) && !senderPlayer
59+
.get().hasPermission(Permission.SEND_VANISHED)))) {
5960
if (!channel) new PlayerNotFoundError(senderPlayer.get().getName()).send(senderPlayer.get());
6061
else {
6162
Message.exitChannel(senderPlayer.get());
62-
new ChannelOfflineError(senderPlayer.get().getName(), Optional.ofNullable(recipient.getName()).orElse("Unknown Player")).send(senderPlayer.get());
63+
new ChannelOfflineError(senderPlayer.get().getName(), Optional.ofNullable(recipient.getName())
64+
.orElse("Unknown Player")).send(senderPlayer.get());
6365
}
6466
return;
6567
}
6668

67-
if (recipientPlayer.isPresent() && senderPlayer.isPresent() && !Message.isIncomingEnabled(recipientPlayer.get()) && !senderPlayer.get().hasPermission(Permission.TOGGLE_BYPASS)) {
69+
if (recipientPlayer.isPresent() && senderPlayer.isPresent() && !Message.isIncomingEnabled(recipientPlayer.get()) && !senderPlayer
70+
.get().hasPermission(Permission.TOGGLE_BYPASS)) {
6871
new PlayerHasIncomingDisabledError(recipientPlayer.get().getName()).send(senderPlayer.get());
6972
return;
7073
}
@@ -75,11 +78,8 @@ public void send(final boolean channel) throws InvalidPlayerError {
7578

7679
sendSpyMessage(sender, recipient, message);
7780

78-
if (
79-
(recipientPlayer.isPresent() && Message.isIgnored(recipientPlayer.get(), sender))
80-
&&
81-
(senderPlayer.isPresent() && !senderPlayer.get().hasPermission(Permission.IGNORE_BYPASS))
82-
) return;
81+
if ((recipientPlayer.isPresent() && Message.isIgnored(recipientPlayer.get(), sender)) && (senderPlayer.isPresent() && !senderPlayer
82+
.get().hasPermission(Permission.IGNORE_BYPASS))) return;
8383
sendMessage(recipient, CloudnodeMSG.getInstance().config()
8484
.incoming(senderUsername, recipientUsername, message));
8585
if (recipientPlayer.isPresent() && !Message.hasChannel(recipientPlayer.get(), sender))
@@ -103,17 +103,18 @@ public static void sendMessage(final @NotNull OfflinePlayer recipient, final @No
103103
* Send social spy to online players with permission
104104
*/
105105
public static void sendSpyMessage(final @NotNull OfflinePlayer sender, final @NotNull OfflinePlayer recipient, final @NotNull Component message) {
106-
final @NotNull String senderName = sender.getUniqueId().equals(console.getUniqueId()) ? CloudnodeMSG.getInstance().config().consoleName() : Optional.ofNullable(sender.getName()).orElse("Unknown Player");
107-
final @NotNull String recipientName = recipient.getUniqueId().equals(console.getUniqueId()) ? CloudnodeMSG.getInstance().config().consoleName() : Optional.ofNullable(recipient.getName()).orElse("Unknown Player");
106+
final @NotNull String senderName = sender.getUniqueId().equals(console.getUniqueId()) ? CloudnodeMSG
107+
.getInstance().config().consoleName() : Optional.ofNullable(sender.getName()).orElse("Unknown Player");
108+
final @NotNull String recipientName = recipient.getUniqueId().equals(console.getUniqueId()) ? CloudnodeMSG
109+
.getInstance().config().consoleName() : Optional.ofNullable(recipient.getName())
110+
.orElse("Unknown Player");
108111
for (final @NotNull Player player : CloudnodeMSG.getInstance().getServer().getOnlinePlayers()) {
109-
if (
110-
!player.hasPermission(Permission.SPY)
111-
|| player.getUniqueId().equals(sender.getUniqueId())
112-
|| player.getUniqueId().equals(recipient.getUniqueId())
113-
) continue;
112+
if (!player.hasPermission(Permission.SPY) || player.getUniqueId().equals(sender.getUniqueId()) || player
113+
.getUniqueId().equals(recipient.getUniqueId())) continue;
114114
sendMessage(player, CloudnodeMSG.getInstance().config().spy(senderName, recipientName, message));
115115
}
116-
if (!sender.getUniqueId().equals(console.getUniqueId()) && !recipient.getUniqueId().equals(console.getUniqueId()))
116+
if (!sender.getUniqueId().equals(console.getUniqueId()) && !recipient.getUniqueId()
117+
.equals(console.getUniqueId()))
117118
sendMessage(console, CloudnodeMSG.getInstance().config().spy(senderName, recipientName, message));
118119
}
119120

@@ -123,18 +124,17 @@ public static void sendSpyMessage(final @NotNull OfflinePlayer sender, final @No
123124

124125
public static void setReplyTo(final @NotNull OfflinePlayer sender, final @NotNull OfflinePlayer recipient) {
125126
if (sender.getUniqueId().equals(console.getUniqueId())) consoleReply = recipient.getUniqueId();
126-
else if (sender.isOnline())
127-
Objects.requireNonNull(sender.getPlayer()).getPersistentDataContainer()
128-
.set(REPLY_TO, PersistentDataType.STRING, recipient.getUniqueId().toString());
127+
else if (sender.isOnline()) Objects.requireNonNull(sender.getPlayer()).getPersistentDataContainer()
128+
.set(REPLY_TO, PersistentDataType.STRING, recipient.getUniqueId().toString());
129129
}
130130

131131
public static @NotNull Optional<@NotNull OfflinePlayer> getReplyTo(final @NotNull OfflinePlayer player) {
132132
if (player.getUniqueId().equals(console.getUniqueId())) return Optional.ofNullable(consoleReply)
133133
.map(uuid -> CloudnodeMSG.getInstance().getServer().getOfflinePlayer(uuid));
134-
if (player.isOnline())
135-
return Optional.ofNullable(Objects.requireNonNull(player.getPlayer()).getPersistentDataContainer()
136-
.get(REPLY_TO, PersistentDataType.STRING))
137-
.map(uuid -> CloudnodeMSG.getInstance().getServer().getOfflinePlayer(UUID.fromString(uuid)));
134+
if (player.isOnline()) return Optional
135+
.ofNullable(Objects.requireNonNull(player.getPlayer()).getPersistentDataContainer()
136+
.get(REPLY_TO, PersistentDataType.STRING))
137+
.map(uuid -> CloudnodeMSG.getInstance().getServer().getOfflinePlayer(UUID.fromString(uuid)));
138138
return Optional.empty();
139139
}
140140

@@ -154,15 +154,16 @@ else if (player.isOnline())
154154
* @param player The player
155155
*/
156156
public static @NotNull HashSet<@NotNull UUID> getIgnored(final @NotNull Player player) {
157-
final @NotNull Optional<@NotNull String> str = Optional.ofNullable(player.getPersistentDataContainer().get(IGNORED_PLAYERS, PersistentDataType.STRING));
158-
return str.map(s -> new HashSet<>(Arrays.stream(s.split(";")).filter(e -> !e.isEmpty()).map(UUID::fromString).toList()))
159-
.orElseGet(HashSet::new);
157+
final @NotNull Optional<@NotNull String> str = Optional.ofNullable(player.getPersistentDataContainer()
158+
.get(IGNORED_PLAYERS, PersistentDataType.STRING));
159+
return str.map(s -> new HashSet<>(Arrays.stream(s.split(";")).filter(e -> !e.isEmpty()).map(UUID::fromString)
160+
.toList())).orElseGet(HashSet::new);
160161
}
161162

162163
/**
163164
* Check if a player is ignored
164165
*
165-
* @param player The player
166+
* @param player The player
166167
* @param ignored The ignored player
167168
*/
168169
public static boolean isIgnored(final @NotNull Player player, final @NotNull OfflinePlayer ignored) {
@@ -178,19 +179,23 @@ public static boolean isIgnored(final @NotNull Player player, final @NotNull Off
178179
public static void ignore(final @NotNull Player player, final @NotNull OfflinePlayer ignore) {
179180
final @NotNull HashSet<@NotNull UUID> ignoredPlayers = getIgnored(player);
180181
ignoredPlayers.add(ignore.getUniqueId());
181-
player.getPersistentDataContainer().set(IGNORED_PLAYERS, PersistentDataType.STRING, String.join(";", ignoredPlayers.stream().map(UUID::toString).toList()));
182+
player.getPersistentDataContainer()
183+
.set(IGNORED_PLAYERS, PersistentDataType.STRING, String.join(";", ignoredPlayers.stream()
184+
.map(UUID::toString).toList()));
182185
}
183186

184187
/**
185188
* Unignore a player
186189
*
187-
* @param player The player
190+
* @param player The player
188191
* @param ignored The player to unignore
189192
*/
190193
public static void unignore(final @NotNull Player player, final @NotNull OfflinePlayer ignored) {
191194
final @NotNull HashSet<@NotNull UUID> ignoredPlayers = getIgnored(player);
192195
ignoredPlayers.remove(ignored.getUniqueId());
193-
player.getPersistentDataContainer().set(IGNORED_PLAYERS, PersistentDataType.STRING, String.join(";", ignoredPlayers.stream().map(UUID::toString).toList()));
196+
player.getPersistentDataContainer()
197+
.set(IGNORED_PLAYERS, PersistentDataType.STRING, String.join(";", ignoredPlayers.stream()
198+
.map(UUID::toString).toList()));
194199
}
195200

196201
public static final @NotNull NamespacedKey INCOMING_ENABLED = new NamespacedKey(CloudnodeMSG.getInstance(), "incoming_enabled");
@@ -229,7 +234,8 @@ public static boolean isIncomingEnabled(final @NotNull Player player) {
229234
* @param recipient The other end of the channel
230235
*/
231236
public static void createChannel(final @NotNull Player player, final @NotNull OfflinePlayer recipient) {
232-
player.getPersistentDataContainer().set(CHANNEL_RECIPIENT, PersistentDataType.STRING, recipient.getUniqueId().toString());
237+
player.getPersistentDataContainer()
238+
.set(CHANNEL_RECIPIENT, PersistentDataType.STRING, recipient.getUniqueId().toString());
233239
player.getPersistentDataContainer().remove(CHANNEL_TEAM);
234240
}
235241

@@ -248,14 +254,15 @@ public static void exitChannel(final @NotNull Player player) {
248254
* @param player The player
249255
*/
250256
public static @NotNull Optional<@NotNull OfflinePlayer> getChannel(final @NotNull Player player) {
251-
return Optional.ofNullable(player.getPersistentDataContainer().get(CHANNEL_RECIPIENT, PersistentDataType.STRING))
257+
return Optional
258+
.ofNullable(player.getPersistentDataContainer().get(CHANNEL_RECIPIENT, PersistentDataType.STRING))
252259
.map(uuid -> CloudnodeMSG.getInstance().getServer().getOfflinePlayer(UUID.fromString(uuid)));
253260
}
254261

255262
/**
256263
* Check whether player has DM channel with recipient
257264
*
258-
* @param player The player
265+
* @param player The player
259266
* @param recipient The recipient
260267
*/
261268
public static boolean hasChannel(final @NotNull Player player, final @NotNull OfflinePlayer recipient) {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la
3232
}
3333

3434
public static boolean ignore(final @NotNull Player player, final @NotNull OfflinePlayer target) {
35-
if (target.isOnline() && Objects.requireNonNull(target.getPlayer()).hasPermission(Permission.IGNORE_BYPASS)) return new CannotIgnoreError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player);
36-
if (!target.isOnline() && !target.hasPlayedBefore()) return new NeverJoinedError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player);
35+
if (target.isOnline() && Objects.requireNonNull(target.getPlayer()).hasPermission(Permission.IGNORE_BYPASS))
36+
return new CannotIgnoreError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player);
37+
if (!target.isOnline() && !target.hasPlayedBefore())
38+
return new NeverJoinedError(Optional.ofNullable(target.getName()).orElse("Unknown Player")).send(player);
3739
Message.ignore(player, target);
38-
return sendMessage(player, CloudnodeMSG.getInstance().config().ignored(Optional.ofNullable(target.getName()).orElse("Unknown Player")));
40+
return sendMessage(player, CloudnodeMSG.getInstance().config()
41+
.ignored(Optional.ofNullable(target.getName()).orElse("Unknown Player")));
3942
}
4043

4144
public static boolean unignore(final @NotNull Player player, final @NotNull OfflinePlayer target) {
4245
Message.unignore(player, target);
43-
return sendMessage(player, CloudnodeMSG.getInstance().config().unignored(Optional.ofNullable(target.getName()).orElse("Unknown Player")));
46+
return sendMessage(player, CloudnodeMSG.getInstance().config()
47+
.unignored(Optional.ofNullable(target.getName()).orElse("Unknown Player")));
4448
}
4549

4650
@Override

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la
2626

2727
private boolean info(final @NotNull CommandSender sender) {
2828
final @NotNull PluginMeta meta = CloudnodeMSG.getInstance().getPluginMeta();
29-
return sendMessage(sender, MiniMessage.miniMessage().deserialize("<green><name> by <author></green><newline><green>Version: <white><version></white></green>",
30-
Placeholder.unparsed("name", meta.getName()),
31-
Placeholder.unparsed("author", String.join(", ", meta.getAuthors())),
32-
Placeholder.unparsed("version", meta.getVersion())
33-
));
29+
return sendMessage(sender, MiniMessage.miniMessage()
30+
.deserialize("<green><name> by <author></green><newline><green>Version: <white><version></white></green>", Placeholder.unparsed("name", meta.getName()), Placeholder.unparsed("author", String.join(", ", meta.getAuthors())), Placeholder.unparsed("version", meta.getVersion())));
3431
}
3532

3633
private boolean reload(final @NotNull CommandSender sender) {
@@ -42,8 +39,8 @@ private boolean reload(final @NotNull CommandSender sender) {
4239
@Override
4340
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) {
4441
final @NotNull List<@NotNull String> completions = new ArrayList<>();
45-
if (args.length == 1)
46-
if (sender.hasPermission(Permission.RELOAD) && "reload".startsWith(args[0].toLowerCase())) completions.add("reload");
42+
if (args.length == 1) if (sender.hasPermission(Permission.RELOAD) && "reload".startsWith(args[0].toLowerCase()))
43+
completions.add("reload");
4744
return completions;
4845
}
4946
}

0 commit comments

Comments
 (0)