zoukankan      html  css  js  c++  java
  • 摸鱼服务器

    网课摸鱼摸出来的服务器

    服务器简介

    是个灾厄开荒,中世界。

    欢迎各位来玩。务必自觉开荒,拜托了。(我甚至提前搭了传送网已经够不肝了

    IP: (39.97.220.53)

    端口:(7777)

    现在想的是每天下午 7:00~23:30 开着。 然后就看到加作业了,错了错了下次,不敢了。

    没有特殊情况应该会一直挂着。

    密码的话请 (Q) 我(其实本来想写防熊的但是……没看懂 (Tshock) 代码,所以就用这种劣质方法了

    这里 下载Mods,密码 (ac6r)

    服务器信息

    版本 : (tmodloader) (11.7.5)

    Mods:

    主mod :Calamity1.4.4.005 (俺也知道大山猪今天发了1.4.5,但是没汉化也没办法啊qaq) 已更换 (Calamity ; 1.4.5.001)

    辅助mod:

    Fargo,炼金npc(非新版),自动连点,无限buff栏位,luaifk,自动连点,bosschecklist,额外翅膀栏位,合成表查询。(大概就这些吧……

    汉化:

    在Mod管理器中点击 (Localizer) 右上角的小钥匙即可选择汉化包。

    问题

    1.有的mod显示版本太旧

    ​ 卸掉重装tmod。

    2.鼠标有移动界限,设置列表点到就卡住

    一律退出重进,或者重启tmod

    3.to be continued

    ​ 现在还在测试中,后面的锅慢慢修

    搭建过程记录

    环境

    阿里云 轻量应用服务器:1C2G,Ubuntu 18.04 镜像

    最好建个新用户

    adduser steam
    

    安装 steamcmd

    cd ~/steamcmd
    
    wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
    
    tar -xvzf steamcmd_linux.tar.gz
    
    ./steamcmd.sh
    

    登录下载terraria

    login USERNAME
    
    app_update 105600 
    

    运行terraria文件夹下自带的Server

    ./TerrariaServer
    

    按照指示新建world

    在管理台开启端口7777的TCP和UDP

    检验一下是否能链接服务器

    然后下载 tModLoader

    最好新建个文件夹 出了锅好调试

    之后运行 tmodloaderserver ,首次运行后会自己生成mod文件夹,位置在:

    ~/.local/share/Terraria
    

    可能是1.4版本适配问题 直接使用 (11.7.5)(tmod) 会使这些未更新的 (mod) 不适配 似乎先使用(11.7.4) 然后再用 (11.7.5) 就行了。(鬼知道什么原理

    然后发现 (Magicstore) 出了bug,一直是 (0) 储存,退出去回来后还会炸掉周围物块。

    找了半天发现有人发了错误报告,原来是 (Magicstore) 在linux上没有合适运行环境,安装mono后把缺失的链接复制到tr里即可(捧读)。

    apt install mono-runtime
    cp /usr/lib/libMonoPosixHelper.so [tr的目录]
    

    虽然仍然一使用存储模块就会报错,但是实际上可以用了。(草这些bug鬼知道我试了多久

    然后照着大佬的脚本自己糊了一份(基本就是看了遍加注释,几处试图修改只有一点点成功了)。

    功能大概是:报时,自动保存,自动备份,显示欢迎信息,游戏内调时间。

    import subprocess
    from threading import Thread
    from queue import Queue, Empty
    import psutil
    from datetime import datetime
    import time
    import traceback
    import sys
    import os
    
    world_name = sys.argv[1]
    
    server_path = "/home/steam/steamcmd/steamapps/common/Terraria/tModLoader11.7.5"
    world_path = "/home/steam/.local/share/Terraria/ModLoader/Worlds"
    backup_path = "/home/steam/tModLoaderServerBackup"
    
    cmd = ("%s/tModLoaderServer.bin.x86_64 -world %s/%s.wld" % (server_path,
                                                                world_path,
                                                                world_name)).split() + sys.argv[2:]
    
    p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    
    
    def enqueue_output(out, queue):
        for line in iter(out.readline, b''):
            queue.put(line)
        out.close()
    
    
    q = Queue()
    t = Thread(target=enqueue_output, args=(p.stdout, q), daemon=True)
    t.start()
    
    
    pid = p.pid
    
    def gfs(Filepath,size=0):
        for root,dirs,files in os.walk(Filepath):
            for f in files :
                size += os.path.getsize(os.path.join(root,f))
        return size
    
    
    def monitor():
        print(pid)
        ready = False
    
        while psutil.pid_exists(pid):
            def write(s):
                s += '
    '
                p.stdin.write(s.encode())
                p.stdin.flush()
            try:
                line = q.get_nowait().decode()
                print(line[:-1]) #将server里的输出打印到屏幕上
                if not ready and "Type 'help' for a list of commands." in line:
                    ready = True
                if ready:
                    if "exit" in line:
                        write("say Closing in 60s...")
                        time.sleep(60)
                        write("say Now closing...")
                        write("exit")
                    if "dawn" in line:
                        write("say Switch game time 4:30AM.")
                        write("dawn")
                    if "dusk" in line:
                        write("say Switch game time 7:30PM.")
                        write("dusk")
                    if "has joined." in line:
                        write("say Welcome to %s! 请自觉开荒,尽量不要破坏人为建筑物。 不要在网课期间摸鱼![滑稽][怒]" % (world_name))
            except Empty:
                if ready:
                    now = datetime.now()
                    if now.second < 5:
                        if now.minute % 15 == 0: #自动备份 自动报时
                            write("say Current time: %02d:%02d." % (now.hour, now.minute))
                            if gfs(backup_path) >= 1073741824 :
                                os.system("cd backup_path")
                                os.system("rm -rf *")
                            for ext in [".wld", ".twld"]:
                                os.system("cp %s %s" % (world_path + '/' + world_name + ext,
                                                        backup_path + '/' + world_name + datetime.now().strftime("-%Y-%M-%d-%H-%M") + ext))
    
                        if now.minute % 3 == 1: #自动保存
                            write("say Now saving...")
                            write("save")
                time.sleep(5)
    
    
    try:
        monitor()
    except Exception as e:  #错误处理
        p.stdin.write(b'exit')
        traceback.print_exc() #输出错误信息
    
    

    本来想着每天最后一节晚自习摸会鱼,结果最后每天基本只能有半个小时时间,然后就折腾了四天……

    最后终于摸出来了 不容易

    参考了下面几个文章(于是把里面的锅都踩了一遍顺便还添新锅):

    https://www.jxtxzzw.com/archives/3629

    https://zerol.me/2020/02/08/Terraria-Server-With-Mods/


    (frak by; thorn\_)

  • 相关阅读:
    UVA 1660 Cable TV Network
    UVA 1149 Bin Packing
    UVA 1610 Party Games
    UVA 12545 Bits Equalizer
    UVA 11491 Erasing and Winning
    UVA 1611 Crane
    DataTable循环删除行
    SqlBulkCopy使用心得 (大量数据导入)
    JQuery选择器大全
    java学习--GUI3
  • 原文地址:https://www.cnblogs.com/thornblog/p/13419645.html
Copyright © 2011-2022 走看看