-
-
Notifications
You must be signed in to change notification settings - Fork 302
/
WanderWaypointProvider.java
65 lines (54 loc) · 1.67 KB
/
WanderWaypointProvider.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
package net.citizensnpcs.trait.waypoint;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.Goal;
import net.citizensnpcs.api.ai.goals.WanderGoal;
import net.citizensnpcs.api.command.CommandContext;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.util.DataKey;
import org.bukkit.entity.Player;
public class WanderWaypointProvider implements WaypointProvider {
private Goal currentGoal;
private volatile boolean paused;
@Persist
private final int xrange = DEFAULT_XRANGE;
@Persist
private final int yrange = DEFAULT_YRANGE;
@Override
public WaypointEditor createEditor(Player player, CommandContext args) {
return new WaypointEditor() {
@Override
public void begin() {
// TODO Auto-generated method stub
}
@Override
public void end() {
// TODO Auto-generated method stub
}
};
}
@Override
public boolean isPaused() {
return paused;
}
@Override
public void load(DataKey key) {
}
@Override
public void onSpawn(NPC npc) {
if (currentGoal == null) {
currentGoal = WanderGoal.createWithNPCAndRange(npc, xrange, yrange);
CitizensAPI.registerEvents(currentGoal);
}
npc.getDefaultGoalController().addGoal(currentGoal, 1);
}
@Override
public void save(DataKey key) {
}
@Override
public void setPaused(boolean paused) {
this.paused = paused;
}
private static final int DEFAULT_XRANGE = 3;
private static final int DEFAULT_YRANGE = 25;
}