/
MapAnimatedImage.java
44 lines (32 loc) · 1.28 KB
/
MapAnimatedImage.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
package net.aufdemrand.denizen.utilities.maps;
import net.aufdemrand.denizen.objects.dPlayer;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapView;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.util.UUID;
public class MapAnimatedImage extends MapImage {
protected AnimationObserver observer = null;
public MapAnimatedImage(String xTag, String yTag, String visibilityTag, boolean debug, String fileTag, int width, int height) {
super(xTag, yTag, visibilityTag, debug, fileTag, width, height, false);
}
@Override
public void render(MapView mapView, MapCanvas mapCanvas, dPlayer player, UUID uuid) {
super.render(mapView, mapCanvas, player, uuid);
if (observer == null) {
observer = new AnimationObserver(this);
imageIcon.setImageObserver(observer);
}
}
public class AnimationObserver implements ImageObserver {
private final MapAnimatedImage image;
AnimationObserver(MapAnimatedImage image) {
this.image = image;
}
@Override
public boolean imageUpdate(Image gif, int infoflags, int x, int y, int width, int height) {
image.setImage(gif);
return true;
}
}
}