Skip to content

Commit

Permalink
Update 3.0.2
Browse files Browse the repository at this point in the history
Fixed some bugs
  • Loading branch information
Teyhota6 authored Feb 21, 2019
1 parent 5c2b52a commit df148f4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 39 deletions.
12 changes: 2 additions & 10 deletions Commands/Command_Vote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
string url = Plugin.VoteRewardsPlugin.Instance.Configuration.Instance.VotePageURL;

try
{
SteamFriends.ActivateGameOverlayToWebPage(url);
}
catch
{
UnturnedChat.Say(caller, Plugin.VoteRewardsPlugin.Instance.Translate("vote_page_msg", Provider.serverName));
Process.Start(url);
}

player.Player.sendBrowserRequest(Plugin.VoteRewardsPlugin.Instance.Translate("vote_page_msg", Provider.serverName), url);
}
}
}
1 change: 1 addition & 0 deletions Plugin/VoteRewardsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal Service(string name, string apiKey)
public void LoadDefaults()
{
Instance = this;
DisableAutoUpdate = "true";
VotePageURL = "https://unturned-servers.net/my_server_vote_page";
AlertOnJoin = true;
GlobalAnnouncement = true;
Expand Down
30 changes: 15 additions & 15 deletions Plugin/VoteRewardsPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Xml;
using Rocket.Core.Plugins;
using Rocket.Unturned.Player;
using Rocket.Unturned;
using Rocket.Unturned;
using Rocket.API.Collections;
using Logger = Rocket.Core.Logging.Logger;

namespace Teyhota.VoteRewards.Plugin
namespace Teyhota.VoteRewards.Plugin
{
public class VoteRewardsPlugin : RocketPlugin<VoteRewardsConfig>
public class VoteRewardsPlugin : RocketPlugin<VoteRewardsConfig>
{
public static string PluginName = "VoteRewards";
public static string PluginVersion = "3.0.1";
public static string BuildVersion = "40";
public static string PluginVersion = "3.0.2";
public static string BuildVersion = "41";
public static string RocketVersion = "4.9.3.0";
public static string UnturnedVersion = "3.23.8.0";
public static string UnturnedVersion = "3.28.0.0";
public static string ThisDirectory = System.IO.Directory.GetCurrentDirectory() + @"\Plugins\VoteRewards\";

public static bool CustomKits = false;
Expand Down Expand Up @@ -181,22 +181,22 @@ protected override void Unload()
Write("Visit Plugins.4Unturned.tk for more!", ConsoleColor.Green);
}

public override TranslationList DefaultTranslations
{
get
public override TranslationList DefaultTranslations
{
get
{
return new TranslationList()
{
{"vote_page_msg", "Vote for {0} and receive a random reward!"},
{"vote_page_msg", "Vote for us and receive a random reward!"},
{"already_voted", "You have already voted in the last 24 hours."},
{"not_yet_voted", "You have not yet voted for this server on {0}. Type /vote"},
{"pending_reward", "You have a pending reward for your vote! Type /reward"},
{"free_reward", "You gave {0} a free reward!"},
{"reward", "You've been rewarded {0}. Thanks for voting!"},
{"reward_announcement", "{0} voted on {1} and has received a reward! Vote now!"},
{"failed_to_connect", "Failed to connect, please try again later..."}
};
}
}
}
};
}
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("e62d7463-577c-418a-90bd-ec9f9fec4077")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyVersion("3.0.2.0")]
[assembly: AssemblyFileVersion("3.0.2.0")]
[assembly: InternalsVisibleTo("Assembly-CSharp-firstpass")]
35 changes: 23 additions & 12 deletions VoteRewards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Rocket.Core.Plugins;
using Rocket.Core;
using Rocket.API;
using SDG.Unturned;
using SDG.Unturned;
using UnityEngine;
using fr34kyn01535.Uconomy;
using Teyhota.CustomKits;
Expand All @@ -21,8 +21,10 @@ public static string GetVote(UnturnedPlayer player, Plugin.VoteRewardsConfig.Ser
WebClient wc = new WebClient();
string result = null;

if (service.APIKey == null)
if (service.APIKey == null || service.APIKey.Length == 0)
{
Logger.LogError("\nVoteRewards >> API key(s) not found\n");

return null;
}

Expand All @@ -33,7 +35,7 @@ public static string GetVote(UnturnedPlayer player, Plugin.VoteRewardsConfig.Ser
catch (WebException)
{
Logger.LogError(string.Format("\nVoteRewards >> Could not connect to {0}'s API\n", service.Name));

return null;
}

Expand Down Expand Up @@ -78,7 +80,7 @@ public static bool SetVote(UnturnedPlayer player, Plugin.VoteRewardsConfig.Servi
url = "http://api.observatory.rocketmod.net/?server={0}&steamid={1}&claim";
}

if (service.APIKey == null || url == null)
if (service.APIKey == null || service.APIKey.Length == 0 || url == null)
{
return false;
}
Expand Down Expand Up @@ -123,6 +125,11 @@ public static void HandleVote(UnturnedPlayer player, bool giveReward)
{
if (service.Name == "unturned-servers")
{
if (service.APIKey == null || service.APIKey.Length == 0)
{
continue;
}

s = new Plugin.VoteRewardsConfig.Service(service.Name, service.APIKey);
voteResult = GetVote(player, s, "http://unturned-servers.net/api/?object=votes&element=claim&key={0}&steamid={1}");
serviceName = service.Name;
Expand All @@ -135,6 +142,11 @@ public static void HandleVote(UnturnedPlayer player, bool giveReward)
}
else if (service.Name == "unturnedsl")
{
if (service.APIKey == null || service.APIKey.Length == 0)
{
continue;
}

s = new Plugin.VoteRewardsConfig.Service(service.Name, service.APIKey);
voteResult = GetVote(player, s, "http://unturnedsl.com/api/dedicated/{0}/{1}");
serviceName = service.Name;
Expand All @@ -147,6 +159,12 @@ public static void HandleVote(UnturnedPlayer player, bool giveReward)
}
else if (service.Name == "obs.erve.me" || service.Name == "observatory")
{

if (service.APIKey == null || service.APIKey.Length == 0)
{
continue;
}

s = new Plugin.VoteRewardsConfig.Service(service.Name, service.APIKey);
voteResult = GetVote(player, s, "http://api.observatory.rocketmod.net/?server={0}&steamid={1}");
serviceName = service.Name;
Expand All @@ -167,14 +185,7 @@ public static void HandleVote(UnturnedPlayer player, bool giveReward)
{
if (voteResult == "0") // Has not voted
{
if (giveReward)
{
UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("not_yet_voted", serviceName), Color.red);
}
else
{
UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("not_yet_voted"));
}
UnturnedChat.Say(player, Plugin.VoteRewardsPlugin.Instance.Translate("not_yet_voted", serviceName), Color.red);
}
else if (voteResult == "1") // Has voted & not claimed
{
Expand Down

0 comments on commit df148f4

Please sign in to comment.