Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加插件: 设置重生点 1.0.0.1 #273

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

pang2333
Copy link

@pang2333 pang2333 commented Jul 5, 2024

No description provided.

BedSet/Class1.cs Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这文件名改一下不要。Class1.cs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好经典的名字

BedSet/Class1.cs Outdated
{
GetDataHandlers.PlayerUpdate.Register(backbed);//使用回城物品 set
PlayerHooks.PlayerPostLogin += PlayerHooks_PlayerPostLogin;//登录返回床位置 login
GetDataHandlers.KillMe.Register(deadafter);//死亡返回床位置 death
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这不该是Spawn事件吗

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,不过改了之后用起来挺怪

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,不过改了之后用起来挺怪

应该放到Spawn事件处理,这样写不会一死就复活吧。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以多问问羽学他有经验

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,不过改了之后用起来挺怪

应该放到Spawn事件处理,这样写不会一死就复活吧。

没一死就复活吧,毕竟我写了个while等着玩家复活(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,不过改了之后用起来挺怪

应该放到Spawn事件处理,这样写不会一死就复活吧。

测试了下只用spawn的,最大缺点是得等魔镜之类的使用时间结束才触发
第二只能把传送位置,记录位置,和清除位置放一起
1.先记录后传送,重进后马上记录了出生地而非床位置,直接废弃
2.先传送后记录,第一次会先传送到床位置清除再记录,但第二次甚至之后依旧只能传送到第一次传送的地方

因为没接触过spawn事件所以以上特性在我写的时候都没遇到(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,不过改了之后用起来挺怪

应该放到Spawn事件处理,这样写不会一死就复活吧。

测试了下只用spawn的,最大缺点是得等魔镜之类的使用时间结束才触发 第二只能把传送位置,记录位置,和清除位置放一起 1.先记录后传送,重进后马上记录了出生地而非床位置,直接废弃 2.先传送后记录,第一次会先传送到床位置清除再记录,但第二次甚至之后依旧只能传送到第一次传送的地方

因为没接触过spawn事件所以以上特性在我写的时候都没遇到(

1不在第1次触发时触发,2只在第1次触发可以互补,不过写起来应该和单独分成3个钩没差多少了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlayerSpawnContext判断这个

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spawn事件里

BedSet/Class1.cs Outdated
)
{
await Task.Delay(300);
string path = $@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


路径用Path.Combine弄个变量

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? 路径用Path.Combine弄个变量

{e.Player.Name}{Main.worldName}已经是变量吧

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? 路径用Path.Combine弄个变量

{e.Player.Name}{Main.worldName}已经是变量吧

你不觉得重复太多代码了吗
正常做法是把这路径作为类属性使用。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在有个问题
你用魔境之类的物品去记录出生点
如果重进后魔晶的出生点依然是默认的点,当人物再次使用魔晶,那你是记录新的点还是传送到已经记录的点,如果记录新的点,OK那就变成记录世界默认出生点了,如果传送到已经记录的点那你这个魔境记录点变得没意义了,用死亡记录的话也有这种问题,所以这个解决方案不是一个好的方法。

BedSet/Class1.cs Outdated
}
if (!File.Exists(path))
{
FileStream bed = File.Create($@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一样

BedSet/Class1.cs Outdated Show resolved Hide resolved
BedSet/Class1.cs Outdated
)
)
{
await Task.Delay(300);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await 开个线程

BedSet/Class1.cs Outdated
//login
private async void PlayerHooks_PlayerPostLogin(PlayerPostLoginEventArgs e)
{
while (true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个Whiletrue很爆炸

@Controllerdestiny Controllerdestiny changed the title add 设置重生点 1.0.0.1 添加插件: 设置重生点 1.0.0.1 Jul 5, 2024
BedSet/Class1.cs Outdated
{
if (disposing)
{
var asm = Assembly.GetExecutingAssembly();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有点多余了

BedSet/Class1.cs Outdated
if (disposing)
{
var asm = Assembly.GetExecutingAssembly();
Commands.ChatCommands.RemoveAll(c => c.CommandDelegate.Method?.DeclaringType?.Assembly == asm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这插件他没指令

BedSet/Class1.cs Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好经典的名字

BedSet/Class1.cs Outdated
}
}
//login
private async void PlayerHooks_PlayerPostLogin(PlayerPostLoginEventArgs e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议异步

BedSet/Class1.cs Outdated
await Task.Delay(1000);
if (e.Player.X != 0)
{
string path = $@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt";
Copy link
Member

@ACaiCat ACaiCat Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种SQL存可能会更好,而且路径不要放中文,不然任意爆掉,不要用worldName,用WorldID,也不要用PlayerName,用AccountID

BedSet/Class1.cs Outdated
private async void deadafter(object? sender, GetDataHandlers.KillMeEventArgs e)
{
while (true)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要while和异步

BedSet/Class1.cs Outdated
{
await Task.Delay(500);
if (e.Player.Dead == false)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

读取保存位置建议单独出一个方法,这里重复太多了,而且位置必须缓存

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

读取保存位置建议单独出一个方法,这里重复太多了,而且位置必须缓存

位置确实)考虑到一个人物逛多个地图的情况

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,你缓存到内存里,不要一直从磁盘读数据,一般是建议服务器启动和Reload的时候才从文件读,其余全放内存里

@ACaiCat
Copy link
Member

ACaiCat commented Jul 5, 2024

如果改不来,可以把能改的先改了,等羽学giegie帮你优化 :(

@Controllerdestiny
Copy link
Contributor

如果改不来,可以把能改的先改了,等羽学giegie帮你优化 :(

桀桀桀

@Controllerdestiny
Copy link
Contributor

我拉下来给你改了,然后你自己测

@Controllerdestiny
Copy link
Contributor

感觉会有一些别的问题

@Controllerdestiny
Copy link
Contributor

感觉会有一些别的问题

比如已经用魔晶记录了下次用魔晶是记录还是传送

@Controllerdestiny Controllerdestiny merged commit deb3f52 into UnrealMultiple:master Jul 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants