-
-
Notifications
You must be signed in to change notification settings - Fork 18
Array
Arrays are basically just a series of items stored into a single variable. Knowing how to use arrays opens up a lot of Bukkit world things, such as using using FOR Loops to iterate through the array.
To create an array, you must first define the variable name, then assign it a size using the array(int size) common method.
myArray = array(10)
Above code will create an array of size 10. This means that you can put 10 different items into this array.
myArray[9] = "Hey";
To store data into an array, add square brackets behind the variable name you defined earlier, then assign it like a regular variable. The number inside the [] brackets is called the 'index,' and it always starts from 0. Since we set the size to 10, the index range is 0 to 9. Index 10 doesn't exist. If we tried using index 10, we would get an index out of bounds error.
Reading data from an array is simple. Just add the index of the item you want to access in square brackets.
#MESSAGE myArray[9]
Not so difficult right?
Using common methods, you can also use sets, lists and maps, which add more functions to your basic array. Basic java knowledge is required to use these kind of arrays. See Methods.
Sets are created using set(). They do not have a set size, which is useful if the amount of items in your array changes. Sets do not allow duplicate elements. They also are unordered, meaning you have no control over index.
bannedWords = set()
bannedWords.add("Hoe")
bannedWords.add("Donkey")
Adds words to a banned word list.
Lists are creating using list(). Like sets, lists do not have a set size. However you have control over the index of the items.
leaderboard = list()
leaderboard.add("MidnightSugar")
leaderboard.add("Wysohn")
#MESSAGE leaderboard.indexOf(0)
Adds some players to a leaderboard, then displays person in first place.
Maps are created using map(). Like sets they do not have a set size, and do not allow duplicate elements, however they contain two objects, a key and a value.
warps = map()
warps.put("Spawn", Location("world", 500, 60, 923))
warps.put("Market", Location("world", 231, 65, 213))
player.teleport(warps.get("Spawn"))
Adds warps to a map, then teleports the player.
Basic Syntax (한) (рус)
1. Getting Started (한) (рус)
S.L. In-game Editor (한) (рус)
List and usage of Triggers / 트리거 목록과 사용 방법:
- Click/Walk Trigger (한) (рус)
- Command Trigger (한) (рус)
- Area Trigger (한) (рус)
- Named Trigger (한) (рус)
- Custom Trigger (한) (рус)
- Inventory Trigger (한) (рус)
- Repeating Trigger (한) (рус)
- 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 조건
- Local Variables / 지역 변수
- Global Variables / 전역 변수
S.L. Understanding Exceptions (한) (рус)
- Using Methods / 메소드 사용법
- Special Data Types / 특수한 데이터 형식
- Reading Javadocs / Javadoc 읽기
- Handling Enum / Enum 데이터 처리
- Lambda Expresion / Lambda(람다) 식 사용법
- Creating an empty array / 빈 배열 만들기
- Storing data into array / 배열에 데이터값 저장하기
- Read data from array / 배열에서 데이터 읽기(불러오기)
- WHILE loop / WHILE 반복문
- FOR loop / FOR 반복문
- Iterating Collection / Collection 형식의 변수 순회법
- #BREAK executor / #BREAK 실행자
- #CONTINUE executor / #CONTINUE 실행자
- #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 예외처리 이해하기
16. Interface Casting (한) (рус)
module x.x does not "opens x.x" problem
- List of Custom Events