개인 자료란 (JE)

  서버 커뮤니티

Profile 오캣진 대표칭호 없음
Profile

질문하기 Java

플레이어가 죽으면 세계를 리셋하는 방법

2023.06.17 조회 수 52 추천 수 0
이해도 초보자 
게임버전 (JE) 1.20 
게임버전 (BE) 관련없음 

플러그인으로 플레이어가 죽으면 서버를 종료하지 않고 새 월드로 초기화하는 방법이 있을까요?

4개의 댓글

윈초
2023.06.18
World world = player.getWorld();
Bukkit.unloadWorld(world, false);

Bukkit.createWorld(new WorldCreator(world.getName()).type(WorldType.NORMAL));
World newWorld = Bukkit.getWorld(world.getName());

for (Player player : Bukkit.getOnlinePlayers()) {
    player.teleport(newWorld.getSpawnLocation());
}
오캣진
2023.06.18
@윈초

리스폰 장소로만 이동하고 끝나는데 혹시 추가 설명 가능한가여?

오캣진
2023.06.18
@오캣진

코드입니다.

 

@EventHandler

public void onPlayerDeath(PlayerDeathEvent event) {

Player player = event.getEntity();

String playerName = player.getName();

 

// Show "Dead Player" in the title for 3 seconds

showSupTitle(player, ChatColor.RED + "[ 사망 ]", "범인 : " + playerName , 3);

 

// Schedule a task to display the countdown

new BukkitRunnable() {

int time = 10;

 

@Override

public void run() {

if (time == 0) {

// Clear the title after the countdown ends

player.sendTitle("", "", 0, 20, 10);

World world = player.getWorld();

Bukkit.unloadWorld(world, false);

 

Bukkit.createWorld(new WorldCreator(world.getName()).type(WorldType.NORMAL));

World newWorld = Bukkit.getWorld(world.getName());

 

for (Player allplayer : Bukkit.getOnlinePlayers()) {

allplayer.teleport(newWorld.getSpawnLocation());

}

cancel();

return;

}

// Update the title with the remaining countdown time

showSupTitle(player, ChatColor.GREEN + "[ 서버 초기화 ]", time + "초" , 0);

time--;

}

}.runTaskTimer(this, 60, 20); // Run the task every second

}

윈초
2023.06.18
@오캣진

같은 시드로 생성되서 그럴거에요. 근처에 블록 설치하고 테스트해봐주시겠어요?

뉴스 및 창작물
/files/thumbnails/308/815/003/262x150.crop.jpg?20240617084353

레드스톤

[피아노커버] 디스코드 - QWER

노트블럭전문가

2024-06-17

0

/files/thumbnails/932/812/003/262x150.crop.jpg?20240616121638

업데이트

마인크래프트 1.21 정식 업데이트

학교가기싫다

2024-06-14

1

/files/thumbnails/308/805/003/262x150.crop.jpg?20240605201646

레드스톤

[노트블럭 커버] 팬서비스/mona 【 HoneyWorks 】

노트블럭전문가

2024-06-05

0

/files/thumbnails/288/791/003/262x150.crop.jpg?20240602150002

아티클

《까다로운 시련》 업데이트 날짜 공개 및 정보

학교가기싫다

2024-06-02

0

/files/thumbnails/841/773/003/262x150.crop.jpg?20240526120908

레드스톤

마인크래프트 노트블록버전 『 봄을 고하다 (春を告げる) 』 [더블옥타브 버전]

노트블럭전문가

2024-05-26

0