created chunkloader item
This commit is contained in:
parent
12cfef6ef8
commit
7c08152114
4 changed files with 67 additions and 4 deletions
|
@ -7,8 +7,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import lightling.gibsoniacraft.crafting.Excavator;
|
import lightling.gibsoniacraft.crafting.Excavator;
|
||||||
import lightling.gibsoniacraft.crafting.Hammer;
|
import lightling.gibsoniacraft.crafting.Hammer;
|
||||||
import lightling.gibsoniacraft.crafting.LumberAxe;
|
import lightling.gibsoniacraft.crafting.LumberAxe;
|
||||||
import lightling.gibsoniacraft.util.BlockListener;
|
import lightling.gibsoniacraft.listener.BlockListener;
|
||||||
import lightling.gibsoniacraft.util.PlayerInteractListener;
|
import lightling.gibsoniacraft.listener.PlayerInteractListener;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class GibsoniaCraft extends JavaPlugin {
|
public final class GibsoniaCraft extends JavaPlugin {
|
||||||
|
|
62
plugin/src/lightling/gibsoniacraft/crafting/ChunkLoader.java
Normal file
62
plugin/src/lightling/gibsoniacraft/crafting/ChunkLoader.java
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
package lightling.gibsoniacraft.crafting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A chunk loader is a block (beacon in appearance) that keeps a chunk loaded
|
||||||
|
* @author Lightling
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class ChunkLoader {
|
||||||
|
|
||||||
|
private ItemStack chunkItem;
|
||||||
|
private ShapedRecipe chunkRecipe;
|
||||||
|
private NamespacedKey chunkKey;
|
||||||
|
private ItemMeta chunkMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a chunk loader
|
||||||
|
* @param plugin
|
||||||
|
*/
|
||||||
|
public ChunkLoader(final JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
Setup(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the chunk loader block
|
||||||
|
* @param plugin
|
||||||
|
*/
|
||||||
|
public void Setup(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
// Handle initial values
|
||||||
|
chunkItem = new ItemStack(Material.BEACON);
|
||||||
|
chunkKey = new NamespacedKey(plugin, "chunkloader");
|
||||||
|
|
||||||
|
// Handle meta
|
||||||
|
chunkMeta = chunkItem.getItemMeta();
|
||||||
|
String loreString = "Keeps chunks loaded";
|
||||||
|
ArrayList<String> lore = new ArrayList<String>() {{ add(loreString); }};
|
||||||
|
chunkMeta.setLore(lore);
|
||||||
|
chunkMeta.setDisplayName("Chunk Loader");
|
||||||
|
chunkItem.setItemMeta(chunkMeta);
|
||||||
|
|
||||||
|
// Handle recipe
|
||||||
|
chunkRecipe = new ShapedRecipe(chunkKey, chunkItem);
|
||||||
|
chunkRecipe.shape(new String[] { "ooo", "eme", "epe" });
|
||||||
|
chunkRecipe.setIngredient('o', Material.OBSIDIAN);
|
||||||
|
chunkRecipe.setIngredient('e', Material.EMERALD);
|
||||||
|
chunkRecipe.setIngredient('m', Material.MAGMA_BLOCK);
|
||||||
|
chunkRecipe.setIngredient('p', Material.PRISMARINE_CRYSTALS);
|
||||||
|
Server server = plugin.getServer();
|
||||||
|
server.addRecipe(chunkRecipe);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package lightling.gibsoniacraft.util;
|
package lightling.gibsoniacraft.listener;
|
||||||
|
|
||||||
// Needed for block information
|
// Needed for block information
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -18,6 +18,7 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import lightling.gibsoniacraft.GibsoniaCraft;
|
import lightling.gibsoniacraft.GibsoniaCraft;
|
||||||
import lightling.gibsoniacraft.lib.BlockRef;
|
import lightling.gibsoniacraft.lib.BlockRef;
|
||||||
|
import lightling.gibsoniacraft.util.ToolUtil;
|
||||||
|
|
||||||
// Needed for GibsoniaCraft tools
|
// Needed for GibsoniaCraft tools
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
|
@ -1,4 +1,4 @@
|
||||||
package lightling.gibsoniacraft.util;
|
package lightling.gibsoniacraft.listener;
|
||||||
|
|
||||||
import java.util.HashMap; // Needed to store block-face information
|
import java.util.HashMap; // Needed to store block-face information
|
||||||
|
|
Reference in a new issue