Skip to content

Commit

Permalink
Ver 0.12.0-B1: Fixed a lot of the bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiroiame-Kusu committed Feb 28, 2024
1 parent f12e9bf commit 977c636
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 30 deletions.
1 change: 0 additions & 1 deletion Serein/Universal/Base/Motd/Motdje.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ internal override void Get()
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
OnlinePlayer = (long)PacketData["players"]["online"];

Check warning on line 133 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 133 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'value' in 'JToken.explicit operator long(JToken value)'.

Check warning on line 133 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 133 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'value' in 'JToken.explicit operator long(JToken value)'.
MaxPlayer = (long)PacketData["players"]["max"];

Check warning on line 134 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 134 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Possible null reference argument for parameter 'value' in 'JToken.explicit operator long(JToken value)'.

Check warning on line 134 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
Version = PacketData["version"]["name"].ToString();

Check warning on line 135 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 135 in Serein/Universal/Base/Motd/Motdje.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
Expand Down
6 changes: 3 additions & 3 deletions Serein/Universal/Core/Server/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ public static void OpenFolder(string? path = null)
{
return;
}
Get();
Process.Start(new ProcessStartInfo("Explorer.exe")
{
Arguments = !string.IsNullOrEmpty(path)
? $"/e,/select,\"{path}\""
: $"/e,\"{BasePath}\""
Arguments = !string.IsNullOrEmpty(path) ? $"/e,/select,\"{path}\"" : $"/e,\"{BasePath}\""
});

}

/// <summary>
Expand Down
14 changes: 8 additions & 6 deletions Serein/Universal/Core/Server/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public static bool Start(bool quiet)
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
float AvailableRAM = ramCounter.NextValue();
double AutoSetRAM = Math.Round(AvailableRAM * 0.8, 0);
Global.Settings.Server.MaxRAM = AutoSetRAM.ToString();
JEStartMaxRam = Global.Settings.Server.MaxRAM;

JEStartMaxRam = AutoSetRAM.ToString();
Logger.MsgBox("未设置最大内存\n已自动为您设置启动内存为 " + JEStartMaxRam + "M", "Serein", 0, 48);

}
Expand Down Expand Up @@ -261,8 +261,9 @@ public static bool Start(bool quiet)
RedirectStandardOutput = true,
RedirectStandardInput = true,
StandardOutputEncoding = _encodings[Global.Settings.Server.OutputEncoding],
WorkingDirectory = Path.GetDirectoryName(Global.Settings.Server.Path)
WorkingDirectory = Path.GetDirectoryName(Global.Settings.Server.Path),
};
Console.WriteLine(JEStartMaxRam + "M " + JEOptimizationArguments);
StartInfo = ServerStartInfo;
File.WriteAllText(Path.GetDirectoryName(Global.Settings.Server.Path) + "\\eula.txt", "eula=true");
}
Expand All @@ -282,7 +283,7 @@ public static bool Start(bool quiet)

StartInfo = ServerStartInfo;
}

