-
-
Notifications
You must be signed in to change notification settings - Fork 19
GH-991 Add MOTD feature #1094
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
GH-991 Add MOTD feature #1094
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c8ce762
Add MOTD feature
Jakubk15 b4e3762
fix example motd content
Jakubk15 d465a73
Review.
vLuckyyy 49ebfca
Fix.
vLuckyyy 122c890
Move MOTD to message files
Jakubk15 63982b1
Merge remote-tracking branch 'origin/motd' into motd
Jakubk15 f5a6470
Fix.
vLuckyyy a5742bf
Remove duplicated title.
vLuckyyy 5b78e47
Merge branch 'master' into motd
Jakubk15 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
27 changes: 27 additions & 0 deletions
27
eternalcore-core/src/main/java/com/eternalcode/core/feature/motd/MotdConfig.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,27 @@ | ||
package com.eternalcode.core.feature.motd; | ||
|
||
import com.eternalcode.multification.notice.Notice; | ||
import eu.okaeri.configs.OkaeriConfig; | ||
import eu.okaeri.configs.annotation.Comment; | ||
import lombok.Getter; | ||
import lombok.experimental.Accessors; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Accessors(fluent = true) | ||
public class MotdConfig extends OkaeriConfig implements MotdSettings { | ||
|
||
@Comment("# Message of the Day (MOTD) content that will be sent to players when they join the server.") | ||
@Comment("# Out of the box supported placeholders: {PLAYER}, {WORLD}, {TIME}") | ||
@Comment("# You can add your own placeholders using the PlaceholderAPI.") | ||
public Notice motdContent = Notice.chat( | ||
List.of("<green>Welcome to the server,</green> <gradient:#ee1d1d:#f1b722>{PLAYER}</gradient>", | ||
"<green>Have a good time playing!</green>", | ||
"<green>The current time in {WORLD} is: </green><gradient:#2c60d5:#742ccf>{TIME}</gradient> <green>ticks", | ||
"<green>If you need any help, don't hesitate to ask our staff using the </green><dark_green><click:suggest_command:'/helpop'>/helpop</click> command!</dark_green>" | ||
) | ||
); | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
eternalcore-core/src/main/java/com/eternalcode/core/feature/motd/MotdSettings.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,9 @@ | ||
package com.eternalcode.core.feature.motd; | ||
|
||
import com.eternalcode.multification.notice.Notice; | ||
|
||
public interface MotdSettings { | ||
|
||
Notice motdContent(); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...alcore-core/src/main/java/com/eternalcode/core/feature/motd/PlayerJoinMotdController.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,36 @@ | ||
package com.eternalcode.core.feature.motd; | ||
|
||
import com.eternalcode.core.injector.annotations.Inject; | ||
import com.eternalcode.core.injector.annotations.component.Controller; | ||
import com.eternalcode.core.notice.NoticeService; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
|
||
@Controller | ||
class PlayerJoinMotdController implements Listener { | ||
|
||
private final NoticeService noticeService; | ||
private final MotdSettings motdSettings; | ||
|
||
@Inject | ||
PlayerJoinMotdController(NoticeService noticeService, MotdSettings motdSettings) { | ||
this.noticeService = noticeService; | ||
this.motdSettings = motdSettings; | ||
} | ||
|
||
@EventHandler | ||
void onPlayerJoin(PlayerJoinEvent event) { | ||
Player player = event.getPlayer(); | ||
|
||
this.noticeService.create() | ||
.notice(this.motdSettings.motdContent()) | ||
.player(player.getUniqueId()) | ||
.placeholder("{PLAYER}", player.getName()) | ||
.placeholder("{TIME}", String.valueOf(player.getWorld().getTime())) | ||
.placeholder("{WORLD}", player.getWorld().getName()) | ||
.send(); | ||
} | ||
|
||
} |
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.