mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-29 22:24:06 +01:00
8.9 release
This commit is contained in:
parent
9a948b6103
commit
1334d90cbc
@ -1,4 +1,9 @@
|
||||
# Changelog
|
||||
## 8.9
|
||||
- Prevent BossShopPro's GUI from being sorted
|
||||
- Added custom event to let 3rd party plugins cancel sorting an inventory, see updated API doc for more information
|
||||
- Published ChestSort in public maven repository repo.jeff-media.de/maven2, see updated API doc for more information
|
||||
|
||||
## 8.8.2
|
||||
- Fixes exception when sorting inventories containing potions in ancient Minecraft versions like 1.8
|
||||
|
||||
|
@ -2,32 +2,71 @@
|
||||
|
||||
If you want to use ChestSort's advanced sorting features for your own plugin, you can use the ChestSort API. It provides methods to sort any given inventory, following the rules you have specified in your ChestSort's plugin.yml and the corresponding category files.
|
||||
|
||||
To use ChestSort's sorting features in your Spigot/Bukkit plugin, you have to import ChestSort.jar into your BuildPath.
|
||||
## Maven repository
|
||||
You can use maven to add ChestSort as a dependency to your Spigot-/Bukkit-Plugin:
|
||||
|
||||
```
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jeff-media-repo</id>
|
||||
<url>https://repo.jeff-media.de/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>ChestSort</artifactId>
|
||||
<version>8.9</version> <!-- Check www.chestsort.de for latest version -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## Accessing the API
|
||||
Then you can access it via the plugin manager:
|
||||
|
||||
```
|
||||
JeffChestSortPlugin chestSort = (JeffChestSortPlugin) getServer().getPluginManager().getPlugin("ChestSort");
|
||||
|
||||
if(chestSort==null || !(chestSort instanceof JeffChestSortPlugin)) {
|
||||
getLogger().warning("ChestSort plugin not found.");
|
||||
ChestSortPlugin chestSort = (ChestSortPlugin) getServer().getPluginManager().getPlugin("ChestSort");
|
||||
if(chestSort==null || !(chestSort instanceof ChestSortPlugin)) {
|
||||
getLogger().severe("Error: ChestSort is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
ChestSortAPI chestSortAPI = chestSort.getAPI();
|
||||
```
|
||||
|
||||
### Sorting inventories
|
||||
|
||||
Now, you can sort any Inventory! Just like this:
|
||||
|
||||
```
|
||||
chestSort.sortInventory(Inventory inventory);
|
||||
chestSortAPI.sortInventory(Inventory inventory);
|
||||
```
|
||||
|
||||
To sort only specific slots, you can pass slot numbers where to start and end sorting. ChestSort will not modify the inventory outside the given slot range.
|
||||
|
||||
```
|
||||
chestSort.sortInventory(Inventory inventory, int startSlot, int endSlot);
|
||||
chestSortAPI.sortInventory(Inventory inventory, int startSlot, int endSlot);
|
||||
```
|
||||
|
||||
You can also check if a player has automatic sorting enabled or disabled:
|
||||
|
||||
```
|
||||
boolean sortingEnabled = chestSort.sortingEnabled(Player player);
|
||||
```
|
||||
boolean sortingEnabled = chestSortAPI.sortingEnabled(Player player);
|
||||
```
|
||||
|
||||
### Custom ChestSort event
|
||||
|
||||
If you want to prevent ChestSort from sorting a certain inventory, you can listen to the ChestSortEvent event.
|
||||
|
||||
```
|
||||
@EventHandler
|
||||
public void onChestSortEvent(ChestSortEvent event) {
|
||||
if(event.getInventory() == whatever) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Example Plugin
|
||||
|
||||
Here is a complete example plugin that shows to add and use the ChestSort API: [LINK](https://github.com/JEFF-Media-GbR/ChestSortAPIExample)
|
24
README.md
24
README.md
@ -6,6 +6,25 @@ Please see the related topic at spigotmc.org for information regarding the comma
|
||||
|
||||
https://www.spigotmc.org/resources/1-13-chestsort.59773/
|
||||
|
||||
## Maven repository
|
||||
If you want to use ChestSort as dependency for your own plugin, you can use our public maven repository:
|
||||
|
||||
```
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jeff-media-repo</id>
|
||||
<url>https://repo.jeff-media.de/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>ChestSort</artifactId>
|
||||
<version>8.9</version> <!-- Check www.chestsort.de for latest version -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
## Building .jar file
|
||||
To build the .jar file, you will need maven. Also, the CrackShot library is in no public repository, so please create a directory called `lib` and put the latest CrackShot.jar file [(available here)](https://www.spigotmc.org/resources/crackshot-guns.48301/) inside it. Now you can do `mvn install`
|
||||
|
||||
@ -13,6 +32,11 @@ To build the .jar file, you will need maven. Also, the CrackShot library is in n
|
||||
ChestSort takes an instance of org.bukkit.inventory.Inventory and copies the contents. The resulting array is sorted by rules defined in the config.yml. This takes far less than one millisecond for a whole chest. So there should be no problems even on big servers, where hundreds of players are using chests at the same time.
|
||||
The plugin should cause no lag at all.
|
||||
|
||||
## API
|
||||
If you want to use ChestSort's advanced sorting features for your own plugin, you can use the ChestSort API. It provides methods to sort any given inventory, following the rules you have specified in your ChestSort's plugin.yml and the corresponding category files.
|
||||
|
||||
More information about the API can be found [HERE](https://github.com/JEFF-Media-GbR/Spigot-ChestSort/blob/master/HOW_TO_USE_API.md).
|
||||
|
||||
## Screenshots
|
||||
<p align="center"><img src="https://www.spigotmc.org/attachments/chestsort-screen2-jpg.382332/" alt="Screenshot ChestSort" /></p>
|
||||
|
||||
|
43
pom.xml
43
pom.xml
@ -4,13 +4,13 @@
|
||||
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>
|
||||
|
||||
<groupId>de.jeffclan</groupId>
|
||||
<artifactId>JeffChestSort</artifactId>
|
||||
<version>8.8.3-pre1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>ChestSort</artifactId>
|
||||
<name>JeffChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Automatically sorts your chests!</description>
|
||||
<version>8.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -18,6 +18,7 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -34,11 +35,8 @@
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<finalName>ChestSort</finalName>
|
||||
|
||||
</configuration>
|
||||
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@ -60,8 +58,16 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
@ -90,8 +96,6 @@
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> <groupId>net.md-5</groupId> <artifactId>bungeecord-api</artifactId>
|
||||
<version>1.15-SNAPSHOT</version> <scope>compile</scope> </dependency> -->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
@ -105,19 +109,18 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/CrackShot.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.jojodmo.customitems</groupId>
|
||||
<artifactId>CustomItems</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/CustomItemsAPI_PLACEHOLDER.jar</systemPath>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>Minepacks-API</artifactId>
|
||||
<version>2.3.8</version><!-- Check api-version shield for newest version -->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<description>Automatically sorts your chests!</description>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>jeff-ftp</id>
|
||||
<url>ftps://ftp.jeff-media.de/maven2</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
|
@ -1,24 +1,39 @@
|
||||
package de.jeff_media.ChestSort;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ChestSortEvent extends Event implements Cancellable {
|
||||
|
||||
boolean cancelled = false;
|
||||
Location loc;
|
||||
Inventory inv;
|
||||
Player p;
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public ChestSortEvent(Location loc) {
|
||||
this.loc=loc;
|
||||
public ChestSortEvent(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Location getLocation() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
|
@ -399,12 +399,10 @@ public class ChestSortListener implements Listener {
|
||||
@EventHandler
|
||||
public void onAdditionalHotkeys(InventoryClickEvent e) {
|
||||
|
||||
if(e.getClickedInventory() != null && e.getClickedInventory().getLocation()!=null) {
|
||||
ChestSortEvent chestSortEvent = new ChestSortEvent(e.getClickedInventory().getLocation());
|
||||
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
||||
if (chestSortEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Debug
|
||||
if(plugin.debug) {
|
||||
System.out.println(e.getInventory().getHolder());
|
||||
System.out.println(e.getInventory().getHolder().getClass().getName());
|
||||
}
|
||||
|
||||
if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
|
||||
@ -431,12 +429,26 @@ public class ChestSortListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't sort inventories belonging to BossShopPro
|
||||
if(e.getInventory()!=null && e.getInventory().getHolder()!=null && e.getInventory().getHolder().getClass().getName().equalsIgnoreCase("org.black_ixx.bossshop.core.BSShopHolder")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !p.hasPermission("chestsort.use")) return;
|
||||
|
||||
plugin.registerPlayerIfNeeded(p);
|
||||
ChestSortPlayerSetting setting = plugin.perPlayerSettings.get(p.getUniqueId().toString());
|
||||
|
||||
|
||||
ChestSortEvent chestSortEvent = new ChestSortEvent(e.getInventory());
|
||||
chestSortEvent.loc=e.getWhoClicked().getLocation();
|
||||
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
||||
if (chestSortEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(e.isLeftClick() && setting.leftClick) {
|
||||
|
||||
plugin.organizer.stuffPlayerInventoryIntoAnother(p.getInventory(), e.getInventory());
|
||||
plugin.organizer.sortInventory(e.getInventory());
|
||||
plugin.organizer.updateInventoryView(e.getInventory());
|
||||
|
@ -388,7 +388,8 @@ public class ChestSortOrganizer {
|
||||
void sortInventory(Inventory inv, int startSlot, int endSlot) {
|
||||
|
||||
if(inv.getLocation() != null) {
|
||||
ChestSortEvent chestSortEvent = new ChestSortEvent(inv.getLocation());
|
||||
ChestSortEvent chestSortEvent = new ChestSortEvent(inv);
|
||||
chestSortEvent.loc = inv.getLocation();
|
||||
Bukkit.getPluginManager().callEvent(chestSortEvent);
|
||||
if (chestSortEvent.isCancelled()) {
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: de.jeff_media.ChestSort.ChestSortPlugin
|
||||
name: ChestSort
|
||||
version: 8.8.3-pre1
|
||||
version: 8.9
|
||||
api-version: 1.13
|
||||
description: Allows automatic chest sorting
|
||||
author: mfnalex
|
||||
|
Loading…
Reference in New Issue
Block a user