Skip to content

Commit

Permalink
Merge pull request #26 from bozoweed/master
Browse files Browse the repository at this point in the history
update to 8.0.0
  • Loading branch information
Spoffy authored Feb 8, 2019
2 parents e3d6b92 + 98ec3ac commit 473dfaa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
23 changes: 12 additions & 11 deletions DiscordLink/DiscordEcoCommands.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System;
using System.Runtime.Remoting.Messaging;
using System.Threading.Tasks;
using Eco.Gameplay.Players;
using Eco.Gameplay.Stats;
using Eco.Gameplay.Systems.Chat;
using Eco.Shared.Localization;
using Eco.Shared.Utils;

namespace Eco.Plugins.DiscordLink
Expand All @@ -15,7 +16,7 @@ public class DiscordEcoCommands : IChatCommandHandler
{
private static void Log(string message)
{
Eco.Shared.Utils.Log.Write("DiscordLink: " + message);
Eco.Shared.Utils.Log.Write(new LocString("DiscordLink: " + message));
}

private delegate void EcoCommandFunction(User user, params string[] args);
Expand All @@ -28,7 +29,7 @@ private static void CallWithErrorHandling<TRet>(EcoCommandFunction toCall, User
}
catch (Exception e)
{
ChatManager.ServerMessageToPlayerAlreadyLocalized("Error occurred while attempting to run that command. Error message: " + e, user, false);
ChatManager.ServerMessageToPlayer(new LocString("Error occurred while attempting to run that command. Error message: " + e), user, false);
Log("Error occurred while attempting to run that command. Error message: " + e);
Log(e.StackTrace);
}
Expand All @@ -39,7 +40,7 @@ public static void VerifyDiscord(User user)
{
CallWithErrorHandling<object>((lUser, args) =>
{
ChatManager.ServerMessageToPlayerAlreadyLocalized("Discord Plugin is loaded.", lUser);
ChatManager.ServerMessageToPlayer(new LocString("Discord Plugin is loaded."), lUser);
},
user);
}
Expand All @@ -54,7 +55,7 @@ public static void DiscordGuilds(User user)
var joinedNames = String.Join(", ", plugin.GuildNames);
ChatManager.ServerMessageToPlayerAlreadyLocalized("Servers: " + joinedNames, user, false);
ChatManager.ServerMessageToPlayer(new LocString("Servers: " + joinedNames), user, false);
},
user);

Expand All @@ -74,7 +75,7 @@ public static void DiscordSendToChannel(User user, string guild, string channel,
plugin.SendMessageAsUser(message, user, channelName, guildName).ContinueWith(result =>
{
ChatManager.ServerMessageToPlayerAlreadyLocalized(result.Result, user);
ChatManager.ServerMessageToPlayer(new LocString(result.Result), user);
});
},
user, guild, channel, outerMessage);
Expand All @@ -92,7 +93,7 @@ public static void DiscordMessage(User user, string message)
plugin.SendMessageAsUser(message, user, defaultChannel).ContinueWith(result =>
{
ChatManager.ServerMessageToPlayerAlreadyLocalized(result.Result, user);
ChatManager.ServerMessageToPlayer(new LocString(result.Result), user);
});
},
user, message);
Expand All @@ -113,11 +114,11 @@ public static void DiscordChannels(User user, string guildName)
//Can happen in DefaultGuild is not configured.
if (guild == null)
{
ChatManager.ServerMessageToPlayerAlreadyLocalized("Unable to find that guild, perhaps the name was misspelled?", user);
ChatManager.ServerMessageToPlayer(new LocString("Unable to find that guild, perhaps the name was misspelled?"), user);
}
var joinedGames = String.Join(", ", guild.TextChannelNames());
ChatManager.ServerMessageToAllAlreadyLocalized("Channels: " + joinedGames, false);
ChatManager.ServerMessageToAll( new LocString("Channels: " + joinedGames), false);
},
user);

Expand All @@ -132,9 +133,9 @@ public static void DiscordDefaultChannel(User user, string guildName, string cha
if (plugin == null) return;
plugin.SetDefaultChannelForPlayer(user.Name, guildName, channelName);
ChatManager.ServerMessageToPlayerAlreadyLocalized("Default channel set to " + channelName, user);
ChatManager.ServerMessageToPlayer(new LocString("Default channel set to " + channelName), user);
},
user);
}
}
}
}
14 changes: 8 additions & 6 deletions DiscordLink/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
using Eco.Shared.Utils;
using Eco.Shared.Localization;
using Eco.Shared.Utils;

namespace Eco.Plugins.DiscordLink
{
public class Logger
{
public static void Debug(string message)
{
Log.Write("DISCORDLINK DEBUG:" + message + "\n");
Log.Write(new LocString("DISCORDLINK DEBUG:" + message + "\n"));
}

public static void DebugVerbose(string message)
{
if (DiscordLink.Obj?.DiscordPluginConfig.Debug == true)
{
Log.Write("DISCORDLINK DEBUG:" + message + "\n");
Log.Write(new LocString("DISCORDLINK DEBUG:" + message + "\n"));
}
}

public static void Info(string message)
{
Log.Write("DISCORDLINK: " + message + "\n");

Log.Write(new LocString("DISCORDLINK: " + message + "\n"));
}

public static void Error(string message)
{
Log.Write("DISCORDLINK ERROR: " + message + "\n");
Log.Write(new LocString("DISCORDLINK ERROR: " + message + "\n"));
}
}
}
}

0 comments on commit 473dfaa

Please sign in to comment.