服务器重启时保存硬币吗?

问题描述 投票:-1回答:1

我用硬币制作了自己的剧本。但是,当服务器重新启动时,每次有人将硬币设置为0时,就会有人知道如何设置可以保存的硬币。 (脚本不久)

这里是脚本:

命令/硬币:别名:硬币触发:发送“&e&lEndless&7●&aDu hast&e%{coins ::%player%}%&aCoins”给玩家

命令/ pay [] []:触发:如果设置了arg-1:如果arg-1不是播放器:如果arg-2小于{coins ::%player%}:从{coins ::%player%}中删除arg-2将arg-2添加到{coins ::%arg-1%}发送“&7Du hast&e%arg-2%硬币&7an&a%arg-1%&7gesendet!”顶层发送“&7Du hast&e%arg-2%Coins&7von&a%player%&7erhalten!”到arg-1停止

            else if arg-2 is bigger than {coins::%player%}:
                send "&e&lEndless &7● &cDu hast nicht genügend &eCoins"
                stop


        else if arg-1 is player:
            send "&e&lEndless &7● &7Du kannst dir selber kein Geld geben!"
            stop


    else if arg-1 is not set:
        send "&e&lEndless &7● &7Nutze&8: &e/pay <Spieler> <Anzahl>"
        stop    

第一次加入:将{coins ::%player%}设置为2000

每1个滴答:循环所有玩家:如果{coins ::%loop-player%}小于0:将{coins ::%loop-player%}设置为0如果未设置{coins ::%loop-player%}:将{coins ::%loop-player%}设置为0

命令/ removecoins [] []:许可:coins.remcoins权限消息:&e&lEndless&7●&c&lKeine Erlaubnis触发:如果设置了arg-1:如果arg-2是一个数字:从{coins ::%arg-1%}中删除arg-2发送“&e&lEndless&7●&7%arg-1%wurden&e%arg-2%硬币&7abgezogen!”停止

    if arg-1 is not set:
        send "&e&lEndless &7● &7Bitte gebe einen Spieler und Beitrag an!"
        stop                

命令/ admin [] []:许可:coins.remcoins权限消息:&e&lEndless&7●&c&lKeine Erlaubnis触发:如果设置了arg-1:如果arg-2是一个数字:从{coins ::%arg-1%}中删除arg-2停止

    if arg-1 is not set:
        stop            

命令/ addcoins [] []:许可:coins.givecoins权限消息:&e&lEndless&7●&c&lKeine Erlaubnis触发:如果设置了arg-1:如果arg-2是一个数字:将arg-2添加到{coins ::%arg-1%}发送“&e&lEndless&7●&7%arg-1%帽子&e%arg-2%硬币&7erhalten!”停止

        else if arg-2 is not a number:
            send "&e&lEndless &7● &7Das ist keine Anzahl!"

    if arg-1 is not set:
        send "&e&lEndless &7● &7Bitte gebe einen Spieler und Beitrag an!"
        stop
minecraft
1个回答
0
投票

也许您可以尝试使用mysql数据库并在其中保存硬币。那么即使服务器离线,您也可以创建Statements并将其安全地存储在数据库中。试试这个连接:

    Connection conn = null;
try {
    // db parameters
    String url       = "jdbc:mysql://localhost:3306/mysqljdbc";
    String user      = "root";
    String password  = "secret";

    // create a connection to the database
    conn = DriverManager.getConnection(url, user, password);
    // more processing here
    // ...  
} catch(SQLException e) {
   System.out.println(e.getMessage());
} finally {
    try{
           if(conn ! null)
             conn.close()
    }catch(SQLException ex){
           System.out.println(ex.getMessage())
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.