mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-06-20 11:44:43 +02:00
added map on ground/ceilling, fixed renderer bug
This commit is contained in:
parent
f9c9049aa6
commit
f79674169e
|
@ -75,34 +75,37 @@ public class NewCommand extends IoMCommand
|
|||
default: throwInvalidArgument(I.t("Invalid Stretching mode.")); break;
|
||||
}
|
||||
}
|
||||
|
||||
ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Rendering..."));
|
||||
ImageRendererExecutor.render(url, scaling, player.getUniqueId(), width, height, new WorkerCallback<ImageMap>()
|
||||
{
|
||||
@Override
|
||||
public void finished(ImageMap result)
|
||||
{
|
||||
ActionBar.removeMessage(player);
|
||||
MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Rendering finished!"));
|
||||
try {
|
||||
|
||||
if (result.give(player) && (result instanceof PosterMap && !((PosterMap) result).hasColumnData()))
|
||||
{
|
||||
info(I.t("The rendered map was too big to fit in your inventory."));
|
||||
info(I.t("Use '/maptool getremaining' to get the remaining maps."));
|
||||
|
||||
ActionBar.sendPermanentMessage(player, ChatColor.DARK_GREEN + I.t("Rendering..."));
|
||||
ImageRendererExecutor.render(url, scaling, player.getUniqueId(), width, height, new WorkerCallback<ImageMap>() {
|
||||
@Override
|
||||
public void finished(ImageMap result) {
|
||||
ActionBar.removeMessage(player);
|
||||
MessageSender.sendActionBarMessage(player, ChatColor.DARK_GREEN + I.t("Rendering finished!"));
|
||||
|
||||
if (result.give(player) && (result instanceof PosterMap && !((PosterMap) result).hasColumnData())) {
|
||||
info(I.t("The rendered map was too big to fit in your inventory."));
|
||||
info(I.t("Use '/maptool getremaining' to get the remaining maps."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errored(Throwable exception)
|
||||
{
|
||||
player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage()));
|
||||
@Override
|
||||
public void errored(Throwable exception) {
|
||||
player.sendMessage(I.t("{ce}Map rendering failed: {0}", exception.getMessage()));
|
||||
|
||||
PluginLogger.warning("Rendering from {0} failed: {1}: {2}",
|
||||
player.getName(),
|
||||
exception.getClass().getCanonicalName(),
|
||||
exception.getMessage());
|
||||
}
|
||||
});
|
||||
PluginLogger.warning("Rendering from {0} failed: {1}: {2}",
|
||||
player.getName(),
|
||||
exception.getClass().getCanonicalName(),
|
||||
exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
//Added to fix bug with rendering displaying after error
|
||||
finally {
|
||||
ActionBar.removeMessage(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,6 +35,7 @@ public class ImageIOExecutor extends Worker
|
|||
{
|
||||
static public void loadImage(final File file, final Renderer mapRenderer)
|
||||
{
|
||||
|
||||
submitQuery(new WorkerRunnable<Void>()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.UUID;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
||||
@WorkerAttributes (name = "Image Renderer", queriesMainThread = true)
|
||||
public class ImageRendererExecutor extends Worker
|
||||
{
|
||||
|
|
|
@ -94,4 +94,4 @@ public class ImageUtils {
|
|||
graphics.dispose();
|
||||
return newImage;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.map.MapView;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MapInitEvent implements Listener
|
||||
{
|
||||
static public void init()
|
||||
|
@ -113,8 +112,10 @@ public class MapInitEvent implements Listener
|
|||
|
||||
static public void initMap(MapView map)
|
||||
{
|
||||
if(map == null) return;
|
||||
if(Renderer.isHandled(map)) return;
|
||||
if(map == null) {
|
||||
return;}
|
||||
if(Renderer.isHandled(map)) {
|
||||
return;}
|
||||
|
||||
File imageFile = ImageOnMap.getPlugin().getImageFile(map.getId());
|
||||
if(imageFile.isFile())
|
||||
|
|
|
@ -93,7 +93,6 @@ public class Renderer extends MapRenderer
|
|||
{
|
||||
//Render only once to avoid overloading the server
|
||||
if (image == null) return;
|
||||
|
||||
canvas.drawImage(0, 0, image);
|
||||
image = null;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ abstract public class MapManager
|
|||
static public ImageMap createMap(PosterImage image, UUID playerUUID, int[] mapsIDs) throws MapManagerException
|
||||
{
|
||||
ImageMap newMap;
|
||||
|
||||
if(image.getImagesCount() == 1)
|
||||
{
|
||||
newMap = new SingleMap(playerUUID, mapsIDs[0]);
|
||||
|
|
|
@ -263,6 +263,7 @@ public class PlayerMapStore implements ConfigurationSerializable
|
|||
try
|
||||
{
|
||||
getToolConfig().save(mapsFile);
|
||||
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ package fr.moribus.imageonmap.map;
|
|||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -132,26 +130,24 @@ public class PosterMap extends ImageMap {
|
|||
return mapsIDs[y * columnCount + x];
|
||||
}
|
||||
|
||||
|
||||
public int getMapIdAtReverseY(int index) {
|
||||
int x = index % (columnCount);
|
||||
int y = index / (columnCount);
|
||||
return getMapIdAt(x, rowCount - y - 1);
|
||||
}
|
||||
|
||||
|
||||
public int getMapIdAtReverseZ(int index, BlockFace orientation, BlockFace bf) {
|
||||
int x = 0, y = 0;
|
||||
switch (bf) {
|
||||
case UP:
|
||||
|
||||
x = index % (columnCount);
|
||||
y = index / (columnCount);
|
||||
|
||||
break;
|
||||
case DOWN:
|
||||
|
||||
x = (columnCount - 1) - index % (columnCount);
|
||||
y = index / (columnCount);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,19 +229,20 @@ public class MapItemManager implements Listener
|
|||
if (frame.getItem().getType() != Material.AIR) return;
|
||||
if (!MapManager.managesMap(mapItem)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (SplatterMapManager.hasSplatterAttributes(mapItem))
|
||||
{
|
||||
if (!SplatterMapManager.placeSplatterMap(frame, player))
|
||||
return;
|
||||
if (!SplatterMapManager.placeSplatterMap(frame, player,event)){
|
||||
event.setCancelled(true); //In case of an error allow to cancel map placement
|
||||
return;}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the item has a display name, bot not one from an anvil by the player, we remove it
|
||||
// si it is not displayed on hover on the wall.
|
||||
// If it is not displayed on hover on the wall.
|
||||
if (mapItem.hasItemMeta() && mapItem.getItemMeta().hasDisplayName() && mapItem.getItemMeta().getDisplayName().startsWith("§r"))
|
||||
{
|
||||
|
||||
final ItemStack frameItem = mapItem.clone();
|
||||
final ItemMeta meta = frameItem.getItemMeta();
|
||||
|
||||
|
@ -251,9 +252,13 @@ public class MapItemManager implements Listener
|
|||
frame.setItem(frameItem);
|
||||
}
|
||||
|
||||
else frame.setItem(mapItem);
|
||||
else{
|
||||
frame.setItem(mapItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ItemUtils.consumeItem(player);
|
||||
}
|
||||
|
||||
|
@ -264,7 +269,7 @@ public class MapItemManager implements Listener
|
|||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
PosterMap poster = SplatterMapManager.removeSplatterMap(frame);
|
||||
PosterMap poster = SplatterMapManager.removeSplatterMap(frame,player);
|
||||
if (poster != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -39,33 +39,29 @@ public class PosterOnASurface {
|
|||
|
||||
public boolean isValid(Player p) {
|
||||
ItemFrame curFrame;
|
||||
PluginLogger.info("Test");
|
||||
|
||||
|
||||
FlatLocation l = loc1.clone();
|
||||
|
||||
BlockFace bf = WorldUtils.get4thOrientation(p.getLocation());
|
||||
|
||||
l.subtract(loc2);
|
||||
;
|
||||
|
||||
|
||||
int distX = Math.abs(l.getBlockX());
|
||||
int distZ = Math.abs(l.getBlockZ());
|
||||
PluginLogger.info("dist X " + distX);
|
||||
PluginLogger.info("dist Z " + distZ);
|
||||
|
||||
frames = new ItemFrame[distX * distZ];
|
||||
l = loc1.clone();
|
||||
for (int x = 0; x < distX; x++) {
|
||||
for (int z = 0; z < distZ; z++) {
|
||||
PluginLogger.info("X=" + l.getBlockX() + " Z= " + l.getBlockZ());
|
||||
|
||||
PluginLogger.info(l.toString() + " " + l.getFacing().name());
|
||||
curFrame = getEmptyFrameAt(l, l.getFacing());
|
||||
|
||||
if (curFrame == null)
|
||||
return false;
|
||||
PluginLogger.info("x " + x + " | z " + z);
|
||||
|
||||
frames[z * distX + x] = curFrame;
|
||||
PluginLogger.info("ind frame " + z * distX + x);
|
||||
|
||||
switch (bf) {
|
||||
case NORTH:
|
||||
|
@ -74,12 +70,12 @@ public class PosterOnASurface {
|
|||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
l.addH(-1, 0, bf);
|
||||
l.addH(1, 0, bf);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (bf) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
|
@ -87,13 +83,10 @@ public class PosterOnASurface {
|
|||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
l.addH(distX, -1, bf);
|
||||
l.addH(-distZ, 1, bf);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,28 +94,76 @@ public class PosterOnASurface {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of map Frames associated with a specific map
|
||||
* */
|
||||
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, int mapId, BlockFace bf) {
|
||||
int mapIndex = map.getIndex(mapId);
|
||||
int x = map.getColumnAt(mapIndex), y = map.getRowAt(mapIndex);
|
||||
|
||||
return getMatchingMapFrames(map, location.clone().addH(-x, y,bf),bf);
|
||||
PluginLogger.info("x = "+x+" y = "+y);
|
||||
return getMatchingMapFrames(map, location.clone().addH(x, y,bf),bf);
|
||||
}
|
||||
|
||||
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, BlockFace bf) {
|
||||
ItemFrame[] frames = new ItemFrame[map.getMapCount()];
|
||||
FlatLocation loc = location.clone();
|
||||
|
||||
for (int y = 0; y < map.getRowCount(); ++y) {
|
||||
for (int x = 0; x < map.getColumnCount(); ++x) {
|
||||
PluginLogger.info("loc = "+location+ " bf = "+bf);
|
||||
|
||||
int X=0;
|
||||
int Y=0;
|
||||
switch (bf){
|
||||
case EAST:
|
||||
case WEST:
|
||||
/* X=map.getRowCount();
|
||||
Y=map.getColumnCount();
|
||||
break;*/
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
|
||||
Y=map.getRowCount();
|
||||
X=map.getColumnCount();
|
||||
break;
|
||||
|
||||
}
|
||||
PluginLogger.info("max: X: "+X+" Y:"+Y);
|
||||
for (int y = 0; y < Y; ++y) {
|
||||
for (int x = 0; x < X; ++x) {
|
||||
PluginLogger.info("x: "+x+" y:"+y);
|
||||
int mapIndex = map.getIndexAt(x, y);
|
||||
PluginLogger.info("map index "+mapIndex);
|
||||
//PluginLogger.info("loc= "+loc);
|
||||
ItemFrame frame = getMapFrameAt(loc, map);
|
||||
PluginLogger.info("frame= "+frame.getLocation());
|
||||
if (frame != null)
|
||||
frames[mapIndex] = frame;
|
||||
loc.add(1, 0);
|
||||
switch (bf){
|
||||
case EAST:
|
||||
case WEST:
|
||||
loc.addH( 0,1,bf);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
loc.addH( 1,0,bf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
loc.setX(location.getX());
|
||||
loc.setZ(location.getZ());
|
||||
loc.addH(0, -1,bf);
|
||||
|
||||
switch (bf){
|
||||
case EAST:
|
||||
case WEST:
|
||||
loc.addH( -1,-map.getRowCount(),bf);//test
|
||||
//loc.addH( -map.getRowCount(),-1,bf);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
loc.addH(-map.getColumnCount(), -1,bf);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return frames;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package fr.moribus.imageonmap.ui;
|
||||
|
||||
import fr.moribus.imageonmap.map.PosterMap;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
import fr.zcraft.zlib.tools.world.FlatLocation;
|
||||
import fr.zcraft.zlib.tools.world.WorldUtils;
|
||||
import org.bukkit.Location;
|
||||
|
@ -45,9 +44,7 @@ public class PosterWall
|
|||
|
||||
int distX = FlatLocation.flatBlockDistanceX(loc1, loc2);
|
||||
int distY = FlatLocation.flatBlockDistanceY(loc1, loc2);
|
||||
|
||||
PluginLogger.info("dist X "+distX);
|
||||
PluginLogger.info("dist Y "+distY);
|
||||
|
||||
frames = new ItemFrame[distX * distY];
|
||||
|
||||
for(int x = 0; x < distX; x++)
|
||||
|
@ -68,9 +65,7 @@ public class PosterWall
|
|||
|
||||
public void expand()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static public ItemFrame[] getMatchingMapFrames(PosterMap map, FlatLocation location, int mapId)
|
||||
|
|
|
@ -34,7 +34,6 @@ import fr.zcraft.zlib.tools.reflection.NMSException;
|
|||
import fr.zcraft.zlib.tools.text.MessageSender;
|
||||
import fr.zcraft.zlib.tools.world.FlatLocation;
|
||||
import fr.zcraft.zlib.tools.world.WorldUtils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
|
@ -42,6 +41,7 @@ import org.bukkit.Rotation;
|
|||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
|
@ -51,6 +51,12 @@ abstract public class SplatterMapManager {
|
|||
}
|
||||
|
||||
static public ItemStack makeSplatterMap(PosterMap map) {
|
||||
String s="";
|
||||
for(Byte b:I.t("Splatter Map").getBytes()){
|
||||
s+=b+" ";
|
||||
}
|
||||
PluginLogger.info(""+s);
|
||||
|
||||
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, " - ")
|
||||
|
@ -145,10 +151,19 @@ abstract public class SplatterMapManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if it is a platter map
|
||||
*
|
||||
* @param itemStack
|
||||
* The item to check.
|
||||
* @return True if is a splatter map
|
||||
*/
|
||||
static public boolean isSplatterMap(ItemStack itemStack) {
|
||||
return hasSplatterAttributes(itemStack) && MapManager.managesMap(itemStack);
|
||||
}
|
||||
|
||||
|
||||
//TODO doc a faire
|
||||
static public boolean hasSplatterMap(Player player, PosterMap map) {
|
||||
Inventory playerInventory = player.getInventory();
|
||||
|
||||
|
@ -161,90 +176,93 @@ abstract public class SplatterMapManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
static public boolean placeSplatterMap(ItemFrame startFrame, Player player) {
|
||||
/**
|
||||
* Place a splatter map
|
||||
*
|
||||
* @param startFrame
|
||||
* Frame clicked by the player
|
||||
* @param player
|
||||
* Player placing map
|
||||
* @return true if the map was correctly placed
|
||||
*/
|
||||
static public boolean placeSplatterMap(ItemFrame startFrame, Player player, PlayerInteractEntityEvent event) {
|
||||
ImageMap map = MapManager.getMap(player.getInventory().getItemInMainHand());
|
||||
|
||||
if (!(map instanceof PosterMap))
|
||||
return false;
|
||||
PosterMap poster = (PosterMap) map;
|
||||
PosterWall wall = new PosterWall();
|
||||
// NEW
|
||||
if (startFrame.getFacing().equals(BlockFace.DOWN) || startFrame.getFacing().equals(BlockFace.UP)) {
|
||||
PluginLogger.info("UP or DOWN ");
|
||||
|
||||
if (startFrame.getFacing().equals(BlockFace.DOWN) || startFrame.getFacing().equals(BlockFace.UP)) {
|
||||
// If it is on floor or ceiling
|
||||
PosterOnASurface surface = new PosterOnASurface();
|
||||
FlatLocation startLocation = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
||||
FlatLocation endLocation = startLocation.clone().addH(poster.getColumnCount(), poster.getRowCount(),
|
||||
WorldUtils.get4thOrientation(player.getLocation()));
|
||||
PluginLogger.info("Before loc asign ");
|
||||
|
||||
surface.loc1 = startLocation;
|
||||
surface.loc2 = endLocation;
|
||||
PluginLogger.info("After loc asign ");
|
||||
|
||||
// todo impletation
|
||||
if (!surface.isValid(player)) {
|
||||
MessageSender.sendActionBarMessage(player,
|
||||
I.t("{ce}There is not enough space to place this map ({0} × {1}).", poster.getColumnCount(),
|
||||
poster.getRowCount()));
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (ItemFrame frame : surface.frames) {
|
||||
PluginLogger.info("Test " + frame.getName());
|
||||
BlockFace bf = WorldUtils.get4thOrientation(player.getLocation());
|
||||
int id = poster.getMapIdAtReverseZ(i, bf, startFrame.getFacing());
|
||||
|
||||
Rotation rot = frame.getRotation();
|
||||
|
||||
// NESW
|
||||
//PluginLogger.info("ordinal " + rot.ordinal() );
|
||||
/*switch(bf){
|
||||
case NORTH:
|
||||
frame.setRotation(Rotation.NONE);
|
||||
break;
|
||||
case EAST:
|
||||
frame.setRotation(Rotation.CLOCKWISE);
|
||||
break;
|
||||
case SOUTH:
|
||||
frame.setRotation(Rotation.FLIPPED);
|
||||
break;
|
||||
case WEST:
|
||||
frame.setRotation(Rotation.COUNTER_CLOCKWISE);
|
||||
break;
|
||||
}*/
|
||||
PluginLogger.info("bf ordinal "+ bf.ordinal());
|
||||
while (rot.ordinal() != 2*bf.ordinal()) {
|
||||
rot = rot.rotateClockwise();
|
||||
//PluginLogger.info("Rotation ordinal " + rot.ordinal() + " bf ordinal " + bf.ordinal());
|
||||
frame.setRotation(rot);
|
||||
Rotation rot = Rotation.NONE;
|
||||
switch(frame.getFacing()){
|
||||
case UP:
|
||||
break;
|
||||
case DOWN:
|
||||
rot = Rotation.FLIPPED;
|
||||
break;
|
||||
}
|
||||
switch (bf) {
|
||||
case UP:
|
||||
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
case DOWN:
|
||||
rot=rot.rotateClockwise().rotateClockwise();
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
}
|
||||
|
||||
rot = frame.getRotation();
|
||||
|
||||
|
||||
//PluginLogger.info("ordinal " + rot.ordinal() );
|
||||
//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.setRotation(Rotation.CLOCKWISE);
|
||||
switch(bf) {
|
||||
case NORTH:
|
||||
if(frame.getFacing()==BlockFace.DOWN){
|
||||
rot = rot.rotateClockwise();
|
||||
rot = rot.rotateClockwise();
|
||||
}
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
case EAST:
|
||||
rot = rot.rotateClockwise();
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
case SOUTH:
|
||||
if(frame.getFacing()==BlockFace.UP){
|
||||
rot = rot.rotateClockwise();
|
||||
rot = rot.rotateClockwise();
|
||||
}
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
case WEST:
|
||||
rot = rot.rotateCounterClockwise();
|
||||
frame.setRotation(rot);
|
||||
break;
|
||||
}
|
||||
|
||||
MapInitEvent.initMap(id);
|
||||
++i;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
// If it is on a wall NSEW
|
||||
FlatLocation startLocation = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
||||
FlatLocation endLocation = startLocation.clone().add(poster.getColumnCount(), poster.getRowCount());
|
||||
|
||||
wall.loc1 = startLocation;
|
||||
wall.loc2 = endLocation;
|
||||
PluginLogger.info("startLocation " + startLocation + " | endLocation " + endLocation);
|
||||
|
||||
if (!wall.isValid()) {
|
||||
MessageSender.sendActionBarMessage(player,
|
||||
I.t("{ce}There is not enough space to place this map ({0} × {1}).", poster.getColumnCount(),
|
||||
|
@ -254,8 +272,15 @@ abstract public class SplatterMapManager {
|
|||
|
||||
int i = 0;
|
||||
for (ItemFrame frame : wall.frames) {
|
||||
|
||||
int id = poster.getMapIdAtReverseY(i);
|
||||
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
|
||||
//Force reset of rotation
|
||||
if(i==0){//First map need to be rotate one time Clockwise
|
||||
frame.setRotation(Rotation.NONE.rotateCounterClockwise());
|
||||
}
|
||||
else{frame.setRotation(Rotation.NONE);}
|
||||
MapInitEvent.initMap(id);
|
||||
++i;
|
||||
}
|
||||
|
@ -263,7 +288,16 @@ abstract public class SplatterMapManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
static public PosterMap removeSplatterMap(ItemFrame startFrame) {
|
||||
/**
|
||||
* Remove splattermap
|
||||
*
|
||||
* @param startFrame
|
||||
* Frame clicked by the player
|
||||
* @param player
|
||||
* The player removing the map
|
||||
* @return
|
||||
*/
|
||||
static public PosterMap removeSplatterMap(ItemFrame startFrame, Player player) {
|
||||
final ImageMap map = MapManager.getMap(startFrame.getItem());
|
||||
if (!(map instanceof PosterMap))
|
||||
return null;
|
||||
|
@ -272,21 +306,21 @@ abstract public class SplatterMapManager {
|
|||
return null;
|
||||
FlatLocation loc = new FlatLocation(startFrame.getLocation(), startFrame.getFacing());
|
||||
ItemFrame[] matchingFrames=null;
|
||||
|
||||
switch(startFrame.getFacing()){
|
||||
case UP:
|
||||
case DOWN:
|
||||
matchingFrames = PosterOnASurface.getMatchingMapFrames(poster, loc,
|
||||
MapManager.getMapIdFromItemStack(startFrame.getItem()),startFrame.getFacing());
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case EAST:
|
||||
case WEST:
|
||||
matchingFrames = PosterWall.getMatchingMapFrames(poster, loc,
|
||||
case UP:
|
||||
case DOWN:
|
||||
matchingFrames = PosterOnASurface.getMatchingMapFrames(poster, loc,
|
||||
MapManager.getMapIdFromItemStack(startFrame.getItem()),WorldUtils.get4thOrientation(player.getLocation()));//startFrame.getFacing());
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case EAST:
|
||||
case WEST:
|
||||
matchingFrames = PosterWall.getMatchingMapFrames(poster, loc,
|
||||
MapManager.getMapIdFromItemStack(startFrame.getItem()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (matchingFrames == null)
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue
Block a user