forked from KyoriPowered/adventure
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Title.java
168 lines (155 loc) · 4.5 KB
/
Title.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2021 KyoriPowered
*
* 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.
*/
package net.kyori.adventure.title;
import java.time.Duration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.util.Ticks;
import net.kyori.examination.Examinable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
/**
* Represents an in-game title, which can be displayed across the centre of the screen.
*
* @see Times
* @since 4.0.0
*/
@ApiStatus.NonExtendable
public interface Title extends Examinable {
/**
* The default times.
*
* @since 4.0.0
*/
Times DEFAULT_TIMES = Times.times(Ticks.duration(10), Ticks.duration(70), Ticks.duration(20));
/**
* Creates a title.
*
* @param title the title
* @param subtitle the subtitle
* @return the title
* @since 4.0.0
*/
static @NotNull Title title(final @NotNull Component title, final @NotNull Component subtitle) {
return title(title, subtitle, DEFAULT_TIMES);
}
/**
* Creates a title.
*
* @param title the title
* @param subtitle the subtitle
* @param times the times
* @return the title
* @since 4.0.0
*/
static @NotNull Title title(final @NotNull Component title, final @NotNull Component subtitle, final @Nullable Times times) {
return new TitleImpl(title, subtitle, times);
}
/**
* Gets the title.
*
* @return the title
* @since 4.0.0
*/
@NotNull Component title();
/**
* Gets the subtitle.
*
* @return the subtitle
* @since 4.0.0
*/
@NotNull Component subtitle();
/**
* Gets the times.
*
* @return the times
* @since 4.0.0
*/
@Nullable Times times();
/**
* Gets a part.
*
* @param part the part
* @param <T> the type of the part
* @return the value
* @since 4.9.0
*/
<T> @UnknownNullability T part(final @NotNull TitlePart<T> part);
/**
* Title times.
*
* @since 4.0.0
*/
interface Times extends Examinable {
/**
* Creates times.
*
* @param fadeIn the fade-in time
* @param stay the stay time
* @param fadeOut the fade-out time
* @return times
* @since 4.0.0
* @deprecated for removal since 4.10.0, use {@link #times()}
*/
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
@Deprecated
static @NotNull Times of(final @NotNull Duration fadeIn, final @NotNull Duration stay, final @NotNull Duration fadeOut) {
return times(fadeIn, stay, fadeOut);
}
/**
* Creates times.
*
* @param fadeIn the fade-in time
* @param stay the stay time
* @param fadeOut the fade-out time
* @return times
* @since 4.10.0
*/
static @NotNull Times times(final @NotNull Duration fadeIn, final @NotNull Duration stay, final @NotNull Duration fadeOut) {
return new TitleImpl.TimesImpl(fadeIn, stay, fadeOut);
}
/**
* Gets the time the title will fade-in.
*
* @return the time the title will fade-in
* @since 4.0.0
*/
@NotNull Duration fadeIn();
/**
* Gets the time the title will stay.
*
* @return the time the title will stay
* @since 4.0.0
*/
@NotNull Duration stay();
/**
* Gets the time the title will fade-out.
*
* @return the time the title will fade-out
* @since 4.0.0
*/
@NotNull Duration fadeOut();
}
}