Skip to content
Permalink
Browse files

Added /Software

Can now change the colors and capitalization of how the server software shows up on the server list.
  • Loading branch information...
123DMWM committed Jan 10, 2019
1 parent 17a9349 commit 0ce88d4cd7a8630cf5c72a82be8859083bea0c6a
Showing with 48 additions and 3 deletions.
  1. +43 −0 fCraft/Commands/MaintenanceCommands.cs
  2. +3 −2 fCraft/Network/Heartbeat.cs
  3. +2 −1 fCraft/System/Server.cs
@@ -27,6 +27,7 @@ static class MaintenanceCommands {
CommandManager.RegisterCommand(CdSave);
CommandManager.RegisterCommand(CdCheckUpdate);
CommandManager.RegisterCommand( CdAutoRankCheck );
CommandManager.RegisterCommand( CdSoftware );
}
#region DumpStats

@@ -1406,5 +1407,47 @@ static void SaveHandler(Player player, CommandReader cmd)
}

#endregion
#region Software
static readonly CommandDescriptor CdSoftware = new CommandDescriptor
{
Name = "Software",
Aliases = new[] { "SetSoftware", "SW" },
Category = CommandCategory.New | CommandCategory.Maintenance,
Permissions = new[] { Permission.EditPlayerDB },
IsConsoleSafe = true,
Help = "Set the colors of the server software name on the server list. &NOnly console may change the actual software name. &NUse reset/default/normal to change it back to &cP&4R&6O&eC&aR&2A&bF&3T",
Usage = "/Software <new software name>",
Handler = SoftwareHandler
};

static void SoftwareHandler(Player player, CommandReader cmd) {


string newSW = cmd.NextAll().Replace('%', '&');
string oldSW = Server.Software;
if (String.IsNullOrEmpty(newSW)) {
player.Message("The current software name is \"&F{0}&S\"", Server.Software);
return;
}
if (newSW.CaselessEquals("reset") || newSW.CaselessEquals("default") || newSW.CaselessEquals("normal")) {
newSW = "&cP&4R&6O&eC&aR&2A&bF&3T";
}

if (newSW == oldSW) {
player.Message("Server software is already set to \"&F{1}&S\"", newSW);
return;
} else if (!Color.StripColors(newSW, true).CaselessEquals(Server.Software) && player != Player.Console) {
player.Message("&COnly console may change the actual name of the software.");
return;
}
if (!cmd.IsConfirmed) {
player.Confirm(cmd, "This will change how the server software shows up on the server list from \"&F{0}&S\" to \"&F{1}&S\"", oldSW, newSW);
return;
}

Server.Software = newSW;
player.Message("Server software was changed from \"&F{0}&S\" to \"&F{1}&S\"", oldSW, newSW);
}
#endregion
}
}
@@ -298,14 +298,15 @@ public sealed class HeartbeatData {
internal Uri CreateUri() {
UriBuilder ub = new UriBuilder(HeartbeatUri);
StringBuilder sb = new StringBuilder();
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software=ProCraft",
sb.AppendFormat("public={0}&max={1}&users={2}&port={3}&version={4}&salt={5}&name={6}&software={7}",
IsPublic,
MaxPlayers,
PlayerCount,
Port,
ProtocolVersion,
Uri.EscapeDataString(Salt),
Uri.EscapeDataString(ServerName));
Uri.EscapeDataString(ServerName),
Server.Software.Replace("&", "%26"));
foreach (var pair in CustomData) {
sb.AppendFormat("&{0}={1}",
Uri.EscapeDataString(pair.Key),
@@ -43,7 +43,8 @@ public static partial class Server {
/// <summary> Default terrain file for each world.</summary>
public static string DefaultTerrain { get; set; }


/// <summary> Software name that shows up on the server list on classicube.</summary>
public static string Software = "&cP&4R&6O&eC&aR&2A&bF&3T";

internal static int MaxUploadSpeed, // set by Config.ApplyConfig
BlockUpdateThrottling; // used when there are no players in a world

0 comments on commit 0ce88d4

Please sign in to comment.
You can’t perform that action at this time.