Skip to content

Commit

Permalink
v3.0.3 - Small Patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Majekdor committed Jul 10, 2022
1 parent 7cd4e99 commit 5503812
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Plugin Changelog

# 3.0.3 - Small Patches

- Fixed bug with messages on `/nickother`.
- Messages will only send provided they're not empty.
- Added `package-info.java` to message package.

Another very minor update with some useful fixes.

# 3.0.2 - Async Improvements

- Nickname commands (`/nick`, `/nickcolor`, and `/nickother`) will now run asynchronously to prevent a server slowdown and a "Working..." message will be displayed until the command completes.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.majek</groupId>
<artifactId>hexnicks</artifactId>
<version>3.0.2</version>
<version>3.0.3</version>
<packaging>jar</packaging>

<name>HexNicks</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
final Component finalNick = nickEvent.newNick();

// Send loading message
Messages.WORKING.send(target);
Messages.WORKING.send(sender);

// Asynchronously check to make sure the nickname isn't taken
HexNicks.core().getServer().getScheduler().runTaskAsynchronously(HexNicks.core(), () -> {
Expand All @@ -117,6 +117,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
// Set nick
HexNicks.core().setNick(target, finalNick);
Messages.NICKNAME_SET.send(target, finalNick);
Messages.NICKNAME_SET_OTHER.send(sender, target, finalNick);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/majek/hexnicks/config/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface Args0 {
Component build();

default void send(CommandSender sender) {
sender.sendMessage(build());
MiscUtils.sendMessage(sender, build());
}
}

Expand All @@ -131,7 +131,7 @@ interface Args1<A0> {
Component build(A0 arg0);

default void send(CommandSender sender, A0 arg0) {
sender.sendMessage(build(arg0));
MiscUtils.sendMessage(sender, build(arg0));
}
}

Expand All @@ -142,7 +142,7 @@ interface Args2<A0, A1> {
Component build(A0 arg0, A1 arg1);

default void send(CommandSender sender, A0 arg0, A1 arg1) {
sender.sendMessage(build(arg0, arg1));
MiscUtils.sendMessage(sender, build(arg0, arg1));
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/dev/majek/hexnicks/event/PlayerChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;

/**
* Handles formatting player chat if enabled in the config.
*/
public class PlayerChat implements Listener {

/**
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/dev/majek/hexnicks/message/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of HexNicks, licensed under the MIT License.
*
* Copyright (c) 2020-2022 Majekdor
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* Message formatting utilities.
*/
package dev.majek.hexnicks.message;
13 changes: 13 additions & 0 deletions src/main/java/dev/majek/hexnicks/util/MiscUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -195,4 +196,16 @@ public static boolean preventDuplicates(@NotNull Component nickname, @NotNull Pl
}
return response.body();
}

/**
* Send a message to a user provided the message isn't empty.
*
* @param recipient the recipient of the message
* @param message the message to send
*/
public static void sendMessage(final @NotNull CommandSender recipient, final @NotNull Component message) {
if (!PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) {
recipient.sendMessage(message);
}
}
}

0 comments on commit 5503812

Please sign in to comment.