Skip to content

Commit 319366b

Browse files
committed
2.2.1
1 parent e6e97f1 commit 319366b

File tree

7 files changed

+93
-24
lines changed

7 files changed

+93
-24
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 2.2.1
4+
- Got rid of ChestSortAPI as shaded dependency
5+
- Fixed leaves not using the proper tool
6+
- Fixed BestTools sometimes not recognizing interaction when mining cobblestone generators for hours
7+
- Added config option "consider-swords-for-cobwebs" (default: false)
8+
9+
## 2.2.0
10+
- Added config option "consider-swords-for-cobwebs"
11+
12+
## 2.1.0
13+
- Added support for BentoBox/OneBlock's magic block generator
14+
315
## 2.0.2
416
- Fixed RAW_IRON_BLOCK not changing to a proper tool
517

pom.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<name>BestTools</name>
1010
<!--<url>https://www.chestsort.de</url>-->
1111
<description>Automatically switches to the best tools. Most efficient Auto-Tool plugin!</description>
12-
<version>2.0.2</version>
12+
<version>2.2.1</version>
1313
<packaging>jar</packaging>
1414

1515
<properties>
@@ -33,8 +33,7 @@
3333
<artifactId>maven-jar-plugin</artifactId>
3434
<version>3.2.0</version>
3535
<configuration>
36-
<finalName>BestTools</finalName>
37-
<outputDirectory>C:\mctest\plugins</outputDirectory>
36+
<finalName>BestTools-${project.version}</finalName>
3837
</configuration>
3938
</plugin>
4039
<plugin>
@@ -149,12 +148,6 @@
149148
<version>1.1.0</version>
150149
<scope>compile</scope>
151150
</dependency>
152-
<dependency>
153-
<groupId>de.jeff_media</groupId>
154-
<artifactId>ChestSortAPI</artifactId>
155-
<version>12.0.0</version> <!-- The API version is independent of the ChestSort version -->
156-
<scope>compile</scope>
157-
</dependency>
158151
<dependency>
159152
<groupId>org.bstats</groupId>
160153
<artifactId>bstats-bukkit</artifactId>

src/main/java/de/jeff_media/BestTools/BestToolsHandler.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class BestToolsHandler {
4747
final ArrayList<Material> allTools = new ArrayList<>();
4848
final ArrayList<Material> instaBreakableByHand = new ArrayList<>();
4949

50+
final EnumSet<Material> leaves = EnumSet.noneOf(Material.class);
51+
5052

5153
final ArrayList<Material> weapons = new ArrayList<>();
5254

@@ -65,6 +67,12 @@ public class BestToolsHandler {
6567
globalBlacklist.add(mat);
6668
}
6769

70+
Arrays.stream(Material.values()).forEach(material -> {
71+
if(material.name().endsWith("_LEAVES")) {
72+
leaves.add(material);
73+
}
74+
});
75+
6876

6977
}
7078

