2014-02-21 2 views
0

그래서 기본적으로 워핑 시스템을 만들고 있지만 미니 게임에 사용하고 있습니다. 나는 서버의 소유주가 미니 게임이 시작될 때 다른 플레이어가 스폰 할 수 있도록 워프를 설정할 수 있기를 바랍니다.구성 파일에 설정된 좌표로 플레이어를 텔레포트 할 수 없습니다 [Bukkit]

 p.teleport(cakestart); 

내가 할 수있는 :

if(cmd.getName().equalsIgnoreCase("cakestart")){ 

      if(getConfig().contains("locations." + args[0])){ 
       int locationsX = this.getConfig().getInt("locations" + args[0] + ".X"); 
       int locationsY = this.getConfig().getInt("locations" + args[0] + ".Y"); 
       int locationsZ = this.getConfig().getInt("locations" + args[0] + ".Z"); 
       int locationsYaw = this.getConfig().getInt("locations" + args[0] + ".Yaw"); 
       int locationsPitch = this.getConfig().getInt("locations" + args[0] + ".Pitch"); 
       Object locationsworld = this.getConfig().get("locations" + args[0] + ".World"); 

       Location cakestart = new Location((World) locationsworld, locationsX, locationsY, locationsZ, locationsYaw, locationsPitch); 

       p.teleport(cakestart); 
       p.sendMessage("TPED!"); 
      } 

     } 

는 오류가 일어나고있다 : 어떤 이유로, 나는 플레이어를 텔레포트 수 없다는되는 오류가 발생하고, 여기에 순간 이동 부분에 대한 내 코드는 필요한 정보를 더 제공하십시오.

+0

StackTrace 란 무엇입니까? (콘솔에 표시되는 내용) – Jojodmo

답변

0

개체를 World 개체에 캐스팅 할 수없는 경우가 있습니다. 세계를 문자열로 저장하고 Bukkit.getWorld("string");을 사용하여 세계 객체에 구문 분석하려고합니다.

Bukkit.getWorld(getConfig().getString("path of the world in the config"); 
+0

')'가 없습니다. – hintss

1

내가 대신 문자열로 locationsworld 정의 대신

Object locationsworld = this.getConfig().get("locations" + args[0] + ".World"); 
Location cakestart = new Location((World) locationsworld, locationsX, locationsY, locationsZ, locationsYaw, locationsPitch); 

의를 제안하고 가져올 것이다 :

이 설정 당신이해야 할 모든에서 세계를 얻으려면이있다 서버의 실제 세계는 대소 문자를 구분하는 고유 한 이름을 사용합니다. 당신이 JavaPlugin를 확장 메인 클래스에있어 가정하면, 그 결과는 다음과 같습니다

String locationsworld = this.getConfig().get("locations" + args[0] + ".World"); 
World tworld = this.getServer().getWorld(locationsworld); 
Location cakestart = new Location(tworld, locationsX, locationsY, locationsZ, locationsYaw, locationsPitch); 

잘못된 세상을하지 않아도 그 방법을. 세계 클래스에는 더 많은 정보가 있습니다. 이름은 단지 World.getName(); 대신 모든 정보를 저장하지 않으면 유형 변환으로 많은 성공을 거둘 수 없습니다.

편집 : Afterthought : 다른 값, 특히 피치 및 요우 값에 정수 대신 double을 사용하는 것이 좋습니다.