Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.jamco.minecraft.plugins.jamos;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.image.BufferedImage;
- import java.util.ArrayList;
- import java.util.List;
- import me.bigteddy98.mapart.ArtRenderer;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.event.Listener;
- import org.bukkit.plugin.java.JavaPlugin;
- public class JamOS extends JavaPlugin implements Listener {
- private ArtRenderer artRenderer;
- @Override
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- artRenderer = new ArtRenderer(this);
- Location loc = new Location(getServer().getWorld("world"), 27, 74, -60);
- BufferedImage image = toBufferedImage(artRenderer.getImageFromURL("http://i.imgur.com/uOAsa4x.png"));
- List<BufferedImage> images = split(image, 5, 3);
- int imageNum = 1;
- int start_x = 27;
- int start_y = 74;
- int start_z = -60;
- int end_x = 31;
- int end_y = 76;
- int end_z = -60;
- for (int x = start_x; x <= end_x; x++) {
- for (int y = start_y; y <= end_y; y++) {
- for (int z = start_z; z <= end_z; z++) {
- loc = new Location(getServer().getWorld("world"), x, y, z);
- artRenderer.makeArt(loc, images.get(imageNum));
- imageNum++;
- }
- }
- }
- }
- public static BufferedImage toBufferedImage(Image img)
- {
- if (img instanceof BufferedImage)
- {
- return (BufferedImage) img;
- }
- // Create a buffered image with transparency
- BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
- // Draw the image on to the buffered image
- Graphics2D bGr = bimage.createGraphics();
- bGr.drawImage(img, 0, 0, null);
- bGr.dispose();
- // Return the buffered image
- return bimage;
- }
- @Override
- public void onDisable() {
- artRenderer.reloadAll();
- }
- public void log(String msg) {
- getLogger().info(msg);
- }
- public List<BufferedImage> split(BufferedImage image, int width, int height) {
- int type = image.getType();
- int imageWidth = image.getWidth();
- int imageHeight = image.getHeight();
- int rows = imageWidth / width;
- if (imageWidth % width != 0)
- rows++;
- int columns = imageHeight / height;
- if (imageHeight % height != 0)
- columns++;
- List<BufferedImage> images = new ArrayList<BufferedImage>();
- for (int x = 0; x < rows; x++) {
- for (int y = 0; y < columns; y++) {
- int positionX = width * x;
- int positionY = width * y;
- int splitWidth = positionX + width > imageWidth ? imageWidth - positionX : width;
- int splitHeight = positionY + height > imageHeight ? imageHeight - positionY : height;
- BufferedImage split = new BufferedImage(splitWidth, splitHeight, type);
- Graphics2D graphics = split.createGraphics();
- graphics.drawImage(image, 0, 0, splitWidth, splitHeight, positionX, positionY, positionX + splitWidth, positionY + splitHeight, null);
- graphics.dispose();
- images.add(split);
- }
- }
- return images;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
- if(cmd.getName().equalsIgnoreCase("jamos")){
- //Do some stuff
- /**if(args[1] == "login") {
- }*/
- return true;
- } //If this has happened the function will return true.
- // If this hasn't happened the a value of false will be returned.
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement