Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minefs.MineStrike.Map;
- import java.awt.Color;
- import java.awt.Graphics2D;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.util.logging.Level;
- import javax.imageio.ImageIO;
- import org.bukkit.map.MapPalette;
- import net.minefs.MineStrike.Main;
- public class MapIcons {
- public static byte[][] PLAYER_DEFAULT, C4, SITE_A, SITE_B, SKULL, ENEMY, SUPPLY;
- @SuppressWarnings("deprecation")
- public static byte[][] loadFromImage(BufferedImage base) {
- int w = base.getWidth(), h = base.getHeight();
- BufferedImage img2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g = img2.createGraphics();
- g.drawImage(base, 0, 0, null);
- g.dispose();
- byte[][] kq = new byte[w][h];
- for (int x = 0; x < w; ++x)
- for (int y = 0; y < h; ++y)
- kq[x][y] = MapPalette.matchColor(new Color(img2.getRGB(x, y), true));
- return kq;
- }
- public static void setupIcons() {
- Main main = Main.getInstance();
- PLAYER_DEFAULT = main.getMySQL().getSkinIcon("skinslib_macdinh_nam");
- try {
- C4 = loadFromImage(ImageIO.read(new File(Main.getInstance().getDataFolder() + "/mapicons/c4.png")));
- } catch (IOException e) {
- main.getLogger().log(Level.SEVERE, "Can't load c4 icon", e);
- }
- try {
- SITE_A = loadFromImage(ImageIO.read(new File(Main.getInstance().getDataFolder() + "/mapicons/site-a.png")));
- } catch (IOException e) {
- main.getLogger().log(Level.SEVERE, "Can't load site A icon", e);
- }
- try {
- SITE_B = loadFromImage(ImageIO.read(new File(Main.getInstance().getDataFolder() + "/mapicons/site-b.png")));
- } catch (IOException e) {
- main.getLogger().log(Level.SEVERE, "Can't load site B icon", e);
- }
- try {
- SKULL = loadFromImage(ImageIO.read(new File(Main.getInstance().getDataFolder() + "/mapicons/skull.png")));
- } catch (IOException e) {
- main.getLogger().log(Level.SEVERE, "Can't load skull icon", e);
- }
- try {
- SUPPLY = loadFromImage(ImageIO.read(new File(Main.getInstance().getDataFolder() + "/mapicons/supply.png")));
- } catch (IOException e) {
- main.getLogger().log(Level.SEVERE, "Can't load suplly icon", e);
- }
- ENEMY = new byte[4][4];
- for (int i = 0; i < 4; ++i)
- for (int j = 0; j < 4; ++j)
- ENEMY[i][j] = 18;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment