mirror of
https://github.com/Novetus/Novetus_src.git
synced 2025-01-31 09:41:33 +02:00
update scripts
This commit is contained in:
parent
a10dcdcdfa
commit
23e597dede
@ -1,5 +1,12 @@
|
||||
1.3 Snapshot v22.8412.32591.1
|
||||
Enhancements:
|
||||
- Added support for HasBadge to the Web Proxy.
|
||||
- Merged some static APIs into one extension.
|
||||
- Restored the Help button functionality.
|
||||
- All clients now work properly with the Web Proxy.
|
||||
----------------------------------------------------------------------------
|
||||
1.3 Snapshot v22.8412.32591.1
|
||||
Enhancements:
|
||||
- Added badge support to the Web Proxy.
|
||||
- The Easter Egg now loads up a server and a client, rather than loading a client in Play Solo mode.
|
||||
- Further improved web proxy reliability.
|
||||
|
@ -20,20 +20,10 @@ public class AwardBadge : IWebProxyExtension
|
||||
}
|
||||
|
||||
private static readonly string BadgeDatabasePath = GlobalPaths.ConfigDir + "\\BadgeDatabase.ini";
|
||||
private string BadgeDatabaseSection = "BadgeDatabase";
|
||||
private static readonly string BadgeDatabaseSection = "BadgeDatabase";
|
||||
private string MetadataFileExtension = "_meta.ini";
|
||||
private INIFile ini = new INIFile(BadgeDatabasePath);
|
||||
|
||||
public override string Name()
|
||||
{
|
||||
return "Badge Award Extension";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
}
|
||||
|
||||
void AddBadgeToDB(long BadgeID, bool Awarded = false)
|
||||
{
|
||||
CreateBadgeDatabaseIfNeeded();
|
||||
@ -62,11 +52,6 @@ public class AwardBadge : IWebProxyExtension
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnExtensionLoad()
|
||||
{
|
||||
CreateBadgeDatabaseIfNeeded();
|
||||
}
|
||||
|
||||
BadgeData LoadMetadata(long BadgeID)
|
||||
{
|
||||
BadgeData result;
|
||||
@ -100,11 +85,6 @@ public class AwardBadge : IWebProxyExtension
|
||||
return result;
|
||||
}
|
||||
|
||||
public override bool IsValidURL(string absolutePath, string host)
|
||||
{
|
||||
return absolutePath.EndsWith("/game/badge/awardbadge.ashx");
|
||||
}
|
||||
|
||||
string GenerateBadgeString(string creatorName, string badgeName, long id)
|
||||
{
|
||||
if (PlayerHasBadge(id))
|
||||
@ -115,9 +95,33 @@ public class AwardBadge : IWebProxyExtension
|
||||
return GlobalVars.UserConfiguration.PlayerName + " won " + creatorName + "'s \"" + badgeName + "\" award!";
|
||||
}
|
||||
|
||||
public override string Name()
|
||||
{
|
||||
return "Badge Award API Extension";
|
||||
}
|
||||
|
||||
public override string Version()
|
||||
{
|
||||
return "1.0.1";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
}
|
||||
|
||||
public override void OnExtensionLoad()
|
||||
{
|
||||
CreateBadgeDatabaseIfNeeded();
|
||||
}
|
||||
|
||||
public override bool IsValidURL(string absolutePath, string host)
|
||||
{
|
||||
return absolutePath.EndsWith("/game/badge/awardbadge.ashx");
|
||||
}
|
||||
|
||||
public override async Task OnRequest(object sender, SessionEventArgs e)
|
||||
{
|
||||
await Util.Delay(1000);
|
||||
string query = e.HttpClient.Request.RequestUri.Query;
|
||||
long badgeid = 0;
|
||||
long userid = 0;
|
||||
@ -132,6 +136,6 @@ public class AwardBadge : IWebProxyExtension
|
||||
|
||||
string badgeAwardString = GenerateBadgeString(meta.BadgeCreatorName, meta.BadgeName, badgeid);
|
||||
AddBadgeToDB(badgeid, true);
|
||||
e.Ok(badgeAwardString, NetFuncs.GenerateHeaders(badgeAwardString.Length.ToString()));
|
||||
e.Ok(badgeAwardString, NetFuncs.GenerateHeaders(badgeAwardString.Length.ToString(), "text/plain"));
|
||||
}
|
||||
}
|
76
defaultaddons/novetusexts/webproxy/HasBadge.cs
Normal file
76
defaultaddons/novetusexts/webproxy/HasBadge.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
using Titanium.Web.Proxy;
|
||||
using Titanium.Web.Proxy.EventArguments;
|
||||
using Titanium.Web.Proxy.Http;
|
||||
using Titanium.Web.Proxy.Models;
|
||||
using Novetus.Core;
|
||||
|
||||
public class HasBadge : IWebProxyExtension
|
||||
{
|
||||
private static readonly string BadgeDatabasePath = GlobalPaths.ConfigDir + "\\BadgeDatabase.ini";
|
||||
private static readonly string BadgeDatabaseSection = "BadgeDatabase";
|
||||
private INIFile ini = new INIFile(BadgeDatabasePath);
|
||||
|
||||
public override string Name()
|
||||
{
|
||||
return "Badge Checker API Extension";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
}
|
||||
|
||||
bool PlayerHasBadge(long BadgeID)
|
||||
{
|
||||
CreateBadgeDatabaseIfNeeded();
|
||||
|
||||
if (ini.IniValueExists(BadgeID.ToString()))
|
||||
{
|
||||
string awarded = ini.IniReadValue(BadgeDatabaseSection, BadgeID.ToString(), "False");
|
||||
return Convert.ToBoolean(awarded);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CreateBadgeDatabaseIfNeeded()
|
||||
{
|
||||
if (!File.Exists(BadgeDatabasePath))
|
||||
{
|
||||
Util.ConsolePrint("WARNING - " + BadgeDatabasePath + " not found. Creating empty badge database.", 5);
|
||||
File.Create(BadgeDatabasePath).Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnExtensionLoad()
|
||||
{
|
||||
CreateBadgeDatabaseIfNeeded();
|
||||
}
|
||||
|
||||
public override bool IsValidURL(string absolutePath, string host)
|
||||
{
|
||||
return absolutePath.EndsWith("/game/badge/hasbadge.ashx");
|
||||
}
|
||||
|
||||
public override async Task OnRequest(object sender, SessionEventArgs e)
|
||||
{
|
||||
string query = e.HttpClient.Request.RequestUri.Query;
|
||||
long badgeid = 0;
|
||||
long userid = 0;
|
||||
if (!long.TryParse(NetFuncs.FindQueryString(query, "badgeid"), out badgeid) &&
|
||||
!long.TryParse(NetFuncs.FindQueryString(query, "userid"), out userid))
|
||||
{
|
||||
e.GenericResponse("", HttpStatusCode.BadRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
string hasBadgeResult = PlayerHasBadge(badgeid) ? "Success" : "Failure";
|
||||
e.Ok(hasBadgeResult, NetFuncs.GenerateHeaders(hasBadgeResult.Length.ToString(), "text/plain"));
|
||||
}
|
||||
}
|
71
defaultaddons/novetusexts/webproxy/StaticPages.cs
Normal file
71
defaultaddons/novetusexts/webproxy/StaticPages.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Titanium.Web.Proxy;
|
||||
using Titanium.Web.Proxy.EventArguments;
|
||||
using Titanium.Web.Proxy.Http;
|
||||
using Titanium.Web.Proxy.Models;
|
||||
using Novetus.Core;
|
||||
|
||||
public class StaticPages : IWebProxyExtension
|
||||
{
|
||||
public override string Name()
|
||||
{
|
||||
return "Static APIs Extension";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
}
|
||||
|
||||
static string GetStudioPageOutput()
|
||||
{
|
||||
return "Welcome to Novetus " + GlobalVars.ProgramInformation.Version + "!";
|
||||
}
|
||||
|
||||
static string GetHelpPageOutput()
|
||||
{
|
||||
string path = GlobalPaths.NovetusExtsWebProxy + @"\\webpages\\Help.html";
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
|
||||
Dictionary<string, string> staticPages = new Dictionary<string, string>()
|
||||
{
|
||||
{"/ide/landing.aspx", GetStudioPageOutput()},
|
||||
{"/discover", GetStudioPageOutput()},
|
||||
{"/my/places.aspx", GetStudioPageOutput()},
|
||||
{"/game/badge/isbadgedisabled.ashx", "0"},
|
||||
{"/game/help.aspx", GetHelpPageOutput()}
|
||||
};
|
||||
|
||||
public override bool IsValidURL(string absolutePath, string host)
|
||||
{
|
||||
foreach(var item in staticPages.Keys)
|
||||
{
|
||||
if (absolutePath.StartsWith(item) || absolutePath.EndsWith(item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task OnRequest(object sender, SessionEventArgs e)
|
||||
{
|
||||
string absPath = e.HttpClient.Request.RequestUri.AbsolutePath.ToLowerInvariant();
|
||||
|
||||
foreach(var item in staticPages.Keys)
|
||||
{
|
||||
if (absPath.StartsWith(item) || absPath.EndsWith(item))
|
||||
{
|
||||
string result = staticPages[item];
|
||||
e.Ok(result, NetFuncs.GenerateHeaders(result.Length.ToString(), "text/html"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Collections.Generic;
|
||||
using Titanium.Web.Proxy;
|
||||
using Titanium.Web.Proxy.EventArguments;
|
||||
using Titanium.Web.Proxy.Http;
|
||||
using Titanium.Web.Proxy.Models;
|
||||
using Novetus.Core;
|
||||
|
||||
public class StudioLaunchPage : IWebProxyExtension
|
||||
{
|
||||
public override string Name()
|
||||
{
|
||||
return "Studio Launch Page Extension";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
}
|
||||
|
||||
public override bool IsValidURL(string absolutePath, string host)
|
||||
{
|
||||
return absolutePath.EndsWith("/ide/landing.aspx") || absolutePath.EndsWith("/my/places.aspx");
|
||||
}
|
||||
|
||||
public override async Task OnRequest(object sender, SessionEventArgs e)
|
||||
{
|
||||
e.Ok("Welcome to Novetus Studio version " + GlobalVars.ProgramInformation.Version);
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@ public class UploadWarnings : IWebProxyExtension
|
||||
return "Upload Dialog Warnings Extension";
|
||||
}
|
||||
|
||||
public override string Version()
|
||||
{
|
||||
return "1.0.1";
|
||||
}
|
||||
|
||||
public override string Author()
|
||||
{
|
||||
return "Bitl";
|
||||
@ -31,14 +36,15 @@ public class UploadWarnings : IWebProxyExtension
|
||||
string absPath = e.HttpClient.Request.RequestUri.AbsolutePath.ToLowerInvariant();
|
||||
|
||||
string type = "video";
|
||||
string folder = "Videos";
|
||||
string folder = "My Videos";
|
||||
|
||||
if (absPath.EndsWith("/uploadmedia/postimage.aspx"))
|
||||
{
|
||||
type = "screenshot";
|
||||
folder = "Pictures";
|
||||
folder = "My Pictures";
|
||||
}
|
||||
|
||||
e.Ok("Your " + type + " was saved! Look in the Roblox folder in your " + folder + " folder!");
|
||||
string result = "Your " + type + " was saved! Look in the Roblox folder in your " + folder + " folder!";
|
||||
e.Ok(result, NetFuncs.GenerateHeaders(result.Length.ToString(), "text/plain"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user