created excavator class
This commit is contained in:
parent
9bbc91baca
commit
aa86b3de7e
7 changed files with 259 additions and 0 deletions
16
plugin/.classpath
Normal file
16
plugin/.classpath
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="E:/Lightling/Libraries/Downloads/Paper-API-1.14.4-14513c3-20190910-1851.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="https://papermc.io/javadocs/paper/1.14/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="E:/Lightling/Libraries/Downloads/buildtools/Spigot/Spigot-API/target/spigot-api-1.14.4-R0.1-SNAPSHOT-shaded.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="https://hub.spigotmc.org/javadocs/spigot/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
13
plugin/.externalToolBuilders/Make JAR.launch
Normal file
13
plugin/.externalToolBuilders/Make JAR.launch
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="GibsoniaCraft"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/build.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
</launchConfiguration>
|
26
plugin/.project
Normal file
26
plugin/.project
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GibsoniaCraft</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Make JAR.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
10
plugin/build.xml
Normal file
10
plugin/build.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="GibsoniaCraft" default="makejar" basedir=".">
|
||||
<target name="makejar" description="Create a jar for the project">
|
||||
<mkdir dir="target"></mkdir>
|
||||
<jar destfile="target/${ant.project.name}.jar">
|
||||
<fileset dir="bin"></fileset>
|
||||
<fileset file="plugin.yml"></fileset>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
5
plugin/plugin.yml
Normal file
5
plugin/plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
main: lightling.gibsoniacraft.gibsoniacraft
|
||||
name: GibsoniaCraft
|
||||
version: 1.0
|
||||
author: Lightling
|
||||
description: Adds some small additions/changes to a PaperMC server
|
21
plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java
Normal file
21
plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package lightling.gibsoniacraft;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import lightling.gibsoniacraft.crafting.Excavator;
|
||||
|
||||
public final class GibsoniaCraft extends JavaPlugin {
|
||||
|
||||
private Excavator excavatorClass;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
}
|
168
plugin/src/lightling/gibsoniacraft/crafting/Excavator.java
Normal file
168
plugin/src/lightling/gibsoniacraft/crafting/Excavator.java
Normal file
|
@ -0,0 +1,168 @@
|
|||
package lightling.gibsoniacraft.crafting;
|
||||
|
||||
// Collections
|
||||
import java.util.List; // Needed for recipe choices and lore
|
||||
import java.util.ArrayList; // Needed for recipe choices and lore
|
||||
|
||||
// Excavator-specific
|
||||
import org.bukkit.NamespacedKey; // Needed for defining excavator's item key
|
||||
import org.bukkit.inventory.meta.ItemMeta; // Needed for defining excavator's item meta information
|
||||
import org.bukkit.Material; // Needed for defining pre-existing items
|
||||
import org.bukkit.inventory.ShapedRecipe; // Needed for defining crafting recipes
|
||||
import org.bukkit.inventory.RecipeChoice; // Needed for wood-excavator's wood choices
|
||||
import org.bukkit.inventory.ItemStack; // Excavator is a type of item, which uses ItemStack
|
||||
|
||||
// Plugin-specific
|
||||
import org.bukkit.plugin.java.JavaPlugin; // For registering the excavator within the plugin
|
||||
import org.bukkit.plugin.Plugin; // Involved in setting up namespaced-key
|
||||
import org.bukkit.Server; // For registering recipes on the server
|
||||
|
||||
/**
|
||||
* An excavator is a shovel-based item that digs in a 3x3 radius as opposed to a singular block
|
||||
* @author Lightling
|
||||
*/
|
||||
public class Excavator
|
||||
{
|
||||
// The item variants for the excavators
|
||||
private ItemStack woodExcavator;
|
||||
private ItemStack stoneExcavator;
|
||||
private ItemStack ironExcavator;
|
||||
private ItemStack goldExcavator;
|
||||
private ItemStack diamondExcavator;
|
||||
|
||||
// The item recipes for the excavators
|
||||
private ShapedRecipe woodExcRecipe;
|
||||
private ShapedRecipe stoneExcRecipe;
|
||||
private ShapedRecipe ironExcRecipe;
|
||||
private ShapedRecipe goldExcRecipe;
|
||||
private ShapedRecipe diamondExcRecipe;
|
||||
|
||||
// The namespaces for the excavators
|
||||
private NamespacedKey woodExcKey;
|
||||
private NamespacedKey stoneExcKey;
|
||||
private NamespacedKey ironExcKey;
|
||||
private NamespacedKey goldExcKey;
|
||||
private NamespacedKey diamondExcKey;
|
||||
|
||||
/**
|
||||
* Defines an excavator
|
||||
* @param plugin The parent plugin the excavator resides
|
||||
*/
|
||||
public Excavator(final JavaPlugin plugin)
|
||||
{
|
||||
SetupItems(plugin);
|
||||
SetupMetadata(plugin);
|
||||
SetupRecipes(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the basic excavator items
|
||||
* @param plugin The parent plugin the excavator resides
|
||||
*/
|
||||
private void SetupItems(final JavaPlugin plugin)
|
||||
{
|
||||
// Define the excavator items
|
||||
woodExcavator = new ItemStack(Material.WOODEN_SHOVEL);
|
||||
stoneExcavator = new ItemStack(Material.STONE_SHOVEL);
|
||||
ironExcavator = new ItemStack(Material.IRON_SHOVEL);
|
||||
goldExcavator = new ItemStack(Material.GOLDEN_SHOVEL);
|
||||
diamondExcavator = new ItemStack(Material.DIAMOND_SHOVEL);
|
||||
|
||||
// Define the excavator namespaced keys
|
||||
woodExcKey = new NamespacedKey((Plugin)plugin, "w_excavator");
|
||||
stoneExcKey = new NamespacedKey((Plugin)plugin, "s_excavator");
|
||||
ironExcKey = new NamespacedKey((Plugin)plugin, "i_excavator");
|
||||
goldExcKey = new NamespacedKey((Plugin)plugin, "g_excavator");
|
||||
diamondExcKey = new NamespacedKey((Plugin)plugin, "d_excavator");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up relevant metadata for the excavator
|
||||
* @param plugin The parent plugin the excavator resides
|
||||
*/
|
||||
private void SetupMetadata(final JavaPlugin plugin)
|
||||
{
|
||||
// Define metadata
|
||||
ItemMeta woodExcMeta = woodExcavator.getItemMeta();
|
||||
ItemMeta stoneExcMeta = stoneExcavator.getItemMeta();
|
||||
ItemMeta ironExcMeta = ironExcavator.getItemMeta();
|
||||
ItemMeta goldExcMeta = goldExcavator.getItemMeta();
|
||||
ItemMeta diamondExcMeta = diamondExcavator.getItemMeta();
|
||||
|
||||
// Define lore
|
||||
String loreString = "Based off of item from Tinkers' Construct";
|
||||
List<String> lore = new ArrayList<String>() {{ add(loreString); }};
|
||||
woodExcMeta.setLore(lore);
|
||||
stoneExcMeta.setLore(lore);
|
||||
ironExcMeta.setLore(lore);
|
||||
goldExcMeta.setLore(lore);
|
||||
diamondExcMeta.setLore(lore);
|
||||
|
||||
// Setup display names
|
||||
woodExcMeta.setDisplayName("Wooden Excavator");
|
||||
stoneExcMeta.setDisplayName("Stone Excavator");
|
||||
ironExcMeta.setDisplayName("Iron Excavator");
|
||||
goldExcMeta.setDisplayName("Golden Excavator");
|
||||
diamondExcMeta.setDisplayName("Diamond Excavator");
|
||||
|
||||
// Set item metadata
|
||||
woodExcavator.setItemMeta(woodExcMeta);
|
||||
stoneExcavator.setItemMeta(stoneExcMeta);
|
||||
ironExcavator.setItemMeta(ironExcMeta);
|
||||
goldExcavator.setItemMeta(goldExcMeta);
|
||||
diamondExcavator.setItemMeta(diamondExcMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the excavator recipes (defining required items) on the server
|
||||
* @param plugin The parent plugin the excavator resides
|
||||
*/
|
||||
private void SetupRecipes(final JavaPlugin plugin)
|
||||
{
|
||||
// Define recipe entries
|
||||
woodExcRecipe = new ShapedRecipe(woodExcKey, woodExcavator);
|
||||
stoneExcRecipe = new ShapedRecipe(stoneExcKey, stoneExcavator);
|
||||
ironExcRecipe = new ShapedRecipe(ironExcKey, ironExcavator);
|
||||
goldExcRecipe = new ShapedRecipe(goldExcKey, goldExcavator);
|
||||
diamondExcRecipe = new ShapedRecipe(diamondExcKey, diamondExcavator);
|
||||
|
||||
// Define recipe shapes
|
||||
woodExcRecipe.shape(new String[] { " x ", " xix ", " x "});
|
||||
stoneExcRecipe.shape(new String[] { " x ", " xix ", " x "});
|
||||
ironExcRecipe.shape(new String[] { " x ", " xix ", " x "});
|
||||
goldExcRecipe.shape(new String[] { " x ", " xix ", " x "});
|
||||
diamondExcRecipe.shape(new String[] { " x ", " xix ", " x "});
|
||||
|
||||
// Define recipe choice ingredients for wood excavator
|
||||
List<Material> woodChoices = new ArrayList<Material>()
|
||||
{{
|
||||
add(Material.ACACIA_PLANKS);
|
||||
add(Material.BIRCH_PLANKS);
|
||||
add(Material.DARK_OAK_PLANKS);
|
||||
add(Material.JUNGLE_PLANKS);
|
||||
add(Material.OAK_PLANKS);
|
||||
add(Material.SPRUCE_PLANKS);
|
||||
}};
|
||||
RecipeChoice woodChoice = new RecipeChoice.MaterialChoice(woodChoices);
|
||||
|
||||
// Define recipes for the excavators
|
||||
woodExcRecipe.setIngredient('x', woodChoice);
|
||||
woodExcRecipe.setIngredient('i', Material.WOODEN_SHOVEL);
|
||||
stoneExcRecipe.setIngredient('x', Material.COBBLESTONE);
|
||||
stoneExcRecipe.setIngredient('i', Material.STONE_SHOVEL);
|
||||
ironExcRecipe.setIngredient('x', Material.IRON_INGOT);
|
||||
ironExcRecipe.setIngredient('i', Material.IRON_SHOVEL);
|
||||
goldExcRecipe.setIngredient('x', Material.GOLD_INGOT);
|
||||
goldExcRecipe.setIngredient('i', Material.GOLDEN_SHOVEL);
|
||||
diamondExcRecipe.setIngredient('x', Material.DIAMOND);
|
||||
diamondExcRecipe.setIngredient('i', Material.DIAMOND_SHOVEL);
|
||||
|
||||
// Register recipes on the server
|
||||
Server server = plugin.getServer();
|
||||
server.addRecipe(woodExcRecipe);
|
||||
server.addRecipe(stoneExcRecipe);
|
||||
server.addRecipe(ironExcRecipe);
|
||||
server.addRecipe(goldExcRecipe);
|
||||
server.addRecipe(diamondExcRecipe);
|
||||
}
|
||||
}
|
Reference in a new issue