Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
VersionConverter112To113.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3using XmlUtilities;
4
5namespace Game {
7 public override string SourceVersion => "1.12";
8
9 public override string TargetVersion => "1.13";
10
11 public override void ConvertProjectXml(XElement projectNode) {
12 XmlUtils.SetAttributeValue(projectNode, "Version", TargetVersion);
13 ProcessNode(projectNode);
14 }
15
16 public override void ConvertWorld(string directoryName) {
17 string path = Storage.CombinePaths(directoryName, "Project.xml");
18 XElement xElement;
19 using (Stream stream = Storage.OpenFile(path, OpenFileMode.Read)) {
20 xElement = XmlUtils.LoadXmlFromStream(stream, null, true);
21 }
22 ConvertProjectXml(xElement);
23 using (Stream stream2 = Storage.OpenFile(path, OpenFileMode.Create)) {
24 XmlUtils.SaveXmlToStream(xElement, stream2, null, true);
25 }
26 }
27
28 public void ProcessNode(XElement node) {
29 foreach (XAttribute item in node.Attributes()) {
30 ProcessAttribute(item);
31 }
32 foreach (XElement item2 in node.Elements()) {
33 ProcessNode(item2);
34 }
35 }
36
37 public void ProcessAttribute(XAttribute attribute) {
38 if (attribute.Name == "Value"
39 && attribute.Value == "Dangerous") {
40 attribute.Value = "Normal";
41 }
42 }
43 }
44}
static Stream OpenFile(string path, OpenFileMode openFileMode)
static string CombinePaths(params string[] paths)
override void ConvertWorld(string directoryName)
override void ConvertProjectXml(XElement projectNode)
static void SetAttributeValue(XElement node, string attributeName, object value)
static XElement LoadXmlFromStream(Stream stream, Encoding encoding, bool throwOnError)
static void SaveXmlToStream(XElement node, Stream stream, Encoding encoding, bool throwOnError)