Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.bukkit.event.inventory.ClickType; | ||
|
||
/** | ||
* Defines a click handler. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD }) | ||
public @interface ClickHandler { | ||
/** | ||
* An optional filter for specific click types. | ||
*/ | ||
ClickType[] value() default {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
public class InventoryMenu { | ||
public InventoryMenu(Menu menu) { | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/net/citizensnpcs/api/gui/InventoryMenuPattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
public class InventoryMenuPattern { | ||
public InventoryMenuPattern(InventoryMenu menu, MenuPattern pattern) { | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/net/citizensnpcs/api/gui/InventoryMenuSlot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
public class InventoryMenuSlot { | ||
public InventoryMenuSlot(InventoryMenu menu, MenuSlot slot) { | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/net/citizensnpcs/api/gui/InventoryMenuTransition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
public class InventoryMenuTransition { | ||
public InventoryMenuTransition(InventoryMenu menu, MenuTransition transition) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.bukkit.event.inventory.ClickType; | ||
|
||
/** | ||
* Defines a GUI inventory menu. Can be linked to a {@link InventoryMenuPattern} or simply at the class level. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
public @interface Menu { | ||
|
||
/** | ||
* The dimensions of the menu, if supported. | ||
*/ | ||
int[] dimensions() default { 3, 3 }; | ||
|
||
/** | ||
* The click types to allow by default. Empty = all allowed | ||
*/ | ||
ClickType[] filter() default {}; | ||
|
||
/** | ||
* The menu title. | ||
*/ | ||
String title() default ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.util.Map; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.inventory.Inventory; | ||
|
||
import com.google.common.collect.Maps; | ||
|
||
/** | ||
* A context class passed into the constructor of a {@link Menu} instance. | ||
*/ | ||
public class MenuContext { | ||
private final Map<String, Object> data = Maps.newHashMap(); | ||
private final Inventory inventory; | ||
private final InventoryMenu parent; | ||
private final Entity user; | ||
|
||
public MenuContext(InventoryMenu parent, Inventory inventory, Entity user, Map<String, Object> data) { | ||
this.inventory = inventory; | ||
this.parent = parent; | ||
this.user = user; | ||
this.data.putAll(data); | ||
} | ||
|
||
public Map<String, Object> data() { | ||
return data; | ||
} | ||
|
||
public Inventory getInventory() { | ||
return inventory; | ||
} | ||
|
||
public InventoryMenu getParent() { | ||
return parent; | ||
} | ||
|
||
public Entity getUser() { | ||
return user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.bukkit.Material; | ||
|
||
/** | ||
* Defines a pattern of slots. Can be linked to a {@link InventoryMenuPattern} or simply at the class level. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.FIELD }) | ||
public @interface MenuPattern { | ||
/** | ||
* The amount of the itemstacks to display. | ||
*/ | ||
int amount() default 1; | ||
|
||
/** | ||
* The material to display (defaults to AIR). | ||
*/ | ||
Material material() default Material.AIR; | ||
|
||
/** | ||
* The pattern string. 0 = AIR | ||
*/ | ||
String value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.event.inventory.ClickType; | ||
|
||
/** | ||
* Defines a slot with a certain item. Can be linked to a {@link InventoryMenuSlot} or simply at the class level. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.FIELD }) | ||
public @interface MenuSlot { | ||
/** | ||
* The amount of the itemstack to display. | ||
*/ | ||
int amount() default 1; | ||
|
||
/** | ||
* Whitelist the allowed clicktypes (empty = all allowed). | ||
*/ | ||
ClickType[] filter() default {}; | ||
|
||
/** | ||
* The material to display (defaults to AIR). For extra customisation see {@link InventoryMenuSlot}. | ||
*/ | ||
Material material() default Material.AIR; | ||
|
||
/** | ||
* The position of the slot within the inventory. | ||
*/ | ||
int[] value() default { 0, 0 }; | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/net/citizensnpcs/api/gui/MenuTransition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.citizensnpcs.api.gui; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.event.inventory.ClickType; | ||
|
||
/** | ||
* Defines a menu transition to a new sub-menu. Can be linked to a {@link InventoryMenuTransition} or simply at the | ||
* class level. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.FIELD }) | ||
public @interface MenuTransition { | ||
/** | ||
* The amount of the itemstack to display. | ||
*/ | ||
int amount() default 1; | ||
|
||
/** | ||
* Whitelist the allowed clicktypes for transition (empty = all allowed). | ||
*/ | ||
ClickType[] filter() default {}; | ||
|
||
/** | ||
* The material to display (defaults to AIR). For extra customisation see {@link InventoryMenuTransition}. | ||
*/ | ||
Material material() default Material.AIR; | ||
|
||
/** | ||
* The position of the slot within the inventory. | ||
*/ | ||
int[] pos() default { 0, 0 }; | ||
|
||
/** | ||
* The next sub-menu class to transition to. | ||
*/ | ||
Class<?> value(); | ||
} |