Skip to content

Commit

Permalink
(refactor) switch mail to new login push api
Browse files Browse the repository at this point in the history
  • Loading branch information
Lori3f6 committed Sep 6, 2024
1 parent 4391078 commit 087a59f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
7 changes: 0 additions & 7 deletions src/main/java/cat/nyaa/ukit/SpigotLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,6 @@ private boolean setupEconomy() {
return economyProvider != null;
}

public void newLoginPush(UUID playerUniqueID, Component message, Component messageSender) throws SQLException, IllegalStateException {
if (loginPushFunction == null) {
throw new IllegalStateException("LoginPushFunction not initialized");
}
loginPushFunction.getLoginPushRecorder().createLoginPush(playerUniqueID, message, messageSender);
}

private boolean setupChat() {
var rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
if (rsp != null) {
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/cat/nyaa/ukit/mail/MailFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cat.nyaa.ukit.MainLang;
import cat.nyaa.ukit.SpigotLoader;
import cat.nyaa.ukit.api.UKitAPI;
import cat.nyaa.ukit.utils.EssentialsPluginUtils;
import cat.nyaa.ukit.utils.LockettePluginUtils;
import cat.nyaa.ukit.utils.SubCommandExecutor;
Expand Down Expand Up @@ -213,16 +214,8 @@ public boolean invokeCommand(CommandSender commandSender, Command command, Strin
Pair.of("amount", itemInHand.getAmount())
);

if (targetPlayer.isOnline()) {
targetPlayer.getPlayer().sendMessage(receiverMessage);
} else {
try {
var serviceSenderName = getLanguage().mailLang.serviceName.produceAsComponent();
pluginInstance.newLoginPush(targetPlayer.getUniqueId(), receiverMessage, serviceSenderName);
} catch (SQLException | IllegalStateException ignore) {
ignore.printStackTrace();
}
}
var serviceSenderName = getLanguage().mailLang.serviceName.produceAsComponent();
UKitAPI.getAPIInstance().pushMessage(targetPlayer.getUniqueId(), receiverMessage, serviceSenderName);

} catch (SQLException e) {
e.printStackTrace();
Expand Down

0 comments on commit 087a59f

Please sign in to comment.