Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
feat: #775 ログイン・ログアウトメッセージを英語化 (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jun 15, 2022
1 parent 9abf303 commit 9efb73d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Event_CustomJoinMessage extends MyMaidLibrary implements Listener, EventPremise {
public class Event_CustomJoinLeftMessage extends MyMaidLibrary implements Listener, EventPremise {
static final List<String> JoinMessages = Arrays.asList(
"the New Generation", "- Super", "Hyper", "Ultra", "Extreme", "Insane", "Gigantic", "Epic", "Amazing", "Beautiful",
"Special", "Swag", "Lunatic", "Exotic", "God", "Hell", "Heaven", "Mega", "Giga", "Tera", "Refined", "Sharp",
Expand All @@ -39,7 +40,7 @@ public class Event_CustomJoinMessage extends MyMaidLibrary implements Listener,

@Override
public String description() {
return "独自のログインメッセージを表示するように制御します。";
return "独自のログイン・ログアウトメッセージを表示するように制御します。";
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand All @@ -49,6 +50,12 @@ public void onEvent_JoinChangeMessage(PlayerJoinEvent event) {
if (joinMessage != null) event.joinMessage(joinMessage);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onEvent_LeftChangeMessage(PlayerQuitEvent event) {
Player player = event.getPlayer();
event.quitMessage(Component.text("%s left the game.".formatted(player.getName()), NamedTextColor.YELLOW));
}

String getJoinMessage(int count) {
if (count < 20) {
return null;
Expand All @@ -67,7 +74,7 @@ String getJoinMessage(int count) {
Component getPlayerJoinMessage(Player player) {
int count = getVoteCount(player);
if (count < 20) {
return null;
return Component.text("%s joined the game.".formatted(player.getName()), NamedTextColor.YELLOW);
}
String rankText = getJoinMessage(count);
String customMessage = getCustomMessage(player);
Expand Down

0 comments on commit 9efb73d

Please sign in to comment.