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
|
package org.bukkit.map;
import java.awt.Color;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.MaterialMapColor;
import org.junit.Assert;
import org.junit.Test;
public class MapTest {
private static final Logger logger = Logger.getLogger("MapTest");
private static final int[] modifiers = {180, 220, 255, 135};
@Test
public void testColors() {
MaterialMapColor[] nmsColors = MaterialMapColor.a;
Color[] bukkitColors = MapPalette.colors;
boolean fail = false;
for (int i = 0; i < nmsColors.length; i++) {
if (nmsColors[i] == null) {
break;
}
int rgb = nmsColors[i].L;
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = rgb & 0xFF;
if (i > bukkitColors.length/4) {
for (int modi : modifiers) {
int mr = (r * modi) / 255;
int mg = (g * modi) / 255;
int mb = (b * modi) / 255;
logger.log(Level.WARNING, "Missing color: c({0}, {1}, {2})", new Object[]{mr, mg, mb});
}
fail = true;
} else {
for (int j = 0; j < modifiers.length; j++) {
int modi = modifiers[j];
Color bukkit = bukkitColors[i * 4 + j];
int mr = (r * modi) / 255;
int mg = (g * modi) / 255;
int mb = (b * modi) / 255;
if (bukkit.getRed() != mr || bukkit.getGreen() != mg || bukkit.getBlue() != mb) {
logger.log(Level.WARNING, "Incorrect color: {6} {7} c({0}, {1}, {2}) != c({3}, {4}, {5})", new Object[]{
bukkit.getRed(), bukkit.getGreen(), bukkit.getBlue(),
mr, mg, mb,
i, j
});
fail = true;
}
}
}
}
Assert.assertFalse(fail);
}
}
|