개인 자료란 (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/520/751/003/262x150.crop.jpg?20240328020349

레드스톤

마인크래프트 노트블록으로 만든 『 Bling‐Bang‐Bang‐Born 』 1

Sonttukk

2024-03-23

1

/files/thumbnails/467/742/003/262x150.crop.jpg?20240311163123

레드스톤

[노트블럭커버] MILGRAM -ミルグラム(밀그램)- / 아마네 「숙청 행진」 제 2심 2

리비온

2024-03-11

0

/files/thumbnails/846/741/003/262x150.crop.jpg?20240310221214

레드스톤

워든 vs 라마 200마리 1

GlassesFilm

2024-03-10

0

/files/thumbnails/542/739/003/262x150.crop.jpg?20240309070457

레드스톤

[고인의 명복을 빕니다][노트블럭]드래곤볼 GT 오프닝 - 점점 마음이 끌려

리비온

2024-03-09

0

/files/thumbnails/326/738/003/262x150.crop.jpg?20240328020414

레드스톤

마인크래프트 노트블록으로 만든 『 Build Our Machine 』

Sonttukk

2024-03-07

0