Skip to content

Commit 1a7ce9e

Browse files
committed
changed build paper version to 1.21.10
1 parent 9641f7b commit 1a7ce9e

File tree

10 files changed

+50
-72
lines changed

10 files changed

+50
-72
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ⚡ QuickSort — плагин для сортировки инвентаря в Minecraft
22

3-
> 🧱 **Совместимость:** Paper / Spigot / Purpur 1.21.8
3+
> 🧱 **Совместимость:** Paper / Purpur 1.21.10
44
> 💡 **Использование:** SHIFT + ПКМ по пустому слоту (в инвентаре игрока или контейнера)
55
66
---
@@ -43,11 +43,10 @@
4343

4444
## 🧱 Совместимость
4545

46-
| Сервер | Версия | Статус |
47-
|--------|--------|--------|
48-
| Paper | 1.21.8 ||
49-
| Spigot | 1.21.8 ||
50-
| Purpur | 1.21.8 ||
46+
| Сервер | Версия | Статус |
47+
|--------|---------|--------|
48+
| Paper | 1.21.10 ||
49+
| Purpur | 1.21.10 ||
5150

5251
---
5352

@@ -62,7 +61,7 @@
6261

6362
## 🧠 Технические детали
6463

65-
- API: Bukkit / Paper 1.21.8
64+
- API: Paper 1.21.10
6665
- Язык: Java 21+
6766
- Без внешних зависимостей
6867
- Ключевые классы: `SortManager`, `CategoryManager`, `EventListener`, `QuickSort`

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = 'com.flyaway.quicksort'
6-
version = '1.2.0'
6+
version = '1.3.0'
77

