Item maps

This commit is contained in:
Sam 2017-07-08 01:34:19 +01:00
parent 994517b3a4
commit 84752f0b17
14 changed files with 355 additions and 575 deletions

View File

@ -1,9 +1,12 @@
package mineplex.core.packethandler; package mineplex.core.imagemap;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.EntityItemFrame; import net.minecraft.server.v1_8_R3.EntityItemFrame;
@ -11,35 +14,30 @@ import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.ItemFrame; import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class CustomFrames extends MiniPlugin implements IPacketHandler public class CustomItemFrames extends MiniPlugin implements IPacketHandler
{ {
private final List<Packet> ourPackets = new ArrayList<>();
private final Map<Integer, Map<UUID, ItemStack>> frameData = new HashMap<>();
private CustomFrames() private final List<Packet> _ourPackets;
private final Map<Integer, Map<UUID, ItemStack>> _frameData;
private CustomItemFrames()
{ {
super("CustomFrames"); super("CustomItemFrames");
_ourPackets = new ArrayList<>();
_frameData = new HashMap<>();
} }
@Override @Override
@ -54,47 +52,19 @@ public class CustomFrames extends MiniPlugin implements IPacketHandler
require(PacketHandler.class).removePacketHandler(this); require(PacketHandler.class).removePacketHandler(this);
} }
//@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(HangingPlaceEvent event)
{
Bukkit.broadcastMessage(event.getEventName());
if (event.getEntity() instanceof ItemFrame)
{
Bukkit.broadcastMessage("ItemFrame");
final ItemFrame frame = (ItemFrame) event.getEntity();
final Random rand = new Random();
new BukkitRunnable()
{
@Override
public void run()
{
Bukkit.broadcastMessage("Setting");
for (Player player : UtilServer.getPlayersCollection())
{
Material mat = Material.values()[rand.nextInt(Material.values().length)];
setItem(player, frame, new org.bukkit.inventory.ItemStack(mat, 1));
}
}
}.runTaskTimer(getPlugin(), 100, 100);
}
}
@Override @Override
public void handle(PacketInfo packetInfo) public void handle(PacketInfo packetInfo)
{ {
if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata) if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata)
{ {
if (ourPackets.contains(packetInfo.getPacket())) if (_ourPackets.contains(packetInfo.getPacket()))
{ {
ourPackets.remove(packetInfo.getPacket()); _ourPackets.remove(packetInfo.getPacket());
return; return;
} }
PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket(); PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket();
Map<UUID, ItemStack> map = frameData.get(packet.a); Map<UUID, ItemStack> map = _frameData.get(packet.a);
if (map != null) if (map != null)
{ {
UUID uuid = packetInfo.getPlayer().getUniqueId(); UUID uuid = packetInfo.getPlayer().getUniqueId();
@ -116,25 +86,23 @@ public class CustomFrames extends MiniPlugin implements IPacketHandler
public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item)
{ {
Bukkit.broadcastMessage(item.getType().toString());
ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone()); ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone());
EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle();
DataWatcher watcher = new DataWatcher(nmsEntity); DataWatcher watcher = new DataWatcher(nmsEntity);
watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem));
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true);
ourPackets.add(packet); _ourPackets.add(packet);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); UtilPlayer.sendPacket(player, packet);
frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem); _frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem);
} }
public void removeItems(ItemFrame frame) public void removeItems(ItemFrame frame)
{ {
frameData.remove(frame.getEntityId()); _frameData.remove(frame.getEntityId());
ItemStack nmsItem = null; ItemStack nmsItem = null;
EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle();

View File

@ -0,0 +1,155 @@
package mineplex.core.imagemap;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilBlock;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapView;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ReflectivelyCreateMiniPlugin
public class ImageMapManager extends MiniPlugin
{
private static final String IMAGE_FILE = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files";
private static final int PIXELS_PER_MAP = 128;
public static int getPixelsPerMap()
{
return PIXELS_PER_MAP;
}
private final CustomItemFrames _itemFrames;
private final Map<String, BufferedImage> _imageCache;
private ImageMapManager()
{
super("Image Map");
_itemFrames = require(CustomItemFrames.class);
_imageCache = new HashMap<>();
}
public void createPlayerBoard(Location topLeft, BlockFace direction, int width, int height)
{
List<ItemFrame> itemFrames = createItemFrames(topLeft, BlockFace.EAST, 7, 4);
PlayerMapImage image1 = new PlayerMapImage(_itemFrames, getImage(new File("Bardolf.png")), itemFrames, 7, 4);
PlayerMapImage image2 = new PlayerMapImage(_itemFrames, getImage(new File("Biff.png")), itemFrames, 7, 4);
runSyncTimer(() ->
{
image.
}, 100, 100);
}
private List<ItemFrame> createItemFrames(Location topLeft, BlockFace direction, int width, int height)
{
List<ItemFrame> itemFrames = new ArrayList<>();
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
Location location = modLocation(topLeft, direction, x, y);
Block opposite = location.getBlock().getRelative(direction.getOppositeFace());
if (!UtilBlock.solid(opposite))
{
opposite.setType(Material.SMOOTH_BRICK);
}
ItemFrame itemFrame = location.getWorld().spawn(location, ItemFrame.class);
itemFrame.setFacingDirection(direction, true);
itemFrames.add(itemFrame);
}
}
return itemFrames;
}
private Location modLocation(Location location, BlockFace direction, int x, int y)
{
int modX = 0;
int modZ = 0;
switch (direction)
{
case NORTH:
modX = -x;
break;
case SOUTH:
modX = x;
break;
case WEST:
modZ = x;
break;
case EAST:
modZ = -x;
break;
}
return new Location(location.getWorld(), location.getBlockX() + modX, location.getBlockY() - y, location.getBlockZ() + modZ);
}
private BufferedImage getImage(File file)
{
if (_imageCache.containsKey(file.getName()))
{
return _imageCache.get(file.getName());
}
try
{
BufferedImage image = ImageIO.read(file);
_imageCache.put(file.getName(), image);
return image;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
private BufferedImage getImage(URL url)
{
if (_imageCache.containsKey(url.toString()))
{
return _imageCache.get(url.toString());
}
try
{
BufferedImage image = ImageIO.read(url);
_imageCache.put(url.toString(), image);
return image;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,41 @@
package mineplex.core.imagemap;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import java.awt.*;
import java.awt.image.BufferedImage;
public class ImageMapRenderer extends MapRenderer
{
private Image _image;
private boolean _rendered;
public ImageMapRenderer(BufferedImage image, int x1, int y1)
{
int startX = Math.min(x1 * ImageMapManager.getPixelsPerMap(), image.getWidth());
startX = Math.max(image.getMinX(), startX);
int startY = Math.min(y1 * ImageMapManager.getPixelsPerMap(), image.getHeight());
startY = Math.max(image.getMinY(), startY);
if (startX + ImageMapManager.getPixelsPerMap() > image.getWidth() || startY + ImageMapManager.getPixelsPerMap() > image.getHeight())
{
return;
}
_image = image.getSubimage(startX, startY, ImageMapManager.getPixelsPerMap(), ImageMapManager.getPixelsPerMap());
}
@Override
public void render(MapView view, MapCanvas canvas, Player player)
{
if (_image != null && !_rendered)
{
canvas.drawImage(0, 0, _image);
_rendered = true;
}
}
}

View File

@ -0,0 +1,55 @@
package mineplex.core.imagemap;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapView;
import java.awt.image.BufferedImage;
import java.util.List;
public class MapImage
{
protected final BufferedImage _image;
protected final List<ItemFrame> _itemFrames;
protected final int _width, _height;
public MapImage(BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
{
_image = image;
_itemFrames = itemFrames;
_width = width;
_height = height;
}
public void create()
{
int i = 0;
for (int x = 0; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
ItemFrame frame = _itemFrames.get(i++);
frame.setItem(getMapItem(frame.getWorld(), x, y));
}
}
}
protected ItemStack getMapItem(World world, int x, int y)
{
ItemStack item = new ItemStack(Material.MAP);
MapView map = Bukkit.getServer().createMap(world);
map.getRenderers().forEach(map::removeRenderer);
map.addRenderer(new ImageMapRenderer(_image, x, y));
item.setDurability(map.getId());
return item;
}
}

View File

@ -0,0 +1,14 @@
package mineplex.core.imagemap;
import org.bukkit.Location;
public class PlayerMapBoard
{
private final Location _location;
public PlayerMapBoard(Location location)
{
_location = location;
}
}

View File

@ -0,0 +1,59 @@
package mineplex.core.imagemap;
import org.bukkit.World;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class PlayerMapImage extends MapImage
{
private final CustomItemFrames _itemFramesManager;
private final List<ItemStack> _itemMaps;
private final List<Player> _viewers;
public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
{
super(image, itemFrames, width, height);
_itemFramesManager = itemFramesManager;
_itemMaps = new ArrayList<>();
_viewers = new ArrayList<>();
}
@Override
public void create()
{
World world = _itemFrames.get(0).getWorld();
for (int x = 0; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
_itemMaps.add(getMapItem(world, x, y));
}
}
}
public void addViewer(Player player)
{
_viewers.add(player);
for (int i = 0; i < _itemMaps.size(); i++)
{
ItemFrame itemFrame = _itemFrames.get(i);
ItemStack itemStack = _itemMaps.get(i);
_itemFramesManager.setItem(player, itemFrame, itemStack);
}
}
public void removeViewer(Player player)
{
_viewers.remove(player);
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer; import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
public class ImageMapRenderer extends MapRenderer class ImageMapRenderer extends MapRenderer
{ {
private BufferedImage _image; private BufferedImage _image;
private boolean _first = true; private boolean _first = true;
public ImageMapRenderer(BufferedImage image) ImageMapRenderer(BufferedImage image)
{ {
_image = image; _image = image;
} }

View File

@ -1,133 +0,0 @@
package mineplex.core.sponsorbranding;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;
import javax.imageio.ImageIO;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
/**
*
* Manager for creating billboards with branding logos
*/
@ReflectivelyCreateMiniPlugin
public class BrandingManager extends MiniPlugin
{
private ConcurrentHashMap<Integer, BrandingPost> _posts = new ConcurrentHashMap<Integer, BrandingPost>();
private ConcurrentHashMap<String, BufferedImage> _imgCache = new ConcurrentHashMap<String, BufferedImage>();
private BrandingManager()
{
super("Branding Manager");
}
private BufferedImage getImage(String fileName)
{
if (_imgCache.containsKey(fileName))
{
return _imgCache.get(fileName);
}
File folder = new File("../../update");
File f = new File(folder, "logos" + File.separatorChar + fileName);
BufferedImage image = null;
if (!f.exists())
{
return null;
}
try
{
image = ImageIO.read(f);
_imgCache.put(fileName, image);
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
private BufferedImage getImage(URL url)
{
if (_imgCache.containsKey(url.toString()))
{
return _imgCache.get(url.toString());
}
BufferedImage image = null;
try
{
image = ImageIO.read(url);
_imgCache.put(url.toString(), image);
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
/**
* Generates a billboard with a stored logo
* @param location The center of the billboard
* @param facing The BlockFace the logo will appear on
* @param imageFileName The file name of the logo's base image
*/
public void createPost(Location location, BlockFace facing, String imageFileName)
{
BufferedImage img = getImage(imageFileName);
if (img == null)
{
System.out.println("ERROR! Invalid image file name!");
return;
}
BrandingPost bp = new BrandingPost(location, facing, img);
bp.spawn();
_posts.put(_posts.size(), bp);
}
public void createPost(Location location, BlockFace facing, URL url)
{
BufferedImage image = getImage(url);
if (image == null)
{
System.out.println("ERROR! Invalid image url!");
return;
}
BrandingPost brandingPost = new BrandingPost(location, facing, image);
brandingPost.spawn();
// Umm why not use a List?
_posts.put(_posts.size(), brandingPost);
}
/**
* Clears away all existing billboards
*/
public void reset()
{
disable();
}
@Override
public void disable()
{
for (Integer key : _posts.keySet())
{
_posts.remove(key).despawn();
}
}
}

View File

@ -1,242 +0,0 @@
package mineplex.core.sponsorbranding;
import java.awt.image.BufferedImage;
import java.util.List;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import com.google.common.collect.Lists;
/**
* An instance of a billboard with all its required data
*/
public class BrandingPost
{
private Location _center;
private BlockFace _facing;
private BufferedImage _img;
private Location[] _corners;
private List<ItemFrame> _ents = Lists.newArrayList();
public BrandingPost(Location center, BlockFace facing, BufferedImage image)
{
_center = center;
_facing = facing;
_img = image;
}
@SuppressWarnings("deprecation")
private ItemStack getMapItem(int x, int y, BufferedImage image)
{
ItemStack item = new ItemStack(Material.MAP);
MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0));
for (MapRenderer r : map.getRenderers())
{
map.removeRenderer(r);
}
map.addRenderer(new LogoMapRenderer(image, x, y));
item.setDurability(map.getId());
return item;
}
/**
* Generates a billboard using parameters from instance constructor
*/
@SuppressWarnings("deprecation")
public void spawn()
{
Location corner1 = _center.clone();
Location corner2 = _center.clone();
Location corner3 = _center.clone();
Location corner4 = _center.clone();
int width = (int) Math.ceil(_img.getWidth() / 128);
int height = (int) Math.ceil(_img.getHeight() / 128);
Bukkit.broadcastMessage("width=" + width + " height=" + height);
switch (_facing)
{
case EAST:
corner1.add(0, 1, -2);
corner2.add(0, -1, 2);
corner3.add(0, 2, -3);
corner4.add(0, -2, 3);
break;
case WEST:
corner1.add(0, 1, -2);
corner2.add(0, -1, 2);
corner3.add(0, 2, -3);
corner4.add(0, -2, 3);
break;
case SOUTH:
corner1.add(-2, 1, 0);
corner2.add(2, -1, 0);
corner3.add(-3, 2, 0);
corner4.add(3, -2, 0);
break;
case NORTH:
corner1.add(-2, 1, 0);
corner2.add(2, -1, 0);
corner3.add(-3, 2, 0);
corner4.add(3, -2, 0);
break;
default:
System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!");
return;
}
_corners = new Location[] {corner1, corner2, corner3, corner4};
for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--)
{
for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--)
{
for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
set.getBlock().setType(Material.STAINED_CLAY);
set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData());
}
}
}
int xMod = 0;
int zMod = 0;
switch (_facing)
{
case EAST:
zMod = -1;
break;
case WEST:
zMod = 1;
break;
case SOUTH:
xMod = 1;
break;
case NORTH:
xMod = -1;
break;
default:
break;
}
BufferedImage image = _img;
if (image == null)
{
System.out.println("ERROR! Invalid image given while loading BrandingPost!");
return;
}
Block base = corner1.getBlock().getRelative(_facing);
try
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
ItemFrame i = null;
Block block = base.getRelative(x * xMod, -y, x * zMod);
i = block.getWorld().spawn(block.getLocation(), ItemFrame.class);
i.setFacingDirection(_facing, false);
ItemStack item = getMapItem(x, y, _img);
i.setItem(item);
Bukkit.broadcastMessage(x + " <- X Y -> " + y);
_ents.add(i);
}
}
}
catch (NullPointerException e)
{
System.out.println("ERROR! ItemFrame space already occupied!");
return;
}
for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--)
{
for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--)
{
for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
if (set.getBlock().getType() == Material.STAINED_CLAY)
continue;
if (UtilMath.offset2d(corner3.getBlock().getLocation(), set.getBlock().getLocation()) == 0 || UtilMath.offset2d(corner4.getBlock().getLocation(), set.getBlock().getLocation()) == 0)
{
if (corner3.getBlockY() != set.getBlockY() && corner4.getBlockY() != set.getBlockY())
{
Material type = Material.COBBLE_WALL;
if (_center.getBlockY() == set.getBlockY())
{
type = Material.FENCE;
}
set.getBlock().setType(type);
continue;
}
}
Material type = Material.STEP;
byte data = (byte)5;
if (set.getBlockY() == corner4.getBlockY())
{
type = Material.SMOOTH_BRICK;
data = (byte)0;
}
set.getBlock().setType(type);
set.getBlock().setData(data);
}
}
}
}
/**
* Clears away all blocks and ItemFrames generated by this billboard
*/
public void despawn()
{
if (_corners != null)
{
for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--)
{
for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--)
{
for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--)
{
Location set = new Location(_center.getWorld(), x, y, z);
set.getBlock().setType(Material.AIR);
}
}
}
}
for (ItemFrame it : _ents)
{
it.setItem(new ItemStack(Material.AIR));
it.remove();
}
_ents.clear();
}
}

