Compare commits

...

4 Commits

Author SHA1 Message Date
mfnalex a6b3dd7a09 fixed McVersion import, fixes #170 2023-03-30 17:05:49 +02:00
mfnalex c95c4421e3
Delete GH actions
Fixes #170
2023-03-30 16:59:44 +02:00
mfnalex 7ef483554d Merge remote-tracking branch 'origin/master' 2023-03-30 15:22:11 +02:00
mfnalex 3e5dccc9bd 13.6.0 2023-03-30 15:22:04 +02:00
6 changed files with 46 additions and 39 deletions

View File

@ -1,34 +0,0 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

16
pom.xml
View File

@ -9,7 +9,7 @@
<name>ChestSort</name>
<url>https://www.chestsort.de</url>
<description>Allows automatic chest sorting!</description>
<version>13.5.1</version>
<version>13.6.0</version>
<packaging>jar</packaging>
<properties>
@ -87,6 +87,11 @@
<shadedPattern>de.jeff_media.chestsort.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.jeff_media.morepersistentdatatypes</pattern>
<shadedPattern>com.jeff_media.chestsort.morepersistentdatatypes</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<excludes>
@ -204,10 +209,17 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jeff_media</groupId>
<artifactId>MorePersistentDataTypes</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jeff_media</groupId>
<artifactId>JeffLib</artifactId>
<version>12.0.0</version>
<version>12.3.1</version>
<scope>compile</scope>
</dependency>

View File

@ -51,7 +51,7 @@ import de.jeff_media.chestsort.listeners.ChestSortListener;
import de.jeff_media.chestsort.placeholders.Placeholders;
import de.jeff_media.chestsort.utils.Utils;
import com.jeff_media.jefflib.JeffLib;
import com.jeff_media.jefflib.McVersion;
import com.jeff_media.jefflib.data.McVersion;
import com.jeff_media.jefflib.NBTAPI;
import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics;

View File

@ -1,8 +1,11 @@
package de.jeff_media.chestsort.gui;
import com.jeff_media.morepersistentdatatypes.DataType;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.data.PlayerSetting;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -10,6 +13,10 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class GUIListener implements Listener {
private static final ChestSortPlugin main = ChestSortPlugin.getInstance();
@ -26,8 +33,12 @@ public class GUIListener implements Listener {
if(!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player) event.getWhoClicked();
PlayerSetting setting = main.getPlayerSetting(player);
String function = clicked.getItemMeta().getPersistentDataContainer().getOrDefault(new NamespacedKey(main,"function"), PersistentDataType.STRING,"");
String function = Objects.requireNonNull(clicked.getItemMeta()).getPersistentDataContainer().getOrDefault(new NamespacedKey(main,"function"), PersistentDataType.STRING,"");
List<String> userCommands = clicked.getItemMeta().getPersistentDataContainer().getOrDefault(new NamespacedKey(main,"user-commands"), DataType.asList(DataType.STRING), new ArrayList<>());
List<String> adminCommands = clicked.getItemMeta().getPersistentDataContainer().getOrDefault(new NamespacedKey(main,"admin-commands"), DataType.asList(DataType.STRING), new ArrayList<>());
executeCommands(player, player, userCommands);
executeCommands(player, Bukkit.getConsoleSender(), adminCommands);
//System.out.println("Click in GUI: " + function);
switch (function) {
@ -44,6 +55,12 @@ public class GUIListener implements Listener {
}
new NewUI(player).showGUI();
}
private void executeCommands(Player player, CommandSender sender, List<String> commands) {
for(String command : commands) {
main.getServer().dispatchCommand(sender, command.replace("{player}", player.getName()));
}
}
}

View File

@ -1,5 +1,6 @@
package de.jeff_media.chestsort.gui;
import com.jeff_media.morepersistentdatatypes.DataType;
import de.jeff_media.chestsort.ChestSortPlugin;
import de.jeff_media.chestsort.enums.Hotkey;
import com.jeff_media.jefflib.ItemStackUtils;
@ -13,6 +14,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.List;
public class NewUI {
private static final ChestSortPlugin main = ChestSortPlugin.getInstance();
@ -44,6 +47,10 @@ public class NewUI {
ItemMeta meta = button.getItemMeta();
assert meta != null;
meta.getPersistentDataContainer().set(new NamespacedKey(main,"function"),PersistentDataType.STRING, buttonName.split("-")[0]);
List<String> userCommands = conf.getStringList("items." + buttonName + ".commands.player");
List<String> adminCommands = conf.getStringList("items." + buttonName + ".commands.console");
meta.getPersistentDataContainer().set(new NamespacedKey(main,"user-commands"), DataType.asList(DataType.STRING), userCommands);
meta.getPersistentDataContainer().set(new NamespacedKey(main,"admin-commands"), DataType.asList(DataType.STRING), adminCommands);
button.setItemMeta(meta);
}
return button;

View File

@ -21,6 +21,11 @@
# enchantments:
# unbreaking: 3
# efficiency: 5
# commands:
# player:
# - "say Hello" # command that will be run as the player
# console:
# - "tell {player} Hello" # command that will be run as the console
title: "<#000000>&l[<#007700>&lChest<#339933>&lSort<#000000>&l] &rSettings"
size: 45