개인 자료란 (JE)

  서버 커뮤니티

Profile Skywolf46 대표칭호 없음
Profile

커뮤니티 소통 개발하기 API

CommandAnnotation / 명령어 등록을 더 쉽고 편리하게.

2020.02.16 조회 수 305 추천 수 1

CommandAnnotation 프로젝트는 더욱 쉽고, 빠르고, 편리하게 명령어를 등록할 수 있는 라이브러리입니다.


"버킷 기반 모든 서버"에서 작동이 가능합니다.


작동 확인된 버킷:

- Spigot (1.5.2,1.7.10,1.11,1.12 Tested)

- CatServerBukkit (1.12 Tested)

- CraftBukkit (1.5.2 Tested)

* 1.12.2를 넘어가는 버전의 서버에서는 아직 지원이 되지 않습니다.


예제 - 명령어 상속받기

1
2
3
4
5
6
7
8
9
10
11
public class TestCommand extends MinecraftAbstractCommand {
    @Override
    public boolean onCommand(CommandArgument args) {
         Player p = args.get(Player.class);
        if(p == null)
            args.get(CommandSender.class).sendMessage("Player only command!");
        else
            p.sendMessage("Hello,World!");
    }
}
 

cs



예제 - 파라미터 이터레이터 사용하기


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class TestCommand extends MinecraftAbstractCommand {
    @Override
    public boolean onCommand(CommandArgument args) {
         Player p = args.get(Player.class);
        if(p == null)
            args.get(CommandSender.class).sendMessage("Player only command!");
        else{
            try{
                Location nextParse = args.iterator().next(Location.class);
            }catch(ParameterException ex){
                p.sendMessage("Illegal arguments.");
            }
        }
    }
}
 
cs



예제 - 파라미터 파서 구현하기


1
2
3
4
5
6
7
public class DoubleParser extends ParameterParser<Double> {
    @Override
    public Double readParameter(ParameterIterator it) {
        return Double.parseDouble(it.next());
    }
}
 
cs



예제 - 파라미터 파서 등록하기

1
2
3
4
5
6
public class TestPlugin extends JavaPlugin {
    @Override
    public void onEnable(){
        ParameterIterator.registerParser(Double.class,new DoubleParser());
    }
}
cs



예제 - 커맨드 등록하기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class TestPlugin extends JavaPlugin {
    @Override
    public void onEnable(){
        // 명령어를 등록하기 위해서는 반드시 이 메서드를 호출해야 합니다.
        CommandAnnotation.forceInit(this);
        MinecraftAbstractCommand.builder()
            .command("/test")
            .add(new TestCommand())
            .child("a",new TestChildA())
            .child("b c"new TestChildBC())
            .child("d"new TestChildD(), true)
                .child("e",new TestChildE())
                .parent()
            .child("f",new TestChildF())
            .complete();
    }
}
cs



버전 이름 클릭시 해당 버전으로 리다이렉트됩니다. (깃허브)


1.3.2 Release

  • ParameterIterator#next(Integer.class)가 Location을 파싱하는 오류를 해결하였습니다.
  • LocationParser의 파싱 기능을 수정하였습니다.
  • CommandAnnotation 프로젝트가 1.5.2에서 일부 작동하지 않는 문제를 해결하였습니다.

1.3 Release

  • 파라미터 이터레이터가 추가되었습니다.
  • Double,Integer,Float의 파라미터 파서가 추가되었습니다.
  • EulerAngle, Vector, Location, World, Player, OfflinePlayer의 파라미터 파서가 추가되었습니다.




3개의 댓글

GoldenMine
2020.02.16

헤에엑 머싯서요!!!!

DDang_
2020.02.18

좋은 글 감사합니다

시듀아
2020.02.19

감사합니다

뉴스 및 창작물
/files/thumbnails/762/770/003/262x150.crop.jpg?20240418073724

레드스톤

T.B.H (고민중독) | 노트블럭 버전 | NoteBlock Cover [한국어 영어 중국어 가사 추가]

노트블럭전문가

2024-04-18

0

/files/thumbnails/218/767/003/262x150.crop.jpg?20240412130213

레드스톤

우리의 꿈 - 원피스 오프닝

노트블럭전문가

2024-04-12

0

/files/thumbnails/505/766/003/262x150.crop.jpg?20240411122306

레드스톤

기동전사 건담 수성의 마녀 | 노트블럭 커버 1

노트블럭전문가

2024-04-11

1

/files/thumbnails/932/765/003/262x150.crop.jpg?20240410124459

레드스톤

마인크래프트 노트블록으로 만든 『 밤양갱 (Bam Yang Gang) 』

노트블럭전문가

2024-04-10

0

/files/thumbnails/403/765/003/262x150.crop.jpg?20240409190538

레드스톤

마인크래프트 노트블록으로 만든 『 밤양갱 (Bam Yang Gang) 』

Sonttukk

2024-04-09

4