Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy Updated Libraries And Command #8

Open
wants to merge 4 commits into
base: legacy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,4 @@ GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/.vs/Uconomy/v15/Server/sqlite3
/.vs
28 changes: 17 additions & 11 deletions CommandBalance.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using fr34kyn01535.Uconomy.Utils;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
Expand All @@ -23,6 +24,7 @@ public class CommandBalance : IRocketCommand

public void Execute(IRocketPlayer caller, params string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
if (command.Length == 1)
{
if (caller.HasPermission("balance.check"))
Expand All @@ -31,32 +33,36 @@ public void Execute(IRocketPlayer caller, params string[] command)
if (target != null)
{
var balance = Uconomy.Instance.Database.GetBalance(target.Id);
UnturnedChat.Say(caller,

ChatManagerUtils.SendMessageToPlayer(player,
Uconomy.Instance.Translate("command_balance_show_otherPlayer",
Uconomy.Instance.Configuration.Instance.MoneySymbol, balance,
Uconomy.Instance.Configuration.Instance.MoneyName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
Uconomy.Instance.Configuration.Instance.MoneySymbol, balance,
Uconomy.Instance.Configuration.Instance.MoneyName));

}
else
{
UnturnedChat.Say(caller, Uconomy.Instance.Translate("command_balance_error_player_not_found"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(player, Uconomy.Instance.Translate("command_balance_error_player_not_found"));
}
}
else
{
UnturnedChat.Say(caller, Uconomy.Instance.Translate("command_balance_check_noPermissions"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(player, Uconomy.Instance.Translate("command_balance_check_noPermissions"));
}
}
else
{
var balance = Uconomy.Instance.Database.GetBalance(caller.Id);
UnturnedChat.Say(caller,



ChatManagerUtils.SendMessageToPlayer(player, Uconomy.Instance.Translations.Instance.Translate("command_balance_show", Uconomy.Instance.Configuration.Instance.MoneySymbol, balance,
Uconomy.Instance.Configuration.Instance.MoneyName));

ChatManagerUtils.SendMessageToPlayer(player,
Uconomy.Instance.Translations.Instance.Translate("command_balance_show",
Uconomy.Instance.Configuration.Instance.MoneySymbol, balance,
Uconomy.Instance.Configuration.Instance.MoneyName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
Uconomy.Instance.Configuration.Instance.MoneyName));
}
}
}
Expand Down
48 changes: 23 additions & 25 deletions CommandPay.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using fr34kyn01535.Uconomy.Utils;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Commands;
using Rocket.Unturned.Player;
using SDG.Unturned;
using UnityEngine;

namespace fr34kyn01535.Uconomy
Expand All @@ -25,8 +27,10 @@ public void Execute(IRocketPlayer caller, params string[] command)
{
if (command.Length != 2)
{
UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_invalid"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));

ChatManagerUtils.SendMessageToPlayer(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_invalid"));


return;
}

Expand All @@ -38,67 +42,61 @@ public void Execute(IRocketPlayer caller, params string[] command)
{
if (caller.Id == otherPlayer)
{
UnturnedChat.Say(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_pay_self"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_pay_self"));
return;
}

if (!decimal.TryParse(command[1], out var amount) || amount <= 0)
{
UnturnedChat.Say(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_invalid_amount"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_invalid_amount"));
return;
}

if (caller is ConsolePlayer)
{
Uconomy.Instance.Database.IncreaseBalance(otherPlayer, amount);
if (otherPlayerOnline != null)
UnturnedChat.Say(otherPlayerOnline,
Uconomy.Instance.Translations.Instance.Translate("command_pay_console", amount,
Uconomy.Instance.Configuration.Instance.MoneyName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_console", amount,
Uconomy.Instance.Configuration.Instance.MoneyName));

}
else
{
var myBalance = Uconomy.Instance.Database.GetBalance(caller.Id);
if (myBalance - amount <= 0)
{
UnturnedChat.Say(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_cant_afford"),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_cant_afford"));
}
else
{
Uconomy.Instance.Database.IncreaseBalance(caller.Id, -amount);
if (otherPlayerOnline != null)
UnturnedChat.Say(caller,
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_private",
otherPlayerOnline.CharacterName, amount,
Uconomy.Instance.Configuration.Instance.MoneyName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
Uconomy.Instance.Configuration.Instance.MoneyName));
else
UnturnedChat.Say(caller,
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_private", otherPlayer,
amount, Uconomy.Instance.Configuration.Instance.MoneyName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
amount, Uconomy.Instance.Configuration.Instance.MoneyName));

Uconomy.Instance.Database.IncreaseBalance(otherPlayer, amount);
if (otherPlayerOnline != null)
UnturnedChat.Say(otherPlayerOnline.CSteamID,
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_other_private", amount,
Uconomy.Instance.Configuration.Instance.MoneyName, caller.DisplayName),
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
Uconomy.Instance.Configuration.Instance.MoneyName, caller.DisplayName));

Uconomy.Instance.HasBeenPayed((UnturnedPlayer) caller, otherPlayer, amount);
}
}
}
else
{
UnturnedChat.Say(caller,
ChatManagerUtils.SendMessageToPlayer(caller,
Uconomy.Instance.Translations.Instance.Translate("command_pay_error_player_not_found"));
}
}
Expand Down
19 changes: 13 additions & 6 deletions Uconomy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>fr34kyn01535.Uconomy</RootNamespace>
<AssemblyName>Uconomy</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
Expand Down Expand Up @@ -40,14 +40,14 @@
<HintPath>lib\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>lib\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BouncyCastle.Crypto">
<HintPath>Libraries\BouncyCastle.Crypto.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="com.rlabrecque.steamworks.net, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\com.rlabrecque.steamworks.net.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf">
<HintPath>Libraries\Google.Protobuf.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -130,6 +130,7 @@
<Compile Include="UconomyConfiguration.cs" />
<Compile Include="Uconomy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\ChatManagerUtils.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Libraries\BouncyCastle.Crypto.dll">
Expand Down Expand Up @@ -159,14 +160,20 @@
<Content Include="Libraries\System.Transactions.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="lib\Assembly-CSharp-firstpass.dll" />
<Content Include="lib\Assembly-CSharp.dll" />
<Content Include="lib\com.rlabrecque.steamworks.net.dll" />
<Content Include="lib\Rocket.API.dll" />
<Content Include="lib\Rocket.Core.dll" />
<Content Include="lib\Rocket.Unturned.dll" />
<Content Include="lib\UnityEngine.CoreModule.dll" />
<Content Include="lib\UnityEngine.dll" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="lib\com.rlabrecque.steamworks.net.dll" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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: 2 additions & 0 deletions UconomyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace fr34kyn01535.Uconomy
{
public class UconomyConfiguration : IRocketPluginConfiguration
{
public string Image { get; set; }
public string DatabaseAddress;
public string DatabaseUsername;
public string DatabasePassword;
Expand All @@ -19,6 +20,7 @@ public class UconomyConfiguration : IRocketPluginConfiguration

public void LoadDefaults()
{
Image = "Url Here";
DatabaseAddress = "127.0.0.1";
DatabaseUsername = "unturned";
DatabasePassword = "password";
Expand Down
46 changes: 46 additions & 0 deletions Utils/ChatManagerUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace fr34kyn01535.Uconomy.Utils
{
public static class ChatManagerUtils
{
public static void SendMessage(string message)
{
ChatManager.serverSendMessage(message.Replace('(', '<').Replace(')', '>'), Color.white, null, null, EChatMode.GLOBAL, Uconomy.Instance.Configuration.Instance.Image, true);
}


public static void SendMessageToPlayer(IRocketPlayer caller, string message)
{

if (caller is ConsolePlayer)
{
UnturnedChat.Say(caller, message,
UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green));
}
else
{
UnturnedPlayer player = caller as UnturnedPlayer;
ChatManager.serverSendMessage(message.Replace('(', '<').Replace(')', '>'), Color.white, null, player.SteamPlayer(), EChatMode.GLOBAL, Uconomy.Instance.Configuration.Instance.Image, true);
}


}



public static void SendMessageToPlayer(UnturnedPlayer player, string message)
{
ChatManager.serverSendMessage(message.Replace('(', '<').Replace(')', '>'), Color.white, null, player.SteamPlayer(), EChatMode.GLOBAL, Uconomy.Instance.Configuration.Instance.Image, true);
}
}
}
Binary file removed lib/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file modified lib/Assembly-CSharp.dll
Binary file not shown.
Binary file modified lib/Rocket.API.dll
Binary file not shown.
Binary file modified lib/Rocket.Core.dll
Binary file not shown.
Binary file modified lib/Rocket.Unturned.dll
Binary file not shown.
Binary file modified lib/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file modified lib/UnityEngine.dll
Binary file not shown.
Binary file added lib/com.rlabrecque.steamworks.net.dll
Binary file not shown.