2016年3月11日 星期五

傳送與傳送騎士與他所騎的馬

傳送與傳送騎士與他所騎的馬

The Horse Go Home


基本上傳送指令是很方便的功能,當你在收刮戰利品,走廢墟走到頭很暈,挖礦挖滿身的鑽石最安全的方法就是傳送回家,問題是你騎著你的愛馬時,你可找不到優質的停車場讓你的愛馬不走失,尤其是屁孩當道的遊戲世界。


特色


就是可以騎馬傳送。

指令


/thgh:傳送到擺床的位置或是世界的重生點。

影片

作影片的時候是使用home當指令,怕衝突畢竟這種名稱滿街都是

下載


Thgh 0.1 只要有馬都可使用,連1.9也可以。


有人要我就發出來了

開源節流


@Overridepublic boolean onCommand(CommandSender commandSender,
                         org.bukkit.command.Command commandString s,
                         String[] strings) {
    // 遊戲中的玩家才能使用

    if (commandSender instanceof Player) {
        // 取得玩家

        Player player = (Player) commandSender;
        // 取得玩家擺床的位置
        Location location = player.getBedSpawnLocation();
        // 取得這個世界的重生點
        Location oLocation = player.getWorld().getSpawnLocation();
        // 判斷玩家是否騎馬
        if (player.isInsideVehicle() && player.getVehicle()
                instanceof Horse) {
            // 取得馬

            Horse horse = (Horse) player.getVehicle();
            // 檢查玩家有無擺床
            if (location == null ) {
                // 人下馬

                player.leaveVehicle();
                // 傳送馬
                horse.teleport(oLocation);
            }else {
                player.leaveVehicle();

                horse.teleport(location);
            }
            // 馬拉人上背

            horse.setPassenger(player);
            return true;
        else {
            // 沒騎馬直接傳送玩家

            if (location == null) {
                player.teleport(oLocation);

            else {
                player.teleport(location);

            }
        }
    }
    return false;}