Logger.Output(LogType.Server_Notice, $"使用的jvm启动参数: {JEOptimizationArguments}\n");
_serverProcess = Process.Start(StartInfo);
_serverProcess!.EnableRaisingEvents = true;
_serverProcess.Exited += (_, _) => CloseAll();
Expand Down Expand Up @@ -484,7 +485,7 @@ public static void InputCommand(string command, bool usingUnicode, bool isFromCo
CommandHistory.Count == 0) &&
!isFromCommand && // 通过Serein命令执行的不计入
!string.IsNullOrEmpty(command)) // 为空不计入
{
{
CommandHistory.Add(command);
}
CommandHistoryIndex = CommandHistory.Count;
Expand Down Expand Up @@ -520,7 +521,8 @@ public static void InputCommand(string command, bool usingUnicode, bool isFromCo
private static void SortOutputHandler(object sender, DataReceivedEventArgs e)
{
if (!string.IsNullOrEmpty(e.Data))
{
{

string lineFiltered = LogPreProcessing.Filter(e.Data);
Console.WriteLine(lineFiltered);
if (string.IsNullOrEmpty(LevelName) && RegExp.Regex.IsMatch(lineFiltered, Global.Settings.Matches.LevelName, RegExp.RegexOptions.IgnoreCase))
Expand Down
2 changes: 1 addition & 1 deletion Serein/Universal/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static class Global
/// <summary>
/// 版本号
/// </summary>
public const string VERSION = "v0.12.0-A1";
public const string VERSION = "v0.12.0-B1";
//public static readonly string VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString();

/// <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.12.0.0")]
[assembly: AssemblyFileVersion("0.12.0-A1")]
[assembly: AssemblyVersion("0.12.0.1")]
[assembly: AssemblyFileVersion("0.12.0-B1")]
Binary file modified Serein/Universal/Sources/net472/Updater.exe
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions Serein/Universal/Sources/net472/publish/Updater.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
18 changes: 18 additions & 0 deletions Serein/WPF/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions Serein/WPF/Properties/PublishProfiles/FolderProfile.pubxml.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-02-28T04:59:26.3089966Z;False|2024-02-28T12:58:35.4897660+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Serein/WPF/Serein-WPF.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
1 change: 1 addition & 0 deletions Serein/WPF/Serein-WPF.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugFramework>net6.0-windows</ActiveDebugFramework>
<_LastSelectedProfileId>D:\GitHub\Serein\Serein\WPF\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<Compile Update="Windows\Pages\Debug.xaml.cs">
Expand Down
2 changes: 1 addition & 1 deletion Serein/WPF/Windows/Pages/Server/Panel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ui:TextBox Grid.Row="0" Name="MaxRAM" Margin="5,0"/>
<ui:TextBox Grid.Row="0" Name="MaxRAM" Margin="5,0" TextChanged="MaxRAM_TextChanged"/>
<ui:ToggleSwitch Grid.Row="1" Name="AutoJVMOptimization" Click="AutoJVMOptimization_Click" Content="启用自动优化" Margin="5"/>
</Grid>
</GroupBox>
Expand Down
8 changes: 7 additions & 1 deletion Serein/WPF/Windows/Pages/Server/Panel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Panel()
_updateInfoTimer.Elapsed += (_, _) => UpdateInfos();
_updateInfoTimer.Start();
PanelRichTextBox.Document.Blocks.Clear();
MaxRAM.Text = Global.Settings.Server.MaxRAM;
lock (Catalog.Server.Cache)
{
Catalog.Server.Cache.ForEach((line) => Append(LogPreProcessing.Color(line)));
Expand All @@ -71,7 +72,7 @@ public Panel()

private void Start_Click(object sender, RoutedEventArgs e)
{
Global.Settings.Server.MaxRAM = MaxRAM.Text;

ServerManager.Start();
UpdateInfos();
}
Expand Down Expand Up @@ -239,5 +240,10 @@ private void CommandHeaderSelected_SelectionChanged(object sender, SelectionChan
break;
}
}

private void MaxRAM_TextChanged(object sender, TextChangedEventArgs e)
{
Global.Settings.Server.MaxRAM = MaxRAM.Text;
}
}
}
55 changes: 42 additions & 13 deletions Serein/WPF/Windows/Pages/Server/PlayerList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public partial class PlayerList : UiPage
//public bool isPlayerListNotNull = true;
public List<Player>? items { get; set; }
private static bool IsBackgroundTaskRunning = false;
public bool isSelecting = false;
public static string PlayerListItemsOld = null;
public PlayerList()
{

Expand Down Expand Up @@ -60,17 +62,21 @@ private void refresh()
{
PlayerListItems = PlayerListData?["sample"]?.ToString();
}
catch
catch(Exception e)
{

Console.WriteLine(e.ToString());
items.Clear();
}
items = new List<Player>();
if (ServerManager.Status)
{
{
if (!string.IsNullOrEmpty(PlayerListItems))
{
for (int a = 0; a < PlayerListData?["sample"]?.Count(); a++)
{

for (int a = 0;
a < PlayerListData?["sample"]?.Count();
a++)
{
string? Username = PlayerListData["sample"]?[a]?["name"]?.ToString();
string? UUID = PlayerListData["sample"]?[a]?["id"]?.ToString();

Expand All @@ -85,24 +91,44 @@ private void refresh()
str = str.Remove(0, 2);
IP = str.Substring(0, str.Length - 1);
}
catch
catch(Exception e)
{

}

items.Add(new Player() { Username = Username, UUID = UUID, IP = IP });



}

}
}
else
{
if (string.IsNullOrEmpty(PlayerListItemsOld) && !isSelecting)
{
Dispatcher.BeginInvoke(() =>
{
PlayerListView.ItemsSource = items;
}, System.Windows.Threading.DispatcherPriority.Background);
PlayerListItemsOld = PlayerListItems;
}
try
{
if (PlayerListItems != PlayerListItemsOld)
{
Dispatcher.BeginInvoke(() =>
{
PlayerListView.ItemsSource = items;
}, System.Windows.Threading.DispatcherPriority.Background);
PlayerListItemsOld = PlayerListItems;
}
}
catch
{

}
}

Dispatcher.BeginInvoke(() =>
{
PlayerListView.ItemsSource = items;
},System.Windows.Threading.DispatcherPriority.Background);

}
private void ListView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
Expand Down Expand Up @@ -279,6 +305,9 @@ private void PlayerListView_MouseDown(object sender, MouseButtonEventArgs e)
{
CurrentSelectedIndex = PlayerListView.SelectedIndex;
}
isSelecting = true;


}
}
public class Player
Expand Down
3 changes: 2 additions & 1 deletion Serein/WPF/Windows/Pages/Server/Plugins.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
Name="Refresh"
Click="MenuItem_Click"
Header="刷新"
SymbolIcon="ArrowClockwise24" />
SymbolIcon="ArrowClockwise24"
Tag="Refresh"/>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
Expand Down
7 changes: 7 additions & 0 deletions Serein/WPF/Windows/Pages/Server/Plugins.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
case "OpenFolder":
if (PluginsListview.SelectedIndex < 0)
{
string DirectoryName = Path.GetDirectoryName(Global.Settings.Server.Path);
if (!Directory.Exists(Path.GetDirectoryName(Global.Settings.Server.Path) + "\\plugins"))
{
Console.WriteLine(DirectoryName);
Directory.CreateDirectory(DirectoryName + "\\plugins");
}
PluginManager.OpenFolder();

}
else
{
Expand Down

0 comments on commit 977c636

Please sign in to comment.