Fix bad position on /f map, fixes #8

This commit is contained in:
Magnus Ulf 2019-02-10 21:57:45 +01:00
parent 2a4777c4b1
commit e4e1b666d2
2 changed files with 26 additions and 24 deletions

View File

@ -43,36 +43,36 @@ public class EngineMoveChunk extends Engine
// ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player);
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
PS psFrom = PS.valueOf(event.getFrom());
PS psTo = PS.valueOf(event.getTo());
// ... send info onwards and try auto-claiming.
sendChunkInfo(mplayer, player, chunkFrom, chunkTo);
tryAutoClaim(mplayer, chunkTo);
sendChunkInfo(mplayer, player, psFrom, psTo);
tryAutoClaim(mplayer, psTo);
}
// -------------------------------------------- //
// MOVE CHUNK: SEND CHUNK INFO
// -------------------------------------------- //
private static void sendChunkInfo(MPlayer mplayer, Player player, PS chunkFrom, PS chunkTo)
private static void sendChunkInfo(MPlayer mplayer, Player player, PS psFrom, PS psTo)
{
sendAutoMapUpdate(mplayer, player);
sendFactionTerritoryInfo(mplayer, player, chunkFrom, chunkTo);
sendTerritoryAccessMessage(mplayer, chunkFrom, chunkTo);
sendAutoMapUpdate(mplayer, psTo);
sendFactionTerritoryInfo(mplayer, player, psFrom, psTo);
sendTerritoryAccessMessage(mplayer, psFrom, psTo);
}
private static void sendAutoMapUpdate(MPlayer mplayer, Player player)
private static void sendAutoMapUpdate(MPlayer mplayer, PS ps)
{
if (!mplayer.isMapAutoUpdating()) return;
AsciiMap map = new AsciiMap(mplayer, player, false);
AsciiMap map = new AsciiMap(mplayer, ps, false);
mplayer.message(map.render());
}
private static void sendFactionTerritoryInfo(MPlayer mplayer, Player player, PS chunkFrom, PS chunkTo)
private static void sendFactionTerritoryInfo(MPlayer mplayer, Player player, PS psFrom, PS psTo)
{
Faction factionFrom = BoardColl.get().getFactionAt(chunkFrom);
Faction factionTo = BoardColl.get().getFactionAt(chunkTo);
Faction factionFrom = BoardColl.get().getFactionAt(psFrom);
Faction factionTo = BoardColl.get().getFactionAt(psTo);
if (factionFrom == factionTo) return;
@ -105,11 +105,11 @@ public class EngineMoveChunk extends Engine
return string;
}
private static void sendTerritoryAccessMessage(MPlayer mplayer, PS chunkFrom, PS chunkTo)
private static void sendTerritoryAccessMessage(MPlayer mplayer, PS psFrom, PS psTo)
{
// Get TerritoryAccess for from & to chunks
TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(chunkFrom);
TerritoryAccess accessTo = BoardColl.get().getTerritoryAccessAt(chunkTo);
TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom);
TerritoryAccess accessTo = BoardColl.get().getTerritoryAccessAt(psTo);
// See if the status has changed
AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer);

View File

@ -9,7 +9,6 @@ import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@ -18,9 +17,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import static com.massivecraft.massivecore.mson.Mson.EMPTY;
import static com.massivecraft.massivecore.mson.Mson.SPACE;
import static com.massivecraft.massivecore.mson.Mson.mson;
import static com.massivecraft.massivecore.mson.Mson.*;
public class AsciiMap
{
@ -81,13 +78,18 @@ public class AsciiMap
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
@Deprecated
public AsciiMap(RelationParticipator relationParticipator, Player player, boolean extraHeight)
{
this(relationParticipator, PS.valueOf(player), extraHeight);
}
public AsciiMap(RelationParticipator relationParticipator, PS ps, boolean extraHeight)
{
this.relationParticipator = relationParticipator;
Location location = player.getLocation();
this.angle = location.getYaw();
this.center = PS.valueOf(location).getChunk(true);
this.angle = ps.getYaw();
this.center = ps.getChunk(true);
this.height = extraHeight ? HEIGHT_EXTRA : HEIGHT;
this.heightHalf = extraHeight ? HEIGHT_EXTRA_HALF : HEIGHT_HALF;
this.topLeft = this.center.plusChunkCoords(-WIDTH_HALF, -this.heightHalf);