Migrate from SongodaCore to CraftaroCore v3.0.0-SNAPSHOT
This commit is contained in:
parent
b1cb59b7e8
commit
2858427d86
20
pom.xml
20
pom.xml
|
@ -53,7 +53,7 @@
|
|||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<pattern>com.craftaro.core</pattern>
|
||||
<shadedPattern>com.songoda.ultimatetimber.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
@ -68,6 +68,14 @@
|
|||
<exclude>LICENSE.**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<artifact>com.craftaro:CraftaroCore</artifact>
|
||||
<excludeDefaults>false</excludeDefaults>
|
||||
<includes>
|
||||
<include>**/nms/v*/**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -85,8 +93,8 @@
|
|||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
<id>craftaro-minecraft-plugins</id>
|
||||
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
|
@ -97,9 +105,9 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.19</version>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.songoda.ultimatetimber;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.hooks.LogManager;
|
||||
import com.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.hooks.LogManager;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.ultimatetimber.commands.CommandGiveAxe;
|
||||
import com.songoda.ultimatetimber.commands.CommandReload;
|
||||
import com.songoda.ultimatetimber.commands.CommandToggle;
|
||||
|
@ -51,7 +51,7 @@ public class UltimateTimber extends SongodaPlugin {
|
|||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 18, CompatibleMaterial.IRON_AXE);
|
||||
SongodaCore.registerPlugin(this, 18, XMaterial.IRON_AXE);
|
||||
|
||||
// Load hooks
|
||||
LogManager.load();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.songoda.ultimatetimber.animation;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleHand;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleHand;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
import com.songoda.ultimatetimber.tree.FallingTreeBlock;
|
||||
|
@ -97,9 +98,8 @@ public abstract class TreeAnimation {
|
|||
protected FallingTreeBlock convertToFallingBlock(TreeBlock treeBlock) {
|
||||
Location location = treeBlock.getLocation().clone().add(0.5, 0, 0.5);
|
||||
Block block = treeBlock.getBlock();
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
|
||||
if (material.isAir()) {
|
||||
XMaterial material = CompatibleMaterial.getMaterial(block.getType()).get();
|
||||
if (CompatibleMaterial.isAir(material)) {
|
||||
this.replaceBlock(treeBlock);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.animation;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.manager.ConfigurationManager;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
|
@ -64,11 +64,11 @@ public class TreeAnimationCrumble extends TreeAnimation {
|
|||
for (int i = 0; i < 3 && !partition.isEmpty(); i++) {
|
||||
ITreeBlock<Block> treeBlock = partition.remove(0);
|
||||
if (treeBlock.getTreeBlockType() == TreeBlockType.LOG) {
|
||||
if (td.getLogMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock()))) {
|
||||
if (td.getLogMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock().getType()).orElse(null))) {
|
||||
continue;
|
||||
}
|
||||
} else if (treeBlock.getTreeBlockType() == TreeBlockType.LEAF) {
|
||||
if (td.getLeafMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock()))) {
|
||||
if (td.getLeafMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock().getType()).orElse(null))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.animation;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.manager.ConfigurationManager;
|
||||
import com.songoda.ultimatetimber.manager.TreeDefinitionManager;
|
||||
|
@ -76,11 +76,11 @@ public class TreeAnimationDisintegrate extends TreeAnimation {
|
|||
|
||||
for (ITreeBlock<Block> treeBlock : toDestroy) {
|
||||
if (treeBlock.getTreeBlockType() == TreeBlockType.LOG) {
|
||||
if (td.getLogMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock()))) {
|
||||
if (td.getLogMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock().getType()).orElse(null))) {
|
||||
continue;
|
||||
}
|
||||
} else if (treeBlock.getTreeBlockType() == TreeBlockType.LEAF) {
|
||||
if (td.getLeafMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock()))) {
|
||||
if (td.getLeafMaterial().stream().noneMatch(x -> x == CompatibleMaterial.getMaterial(treeBlock.getBlock().getType()).orElse(null))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatetimber.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.utils.PlayerUtils;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.utils.PlayerUtils;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.events.TreeFellEvent;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
|
@ -57,7 +57,7 @@ public class PlacedBlockManager extends Manager implements Listener {
|
|||
}
|
||||
|
||||
// Ignore stripping logs
|
||||
if (event.getBlockPlaced().getType().name().contains("STRIPPED") && !CompatibleMaterial.getMaterial(event.getBlockReplacedState().getType()).isAir()) {
|
||||
if (event.getBlockPlaced().getType().name().contains("STRIPPED") && !CompatibleMaterial.isAir(CompatibleMaterial.getMaterial(event.getBlockReplacedState().getType()).get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XBlock;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockType;
|
||||
|
@ -61,7 +63,7 @@ public class SaplingManager extends Manager {
|
|||
* @param treeBlock The ITreeBlock to replant for
|
||||
*/
|
||||
public void replantSaplingWithChance(TreeDefinition treeDefinition, ITreeBlock treeBlock) {
|
||||
if (!ConfigurationManager.Setting.FALLING_BLOCKS_REPLANT_SAPLINGS.getBoolean() || !CompatibleMaterial.getMaterial(treeBlock.getLocation().getBlock()).isAir()) {
|
||||
if (!ConfigurationManager.Setting.FALLING_BLOCKS_REPLANT_SAPLINGS.getBoolean() || !CompatibleMaterial.isAir(CompatibleMaterial.getMaterial(treeBlock.getLocation().getBlock().getType()).get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,8 +87,8 @@ public class SaplingManager extends Manager {
|
|||
Block block = treeBlock.getLocation().getBlock();
|
||||
Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
boolean isValidSoil = false;
|
||||
for (CompatibleMaterial soilMaterial : treeDefinitionManager.getPlantableSoilMaterial(treeDefinition)) {
|
||||
if (soilMaterial == CompatibleMaterial.getMaterial(blockBelow)) {
|
||||
for (XMaterial soilMaterial : treeDefinitionManager.getPlantableSoilMaterial(treeDefinition)) {
|
||||
if (soilMaterial == CompatibleMaterial.getMaterial(blockBelow.getType()).orElse(null)) {
|
||||
isValidSoil = true;
|
||||
break;
|
||||
}
|
||||
|
@ -96,8 +98,8 @@ public class SaplingManager extends Manager {
|
|||
return;
|
||||
}
|
||||
|
||||
CompatibleMaterial material = treeDefinition.getSaplingMaterial();
|
||||
material.applyToBlock(block);
|
||||
XMaterial material = treeDefinition.getSaplingMaterial();
|
||||
XBlock.setType(block, material);
|
||||
|
||||
int cooldown = ConfigurationManager.Setting.REPLANT_SAPLINGS_COOLDOWN.getInt();
|
||||
if (cooldown != 0) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.animation.TreeAnimation;
|
||||
import com.songoda.ultimatetimber.animation.TreeAnimationCrumble;
|
||||
|
@ -173,7 +173,7 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
|
|||
|
||||
Block block = treeBlock.getLocation().subtract(0, 1, 0).getBlock();
|
||||
if (ConfigurationManager.Setting.FRAGILE_BLOCKS.getStringList().contains(block.getType().toString())) {
|
||||
block.getWorld().dropItemNaturally(block.getLocation(), CompatibleMaterial.getMaterial(block).getItem());
|
||||
block.getWorld().dropItemNaturally(block.getLocation(), CompatibleMaterial.getMaterial(block.getType()).get().parseItem());
|
||||
block.breakNaturally();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.hooks.McMMOHook;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.google.common.base.Strings;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.hooks.McMMOHook;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockType;
|
||||
|
@ -26,6 +27,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -33,7 +35,7 @@ import java.util.stream.Collectors;
|
|||
public class TreeDefinitionManager extends Manager {
|
||||
private final Random random;
|
||||
private final Set<TreeDefinition> treeDefinitions;
|
||||
private final Set<CompatibleMaterial> globalPlantableSoil;
|
||||
private final Set<XMaterial> globalPlantableSoil;
|
||||
private final Set<TreeLoot> globalLogLoot, globalLeafLoot, globalEntireTreeLoot;
|
||||
private final Set<ItemStack> globalRequiredTools;
|
||||
|
||||
|
@ -70,10 +72,10 @@ public class TreeDefinitionManager extends Manager {
|
|||
for (String key : treeSection.getKeys(false)) {
|
||||
ConfigurationSection tree = treeSection.getConfigurationSection(key);
|
||||
|
||||
Set<CompatibleMaterial> logMaterials = new HashSet<>();
|
||||
Set<CompatibleMaterial> leafMaterials = new HashSet<>();
|
||||
CompatibleMaterial saplingMaterial;
|
||||
Set<CompatibleMaterial> plantableSoilMaterial = new HashSet<>();
|
||||
Set<XMaterial> logMaterials = new HashSet<>();
|
||||
Set<XMaterial> leafMaterials = new HashSet<>();
|
||||
XMaterial saplingMaterial;
|
||||
Set<XMaterial> plantableSoilMaterial = new HashSet<>();
|
||||
double maxLogDistanceFromTrunk;
|
||||
int maxLeafDistanceFromLog;
|
||||
boolean detectLeavesDiagonally;
|
||||
|
@ -86,29 +88,29 @@ public class TreeDefinitionManager extends Manager {
|
|||
boolean requiredAxe;
|
||||
|
||||
for (String materialString : tree.getStringList("logs")) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (material == null || material.getMaterial() == null) {
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (!material.isPresent() || !material.get().isSupported()) {
|
||||
continue top;
|
||||
}
|
||||
logMaterials.add(material);
|
||||
logMaterials.add(material.get());
|
||||
}
|
||||
|
||||
for (String materialString : tree.getStringList("leaves")) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (material == null || material.getMaterial() == null) {
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (!material.isPresent() || !material.get().isSupported()) {
|
||||
continue top;
|
||||
}
|
||||
leafMaterials.add(material);
|
||||
leafMaterials.add(material.get());
|
||||
}
|
||||
|
||||
saplingMaterial = CompatibleMaterial.getMaterial(tree.getString("sapling"));
|
||||
saplingMaterial = CompatibleMaterial.getMaterial(tree.getString("sapling")).get();
|
||||
|
||||
for (String materialString : tree.getStringList("plantable-soil")) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (material == null || material.getMaterial() == null) {
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(materialString);
|
||||
if (!material.isPresent() || !material.get().isSupported()) {
|
||||
continue top;
|
||||
}
|
||||
plantableSoilMaterial.add(material);
|
||||
plantableSoilMaterial.add(material.get());
|
||||
}
|
||||
|
||||
maxLogDistanceFromTrunk = tree.getDouble("max-log-distance-from-trunk");
|
||||
|
@ -139,11 +141,11 @@ public class TreeDefinitionManager extends Manager {
|
|||
}
|
||||
|
||||
for (String itemStackString : tree.getStringList("required-tools")) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(itemStackString);
|
||||
if (material == null) {
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(itemStackString);
|
||||
if (!material.isPresent()) {
|
||||
continue top;
|
||||
}
|
||||
requiredTools.add(material.getItem());
|
||||
requiredTools.add(material.get().parseItem());
|
||||
}
|
||||
|
||||
requiredAxe = tree.getBoolean("required-axe", false);
|
||||
|
@ -154,7 +156,7 @@ public class TreeDefinitionManager extends Manager {
|
|||
|
||||
// Load global plantable soil
|
||||
for (String material : config.getStringList("global-plantable-soil")) {
|
||||
this.globalPlantableSoil.add(CompatibleMaterial.getMaterial(material));
|
||||
this.globalPlantableSoil.add(CompatibleMaterial.getMaterial(material).get());
|
||||
}
|
||||
|
||||
// Load global log drops
|
||||
|
@ -183,11 +185,11 @@ public class TreeDefinitionManager extends Manager {
|
|||
|
||||
// Load global tools
|
||||
for (String itemStackString : config.getStringList("global-required-tools")) {
|
||||
ItemStack tool = CompatibleMaterial.getMaterial(itemStackString).getItem();
|
||||
if (tool == null) {
|
||||
Optional<XMaterial> tool = CompatibleMaterial.getMaterial(itemStackString);
|
||||
if (!tool.isPresent()) {
|
||||
continue;
|
||||
}
|
||||
this.globalRequiredTools.add(tool);
|
||||
this.globalRequiredTools.add(tool.get().parseItem());
|
||||
}
|
||||
|
||||
this.globalAxeRequired = config.getBoolean("global-required-axe", false);
|
||||
|
@ -210,14 +212,13 @@ public class TreeDefinitionManager extends Manager {
|
|||
return;
|
||||
}
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(typeString);
|
||||
|
||||
if (material == null) {
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(typeString);
|
||||
if (!material.isPresent()) {
|
||||
this.plugin.getLogger().warning("Material " + typeString + " is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = material.getItem();
|
||||
ItemStack item = material.get().parseItem();
|
||||
|
||||
// Add display name and lore
|
||||
String displayName = TextUtils.formatText(config.getString("required-axe.name"));
|
||||
|
@ -310,8 +311,8 @@ public class TreeDefinitionManager extends Manager {
|
|||
switch (treeBlockType) {
|
||||
case LOG:
|
||||
for (TreeDefinition treeDefinition : possibleTreeDefinitions) {
|
||||
for (CompatibleMaterial material : treeDefinition.getLogMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block)) {
|
||||
for (XMaterial material : treeDefinition.getLogMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block.getType()).orElse(null)) {
|
||||
matchingTreeDefinitions.add(treeDefinition);
|
||||
break;
|
||||
}
|
||||
|
@ -320,8 +321,8 @@ public class TreeDefinitionManager extends Manager {
|
|||
break;
|
||||
case LEAF:
|
||||
for (TreeDefinition treeDefinition : possibleTreeDefinitions) {
|
||||
for (CompatibleMaterial material : treeDefinition.getLeafMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block)) {
|
||||
for (XMaterial material : treeDefinition.getLeafMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block.getType()).orElse(null)) {
|
||||
matchingTreeDefinitions.add(treeDefinition);
|
||||
break;
|
||||
}
|
||||
|
@ -354,14 +355,14 @@ public class TreeDefinitionManager extends Manager {
|
|||
|
||||
for (TreeDefinition treeDefinition : this.treeDefinitions) {
|
||||
for (ItemStack requiredTool : treeDefinition.getRequiredTools()) {
|
||||
if (requiredTool.getType() == tool.getType()) {
|
||||
if (tool != null && requiredTool.getType() == tool.getType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack requiredTool : this.globalRequiredTools) {
|
||||
if (requiredTool.getType() == tool.getType()) {
|
||||
if (tool != null && requiredTool.getType() == tool.getType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -516,8 +517,8 @@ public class TreeDefinitionManager extends Manager {
|
|||
* @param treeDefinition The TreeDefinition
|
||||
* @return A Set of IBlockData of plantable soil
|
||||
*/
|
||||
public Set<CompatibleMaterial> getPlantableSoilMaterial(TreeDefinition treeDefinition) {
|
||||
Set<CompatibleMaterial> plantableSoilBlockData = new HashSet<>();
|
||||
public Set<XMaterial> getPlantableSoilMaterial(TreeDefinition treeDefinition) {
|
||||
Set<XMaterial> plantableSoilBlockData = new HashSet<>();
|
||||
plantableSoilBlockData.addAll(treeDefinition.getPlantableSoilMaterial());
|
||||
plantableSoilBlockData.addAll(this.globalPlantableSoil);
|
||||
return plantableSoilBlockData;
|
||||
|
@ -532,9 +533,9 @@ public class TreeDefinitionManager extends Manager {
|
|||
*/
|
||||
private TreeLoot getTreeLootEntry(TreeBlockType treeBlockType, ConfigurationSection configurationSection) {
|
||||
String material = configurationSection.getString("material");
|
||||
CompatibleMaterial compatibleMaterial = material == null ? null : CompatibleMaterial.getMaterial(material);
|
||||
Optional<XMaterial> compatibleMaterial = material == null ? Optional.empty() : CompatibleMaterial.getMaterial(material);
|
||||
|
||||
ItemStack item = compatibleMaterial == null ? null : compatibleMaterial.getItem();
|
||||
ItemStack item = compatibleMaterial.map(XMaterial::parseItem).orElse(null);
|
||||
String command = configurationSection.getString("command");
|
||||
double chance = configurationSection.getDouble("chance");
|
||||
return new TreeLoot(treeBlockType, item, command, chance);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
|
@ -148,8 +149,8 @@ public class TreeDetectionManager extends Manager {
|
|||
Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
boolean blockBelowIsLog = this.isValidLogType(possibleTreeDefinitions, null, blockBelow);
|
||||
boolean blockBelowIsSoil = false;
|
||||
for (CompatibleMaterial material : treeDefinitionManager.getPlantableSoilMaterial(actualTreeDefinition)) {
|
||||
if (material == CompatibleMaterial.getMaterial(blockBelow)) {
|
||||
for (XMaterial material : treeDefinitionManager.getPlantableSoilMaterial(actualTreeDefinition)) {
|
||||
if (material == CompatibleMaterial.getMaterial(blockBelow.getType()).orElse(null)) {
|
||||
blockBelowIsSoil = true;
|
||||
break;
|
||||
}
|
||||
|
@ -248,8 +249,8 @@ public class TreeDetectionManager extends Manager {
|
|||
// Check if it matches the tree definition
|
||||
boolean isCorrectType = false;
|
||||
for (TreeDefinition treeDefinition : treeDefinitions) {
|
||||
for (CompatibleMaterial material : treeDefinition.getLogMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block)) {
|
||||
for (XMaterial material : treeDefinition.getLogMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block.getType()).orElse(null)) {
|
||||
isCorrectType = true;
|
||||
break;
|
||||
}
|
||||
|
@ -299,8 +300,8 @@ public class TreeDetectionManager extends Manager {
|
|||
// Check if it matches the tree definition
|
||||
boolean isCorrectType = false;
|
||||
for (TreeDefinition treeDefinition : treeDefinitions) {
|
||||
for (CompatibleMaterial material : treeDefinition.getLeafMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block)) {
|
||||
for (XMaterial material : treeDefinition.getLeafMaterial()) {
|
||||
if (material == CompatibleMaterial.getMaterial(block.getType()).orElse(null)) {
|
||||
isCorrectType = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleHand;
|
||||
import com.songoda.core.hooks.JobsHook;
|
||||
import com.songoda.core.hooks.LogManager;
|
||||
import com.songoda.core.hooks.McMMOHook;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.world.SItemStack;
|
||||
import com.craftaro.core.compatibility.CompatibleHand;
|
||||
import com.craftaro.core.hooks.JobsHook;
|
||||
import com.craftaro.core.hooks.LogManager;
|
||||
import com.craftaro.core.hooks.McMMOHook;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.world.SItemStack;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.events.TreeFallEvent;
|
||||
import com.songoda.ultimatetimber.events.TreeFellEvent;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.tree;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -8,8 +8,8 @@ import java.util.Set;
|
|||
|
||||
public class TreeDefinition {
|
||||
private final String key;
|
||||
private final Set<CompatibleMaterial> logMaterial, leafMaterial, plantableSoilMaterial;
|
||||
private final CompatibleMaterial saplingMaterial;
|
||||
private final Set<XMaterial> logMaterial, leafMaterial, plantableSoilMaterial;
|
||||
private final XMaterial saplingMaterial;
|
||||
private final double maxLogDistanceFromTrunk;
|
||||
private final int maxLeafDistanceFromLog;
|
||||
private final boolean detectLeavesDiagonally;
|
||||
|
@ -18,8 +18,8 @@ public class TreeDefinition {
|
|||
private final Set<ItemStack> requiredTools;
|
||||
private final boolean requiredAxe;
|
||||
|
||||
public TreeDefinition(String key, Set<CompatibleMaterial> logMaterial, Set<CompatibleMaterial> leafMaterial, CompatibleMaterial saplingMaterial,
|
||||
Set<CompatibleMaterial> plantableSoilMaterial, double maxLogDistanceFromTrunk, int maxLeafDistanceFromLog,
|
||||
public TreeDefinition(String key, Set<XMaterial> logMaterial, Set<XMaterial> leafMaterial, XMaterial saplingMaterial,
|
||||
Set<XMaterial> plantableSoilMaterial, double maxLogDistanceFromTrunk, int maxLeafDistanceFromLog,
|
||||
boolean detectLeavesDiagonally, boolean dropOriginalLog, boolean dropOriginalLeaf, Set<TreeLoot> logLoot,
|
||||
Set<TreeLoot> leafLoot, Set<TreeLoot> entireTreeLoot, Set<ItemStack> requiredTools, boolean requiredAxe) {
|
||||
this.key = key;
|
||||
|
@ -53,7 +53,7 @@ public class TreeDefinition {
|
|||
*
|
||||
* @return A Set of CompatibleMaterial
|
||||
*/
|
||||
public Set<CompatibleMaterial> getLogMaterial() {
|
||||
public Set<XMaterial> getLogMaterial() {
|
||||
return Collections.unmodifiableSet(this.logMaterial);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class TreeDefinition {
|
|||
*
|
||||
* @return A Set of CompatibleMaterial
|
||||
*/
|
||||
public Set<CompatibleMaterial> getLeafMaterial() {
|
||||
public Set<XMaterial> getLeafMaterial() {
|
||||
return Collections.unmodifiableSet(this.leafMaterial);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class TreeDefinition {
|
|||
*
|
||||
* @return An CompatibleMaterial instance for the sapling
|
||||
*/
|
||||
public CompatibleMaterial getSaplingMaterial() {
|
||||
public XMaterial getSaplingMaterial() {
|
||||
return this.saplingMaterial;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class TreeDefinition {
|
|||
*
|
||||
* @return A Set of CompatibleMaterial
|
||||
*/
|
||||
public Set<CompatibleMaterial> getPlantableSoilMaterial() {
|
||||
public Set<XMaterial> getPlantableSoilMaterial() {
|
||||
return Collections.unmodifiableSet(this.plantableSoilMaterial);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.songoda.ultimatetimber.utils;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.compatibility.CompatibleMaterial;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -10,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockUtils {
|
||||
|
@ -17,26 +19,29 @@ public class BlockUtils {
|
|||
Set<ItemStack> drops = new HashSet<>();
|
||||
if (treeBlock.getBlock() instanceof Block) {
|
||||
Block block = (Block) treeBlock.getBlock();
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
if (material.isAir())
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(block.getType());
|
||||
if (!material.isPresent() || CompatibleMaterial.isAir(material.get())) {
|
||||
return drops;
|
||||
drops.add(CompatibleMaterial.getMaterial(block).getItem());
|
||||
}
|
||||
drops.add(material.get().parseItem());
|
||||
} else if (treeBlock.getBlock() instanceof FallingBlock) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial((FallingBlock) treeBlock.getBlock());
|
||||
if (material == null)
|
||||
Optional<XMaterial> material = CompatibleMaterial.getMaterial(((FallingBlock) treeBlock.getBlock()).getBlockData().getMaterial());
|
||||
if (!material.isPresent()) {
|
||||
return drops;
|
||||
drops.add(material.getItem());
|
||||
}
|
||||
drops.add(material.get().parseItem());
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
|
||||
public static void toggleGravityFallingBlock(FallingBlock fallingBlock, boolean applyGravity) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
fallingBlock.setGravity(applyGravity);
|
||||
}
|
||||
}
|
||||
|
||||
public static FallingBlock spawnFallingBlock(Location location, CompatibleMaterial material) {
|
||||
return location.getWorld().spawnFallingBlock(location, material.getMaterial(), material.getData());
|
||||
public static FallingBlock spawnFallingBlock(Location location, XMaterial material) {
|
||||
return location.getWorld().spawnFallingBlock(location, material.parseMaterial(), material.getData());
|
||||
}
|
||||
|
||||
public static void configureFallingBlock(FallingBlock fallingBlock) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.ultimatetimber.utils;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.craftaro.core.third_party.com.cryptomorin.xseries.XSound;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockType;
|
||||
import org.bukkit.Location;
|
||||
|
@ -11,7 +11,7 @@ public class SoundUtils {
|
|||
if (location.getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
CompatibleSound.BLOCK_CHEST_OPEN.play(location.getWorld(), location, 2F, 0.1F);
|
||||
XSound.BLOCK_CHEST_OPEN.play(location, 2, .1f);
|
||||
}
|
||||
|
||||
public static void playLandingSound(ITreeBlock block) {
|
||||
|
@ -21,9 +21,9 @@ public class SoundUtils {
|
|||
}
|
||||
|
||||
if (block.getTreeBlockType() == TreeBlockType.LOG) {
|
||||
CompatibleSound.BLOCK_WOOD_FALL.play(location.getWorld(), location, 2F, 0.1F);
|
||||
XSound.BLOCK_WOOD_FALL.play(location, 2, .1f);
|
||||
} else {
|
||||
CompatibleSound.BLOCK_GRASS_BREAK.play(location.getWorld(), location, 0.5F, 0.75F);
|
||||
XSound.BLOCK_GRASS_BREAK.play(location, .5f, .75f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue