간만에 마인크래프트 플러그인을 다시 개발해보는데요
관련된 버전들이 새로 업그레이드 된 것 같아 셋팅 부터 다시 시작해보도록 하겠습니다.
https://www.spigotmc.org/threads/spigot-bungeecord-1-21-2-1-21-3.667019/
Spigot 공식 포럼을 확인하면 Spigot 의 버전이 1.21.3 으로 변경된 것 같습니다.
자바의 경우에도 저는 기존에 JDK 21 을 사용하고 있었으나 JDK 23 을 사용할 수 있을 것 같아 업그레이드 했습니다.
https://www.oracle.com/kr/java/technologies/downloads/
Download the Latest Java LTS Free
Subscribe to Java SE and get the most comprehensive Java support available, with 24/7 global access to the experts.
www.oracle.com
해당 spigot 포럼에서 BuildTools 를 다운 받아 가장 최신 버전을 설치해보도록 하겠습니다.
마인크래프트의 버전도 1.21.3 버전이 가장 최신 버전인 것 같습니다. spigot 역시 이 마인크래프트 버전을 따라가는 것 같습니다.
BuildTools 를 사용해 설치하니 위와 같이 파일들이 만들어졌습니다.
spigot-1.21.3jar 파일을 통해 우선 서버를 가동시켜 보도록 하겠습니다.
정상적으로 서버가 가동되고 마인크래프트에서 접속이 되는 것을 확인할 수 있었습니다.
이제 Eclipse IDE 를 통해 개발 환경을 구성해보도록 하겠습니다.
프로젝트를 구성하는 방법이 잘 생각나지 않아 이전 글들을 보며 따라해보도록 하겠습니다.
7. 마인크래프트 플러그인 개발 - 데미지 디스플레이 플러그인 개발
이번에도 Listener 와 조금 더 친해지기 위해 플러그인 개발을 실습해보도록 하겠습니다. 2편 에서 서버와의 통신에 대해 이야기할 때 플레이어가 검으로 좀비를 공격했을 때 체력을 알 수 있는
beingb.tistory.com
그럼 플러그인 제작을 위한 준비는 모두 마쳤습니다.
이번에 제작할 플러그인은 더블 점프 플러그인입니다.
1. 플레이어가 점프 중일 때
2. 스페이스바를 한번 더 누르면
3. 점프를 할 수 있게 한다.
이렇게 만들고 싶은 플러그인의 기능을 분리할 수 있을 것 같습니다.
하나씩 관련된 내용을 리서칭해보도록 하겠습니다. 마인크래프트는 대부분 이벤트 라는 것에 의해 작동된다고 이야기 했었습니다.
2. 마인크래프트 플러그인 개발 - 플러그인이란 ?
1편의 진행에서 제작한 서버는 마인크래프트에서 공식으로 제공하는 바닐라 서버 입니다.바닐라 서버의 경우에는 플러그인을 탑재할 수 없습니다. 우리는 저번 1편에서 정독했던 WIKI 의 Custom
beingb.tistory.com
그러면 플레이어가 점프 중인지를 판단하기 위해 Spigot Player Jump Event 라는 주제로 우선 리서칭 해보도록 하겠습니다.
https://www.spigotmc.org/threads/player-jump.61335/
가장 최상단의 글을 보면 PlayerMoveEvent 라는 것을 통해 감지할 수 있는 것 같습니다.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerMoveEvent.html
PlayerMoveEvent (Spigot-API 1.21.3-R0.1-SNAPSHOT API)
All Implemented Interfaces: Cancellable Direct Known Subclasses: PlayerTeleportEvent Holds information for player movement events Nested Class Summary Field Summary Constructor Summary Constructors Method Summary Constructor Details PlayerMoveEvent Method
hub.spigotmc.org
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html
Player (Spigot-API 1.21.3-R0.1-SNAPSHOT API)
spawnParticle void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target locatio
hub.spigotmc.org
아쉽게도 플레이어의 Interface 를 보면 점프 중인지 파악할 수 있는 메서드는 따로 없는 것 같습니다.
썩 마음에 들지는 않지만...
PlayerMoveEvent 에서 From -> To 로 이동할 때 Y 좌표가 증가하는지 그리고 플레이어가 날고 있거나 수영중이지 않을 때
플레이어가 점프중이다 라고 판단하는 것 같습니다.
우선 위와 같이 코드를 작성했을 때 플레이어의 점프가 탐지되는지 파악해보도록 하겠습니다.
@EventHandler
public void onPlayerJump(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location from = event.getFrom();
Location to = event.getTo();
Boolean isPlayerJump = from.getBlockY() < to.getBlockY() && !player.isSwimming() && !player.isFlying();
if (isPlayerJump) {
player.sendMessage("PLAYER JUMP");
}
}
해당 코드로 플레이어의 점프가 정상적으로 확인되는 것을 알 수 있었습니다.
그런 다음 점프 중일 때 플레이어의 Input 을 파악해보도록 하겠습니다.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#getCurrentInput()
Player (Spigot-API 1.21.3-R0.1-SNAPSHOT API)
spawnParticle void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) Spawns the particle (the number of times specified by count) at the target locatio
hub.spigotmc.org
Player 의 메서드 중에 getCurrentInput 을 통해 점프 중에 스페이스바를 한번 더 누르는 것이 탐지되는지 확인해보겠습니다.
@EventHandler
public void onPlayerJump(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location from = event.getFrom();
Location to = event.getTo();
Boolean isPlayerJump = from.getBlockY() < to.getBlockY() && !player.isSwimming() && !player.isFlying();
Input playerCurrentInput = player.getCurrentInput();
player.sendMessage(playerCurrentInput.toString());
if (isPlayerJump) {
player.sendMessage("PLAYER JUMP");
}
}
코드를 보면 왜인지 모르겠으나 PlayerMoveEvent 는 매우 다양하게 측정되고 있습니다.
여기서 주의깊게 봐야할 내용은 PLAYER JUMP 이후
플레이어가 점프를 한 이후에 Input 의 jump 가 한 번 true 값으로 들어온다는 것입니다.
즉 플레이어가 점프 중인지를 파악하고 점프 중일 때 Input 의 Jump 값이 true 로 들어온다면 더블 점프를 하고 싶어한다.
라는 것을 알 수 있습니다.
'마인크래프트' 카테고리의 다른 글
11. 마인크래프트 플러그인 개발 - 커스텀 아이템 플러그인 개발 (1) | 2024.08.31 |
---|---|
10. 마인크래프트 플러그인 개발 - 작물 성장 체크 플러그인 개발 (0) | 2024.08.25 |
9. 마인크래프트 플러그인 개발 - 챗컬러 플러그인 개발 (0) | 2024.08.24 |
7. 마인크래프트 플러그인 개발 - 데미지 디스플레이 플러그인 개발 (0) | 2024.08.16 |
6. 마인크래프트 플러그인 개발 - Listener 활용 (0) | 2024.08.16 |