Ejemplo n.º 1
0
        // 主入口实现
        public static void init(MCCSAPI api)
        {
            mapi = api;

            string[] bts = null;
            if (!api.COMMERCIAL)
            {
                bts = new string[] {
                    "后台指令tell",
                    "前缀/去前缀名",
                    "模拟喊话",
                    "模拟执行me指令",
                    "后台指令输出hello",
                    "查询当前状态至后台",
                    "给32个白桦木",
                    "断开自身连接"
                };
            }
            else
            {
                bts = new string[] {
                    "后台指令tell",
                    "前缀/去前缀名",
                    "模拟喊话",
                    "模拟执行me指令",
                    "后台指令输出hello",
                    "查询当前状态至后台",
                    "给32个白桦木",
                    "断开自身连接",                                                           // 以下是非社区版内容
                    "穿墙能力开/关",
                    "传送至梦之故里大厅",
                    "跨维传送至末地祭坛",
                    "读当前属性值至后台",
                    "临时攻击+10,生命+2,附命+2,抗飞+1,等级+5,食物+2",
                    "读属性上限值至后台",
                    "攻限+10,命限+10,食限+10",
                    "读当前选中物品至后台",
                    "给1个附魔叉",
                    "替换副手为一个叉子",
                    "保存玩家所有物品列表至pit.json并清空",
                    "读pit.json到当前玩家",
                    "读玩家当前效果列表到后台",
                    "设置玩家临时存储的效果列表",
                    "显示欢迎一个血条",
                    "清除欢迎血条",
                    "显示一个带统计的自定义侧边栏",
                    "移除自定义侧边栏",
                    "读当前权限与游戏模式至后台",
                    "切换op/visitor,生存/生存观察者模式",
                    "导出当前位置+长宽高x10的结构到st1.json",
                    "读结构st1.json到当前位置"
                };
            }

            var a = new ArrayList(bts);

            // 设置指令描述
            api.setCommandDescribeEx("testcase", "开始一个测试用例", MCCSAPI.CommandPermissionLevel.GameMasters,
                                     (byte)MCCSAPI.CommandCheatFlag.NotCheat, 0);
            // 添加测试指令监听
            api.addBeforeActListener(EventKey.onInputCommand, x => {
                var e = BaseEvent.getFrom(x) as InputCommandEvent;
                if (e.cmd.Trim() == "/testcase")
                {
                    // 此处执行拦截操作
                    string uuid = getUUUD(e.playername);
                    var gui     = new SimpleGUI(api, uuid, "测试用例", "请于30秒内选择测试用例进行测试:",
                                                a);
                    gui.send(30000, selected => {
                        switch (selected)
                        {
                        case "0":
                            api.runcmd("tell \"" + e.playername + "\" 你好 c# !");
                            break;

                        case "1":
                            {
                                string r = e.playername;
                                r        = (r.IndexOf("[前缀]") >= 0 ? r.Substring(4) : "[前缀]" + r);
                                api.reNameByUuid(uuid, r);
                            }
                            break;

                        case "2":
                            api.talkAs(uuid, "你好 c# !");
                            break;

                        case "3":
                            api.runcmdAs(uuid, "/me 你好 c# !");
                            break;

                        case "4":
                            api.logout("logout: 你好 c# !");
                            break;

                        case "5":
                            Console.WriteLine(api.selectPlayer(uuid));
                            break;

                        case "6":
                            api.addPlayerItem(uuid, 17, 2, 32);
                            break;

                        case "7":
                            api.disconnectClient(uuid, "这个消息来自测试");
                            break;
                            #region 以下部分为非社区版内容

                        case "8":
                            {
                                string sa = api.getPlayerAbilities(uuid);
                                if (!string.IsNullOrEmpty(sa))
                                {
                                    var ser = new JavaScriptSerializer();
                                    var ja  = ser.Deserialize <Dictionary <string, object> >(sa);
                                    var cja = new Dictionary <string, object>();
                                    object nnoclip;
                                    if (ja.TryGetValue("noclip", out nnoclip))
                                    {
                                        cja["noclip"] = !((bool)nnoclip);
                                    }
                                    api.setPlayerAbilities(uuid, ser.Serialize(cja));
                                }
                            }
                            break;

                        case "9":
                            api.transferserver(uuid, "www.xiafox.com", 19132);
                            break;

                        case "10":
                            api.teleport(uuid, 10, 99, 10, 2);
                            break;

                        case "11":
                            api.logout(api.getPlayerAttributes(uuid));
                            break;

                        case "12":
                            {
                                var sa = api.getPlayerAttributes(uuid);
                                if (!string.IsNullOrEmpty(sa))
                                {
                                    var ser = new JavaScriptSerializer();
                                    var ja  = ser.Deserialize <Dictionary <string, object> >(sa);
                                    var cja = new Dictionary <string, object>();
                                    object atdmg;
                                    if (ja.TryGetValue("attack_damage", out atdmg))
                                    {
                                        cja["attack_damage"] = Convert.ToSingle(atdmg) + 10;
                                    }
                                    if (ja.TryGetValue("absorption", out atdmg))
                                    {
                                        cja["absorption"] = Convert.ToSingle(atdmg) + 2;
                                    }
                                    if (ja.TryGetValue("health", out atdmg))
                                    {
                                        cja["health"] = Convert.ToSingle(atdmg) + 2;
                                    }
                                    if (ja.TryGetValue("knockback_resistance", out atdmg))
                                    {
                                        cja["knockback_resistance"] = Convert.ToSingle(atdmg) + 1;
                                    }
                                    if (ja.TryGetValue("level", out atdmg))
                                    {
                                        cja["level"] = Convert.ToSingle(atdmg) + 5;
                                    }
                                    if (ja.TryGetValue("hunger", out atdmg))
                                    {
                                        cja["hunger"] = Convert.ToSingle(atdmg) + 2;
                                    }
                                    api.setPlayerTempAttributes(uuid, ser.Serialize(cja));
                                }
                            }
                            break;

                        case "13":
                            api.logout(api.getPlayerMaxAttributes(uuid));
                            break;

                        case "14":
                            {
                                var sa = api.getPlayerMaxAttributes(uuid);
                                if (!string.IsNullOrEmpty(sa))
                                {
                                    var ser = new JavaScriptSerializer();
                                    var ja  = ser.Deserialize <Dictionary <string, object> >(sa);
                                    var cja = new Dictionary <string, object>();
                                    object dmg;
                                    if (ja.TryGetValue("maxattack_damage", out dmg))
                                    {
                                        cja["maxattack_damage"] = Convert.ToSingle(dmg) + 10;
                                    }
                                    if (ja.TryGetValue("maxhealth", out dmg))
                                    {
                                        cja["maxhealth"] = Convert.ToSingle(dmg) + 10;
                                    }
                                    if (ja.TryGetValue("maxhunger", out dmg))
                                    {
                                        cja["maxhunger"] = Convert.ToSingle(dmg) + 10;
                                    }
                                    api.setPlayerMaxAttributes(uuid, ser.Serialize(cja));
                                }
                            }
                            break;

                        case "15":
                            api.logout(api.getPlayerSelectedItem(uuid));
                            break;

                        case "16":
                            {
                                // tt - TAG_TYPE		标签数据类型,总计11种类型
                                // tv - TAG_VALUE		标签值,由类型决定
                                // ck - Compound_KEY	nbt关键字,字符串类型
                                // cv - Compound_VALUE	nbt值,总是为一个TAG
                                var jitem = "{" +
                                            "\"tt\": 10, \"tv\": [" +
                                            "{ \"ck\": \"Count\", \"cv\": { \"tt\": 1, \"tv\": 1 } }," +
                                            "{ \"ck\": \"Damage\", \"cv\": { \"tt\": 2, \"tv\": 0 } }," +
                                            "{ \"ck\": \"Name\", \"cv\": { \"tt\": 8, \"tv\": \"minecraft:trident\" } }," +
                                            "{ \"ck\": \"tag\", \"cv\": { \"tt\": 10, \"tv\": [" +
                                            "{ \"ck\": \"ench\", \"cv\": { \"tt\": 9, \"tv\": [" +
                                            "{ \"tt\": 10, \"tv\": [" +
                                            "{ \"ck\": \"id\", \"cv\": { \"tt\": 2, \"tv\": 10 } }," +
                                            "{ \"ck\": \"lvl\", \"cv\": { \"tt\": 2, \"tv\": 9999 } }]" +
                                            "}]}" +
                                            "}]}" +
                                            "}]" +
                                            "}";
                                api.addPlayerItemEx(uuid, jitem);
                            }
                            break;

                        case "17":
                            {
                                var jtem = "{" +
                                           "\"Offhand\": { \"tt\": 9, \"tv\": [" +
                                           "{ \"tt\": 10, \"tv\": [" +
                                           "{ \"ck\": \"Count\", \"cv\": { \"tt\": 1, \"tv\": 1 } }," +
                                           "{ \"ck\": \"Damage\", \"cv\": { \"tt\": 2, \"tv\": 0 } }," +
                                           "{ \"ck\": \"Name\", \"cv\": { \"tt\": 8, \"tv\": \"minecraft:trident\" } }," +
                                           "{ \"ck\": \"tag\", \"cv\": { \"tt\": 10, \"tv\": [" +
                                           "{ \"ck\": \"ench\", \"cv\": {" +
                                           "\"tt\": 9, \"tv\": [" +
                                           "{ \"tt\": 10, \"tv\": [" +
                                           "{ \"ck\": \"id\", \"cv\": { \"tt\": 2, \"tv\": 7 } }," +
                                           "{ \"ck\": \"lvl\", \"cv\": { \"tt\": 2, \"tv\": 8888 } }]" +
                                           "}]}" +
                                           "}]}" +
                                           "}]" +
                                           "}]}" +
                                           "}";
                                api.setPlayerItems(uuid, jtem);
                            }
                            break;

                        case "18":
                            {
                                var its = api.getPlayerItems(uuid);
                                File.WriteAllText("pit.json", its);
                                // 此处使用空气填充末影箱
                                var sair = "{\"tt\":10,\"tv\":[{\"ck\":\"Count\",\"cv\":{\"tt\":1,\"tv\":0}},{\"ck\":\"Damage\",\"cv\":{\"tt\":2,\"tv\":0}},{\"ck\":\"Name\"" + ",\"cv\":{\"tt\":8,\"tv\":\"\"}},{\"ck\":\"Slot\",\"cv\":{\"tt\":1,\"tv\":0}}]}";
                                //let air = { "tt": 10, "tv": [{ "ck": "Count", "cv": { "tt": 1, "tv": 0 } }, { "ck": "Damage", "cv": { "tt": 2, "tv": 0 } }, { "ck": "Name", "cv": { "tt": 8, "tv": "" } }, { "ck": "Slot", "cv": { "tt": 1, "tv": 0 } }] };

                                var endc    = new Dictionary <string, object>();
                                var eci     = new Dictionary <string, object>();
                                var edclist = new ArrayList();
                                eci["tt"]   = 9;
                                var ser     = new JavaScriptSerializer();
                                for (int i = 0; i < 27; i++)
                                {
                                    var mair = ser.Deserialize <Dictionary <string, object> >(sair);
                                    if (((Dictionary <string, object>)(((ArrayList)(mair["tv"]))[3]))["ck"].ToString() == "Slot")                                                       // 此处需修改并应用
                                    {
                                        ((Dictionary <string, object>)(((Dictionary <string, object>)(((ArrayList)(mair["tv"]))[3]))["cv"]))["tv"] = i;
                                    }
                                    edclist.Add(mair);
                                }
                                eci["tv"] = edclist;
                                endc["EnderChestInventory"] = eci;
                                api.setPlayerItems(uuid, ser.Serialize(endc));
                                api.runcmd("clear \"" + e.playername + "\"");
                            }
                            break;

                        case "19":
                            {
                                try {
                                    var its = File.ReadAllText("pit.json");
                                    if (its != null)
                                    {
                                        api.setPlayerItems(uuid, its);
                                    }
                                } catch {
                                }
                            }
                            break;

                        case "20":
                            {
                                var efs = api.getPlayerEffects(uuid);
                                tmpeff  = efs;
                                Console.WriteLine(efs);
                            }
                            break;

                        case "21":
                            api.setPlayerEffects(uuid, tmpeff);
                            break;

                        case "22":
                            api.setPlayerBossBar(uuid, "欢迎使用NetRunner自定义血条!", ((float)(new Random().Next() % 1001)) / 1000.0f);
                            break;

                        case "23":
                            api.removePlayerBossBar(uuid);
                            break;

                        case "24":
                            {
                                int count = 0;
                                if (!sidecount.TryGetValue(uuid, out count))
                                {
                                    sidecount[uuid] = 0;
                                }
                                ++sidecount[uuid];
                                var ser  = new JavaScriptSerializer();
                                var list = new List <object>();
                                list.Add("第" + sidecount[uuid] + "次打开侧边栏    ");
                                list.Add("这是第二行 ");
                                list.Add("这是下一行 ");
                                list.Add("属性:[待填写] ");
                                list.Add("§e颜色自拟 ");
                                api.setPlayerSidebar(uuid, e.playername + "的侧边栏", ser.Serialize(list));
                            }
                            break;

                        case "25":
                            api.removePlayerSidebar(uuid);
                            break;

                        case "26":
                            Console.WriteLine(api.getPlayerPermissionAndGametype(uuid));
                            break;

                        case "27":
                            {
                                var st  = api.getPlayerPermissionAndGametype(uuid);
                                var ser = new JavaScriptSerializer();
                                var t   = ser.Deserialize <Dictionary <string, object> >(st);
                                if (t != null)
                                {
                                    t["gametype"]   = (int)(t["gametype"]) == 0 ? 3 : 0;
                                    t["permission"] = (int)(t["permission"]) == 0 ? 2 : 0;
                                    api.setPlayerPermissionAndGametype(uuid, ser.Serialize(t));
                                }
                            }
                            break;

                        case "28":
                            {
                                var posa = e.XYZ;
                                var ser  = new JavaScriptSerializer();
                                var posb = new Vec3();
                                posb.x   = posa.x + 10;
                                posb.y   = posa.y + 10;
                                posb.z   = posa.z + 10;
                                var data = api.getStructure(e.dimensionid, ser.Serialize(posa), ser.Serialize(posb), false, true);
                                File.WriteAllText("st1.json", data);
                            }
                            break;

                        case "29":
                            try {
                                var data = File.ReadAllText("st1.json");
                                var ser  = new JavaScriptSerializer();
                                api.setStructure(data, e.dimensionid, ser.Serialize(e.XYZ), 0, true, true);
                            } catch {
                            }
                            break;

                            #endregion
                        case "null":
                            Console.WriteLine("玩家 " + e.playername + " 主动取消了一个表单项。", gui.id);
                            break;
                        }
                    },
                             () => Console.WriteLine("[testcase] 玩家 " + e.playername + " 表单已超时,id={0}", gui.id));
                    return(false);
                }
                return(true);
            });
            // 离开监听
            api.addAfterActListener(EventKey.onPlayerLeft, x => {
                var e = BaseEvent.getFrom(x) as PlayerLeftEvent;
                string uuid;
                if (nameuuids.TryGetValue(e.playername, out uuid))
                {
                    nameuuids.Remove(e.playername);
                }
                return(true);
            });
        }
