This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EditSign.lxl.js
75 lines (66 loc) · 2.59 KB
/
EditSign.lxl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// 文件名:EditSign.lxl.js
// 文件功能:LXL平台下修改告示牌文字工具
// 作者:yqs112358
// 首发平台:MineBBS
var _VER = '1.0.1'
mc.regPlayerCmd("editsign","开始修改告示牌",function(pl,args)
{
pl.setExtraData("_IS_CHANGING_SIGN",true);
pl.tell("<EditSign>进入编辑模式\n<EditSign>点击任意告示牌来修改其文字");
});
mc.listen("onPlaceBlock",function(pl,bl){
if(pl.getExtraData("_IS_CHANGING_SIGN"))
{
pl.tell("<EditSign>点击的不是告示牌,编辑模式已退出");
pl.setExtraData("_IS_CHANGING_SIGN",null);
}
});
mc.listen("onAttack",function(pl,ac){
if(pl.getExtraData("_IS_CHANGING_SIGN"))
{
pl.tell("<EditSign>点击的不是告示牌,编辑模式已退出");
pl.setExtraData("_IS_CHANGING_SIGN",null);
}
});
mc.listen("onUseItemOn",function(pl,it,bl){
if(pl.getExtraData("_IS_CHANGING_SIGN"))
{
if((bl.type == "sign" || bl.type.indexOf("_sign") != -1) && bl.hasBlockEntity())
{
if(pl.getExtraData("_IS_EDIT_SIGN_CLICKING"))
return;
pl.setExtraData("_IS_EDIT_SIGN_CLICKING",true)
setTimeout(function(){ pl.setExtraData("_IS_EDIT_SIGN_CLICKING",null) },200);
let ble = bl.getBlockEntity();
let nbt = ble.getNbt();
let text = nbt.getTag("Text").get().replace(/\n/g, "\\n");
let form = mc.newCustomForm();
form.setTitle("EditSign - 编辑模式");
form.addInput("修改目标告示牌的文字为:","",text);
form.addLabel("使用\\n来表示换行符");
pl.sendForm(form,function(pl,data){
if(!data)
{
pl.tell("<EditSign>编辑模式已退出");
pl.setExtraData("_IS_CHANGING_SIGN",null);
}
else
{
nbt.setString("Text",data[0].replace(/\\n/g, "\n"));
ble.setNbt(nbt);
pl.tell("<EditSign>编辑完毕");
pl.setExtraData("_IS_CHANGING_SIGN",null);
}
});
}
else
{
pl.tell("<EditSign>点击的不是告示牌,编辑模式已退出");
pl.setExtraData("_IS_CHANGING_SIGN",null);
}
}
});
log('[EditSign] EditSign告示牌编辑插件 当前版本:' + _VER);
log('[EditSign] 游戏内使用/editsign命令进入告示牌编辑模式');
log('[EditSign] 作者:yqs112358 首发平台:MineBBS');
log('[EditSign] 想要联系作者可前往MineBBS论坛');