/// <summary> /// 初始化插件 /// </summary> /// <param name="api">MC相关API方法</param> public static void init(MCCSAPI api) { mcapi = api; initPlugin(); #region 注册命令 mcapi.setCommandDescribe("land", "打开领地菜单"); #endregion #region 设置事件监听器 api.addAfterActListener(EventKey.onLoadName, PlayerJoin); api.addBeforeActListener(EventKey.onAttack, Attack); api.addBeforeActListener(EventKey.onUseItem, UseItem); api.addBeforeActListener(EventKey.onServerCmd, ServerCmd); api.addBeforeActListener(EventKey.onPlacedBlock, PlacedBlock); api.addBeforeActListener(EventKey.onInputCommand, InputCommand); api.addBeforeActListener(EventKey.onDestroyBlock, DestroyBlock); api.addBeforeActListener(EventKey.onLevelExplode, LevelExplode); api.addBeforeActListener(EventKey.onStartOpenChest, StartOpenChest); // api.addBeforeActListener(EventKey.onStartOpenBarrel, StartOpenBarrel); #endregion }
/// <summary> /// 初始化文件 /// </summary> private static void initPlugin() { if (!Directory.Exists(BDSName)) { Directory.CreateDirectory(BDSName); } if (!Directory.Exists(FolderName)) { Directory.CreateDirectory(FolderName); } if (!Directory.Exists(MenuName)) { Directory.CreateDirectory(MenuName); } if (!File.Exists(configFile)) { initConfig(); } if (!File.Exists(defaultFile)) { initDefault(); } try { config = JObject.Parse(File.ReadAllText(configFile)); mcapi.setCommandDescribe("menu", "打开主菜单"); foreach (JObject menu in config["menu"]) { mcapi.setCommandDescribeEx((string)menu["command"], (string)menu["description"], (bool)config["admin"] ? MCCSAPI.CommandPermissionLevel.Admin : MCCSAPI.CommandPermissionLevel.Any, (byte)MCCSAPI.CommandCheatFlag.NotCheat, (byte)MCCSAPI.CommandVisibilityFlag.Visible); } } catch { Console.WriteLine("Menu >> 配置文件 config.json 读取失败!"); Console.WriteLine("Menu >> 为了服务器的安全,已卸载本插件的所有功能,请重启服务器确保插件正常运行!"); mcapi.removeAfterActListener(EventKey.onUseItem, UseItem); mcapi.removeAfterActListener(EventKey.onLoadName, PlayerJoin); mcapi.removeAfterActListener(EventKey.onPlayerLeft, PlayerLeft); mcapi.removeAfterActListener(EventKey.onFormSelect, FormSelect); mcapi.removeBeforeActListener(EventKey.onServerCmd, ServerCmd); mcapi.removeBeforeActListener(EventKey.onInputCommand, InputCommand); return; } try { Mdefault = JObject.Parse(File.ReadAllText(defaultFile)); } catch { Console.WriteLine("Menu >> 菜单文件 default.json 读取失败!"); } }
public static void tpaa(MCCSAPI api) { api.setCommandDescribe("homegui", "打开homegui"); api.setCommandDescribe("tpato", "传送到一个玩家"); api.setCommandDescribe("tpac", "同游传送请求"); api.setCommandDescribe("tpde", "拒绝传送请求"); api.setCommandDescribe("tpapb", "改变tpa屏蔽状态"); api.setCommandDescribe("tpagui", "打开tpagui"); api.setCommandDescribe("homeadd", "添加一个私人传送点"); api.setCommandDescribe("homedel", "删除一个私人传送点"); api.setCommandDescribe("homego", "前往一个私人传送点"); api.setCommandDescribe("back", "返回上一个死亡点"); Dictionary <string, string> uuid = new Dictionary <string, string>(); //uuid Dictionary <string, string> tpa_pb = new Dictionary <string, string>(); //tpa屏蔽状态 Dictionary <string, string> tpa_dx = new Dictionary <string, string>(); //tpa对象 Dictionary <string, string> tpa_ys = new Dictionary <string, string>(); //tpa延时用 Dictionary <string, string> tpa_gui = new Dictionary <string, string>(); //记录guiid Dictionary <string, string> guils = new Dictionary <string, string>(); //gui类型 Dictionary <string, string> back_x = new Dictionary <string, string>(); //backx Dictionary <string, string> back_y = new Dictionary <string, string>(); //backy Dictionary <string, string> back_z = new Dictionary <string, string>(); //backz Dictionary <string, int> back_did = new Dictionary <string, int>(); //back维度 ArrayList onlineplayer = new ArrayList(); //在线玩家 int tpa_yx = 30000; string __back = "true"; string home_max = "5"; if (File.Exists("./config/tpa.txt")) { try { string[] config = File.ReadAllLines("./config/tpa.txt", System.Text.Encoding.Default); tpa_yx = int.Parse(config[0].Substring(12)); __back = config[1].Substring(12); home_max = config[2].Substring(14); Console.WriteLine("[TPA]配置文件读取成功!"); } catch { Console.WriteLine("[TPA]配置文件读取失败!"); } } else { Directory.CreateDirectory("config/"); File.AppendAllText("./config/tpa.txt", "玩家tpa请求有效时间:30000\n是否开启/back功能:true\n玩家设置home的最大数量:5", System.Text.Encoding.Default); Console.WriteLine("[TPA]未检查到配置文件!将自动创建!"); } api.addAfterActListener(EventKey.onLoadName, x => { var a = BaseEvent.getFrom(x) as LoadNameEvent; uuid.Add(a.playername, a.uuid); guils.Add(a.playername, "other"); onlineplayer.Add(a.playername); if (tpa_pb.ContainsKey(a.playername) == false) { tpa_pb.Add(a.playername, "no"); } try { tpa_dx.Add(a.playername, "cxk"); tpa_gui.Add(a.playername, "a"); tpa_ys.Add(a.playername, "0"); back_x.Add(a.playername, string.Empty); back_y.Add(a.playername, string.Empty); back_z.Add(a.playername, string.Empty); back_did.Add(a.playername, 0); } catch { Console.WriteLine("warn!!!!"); } return(true); }); api.addBeforeActListener(EventKey.onInputCommand, x => { bool re = true; var a = BaseEvent.getFrom(x) as InputCommandEvent; if (a.cmd.StartsWith("/tpato")) { string tpatoplayername = string.Empty; re = false; try { if (tpa_ys[a.playername] == "0") { tpatoplayername = a.cmd.Substring(7); if (api.getOnLinePlayers().IndexOf(tpatoplayername) != -1 || tpatoplayername.Length > 5) { if (tpa_pb[tpatoplayername] == "no") { api.runcmd("tellraw \"" + tpatoplayername + "\" {\"rawtext\":[{\"text\":\"玩家" + a.playername + "向您发送了一个传送请求,/tpac接受,/tpde拒绝\"}]}"); tpa_ys[a.playername] = "1"; tpa_dx[tpatoplayername] = a.playername; tpa_gui[tpatoplayername] = api.sendModalForm(uuid[tpatoplayername], "TPA请求", "玩家" + a.playername + "向您发送了一个传送请求", "同意", "拒绝").ToString(); Task taskkk = Task.Run(async() => { await Task.Delay(30000); if (tpa_ys[a.playername] == "1") { tpa_ys[a.playername] = "0"; api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"tpa请求超时\"}]}"); tpa_dx[tpatoplayername] = "cxk"; } }); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"对方屏蔽了tpa请求\"}]}"); } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"tpa请求发送失败,请检查您输入的指令\"}]}"); } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"您有另一个tpa正在进行中!\"}]}"); } } catch { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"tpa请求发送失败,请检查您输入的指令\"}]}"); Console.WriteLine("warn!"); } } if (a.cmd.StartsWith("/tpapb")) { re = false; if (tpa_pb[a.playername] == "yes") { tpa_pb[a.playername] = "no"; } else { tpa_pb[a.playername] = "yes"; } } if (a.cmd.StartsWith("/tpac")) { re = false; if (tpa_dx[a.playername] != "cxk") { api.runcmd("tp \"" + a.playername + "\" " + tpa_dx[a.playername]); tpa_ys[tpa_dx[a.playername]] = "0"; tpa_dx[a.playername] = "cxk"; } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"没有人向你发送传送请求!\"}]}"); } } if (a.cmd.StartsWith("/tpde")) { re = false; if (tpa_dx[a.playername] != "cxk") { api.runcmd("tellraw \"" + tpa_dx[a.playername] + "\" {\"rawtext\":[{\"text\":\"对方拒绝了您的传送请求\"}]}"); tpa_ys[tpa_dx[a.playername]] = "0"; tpa_dx[a.playername] = "cxk"; } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"没有人向你发送传送请求!\"}]}"); } } if (a.cmd.StartsWith("/tpagui")) { re = false; string online = "[\""; foreach (string p in onlineplayer) { online = online + "\",\"" + p; } online = online + "\"]"; online = "[" + online.Substring(4); api.sendCustomForm(uuid[a.playername], "{\"content\":[{\"type\":\"label\",\"text\":\"这个一个TPAGUI喵\"},{\"default\":0,\"options\":" + online + ",\"type\":\"dropdown\",\"text\":\"请选择一个玩家\"}], \"type\":\"custom_form\",\"title\":\"TPAGUI\"}").ToString(); guils[a.playername] = "fz"; } if (__back == "true") { if (a.cmd.StartsWith("/back") && a.cmd.EndsWith("/back")) { re = false; if (back_x[a.playername] != string.Empty) { api.teleport(uuid[a.playername], Convert.ToSingle(back_x[a.playername]), Convert.ToSingle(back_y[a.playername]), Convert.ToSingle(back_z[a.playername]), back_did[a.playername]); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"命令已执行\"}]}"); back_x[a.playername] = string.Empty; back_y[a.playername] = string.Empty; back_z[a.playername] = string.Empty; } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"未找到死亡点!\"}]}"); } } } if (a.cmd.StartsWith("/homeadd ")) { re = false; if (File.Exists("./data/tpa/" + a.playername + ".txt")) { if (File.ReadAllLines("./data/tpa/" + a.playername + ".txt").Length < int.Parse(home_max)) { File.AppendAllText("./data/tpa/" + a.playername + ".txt", a.cmd.Substring(9) + "-" + a.XYZ.x + " " + a.XYZ.y + " " + a.XYZ.z + "\n"); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"您设置的home数量已达到上限!\"}]}"); } } else { Directory.CreateDirectory("./data/tpa"); File.AppendAllText("./data/tpa/" + a.playername + ".txt", a.cmd.Substring(9) + "-" + a.XYZ.x + " " + a.XYZ.y + " " + a.XYZ.z + "\n"); } } if (a.cmd == "/homegui") { re = false; if (File.Exists("./data/tpa/" + a.playername + ".txt")) { string[] lines = File.ReadAllLines("./data/tpa/" + a.playername + ".txt"); if (lines.Length != 0) { string homes = "["; foreach (string line in lines) { Console.WriteLine(line); homes = homes + "\"" + line.Substring(0, line.IndexOf("-")) + "\"" + ","; } homes = homes.Substring(0, homes.Length - 1) + "]"; api.sendCustomForm(uuid[a.playername], "{\"content\":[{\"type\":\"label\",\"text\":\"这个一个Thomegui\"},{\"default\":0,\"options\":" + homes + ",\"type\":\"dropdown\",\"text\":\"请选择一个家\"}], \"type\":\"custom_form\",\"title\":\"HOMEGUI\"}").ToString(); guils[a.playername] = "homegui"; } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"您还没有任何家!\"}]}"); } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"您还没有任何家!\"}]}"); } } if (a.cmd.StartsWith("/homego ")) { re = false; string tz = a.cmd.Substring(8); if (File.Exists("./data/tpa/" + a.playername + ".txt")) { byte bbb = 1; foreach (string line in File.ReadAllLines("./data/tpa/" + a.playername + ".txt")) { if (line.StartsWith(tz)) { bbb = 0; api.runcmd("tp \"" + a.playername + "\" " + line.Substring(tz.Length + 1)); break; } } if (bbb == 1) { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"未找到该名称的home点!\"}]}"); } } } if (a.cmd.StartsWith("/homedel ")) { re = false; if (File.Exists("./data/tpa/" + a.playername + ".txt")) { string[] lines = File.ReadAllLines("./data/tpa/" + a.playername + ".txt", System.Text.Encoding.Default); if (lines.Length != 0) { ArrayList ol = new ArrayList(); foreach (string line in lines) { ol.Add(line); if (line.StartsWith(a.cmd.Substring(9))) { ol.Remove(line); } } if (ol.Count == lines.Length) { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"未找到该名字的home点\"}]}"); } else { File.Delete("./data/tpa/" + a.playername + ".txt"); File.AppendAllLines("./data/tpa/" + a.playername + ".txt", (string[])ol.ToArray(typeof(string))); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"该home点已删除!\"}]}"); } } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"您还没有任何home点\"}]}"); } } return(re); }); api.addAfterActListener(EventKey.onMobDie, x => { var a = BaseEvent.getFrom(x) as MobDieEvent; if (a.mobtype == "entity.player.name") { try { back_x[a.playername] = a.XYZ.x.ToString(); back_y[a.playername] = a.XYZ.y.ToString(); back_z[a.playername] = a.XYZ.z.ToString(); back_did[a.playername] = a.dimensionid; } catch { } } return(true); }); api.addAfterActListener(EventKey.onPlayerLeft, x => { var a = BaseEvent.getFrom(x) as PlayerLeftEvent; uuid.Remove(a.playername); guils.Remove(a.playername); onlineplayer.Remove(a.playername); tpa_dx.Remove(a.playername); tpa_gui.Remove(a.playername); tpa_ys.Remove(a.playername); back_x.Remove(a.playername); back_y.Remove(a.playername); back_z.Remove(a.playername); return(true); }); api.addAfterActListener(EventKey.onFormSelect, x => { var a = BaseEvent.getFrom(x) as FormSelectEvent; if (guils[a.playername] == "homegui") { int ssss = Convert.ToInt32(a.selected.Substring(6, a.selected.Length - 7)); string[] lines = File.ReadAllLines("./data/tpa/" + a.playername + ".txt"); api.runcmd("tp " + a.playername + " " + lines[ssss].Substring(lines[ssss].IndexOf("-") + 1)); } if (guils[a.playername] == "fz") { if (tpa_ys[a.playername] == "0") { String tpatoplayername; tpatoplayername = onlineplayer[int.Parse(a.selected.Substring(6, 1))].ToString(); if (api.getOnLinePlayers().IndexOf(tpatoplayername) != -1 && tpatoplayername.Length > 5) { if (tpa_pb[tpatoplayername] == "no") { api.runcmd("tellraw \"" + tpatoplayername + "\" {\"rawtext\":[{\"text\":\"玩家" + a.playername + "向您发送了一个传送请求,/tpac接受,/tpde拒绝\"}]}"); tpa_ys[a.playername] = "1"; tpa_dx[tpatoplayername] = a.playername; tpa_gui[tpatoplayername] = api.sendModalForm(uuid[tpatoplayername], "TPA请求", "玩家" + a.playername + "向您发送了一个传送请求", "同意", "拒绝").ToString(); guils[a.playername] = "jd"; Task taskkk = Task.Run(async() => { await Task.Delay(tpa_yx); if (tpa_ys[a.playername] == "1") { tpa_ys[a.playername] = "0"; api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"tpa请求超时\"}]}"); tpa_dx[tpatoplayername] = "cxk"; } }); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"对方屏蔽了tpa请求\"}]}"); } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"tpa请求发送失败,请检查您输入的指令\"}]}"); } } } if (guils[a.playername] == "jd") { if (a.selected == "true") { if (tpa_dx[a.playername] != "cxk") { if (tpa_dx[a.playername] != "cxk") { api.runcmd("tp \"" + a.playername + "\" " + tpa_dx[a.playername]); tpa_ys[tpa_dx[a.playername]] = "0"; tpa_dx[a.playername] = "cxk"; } } } if (a.selected == "false") { api.runcmd("tellraw \"" + tpa_dx[a.playername] + "\" {\"rawtext\":[{\"text\":\"对方拒绝了您的传送请求\"}]}"); tpa_ys[tpa_dx[a.playername]] = "0"; tpa_dx[a.playername] = "cxk"; } } return(true); }); }
public static void aaascr(MCCSAPI api) { api.setCommandDescribe("is creative", "创建一个空岛"); api.setCommandDescribe("is goreset", "重置空岛传送点"); api.setCommandDescribe("is go", "保存或传送到空岛传送点"); api.setCommandDescribe("is sign", "签到"); api.setCommandDescribe("is clear", "清理掉落物品"); string qdpath = "./skyblockX/sign/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.DayOfYear.ToString(); string qdjlpath = "./skyblockX/sign/签到奖励.txt"; string _ifobsition = "true"; string _ifrespawnpunish = "false"; string eula = "false"; string _ifautoclear = "false"; string qdjl = "give @s apple"; int cleartime = 10; int start_x = 0; int start_y = 0; int start_z = 0; int end_x = 0; int end_y = 0; int end_z = 0; int x_max = 5000; int z_max = 5000; if (File.Exists("./skyblockX/skyblockX.txt")) { try { string[] config = File.ReadAllLines("./skyblockX/skyblockX.txt", System.Text.Encoding.Default); _ifobsition = config[0].Substring(14); _ifrespawnpunish = config[1].Substring(9); _ifautoclear = config[2].Substring(7); cleartime = int.Parse(config[3].Substring(7)); start_x = int.Parse(config[4].Substring(8)); start_y = int.Parse(config[5].Substring(8)); start_z = int.Parse(config[6].Substring(8)); end_x = int.Parse(config[7].Substring(6)); end_y = int.Parse(config[8].Substring(6)); end_z = int.Parse(config[9].Substring(6)); x_max = int.Parse(config[10].Substring(6)); z_max = int.Parse(config[11].Substring(6)); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]配置文件读取成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]配置文件读取失败!"); Console.ForegroundColor = ConsoleColor.White; } } else { Directory.CreateDirectory("./skyblockX"); File.AppendAllText("./skyblockX/skyblockX.txt", "是否允许桶点黑曜石变为岩浆:true\n是否开启重生惩罚:false\n是否自动清理:false\n自动清理间隔:10\nstart_x:0\nstart_y:0\nstart_z:0\nend_x:0\nend_y:0\nend_z:0\nx_max:5000\nz_max:5000", System.Text.Encoding.Default); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]未检查到配置文件!将自动创建!"); Console.ForegroundColor = ConsoleColor.White; } int ktime = 60000 * cleartime; if (File.Exists("./skyblockX/islands")) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]数据读取成功成功!"); Console.ForegroundColor = ConsoleColor.White; } else { try { System.IO.Directory.CreateDirectory("./skyblockX/islands"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]文件夹创建成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]文件夹创建失败!"); Console.ForegroundColor = ConsoleColor.White; } } if (File.Exists("./skyblockX/spawns")) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]数据读取成功成功!"); Console.ForegroundColor = ConsoleColor.White; } else { try { System.IO.Directory.CreateDirectory("./skyblockX/spawns"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]文件夹创建成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]文件夹创建失败!"); Console.ForegroundColor = ConsoleColor.White; } } if (File.Exists(qdpath)) { } else { try { System.IO.Directory.CreateDirectory(qdpath); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]文件夹创建成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]文件夹创建失败!"); Console.ForegroundColor = ConsoleColor.White; Directory.CreateDirectory(qdpath); } } if (File.Exists("./SkyBlockXeula.txt")) { try { string[] config = File.ReadAllLines("./SkyBlockXeula.txt", System.Text.Encoding.Default); eula = config[0].Substring(5); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]eula协议读取成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]eula协议读取失败!"); Console.ForegroundColor = ConsoleColor.White; } } else { File.AppendAllText("./SkyBlockXeula.txt", "eula=false\nAugust 2020 SkyBlockX Release.\nThanks for using SkyBlockX.\n一条重要规定是除非Sbaoor明确同意,\n否则您不得分发使用SkyBlockX创建的任何内容。\n\"分发使用SkyBlockX创建的任何内容\"是指:\n1.向任何其他人提供使用SkyBlockX的服务端整合包;\n2.将SkyBlockX用于商业用途;\n3.试图通过SkyBlockX创建的任何内容赚钱;\n如果您同意了eula协定,\n这代表您已被授予使用的许可,\n因此您可以在自己的服务端上使用它。\n", System.Text.Encoding.Default); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]未检查到eula文件!将自动创建!"); Console.ForegroundColor = ConsoleColor.White; } if (eula != "true") { while (true) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyblockX]请同意用户协议"); Console.ForegroundColor = ConsoleColor.White; Console.ReadKey(); } } Dictionary <string, string> uuid = new Dictionary <string, string>(); api.addAfterActListener(EventKey.onLoadName, x => { var a = BaseEvent.getFrom(x) as LoadNameEvent; uuid.Add(a.playername, a.uuid); return(true); }); api.addBeforeActListener(EventKey.onPlayerLeft, x => { var a = BaseEvent.getFrom(x) as PlayerLeftEvent; uuid.Remove(a.playername); return(true); }); api.addBeforeActListener(EventKey.onUseItem, x => { var a = BaseEvent.getFrom(x) as UseItemEvent; string obsidian = "minecraft:obsidian"; string Bucket = "Bucket"; //Console.WriteLine("{0} {1}", a.blockname, a.itemname); if (a.blockname == obsidian & a.itemname == Bucket & a.dimensionid == 0 & _ifobsition == "true") { api.runcmd("setblock " + a.position.x + " " + a.position.y + " " + a.position.z + " flowing_lava"); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3已帮你恢复岩浆!\"}]}"); } if (a.blockname == obsidian & a.itemname == Bucket & a.dimensionid == 0 & _ifobsition == "false") { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3岩浆还原已被禁用!\"}]}"); } if (a.blockname == obsidian & a.itemname == Bucket & a.dimensionid == 0 & _ifobsition != "false" & _ifobsition != "true") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]配置文件填写错误!请检查是否允许岩浆还原项!"); Console.ForegroundColor = ConsoleColor.White; } return(true); }); api.addBeforeActListener(EventKey.onRespawn, x => { var a = BaseEvent.getFrom(x) as RespawnEvent; if (_ifrespawnpunish == "true") { api.runcmd("effect " + a.playername + " hunger 4 225 true"); } if (_ifrespawnpunish == "false") { } if (_ifrespawnpunish != "false" & _ifrespawnpunish != "true") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]配置文件填写错误!请检查是否重生惩罚项!"); Console.ForegroundColor = ConsoleColor.White; } return(true); }); api.addBeforeActListener(EventKey.onInputCommand, x => { var a = BaseEvent.getFrom(x) as InputCommandEvent; string ispath = "./skyblockx/islands/" + a.playername + ".txt"; string sppath = "./skyblockX/spawns/" + a.playername + ".txt"; if (a.cmd.StartsWith("/is")) { string iscommand = string.Empty; iscommand = a.cmd.Substring(4); if (iscommand == "creative") { if (File.Exists(ispath)) { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3你已经创建过了!!\"}]}"); return(false); } else { Random ran = new Random(); int n = ran.Next(0, x_max); int z = ran.Next(0, z_max); api.runcmd("tp \"" + a.playername + "\" " + n + " 100 " + z); api.runcmd("effect \"" + a.playername + "\" slow_falling 10 5 true"); StreamWriter writer = new StreamWriter(ispath); writer.Write(string.Concat("坐标:" + n + " 70 " + z, Environment.NewLine)); writer.Close(); //Thread.Sleep(5000); var t = Task.Run(async delegate { await Task.Delay(3000); api.runcmd("clone " + start_x + " " + start_y + " " + start_z + " " + end_x + " " + end_y + " " + end_z + " " + n + " 50 " + z); return(42); }); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3创建成功!\"}]}"); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3请用/is go来保存你的传送点!\"}]}"); return(false); } } if (iscommand == "go") { if (File.Exists(sppath)) { string[] config = File.ReadAllLines(sppath, System.Text.Encoding.Default); int sp_x = int.Parse(config[0].Substring(2)); int sp_y = int.Parse(config[1].Substring(2)); int sp_z = int.Parse(config[2].Substring(2)); api.teleport(uuid[a.playername], sp_x, sp_y, sp_z, 0); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3传送成功!\"}]}"); return(false); } else { StreamWriter writer = new StreamWriter(sppath); int intx = Convert.ToInt32(a.XYZ.x); int inty = Convert.ToInt32(a.XYZ.y); int intz = Convert.ToInt32(a.XYZ.z); writer.Write(string.Concat("x:" + intx, Environment.NewLine)); writer.Write(string.Concat("y:" + inty, Environment.NewLine)); writer.Write(string.Concat("z:" + intz, Environment.NewLine)); writer.Close(); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3已保存空岛传送点!\"}]}"); return(false); } } if (iscommand == "goreset") { StreamWriter writer = new StreamWriter(sppath); int intx = Convert.ToInt32(a.XYZ.x); int inty = Convert.ToInt32(a.XYZ.y); int intz = Convert.ToInt32(a.XYZ.z); writer.Write(string.Concat("x:" + intx, Environment.NewLine)); writer.Write(string.Concat("y:" + inty, Environment.NewLine)); writer.Write(string.Concat("z:" + intz, Environment.NewLine)); writer.Close(); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3已重置空岛传送点!\"}]}"); return(false); } if (iscommand == "clear") { var b = Tools.Player.getPlayerAbilities(api, uuid[a.playername]); if (b.op == "true") { var t = Task.Run(async delegate { api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3还有10秒就要清理掉落物品了!\"}]}"); await Task.Delay(10000); api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3清理完毕!\"}]}"); api.runcmd("kill @e[type=item]"); return(42); }); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3权限不足!\"}]}"); } return(false); } if (iscommand == "sign") { string grqdpath = "./skyblockX/sign/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.DayOfYear.ToString() + "/" + a.playername + ".txt"; if (File.Exists(qdjlpath)) { if (File.Exists(grqdpath)) { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3你签到过了!\"}]}"); return(false); } else { if (File.Exists(qdpath)) { string[] config = File.ReadAllLines(qdjlpath, System.Text.Encoding.Default); qdjl = config[0].Substring(5); if (qdjl != null) { api.runcmd("execute \"" + a.playername + "\" ~~~ " + qdjl); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3签到成功!\"}]}"); StreamWriter writer = new StreamWriter(grqdpath); writer.Write(string.Concat(DateTime.Now.ToString("hh:mm:ss"), Environment.NewLine)); writer.Close(); return(false); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3你的服主还没设置签到奖励!\"}]}"); return(false); } } else { Directory.CreateDirectory("./skyblockX/sign/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.DayOfYear.ToString()); string[] config = File.ReadAllLines(qdjlpath, System.Text.Encoding.Default); qdjl = config[0].Substring(5); if (qdjl != null) { api.runcmd("execute \"" + a.playername + "\" ~~~ " + qdjl); api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3签到成功!\"}]}"); StreamWriter writer = new StreamWriter(grqdpath); writer.Write(string.Concat(DateTime.Now.ToString("hh:mm:ss"), Environment.NewLine)); writer.Close(); return(false); } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3你的服主还没设置签到奖励!\"}]}"); return(false); } } } } else { api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3你的服主还没设置签到奖励!\"}]}"); Directory.CreateDirectory("/skyblockX/sign"); File.AppendAllText(qdjlpath, "签到奖励:", System.Text.Encoding.Default); return(false); } } } return(true); }); if (_ifautoclear == "true") { Task.Run(() => { while (true) { Thread.Sleep(ktime); api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3还有10秒就要清理掉落物品了!\"}]}"); Thread.Sleep(10000); api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3清理完毕!\"}]}"); api.runcmd("kill @e[type=item]"); } }); } api.addBeforeActListener(EventKey.onServerCmd, x => { var commandinput = BaseEvent.getFrom(x) as ServerCmdEvent; if (commandinput.cmd == "skyreload") { try { string[] config = File.ReadAllLines("./skyblockX/skyblockX.txt", System.Text.Encoding.Default); _ifobsition = config[0].Substring(14); _ifrespawnpunish = config[1].Substring(9); _ifautoclear = config[2].Substring(7); cleartime = int.Parse(config[3].Substring(7)); start_x = int.Parse(config[4].Substring(8)); start_y = int.Parse(config[5].Substring(8)); start_z = int.Parse(config[6].Substring(8)); end_x = int.Parse(config[7].Substring(6)); end_y = int.Parse(config[8].Substring(6)); end_z = int.Parse(config[9].Substring(6)); x_max = int.Parse(config[10].Substring(6)); z_max = int.Parse(config[11].Substring(6)); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[SkyBlockX]配置文件读取成功!"); Console.ForegroundColor = ConsoleColor.White; } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[SkyBlockX]配置文件读取失败!"); Console.ForegroundColor = ConsoleColor.White; } return(false); } if (commandinput.cmd == "stop") { Task.Run(() => { while (true) { api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3还有30秒就要关服了!\"}]}"); Thread.Sleep(10000); api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3还有20秒就要关服了!\"}]}"); Thread.Sleep(10000); api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"§3还有10秒就要关服了!\"}]}"); Thread.Sleep(10000); api.runcmd("stop"); } }); return(false); } return(true); }); }