@@ -296,14 +304,14 @@ ItemStack getBestToolFromInventory(@NotNull Material mat, Player p, boolean hotb
296304
ItemStack[] items = inventoryToArray(p,hotbarOnly);
297305

298306
Tool bestType;
299-
if(!LeavesUtils.isLeaves(mat)) {
307+
if(!LeavesUtils.isLeaves(mat) && mat != Material.COBWEB) {
300308
bestType=getBestToolType(mat);
301309
} else {
302310
if(LeavesUtils.hasShears(hotbarOnly, p.getInventory().getStorageContents())) {
303311
bestType = Tool.SHEARS;
304-
} else if(LeavesUtils.hasHoe(hotbarOnly,p.getInventory().getStorageContents())) {
312+
} else if(LeavesUtils.hasHoe(hotbarOnly,p.getInventory().getStorageContents()) && mat != Material.COBWEB) {
305313
bestType = Tool.HOE;
306-
} else if(main.getConfig().getBoolean("consider-swords-for-leaves") && LeavesUtils.hasSword(hotbarOnly, p.getInventory().getStorageContents())) {
314+
} else if(((main.getConfig().getBoolean("consider-swords-for-cobwebs") && mat == Material.COBWEB)||(mat != Material.COBWEB && main.getConfig().getBoolean("consider-swords-for-leaves"))) && LeavesUtils.hasSword(hotbarOnly, p.getInventory().getStorageContents())) {
307315
bestType = Tool.SWORD;
308316
} else {
309317
bestType = Tool.NONE;

src/main/java/de/jeff_media/BestTools/BestToolsListener.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package de.jeff_media.BestTools;
22

3+
import de.jeff_media.BestTools.events.BestToolsNotifyEvent;
4+
import org.bukkit.Bukkit;
35
import org.bukkit.Material;
46
import org.bukkit.block.Block;
7+
import org.bukkit.block.BlockFace;
58
import org.bukkit.entity.Entity;
69
import org.bukkit.entity.Monster;
710
import org.bukkit.entity.Player;
811
import org.bukkit.event.EventHandler;
12+
import org.bukkit.event.EventPriority;
913
import org.bukkit.event.Listener;
1014
import org.bukkit.event.block.Action;
15+
import org.bukkit.event.block.BlockBreakEvent;
1116
import org.bukkit.event.entity.EntityDamageByEntityEvent;
1217
import org.bukkit.event.player.PlayerInteractEvent;
1318
import org.bukkit.inventory.EquipmentSlot;
@@ -72,6 +77,20 @@ public void onPlayerAttackEntity(EntityDamageByEntityEvent e) {
7277

7378
}
7479

80+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
81+
public void onBreak(BlockBreakEvent event) {
82+
//System.out.println("BlockBreakEvent LISTENER");
83+
//System.out.println(event.getBlock());
84+
Bukkit.getScheduler().runTaskLater(main, () -> {
85+
Bukkit.getPluginManager().callEvent(new BestToolsNotifyEvent(event.getPlayer(), event.getBlock()));
86+
//Bukkit.getPluginManager().callEvent(new PlayerInteractEvent(event.getPlayer(), Action.LEFT_CLICK_BLOCK, event.getPlayer().getInventory().getItemInMainHand(),event.getBlock(),BlockFace.SELF,EquipmentSlot.HAND));
87+
},1);
88+
}
89+
90+
@EventHandler
91+
public void onNotify(BestToolsNotifyEvent event) {
92+
onPlayerInteractWithBlock(new PlayerInteractEvent(event.getPlayer(), Action.LEFT_CLICK_BLOCK, event.getPlayer().getInventory().getItemInMainHand(),event.getBlock(),BlockFace.SELF,EquipmentSlot.HAND));
93+
}
7594

7695
@EventHandler
7796
public void onPlayerInteractWithBlock(PlayerInteractEvent event) {
@@ -80,6 +99,9 @@ public void onPlayerInteractWithBlock(PlayerInteractEvent event) {
8099
//for (RegisteredListener registeredListener : event.getHandlers().getRegisteredListeners()) {
81100
// main.debug(registeredListener.getPlugin().getName()+": "+registeredListener.getListener().getClass().getName() + " @ "+registeredListener.getPriority().name());
82101
//}
102+
// if(main.debug && event.getAction() == Action.LEFT_CLICK_BLOCK) {
103+
// main.getLogger().warning(event.getClickedBlock().getType().name());
104+
// }
83105
//
84106

85107
long st= main.measurePerformance ? System.nanoTime() : 0;

src/main/java/de/jeff_media/BestTools/GUIHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package de.jeff_media.BestTools;
22

3-
import de.jeff_media.chestsort.api.ChestSortEvent;
43
import org.bukkit.Bukkit;
54
import org.bukkit.ChatColor;
65
import org.bukkit.Material;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package de.jeff_media.BestTools.events;
2+
3+
import org.bukkit.block.Block;
4+
import org.bukkit.entity.Player;
5+
import org.bukkit.event.HandlerList;
6+
import org.bukkit.event.player.PlayerEvent;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
public class BestToolsNotifyEvent extends PlayerEvent {
10+
11+
private static final HandlerList HANDLERS = new HandlerList();
12+
private final Block block;
13+
14+
public BestToolsNotifyEvent(@NotNull Player who, Block block) {
15+
super(who);
16+
this.block = block;
17+
}
18+
19+
public Block getBlock() {
20+
return block;
21+
}
22+
23+
@NotNull
24+
@Override
25+
public HandlerList getHandlers() {
26+
return HANDLERS;
27+
}
28+
29+
public static HandlerList getHandlerList() {
30+
return HANDLERS;
31+
}
32+
}

src/main/resources/config.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ dont-switch-during-battle: true
8383
# leaves with it.
8484
consider-swords-for-leaves: false
8585

86+
# Uses swords for cobwebs if you don't have shears.
87+
consider-swords-for-cobwebs: false
88+
8689
# Allow /besttools to switch to your sword/axe (whatever is better) when attacking mobs?
8790
use-sword-on-hostile-mobs: true
8891

@@ -153,7 +156,7 @@ message-besttools-disabled: "&7BestTools has been &cdisabled&7."
153156
message-refill-enabled: "&7Refill has been &aenabled&7."
154157
message-refill-disabled: "&7Refill has been &cdisabled&7."
155158
message-besttools-usage: "&7Hint: Type &6/besttools&7 or &6/bt&7 to automatically use the best tool when breaking blocks."
156-
message-refill-usage": "&7Hint: Type &6/refill&7 or &6/rf&7 to automatically refill empty items from your inventory."
159+
message-refill-usage: "&7Hint: Type &6/refill&7 or &6/rf&7 to automatically refill empty items from your inventory."
157160
message-hotbar-only-enabled: "&7BestTools will only use tools from your hotbar."
158161
message-hotbar-only-disabled: "&7BestTools will use all tools from your inventory."
159162
gui-favorite-slot: "Set as favorite slot"
@@ -168,7 +171,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
168171
#message-refill-enabled: "&7Refill has been &aenabled&7."
169172
#message-refill-disabled: "&7Refill has been &cdisabled&7."
170173
#message-besttools-usage: "&7Hint: Type &6/besttools&7 or &6/bt&7 to automatically use the best tool when breaking blocks."
171-
#message-refill-usage": "&7Hint: Type &6/refill&7 or &6/rf&7 to automatically refill empty items from your inventory."
174+
#message-refill-usage: "&7Hint: Type &6/refill&7 or &6/rf&7 to automatically refill empty items from your inventory."
172175
#message-hotbar-only-enabled: "&7BestTools will only use tools from your hotbar."
173176
#message-hotbar-only-disabled: "&7BestTools will use all tools from your inventory."
174177
#gui-favorite-slot: "Set as favorite slot"
@@ -213,7 +216,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
213216
#message-refill-enabled: "&7Hervullen is &aingeschakeld&7."
214217
#message-refill-disabled: "&7Hervullen is &cuitgeschakeld&7."
215218
#message-besttools-usage: "&7Hint: Type &6/besttools&7 of &6/bt&7 om automatisch het beste gereedschap te gebruiken om blokken te breken."
216-
#message-refill-usage": "&7Hint: Type &6/refill&7 of &6/rf&7 om automatisch lege vakken te hervullen uit je inventaris."
219+
#message-refill-usage: "&7Hint: Type &6/refill&7 of &6/rf&7 om automatisch lege vakken te hervullen uit je inventaris."
217220
#message-hotbar-only-enabled: "&7BestTools zal alleen gereedschap uit je hotbar gebruiken."
218221
#message-hotbar-only-disabled: "&7BestTools zal alle gereedschappen uit je inventaris gebruiken."
219222
#gui-favorite-slot: "Zet als favoriete vak"
@@ -228,7 +231,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
228231
#message-refill-enabled: "&7La recharge a été &activée&7."
229232
#message-refill-disabled: "&7La recharge a été &cdésactivée&7."
230233
#message-besttools-usage: "&7Astuce: Tapez &6/bt&7 pour utiliser automatiquement le BestTools lors de la rupture des blocs."
231-
#message-refill-usage": "&7Astuce: Tapez &6/rf&7 pour remplir automatiquement les articles vides de votre inventaire."
234+
#message-refill-usage: "&7Astuce: Tapez &6/rf&7 pour remplir automatiquement les articles vides de votre inventaire."
232235
#message-hotbar-only-enabled: "&7BestTools n'utilisera que les outils de votre hotbar."
233236
#message-hotbar-only-disabled: "&7BestTools utilisera tous les outils de votre inventaire."
234237
#gui-favorite-slot: "Définir comme emplacement favori"
@@ -243,7 +246,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
243246
#message-refill-enabled: "&7Refill wurde &aaktiviert&7."
244247
#message-refill-disabled: "&7Refill wurde &cdeaktiviert&7."
245248
#message-besttools-usage: "&Hinweis: Benutze &6/besttools&7 oder &6/bt&7 um die automatische Werkzeugauswahl zu aktivieren."
246-
#message-refill-usage": "&7Hinweis: Benutze &6/refill&7 oder &6/rf&7 um die automatische Itemauffüllung zu aktivieren."
249+
#message-refill-usage: "&7Hinweis: Benutze &6/refill&7 oder &6/rf&7 um die automatische Itemauffüllung zu aktivieren."
247250
#message-hotbar-only-enabled: "&7BestTools wird nur Werkzeuge aus deiner Hotbar benutzen."
248251
#message-hotbar-only-disabled: "&7BestTools wird alle Werkzeuge aus deinem Inventar benutzen."
249252
#gui-favorite-slot: "Als Lieblingsslot festlegen"
@@ -258,7 +261,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
258261
#message-refill-enabled: "&7Auto-refill został &awłączony&7."
259262
#message-refill-disabled: "&7Auto-refill został &cwyłączony&7."
260263
#message-besttools-usage: "&7Podpowiedź: Wpisz &6/besttools&7 lub &6/bt&7 by automatycznie użyć naodpowiedniejszych narzędzi do niszczenia danego typu bloków."
261-
#message-refill-usage": "&7Podpowiedź: Wpisz &6/refill&7 lub &6/rf&7 by automatycznie wypełnić pasek szybkiego wyboru przedmiotami z ekwipunku."
264+
#message-refill-usage: "&7Podpowiedź: Wpisz &6/refill&7 lub &6/rf&7 by automatycznie wypełnić pasek szybkiego wyboru przedmiotami z ekwipunku."
262265
#message-hotbar-only-enabled: "&7BestTools będzie używać tylko narzędzi z paska szybkiego wyboru."
263266
#message-hotbar-only-disabled: "&7BestTools będzie używać wszystkich narzędzi z ekwipunku."
264267
#gui-favorite-slot: "Ustaw ten slot jako ulubiony"
@@ -273,7 +276,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
273276
#message-refill-enabled: "&7Reabastecimento foi &ahabilitado&7."
274277
#message-refill-disabled: "&7Reabastecimento foi &cdesabilitado&7."
275278
#message-besttools-usage: "&7Dica: Digite &6/besttools&7 ou &6/bt&7 para usar a melhor ferramente automaticamente ao quebrar blocos."
276-
#message-refill-usage": "&7Dica: Digite &6/refill&7 ou &6/rf&7 para reabastecer-se automaticamente com itens do inventário."
279+
#message-refill-usage: "&7Dica: Digite &6/refill&7 ou &6/rf&7 para reabastecer-se automaticamente com itens do inventário."
277280
#message-hotbar-only-enabled: "&7BestTools usará apenas as ferramentas da sua barra rápida."
278281
#message-hotbar-only-disabled: "&7BestTools usará todas as ferramentas do seu inventário."
279282
#gui-favorite-slot: "Definir como slot favorito"
@@ -288,7 +291,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
288291
#message-refill-enabled: "&7Заполнение &aактивировано&7."
289292
#message-refill-disabled: "&7Заполнение &cдеактивировано&7."
290293
#message-besttools-usage: "&7Подсказка: Введите &6/besttools&7 или &6/bt&7 чтобы автоматически использовать лучший предмет для ломания блоков."
291-
#message-refill-usage": "&7Подсказка: Введите &6/refill&7 или &6/rf&7 чтобы автоматически наполнять ваши предметы в инвентаре."
294+
#message-refill-usage: "&7Подсказка: Введите &6/refill&7 или &6/rf&7 чтобы автоматически наполнять ваши предметы в инвентаре."
292295
#message-hotbar-only-enabled: "&7BestTools будет использовать только инструменты с вашей панели быстрого доступа."
293296
#message-hotbar-only-disabled: "&7BestTools будет использовать все инструменты из вашего инвентаря."
294297
#gui-favorite-slot: "Установить любимый слот"
@@ -303,7 +306,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
303306
#message-refill-enabled: "&7Has &aactivado &7la reposición automática de objetos."
304307
#message-refill-disabled: "&7Has &cdesactivado &7la reposición automática de objetos."
305308
#message-besttools-usage: "&7Usa el comando &6/besttools &7para cambiar automáticamente la herramienta que mejor convenga para cada situación."
306-
#message-refill-usage": "&7Usa el comando &6/refill &7para reponer automáticamente los bloques de tu inventario."
309+
#message-refill-usage: "&7Usa el comando &6/refill &7para reponer automáticamente los bloques de tu inventario."
307310
#message-hotbar-only-enabled: "&7Ahora solo se seleccionarán automáticamente las herramientas alojadas en tu cinturón."
308311
#message-hotbar-only-disabled: "&7Ahora se seleccionarán automáticamente las herramientas de tu inventario y tu cinturón."
309312
#gui-favorite-slot: "&7Determina la ranura que quieres utilizar de tu cinturón."
@@ -318,7 +321,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
318321
#message-refill-enabled: "&7Refill har &aaktiverats&7."
319322
#message-refill-disabled: "&7Refill has been &cdisabled&7."
320323
#message-besttools-usage: "&7Tips: Skriv &6/besttools&7 eller &6/bt&7 för att automatiskt använda det bästa verktyget när du bryter block."
321-
#message-refill-usage": "&7Tips: Skriv &6/refill&7 eller &6/rf&7 för att automatiskt fylla på tomma föremål från ditt lager."
324+
#message-refill-usage: "&7Tips: Skriv &6/refill&7 eller &6/rf&7 för att automatiskt fylla på tomma föremål från ditt lager."
322325
#message-hotbar-only-enabled: "&7BestTools kommer endast att använda verktyg från din hotbar."
323326
#message-hotbar-only-disabled: "&7BestTools kommer att använda alla verktyg från ditt inventarium."
324327
#gui-favorite-slot: "Ange som favoritplats"
@@ -333,7 +336,7 @@ gui-refill-lore: "Automatically refills empty hotbar slots."
333336
#message-refill-enabled: "&7Otomatik doldurma &aaktif edildi&7."
334337
#message-refill-disabled: "&7Otomatik doldurma &cdeaktif edildi&7."
335338
#message-besttools-usage: "&7İpucu: Blok kırarken otomatik olarak en iyi aleti kullanmak için &6/besttols&7 veya &6/bt&7 yazınız."
336-
#message-refill-usage": "&7İpucu: Slotunuzdaki blokları otomatik doldurmak için &6/refill&7 veya &6/rf&7 yazınız."
339+
#message-refill-usage: "&7İpucu: Slotunuzdaki blokları otomatik doldurmak için &6/refill&7 veya &6/rf&7 yazınız."
337340
#message-hotbar-only-enabled: "&7BestTools sadece slotlarınızdaki aletleri kullanacaktır."
338341
#message-hotbar-only-disabled: "&7BestTools envanterinizdeki bütün aletleri kullanacaktır."
339342
#gui-favorite-slot: "Favori slot olarak seç"

0 commit comments

Comments
 (0)