Initial commit

This commit is contained in:
Ubuntu
2026-06-19 00:00:16 -04:00
commit 73701ff86e
7100 changed files with 1952988 additions and 0 deletions
+101
View File
@@ -0,0 +1,101 @@
using System.IO;
using Server.Mobiles;
using Server.Commands;
using System.Collections.Generic;
namespace Server.Custom.RegionBanner
{
internal class RegionBannerCommand
{
private static string RBDataFile = Path.Combine(Directory.GetCurrentDirectory(), "Data", "RB_ExcludeList");
private static List<string> ExcludeBannerList = new List<string>();
public static void Initialize()
{
CommandSystem.Register("ToggleRBanner", AccessLevel.Player, new CommandEventHandler(RBanner_OnCommand));
EventSink.AfterWorldSave += EventSink_AfterWorldSave;
try
{
if (File.Exists(RBDataFile))
{
var list = File.ReadAllLines(RBDataFile);
foreach (var info in list)
{
if (ExcludeBannerList == null)
{
ExcludeBannerList = new List<string>();
}
ExcludeBannerList.Add(info);
}
}
}
catch
{
// do nothing
}
}
[Usage("ToggleRegionBannerSystem")]
[Description("Region Banner System: ON/OFF")]
private static void RBanner_OnCommand(CommandEventArgs e)
{
bool isListed = false;
if (e.Mobile is PlayerMobile pm)
{
isListed = IsExcludedPlayer(pm);
if (!isListed)
{
ExcludeBannerList.Add($"{pm.Account.Username}:{pm.Name}");
pm.SendMessage(53, "Region Banner : Off");
}
else
{
ExcludeBannerList.Remove($"{pm.Account.Username}:{pm.Name}");
pm.SendMessage(53, "Region Banner : On");
}
}
}
private static void EventSink_AfterWorldSave(AfterWorldSaveEventArgs e)
{
if (ExcludeBannerList.Count > 0)
{
try
{
File.WriteAllLines(RBDataFile, ExcludeBannerList);
}
catch
{
// do nothing
}
}
}
internal static bool IsExcludedPlayer(PlayerMobile pm)
{
foreach (var listing in ExcludeBannerList)
{
var listingInfo = listing.Split(':');
if (listingInfo.Length > 1)
{
if (listingInfo[0] == pm.Account.Username && listingInfo[1] == pm.Name)
{
return true;
}
}
}
return false;
}
}
}
+58
View File
@@ -0,0 +1,58 @@
using Server.Gumps;
using Server.Mobiles;
using Server.Multis;
using Server.Regions;
namespace Server.Custom.RegionBanner
{
internal class RegionBannerCore
{
public static void Initialize()
{
EventSink.OnEnterRegion += EventSink_OnEnterRegion;
}
private static void EventSink_OnEnterRegion(OnEnterRegionEventArgs e)
{
if (e.From is PlayerMobile pm && !RegionBannerCommand.IsExcludedPlayer(pm))
{
bool isGood = true;
if (e.OldRegion != null)
{
isGood = ValidateRegion(e.OldRegion, isGood);
}
if (isGood && e.NewRegion != null)
{
isGood = ValidateRegion(e.NewRegion, isGood);
}
if (isGood)
{
if (pm.HasGump(typeof(RegionBannerGump)))
{
pm.CloseGump(typeof(RegionBannerGump));
}
BaseGump.SendGump(new RegionBannerGump(pm, e.NewRegion.Name));
}
}
}
private static bool ValidateRegion(Region region, bool isGood)
{
if (!region.IsPartOf(typeof(DungeonRegion)) && region.Name != null && region.Name.Contains("Cave"))
{
return false;
}
if (region is HouseRegion || region is NoHousingRegion || region is TempNoHousingRegion)
{
return false;
}
return isGood;
}
}
}
+77
View File
@@ -0,0 +1,77 @@
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using System;
namespace Server.Custom.RegionBanner
{
internal class RegionBannerGump : BaseGump
{
private string _RegionName;
private Timer _AutoCloseTimer;
public RegionBannerGump(PlayerMobile user, string name) : base(user, 50, 50, null)
{
_RegionName = name;
if (string.IsNullOrEmpty(_RegionName))
{
_RegionName = $"{user.Map.Name} Wilds";
}
}
public override void AddGumpLayout()
{
Closable = false;
Resizable = false;
Dragable = true;
AddBackground(X, Y, 200, 100, 39925);
AddAlphaRegion(X + 20, Y + 20, 160, 60);
AddBackground(X + 15, Y + 15, 170, 70, 40000);
AddLabel(X + CalculateOffset($"Entering"), Y + 27, 43, $"Entering");
AddLabel(X + CalculateOffset($"{_RegionName}"), Y + 52, 53, $"{_RegionName}");
_AutoCloseTimer = Timer.DelayCall(TimeSpan.FromSeconds(3), () =>
{
Close();
});
}
public override void Close()
{
StopAutoClose();
base.Close();
}
public override void OnServerClose(NetState owner)
{
StopAutoClose();
base.OnServerClose(owner);
}
private void StopAutoClose()
{
if (_AutoCloseTimer != null && _AutoCloseTimer.Running)
{
_AutoCloseTimer.Stop();
_AutoCloseTimer = null;
}
}
private int CalculateOffset(string text)
{
int textWidth = text.Length * 6;
return (200 - textWidth) / 2;
}
}
}