mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-02-27 00:51:41 +01:00
Added lots of boilerplate code
This commit is contained in:
parent
7bd1157f07
commit
665ece06da
@ -1,36 +1,30 @@
|
||||
package com.songoda.ultimatetimber;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapter;
|
||||
import com.songoda.ultimatetimber.adapter.current.CurrentAdapter;
|
||||
import com.songoda.ultimatetimber.adapter.legacy.LegacyAdapter;
|
||||
import com.songoda.ultimatetimber.manager.*;
|
||||
import com.songoda.ultimatetimber.utils.Methods;
|
||||
import com.songoda.ultimatetimber.utils.Metrics;
|
||||
import com.songoda.ultimatetimber.utils.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.songoda.ultimatetimber.commands.CommandHandler;
|
||||
import com.songoda.ultimatetimber.configurations.DefaultConfig;
|
||||
import com.songoda.ultimatetimber.manager.HookManager;
|
||||
import com.songoda.ultimatetimber.treefall.CustomLoot;
|
||||
import com.songoda.ultimatetimber.treefall.TreeFallAnimation;
|
||||
import com.songoda.ultimatetimber.treefall.TreeFallListener;
|
||||
import com.songoda.ultimatetimber.utils.Methods;
|
||||
|
||||
public class UltimateTimber extends JavaPlugin {
|
||||
|
||||
private static final String prefix = "&8[&6UltimateTimber&8]";
|
||||
private static final CommandSender console = Bukkit.getConsoleSender();
|
||||
private static UltimateTimber INSTANCE;
|
||||
|
||||
private VersionAdapter adapter;
|
||||
private Set<String> validWorlds = new HashSet<>();
|
||||
private List<UUID> isNotChopping = new ArrayList<>();
|
||||
private VersionAdapter versionAdapter;
|
||||
private ConfigurationManager configurationManager;
|
||||
private DisabledWorldManager disabledWorldManager;
|
||||
private HookManager hookManager;
|
||||
private MessageManager messageManager;
|
||||
private SettingsManager settingsManager;
|
||||
private TreeAnimationManager treeAnimationManager;
|
||||
private TreeDefinitionManager treeDefinitionManager;
|
||||
private TreeFallManager treeFallManager;
|
||||
|
||||
public static UltimateTimber getInstance() {
|
||||
return INSTANCE;
|
||||
@ -44,52 +38,18 @@ public class UltimateTimber extends JavaPlugin {
|
||||
console.sendMessage(Methods.formatText("&7" + this.getDescription().getName() + " " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
|
||||
|
||||
/*
|
||||
Set up version adapter
|
||||
*/
|
||||
this.setupAdapter();
|
||||
this.configurationManager = new ConfigurationManager(this);
|
||||
this.disabledWorldManager = new DisabledWorldManager(this);
|
||||
this.hookManager = new HookManager(this);
|
||||
this.messageManager = new MessageManager(this);
|
||||
this.settingsManager = new SettingsManager(this);
|
||||
this.treeAnimationManager = new TreeAnimationManager(this);
|
||||
this.treeDefinitionManager = new TreeDefinitionManager(this);
|
||||
this.treeFallManager = new TreeFallManager(this);
|
||||
|
||||
/*
|
||||
Register the main event that handles toppling down trees
|
||||
*/
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new TreeFallListener(), this);
|
||||
this.setupVersionAdapter();
|
||||
this.reload();
|
||||
|
||||
/*
|
||||
Prevent falling blocks from forming new blocks on the floor
|
||||
*/
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new TreeFallAnimation(), this);
|
||||
|
||||
/*
|
||||
Initialize config
|
||||
*/
|
||||
DefaultConfig.initialize();
|
||||
|
||||
/*
|
||||
Initialize custom loot
|
||||
*/
|
||||
CustomLoot.initializeCustomItems();
|
||||
|
||||
/*
|
||||
Cache valid world names for later use
|
||||
*/
|
||||
this.reloadValidWorlds();
|
||||
|
||||
/*
|
||||
Hook into supported plugins
|
||||
*/
|
||||
HookManager.getInstance().hook();
|
||||
|
||||
/*
|
||||
Register command executor and tab completer
|
||||
*/
|
||||
PluginCommand ultimatetimber = this.getCommand("ultimatetimber");
|
||||
CommandHandler commandHandler = new CommandHandler();
|
||||
ultimatetimber.setExecutor(commandHandler);
|
||||
ultimatetimber.setTabCompleter(commandHandler);
|
||||
|
||||
/*
|
||||
Set up metrics
|
||||
*/
|
||||
new Metrics(this);
|
||||
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
@ -101,45 +61,103 @@ public class UltimateTimber extends JavaPlugin {
|
||||
console.sendMessage(Methods.formatText("&7" + this.getDescription().getName() + " " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &cDisabling&7..."));
|
||||
|
||||
this.validWorlds.clear();
|
||||
this.isNotChopping.clear();
|
||||
|
||||
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
}
|
||||
|
||||
public void reloadValidWorlds() {
|
||||
this.validWorlds = this.getConfig().getConfigurationSection(DefaultConfig.VALID_WORLDS).getKeys(false);
|
||||
/**
|
||||
* Reloads the plugin's settings
|
||||
*/
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isWorldValid(World world) {
|
||||
return this.validWorlds.contains(world.getName());
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
private void setupAdapter() {
|
||||
/**
|
||||
* Sets up the version adapter
|
||||
*/
|
||||
private void setupVersionAdapter() {
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
this.adapter = new CurrentAdapter();
|
||||
this.versionAdapter = new CurrentAdapter();
|
||||
} else {
|
||||
this.adapter = new LegacyAdapter();
|
||||
this.versionAdapter = new LegacyAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean toggleChopping(Player player) {
|
||||
boolean removed = this.isNotChopping.remove(player.getUniqueId());
|
||||
if (!removed)
|
||||
this.isNotChopping.add(player.getUniqueId());
|
||||
return removed;
|
||||
public VersionAdapter getVersionAdapter() {
|
||||
return this.versionAdapter;
|
||||
}
|
||||
|
||||
public boolean isChopping(Player player) {
|
||||
return !this.isNotChopping.contains(player.getUniqueId());
|
||||
/**
|
||||
* Gets the configuration manager
|
||||
*
|
||||
* @return The ConfigurationManager instance
|
||||
*/
|
||||
public ConfigurationManager getConfigurationManager() {
|
||||
return configurationManager;
|
||||
}
|
||||
|
||||
public VersionAdapter getAdapter() {
|
||||
return this.adapter;
|
||||
/**
|
||||
* Gets the disabled world manager
|
||||
*
|
||||
* @return The DisabledWorldManager instance
|
||||
*/
|
||||
public DisabledWorldManager getDisabledWorldManager() {
|
||||
return disabledWorldManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hook manager
|
||||
*
|
||||
* @return The HookManager instance
|
||||
*/
|
||||
public HookManager getHookManager() {
|
||||
return hookManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration manager
|
||||
*
|
||||
* @return The ConfigurationManager instance
|
||||
*/
|
||||
public MessageManager getMessageManager() {
|
||||
return messageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings manager
|
||||
*
|
||||
* @return The SettingsManager instance
|
||||
*/
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree animation manager
|
||||
*
|
||||
* @return The TreeAnimationManager instance
|
||||
*/
|
||||
public TreeAnimationManager getTreeAnimationManager() {
|
||||
return treeAnimationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree definition manager
|
||||
*
|
||||
* @return The TreeDefinitionManager instance
|
||||
*/
|
||||
public TreeDefinitionManager getTreeDefinitionManager() {
|
||||
return treeDefinitionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree fall manager
|
||||
*
|
||||
* @return The TreeFallManager instance
|
||||
*/
|
||||
public TreeFallManager getTreeFallManager() {
|
||||
return treeFallManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.ultimatetimber.adapter;
|
||||
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeDefinition;
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -7,22 +9,30 @@ import java.util.Set;
|
||||
|
||||
public interface VersionAdapter {
|
||||
|
||||
VersionAdapterType getVersionAdapterType();
|
||||
|
||||
/**
|
||||
* Get the items that a block should drop when it breaks
|
||||
* Loads a Set of TreeDefinitions from the config
|
||||
*
|
||||
* @param block The target block
|
||||
* @return A Set of loaded TreeDefinitions
|
||||
*/
|
||||
Set<TreeDefinition> loadTreeDefinitions();
|
||||
|
||||
/**
|
||||
* Get the items that a tree block should drop when it breaks
|
||||
*
|
||||
* @param treeBlock The tree block broken
|
||||
* @param treeDefinition The tree definition to get the drops for
|
||||
* @return A Set of ItemStacks that should be dropped
|
||||
*/
|
||||
Set<ItemStack> getBlockDrops(Block block);
|
||||
Set<ItemStack> getTreeBlockDrops(TreeBlock treeBlock, TreeDefinition treeDefinition);
|
||||
|
||||
/**
|
||||
* Applies damage to a tool
|
||||
*
|
||||
* @param blocks The Set of blocks that are being broken
|
||||
* @param treeBlocks The Set of tree blocks that are being broken
|
||||
* @param tool The tool to apply damage to
|
||||
*/
|
||||
void applyToolDurability(Set<Block> blocks, ItemStack tool);
|
||||
|
||||
|
||||
void applyToolDurability(Set<TreeBlock> treeBlocks, ItemStack tool);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.songoda.ultimatetimber.adapter;
|
||||
|
||||
/**
|
||||
* The version adapter type
|
||||
* Used to determine what version adapter is being used
|
||||
*/
|
||||
public enum VersionAdapterType {
|
||||
CURRENT,
|
||||
LEGACY
|
||||
}
|
@ -1,7 +1,33 @@
|
||||
package com.songoda.ultimatetimber.adapter.current;
|
||||
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapter;
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapterType;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeDefinition;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class CurrentAdapter implements VersionAdapter {
|
||||
|
||||
@Override
|
||||
public VersionAdapterType getVersionAdapterType() {
|
||||
return VersionAdapterType.CURRENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TreeDefinition> loadTreeDefinitions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ItemStack> getTreeBlockDrops(TreeBlock treeBlock, TreeDefinition treeDefinition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToolDurability(Set<TreeBlock> blocks, ItemStack tool) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,33 @@
|
||||
package com.songoda.ultimatetimber.adapter.legacy;
|
||||
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapter;
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapterType;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeDefinition;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class LegacyAdapter implements VersionAdapter {
|
||||
|
||||
@Override
|
||||
public VersionAdapterType getVersionAdapterType() {
|
||||
return VersionAdapterType.LEGACY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TreeDefinition> loadTreeDefinitions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ItemStack> getTreeBlockDrops(TreeBlock treeBlock, TreeDefinition treeDefinition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToolDurability(Set<TreeBlock> blocks, ItemStack tool) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (args.length > 0)
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (commandSender instanceof Player && !permCheck((Player) commandSender, "ultimatetimber.reload")) {
|
||||
return true;
|
||||
@ -37,6 +37,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter {
|
||||
commandSender.sendMessage(Methods.formatText("&cConsole cannot toggle chopping mode!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
commandSender.sendMessage("");
|
||||
commandSender.sendMessage(Methods.formatText(UltimateTimber.getInstance().getPrefix() + " &7Version " + UltimateTimber.getInstance().getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
|
@ -12,7 +12,7 @@ import com.songoda.ultimatetimber.treefall.TreeChecker;
|
||||
*/
|
||||
public class TreeFallEvent extends TreeEvent implements Cancellable {
|
||||
|
||||
boolean cancelled = false;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public TreeFallEvent(Player player, TreeChecker treeChecker, Block broke) {
|
||||
super(player, treeChecker, broke);
|
||||
|
@ -14,7 +14,7 @@ import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.songoda.ultimatetimber.utils.WoodToLogConverter;
|
||||
|
||||
public class JobsRebornHook implements TimberHook {
|
||||
public class JobsHook implements TimberHook {
|
||||
|
||||
@Override
|
||||
public void apply(Player player, HashSet<Block> treeBlocks) throws Exception {
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.ultimatetimber.hooks;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -10,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.api.ExperienceAPI;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.songoda.ultimatetimber.utils.WoodToLogConverter;
|
||||
|
||||
public class McMMOHook implements TimberHook {
|
||||
|
||||
@ -42,7 +42,7 @@ public class McMMOHook implements TimberHook {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player, HashSet<Block> treeBlocks) throws Exception {
|
||||
public void apply(Player player, Set<TreeBlock> treeBlocks) throws Exception {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE))
|
||||
return;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.songoda.ultimatetimber.hooks;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface TimberHook {
|
||||
|
||||
/**
|
||||
* Applies the hook
|
||||
*/
|
||||
void apply(Player player, HashSet<Block> treeBlocks) throws Exception;
|
||||
void apply(Player player, Set<TreeBlock> treeBlocks) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,21 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
public class ConfigurationManager {
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
|
||||
public class ConfigurationManager extends Manager {
|
||||
|
||||
public ConfigurationManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DisabledWorldManager extends Manager {
|
||||
|
||||
private Set<String> disabledWorldNames;
|
||||
|
||||
public DisabledWorldManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
this.disabledWorldNames = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -3,32 +3,30 @@ package com.songoda.ultimatetimber.manager;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.songoda.ultimatetimber.hooks.JobsRebornHook;
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.hooks.JobsHook;
|
||||
import com.songoda.ultimatetimber.hooks.McMMOHook;
|
||||
import com.songoda.ultimatetimber.hooks.TimberHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HookManager {
|
||||
|
||||
private static HookManager instance;
|
||||
public class HookManager extends Manager {
|
||||
|
||||
private Set<TimberHook> hooks;
|
||||
|
||||
private HookManager() {
|
||||
this.hooks = new HashSet<>();
|
||||
public HookManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the HookManager
|
||||
*
|
||||
* @return The instance of the HookManager
|
||||
*/
|
||||
public static HookManager getInstance() {
|
||||
if (instance == null)
|
||||
instance = new HookManager();
|
||||
return instance;
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,7 +34,7 @@ public class HookManager {
|
||||
*/
|
||||
public void hook() {
|
||||
this.tryHook("mcMMO", McMMOHook.class);
|
||||
this.tryHook("Jobs", JobsRebornHook.class);
|
||||
this.tryHook("Jobs", JobsHook.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
|
||||
abstract class Manager {
|
||||
|
||||
protected UltimateTimber ultimateTimber;
|
||||
|
||||
Manager(UltimateTimber ultimateTimber) {
|
||||
this.ultimateTimber = ultimateTimber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the Manager's settings
|
||||
*/
|
||||
abstract void reload();
|
||||
|
||||
/**
|
||||
* Cleans up the Manager's resources
|
||||
*/
|
||||
abstract void disable();
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
public class MessageManager {
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
|
||||
public class MessageManager extends Manager {
|
||||
|
||||
public enum MessageType {
|
||||
TOGGLE_ON,
|
||||
@ -8,4 +10,24 @@ public class MessageManager {
|
||||
RELOAD
|
||||
}
|
||||
|
||||
private final String prefix = "&8[&6UltimateTimber&8]";
|
||||
|
||||
public MessageManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,20 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
public class SettingsManager {
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
|
||||
public enum TSetting {
|
||||
public class SettingsManager extends Manager {
|
||||
|
||||
public SettingsManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,32 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
public class TreeAnimationManager {
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
public class TreeAnimationManager extends Manager implements Listener {
|
||||
|
||||
public TreeAnimationManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
Bukkit.getPluginManager().registerEvents(this, ultimateTimber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onFallingBlockLand(EntityChangeBlockEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,26 @@ import com.songoda.ultimatetimber.tree.TreeDefinition;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TreeDefinitionManager {
|
||||
public class TreeDefinitionManager extends Manager {
|
||||
|
||||
private UltimateTimber ultimateTimber;
|
||||
private Set<TreeDefinition> treeDefinitions;
|
||||
|
||||
public TreeDefinitionManager(UltimateTimber ultimateTimber) {
|
||||
this.ultimateTimber = ultimateTimber;
|
||||
super(ultimateTimber);
|
||||
this.treeDefinitions = new HashSet<>();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@Override
|
||||
public void reload() {
|
||||
this.treeDefinitions.clear();
|
||||
|
||||
this.treeDefinitions = this.ultimateTimber.getVersionAdapter().loadTreeDefinitions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
this.treeDefinitions.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,32 @@
|
||||
package com.songoda.ultimatetimber.manager;
|
||||
|
||||
public class TreeFallManager {
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class TreeFallManager extends Manager implements Listener {
|
||||
|
||||
public TreeFallManager(UltimateTimber ultimateTimber) {
|
||||
super(ultimateTimber);
|
||||
Bukkit.getPluginManager().registerEvents(this, ultimateTimber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.songoda.ultimatetimber.tree;
|
||||
|
||||
public enum TreeAnimationType {
|
||||
FANCY,
|
||||
DISENTIGRATE,
|
||||
CHAOS,
|
||||
NONE
|
||||
}
|
23
src/main/java/com/songoda/ultimatetimber/tree/TreeBlock.java
Normal file
23
src/main/java/com/songoda/ultimatetimber/tree/TreeBlock.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.songoda.ultimatetimber.tree;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class TreeBlock {
|
||||
|
||||
private final Block block;
|
||||
private final TreeBlockType treeBlockType;
|
||||
|
||||
public TreeBlock(Block block, TreeBlockType treeBlockType) {
|
||||
this.block = block;
|
||||
this.treeBlockType = treeBlockType;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
public TreeBlockType getTreeBlockType() {
|
||||
return this.treeBlockType;
|
||||
}
|
||||
|
||||
}
|
156
src/main/java/com/songoda/ultimatetimber/tree/TreeBlockSet.java
Normal file
156
src/main/java/com/songoda/ultimatetimber/tree/TreeBlockSet.java
Normal file
@ -0,0 +1,156 @@
|
||||
package com.songoda.ultimatetimber.tree;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TreeBlockSet implements Collection {
|
||||
|
||||
private Set<TreeBlock> logBlocks;
|
||||
private Set<TreeBlock> leafBlocks;
|
||||
|
||||
public TreeBlockSet() {
|
||||
this.logBlocks = new HashSet<>();
|
||||
this.leafBlocks = new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all logs in this TreeBlockSet
|
||||
*
|
||||
* @return A Set of TreeBlocks
|
||||
*/
|
||||
public Set<TreeBlock> getLogBlocks() {
|
||||
return Collections.unmodifiableSet(this.logBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all leaves in this TreeBlockSet
|
||||
*
|
||||
* @return A Set of TreeBlocks
|
||||
*/
|
||||
public Set<TreeBlock> getLeafBlocks() {
|
||||
return Collections.unmodifiableSet(this.leafBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all blocks in this TreeBlockSet
|
||||
*
|
||||
* @return A Set of all TreeBlocks
|
||||
*/
|
||||
public Set<TreeBlock> getAllTreeBlocks() {
|
||||
Set<TreeBlock> treeBlocks = new HashSet<>();
|
||||
treeBlocks.addAll(this.logBlocks);
|
||||
treeBlocks.addAll(this.leafBlocks);
|
||||
return treeBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.logBlocks.size() + this.leafBlocks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.logBlocks.isEmpty() && this.leafBlocks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return this.logBlocks.contains(o) || this.leafBlocks.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
return this.getAllTreeBlocks().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return this.getAllTreeBlocks().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Object o) {
|
||||
if (!(o instanceof TreeBlock)) return false;
|
||||
TreeBlock treeBlock = (TreeBlock) o;
|
||||
switch (treeBlock.getTreeBlockType()) {
|
||||
case LOG:
|
||||
return this.logBlocks.add(treeBlock);
|
||||
case LEAF:
|
||||
return this.leafBlocks.add(treeBlock);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if (!(o instanceof TreeBlock)) return false;
|
||||
TreeBlock treeBlock = (TreeBlock) o;
|
||||
switch (treeBlock.getTreeBlockType()) {
|
||||
case LOG:
|
||||
return this.logBlocks.remove(treeBlock);
|
||||
case LEAF:
|
||||
return this.leafBlocks.remove(treeBlock);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection c) {
|
||||
boolean allAdded = true;
|
||||
for (Object o : c) {
|
||||
if (!this.add(o)) {
|
||||
allAdded = false;
|
||||
}
|
||||
}
|
||||
return allAdded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.logBlocks.clear();
|
||||
this.leafBlocks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection c) {
|
||||
boolean retainedAll = true;
|
||||
for (Object o : c) {
|
||||
if (!this.contains(o)) {
|
||||
this.remove(o);
|
||||
} else {
|
||||
retainedAll = false;
|
||||
}
|
||||
}
|
||||
return retainedAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection c) {
|
||||
boolean removedAll = true;
|
||||
for (Object o : c) {
|
||||
if (this.contains(o)) {
|
||||
this.remove(o);
|
||||
} else {
|
||||
removedAll = false;
|
||||
}
|
||||
}
|
||||
return removedAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection c) {
|
||||
for (Object o : c)
|
||||
if (!this.contains(o))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray(Object[] a) {
|
||||
Set<TreeBlock> treeBlocks = new HashSet<>();
|
||||
for (Object o : a)
|
||||
if (o instanceof TreeBlock)
|
||||
treeBlocks.add((TreeBlock)o);
|
||||
return treeBlocks.toArray();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.songoda.ultimatetimber.tree;
|
||||
|
||||
/**
|
||||
* Represents a tree block type and whether it is a log or a leaf block
|
||||
*/
|
||||
public enum TreeBlockType {
|
||||
LOG,
|
||||
LEAF
|
||||
}
|
@ -17,4 +17,5 @@ public class Methods {
|
||||
text = text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -256,10 +256,18 @@ trees:
|
||||
# The loot applies to each log broken in the tree
|
||||
# To add more, increment the number by 1
|
||||
# The chance is out of 100 and can contain decimals
|
||||
# The default examples here are to show what you can do with custom loot
|
||||
global-custom-log-loot:
|
||||
0:
|
||||
material: DIAMOND
|
||||
chance: 0
|
||||
1:
|
||||
command: 'eco give %player% 5'
|
||||
chance: 0
|
||||
2:
|
||||
material: GOLDEN_APPLE
|
||||
command: 'broadcast %player% found a golden apple in a tree!'
|
||||
chance: 0
|
||||
|
||||
# Custom loot that is available for all tree types
|
||||
# The loot applies to each leaf broken in the tree
|
||||
@ -278,3 +286,12 @@ global-required-tools:
|
||||
- IRON_AXE
|
||||
- GOLDEN_AXE
|
||||
- DIAMOND_AXE
|
||||
|
||||
# Hooks into other plugins to apply exp gain/abilities
|
||||
hooks:
|
||||
jobs:
|
||||
enabled: false
|
||||
mcmmo:
|
||||
enabled: false
|
||||
require-tree-feller-ability-active: false
|
||||
apply-extra-drops-multiplier: true
|
||||
|
@ -297,10 +297,18 @@ trees:
|
||||
# The loot applies to each log broken in the tree
|
||||
# To add more, increment the number by 1
|
||||
# The chance is out of 100 and can contain decimals
|
||||
# The default examples here are to show what you can do with custom loot
|
||||
global-custom-log-loot:
|
||||
0:
|
||||
material: DIAMOND
|
||||
chance: 0
|
||||
1:
|
||||
command: 'eco give %player% 5'
|
||||
chance: 0
|
||||
2:
|
||||
material: GOLDEN_APPLE
|
||||
command: 'broadcast %player% found a golden apple in a tree!'
|
||||
chance: 0
|
||||
|
||||
# Custom loot that is available for all tree types
|
||||
# The loot applies to each leaf broken in the tree
|
||||
@ -319,3 +327,12 @@ global-required-tools:
|
||||
- IRON_AXE
|
||||
- GOLD_AXE
|
||||
- DIAMOND_AXE
|
||||
|
||||
# Hooks into other plugins to apply exp gain/abilities
|
||||
hooks:
|
||||
jobs:
|
||||
enabled: false
|
||||
mcmmo:
|
||||
enabled: false
|
||||
require-tree-feller-ability-active: false
|
||||
apply-extra-drops-multiplier: true
|
||||
|
0
src/main/resources/messages.yml
Normal file
0
src/main/resources/messages.yml
Normal file
Loading…
Reference in New Issue
Block a user