Ejemplo n.º 2
0
        public static void Dracoup(MCCSAPI api)
        {
            Dictionary <string, int>    level    = new Dictionary <string, int>();    //等级
            Dictionary <string, double> addition = new Dictionary <string, double>(); //加成值
            Dictionary <string, string> uuid     = new Dictionary <string, string>(); //uuid
            Dictionary <string, string> xuid     = new Dictionary <string, string>(); //xuid
            Dictionary <string, string> job      = new Dictionary <string, string>(); //职业
            Dictionary <string, string> ifban    = new Dictionary <string, string>(); //是否为黑名单
            string MoneyPath   = "./plugins/Draco/RewardMoney.yaml";
            string playersPath = "./plugins/Draco/playersjob.yaml";
            string banPath     = "./plugins/Draco/banplayers.yaml";

            #region //yaml转json示例
            //if (File.Exists("./plugins/Draco/config.yaml"))
            //{
            //    var r = new StringReader(File.ReadAllText("./plugins/Draco/config.yaml"));
            //    var deserializer = new DeserializerBuilder().Build();
            //    var yamlObject = deserializer.Deserialize(r);
            //    var serializer = new SerializerBuilder()
            //        .JsonCompatible()
            //        .Build();
            //    var json = serializer.Serialize(yamlObject);
            //    //Console.WriteLine(json);
            //    config rb = JsonConvert.DeserializeObject<config>(json);
            //    Console.WriteLine("是否开启攻击加成:"+rb.ATNPlus);
            //}
            #endregion
            string awa = @"September 2020 Draco Release.
Thanks for using Draco.
本插件基于Mozilla协议开源
项目地址:
https://github.com/Sbaoor-fly/CSR-Draco
Mozilla协议具体信息:
http://www.mozilla.org/MPL/MPL-1.1.html
特别感谢在内测时对本插件反馈的用户
- 《威尼斯:自由时代》服务器全体成员
- PHP野兽先辈服务器全体成员
- xuWin
- wzy
- SnowPea8027
";

            if (File.Exists("./plugins/Draco/Draco.txt"))
            {
            }
            else
            {
                DialogResult dr = MessageBox.Show("您正在使用公测版的Draco\t\n如果发现bug或想贡献宝贵的建议\t\n请加群反馈:514160938\t\n如果选择“是”,代表您同意我们的服务条款", "Draco", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                //如果消息框返回值是Yes,显示新窗体
                if (dr == DialogResult.Yes)
                {
                }
                //如果消息框返回值是No,关闭当前窗体
                else if (dr == DialogResult.No)
                {
                    //关闭当前窗体
                    var a = File.ReadAllLines("./awa,txt");
                }
                //创建文件和文件夹
                Directory.CreateDirectory("./plugins/Draco");
                File.AppendAllText(banPath, "#格式 玩家ID: 被ban原因", System.Text.Encoding.UTF8);
                File.AppendAllText(playersPath, "Steve: Miner", System.Text.Encoding.Default);
                File.AppendAllText(MoneyPath, "DeBug: false\ncow: 10", System.Text.Encoding.Default);
                File.AppendAllText("./plugins/Draco/Draco.txt", awa, System.Text.Encoding.Default);
                Directory.CreateDirectory("./plugins/Draco/Miner");
                Directory.CreateDirectory("./plugins/Draco/Hunter");
                Directory.CreateDirectory("./plugins/Draco/Swordman");
                Directory.CreateDirectory("./plugins/Draco/Sorcerer");
                var t = Task.Run(async delegate
                {
                    await Task.Delay(10000);
                    api.runcmd("scoreboard objectives add money dummy");
                });
            }
            api.addBeforeActListener(EventKey.onLoadName, x =>
            {
                var a = BaseEvent.getFrom(x) as LoadNameEvent;
                uuid.Add(a.playername, a.uuid);
                xuid.Add(a.playername, a.xuid);
                YML banyml = new YML(banPath);
                if (banyml.read(a.playername, "") != null)
                {
                    ifban.Add(a.playername, "true");
                }
                else
                {
                    ifban.Add(a.playername, "false");
                }
                YML plyml = new YML(playersPath);
                if (plyml.read(a.playername, "") != null)
                {
                    if (File.Exists("./plugins/Draco/" + plyml.read(a.playername, "") + "/" + xuid[a.playername] + ".json"))
                    {
                        var jsontext    = File.ReadAllText("./plugins/Draco/" + plyml.read(a.playername, "") + "/" + xuid[a.playername] + ".json");
                        Playerconfig rb = JsonConvert.DeserializeObject <Playerconfig>(jsontext);
                        addition.Add(a.playername, rb.Addition);
                        job.Add(a.playername, rb.job);
                        level.Add(a.playername, rb.level);
                        Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Draco] 配置文件读取成功!");
                    }
                    else
                    {
                        Playerconfig write = new Playerconfig
                        {
                            Addition = 0.1,
                            Name     = a.playername,
                            level    = 1,
                            job      = plyml.read(a.playername, "")
                        };
                        string str = JsonConvert.SerializeObject(write);
                        File.WriteAllText("./plugins/Draco/" + plyml.read(a.playername, "") + "/" + xuid[a.playername] + ".json", str, System.Text.Encoding.Default);
                        level.Add(a.playername, 1);
                        addition.Add(a.playername, 0.1);
                        job.Add(a.playername, plyml.read(a.playername, ""));
                        Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Draco] 配置文件创建成功!");
                    }
                }
                else
                {
                    job.Add(a.playername, "无职业");
                    level.Add(a.playername, 0);
                    //防止聊天调用等级和职业时崩服
                    Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Draco] {0}进入了游戏", a.playername);
                }
                return(true);
            });
            api.addBeforeActListener(EventKey.onRespawn, x =>
            {
                YML banyml2 = new YML(banPath);
                var a       = BaseEvent.getFrom(x) as RespawnEvent;
                if (ifban[a.playername] == "true")
                {
                    api.runcmd("kick " + a.playername + " " + banyml2.read(a.playername, ""));
                }
                else
                {
                    if (job[a.playername] == "无职业")
                    {
                        var t = Task.Run(async delegate
                        {
                            await Task.Delay(3000);
                            api.sendSimpleForm(uuid[a.playername], "职业选择", "请选择", "[\"剑士\",\"猎手\",\"矿工\",\"法师\"]");
                            api.addBeforeActListener(EventKey.onFormSelect, y =>
                            {
                                var pp = BaseEvent.getFrom(y) as FormSelectEvent;
                                if (job[a.playername] == "无职业")
                                {
                                    if (!string.IsNullOrEmpty(pp.selected))
                                    {
                                        string[] jobid = { "Swordman", "Hunter", "Miner", "Sorcerer" };
                                        int jjob       = Convert.ToInt32(pp.selected);
                                        File.AppendAllText(playersPath, "\n" + a.playername + ": " + jobid[jjob], System.Text.Encoding.UTF8);
                                        //api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§6职业选择成功!会在下次进入游戏时生效!\"}]}");
                                        api.runcmd("kick \"" + a.playername + "\" 请重新登录!");
                                    }
                                    else
                                    {
                                        api.runcmd("kick \"" + a.playername + "\" 你必须有一个职业!");
                                    }
                                }
                                return(true);
                            });
                        });
                    }
                    int b = api.getscoreboard(uuid[a.playername], "money");
                    api.setPlayerSidebar(uuid[a.playername], "个人信息", "[\"玩家名称:" + a.playername + "\",\"职业:" + job[a.playername] + "\",\"等级:" + level[a.playername] + "\",\"金币:" + b + "\"]");
                    int ti = 0;
                    if (level[a.playername] < 50 & level[a.playername] >= 20)
                    {
                        ti = 1;
                    }
                    if (level[a.playername] > 50)
                    {
                        ti = 2;
                    }
                    if (job[a.playername] == "Miner" & ti != 0)
                    {
                        api.runcmd("effect \"" + a.playername + "\" night_version 9999999 " + ti + " true");
                    }
                    if (job[a.playername] == "Swordman" & ti != 0)
                    {
                        api.runcmd("effect \"" + a.playername + "\" resistance 9999999 " + ti + " true");
                    }
                    if (job[a.playername] == "Sorcerer" & ti != 0)
                    {
                        api.runcmd("effect \"" + a.playername + "\" fire_resistance 9999999 " + ti + " true");
                    }
                }
                return(true);
            });
            api.addBeforeActListener(EventKey.onPlayerLeft, x =>
            {
                var a = BaseEvent.getFrom(x) as PlayerLeftEvent;
                level.Remove(a.playername);
                addition.Remove(a.playername);
                uuid.Remove(a.playername);
                xuid.Remove(a.playername);
                job.Remove(a.playername);
                ifban.Remove(a.playername);
                Console.WriteLine("[Draco]{0}离开了游戏,正在保存数据", a.playername);
                return(true);
            });
            api.addBeforeActListener(EventKey.onAttack, x =>
            {
                var a = BaseEvent.getFrom(x) as AttackEvent;
                if (job[a.playername] == "Swordman")
                {
                    int ti = 1;
                    if (level[a.playername] < 20)
                    {
                        ti = 1;
                    }
                    if (level[a.playername] < 50 & level[a.playername] >= 20)
                    {
                        ti = 2;
                    }
                    if (level[a.playername] > 50)
                    {
                        ti = 3;
                    }
                    Random r = new Random();
                    if (r.Next(100) < level[a.playername] * 2)//随机概率
                    {
                        try
                        {
                            if (Convert.ToInt32(level[a.playername] * addition[a.playername]) != 0)
                            {
                                api.runcmd("effect \"" + a.playername + "\" strength " + Convert.ToInt32(level[a.playername] * addition[a.playername]) + " " + ti + " true");
                            }
                        }
                        catch { Console.WriteLine("WARNING!!!"); }
                    }
                }
                return(true);
            });
            api.addBeforeActListener(EventKey.onDestroyBlock, x =>
            {
                var a = BaseEvent.getFrom(x) as DestroyBlockEvent;
                if (job[a.playername] == "Miner")
                {
                    int ti = 1;
                    if (level[a.playername] < 20)
                    {
                        ti = 1;
                    }
                    if (level[a.playername] < 50 & level[a.playername] >= 20)
                    {
                        ti = 2;
                    }
                    if (level[a.playername] > 50)
                    {
                        ti = 3;
                    }
                    Random r = new Random();
                    if (r.Next(100) < level[a.playername] * 2)
                    {
                        try
                        {
                            if (Convert.ToInt32(level[a.playername] * addition[a.playername]) != 0) //防止0级
                            {
                                api.runcmd("effect \"" + a.playername + "\" haste " + Convert.ToInt32(level[a.playername] * addition[a.playername]) + " " + ti + " true");
                            }
                        }
                        catch { Console.WriteLine("WARNING!!!"); }
                    }
                }
                return(true);
            });
            api.addBeforeActListener(EventKey.onMobDie, x =>
            {
                var a           = BaseEvent.getFrom(x) as MobDieEvent;
                string str      = a.mobtype;
                string[] sArray = str.Split(new char[2] {
                    '.', '.'
                });
                YML yml = new YML(MoneyPath);
                if (yml.read("DeBug", "") == "true")
                {
                    Console.WriteLine(sArray[1]);
                }                                                                      //是否在控制台输出
                if (yml.read(sArray[1], "") != null & a.srcname != "")
                {
                    api.runcmd("scoreboard players add \"" + a.srcname + "\" money " + yml.read(sArray[1], ""));
                    api.runcmd("tellraw \"" + a.srcname + "\" {\"rawtext\":[{\"text\":\"§6击杀奖励" + yml.read(sArray[1], "") + "金币!\"}]}");
                    int z = api.getscoreboard(uuid[a.srcname], "money");
                    api.removePlayerSidebar(uuid[a.srcname]);
                    api.setPlayerSidebar(uuid[a.srcname], "个人信息", "[\"玩家名称:" + a.srcname + "\",\"职业:" + job[a.srcname] + "\",\"等级:" + level[a.srcname] + "\",\"金币:" + z + "\"]");
                    if (job[a.srcname] == "Hunter") //猎手加成
                    {
                        int ti = 1;
                        if (level[a.srcname] < 20)
                        {
                            ti = 5;
                        }
                        if (level[a.srcname] < 50 & level[a.srcname] >= 20)
                        {
                            ti = 3;
                        }
                        if (level[a.srcname] > 50)
                        {
                            ti = 2;
                        }
                        int b = Convert.ToInt32(yml.read(sArray[1], "")) / ti;
                        if (b != 0)
                        {
                            api.runcmd("scoreboard players add \"" + a.srcname + "\" money " + b);
                            api.runcmd("tellraw \"" + a.srcname + "\" {\"rawtext\":[{\"text\":\"[§3猎手加成§r]§6 额外奖励" + b + "金币!\"}]}");
                            var t = Task.Run(async delegate
                            {
                                await Task.Delay(500);
                                int v = api.getscoreboard(uuid[a.srcname], "money");
                                api.removePlayerSidebar(uuid[a.srcname]);
                                api.setPlayerSidebar(uuid[a.srcname], "个人信息", "[\"玩家名称:" + a.srcname + "\",\"职业:" + job[a.srcname] + "\",\"等级:" + level[a.srcname] + "\",\"金币:" + v + "\"]");
                            });
                        }
                    }
                }
                return(true);
            });
            api.addBeforeActListener(EventKey.onInputText, x =>
            {
                var a          = BaseEvent.getFrom(x) as InputTextEvent;
                string[] diam  = { "§2主世界", "§4地狱", "§e末地" };
                string[] diam2 = { "主世界", "地狱", "末地" };
                if (a.msg == "here")
                {
                    api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"[" + diam[a.dimensionid] + "§r] §3" + a.playername + "§r 共享了一个坐标 >> " + Convert.ToInt32(a.XYZ.x) + " " + Convert.ToInt32(a.XYZ.y) + " " + Convert.ToInt32(a.XYZ.z) + "\"}]}");
                    Console.WriteLine("!{0} 共享了坐标:位于{4}的 {1},{2},{3} ", a.playername, Convert.ToInt32(a.XYZ.x), Convert.ToInt32(a.XYZ.y), Convert.ToInt32(a.XYZ.z), diam2[a.dimensionid]);
                    return(false);
                }
                if (a.msg == "levelup" & job[a.playername] != "无职业")
                {
                    int b = api.getscoreboard(uuid[a.playername], "money");
                    int c = level[a.playername] * 100;
                    if (b >= c)
                    {
                        Playerconfig write = new Playerconfig();
                        write.Addition     = addition[a.playername];
                        write.Name         = a.playername;
                        write.level        = level[a.playername] + 1;
                        write.job          = job[a.playername];
                        string str         = JsonConvert.SerializeObject(write);//这里修改等级我是直接重写覆盖,因为8会修改(
                        File.WriteAllText("./plugins/Draco/" + job[a.playername] + "/" + xuid[a.playername] + ".json", str, System.Text.Encoding.Default);
                        level[a.playername] += 1;
                        api.runcmd("scoreboard players remove \"" + a.playername + "\" money " + c);
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§b成功升到了" + level[a.playername] + "级!花费了" + c + "金币!\"}]}");
                        var t = Task.Run(async delegate
                        {
                            await Task.Delay(500);
                            int tt = api.getscoreboard(uuid[a.playername], "money");
                            api.setPlayerSidebar(uuid[a.playername], "个人信息", "[\"玩家名称:" + a.playername + "\",\"职业:" + job[a.playername] + "\",\"等级:" + level[a.playername] + "\",\"金币:" + tt + "\"]");
                        });
                    }
                    else
                    {
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§4金币不足!距离" + (level[a.playername] + 1) + "级还需要" + c + "金币!\"}]}");
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§4当前金币:" + b + "\"}]}");
                    }
                }
                else
                {
                    api.runcmd("tellraw @a {\"rawtext\":[{\"text\":\"[" + diam[a.dimensionid] + "§r][§3" + level[a.playername] + "级" + job[a.playername] + "§r " + a.playername + "] >> " + a.msg + "\"}]}");
                    Console.WriteLine("![{2} {0}] >> {1}", a.playername, a.msg, job[a.playername]);
                }
                return(false);
            });
            api.addBeforeActListener(EventKey.onUseItem, x =>
            {
                var a = BaseEvent.getFrom(x) as UseItemEvent;
                int b = api.getscoreboard(uuid[a.playername], "money");
                if (a.itemid == 345 & job[a.playername] == "Sorcerer" & level[a.playername] >= 20)
                {
                    int ti = 5;
                    if (level[a.playername] < 50 & level[a.playername] >= 20)
                    {
                        ti = 10;
                    }
                    if (level[a.playername] > 50)
                    {
                        ti = 15;
                    }
                    if (b > 500)
                    {
                        api.runcmd("effect \"" + a.playername + "\" invisibility " + ti + " 1 true");
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3发动技能成功!\"}]}");
                        api.runcmd("scoreboard players remove " + a.playername + " money 500 ");
                    }
                    else
                    {
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§4金币不足!!至少需要500金币来发动技能!\"}]}");
                    }
                }
                if (a.itemid == 345 & job[a.playername] == "Miner" & level[a.playername] >= 20)
                {
                    int ti = 5;
                    if (level[a.playername] < 50 & level[a.playername] >= 20)
                    {
                        ti = 10;
                    }
                    if (level[a.playername] > 50)
                    {
                        ti = 15;
                    }
                    if (b > 500)
                    {
                        api.runcmd("effect \"" + a.playername + "\" haste " + ti + " 3 true");
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§3发动技能成功!\"}]}");
                        api.runcmd("scoreboard players remove " + a.playername + " money 500 ");
                    }
                    else
                    {
                        api.runcmd("tellraw \"" + a.playername + "\" {\"rawtext\":[{\"text\":\"§4金币不足!!至少需要500金币来发动技能!\"}]}");
                    }
                }
                return(true);
            });
        }