Merge branch 'development'

This commit is contained in:
Christian Koop 2022-03-18 21:11:18 +01:00
commit 7f1c9ab3a3
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
4 changed files with 28 additions and 19 deletions

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId> <artifactId>UltimateTimber</artifactId>
<version>2.3.1</version> <version>2.3.2</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId> <artifactId>SongodaCore</artifactId>
<version>2.6.11</version> <version>2.6.12</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId> <artifactId>UltimateTimber</artifactId>
<version>2.3.1</version> <version>2.3.2</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -4,8 +4,7 @@ import com.google.common.base.Strings;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.hooks.McMMOHook; import com.songoda.core.hooks.McMMOHook;
import com.songoda.core.nms.NmsManager; import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatetimber.UltimateTimber; import com.songoda.ultimatetimber.UltimateTimber;
import com.songoda.ultimatetimber.tree.ITreeBlock; import com.songoda.ultimatetimber.tree.ITreeBlock;
@ -24,7 +23,11 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TreeDefinitionManager extends Manager { public class TreeDefinitionManager extends Manager {
@ -232,9 +235,9 @@ public class TreeDefinitionManager extends Manager {
item.setItemMeta(meta); item.setItemMeta(meta);
// Apply NBT // Apply NBT
NBTItem nbtItem = NmsManager.getNbt().of(item); NBTItem nbtItem = new NBTItem(item);
nbtItem.set(requiredAxeKey, true); nbtItem.setBoolean(requiredAxeKey, true);
item = nbtItem.finish(); item = nbtItem.getItem();
this.requiredAxe = item; this.requiredAxe = item;
} }
@ -264,6 +267,7 @@ public class TreeDefinitionManager extends Manager {
* Gets a Set of possible TreeDefinitions that match the given Block * Gets a Set of possible TreeDefinitions that match the given Block
* *
* @param block The Block to check * @param block The Block to check
*
* @return A Set of TreeDefinitions for the given Block * @return A Set of TreeDefinitions for the given Block
*/ */
public Set<TreeDefinition> getTreeDefinitionsForLog(Block block) { public Set<TreeDefinition> getTreeDefinitionsForLog(Block block) {
@ -276,6 +280,7 @@ public class TreeDefinitionManager extends Manager {
* @param possibleTreeDefinitions The possible TreeDefinitions * @param possibleTreeDefinitions The possible TreeDefinitions
* @param block The Block to narrow to * @param block The Block to narrow to
* @param treeBlockType The TreeBlockType of the given Block * @param treeBlockType The TreeBlockType of the given Block
*
* @return A Set of TreeDefinitions narrowed down * @return A Set of TreeDefinitions narrowed down
*/ */
public Set<TreeDefinition> narrowTreeDefinition(Set<TreeDefinition> possibleTreeDefinitions, Block block, TreeBlockType treeBlockType) { public Set<TreeDefinition> narrowTreeDefinition(Set<TreeDefinition> possibleTreeDefinitions, Block block, TreeBlockType treeBlockType) {
@ -310,6 +315,7 @@ public class TreeDefinitionManager extends Manager {
* Checks if a given tool is valid for any tree definitions, also takes into account global tools * Checks if a given tool is valid for any tree definitions, also takes into account global tools
* *
* @param tool The tool to check * @param tool The tool to check
*
* @return True if the tool is allowed for toppling any trees * @return True if the tool is allowed for toppling any trees
*/ */
public boolean isToolValidForAnyTreeDefinition(ItemStack tool) { public boolean isToolValidForAnyTreeDefinition(ItemStack tool) {
@ -318,8 +324,7 @@ public class TreeDefinitionManager extends Manager {
for (TreeDefinition treeDefinition : this.treeDefinitions) { for (TreeDefinition treeDefinition : this.treeDefinitions) {
if (treeDefinition.isRequiredAxe() || isGlobalAxeRequired()) { if (treeDefinition.isRequiredAxe() || isGlobalAxeRequired()) {
NBTItem nbtItem = NmsManager.getNbt().of(tool); if (new NBTItem(tool).hasKey(requiredAxeKey))
if (nbtItem.has(requiredAxeKey))
return true; return true;
} }
} }
@ -341,6 +346,7 @@ public class TreeDefinitionManager extends Manager {
* *
* @param treeDefinition The TreeDefinition to use * @param treeDefinition The TreeDefinition to use
* @param tool The tool to check * @param tool The tool to check
*
* @return True if the tool is allowed for toppling the given TreeDefinition * @return True if the tool is allowed for toppling the given TreeDefinition
*/ */
public boolean isToolValidForTreeDefinition(TreeDefinition treeDefinition, ItemStack tool) { public boolean isToolValidForTreeDefinition(TreeDefinition treeDefinition, ItemStack tool) {
@ -350,8 +356,7 @@ public class TreeDefinitionManager extends Manager {
// If the tree definition requires the custom axe, don't allow any other checks to pass. // If the tree definition requires the custom axe, don't allow any other checks to pass.
if (treeDefinition.isRequiredAxe() || isGlobalAxeRequired()) { if (treeDefinition.isRequiredAxe() || isGlobalAxeRequired()) {
NBTItem nbtItem = NmsManager.getNbt().of(tool); return new NBTItem(tool).hasKey(requiredAxeKey);
return nbtItem.has(requiredAxeKey);
} }
for (ItemStack requiredTool : treeDefinition.getRequiredTools()) for (ItemStack requiredTool : treeDefinition.getRequiredTools())
@ -386,7 +391,7 @@ public class TreeDefinitionManager extends Manager {
} else { } else {
if (ConfigurationManager.Setting.APPLY_SILK_TOUCH.getBoolean() && hasSilkTouch) { if (ConfigurationManager.Setting.APPLY_SILK_TOUCH.getBoolean() && hasSilkTouch) {
if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean()
&& McMMOHook.hasWoodcuttingDoubleDrops(player)) && McMMOHook.hasWoodcuttingDoubleDrops(player))
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
} else { } else {
@ -396,7 +401,7 @@ public class TreeDefinitionManager extends Manager {
toTry.addAll(this.globalLogLoot); toTry.addAll(this.globalLogLoot);
if (treeDefinition.shouldDropOriginalLog()) { if (treeDefinition.shouldDropOriginalLog()) {
if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean()
&& McMMOHook.hasWoodcuttingDoubleDrops(player)) && McMMOHook.hasWoodcuttingDoubleDrops(player))
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
} }
@ -406,7 +411,7 @@ public class TreeDefinitionManager extends Manager {
toTry.addAll(this.globalLeafLoot); toTry.addAll(this.globalLeafLoot);
if (treeDefinition.shouldDropOriginalLeaf()) { if (treeDefinition.shouldDropOriginalLeaf()) {
if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean()
&& McMMOHook.hasWoodcuttingDoubleDrops(player)) && McMMOHook.hasWoodcuttingDoubleDrops(player))
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock)); lootedItems.addAll(BlockUtils.getBlockDrops(treeBlock));
} }
@ -425,14 +430,14 @@ public class TreeDefinitionManager extends Manager {
if (treeLoot.hasItem()) { if (treeLoot.hasItem()) {
if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean()
&& McMMOHook.hasWoodcuttingDoubleDrops(player)) && McMMOHook.hasWoodcuttingDoubleDrops(player))
lootedItems.add(treeLoot.getItem()); lootedItems.add(treeLoot.getItem());
lootedItems.add(treeLoot.getItem()); lootedItems.add(treeLoot.getItem());
} }
if (treeLoot.hasCommand()) { if (treeLoot.hasCommand()) {
if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean() if (ConfigurationManager.Setting.HOOKS_APPLY_EXTRA_DROPS.getBoolean()
&& McMMOHook.hasWoodcuttingDoubleDrops(player)) && McMMOHook.hasWoodcuttingDoubleDrops(player))
lootedCommands.add(treeLoot.getCommand()); lootedCommands.add(treeLoot.getCommand());
lootedCommands.add(treeLoot.getCommand()); lootedCommands.add(treeLoot.getCommand());
} }
@ -466,6 +471,7 @@ public class TreeDefinitionManager extends Manager {
* Gets all possible plantable soil blocks for the given tree definition * Gets all possible plantable soil blocks for the given tree definition
* *
* @param treeDefinition The TreeDefinition * @param treeDefinition The TreeDefinition
*
* @return A Set of IBlockData of plantable soil * @return A Set of IBlockData of plantable soil
*/ */
public Set<CompatibleMaterial> getPlantableSoilMaterial(TreeDefinition treeDefinition) { public Set<CompatibleMaterial> getPlantableSoilMaterial(TreeDefinition treeDefinition) {
@ -480,6 +486,7 @@ public class TreeDefinitionManager extends Manager {
* *
* @param treeBlockType The TreeBlockType to use * @param treeBlockType The TreeBlockType to use
* @param configurationSection The ConfigurationSection * @param configurationSection The ConfigurationSection
*
* @return A TreeLoot entry from the section * @return A TreeLoot entry from the section
*/ */
private TreeLoot getTreeLootEntry(TreeBlockType treeBlockType, ConfigurationSection configurationSection) { private TreeLoot getTreeLootEntry(TreeBlockType treeBlockType, ConfigurationSection configurationSection) {

View File

@ -3,9 +3,11 @@
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId> <artifactId>UltimateTimber</artifactId>
<version>2.3.1</version> <version>2.3.2</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<!-- Run 'mvn versions:set -DgenerateBackupPoms=false -DnewVersion=X.Y.Z' to update version recursively -->
<modules> <modules>
<module>UltimateTimber/Core</module> <module>UltimateTimber/Core</module>
<module>UltimateTimber/Plugin</module> <module>UltimateTimber/Plugin</module>