Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.bgsoftware.wildtools.api.events;

import com.bgsoftware.wildtools.api.WildTools;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public final class PluginInitializeEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final WildTools plugin;

public PluginInitializeEvent(WildTools plugin) {
this.plugin = plugin;
}

public WildTools getPlugin() {
return plugin;
}

@Override public HandlerList getHandlers() { return HANDLERS; }
public static HandlerList getHandlerList() { return HANDLERS; }
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bgsoftware.wildtools.api.handlers;

import com.bgsoftware.wildtools.api.objects.Selection;
import com.bgsoftware.wildtools.api.objects.*;
import com.bgsoftware.wildtools.api.objects.tools.BuilderTool;
import com.bgsoftware.wildtools.api.objects.tools.CannonTool;
import com.bgsoftware.wildtools.api.objects.tools.CraftingTool;
Expand All @@ -19,6 +19,7 @@
import com.bgsoftware.wildtools.api.objects.tools.SellTool;

import java.util.List;
import java.util.Map;

public interface ToolsManager {

Expand Down Expand Up @@ -132,16 +133,48 @@ public interface ToolsManager {
*/
double getPrice(Player player, ItemStack itemStack);

/**
* Register a new tool kind.
* @param kind The tool kind to register.
* @param factory The factory for creating tools of this kind.
*/
void registerToolKind(ToolKind kind,
ToolKindFactory factory);

/**
* Get a tool kind by its id.
* @param id The id to check.
* @return If exists, the tool kind. Otherwise, null.
*/
ToolKind getKind(String id);

/**
* Get all the registered tool kinds.
*/
Map<String, ToolKind> getRegisteredKinds();

/**
* Register a new tool.
* @param type The type of the tool.
* @param name The name of the tool.
* @param toolClass The tool class.
* @param arg Additional arguments for the item.
* @return The new tool.
* @deprecated Use {@link #registerTool(String, Material, String, ToolSectionView)} instead.
*/
@Deprecated
<T extends Tool> T registerTool(Material type, String name, Class<T> toolClass, Object arg);

/**
* Register a new tool.
* @param kindId The kind id of the tool.
* @param type The type of the tool.
* @param name The name of the tool.
* @param cfg The tool section view configuration.
* @return The new tool.
*/
<T extends Tool> T registerTool(String kindId, Material type, String name, ToolSectionView cfg);

/**
* Check whether or not a player is owning an item or not.
* @param itemStack The item to check.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.bgsoftware.wildtools.api.objects;

import org.bukkit.inventory.ItemStack;
import com.bgsoftware.wildtools.api.objects.tools.Tool;

public interface ToolKind {
String id();

default int sortOrder() {
return 0;
}

default boolean isSimilar(ItemStack stack, Tool tool) {
return tool.isSimilar(stack);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.bgsoftware.wildtools.api.objects;

import org.bukkit.Material;
import com.bgsoftware.wildtools.api.objects.tools.Tool;

@FunctionalInterface
public interface ToolKindFactory {
Tool create(Material type, String name, ToolSectionView cfg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.bgsoftware.wildtools.api.objects;

import java.util.List;

public interface ToolSectionView {
boolean contains(String path);

String getString(String path, String def);

int getInt(String path, int def);

long getLong(String path, long def);

double getDouble(String path, double def);

boolean getBoolean(String path, boolean def);

List<String> getStringList(String path);
}
Loading