개인 자료란 (JE)

  서버 커뮤니티

Profile lhh2020 대표칭호 없음

lhh2020 8ca6df15355443579fc74f5cb3bcbb46

Profile

강좌 자바 에디션(JE) 플러그인 개발

●플러그인 강좌● ItemStack을 "yml" 파일로 저장해보자

2020.11.14 조회 수 2177 추천 수 0
분야 플러그인 
장르 개발자 툴 
게임버전 모든버전 
API 스피곳, 페이퍼 


저장

File file = new file(경로);

FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);

configFile.set( key ,  value(ItemStack) );

configFile.save(file);


읽기

File file = new file(경로);

FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);

ItemStack item = configFile.getItemStack( key );


예시

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) 

{

File file = new File("plugins/testplugin/item.yml");

File directory = new File("plugins/testplugin");

if(!directory.exists()) directory.mkdir();

if(!file.exists())try {file.createNewFile();} catch (IOException e) {}

FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);

configFile.set("1", ((Player)sender).getInventory().getItemInMainHand());

try {

configFile.save(file);

} catch (IOException e) {}

return true;

}


출력

'1':

  ==: org.bukkit.inventory.ItemStack

  type: ENCHANTED_BOOK

  meta:

    ==: ItemMeta

    meta-type: ENCHANTED

    stored-enchants:

      VANISHING_CURSE: 1


응용

상점 ∙ 가상창고 ∙ 메뉴등 GuiChest를 활용하는 것등 아이템을 활용하는 대부분에 곳에서 사용할 수 있습니다


처음 쓰는 글인데 수정할 점이 있으면 말씀해주세요

                                                                                                                                           -↓추천





2개의 댓글

yellow0519
2020.11.18
비밀글입니다.

비밀번호를 입력하세요.

lhh2020
2020.11.19
@yellow0519

java 요

뉴스 및 창작물
/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

/files/thumbnails/712/796/003/262x150.crop.jpg?20240525085438

레드스톤

마인크래프트 노트블록으로 만든 『 봄을 고하다 (春を告げる) 』 1

Sonttukk

2024-05-25

0

/files/thumbnails/268/789/003/262x150.crop.jpg?20240515192032

레드스톤

벌레먹은 돌 빠르게 제거하는 법

GlassesFilm

2024-05-15

0

/files/thumbnails/797/788/003/262x150.crop.jpg?20240515090924

건축

마인크래프트로 구현한 카르카손 보드게임

Warak

2024-05-15

1

/files/thumbnails/487/784/003/262x150.crop.jpg?20240508233607

모드

Windows Borderless 모드에서 악성코드 발견 3

학교가기싫다

2024-05-08

1

/files/thumbnails/384/778/003/262x150.crop.jpg?20240512002324

업데이트

마인크래프트 자바 에디션 스냅샷 24w18a

학교가기싫다

2024-05-06

0