Skip to content

Commit

Permalink
Allow players to choose from configurable pronouns (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodlyay committed Mar 29, 2024
1 parent eea7969 commit 02b48ec
Show file tree
Hide file tree
Showing 20 changed files with 329 additions and 34 deletions.
4 changes: 2 additions & 2 deletions MCGalaxy/Commands/CPE/CmdModel.cs
Expand Up @@ -57,9 +57,9 @@ public class CmdModel : EntityPropertyCmd
who.UpdateModel(model);

if (p != who) {
Chat.MessageFrom(who, "λNICK &Shad their model changed to a &c" + model);
Chat.MessageFrom(who, "λNICK &Shad " + who.pronouns.Object + " model changed to &c" + model);
} else {
who.Message("Changed your own model to a &c" + model);
who.Message("Changed your own model to &c" + model);
}

if (!model.CaselessEq("humanoid")) {
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/CPE/CmdModelScale.cs
Expand Up @@ -49,7 +49,7 @@ public class CmdModelScale : EntityPropertyCmd
who.UpdateModel(who.Model);

if (p != who) {
Chat.MessageFrom(who, "λNICK &Shad their " + axis + " scale changed");
Chat.MessageFrom(who, "λNICK &Shad "+who.pronouns.Object+" " + axis + " scale changed");
} else {
who.Message("Changed your own {0} scale", axis);
}
Expand Down
45 changes: 45 additions & 0 deletions MCGalaxy/Commands/Chat/CmdPronouns.cs
@@ -0,0 +1,45 @@
/*
Copyright 2015 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
https://opensource.org/license/ecl-2-0/
https://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/

namespace MCGalaxy.Commands.Chatting {
public class CmdPronouns : Command2 {
public override string name { get { return "Pronouns"; } }
public override string type { get { return CommandTypes.Chat; } }
public override void Use(Player p, string message, CommandData data) {
if (message.Length == 0) { Help(p); return; }

Pronouns pro = Pronouns.FindMatch(p, message);
if (pro == null) { HelpList(p); return; }

p.pronouns = pro;
p.Message("Your pronouns were changed to: &H{0}", pro.Name);
pro.SaveFor(p);
}

public override void Help(Player p) {
p.Message("&T/Pronouns [pronouns]");
p.Message("&HChanges the pronouns used to refer to you in server messages.");
HelpList(p);
p.Message("&HYour pronouns are currently: &T{0}", p.pronouns.Name);
}
static void HelpList(Player p) {
p.Message("&HThe following pronouns are currently available:");
p.Message("&H &T{0}", Pronouns.GetNames().Join("&H, &T"));
}
}
}
7 changes: 4 additions & 3 deletions MCGalaxy/Commands/Chat/CmdSend.cs
Expand Up @@ -47,9 +47,10 @@ public sealed class CmdSend : Command2

int pending = Database.CountRows("Inbox" + name, "WHERE PlayerFrom=@0", p.name);
if (pending >= 200) {
p.Message("{0} &calready has 200+ messages from you currently in their inbox. " +
"Try again later after they have deleted some of their inbox messages",
p.FormatNick(name));
Pronouns pronouns = Pronouns.GetFor(name);
p.Message("{0} &calready has 200+ messages from you currently in {1} inbox. " +
"Try again later after {2} {3} deleted some of {4} inbox messages",
p.FormatNick(name), pronouns.Object, pronouns.Subject, pronouns.PresentPerfectVerb, pronouns.Object);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/Moderation/CmdMoveAll.cs
Expand Up @@ -32,7 +32,7 @@ public sealed class CmdMoveAll : Command2 {
if (pl.Rank < data.Rank)
PlayerActions.ChangeMap(pl, level.name);
else
p.Message("You cannot move {0} &Sbecause they are of equal or higher rank", p.FormatNick(pl));
p.Message("You cannot move {0} &Sbecause {1} {2} of equal or higher rank", p.FormatNick(pl), pl.pronouns.Subject, pl.pronouns.PresentVerb);
}
}

Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/Moderation/CmdReport.cs
Expand Up @@ -159,7 +159,7 @@ public sealed class CmdReport : Command2 {

string opsMsg = "λNICK &Sreported " + nick + "&S. Reason: " + reason;
Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
string allMsg = "Use &T/Report check " + target + " &Sto see all of their reports";
string allMsg = "Use &T/Report check " + target + " &Sto see all of " + Pronouns.GetFor(target).Object + " reports";
Chat.MessageFrom(ChatScope.Perms, p, allMsg, checkPerms, null, true);
}

Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/other/CmdKill.cs
Expand Up @@ -31,7 +31,7 @@ public sealed class CmdKill : Command2 {
Player target = PlayerInfo.FindMatches(p, args[0]);

if (target == null) {
if (p != null) p.HandleDeath(Block.Stone, "@p &Skilled themselves in their confusion");
if (p != null) p.HandleDeath(Block.Stone, "@p &Skilled "+ p.pronouns.Reflexive +" in " + p.pronouns.Object + " confusion");
return;
}
if (!CheckRank(p, data, target, "kill", false)) return;
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/CorePlugin/ConnectHandler.cs
Expand Up @@ -25,6 +25,7 @@ internal static class ConnectHandler {
if (p.CanUse("ReachDistance")) LoadReach(p);

p.Ignores.Load(p);
p.pronouns = Pronouns.GetFor(p.name);
}

static void LoadReach(Player p) {
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/CorePlugin/ModActionHandler.cs
Expand Up @@ -146,7 +146,7 @@ internal static class ModActionHandler {

string ip = PlayerDB.FindIP(e.Target);
if (ip != null && Server.bannedIP.Contains(ip)) {
e.Actor.Message("NOTE: Their IP is still banned.");
e.Actor.Message("NOTE: {0} IP is still banned.", Pronouns.GetFor(e.Target).Object);
}
}

Expand Down
7 changes: 3 additions & 4 deletions MCGalaxy/MCGalaxy_.csproj
Expand Up @@ -147,6 +147,7 @@
<Compile Include="Commands\building\CmdUndo.cs" />
<Compile Include="Commands\building\CmdWrite.cs" />
<Compile Include="Commands\building\DrawCmd.cs" />
<Compile Include="Commands\Chat\CmdPronouns.cs" />
<Compile Include="Commands\Chat\Cmd8Ball.cs" />
<Compile Include="Commands\Chat\CmdAdminChat.cs" />
<Compile Include="Commands\Chat\CmdAfk.cs" />
Expand Down Expand Up @@ -640,6 +641,7 @@
<Compile Include="Player\PlayerInfo.cs" />
<Compile Include="Player\PlayerOperations.cs" />
<Compile Include="Player\PlayerPhysics.cs" />
<Compile Include="Player\Pronouns.cs" />
<Compile Include="Player\SpamChecker.cs" />
<Compile Include="Database\Undo\UndoFormat.cs" />
<Compile Include="Network\Player.Networking.cs" />
Expand Down Expand Up @@ -717,10 +719,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\Moderation\Review" />
<Folder Include="Modules\Warps" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Modules/Awards/CmdAward.cs
Expand Up @@ -54,7 +54,7 @@ public sealed class CmdAward : Command2
}
} else {
if (PlayerAwards.Take(plName, award)) {
Chat.MessageGlobal("{0} &Shad their &b{1} &Saward removed", displayName, award);
Chat.MessageGlobal(string.Format("{0} &Shad {1} &b{2} &Saward removed", displayName, Pronouns.GetFor(plName).Object, award));
PlayerAwards.Save();
} else if (plName.CaselessEq(p.name)) {
p.Message("You did not have that award to begin with.");
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Modules/Games/TNTWars/TWGame.Physics.cs
Expand Up @@ -214,7 +214,7 @@ public partial class TWGame : RoundsGame
else if (data.KillStreak >= cfg.StreakTwoAmount && data.KillStreak < cfg.StreakThreeAmount && data.LastKillStreakAnnounced != cfg.StreakTwoAmount)
{
killer.Message("TNT Wars: Kill streak of " + data.KillStreak + " (Multiplier of " + cfg.StreakTwoMultiplier + " and a bigger explosion!)");
Map.Message(killer.ColoredName + " &Shas a kill streak of " + data.KillStreak + " and now has a bigger explosion for their TNT!");
Map.Message(killer.ColoredName + " &Shas a kill streak of " + data.KillStreak + " and now has a bigger explosion for " + killer.pronouns.Object + " TNT!");
data.ScoreMultiplier = cfg.StreakTwoMultiplier;
data.LastKillStreakAnnounced = cfg.StreakTwoAmount;
}
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Modules/Games/ZombieSurvival/Commands/CmdHuman.cs
Expand Up @@ -51,7 +51,7 @@ sealed class CmdHuman : Command2

data.PledgeSurvive = true;
ZSGame.Instance.Map
.Message(p.ColoredName + " &Spledges that they will not succumb to the infection!");
.Message(p.ColoredName + " &Spledges that " + p.pronouns.Subject + " will not succumb to the infection!");
}

public override void Help(Player p) {
Expand Down
30 changes: 21 additions & 9 deletions MCGalaxy/Modules/Games/ZombieSurvival/ZSConfig.cs
Expand Up @@ -122,13 +122,25 @@ public sealed class ZSConfig : RoundsGameConfig
}
}


static string[] defMessages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
"{0} licked {1}'s brain ", "{0} danubed {1}", "{0} made {1} meet their maker", "{0} tripped {1}",
"{0} made some zombie babies with {1}", "{0} made {1} see the dark side", "{0} tweeted {1}",
"{0} made {1} open source", "{0} infected {1}", "{0} iDotted {1}", "{1} got nommed on",
"{0} transplanted {1}'s living brain" };

public const string InfectZombiePlaceholder = "<zombie>";
public const string InfectHumanPlaceholder = "<human>";
const string InfectZombieObjectPlaceholder = "<zobject>";
const string InfectHumanObjectPlaceholder = "<hobject>";

static string[] defMessages = new string[] { "<zombie> WIKIWOO'D <human>", "<zombie> stuck <zobject> teeth into <human>",
"<zombie> licked <human>'s brain ", "<zombie> danubed <human>", "<zombie> made <human> meet <hobject> maker", "<zombie> tripped <human>",
"<zombie> made some zombie babies with <human>", "<zombie> made <human> see the dark side", "<zombie> tweeted <human>",
"<zombie> made <human> open source", "<zombie> infected <human>", "<zombie> iDotted <human>", "<human> got nommed on",
"<zombie> transplanted <human>'s living brain" };

public static string FormatInfectMessage(string infectMsg, Player pKiller, Player pAlive) {
return infectMsg
.Replace(InfectZombiePlaceholder, "&c" + pKiller.DisplayName + "&S")
.Replace(InfectHumanPlaceholder, pAlive.ColoredName + "&S")
.Replace(InfectZombieObjectPlaceholder, pKiller.pronouns.Object)
.Replace(InfectHumanObjectPlaceholder, pAlive.pronouns.Object);
}

public static List<string> LoadInfectMessages() {
List<string> msgs = new List<string>();
try {
Expand Down Expand Up @@ -165,8 +177,8 @@ public sealed class ZSConfig : RoundsGameConfig
for (int i = 0; i < messages.Count; i++)
{
messages[i] = messages[i]
.Replace("{0}", "<zombie>")
.Replace("{1}", "<human>");
.Replace("{0}", InfectZombiePlaceholder)
.Replace("{1}", InfectHumanPlaceholder);
}
return messages;
}
Expand Down
5 changes: 2 additions & 3 deletions MCGalaxy/Modules/Games/ZombieSurvival/ZSGame.Round.cs
Expand Up @@ -183,7 +183,7 @@ public partial class ZSGame : RoundsGame
ZSData data = Get(p);
if (!data.PledgeSurvive) return;
data.PledgeSurvive = false;
Map.Message("&c" + p.DisplayName + " &Sbroke their pledge of not being infected.");
Map.Message("&c" + p.DisplayName + " &Sbroke "+p.pronouns.Object+" pledge of not being infected.");

if (killer == null) {
p.Message("As this was an automatic infection, you have not lost any &3" + Server.Config.Currency);
Expand Down Expand Up @@ -220,8 +220,7 @@ public partial class ZSGame : RoundsGame
text = infectMessages[random.Next(infectMessages.Count)];
}

Map.Message(text.Replace("<zombie>", "&c" + pKiller.DisplayName + "&S")
.Replace("<human>", pAlive.ColoredName + "&S"));
Map.Message(ZSConfig.FormatInfectMessage(text, pKiller, pAlive));
}

internal static void RespawnPlayer(Player p) {
Expand Down
11 changes: 7 additions & 4 deletions MCGalaxy/Modules/Games/ZombieSurvival/ZSItems.cs
Expand Up @@ -94,9 +94,11 @@ sealed class InfectMessageItem : SimpleItem
public override void OnPurchase(Player p, string msg) {
if (msg.Length == 0) { OnStoreCommand(p); return; }

if (!msg.Contains("<human>") && !msg.Contains("<zombie>")) {
p.Message("You need to include a \"<zombie>\" (placeholder for zombie player) " +
"and/or a \"<human>\" (placeholder for human player) in the infect message."); return;
if (!msg.Contains(ZSConfig.InfectZombiePlaceholder) && !msg.Contains(ZSConfig.InfectHumanPlaceholder)) {
p.Message("You need to include a \"{0}\" (placeholder for zombie player) " +
"and/or a \"{1}\" (placeholder for human player) in the infect message.",
ZSConfig.InfectZombiePlaceholder, ZSConfig.InfectHumanPlaceholder);
return;
}

if (!CheckPrice(p)) return;
Expand All @@ -111,7 +113,8 @@ sealed class InfectMessageItem : SimpleItem

protected internal override void OnStoreCommand(Player p) {
base.OnStoreCommand(p);
p.Message("&HInfect messages must include either \"<zombie>\" or \"<human>\" (placeholders for zombie and/or human player) in them");
p.Message("&HInfect messages must include either \"{0}\" or \"{1}\" (placeholders for zombie and/or human player) in them",
ZSConfig.InfectZombiePlaceholder, ZSConfig.InfectHumanPlaceholder);
}
}

Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Player/Player.Fields.cs
Expand Up @@ -63,6 +63,7 @@ public partial class Player : IDisposable {
/// <remarks> Use 'truename' for displaying/logging, use 'name' for storing data </remarks>
public string name;
public string DisplayName;
public Pronouns pronouns = Pronouns.Default;
public int warn;
public byte id;
public IPAddress IP;
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Player/PlayerOperations.cs
Expand Up @@ -158,7 +158,7 @@ public static class PlayerOperations

if (actor == who) {
message = message.Replace("λACTOR", "λNICK")
.Replace("λTARGET", "their");
.Replace("λTARGET", actor.pronouns.Object);
Chat.MessageFrom(who, message);
} else if (!global) {
message = message.Replace("λACTOR", actor.ColoredName)
Expand Down

0 comments on commit 02b48ec

Please sign in to comment.