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