88
java {
99
toolchain {
@@ -20,7 +20,7 @@ repositories {
2020
}
2121

2222
dependencies {
23-
compileOnly 'io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT'
23+
compileOnly 'io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT'
2424
}
2525

2626
tasks.jar {
File renamed without changes.

src/main/java/com/flyaway/quciksort/CategoryManager.java renamed to src/main/java/com/flyaway/quicksort/CategoryManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.flyaway.quicksort;
22

33
import org.bukkit.Material;
4-
import org.bukkit.configuration.ConfigurationSection;
54
import org.bukkit.configuration.file.FileConfiguration;
65

76
import java.util.*;

src/main/java/com/flyaway/quciksort/EventListener.java renamed to src/main/java/com/flyaway/quicksort/EventListener.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,57 +30,45 @@ public EventListener(QuickSort plugin) {
3030

3131
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
3232
public void onInventoryClick(InventoryClickEvent event) {
33-
// Only handle player clicks
34-
if (!(event.getWhoClicked() instanceof Player)) {
33+
if (!(event.getWhoClicked() instanceof Player player)) {
3534
return;
3635
}
3736

38-
Player player = (Player) event.getWhoClicked();
39-
40-
// Check if it's Shift+Right-Click
4137
if (event.getClick() != ClickType.SHIFT_RIGHT) {
4238
return;
4339
}
4440

45-
// Check if clicked on empty slot (air)
4641
ItemStack clickedItem = event.getCurrentItem();
4742
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
4843
return;
4944
}
5045

51-
// Check permission
5246
if (!sortManager.canSort(player)) {
5347
return;
5448
}
5549

56-
// Check cooldown
5750
if (sortManager.isOnCooldown(player)) {
5851
return;
5952
}
6053

61-
// Determine which inventory to sort
6254
Inventory targetInventory = null;
6355

64-
// Check if clicked in player inventory
6556
if (event.getClickedInventory() != null &&
6657
event.getClickedInventory().getType() == InventoryType.PLAYER) {
6758
targetInventory = player.getInventory();
6859
}
69-
// Check if clicked in an allowed container
60+
7061
else if (event.getClickedInventory() != null &&
7162
isAllowedContainer(event.getClickedInventory())) {
7263
targetInventory = event.getClickedInventory();
7364
}
7465

75-
// If no valid inventory found, return
7666
if (targetInventory == null) {
7767
return;
7868
}
7969

80-
// Cancel the click event
8170
event.setCancelled(true);
8271

83-
// Perform the sorting
8472
sortManager.sortInventory(targetInventory);
8573
sortManager.setCooldown(player);
8674
player.sendMessage("§aИнвентарь отсортирован!");
@@ -101,11 +89,7 @@ private boolean isAllowedContainer(Inventory inventory) {
10189
}
10290

10391
InventoryType type = inventory.getType();
104-
if (type == InventoryType.ENDER_CHEST
105-
|| type == InventoryType.SHULKER_BOX) {
106-
return true;
107-
}
108-
109-
return false;
92+
return type == InventoryType.ENDER_CHEST
93+
|| type == InventoryType.SHULKER_BOX;
11094
}
11195
}

src/main/java/com/flyaway/quciksort/ItemStackManager.java renamed to src/main/java/com/flyaway/quicksort/ItemStackManager.java

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/main/java/com/flyaway/quciksort/SortManager.java renamed to src/main/java/com/flyaway/quicksort/SortManager.java

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.flyaway.quicksort;
22

33
import org.bukkit.Material;
4+
import org.bukkit.enchantments.Enchantment;
45
import org.bukkit.entity.Player;
56
import org.bukkit.inventory.Inventory;
67
import org.bukkit.inventory.ItemStack;
78
import org.bukkit.inventory.PlayerInventory;
9+
import org.bukkit.inventory.meta.PotionMeta;
10+
import org.bukkit.potion.PotionType;
811

912
import java.util.*;
1013

@@ -27,9 +30,6 @@ public boolean canSort(Player player) {
2730

2831
public boolean isOnCooldown(Player player) {
2932
long cooldownTime = 1000L; // 1 second cooldown
30-
if (cooldownTime <= 0L) {
31-
return false;
32-
}
3333

3434
Long lastSort = sortCooldowns.get(player.getUniqueId());
3535
if (lastSort == null) {
@@ -147,9 +147,9 @@ private void sortCategoryByOrder(List<ItemStack> items, List<Material> order) {
147147
// Если порядок одинаковый, продолжаем сравнение
148148
}
149149
// Если один в порядке, а другой нет - тот что в порядке идет первым
150-
else if (index1 != -1 && index2 == -1) {
150+
else if (index1 != -1) {
151151
return -1;
152-
} else if (index1 == -1 && index2 != -1) {
152+
} else if (index2 != -1) {
153153
return 1;
154154
}
155155
// Если оба не в порядке или порядок одинаковый - сравниваем дальше
@@ -170,8 +170,8 @@ else if (index1 != -1 && index2 == -1) {
170170
}
171171

172172
private int compareByEnchantments(ItemStack item1, ItemStack item2) {
173-
Map<org.bukkit.enchantments.Enchantment, Integer> enchants1 = ItemStackManager.getAllEnchantments(item1);
174-
Map<org.bukkit.enchantments.Enchantment, Integer> enchants2 = ItemStackManager.getAllEnchantments(item2);
173+
Map<Enchantment, Integer> enchants1 = ItemStackManager.getAllEnchantments(item1);
174+
Map<Enchantment, Integer> enchants2 = ItemStackManager.getAllEnchantments(item2);
175175

176176
// Сначала по количеству зачарований (убывание)
177177
int enchantCount1 = enchants1.size();
@@ -181,9 +181,9 @@ private int compareByEnchantments(ItemStack item1, ItemStack item2) {
181181
}
182182

183183
// Если количество одинаковое — сравниваем по названию и уровню первого зачарования
184-
if (enchantCount1 > 0 && enchantCount2 > 0) {
185-
Map.Entry<org.bukkit.enchantments.Enchantment, Integer> enchant1 = enchants1.entrySet().iterator().next();
186-
Map.Entry<org.bukkit.enchantments.Enchantment, Integer> enchant2 = enchants2.entrySet().iterator().next();
184+
if (enchantCount1 > 0) {
185+
Map.Entry<Enchantment, Integer> enchant1 = enchants1.entrySet().iterator().next();
186+
Map.Entry<Enchantment, Integer> enchant2 = enchants2.entrySet().iterator().next();
187187

188188
String name1 = enchant1.getKey().getKey().getKey();
189189
String name2 = enchant2.getKey().getKey().getKey();
@@ -198,13 +198,6 @@ private int compareByEnchantments(ItemStack item1, ItemStack item2) {
198198
return 0;
199199
}
200200

201-
/**
202-
* Возвращает зачарования для любого предмета, включая зачарованные книги.
203-
*/
204-
private static Map<org.bukkit.enchantments.Enchantment, Integer> getAllEnchantments(ItemStack item) {
205-
return ItemStackManager.getAllEnchantments(item);
206-
}
207-
208201
private void sortPotions(List<ItemStack> potions, List<Material> order) {
209202
potions.sort((item1, item2) -> {
210203
int index1 = order.indexOf(item1.getType());
@@ -219,9 +212,9 @@ private void sortPotions(List<ItemStack> potions, List<Material> order) {
219212
// Если порядок одинаковый, продолжаем сравнение
220213
}
221214
// Если одно в порядке, а другое нет - то что в порядке идет первым
222-
else if (index1 != -1 && index2 == -1) {
215+
else if (index1 != -1) {
223216
return -1;
224-
} else if (index1 == -1 && index2 != -1) {
217+
} else if (index2 != -1) {
225218
return 1;
226219
}
227220
// Если оба не в порядке или порядок одинаковый - сравниваем дальше
@@ -263,7 +256,7 @@ else if (index1 != -1 && index2 == -1) {
263256
}
264257

265258
private boolean hasPotionEffect(ItemStack potion) {
266-
if (!(potion.getItemMeta() instanceof org.bukkit.inventory.meta.PotionMeta meta)) {
259+
if (!(potion.getItemMeta() instanceof PotionMeta meta)) {
267260
return false;
268261
}
269262

@@ -272,33 +265,26 @@ private boolean hasPotionEffect(ItemStack potion) {
272265
return true;
273266
}
274267

275-
// Новый способ проверки базового типа зелья
276-
org.bukkit.potion.PotionType potionType = meta.getBasePotionType();
268+
PotionType potionType = meta.getBasePotionType();
277269
if (potionType == null) return false;
278270

279271
// Безэффектные типы — всегда false
280272
return !isEffectlessPotion(potionType);
281273
}
282274

283-
private boolean isEffectlessPotion(org.bukkit.potion.PotionType potionType) {
284-
switch (potionType) {
285-
case WATER:
286-
case MUNDANE:
287-
case THICK:
288-
case AWKWARD:
289-
return true;
290-
default:
291-
return false;
292-
}
275+
private boolean isEffectlessPotion(PotionType potionType) {
276+
return switch (potionType) {
277+
case WATER, MUNDANE, THICK, AWKWARD -> true;
278+
default -> false;
279+
};
293280
}
294281

295282
private String getPotionEffectName(ItemStack potion) {
296-
if (potion.getItemMeta() instanceof org.bukkit.inventory.meta.PotionMeta meta) {
283+
if (potion.getItemMeta() instanceof PotionMeta meta) {
297284
if (meta.hasCustomEffects()) {
298-
return meta.getCustomEffects().get(0).getType().getName();
285+
return meta.getCustomEffects().getFirst().getType().getKey().asString();
299286
}
300-
// Новый способ получения типа зелья
301-
org.bukkit.potion.PotionType potionType = meta.getBasePotionType();
287+
PotionType potionType = meta.getBasePotionType();
302288
if (potionType != null) {
303289
return potionType.name();
304290
}
@@ -307,20 +293,18 @@ private String getPotionEffectName(ItemStack potion) {
307293
}
308294

309295
private int getPotionLevel(ItemStack potion) {
310-
if (potion.getItemMeta() instanceof org.bukkit.inventory.meta.PotionMeta) {
311-
org.bukkit.inventory.meta.PotionMeta meta = (org.bukkit.inventory.meta.PotionMeta) potion.getItemMeta();
296+
if (potion.getItemMeta() instanceof PotionMeta meta) {
312297
if (meta.hasCustomEffects()) {
313-
return meta.getCustomEffects().get(0).getAmplifier() + 1;
298+
return meta.getCustomEffects().getFirst().getAmplifier() + 1;
314299
}
315300
}
316301
return 1;
317302
}
318303

319304
private int getPotionDuration(ItemStack potion) {
320-
if (potion.getItemMeta() instanceof org.bukkit.inventory.meta.PotionMeta) {
321-
org.bukkit.inventory.meta.PotionMeta meta = (org.bukkit.inventory.meta.PotionMeta) potion.getItemMeta();
305+
if (potion.getItemMeta() instanceof PotionMeta meta) {
322306
if (meta.hasCustomEffects()) {
323-
return meta.getCustomEffects().get(0).getDuration();
307+
return meta.getCustomEffects().getFirst().getDuration();
324308
}
325309
}
326310
return 0;

src/main/resources/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ categories:
5252
- STONE_AXE
5353
- STONE_SHOVEL
5454
- STONE_HOE
55+
- COPPER_PICKAXE
56+
- COPPER_AXE
57+
- COPPER_SHOVEL
58+
- COPPER_HOE
5559
- IRON_PICKAXE
5660
- IRON_AXE
5761
- IRON_SHOVEL
@@ -80,6 +84,7 @@ categories:
8084
- SHIELD
8185
- WOODEN_SWORD
8286
- STONE_SWORD
87+
- COPPER_SWORD
8388
- IRON_SWORD
8489
- GOLDEN_SWORD
8590
- DIAMOND_SWORD
@@ -92,6 +97,7 @@ categories:
9297

9398
armor:
9499
- LEATHER_HORSE_ARMOR
100+
- COPPER_HORSE_ARMOR
95101
- IRON_HORSE_ARMOR
96102
- GOLDEN_HORSE_ARMOR
97103
- DIAMOND_HORSE_ARMOR
@@ -105,6 +111,10 @@ categories:
105111
- CHAINMAIL_CHESTPLATE
106112
- CHAINMAIL_LEGGINGS
107113
- CHAINMAIL_BOOTS
114+
- COPPER_HELMET
115+
- COPPER_CHESTPLATE
116+
- COPPER_LEGGINGS
117+
- COPPER_BOOTS
108118
- IRON_HELMET
109119
- IRON_CHESTPLATE
110120
- IRON_LEGGINGS
@@ -144,6 +154,7 @@ categories:
144154
- COPPER_ORE
145155
- DEEPSLATE_COPPER_ORE
146156
- RAW_COPPER
157+
- COPPER_NUGGET
147158
- COPPER_INGOT
148159
- COPPER_BLOCK
149160
- IRON_ORE
@@ -333,6 +344,7 @@ categories:
333344
- ITEM_FRAME
334345
- PAINTING
335346
- CHEST
347+
- COPPER_CHEST
336348
- TRAPPED_CHEST
337349
- ENDER_CHEST
338350
- SHULKER_BOX

0 commit comments

Comments
 (0)