View File

@ -1,51 +0,0 @@
package mineplex.core.sponsorbranding;
import java.awt.Image;
import java.awt.image.BufferedImage;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
/**
* Renderer for each map panel of the full billboard logo
*/
public class LogoMapRenderer extends MapRenderer
{
private Image _img;
private boolean _first = true;
public LogoMapRenderer(BufferedImage image, int x1, int y1)
{
recalculateInput(image, x1, y1);
}
private void recalculateInput(BufferedImage input, int x1, int y1)
{
if (x1 > input.getWidth() || y1 > input.getHeight())
{
return;
}
int startX = Math.min(x1 * 128, input.getWidth());
startX = Math.max(input.getMinX(), startX);
int startY = Math.min(y1 * 128, input.getHeight());
startY = Math.max(input.getMinY(), startY);
_img = input.getSubimage(startX, startY, 128, 128);
_first = true;
}
@Override
public void render(MapView view, MapCanvas canvas, Player player)
{
if (_img != null && _first)
{
canvas.drawImage(0, 0, _img);
_first = false;
}
}
}

View File

@ -3,7 +3,7 @@ package nautilus.game.arcade;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.packethandler.CustomFrames; import mineplex.core.imagemap.CustomItemFrames;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -230,7 +230,7 @@ public class Arcade extends JavaPlugin
AprilFoolsManager.getInstance(); AprilFoolsManager.getInstance();
require(CustomFrames.class); require(CustomItemFrames.class);
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -1,13 +1,5 @@
package mineplex.gemhunters; package mineplex.gemhunters;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix; import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix; import mineplex.core.FoodDupeFix;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -70,7 +62,6 @@ import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater; import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager; import mineplex.core.visibility.VisibilityManager;
import mineplex.gemhunters.beta.BetaModule; import mineplex.gemhunters.beta.BetaModule;
import mineplex.gemhunters.bounties.BountyModule;
import mineplex.gemhunters.chat.ChatModule; import mineplex.gemhunters.chat.ChatModule;
import mineplex.gemhunters.death.DeathModule; import mineplex.gemhunters.death.DeathModule;
import mineplex.gemhunters.death.quitnpc.QuitNPCModule; import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
@ -100,6 +91,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule;
import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.damage.DamageManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import static mineplex.core.Managers.require; import static mineplex.core.Managers.require;
@ -275,7 +272,6 @@ public class GemHunters extends JavaPlugin
// Though if any other module needs one of these it will be generated in // Though if any other module needs one of these it will be generated in
// order, however they are all here just for good measure. // order, however they are all here just for good measure.
require(BetaModule.class); require(BetaModule.class);
require(BountyModule.class);
require(CashOutModule.class); require(CashOutModule.class);
require(ChatModule.class); require(ChatModule.class);
require(DeathModule.class); require(DeathModule.class);

View File

@ -1,36 +0,0 @@
package mineplex.gemhunters.bounties;
import java.util.UUID;
import org.bukkit.entity.Player;
public class Bounty
{
private UUID _target;
private UUID _setter;
private int _amount;
public Bounty(Player target, Player setter, int amount)
{
_target = target.getUniqueId();
_setter = setter.getUniqueId();
_amount = amount;
}
public UUID getTarget()
{
return _target;
}
public UUID getSetter()
{
return _setter;
}
public int getAmount()
{
return _amount;
}
}

View File

@ -1,46 +0,0 @@
package mineplex.gemhunters.bounties;
import java.net.MalformedURLException;
import java.net.URL;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.sponsorbranding.BrandingManager;
@ReflectivelyCreateMiniPlugin
public class BountyModule extends MiniPlugin
{
private final BrandingManager _brandingManager;
private BountyModule()
{
super("Bounty");
_brandingManager = require(BrandingManager.class);
}
//@EventHandler
public void test(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().startsWith("/want"))
{
return;
}
try
{
event.setCancelled(true);
_brandingManager.createPost(event.getPlayer().getLocation(), BlockFace.SOUTH, new URL("http://minotar.net/helm/Moppletop.png"));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}