-
Notifications
You must be signed in to change notification settings - Fork 73
/
TimeSetToDayEvent.java
93 lines (71 loc) · 2.13 KB
/
TimeSetToDayEvent.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
package be.dezijwegel.bettersleeping.events.custom;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
public class TimeSetToDayEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final World world; // The world in which the time was set to day
private final Cause cause; // The cause of time being set to day
private final List<Player> sleepers; // List of players that slept
private final List<Player> nonSleepers; // List of players that did not sleep
public enum Cause {
NATURAL,
SLEEPING,
OTHER
}
public TimeSetToDayEvent (World world, Cause cause, List<Player> sleepers, List<Player> nonSleepers)
{
super();
this.world = world;
this.cause = cause;
this.sleepers = sleepers.stream()
.filter( player -> !player.hasMetadata("NPC") )
.collect( Collectors.toList() );
this.nonSleepers = nonSleepers.stream()
.filter( player -> !player.hasMetadata("NPC") )
.collect( Collectors.toList() );
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
/**
* Get the world in which the time was set to day
* @return the world
*/
public World getWorld()
{
return world;
}
/**
* Get the cause of time being set to day
* @return the cause
*/
public Cause getCause()
{
return cause;
}
/**
* Get a List of players that slept this night
* @return the list of Players
*/
public List<Player> getPlayersWhoSlept()
{
return sleepers;
}
/**
* Get the List of players that did not sleep last night
* @return the list of players
*/
public List<Player> getPlayersWhoDidNotSleep()
{
return nonSleepers;
}
}