Skip to content

Commit

Permalink
Ver 0.12.0-A1: Okay, Okay.
Browse files Browse the repository at this point in the history
I mean, you're right.
  • Loading branch information
Shiroiame-Kusu committed Feb 4, 2024
1 parent 8ea29f2 commit 31ef8fe
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 62 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion Serein/Universal/Core/Server/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static bool Start(bool quiet)

#region 主变量初始化
if (ServerType == "jar")
{
{
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
float AvailableRAM = ramCounter.NextValue();
if (Global.Settings.Server.AutoJVMOptimization)
Expand Down
4 changes: 2 additions & 2 deletions Serein/Universal/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ internal static class Global
/// <summary>
/// 版本号
/// </summary>
public const string VERSION = "v0.10.1-RC1";
public const string VERSION = "v0.12.0-A1";
//public static readonly string VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString();

/// <summary>
/// 分支
/// </summary>
public const string BRANCH = "ReleaseCandidate";
public const string BRANCH = "Preview";
//public static readonly Object[]? Shiroiame_Kusu = { };
/// <summary>
/// 类型
Expand Down
4 changes: 2 additions & 2 deletions Serein/Universal/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("0.10.1.1")]
[assembly: AssemblyFileVersion("0.10.1-RC1")]
[assembly: AssemblyVersion("0.12.0.0")]
[assembly: AssemblyFileVersion("0.12.0-A1")]
2 changes: 1 addition & 1 deletion Serein/Universal/Utils/CrashInterception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void ShowException(Exception e)
$"◦ 崩溃日志已保存在 {Path.Combine("logs", "crash", $"{DateTime.Now:yyyy-MM-dd}.log")}\n" +
$"◦ 反馈此问题可以帮助作者更好的改进Serein",
MainIcon = TaskDialogIcon.Error,
Footer = $"你可以<a href=\"https://github.com/Shiroiame-Kusu/Serein/issues/new?labels=%E2%9D%97+%E5%B4%A9%E6%BA%83&template=crush_report.yml&title=崩溃反馈+{e.GetType()}\">提交Issue</a>",
Footer = $"你可以<a href=\"https://github.com/Shiroiame-Kusu/Serein/issues/new?labels=%E2%9D%97+%E5%B4%A9%E6%BA%83&template=crash_report.yml&title=崩溃反馈+{e.GetType()}\">提交Issue</a>",
FooterIcon = TaskDialogIcon.Information,
EnableHyperlinks = true,
ExpandedInformation = exceptionMsg
Expand Down
4 changes: 4 additions & 0 deletions Serein/Universal/Utils/PropertyOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public ArrayList List
/// </summary>
/// <param name="fileName">要读写的properties文件名</param>
public PropertyOperation(string fileName)
{
PropertyOperator(fileName);
}
public void PropertyOperator(string fileName)
{
this.fileName = fileName;
this.Load(fileName);
Expand Down
31 changes: 22 additions & 9 deletions Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Serein.Windows.Pages.Function.Frp
/// </summary>
public partial class Login : UiPage
{
private string token { get; set; }
private string? token { get; set; }
public Login()
{
InitializeComponent();
Expand Down Expand Up @@ -58,25 +58,38 @@ private async void Login_Click(object sender, RoutedEventArgs e)
Username.IsEnabled = false;
Password.IsEnabled = false;
using var client = new HttpClient();
var result = await client.GetAsync("https://api.locyanfrp.cn/User/DoLogin?username=" + Username.Text + "&password=" + Password.Text);

JObject? ParsedResult = JObject.Parse(result.Content.ReadAsStringAsync().ToString());
if(result.StatusCode.ToString() == "200")
string username = Username.Text;
string password = Password.Text;
var result = await client.GetAsync("https://api.locyanfrp.cn/User/DoLogin?username=" + username + "&password=" + password);

if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
if(ParsedResult["status"].ToString() == "0")
var result2 = result.Content.ReadAsStringAsync().ToString();
JObject? ParsedResult = JObject.Parse(result2);

Check warning on line 68 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 68 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 68 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 68 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.

Check warning on line 68 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'json' in 'JObject JObject.Parse(string json)'.
if(result.StatusCode.ToString() == "200")
{
token = ParsedResult["token"].ToString();
if(ParsedResult["status"].ToString() == "0")

Check warning on line 71 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 71 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
{
token = ParsedResult["token"].ToString();

Check warning on line 73 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
}
else
{
Logger.MsgBox("Serein", ParsedResult["message"].ToString(), 0, 48);

Check warning on line 77 in Serein/WPF/Windows/Pages/Function/Frp/Login.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
}
}
else
{
Logger.MsgBox("Serein", ParsedResult["message"].ToString(), 0, 48);
Logger.MsgBox("Serein", "请检查您的网络连接", 0, 48);
}
}
else
{
Logger.MsgBox("Serein", "请检查您的网络连接", 0, 48);
Username.IsEnabled = true;
Password.IsEnabled = true;
Logger.MsgBox("Serein", "你到底打没打用户名和密码", 0, 48);
}


}
}
}
8 changes: 4 additions & 4 deletions Serein/WPF/Windows/Pages/Server/Container.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public Container()
switch (ServerType)
{
case "jar":
Dispatcher.Invoke(() => { MinecraftProperties.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.Invoke(() => { PlayerList.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { MinecraftProperties.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { PlayerList.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
break;
default:
Dispatcher.Invoke(() => { MinecraftProperties.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.Invoke(() => { PlayerList.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { MinecraftProperties.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { PlayerList.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
break;
}
System.Threading.Thread.Sleep(500);
Expand Down
3 changes: 3 additions & 0 deletions Serein/WPF/Windows/Pages/Server/Download.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ private async void ServerDownload(object sender, RoutedEventArgs e)
if ((bool)AutoSetupPath.IsChecked)
{
Global.Settings.Server.Path = CurrentServerPath + "\\server.jar";
if (Catalog.Server.Plugins != null) { Catalog.Server.Plugins.Load(); }
var Loader = new Settings.Server();
Loader.Path.Text = Global.Settings.Server.Path;
}
try
{
Expand Down
25 changes: 25 additions & 0 deletions Serein/WPF/Windows/Pages/Server/Panel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,31 @@
Header="控制台">
<DockPanel>
<DockPanel DockPanel.Dock="Bottom">
<ComboBox
DockPanel.Dock="Left"
Margin="5"
SelectedIndex="0"
SelectionChanged="CommandHeaderSelected_SelectionChanged"
Name="CommandHeader">
<ComboBoxItem >
/
</ComboBoxItem>
<ComboBoxItem>
say
</ComboBoxItem>
<ComboBoxItem>
kill
</ComboBoxItem>
<ComboBoxItem>
effect
</ComboBoxItem>
<ComboBoxItem>
whitelist
</ComboBoxItem>
<ComboBoxItem>
broadcast
</ComboBoxItem>
</ComboBox>
<ui:Button
Margin="5"
Padding="0,3"
Expand Down
76 changes: 55 additions & 21 deletions Serein/WPF/Windows/Pages/Server/Panel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,47 @@

namespace Serein.Windows.Pages.Server
{

public partial class Panel : UiPage
{
private readonly Timer _updateInfoTimer = new Timer(2000) { AutoReset = true };
public static string ServerLog {get; set;}
private string CommandHeaderSelected = "";
private static bool IsBackgroundTaskRunning = false;
public Panel()
{
InitializeComponent();
Task.Run(() => {
while (true)
{
string? ServerType = null;
try
{
ServerType = Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3);
}
catch
{
if (!IsBackgroundTaskRunning)
{
Task.Run(() => {

while (true)
{
IsBackgroundTaskRunning = true;
string? ServerType = null;
try
{
ServerType = Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3);
}
catch
{

}
}
switch (ServerType)
{
case "jar":
Dispatcher.Invoke(() => { MEMSettings.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { MEMSettings.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);

break;
default:
Dispatcher.Invoke(() => { MEMSettings.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { MEMSettings.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
break;
}
System.Threading.Thread.Sleep(500);
}
});
System.Threading.Thread.Sleep(500);
}
});
}




Expand All @@ -55,7 +64,7 @@ public Panel()
PanelRichTextBox.Document.Blocks.Clear();
lock (Catalog.Server.Cache)
{
Catalog.Server.Cache.ForEach((line) => Dispatcher.Invoke(() => Append(LogPreProcessing.Color(line))));
Catalog.Server.Cache.ForEach((line) => Append(LogPreProcessing.Color(line)));
}
Catalog.Server.Panel = this;
}
Expand All @@ -81,7 +90,7 @@ private void Kill_Click(object sender, RoutedEventArgs e)

private void Enter_Click(object sender, RoutedEventArgs e)
{
ServerManager.InputCommand(InputBox.Text);
ServerManager.InputCommand(CommandHeaderSelected + InputBox.Text);
InputBox.Text = "";
}

Expand All @@ -90,7 +99,7 @@ private void InputBox_PreviewKeyDown(object sender, KeyEventArgs e)
switch (e.Key)
{
case Key.Enter:
ServerManager.InputCommand(InputBox.Text);
ServerManager.InputCommand(CommandHeaderSelected + InputBox.Text);
InputBox.Text = "";
e.Handled = true;
break;
Expand Down Expand Up @@ -129,7 +138,7 @@ private void InputBox_PreviewKeyDown(object sender, KeyEventArgs e)

public void Append(Paragraph paragraph)
{
Dispatcher.Invoke(() =>
Dispatcher.BeginInvoke(() =>
{
PanelRichTextBox.Document = PanelRichTextBox.Document ?? new();
PanelRichTextBox.Document.Blocks.Add(paragraph);
Expand Down Expand Up @@ -205,5 +214,30 @@ private void PanelRichTextBox_TextChanged(object sender, TextChangedEventArgs e)
// representing the plain text content of the TextRange.
ServerLog = textRange.Text;
}

private void CommandHeaderSelected_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch (CommandHeader.SelectedIndex)
{
case 0:
CommandHeaderSelected = "";
break;
case 1:
CommandHeaderSelected = "say ";
break;
case 2:
CommandHeaderSelected = "kill ";
break;
case 3:
CommandHeaderSelected = "effect ";
break;
case 4:
CommandHeaderSelected = "whitelist ";
break;
case 5:
CommandHeaderSelected = "broadcast ";
break;
}
}
}
}
27 changes: 15 additions & 12 deletions Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@ public partial class PlayerList : UiPage
public static int CurrentSelectedIndex;
//public bool isPlayerListNotNull = true;
public List<Player>? items { get; set; }
private static bool IsBackgroundTaskRunning = false;
public PlayerList()
{

InitializeComponent();

Task.Run(() =>
if (!IsBackgroundTaskRunning)
{

while (true)
{
refresh();
Thread.Sleep(500);
}
});

IsBackgroundTaskRunning = true;
Task.Run(() =>
{

while (true)
{
refresh();
Thread.Sleep(500);
}
});
}

}

Expand Down Expand Up @@ -96,10 +99,10 @@ private void refresh()

}

Dispatcher.Invoke(() =>
Dispatcher.BeginInvoke(() =>
{
PlayerListView.ItemsSource = items;
});
},System.Windows.Threading.DispatcherPriority.Background);
}
private void ListView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
Expand Down
15 changes: 8 additions & 7 deletions Serein/WPF/Windows/Pages/Server/Properties.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ public partial class Properties : UiPage

public PropertyOperation PropertiesOperation;
public static int i = 0;

private static bool IsBackgroundTaskRunning = false;
public Properties()

Check warning on line 34 in Serein/WPF/Windows/Pages/Server/Properties.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Non-nullable field 'PropertiesOperation' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 34 in Serein/WPF/Windows/Pages/Server/Properties.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Non-nullable field 'PropertiesOperation' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 34 in Serein/WPF/Windows/Pages/Server/Properties.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Non-nullable field 'PropertiesOperation' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 34 in Serein/WPF/Windows/Pages/Server/Properties.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Non-nullable field 'PropertiesOperation' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 34 in Serein/WPF/Windows/Pages/Server/Properties.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Non-nullable field 'PropertiesOperation' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
InitializeComponent();

PropertiesPage.IsEnabled = false;
try
{
Expand Down Expand Up @@ -61,14 +64,12 @@ private void ReloadinBackground()
{
Task.Run(() => {
while (true)
{



{
GC.Collect();
if (File.Exists(Path.GetDirectoryName(Global.Settings.Server.Path) + "\\server.properties"))
{
PropertiesOperation = new PropertyOperation(Path.GetDirectoryName(Global.Settings.Server.Path) + "\\server.properties");
Dispatcher.Invoke(() =>
Dispatcher.InvokeAsync(() =>
{

PropertiesPage.IsEnabled = true;
Expand All @@ -77,12 +78,12 @@ private void ReloadinBackground()
}
else
{
Dispatcher.Invoke(() =>
Dispatcher.InvokeAsync(() =>
{
PropertiesPage.IsEnabled = false;
}, System.Windows.Threading.DispatcherPriority.Background);
}
Thread.Sleep(500);
Thread.Sleep(1000);
}


Expand Down
Loading

0 comments on commit 31ef8fe

Please sign in to comment.