项目初始化
This commit is contained in:
commit
eda94fb915
165
pom.xml
Normal file
165
pom.xml
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<groupId>cc.carm.plugin</groupId>
|
||||||
|
<artifactId>TestPlugin</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-bom</artifactId>
|
||||||
|
<version>1.3.1</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<url>https://repo1.maven.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>carm-repo</id>
|
||||||
|
<name>Carm's Repo</name>
|
||||||
|
<url>https://repo.carm.cc/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-main</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-configuration</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-gui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-database</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.tr7zw</groupId>
|
||||||
|
<artifactId>item-nbt-api</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.10.9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
<configuration>
|
||||||
|
<useSystemClassLoader>false</useSystemClassLoader>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<compilerArgument>-parameters</compilerArgument>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>cc.carm.lib.easyplugin</pattern>
|
||||||
|
<shadedPattern>cc.carm.plugin.test.lib.easyplugin</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
|
<exclude>META-INF/*.txt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</project>
|
17
src/main/java/cc/carm/plugin/test/Main.java
Normal file
17
src/main/java/cc/carm/plugin/test/Main.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package cc.carm.plugin.test;
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.EasyPlugin;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUI;
|
||||||
|
import cc.carm.plugin.test.command.TestCommand;
|
||||||
|
|
||||||
|
public class Main extends EasyPlugin {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean initialize() {
|
||||||
|
GUI.initialize(this);
|
||||||
|
registerCommand("Test", new TestCommand());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
src/main/java/cc/carm/plugin/test/command/TestCommand.java
Normal file
32
src/main/java/cc/carm/plugin/test/command/TestCommand.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package cc.carm.plugin.test.command;
|
||||||
|
|
||||||
|
import cc.carm.plugin.test.ui.SoundsGUI;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class TestCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player)) return true;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (args.length < 1) return false;
|
||||||
|
String aim = args[0];
|
||||||
|
if (aim.equalsIgnoreCase("gui")) {
|
||||||
|
SoundsGUI.open((Player) sender);
|
||||||
|
} else if (aim.equalsIgnoreCase("item")) {
|
||||||
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
NBTItem nbtItem = new NBTItem(item);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
player.sendMessage(gson.toJson(nbtItem.getCompound()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
49
src/main/java/cc/carm/plugin/test/ui/SoundsGUI.java
Normal file
49
src/main/java/cc/carm/plugin/test/ui/SoundsGUI.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package cc.carm.plugin.test.ui;
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||||
|
import cc.carm.lib.easyplugin.utils.ItemStackFactory;
|
||||||
|
import cc.carm.plugin.test.utils.gui.AutoPagedGUI;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
public class SoundsGUI extends AutoPagedGUI {
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
|
||||||
|
|
||||||
|
private SoundsGUI(Player player) {
|
||||||
|
super(GUIType.SIX_BY_NINE, "Sounds", 10, 43);
|
||||||
|
this.player = player;
|
||||||
|
setPreviousPageSlot(18);
|
||||||
|
setNextPageSlot(26);
|
||||||
|
|
||||||
|
loadItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadItems() {
|
||||||
|
for (Sound value : Sound.values()) {
|
||||||
|
addItem(new GUIItem(new ItemStackFactory(Material.NOTE_BLOCK)
|
||||||
|
.setDisplayName(value.name())
|
||||||
|
.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
setDisplay(new ItemStackFactory(Material.DIAMOND_BLOCK).setDisplayName(value.name()).toItemStack());
|
||||||
|
getPlayer().playSound(player.getLocation(), value, 1, 1);
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void open(Player player) {
|
||||||
|
SoundsGUI gui = new SoundsGUI(player);
|
||||||
|
gui.openGUI(player);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package cc.carm.plugin.test.utils.gui;
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class AutoPagedGUI extends CommonPagedGUI {
|
||||||
|
|
||||||
|
ItemStack previousPageUI;
|
||||||
|
ItemStack nextPageUI;
|
||||||
|
int previousPageSlot = -1;
|
||||||
|
int nextPageSlot = -1;
|
||||||
|
|
||||||
|
public AutoPagedGUI(GUIType type, String name, int[] range) {
|
||||||
|
super(type, name, range);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AutoPagedGUI(GUIType type, String name, int a, int b) {
|
||||||
|
super(type, name, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousPageUI(ItemStack lastPageUI) {
|
||||||
|
this.previousPageUI = lastPageUI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextPageUI(ItemStack nextPageUI) {
|
||||||
|
this.nextPageUI = nextPageUI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousPageSlot(int slot) {
|
||||||
|
this.previousPageSlot = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextPageSlot(int slot) {
|
||||||
|
this.nextPageSlot = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openGUI(Player user) {
|
||||||
|
if (previousPageSlot >= 0) {
|
||||||
|
if (hasPreviousPage()) {
|
||||||
|
setItem(previousPageSlot, new GUIItem(
|
||||||
|
previousPageUI == null ? new ItemStack(Material.ARROW) : previousPageUI) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
if (type == ClickType.RIGHT) {
|
||||||
|
goFirstPage();
|
||||||
|
} else {
|
||||||
|
goPreviousPage();
|
||||||
|
}
|
||||||
|
openGUI(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setItem(previousPageSlot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextPageSlot >= 0) {
|
||||||
|
if (hasNextPage()) {
|
||||||
|
setItem(nextPageSlot, new GUIItem(
|
||||||
|
nextPageUI == null ? new ItemStack(Material.ARROW) : nextPageUI) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
if (type == ClickType.RIGHT) {
|
||||||
|
goLastPage();
|
||||||
|
} else {
|
||||||
|
goNextPage();
|
||||||
|
}
|
||||||
|
openGUI(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setItem(nextPageSlot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
super.openGUI(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
162
src/main/java/cc/carm/plugin/test/utils/gui/CommonPagedGUI.java
Normal file
162
src/main/java/cc/carm/plugin/test/utils/gui/CommonPagedGUI.java
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
package cc.carm.plugin.test.utils.gui;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommonPagedGUI extends PagedGUI {
|
||||||
|
|
||||||
|
private int[] range;
|
||||||
|
|
||||||
|
private CommonPagedGUI(GUIType type, String name) {
|
||||||
|
super(type, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonPagedGUI(GUIType type, String Name, int a, int b) {
|
||||||
|
this(type, Name, toRange(type, a, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonPagedGUI(GUIType type, String Name, int[] range) {
|
||||||
|
super(type, Name);
|
||||||
|
Arrays.sort(range);
|
||||||
|
this.range = range;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
int[] matrix = new int[]{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||||
|
9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||||
|
18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||||
|
27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||||
|
36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||||
|
45, 46, 47, 48, 49, 50, 51, 52, 53
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static int[] toRange(GUIType type, int a, int b) {
|
||||||
|
if (a > b) {
|
||||||
|
a = a ^ b;
|
||||||
|
b = a ^ b;
|
||||||
|
a = a ^ b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lineA = getLine(a);
|
||||||
|
int columnA = getColumn(a);
|
||||||
|
int lineB = getLine(b);
|
||||||
|
int columnB = getColumn(b);
|
||||||
|
|
||||||
|
if (lineB > type.getLines())
|
||||||
|
throw new IndexOutOfBoundsException("页面内容范围超过了GUI的大小");
|
||||||
|
|
||||||
|
int[] range = new int[(lineB - lineA + 1) * (columnB - columnA + 1)];
|
||||||
|
|
||||||
|
for (int i = 0, l = 0; i < type.getSize(); i++) {
|
||||||
|
int li = getLine(i);
|
||||||
|
int ci = getColumn(i);
|
||||||
|
if (li >= lineA && li <= lineB && ci >= columnA && ci <= columnB) {
|
||||||
|
range[l] = i;
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getLine(int i) {
|
||||||
|
return i / 9 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getColumn(int i) {
|
||||||
|
return i % 9 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPreviousPage() {
|
||||||
|
return page > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNextPage() {
|
||||||
|
return page < getLastPageNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前往第一页
|
||||||
|
*/
|
||||||
|
public void goFirstPage() {
|
||||||
|
if (hasPreviousPage())
|
||||||
|
this.page = 1;
|
||||||
|
else
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前往最后一页
|
||||||
|
*/
|
||||||
|
public void goLastPage() {
|
||||||
|
if (hasNextPage())
|
||||||
|
this.page = getLastPageNumber();
|
||||||
|
else
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到最后一页的页码
|
||||||
|
*
|
||||||
|
* @return 最后一页的页码
|
||||||
|
*/
|
||||||
|
public int getLastPageNumber() {
|
||||||
|
return (this.container.size() / range.length) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到第一页的页码
|
||||||
|
*
|
||||||
|
* @return 第一页页码(默认为1)
|
||||||
|
*/
|
||||||
|
public int getFirstPageNumber() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openGUI(Player player) {
|
||||||
|
if (container.isEmpty()) {
|
||||||
|
super.openGUI(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<GUIItem> list = new ArrayList<>();
|
||||||
|
int start = (page - 1) * range.length;
|
||||||
|
for (int i = start; i < start + range.length; i++) {
|
||||||
|
if (i < container.size()) {
|
||||||
|
list.add(container.get(i));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
Arrays.stream(range).forEach(index -> setItem(index, null));
|
||||||
|
for (int index : range) {
|
||||||
|
if (i < list.size()) {
|
||||||
|
setItem(index, list.get(i));
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.openGUI(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
79
src/main/java/cc/carm/plugin/test/utils/gui/PagedGUI.java
Normal file
79
src/main/java/cc/carm/plugin/test/utils/gui/PagedGUI.java
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package cc.carm.plugin.test.utils.gui;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUI;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||||
|
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class PagedGUI extends GUI {
|
||||||
|
|
||||||
|
List<GUIItem> container = new ArrayList<>();
|
||||||
|
public int page = 1;
|
||||||
|
|
||||||
|
public PagedGUI(GUIType type, String name) {
|
||||||
|
super(type, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int addItem(GUIItem i) {
|
||||||
|
container.add(i);
|
||||||
|
return container.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从GUI中移除一个物品
|
||||||
|
*
|
||||||
|
* @param item 物品
|
||||||
|
*/
|
||||||
|
public void removeItem(GUIItem item) {
|
||||||
|
container.remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从GUI中移除一个物品
|
||||||
|
*
|
||||||
|
* @param slot 物品格子数
|
||||||
|
*/
|
||||||
|
public void removeItem(int slot) {
|
||||||
|
container.remove(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GUIItem> getItemsContainer() {
|
||||||
|
return new ArrayList<>(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前往上一页
|
||||||
|
*/
|
||||||
|
public void goPreviousPage() {
|
||||||
|
if (hasPreviousPage())
|
||||||
|
page--;
|
||||||
|
else
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前往下一页
|
||||||
|
*/
|
||||||
|
public void goNextPage() {
|
||||||
|
if (hasNextPage())
|
||||||
|
page++;
|
||||||
|
else
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否有上一页
|
||||||
|
*/
|
||||||
|
public abstract boolean hasPreviousPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 是否有下一页
|
||||||
|
*/
|
||||||
|
public abstract boolean hasNextPage();
|
||||||
|
|
||||||
|
}
|
13
src/main/resources/plugin.yml
Normal file
13
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
main: cc.carm.plugin.test.Main
|
||||||
|
name: TestPlugin
|
||||||
|
version: ${project.version}
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- CarmJos
|
||||||
|
api-version: 1.13
|
||||||
|
|
||||||
|
softdepend:
|
||||||
|
- PlaceholderAPI
|
||||||
|
|
||||||
|
commands:
|
||||||
|
"Test":
|
Loading…
Reference in New Issue
Block a user