-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnnotationsExample.java
More file actions
107 lines (86 loc) · 3.65 KB
/
AnnotationsExample.java
File metadata and controls
107 lines (86 loc) · 3.65 KB
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
package net.codingarea.challenges.example.examples.others;
import net.anweisen.utilities.common.annotations.Since;
import net.codingarea.challenges.plugin.challenges.implementation.challenge.RandomChallengeChallenge;
import net.codingarea.challenges.plugin.challenges.type.abstraction.Setting;
import net.codingarea.challenges.plugin.management.challenges.annotations.CanInstaKillOnEnable;
import net.codingarea.challenges.plugin.management.challenges.annotations.ExcludeFromRandomChallenges;
import net.codingarea.challenges.plugin.management.menu.MenuType;
import net.codingarea.challenges.plugin.management.scheduler.policy.ChallengeStatusPolicy;
import net.codingarea.challenges.plugin.management.scheduler.policy.ExtraWorldPolicy;
import net.codingarea.challenges.plugin.management.scheduler.policy.FreshnessPolicy;
import net.codingarea.challenges.plugin.management.scheduler.policy.PlayerCountPolicy;
import net.codingarea.challenges.plugin.management.scheduler.task.ScheduledTask;
import net.codingarea.challenges.plugin.management.scheduler.task.TimerTask;
import net.codingarea.challenges.plugin.management.scheduler.timer.TimerStatus;
import net.codingarea.challenges.plugin.utils.item.ItemBuilder;
/**
* Example to show annotations which can be used to improve your challenges
*
* {@link Since} indicates when the challenge was added to the plugin. Used to display the "new" suffix behind the display item's name when its new
* {@link CanInstaKillOnEnable} should be used when your challenge can instantly kill players when its enabled
* {@link ExcludeFromRandomChallenges} excludes this challenge from {@link RandomChallengeChallenge}
*
* The following method examples are showing two other annotations which are used to detect timer status updates and timer updates.
*/
@Since("1.0")
@CanInstaKillOnEnable
@ExcludeFromRandomChallenges
public class AnnotationsExample extends Setting {
public AnnotationsExample(MenuType menu) {
super(menu);
}
@Override
public ItemBuilder createDisplayItem() {
return null;
}
/**
* Executes asynchronous when timer is started
*/
@TimerTask(status = TimerStatus.RUNNING)
public void onTimerStartAsync() {
}
/**
* Executes synchronous when timer is paused
*/
@TimerTask(status = TimerStatus.PAUSED, async = false)
public void onTimerPause() {
}
/**
* Others parameters will be showen in this example
*/
@TimerTask(
status = TimerStatus.RUNNING, // When timer is started
async = false, // Not asynchronous
challengePolicy = ChallengeStatusPolicy.DISABLED, // Only executes when challenge is not enabled
playerPolicy = PlayerCountPolicy.SOMEONE, // Only executes when a player is online
worldPolicy = ExtraWorldPolicy.NOT_USED, // Only executes when the flat world isn't in use
freshnessPolicy = FreshnessPolicy.FRESH // Only executes when the timer wasn't started before
)
public void onTimer() {
}
/**
* Executes every 20 ticks asynchronous (1 second)
*/
@ScheduledTask(ticks = 20)
public void onSecondAsync() {
}
/**
* Executes every 20 ticks synchronous (1 second)
*/
@ScheduledTask(ticks = 20, async = false)
public void onSecond() {
}
/**
* Others parameters will be showen in this example
*/
@ScheduledTask(
ticks = 1, // Every tick
async = false, // Not asynchronous
challengePolicy = ChallengeStatusPolicy.DISABLED, // Only executes when challenge is not enabled
playerPolicy = PlayerCountPolicy.SOMEONE, // Only executes when a player is online
worldPolicy = ExtraWorldPolicy.NOT_USED, // Only executes when the flat world isn't in use
freshnessPolicy = FreshnessPolicy.FRESH // Only executes when the timer wasn't started before
)
public void onTick() {
}
}