mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2024-09-19 19:25:45 +00:00
parent
376cde3529
commit
fb125ee9bd
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -13,10 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class GUI {
|
||||
@ -56,9 +53,9 @@ public class GUI {
|
||||
*/
|
||||
boolean cancelOnOuter = true;
|
||||
|
||||
Map<String, Object> flags;
|
||||
protected final Map<String, Object> flags = new LinkedHashMap<>();
|
||||
|
||||
GUIListener listener;
|
||||
protected GUIListener listener;
|
||||
|
||||
public GUI(GUIType type, String name) {
|
||||
this.type = type;
|
||||
@ -131,24 +128,15 @@ public class GUI {
|
||||
this.cancelOnOuter = b;
|
||||
}
|
||||
|
||||
public void addFlag(String flag, Object obj) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.put(flag, obj);
|
||||
}
|
||||
|
||||
public Object getFlag(String flag) {
|
||||
if (this.flags == null) return null;
|
||||
else
|
||||
return this.flags.get(flag);
|
||||
return this.flags.get(flag);
|
||||
}
|
||||
|
||||
public void setFlag(String flag, Object obj) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.replace(flag, obj);
|
||||
this.flags.put(flag, obj);
|
||||
}
|
||||
|
||||
public void removeFlag(String flag) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.remove(flag);
|
||||
}
|
||||
|
||||
@ -193,6 +181,13 @@ public class GUI {
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
public GUIType getGUIType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getGUIName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static void setOpenedGUI(Player player, GUI gui) {
|
||||
getOpenedGUIs().put(player.getUniqueId(), gui);
|
||||
|
@ -37,12 +37,24 @@ public class GUIItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家点击GUI后执行的代码
|
||||
* 玩家点击该物品后执行的代码
|
||||
* 可以使用 {@link #onClick(Player, ClickType)} 操作点击者
|
||||
*
|
||||
* @param type 点击的类型
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
public void onClick(ClickType type) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家点击GUI后执行的代码
|
||||
*
|
||||
* @param clicker 点击的玩家
|
||||
* @param type 点击的类型
|
||||
*/
|
||||
public void onClick(Player clicker, ClickType type) {
|
||||
this.onClick(type); // Deprecated method support
|
||||
}
|
||||
|
||||
public void addClickAction(GUIClickAction action) {
|
||||
@ -58,7 +70,7 @@ public class GUIItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家点击GUI后执行的代码
|
||||
* 自定义点击事件代码 (须自行触发)
|
||||
*
|
||||
* @param player 点击GUI的玩家
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public class GUIListener implements Listener {
|
||||
GUIItem clickedItem = getCurrentGUI().getItem(event.getSlot());
|
||||
if (clickedItem != null) {
|
||||
if (clickedItem.isActionActive()) {
|
||||
clickedItem.onClick(event.getClick());
|
||||
clickedItem.onClick(player, event.getClick());
|
||||
clickedItem.rawClickAction(event);
|
||||
clickedItem.actions.forEach(action -> action.run(event.getClick(), player));
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public enum GUIType {
|
||||
SIX_BY_NINE(6, 54),
|
||||
CANCEL(0, 0);
|
||||
|
||||
int lines;
|
||||
int size;
|
||||
private final int lines;
|
||||
private final int size;
|
||||
|
||||
GUIType(int lines, int size) {
|
||||
this.lines = lines;
|
||||
|
@ -49,7 +49,7 @@ public class AutoPagedGUI extends CommonPagedGUI {
|
||||
setItem(previousPageSlot, new GUIItem(
|
||||
previousPageUI == null ? getDefaultPreviousPage(user) : previousPageUI) {
|
||||
@Override
|
||||
public void onClick(ClickType type) {
|
||||
public void onClick(Player clicker, ClickType type) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
goFirstPage();
|
||||
} else {
|
||||
@ -68,7 +68,7 @@ public class AutoPagedGUI extends CommonPagedGUI {
|
||||
setItem(nextPageSlot, new GUIItem(
|
||||
nextPageUI == null ? getDefaultNextPage(user) : nextPageUI) {
|
||||
@Override
|
||||
public void onClick(ClickType type) {
|
||||
public void onClick(Player clicker, ClickType type) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
goLastPage();
|
||||
} else {
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
Loading…
Reference in New Issue
Block a user