From e4e1b666d241b7477696928a2eb2973af983c9b7 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sun, 10 Feb 2019 21:57:45 +0100 Subject: [PATCH] Fix bad position on /f map, fixes #8 --- .../factions/engine/EngineMoveChunk.java | 32 +++++++++---------- .../massivecraft/factions/util/AsciiMap.java | 18 ++++++----- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/com/massivecraft/factions/engine/EngineMoveChunk.java b/src/com/massivecraft/factions/engine/EngineMoveChunk.java index e411e73e..2469a144 100644 --- a/src/com/massivecraft/factions/engine/EngineMoveChunk.java +++ b/src/com/massivecraft/factions/engine/EngineMoveChunk.java @@ -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); diff --git a/src/com/massivecraft/factions/util/AsciiMap.java b/src/com/massivecraft/factions/util/AsciiMap.java index bb68141c..bde62f99 100644 --- a/src/com/massivecraft/factions/util/AsciiMap.java +++ b/src/com/massivecraft/factions/util/AsciiMap.java @@ -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);