Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void loadPhotos() {
- Path path = Paths.get(main.plugin.getDataFolder().getAbsolutePath() + "/photos/");
- if (!Files.exists(path))return;
- for (File file : new File(path.toString()).listFiles()) {
- String FilePhotoName = file.getName();
- FilePhotoName = FilePhotoName.replace(".yml", "");
- FileConfiguration photos = getPhotos(FilePhotoName);
- String photokey = "photo.frames.";
- ConfigurationSection photoSection = photos.getConfigurationSection(photokey);
- if (photos.isConfigurationSection(photokey)) {
- for (String key : photoSection.getKeys(false)) {
- for (int i = 0; i < photoSection.getKeys(false).size(); i++) {
- if (!photos.isConfigurationSection(photokey + key + ".location")) {
- return;
- }
- Double x = Double.valueOf(photos.getString(photokey + key + ".location.x"));
- Double y = Double.valueOf(photos.getString(photokey + key + ".location.y"));
- Double z = Double.valueOf(photos.getString(photokey + key + ".location.z"));
- World world = main.plugin.getServer().getWorld(UUID.fromString(photos.getString(photokey + key + ".world")));
- Location location = new Location(world, x, y, z);
- MapView mapv = Bukkit.getServer().getMap(photos.getInt(photokey + key + ".mapid"));
- for (MapRenderer render : mapv.getRenderers()) {
- mapv.removeRenderer(render);
- }
- mapv.addRenderer(new MapRenderer() {
- @Override
- public void render(MapView map, MapCanvas canvas, Player player) {
- try {
- URL url = new URL(photos.getString(photokey + key + ".url"));
- BufferedImage inputImage = ImageIO.read(url);
- BufferedImage outputImage = new BufferedImage(128, 128, inputImage.getType());
- Graphics2D g2d = outputImage.createGraphics();
- g2d.drawImage(inputImage, 0, 0, 128, 128, null);
- g2d.dispose();
- canvas.drawImage(0, 0, outputImage);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- });
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment