mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-12-11 11:18:55 +01:00
dithering floyd (partial don't work properly)
This commit is contained in:
parent
219869c82b
commit
97af1a8080
@ -120,6 +120,9 @@ public class NewCommand extends IoMCommand
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch(final Throwable e){
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
//Added to fix bug with rendering displaying after error
|
//Added to fix bug with rendering displaying after error
|
||||||
finally {
|
finally {
|
||||||
ActionBar.removeMessage(player);
|
ActionBar.removeMessage(player);
|
||||||
|
@ -38,6 +38,7 @@ package fr.moribus.imageonmap.image;
|
|||||||
|
|
||||||
import fr.moribus.imageonmap.ImageOnMap;
|
import fr.moribus.imageonmap.ImageOnMap;
|
||||||
import fr.moribus.imageonmap.map.MapManager;
|
import fr.moribus.imageonmap.map.MapManager;
|
||||||
|
import fr.moribus.imageonmap.ui.SplatterMapManager;
|
||||||
import fr.zcraft.zlib.core.ZLib;
|
import fr.zcraft.zlib.core.ZLib;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -47,9 +48,11 @@ import org.bukkit.entity.HumanEntity;
|
|||||||
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.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -114,7 +117,56 @@ public class MapInitEvent implements Listener
|
|||||||
initMap(event.getCursor());
|
initMap(event.getCursor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
private void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
|
||||||
|
//Checks if they have clicked anywhere else on the screen while an inventory is open
|
||||||
|
if(event.getClickedInventory() == null) return;
|
||||||
|
|
||||||
|
//Checks if the clicked slot is empty
|
||||||
|
if(event.getClickedInventory().getItem(event.getSlot()) == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
//Forbid deposit of map in unwanted block
|
||||||
|
if(event.getInventory().getType().name().equals("GRINDSTONE") & SplatterMapManager.isSplatterMap(event.getCurrentItem())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//To cancel removing of glowing effect
|
||||||
|
if(event.getClickedInventory().getSize()==3) {
|
||||||
|
|
||||||
|
String inventoryClickedTitle=event.getClickedInventory().getType().name();
|
||||||
|
//Ignore those blocks
|
||||||
|
if(event.getClickedInventory().getType()== InventoryType.ANVIL||event.getClickedInventory().getType()==InventoryType.FURNACE||inventoryClickedTitle.equals("BLAST_FURNACE")||inventoryClickedTitle.equals("SMOKER")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(inventoryClickedTitle.equals("CARTOGRAPHY_TABLE")){
|
||||||
|
if(event.getInventory().contains(Material.PAPER)){
|
||||||
|
ItemStack[] inventory=event.getClickedInventory().getContents();
|
||||||
|
|
||||||
|
for(ItemStack item:inventory) {
|
||||||
|
if (SplatterMapManager.isSplatterMap(item)) {
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemStack[] inventory=event.getClickedInventory().getContents();
|
||||||
|
|
||||||
|
for(ItemStack item:inventory){
|
||||||
|
if (SplatterMapManager.isSplatterMap(item)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
static public void initMap(ItemStack item)
|
static public void initMap(ItemStack item)
|
||||||
{
|
{
|
||||||
if (item != null && item.getType() == Material.FILLED_MAP)
|
if (item != null && item.getType() == Material.FILLED_MAP)
|
||||||
|
@ -40,88 +40,280 @@ import fr.zcraft.zlib.tools.PluginLogger;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.map.MapCanvas;
|
import org.bukkit.map.MapCanvas;
|
||||||
|
import org.bukkit.map.MapPalette;
|
||||||
import org.bukkit.map.MapRenderer;
|
import org.bukkit.map.MapRenderer;
|
||||||
import org.bukkit.map.MapView;
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public class Renderer extends MapRenderer
|
public class Renderer extends MapRenderer {
|
||||||
{
|
private BufferedImage image;
|
||||||
static public boolean isHandled(MapView map)
|
|
||||||
{
|
protected Renderer() {
|
||||||
if(map == null) return false;
|
this(null);
|
||||||
for(MapRenderer renderer : map.getRenderers())
|
}
|
||||||
{
|
|
||||||
if(renderer instanceof Renderer) return true;
|
protected Renderer(BufferedImage image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public boolean isHandled(MapView map) {
|
||||||
|
if (map == null) return false;
|
||||||
|
for (MapRenderer renderer : map.getRenderers()) {
|
||||||
|
if (renderer instanceof Renderer) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void installRenderer(PosterImage image, int[] mapsIds)
|
static public void installRenderer(PosterImage image, int[] mapsIds) {
|
||||||
{
|
for (int i = 0; i < mapsIds.length; i++) {
|
||||||
for(int i = 0; i < mapsIds.length; i++)
|
|
||||||
{
|
|
||||||
installRenderer(image.getImageAt(i), mapsIds[i]);
|
installRenderer(image.getImageAt(i), mapsIds[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void installRenderer(BufferedImage image, int mapID)
|
static public void installRenderer(BufferedImage image, int mapID) {
|
||||||
{
|
|
||||||
MapView map = Bukkit.getMap(mapID);
|
MapView map = Bukkit.getMap(mapID);
|
||||||
if(map == null)
|
if (map == null) {
|
||||||
{
|
|
||||||
PluginLogger.warning("Could not install renderer for map {0}: the Minecraft map does not exist", mapID);
|
PluginLogger.warning("Could not install renderer for map {0}: the Minecraft map does not exist", mapID);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
installRenderer(map).setImage(image);
|
installRenderer(map).setImage(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Renderer installRenderer(MapView map)
|
static public Renderer installRenderer(MapView map) {
|
||||||
{
|
|
||||||
Renderer renderer = new Renderer();
|
Renderer renderer = new Renderer();
|
||||||
removeRenderers(map);
|
removeRenderers(map);
|
||||||
map.addRenderer(renderer);
|
map.addRenderer(renderer);
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void removeRenderers(MapView map)
|
static public void removeRenderers(MapView map) {
|
||||||
{
|
for (MapRenderer renderer : map.getRenderers()) {
|
||||||
for(MapRenderer renderer : map.getRenderers())
|
|
||||||
{
|
|
||||||
map.removeRenderer(renderer);
|
map.removeRenderer(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedImage image;
|
|
||||||
|
|
||||||
protected Renderer()
|
|
||||||
{
|
|
||||||
this(null);
|
private static double getDistance(Color c1, Color c2) {
|
||||||
|
double rmean = (c1.getRed() + c2.getRed()) / 2.0;
|
||||||
|
double r = c1.getRed() - c2.getRed();
|
||||||
|
double g = c1.getGreen() - c2.getGreen();
|
||||||
|
int b = c1.getBlue() - c2.getBlue();
|
||||||
|
double weightR = 2 + rmean / 256.0;
|
||||||
|
double weightG = 4.0;
|
||||||
|
double weightB = 2 + (255 - rmean) / 256.0;
|
||||||
|
return weightR * r * r + weightG * g * g + weightB * b * b;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Renderer(BufferedImage image)
|
private byte closestColor(int rgb) {
|
||||||
{
|
int alpha = (rgb >>> 24) & 0xFF;
|
||||||
this.image = image;
|
int r = (rgb >>> 16) & 0xFF;
|
||||||
|
int g = (rgb >>> 8) & 0xFF;
|
||||||
|
int b = rgb & 0xFF;
|
||||||
|
byte col = MapPalette.matchColor(new Color(r, g, b, alpha));
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class RGB{
|
||||||
|
private int alpha,r,g,b;
|
||||||
|
public RGB(int r, int g, int b,int alpha){
|
||||||
|
|
||||||
|
this.r=r;
|
||||||
|
this.g=g;
|
||||||
|
this.b=b;
|
||||||
|
this.alpha=alpha;
|
||||||
|
}
|
||||||
|
public RGB(int rgb){
|
||||||
|
int alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
int r = (rgb >>> 16) & 0xFF;
|
||||||
|
int g = (rgb >>> 8) & 0xFF;
|
||||||
|
int b = rgb & 0xFF;
|
||||||
|
|
||||||
|
this.r=r;
|
||||||
|
this.g=g;
|
||||||
|
this.b=b;
|
||||||
|
this.alpha=alpha;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RGB(int r, int g, int b){
|
||||||
|
|
||||||
|
this.r=r;
|
||||||
|
this.g=g;
|
||||||
|
this.b=b;
|
||||||
|
this.alpha=255;
|
||||||
|
}
|
||||||
|
public void applyFactor(double factor){
|
||||||
|
r*=factor;
|
||||||
|
g*=factor;
|
||||||
|
b*=factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void dithering(MapCanvas canvas) {
|
||||||
|
|
||||||
|
for (int x = 0; x < 128; x++) {
|
||||||
|
for (int y = 0; y < 128; y++) {
|
||||||
|
int rgb = image.getRGB(x, y);
|
||||||
|
Color old_pix = new Color(rgb);
|
||||||
|
Color new_pix = MapPalette.getColor(MapPalette.matchColor(old_pix));//Couleur la plus proche
|
||||||
|
|
||||||
|
int alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
if (alpha < 128) {
|
||||||
|
canvas.setPixel(x, y, (byte) 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
canvas.setPixel(x, y, MapPalette.matchColor(new_pix));//On applique la nouvelle couleur
|
||||||
|
|
||||||
|
int diff_red=old_pix.getRed()-new_pix.getRed();
|
||||||
|
int diff_green=old_pix.getGreen()-new_pix.getGreen();
|
||||||
|
int diff_blue=old_pix.getBlue()-new_pix.getBlue();
|
||||||
|
|
||||||
|
|
||||||
|
//Distribution de l'erreur
|
||||||
|
int X = 0, Y = 0, r, g, b;
|
||||||
|
int value = 0;//120+4+4+7*4+24+1+16;//208+10*4+4;
|
||||||
|
if (x + 1 >= 128 | y + 1 >= 128 | x - 1 < 0) {
|
||||||
|
//PluginLogger.info("On va trop loin");
|
||||||
|
canvas.setPixel(x, y, (byte) 20);//MapPalette.matchColor(new_pix));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double factor;
|
||||||
|
try {
|
||||||
|
X = x + 1;
|
||||||
|
Y = y;
|
||||||
|
factor=7.0/16;
|
||||||
|
|
||||||
|
rgb=(MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB());
|
||||||
|
//rgb = (int) ((MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB()) + (error * 7.0 / 16));
|
||||||
|
alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
r = (rgb >>> 16) & 0xFF;
|
||||||
|
g = (rgb >>> 8) & 0xFF;
|
||||||
|
b = rgb & 0xFF;
|
||||||
|
r+=diff_red*factor;
|
||||||
|
g+=diff_green*factor;
|
||||||
|
b+=diff_blue*factor;
|
||||||
|
|
||||||
|
if (alpha < 128)
|
||||||
|
canvas.setPixel(x, y, (byte) 0);
|
||||||
|
else
|
||||||
|
canvas.setPixel(x, y, MapPalette.matchColor(r, g, b));//Pb possible avec alpha
|
||||||
|
|
||||||
|
X = x - 1;
|
||||||
|
Y = y + 1;
|
||||||
|
factor=3.0/16;
|
||||||
|
rgb=(MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB());
|
||||||
|
//rgb = (int) ((MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB()) + (error * 3.0 / 16));
|
||||||
|
alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
r = (rgb >>> 16) & 0xFF;
|
||||||
|
g = (rgb >>> 8) & 0xFF;
|
||||||
|
b = rgb & 0xFF;
|
||||||
|
r+=diff_red*factor;
|
||||||
|
g+=diff_green*factor;
|
||||||
|
b+=diff_blue*factor;
|
||||||
|
if (alpha < 128)
|
||||||
|
canvas.setPixel(x, y, (byte) 0);
|
||||||
|
else
|
||||||
|
canvas.setPixel(x, y, MapPalette.matchColor(r, g, b));//Pb possible avec alpha
|
||||||
|
|
||||||
|
X = x;
|
||||||
|
Y = y + 1;
|
||||||
|
factor=5.0/16;
|
||||||
|
rgb=(MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB());
|
||||||
|
//rgb = (int) ((MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB()) + (error * 5.0 / 16));
|
||||||
|
alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
r = (rgb >>> 16) & 0xFF;
|
||||||
|
g = (rgb >>> 8) & 0xFF;
|
||||||
|
b = rgb & 0xFF;
|
||||||
|
r+=diff_red*factor;
|
||||||
|
g+=diff_green*factor;
|
||||||
|
b+=diff_blue*factor;
|
||||||
|
if (alpha < 128)
|
||||||
|
canvas.setPixel(x, y, (byte) 0);
|
||||||
|
else
|
||||||
|
canvas.setPixel(x, y, MapPalette.matchColor(r, g, b));//Pb possible avec alpha
|
||||||
|
|
||||||
|
X = x + 1;
|
||||||
|
Y = y + 1;
|
||||||
|
factor=1.0/16;
|
||||||
|
rgb=(MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB());
|
||||||
|
//rgb = (int) ((MapPalette.getColor(canvas.getPixel(X, Y) < 0 ? (byte) (canvas.getPixel(x, y) + value) : canvas.getPixel(x, y)).getRGB()) + (error * 1.0 / 16));
|
||||||
|
alpha = (rgb >>> 24) & 0xFF;
|
||||||
|
r = (rgb >>> 16) & 0xFF;
|
||||||
|
g = (rgb >>> 8) & 0xFF;
|
||||||
|
b = rgb & 0xFF;
|
||||||
|
int rold = r;
|
||||||
|
int gold = g;
|
||||||
|
int bold = b;
|
||||||
|
r+=diff_red*factor;
|
||||||
|
g+=diff_green*factor;
|
||||||
|
b+=diff_blue*factor;
|
||||||
|
if (alpha < 128)
|
||||||
|
canvas.setPixel(x, y, (byte) 0);
|
||||||
|
else
|
||||||
|
canvas.setPixel(x, y, MapPalette.matchColor(r, g, b));//Pb possible avec alpha
|
||||||
|
// PluginLogger.info("r "+r+" g "+g+" b "+b);
|
||||||
|
//PluginLogger.info("rold "+rold+" gold "+gold+" bold "+bold);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PluginLogger.info("Exception get color ");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
//canvas.setPixel(x-1,y+1,canvas.getPixel(x-1,y+1)+(error*7.0/16));
|
||||||
|
//canvas.setPixel(x,y+1,canvas.getPixel(x,y+1)+(error*7.0/16));
|
||||||
|
//canvas.setPixel(x+1,y+1,canvas.getPixel(x+1,y+1)+(error*7.0/16));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MapView v, final MapCanvas canvas, Player p)
|
public void render(MapView v, MapCanvas canvas, Player p) {
|
||||||
{
|
|
||||||
|
|
||||||
//Render only once to avoid overloading the server
|
//Render only once to avoid overloading the server
|
||||||
if (image == null) return;
|
if (image == null) return;
|
||||||
canvas.drawImage(0, 0, image);
|
boolean dither = true;
|
||||||
image = null;
|
// canvas.drawImage(0, 0, image);
|
||||||
|
if (dither) {
|
||||||
|
dithering(canvas);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int x = 0; x < 128; x++) {
|
||||||
|
for (int y = 0; y < 128; y++) {
|
||||||
|
int rgb = image.getRGB(x, y);
|
||||||
|
byte col = closestColor(rgb);
|
||||||
|
|
||||||
|
canvas.setPixel(x, y, col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage()
|
/* for(int x=0;x<128;x++){
|
||||||
{
|
for(int y=0;y<128;y++){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int rgb=image.getRGB(x,y);
|
||||||
|
int r = (rgb >>> 16) & 0xFF;
|
||||||
|
int g = (rgb >>> 8) & 0xFF;
|
||||||
|
int b = rgb & 0xFF;
|
||||||
|
//PluginLogger.info("canvas pixel "+x+" "+y+" r "+r+" g "+g+" b "+b);
|
||||||
|
PluginLogger.info(""+canvas.getBasePixel(x,y));
|
||||||
|
canvas.setPixel(x,y,(byte)208);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
image = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImage(BufferedImage image)
|
public void setImage(BufferedImage image) {
|
||||||
{
|
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,12 +126,20 @@ abstract public class MapManager
|
|||||||
static public int[] getNewMapsIds(int amount)
|
static public int[] getNewMapsIds(int amount)
|
||||||
{
|
{
|
||||||
int[] mapsIds = new int[amount];
|
int[] mapsIds = new int[amount];
|
||||||
for(int i = 0; i < amount; i++)
|
try {
|
||||||
{
|
for (int i = 0; i < amount; i++) {
|
||||||
mapsIds[i] = Bukkit.createMap(Bukkit.getWorlds().get(0)).getId();
|
mapsIds[i] = Bukkit.createMap(Bukkit.getWorlds().get(0)).getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
return mapsIds;
|
return mapsIds;
|
||||||
}
|
}
|
||||||
|
catch (final Throwable e){
|
||||||
|
PluginLogger.warning("Erreur a la creation de map !!!");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the map ID from an ItemStack
|
* Returns the map ID from an ItemStack
|
||||||
@ -140,12 +148,15 @@ abstract public class MapManager
|
|||||||
*/
|
*/
|
||||||
static public int getMapIdFromItemStack(final ItemStack item)
|
static public int getMapIdFromItemStack(final ItemStack item)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
final ItemMeta meta = item.getItemMeta();
|
||||||
if (!(meta instanceof MapMeta)) return 0;
|
if (!(meta instanceof MapMeta)) return 0;
|
||||||
|
|
||||||
return ((MapMeta) meta).hasMapId() ? ((MapMeta) meta).getMapId() : 0;
|
return ((MapMeta) meta).hasMapId() ? ((MapMeta) meta).getMapId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public void addMap(ImageMap map) throws MapManagerException
|
static public void addMap(ImageMap map) throws MapManagerException
|
||||||
{
|
{
|
||||||
getPlayerMapStore(map.getUserUUID()).addMap(map);
|
getPlayerMapStore(map.getUserUUID()).addMap(map);
|
||||||
|
@ -36,12 +36,14 @@
|
|||||||
|
|
||||||
package fr.moribus.imageonmap.ui;
|
package fr.moribus.imageonmap.ui;
|
||||||
|
|
||||||
|
import fr.moribus.imageonmap.Permissions;
|
||||||
import fr.moribus.imageonmap.map.ImageMap;
|
import fr.moribus.imageonmap.map.ImageMap;
|
||||||
import fr.moribus.imageonmap.map.MapManager;
|
import fr.moribus.imageonmap.map.MapManager;
|
||||||
import fr.moribus.imageonmap.map.PosterMap;
|
import fr.moribus.imageonmap.map.PosterMap;
|
||||||
import fr.moribus.imageonmap.map.SingleMap;
|
import fr.moribus.imageonmap.map.SingleMap;
|
||||||
import fr.zcraft.zlib.components.i18n.I;
|
import fr.zcraft.zlib.components.i18n.I;
|
||||||
import fr.zcraft.zlib.core.ZLib;
|
import fr.zcraft.zlib.core.ZLib;
|
||||||
|
import fr.zcraft.zlib.tools.PluginLogger;
|
||||||
import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
||||||
import fr.zcraft.zlib.tools.items.ItemUtils;
|
import fr.zcraft.zlib.tools.items.ItemUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -271,6 +273,7 @@ public class MapItemManager implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
|
PluginLogger.info("Coucou je suis une carte simple");
|
||||||
frame.setItem(mapItem);
|
frame.setItem(mapItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,6 +288,8 @@ public class MapItemManager implements Listener
|
|||||||
ItemStack item = frame.getItem();
|
ItemStack item = frame.getItem();
|
||||||
if (frame.getItem().getType() != Material.FILLED_MAP) return;
|
if (frame.getItem().getType() != Material.FILLED_MAP) return;
|
||||||
|
|
||||||
|
if (Permissions.REMOVE_SPLATTER_MAP.grantedTo(player))
|
||||||
|
{
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
{
|
{
|
||||||
PosterMap poster = SplatterMapManager.removeSplatterMap(frame,player);
|
PosterMap poster = SplatterMapManager.removeSplatterMap(frame,player);
|
||||||
@ -298,6 +303,7 @@ public class MapItemManager implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!MapManager.managesMap(frame.getItem())) return;
|
if (!MapManager.managesMap(frame.getItem())) return;
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ public class PosterOnASurface {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If in creative expand item frames in order to auto deploy
|
||||||
public void expand() {
|
public void expand() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,69 +43,82 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PosterWall
|
public class PosterWall {
|
||||||
{
|
|
||||||
|
|
||||||
public FlatLocation loc1;
|
public FlatLocation loc1;
|
||||||
public FlatLocation loc2;
|
public FlatLocation loc2;
|
||||||
|
|
||||||
public ItemFrame[] frames;
|
public ItemFrame[] frames;
|
||||||
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
ItemFrame curFrame;
|
|
||||||
FlatLocation bottomLeft = FlatLocation.minMerged(loc1, loc2);
|
|
||||||
FlatLocation loc = bottomLeft.clone();
|
|
||||||
|
|
||||||
int distX = FlatLocation.flatBlockDistanceX(loc1, loc2);
|
|
||||||
int distY = FlatLocation.flatBlockDistanceY(loc1, loc2);
|
|
||||||
|
|
||||||
frames = new ItemFrame[distX * distY];
|
private static boolean supportIsValid(FlatLocation location, BlockFace bf, int width, int height) {
|
||||||
|
//Code to add
|
||||||
for(int x = 0; x < distX; x++)
|
FlatLocation loc=location.clone();
|
||||||
{
|
loc.add(0,-1);
|
||||||
for(int y = 0; y < distY; y++)
|
switch (bf){
|
||||||
{
|
case EAST:
|
||||||
curFrame = getEmptyFrameAt(loc, loc.getFacing());
|
case WEST:
|
||||||
if(curFrame == null) return false;
|
loc.addH(1,0,bf);
|
||||||
frames[y * distX + x] = curFrame;
|
break;
|
||||||
loc.add(0, 1);
|
case NORTH:
|
||||||
|
case SOUTH:
|
||||||
|
loc.addH(0,1,bf);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
loc.add(1, 0);
|
for (int x = 0; x < width; x++) {
|
||||||
loc.setY(bottomLeft.getY());
|
for (int y = 0; y < height; y++) {
|
||||||
}
|
// if(loc.getBlock().)
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void expand()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, int mapId)
|
}
|
||||||
{
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Used to expand itemframes when possible
|
||||||
|
public static void expand(FlatLocation location,BlockFace bf ,int width, int height) throws Exception{
|
||||||
|
if (!supportIsValid(location,bf, width, height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
FlatLocation loc=location.clone();
|
||||||
|
loc.add(0,-1);
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
loc.add(0,1);
|
||||||
|
loc.getWorld().spawnEntity(loc, EntityType.ITEM_FRAME);
|
||||||
|
}
|
||||||
|
loc.add(1,-height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, int mapId, Player p) {
|
||||||
|
if (p.getGameMode() == GameMode.CREATIVE)
|
||||||
|
expand(location, map.getColumnCount(), map.getRowCount());
|
||||||
|
return getMatchingMapFrames(map, location, mapId);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, int mapId) {
|
||||||
int mapIndex = map.getIndex(mapId);
|
int mapIndex = map.getIndex(mapId);
|
||||||
int x = map.getColumnAt(mapIndex), y = map.getRowAt(mapIndex);
|
int x = map.getColumnAt(mapIndex), y = map.getRowAt(mapIndex);
|
||||||
|
|
||||||
return getMatchingMapFrames(map, location.clone().add(-x, y));
|
return getMatchingMapFrames(map, location.clone().add(-x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location)
|
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location) {
|
||||||
{
|
|
||||||
ItemFrame[] frames = new ItemFrame[map.getMapCount()];
|
ItemFrame[] frames = new ItemFrame[map.getMapCount()];
|
||||||
FlatLocation loc = location.clone();
|
FlatLocation loc = location.clone();
|
||||||
|
|
||||||
for(int y = 0; y < map.getRowCount(); ++y)
|
for (int y = 0; y < map.getRowCount(); ++y) {
|
||||||
{
|
for (int x = 0; x < map.getColumnCount(); ++x) {
|
||||||
for(int x = 0; x < map.getColumnCount(); ++x)
|
|
||||||
{
|
|
||||||
int mapIndex = map.getIndexAt(x, y);
|
int mapIndex = map.getIndexAt(x, y);
|
||||||
ItemFrame frame = getMapFrameAt(loc, map);
|
ItemFrame frame = getMapFrameAt(loc, map);
|
||||||
if(frame != null) frames[mapIndex] = frame;
|
if (frame != null) frames[mapIndex] = frame;
|
||||||
loc.add(1, 0);
|
loc.add(1, 0);
|
||||||
}
|
}
|
||||||
loc.setX(location.getX());
|
loc.setX(location.getX());
|
||||||
@ -116,40 +129,60 @@ public class PosterWall
|
|||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ItemFrame getMapFrameAt(FlatLocation location, PosterMap map)
|
static public ItemFrame getMapFrameAt(FlatLocation location, PosterMap map) {
|
||||||
{
|
|
||||||
Entity entities[] = location.getChunk().getEntities();
|
Entity entities[] = location.getChunk().getEntities();
|
||||||
|
|
||||||
for(Entity entity : entities)
|
for (Entity entity : entities) {
|
||||||
{
|
if (!(entity instanceof ItemFrame)) continue;
|
||||||
if(!(entity instanceof ItemFrame)) continue;
|
if (!WorldUtils.blockEquals(location, entity.getLocation())) continue;
|
||||||
if(!WorldUtils.blockEquals(location, entity.getLocation())) continue;
|
|
||||||
ItemFrame frame = (ItemFrame) entity;
|
ItemFrame frame = (ItemFrame) entity;
|
||||||
if(frame.getFacing() != location.getFacing()) continue;
|
if (frame.getFacing() != location.getFacing()) continue;
|
||||||
ItemStack item = frame.getItem();
|
ItemStack item = frame.getItem();
|
||||||
if(item.getType() != Material.FILLED_MAP) continue;
|
if (item.getType() != Material.FILLED_MAP) continue;
|
||||||
if(!map.managesMap(item)) continue;
|
if (!map.managesMap(item)) continue;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ItemFrame getEmptyFrameAt(Location location, BlockFace facing)
|
static public ItemFrame getEmptyFrameAt(Location location, BlockFace facing) {
|
||||||
{
|
|
||||||
Entity entities[] = location.getChunk().getEntities();
|
Entity entities[] = location.getChunk().getEntities();
|
||||||
|
|
||||||
for(Entity entity : entities)
|
for (Entity entity : entities) {
|
||||||
{
|
if (!(entity instanceof ItemFrame)) continue;
|
||||||
if(!(entity instanceof ItemFrame)) continue;
|
if (!WorldUtils.blockEquals(location, entity.getLocation())) continue;
|
||||||
if(!WorldUtils.blockEquals(location, entity.getLocation())) continue;
|
|
||||||
ItemFrame frame = (ItemFrame) entity;
|
ItemFrame frame = (ItemFrame) entity;
|
||||||
if(frame.getFacing() != facing) continue;
|
if (frame.getFacing() != facing) continue;
|
||||||
ItemStack item = frame.getItem();
|
ItemStack item = frame.getItem();
|
||||||
if(item.getType() != Material.AIR) continue;
|
if (item.getType() != Material.AIR) continue;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
ItemFrame curFrame;
|
||||||
|
FlatLocation bottomLeft = FlatLocation.minMerged(loc1, loc2);
|
||||||
|
FlatLocation loc = bottomLeft.clone();
|
||||||
|
|
||||||
|
int distX = FlatLocation.flatBlockDistanceX(loc1, loc2);
|
||||||
|
int distY = FlatLocation.flatBlockDistanceY(loc1, loc2);
|
||||||
|
|
||||||
|
frames = new ItemFrame[distX * distY];
|
||||||
|
|
||||||
|
for (int x = 0; x < distX; x++) {
|
||||||
|
for (int y = 0; y < distY; y++) {
|
||||||
|
curFrame = getEmptyFrameAt(loc, loc.getFacing());
|
||||||
|
if (curFrame == null) return false;
|
||||||
|
frames[y * distX + x] = curFrame;
|
||||||
|
loc.add(0, 1);
|
||||||
|
}
|
||||||
|
loc.add(1, 0);
|
||||||
|
loc.setY(bottomLeft.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,7 @@ import fr.zcraft.zlib.tools.reflection.NMSException;
|
|||||||
import fr.zcraft.zlib.tools.text.MessageSender;
|
import fr.zcraft.zlib.tools.text.MessageSender;
|
||||||
import fr.zcraft.zlib.tools.world.FlatLocation;
|
import fr.zcraft.zlib.tools.world.FlatLocation;
|
||||||
import fr.zcraft.zlib.tools.world.WorldUtils;
|
import fr.zcraft.zlib.tools.world.WorldUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Rotation;
|
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -64,6 +61,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.MapMeta;
|
import org.bukkit.inventory.meta.MapMeta;
|
||||||
|
|
||||||
|
|
||||||
abstract public class SplatterMapManager {
|
abstract public class SplatterMapManager {
|
||||||
private SplatterMapManager() {
|
private SplatterMapManager() {
|
||||||
}
|
}
|
||||||
@ -71,7 +69,6 @@ abstract public class SplatterMapManager {
|
|||||||
static public ItemStack makeSplatterMap(PosterMap map) {
|
static public ItemStack makeSplatterMap(PosterMap map) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final ItemStack splatter = new ItemStackBuilder(Material.FILLED_MAP).title(ChatColor.GOLD, map.getName())
|
final ItemStack splatter = new ItemStackBuilder(Material.FILLED_MAP).title(ChatColor.GOLD, map.getName())
|
||||||
.title(ChatColor.DARK_GRAY, " - ").title(ChatColor.GRAY, I.t("Splatter Map"))
|
.title(ChatColor.DARK_GRAY, " - ").title(ChatColor.GRAY, I.t("Splatter Map"))
|
||||||
.title(ChatColor.DARK_GRAY, " - ")
|
.title(ChatColor.DARK_GRAY, " - ")
|
||||||
@ -106,18 +103,17 @@ abstract public class SplatterMapManager {
|
|||||||
/**
|
/**
|
||||||
* To identify image on maps for the auto-splattering to work, we mark the
|
* To identify image on maps for the auto-splattering to work, we mark the
|
||||||
* items using an enchantment maps are not supposed to have (Mending).
|
* items using an enchantment maps are not supposed to have (Mending).
|
||||||
*
|
* <p>
|
||||||
* Then we check if the map is enchanted at all to know if it's a splatter
|
* Then we check if the map is enchanted at all to know if it's a splatter
|
||||||
* map. This ensure compatibility with old splatter maps from 3.x, where
|
* map. This ensure compatibility with old splatter maps from 3.x, where
|
||||||
* zLib's glow effect was used.
|
* zLib's glow effect was used.
|
||||||
*
|
* <p>
|
||||||
* An AttributeModifier (using zLib's attributes system) is not used,
|
* An AttributeModifier (using zLib's attributes system) is not used,
|
||||||
* because Minecraft (or Spigot) removes them from maps in 1.14+, so that
|
* because Minecraft (or Spigot) removes them from maps in 1.14+, so that
|
||||||
* wasn't stable enough (and the glowing effect of enchantments is
|
* wasn't stable enough (and the glowing effect of enchantments is
|
||||||
* prettier).
|
* prettier).
|
||||||
*
|
*
|
||||||
* @param itemStack
|
* @param itemStack The item stack to mark as a splatter map.
|
||||||
* The item stack to mark as a splatter map.
|
|
||||||
* @return The modified item stack. The instance may be different if the
|
* @return The modified item stack. The instance may be different if the
|
||||||
* passed item stack is not a craft item stack; that's why the
|
* passed item stack is not a craft item stack; that's why the
|
||||||
* instance is returned.
|
* instance is returned.
|
||||||
@ -145,8 +141,7 @@ abstract public class SplatterMapManager {
|
|||||||
* Checks if an item have the splatter attribute set (i.e. if the item is
|
* Checks if an item have the splatter attribute set (i.e. if the item is
|
||||||
* enchanted in any way).
|
* enchanted in any way).
|
||||||
*
|
*
|
||||||
* @param itemStack
|
* @param itemStack The item to check.
|
||||||
* The item to check.
|
|
||||||
* @return True if the attribute was detected.
|
* @return True if the attribute was detected.
|
||||||
*/
|
*/
|
||||||
static public boolean hasSplatterAttributes(ItemStack itemStack) {
|
static public boolean hasSplatterAttributes(ItemStack itemStack) {
|
||||||
@ -167,12 +162,11 @@ abstract public class SplatterMapManager {
|
|||||||
/**
|
/**
|
||||||
* Return true if it is a platter map
|
* Return true if it is a platter map
|
||||||
*
|
*
|
||||||
* @param itemStack
|
* @param itemStack The item to check.
|
||||||
* The item to check.
|
|
||||||
* @return True if is a splatter map
|
* @return True if is a splatter map
|
||||||
*/
|
*/
|
||||||
static public boolean isSplatterMap(ItemStack itemStack) {
|
static public boolean isSplatterMap(ItemStack itemStack) {
|
||||||
if(itemStack==null) return false;
|
if (itemStack == null) return false;
|
||||||
return hasSplatterAttributes(itemStack) && MapManager.managesMap(itemStack);
|
return hasSplatterAttributes(itemStack) && MapManager.managesMap(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,10 +187,8 @@ abstract public class SplatterMapManager {
|
|||||||
/**
|
/**
|
||||||
* Place a splatter map
|
* Place a splatter map
|
||||||
*
|
*
|
||||||
* @param startFrame
|
* @param startFrame Frame clicked by the player
|
||||||
* Frame clicked by the player
|
* @param player Player placing map
|
||||||
* @param player
|
|
||||||
* Player placing map
|
|
||||||
* @return true if the map was correctly placed
|
* @return true if the map was correctly placed
|
||||||
*/
|
*/
|
||||||
static public boolean placeSplatterMap(ItemFrame startFrame, Player player, PlayerInteractEntityEvent event) {
|
static public boolean placeSplatterMap(ItemFrame startFrame, Player player, PlayerInteractEntityEvent event) {
|
||||||
@ -231,7 +223,7 @@ abstract public class SplatterMapManager {
|
|||||||
BlockFace bf = WorldUtils.get4thOrientation(player.getLocation());
|
BlockFace bf = WorldUtils.get4thOrientation(player.getLocation());
|
||||||
int id = poster.getMapIdAtReverseZ(i, bf, startFrame.getFacing());
|
int id = poster.getMapIdAtReverseZ(i, bf, startFrame.getFacing());
|
||||||
Rotation rot = Rotation.NONE;
|
Rotation rot = Rotation.NONE;
|
||||||
switch(frame.getFacing()){
|
switch (frame.getFacing()) {
|
||||||
case UP:
|
case UP:
|
||||||
break;
|
break;
|
||||||
case DOWN:
|
case DOWN:
|
||||||
@ -240,8 +232,8 @@ abstract public class SplatterMapManager {
|
|||||||
}
|
}
|
||||||
//Rotation management relative to player rotation the default position is North, when on ceiling we flipped the rotation
|
//Rotation management relative to player rotation the default position is North, when on ceiling we flipped the rotation
|
||||||
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||||
if(i==0){//First map need to be rotate one time CounterClockwise
|
if (i == 0) {//First map need to be rotate one time CounterClockwise
|
||||||
rot=rot.rotateCounterClockwise();
|
rot = rot.rotateCounterClockwise();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bf) {
|
switch (bf) {
|
||||||
@ -269,17 +261,18 @@ abstract public class SplatterMapManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldMap
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MapInitEvent.initMap(id);
|
MapInitEvent.initMap(id);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If it is on a wall NSEW
|
// If it is on a wall NSEW
|
||||||
|
|
||||||
|
|
||||||
FlatLocation startLocation = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
FlatLocation startLocation = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
||||||
FlatLocation endLocation = startLocation.clone().add(poster.getColumnCount(), poster.getRowCount());
|
FlatLocation endLocation = startLocation.clone().add(poster.getColumnCount(), poster.getRowCount());
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
|
PosterWall.expand(startLocation,startFrame.getAttachedFace(), poster.getColumnCount(), poster.getRowCount());
|
||||||
|
|
||||||
wall.loc1 = startLocation;
|
wall.loc1 = startLocation;
|
||||||
wall.loc2 = endLocation;
|
wall.loc2 = endLocation;
|
||||||
@ -298,10 +291,11 @@ abstract public class SplatterMapManager {
|
|||||||
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||||
|
|
||||||
//Force reset of rotation
|
//Force reset of rotation
|
||||||
if(i==0){//First map need to be rotate one time Clockwise
|
if (i == 0) {//First map need to be rotate one time Clockwise
|
||||||
frame.setRotation(Rotation.NONE.rotateCounterClockwise());
|
frame.setRotation(Rotation.NONE.rotateCounterClockwise());
|
||||||
|
} else {
|
||||||
|
frame.setRotation(Rotation.NONE);
|
||||||
}
|
}
|
||||||
else{frame.setRotation(Rotation.NONE);}
|
|
||||||
MapInitEvent.initMap(id);
|
MapInitEvent.initMap(id);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -312,10 +306,8 @@ abstract public class SplatterMapManager {
|
|||||||
/**
|
/**
|
||||||
* Remove splattermap
|
* Remove splattermap
|
||||||
*
|
*
|
||||||
* @param startFrame
|
* @param startFrame Frame clicked by the player
|
||||||
* Frame clicked by the player
|
* @param player The player removing the map
|
||||||
* @param player
|
|
||||||
* The player removing the map
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static public PosterMap removeSplatterMap(ItemFrame startFrame, Player player) {
|
static public PosterMap removeSplatterMap(ItemFrame startFrame, Player player) {
|
||||||
@ -326,13 +318,13 @@ abstract public class SplatterMapManager {
|
|||||||
if (!poster.hasColumnData())
|
if (!poster.hasColumnData())
|
||||||
return null;
|
return null;
|
||||||
FlatLocation loc = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
FlatLocation loc = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
||||||
ItemFrame[] matchingFrames=null;
|
ItemFrame[] matchingFrames = null;
|
||||||
|
|
||||||
switch(startFrame.getFacing()){
|
switch (startFrame.getFacing()) {
|
||||||
case UP:
|
case UP:
|
||||||
case DOWN:
|
case DOWN:
|
||||||
matchingFrames = PosterOnASurface.getMatchingMapFrames(poster, loc,
|
matchingFrames = PosterOnASurface.getMatchingMapFrames(poster, loc,
|
||||||
MapManager.getMapIdFromItemStack(startFrame.getItem()),WorldUtils.get4thOrientation(player.getLocation()));//startFrame.getFacing());
|
MapManager.getMapIdFromItemStack(startFrame.getItem()), WorldUtils.get4thOrientation(player.getLocation()));//startFrame.getFacing());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORTH:
|
case NORTH:
|
||||||
|
Loading…
Reference in New Issue
Block a user