Skip to content
Permalink
Browse files

Quick fix for /signadd on case-sensitive filesystems, remove hardcodi…

…ng of 'WorldGreeting' directory in various places
  • Loading branch information...
UnknownShadow200 committed Jul 1, 2017
1 parent 026ae2e commit 44c6aa71c45968586b746754f071195789d09d1e
@@ -3030,13 +3030,14 @@ static void WorldClearHandler(Player player, CommandReader cmd)
}

static void SetGreeting(Player player, World world, string value) {
if (!Directory.Exists("./WorldGreeting/"))
Directory.CreateDirectory("./WorldGreeting/");
if (!Directory.Exists(Paths.WGreetingsPath))
Directory.CreateDirectory(Paths.WGreetingsPath);
string greetingsPath = Path.Combine(Paths.WGreetingsPath, world.Name + ".txt");

if (String.IsNullOrEmpty(value)) {
if (world.Greeting == null) {
if (File.Exists("./WorldGreeting/" + world.Name + ".txt")) {
world.Greeting = File.ReadAllText("./WorldGreeting/" + world.Name + ".txt");
if (File.Exists(greetingsPath)) {
world.Greeting = File.ReadAllText(greetingsPath);
if (world.Greeting.Length == 0)
player.Message("No greeting message is set for world {0}", world.ClassyName);
else
@@ -3048,13 +3049,13 @@ static void WorldClearHandler(Player player, CommandReader cmd)
}
} else if (value.CaselessEquals("remove")) {
player.Message("Greeting message removed for world {0}", world.ClassyName);
if (File.Exists("./WorldGreeting/" + world.Name + ".txt"))
File.Delete("./WorldGreeting/" + world.Name + ".txt");
if (File.Exists(greetingsPath))
File.Delete(greetingsPath);
world.Greeting = null;
} else {
world.Greeting = value;
player.Message("Greeting message for world {0}&S set to: {1}", world.ClassyName, world.Greeting);
File.WriteAllText("./WorldGreeting/" + world.Name + ".txt", world.Greeting);
File.WriteAllText(greetingsPath, world.Greeting);
world.Greeting = null;
}
}
@@ -1160,33 +1160,27 @@ bool LoginSequence()
}

void SendJoinMessage(World oldWorld, World newWorld) {
if (oldWorld == newWorld)
{
if (oldWorld == newWorld) {
Message("&SRejoined world {0}", newWorld.ClassyName);
return;
}
else
{
Message("&SJoined world {0}", newWorld.ClassyName);
string greeting = newWorld.Greeting;
if (greeting != null)
{
greeting = Chat.ReplaceTextKeywords(this, greeting);
Message(greeting);
}
else
{
FileInfo GreetingInfo = new FileInfo("./WorldGreeting/" + World.Name + ".txt");
if (GreetingInfo.Exists)
{
string[] Greeting = File.ReadAllLines("./WorldGreeting/" + World.Name + ".txt");
string GreetingMessage = "";
foreach (string line in Greeting)
{
GreetingMessage += line + "&N";
}
Message(Chat.ReplaceTextKeywords(this, GreetingMessage));
}

Message("&SJoined world {0}", newWorld.ClassyName);
string greeting = newWorld.Greeting;
if (greeting != null) {
greeting = Chat.ReplaceTextKeywords(this, greeting);
Message(greeting);
return;
}

string greetingsPath = Path.Combine(Paths.WGreetingsPath, World.Name + ".txt");
if (File.Exists(greetingsPath)) {
string[] lines = File.ReadAllLines(greetingsPath);
greeting = "";
foreach (string line in lines) {
greeting += line + "&N";
}
Message(Chat.ReplaceTextKeywords(this, greeting));
}
}

@@ -79,18 +79,24 @@ public static class Paths {
public static readonly string WorkingPathDefault;

public const string FontsDirectory = "fonts";

public static string FontsPath
{
public static string FontsPath {
get { return Path.Combine(WorkingPath, FontsDirectory); }
}

public const string WClearDirectory = "WClearBackups";

public static string WClearPath
{
public static string WClearPath {
get { return Path.Combine(WorkingPath, WClearDirectory); }
}

public const string SignsDirectory = "Signs";
public static string SignsPath {
get { return Path.Combine(WorkingPath, SignsDirectory); }
}

public const string WGreetingDirectory = "WorldGreeting";
public static string WGreetingsPath {
get { return Path.Combine(WorkingPath, WGreetingDirectory); }
}

/// <summary> Path to save maps to (default: .\maps)
/// Can be overridden at startup via command-line argument "--mappath=",
@@ -34,7 +34,7 @@ public static partial class SpecialZone {
if (TextCooldown(p)) return;

if (zone.Sign == null) {
string path = "./signs/" + p.World.Name + "/" + zone.Name + ".txt";
string path = "./Signs/" + p.World.Name + "/" + zone.Name + ".txt";
if (File.Exists(path)) {
p.SignLines = File.ReadAllLines(path);
p.Message(String.Join("&N", p.SignLines));
@@ -55,7 +55,7 @@ public static partial class SpecialZone {
if (p.IsCommandBlockRunning || TextCooldown(p)) return;

if (zone.Sign == null) {
string path = "./signs/" + p.World.Name + "/" + zone.Name + ".txt";
string path = "./Signs/" + p.World.Name + "/" + zone.Name + ".txt";
if (File.Exists(path)) {
p.SignLines = File.ReadAllLines(path);

@@ -54,7 +54,7 @@ public static partial class SpecialZone {
}

static string GetSignMessage(Player p, Zone zone) {
string path = "./signs/" + p.World.Name + "/" + zone.Name + ".txt";
string path = "./Signs/" + p.World.Name + "/" + zone.Name + ".txt";
if (!File.Exists(path)) return null;

string[] lines = File.ReadAllLines(path);

0 comments on commit 44c6aa7

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