개인 자료란 (JE)

  서버 커뮤니티

Profile lhh2020 대표칭호 없음

lhh2020 8ca6df15355443579fc74f5cb3bcbb46

Profile

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

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

2020.11.14 조회 수 2160 추천 수 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/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 모드에서 악성코드 발견

학교가기싫다

2024-05-08

1

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

업데이트

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

학교가기싫다

2024-05-06

0

/files/thumbnails/855/781/003/262x150.crop.jpg?20240505141129

레드스톤

레이저 클리너

GlassesFilm

2024-05-05

1

/files/thumbnails/576/775/003/262x150.crop.jpg?20240426232553

아티클

이달의 블록: 단단한 진흙

학교가기싫다

2024-04-26

0

/files/thumbnails/115/774/003/262x150.crop.jpg?20240428135129

업데이트

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

학교가기싫다

2024-04-24

0