-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rework Mail System #3710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rework Mail System #3710
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
06926a0
Add rich mail messages
JRoy 067c684
Merge branch '2.x' into feature/mail-revamp
JRoy f2da0c7
Don't use bukkit configs :(
JRoy 30706b9
Merge branch '2.x' into feature/mail-revamp
JRoy 3b1b848
Fix mail conversions
JRoy 9312646
lmfao
JRoy 7c33159
Merge branch '2.x' into feature/mail-revamp
JRoy d06bd22
Don't use vanilla handler here, player names are cringe
JRoy a8e2c4f
Merge branch '2.x' into feature/mail-revamp
JRoy 3902795
Merge branch '2.x' into feature/mail-revamp
JRoy 439cdbb
Merge branch '2.x' into feature/mail-revamp
JRoy e4b777d
Merge branch '2.x' into feature/mail-revamp
JRoy a1040e4
Kill me
JRoy 8b1e33d
Mail -> MailService
JRoy 51ebbe2
Merge branch '2.x' into feature/mail-revamp
JRoy bff633f
Merge branch '2.x' into feature/mail-revamp
JRoy 00a6700
Add missing methods from DiscordMessageRecipient
JRoy 182fd3e
Merge branch '2.x' into feature/mail-revamp
JRoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Essentials/src/main/java/com/earth2me/essentials/MailServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.earth2me.essentials; | ||
|
|
||
| import net.ess3.api.IUser; | ||
| import net.essentialsx.api.v2.services.mail.MailService; | ||
| import net.essentialsx.api.v2.services.mail.MailMessage; | ||
| import net.essentialsx.api.v2.services.mail.MailSender; | ||
| import org.bukkit.plugin.ServicePriority; | ||
|
|
||
| import java.text.SimpleDateFormat; | ||
| import java.util.ArrayList; | ||
| import java.util.Date; | ||
|
|
||
| import static com.earth2me.essentials.I18n.tl; | ||
|
|
||
| public class MailServiceImpl implements MailService { | ||
| private final transient ThreadLocal<SimpleDateFormat> df = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy/MM/dd HH:mm")); | ||
|
|
||
| public MailServiceImpl(IEssentials ess) { | ||
| ess.getServer().getServicesManager().register(MailService.class, this, ess, ServicePriority.Normal); | ||
| } | ||
|
|
||
| @Override | ||
| public void sendMail(IUser recipient, MailSender sender, String message) { | ||
| sendMail(recipient, sender, message, 0L); | ||
| } | ||
|
|
||
| @Override | ||
| public void sendMail(IUser recipient, MailSender sender, String message, long expireAt) { | ||
| sendMail(recipient, new MailMessage(false, false, sender.getName(), sender.getUUID(), System.currentTimeMillis(), expireAt, message)); | ||
| } | ||
|
|
||
| @Override | ||
| public void sendLegacyMail(IUser recipient, String message) { | ||
| sendMail(recipient, new MailMessage(false, true, null, null, 0L, 0L, message)); | ||
| } | ||
|
|
||
| private void sendMail(IUser recipient, MailMessage message) { | ||
| final ArrayList<MailMessage> messages = recipient.getMailMessages(); | ||
| messages.add(0, message); | ||
| recipient.setMailList(messages); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMailLine(MailMessage mail) { | ||
| final String message = mail.getMessage(); | ||
| if (mail.isLegacy()) { | ||
| return tl("mailMessage", message); | ||
| } | ||
|
|
||
| final String expire = mail.getTimeExpire() != 0 ? "Timed" : ""; | ||
| return tl((mail.isRead() ? "mailFormatNewRead" : "mailFormatNew") + expire, df.get().format(new Date(mail.getTimeSent())), mail.getSenderUsername(), message); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.