From 50930d7583e8c258abcb98a52083d906e1ca22bf Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sat, 10 Feb 2018 16:20:13 -0800 Subject: [PATCH] Bigger /f map Add /f mapheight command to allow players to set their mapheight. Increase default map height and width to be in line with larger values servers want --- .../java/com/massivecraft/factions/Conf.java | 5 ++- .../com/massivecraft/factions/FPlayer.java | 3 ++ .../factions/cmd/CmdMapHeight.java | 39 +++++++++++++++++++ .../massivecraft/factions/cmd/FCmdRoot.java | 2 + .../factions/struct/Permission.java | 1 + .../factions/zcore/persist/MemoryBoard.java | 3 +- .../factions/zcore/persist/MemoryFPlayer.java | 10 +++++ .../massivecraft/factions/zcore/util/TL.java | 3 ++ src/main/resources/plugin.yml | 5 ++- 9 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index eb9d6b33..88cdf31c 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -364,8 +364,9 @@ public class Conf { public static Backend backEnd = Backend.JSON; - public static transient int mapHeight = 8; - public static transient int mapWidth = 39; + // Taller and wider for "bigger f map" + public static transient int mapHeight = 17; + public static transient int mapWidth = 49; public static transient char[] mapKeyChrs = "\\/#$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz?".toCharArray(); static { diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 165bb952..c6f3afbe 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -244,6 +244,9 @@ public interface FPlayer extends EconomyParticipator { public void sendFancyMessage(List message); + public int getMapHeight(); + + public void setMapHeight(int height); public boolean isOnlineAndVisibleTo(Player me); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java new file mode 100644 index 00000000..43ba2bed --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMapHeight.java @@ -0,0 +1,39 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdMapHeight extends FCommand { + + public CmdMapHeight() { + super(); + + this.aliases.add("mapheight"); + this.aliases.add("mh"); + + this.requiredArgs.add("height"); + + this.permission = Permission.MAPHEIGHT.node; + + this.senderMustBePlayer = true; + } + + @Override + public void perform() { + int height = argAsInt(0, -1); + + if (height == -1) { + fme.sendMessage(TL.COMMAND_MAPHEIGHT_DESCRIPTION.toString()); + return; + } + + fme.setMapHeight(height); + fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(height)); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_MAPHEIGHT_DESCRIPTION; + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index b8dfdfa9..464f68c3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -74,6 +74,7 @@ public class FCmdRoot extends FCommand { public CmdPromote cmdPromote = new CmdPromote(); public CmdDemote cmdDemote = new CmdDemote(); public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole(); + public CmdMapHeight cmdMapHeight = new CmdMapHeight(); public FCmdRoot() { super(); @@ -162,6 +163,7 @@ public class FCmdRoot extends FCommand { this.addSubCommand(this.cmdPromote); this.addSubCommand(this.cmdDemote); this.addSubCommand(this.cmdSetDefaultRole); + this.addSubCommand(this.cmdMapHeight); if (P.p.isHookedPlayervaults()) { P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands."); this.addSubCommand(new CmdSetMaxVaults()); diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 8642de5e..37fe1d69 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -38,6 +38,7 @@ public enum Permission { LIST("list"), LOCK("lock"), MAP("map"), + MAPHEIGHT("mapheight"), MOD("mod"), MOD_ANY("mod.any"), MODIFY_POWER("modifypower"), diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java index ccb7876e..1fab3c4d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java @@ -259,7 +259,8 @@ public abstract class MemoryBoard extends Board { ret.add(new FancyMessage(asciiCompass.get(2))); int halfWidth = Conf.mapWidth / 2; - int halfHeight = Conf.mapHeight / 2; + // Use player's value for height + int halfHeight = fplayer.getMapHeight() / 2; FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); int width = halfWidth * 2 + 1; int height = halfHeight * 2 + 1; diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 37e2c2aa..ad5d356b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -59,6 +59,7 @@ public abstract class MemoryFPlayer implements FPlayer { protected boolean isAdminBypassing = false; protected int kills, deaths; protected boolean willAutoLeave = true; + protected int mapHeight; protected transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked? protected transient boolean mapAutoUpdating; @@ -243,6 +244,7 @@ public abstract class MemoryFPlayer implements FPlayer { this.showScoreboard = P.p.getConfig().getBoolean("scoreboard.default-enabled", false); this.kills = 0; this.deaths = 0; + this.mapHeight = Conf.mapHeight; if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.getInstance().isValidFactionId(Conf.newPlayerStartingFactionID)) { this.factionId = Conf.newPlayerStartingFactionID; @@ -269,6 +271,7 @@ public abstract class MemoryFPlayer implements FPlayer { this.showScoreboard = P.p.getConfig().getBoolean("scoreboard.default-enabled", true); this.kills = other.kills; this.deaths = other.deaths; + this.mapHeight = Conf.mapHeight; } public void resetFactionData(boolean doSpoutUpdate) { @@ -913,6 +916,13 @@ public abstract class MemoryFPlayer implements FPlayer { } } + public int getMapHeight() { + return this.mapHeight; + } + + public void setMapHeight(int height) { + this.mapHeight = height; + } public String getNameAndTitle(FPlayer fplayer) { return this.getColorTo(fplayer) + this.getNameAndTitle(); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 05cc9178..076764f1 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -295,6 +295,9 @@ public enum TL { COMMAND_MAP_UPDATE_DISABLED("Map auto update DISABLED."), COMMAND_MAP_DESCRIPTION("Show the territory map, and set optional auto update"), + COMMAND_MAPHEIGHT_DESCRIPTION("Update the lines that /f map sends"), + COMMAND_MAPHEIGHT_SET("Set /f map lines to %1$d"), + COMMAND_MOD_CANDIDATES("Players you can promote: "), COMMAND_MOD_CLICKTOPROMOTE("Click to promote "), COMMAND_MOD_NOTMEMBER("%1$s is not a member in your faction."), diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 554248bc..55821901 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -99,6 +99,7 @@ permissions: factions.top: true factions.togglealliancechat: true factions.vault: true + factions.mapheight: true factions.admin: description: hand over your admin rights factions.admin.any: @@ -273,4 +274,6 @@ permissions: factions.vault: description: Access faction vault. factions.setmaxvault: - description: Set a faction's max vaults. \ No newline at end of file + description: Set a faction's max vaults. + factions.mapheight: + description: Set your /f map height. \ No newline at end of file