Skip to content
wysohn edited this page Mar 27, 2021 · 13 revisions

This trigger can be used only via the #CALL executor. You can call a Named Trigger inside of a Named Trigger too, but don't ever call a named trigger inside of itself if you don't know what you are doing. It could cause an infinite loop.

Or, alternatively, you may use /trg call <NamedTrigger name> to execute it as if it was called in a random CommandTrigger through #CALL

There are no commands to create a named trigger. Instead, just create an empty file and start coding from there. Make sure your file has the .trg extension. If you want a named trigger called foo, the file should be named foo.trg

Using Named Trigger

Unlike other triggers, named triggers can only be called from other triggers.

To do so, use #CALL executor in the other triggers.

For example, in your Command Trigger:

#CALL "Trigger1"

This will activate Trigger1. But if you have more than one line of code, it might be confusing.

For example:

#MESSAGE "HEY"
#CALL "Trigger1"
#MESSAGE "Done!"

In this scenario, here is how the execution will go:

First, the #MESSAGE executor will print HEY to the user.

Second, the current trigger will hand execution control over to the named Trigger (Trigger1 in our example), and the named Trigger will begin working. While the named Trigger is working, the current Trigger will wait for the named Trigger to end.

Third, when the execution of named Trigger is done, it will hand the execution control back to the current Trigger, and now the current Trigger can continue. In our example, Done! will be printed.

Variable sharing

By default, Named Triggers share local variables with the current Triggers. So any local variable in the current Trigger can be used in the Named Trigger, and any local variable created from a Named Trigger can be used in the current Trigger too.

Concurrency

If you want the Named Trigger to run concurrently, you may add an additional parameter to the #CALL executor. For example:

#CALL "MyTrigger1" false

This code will spawn a new task that will be running concurrently beside the Trigger that just started the MyTrigger1.

But in this case, the variables will be 'copied' to the Named Trigger, and will not be shared with the current Trigger.

Grouping Named Trigger

If your project gets larger, it's always a good idea to put groups of named triggers in folders to avoid naming collision. All you have to do is create a sub folder inside of the main named triggers folder and move your named triggers inside. Named Triggers inside of folders will not collide with named triggers in the main folder or inside of other folders even if they have identical names.

Don't forget to run /trg reload after creating new folders or files!

Calling trigger that is in a folder

Very simple. You just have to specify the path of Trigger using ':'

For example, if you have your Trigger5 in folder named MyTriggers, then call it with the following code:

#CALL "MyTriggers:Trigger5"

Plugin Description / 목차

1. Getting Started () (рус)

S.L. In-game Editor () (рус)

2. Triggers () (рус)

List and usage of Triggers / 트리거 목록과 사용 방법:

  • List of Executors / 실행자(Executor) 목록

4. Placeholders () (рус)

  • Using PlaceholderAPI / PlaceholderAPI 사용법
  • List of Placeholders / 플레이스 홀더(Placeholder) 목록

5. Conditions () (рус)

  • Creating Conditions / 조건식 만들기
    • Boolean Expressions / 부울 (Boolean) 표현 방법
  • Logical Operators / 연산자 사용법
  • IF statement / IF 조건문
  • Null Checking / Null 검사법
  • Switch Case / Switch Case 조건

6. Variables () (рус)

  • Local Variables / 지역 변수
  • Global Variables / 전역 변수

Advanced

Timings () (рус)

7. Methods () (рус)

  • Using Methods / 메소드 사용법
  • Special Data Types / 특수한 데이터 형식
  • Reading Javadocs / Javadoc 읽기
  • Handling Enum / Enum 데이터 처리
  • Lambda Expresion / Lambda(람다) 식 사용법

8. Array () (рус)

  • Creating an empty array / 빈 배열 만들기
  • Storing data into array / 배열에 데이터값 저장하기
  • Read data from array / 배열에서 데이터 읽기(불러오기)

9. Loops () (рус)

  • WHILE loop / WHILE 반복문
  • FOR loop / FOR 반복문
    • Iterating Collection / Collection 형식의 변수 순회법
    • #BREAK executor / #BREAK 실행자
    • #CONTINUE executor / #CONTINUE 실행자

10. Sync Mode () (рус)

  • #CANCELEVENT executor / #CANCELEVENT 실행자
  • Setting Sync/Async Mode / 동기, 비동기 모드 전환
    • Custom Trigger
    • Area Trigger

11. Custom Executors () (рус)

12. Plugin Access () (рус)

  • Check And Use / 플러그인 존재여부 확인
    • Get Third Party Plugin / 제 3자 플러그인 불러오기
    • Check Eligibility / 호환성 확인하기
    • Use the Plugin / 플러그인 사용하기

13. IMPORT Statement () (рус)

  • Creating new instance / 새 인스턴스 생성하기
  • Accessing static method / 종속 메소드 불러오기
  • Accessing static field / 종속 Enum 불러오기

14. IS Statement () (рус)

  • Understanding / 이해하기
    • Understanding Instance / 인스턴스 이해하기
    • Understanding Superclass / 부모클래스 이해하기
    • Understanding Subclass / 자식클래스 이해하기
  • Using IS Statement / IS조건연산자 사용하기

15. TRY-CATCH Statement () (рус)

  • Understanding TRY-CATCH Exception Handling / TRY-CATCH 예외처리 이해하기

Misc

16. Interface Casting () (рус)

module x.x does not "opens x.x" problem

  • List of Custom Events

Examples

Trigger

Trigger Example () (рус)

More Examples: Bukkit, Sponge

Case Specific

Clone this wiki locally