### Good Code Example Source: https://github.com/pikamug/quests/blob/main/CONTRIBUTING.md Demonstrates correct code formatting with proper indentation and spacing. ```Java if (var.func(param1, param2)) { // do things } ``` -------------------------------- ### Bad Code Example Source: https://github.com/pikamug/quests/blob/main/CONTRIBUTING.md Illustrates incorrect code formatting with inconsistent spacing and indentation. ```Java if(vAR.func( param1, param2 )) //do things ``` -------------------------------- ### MySQL Storage Configuration Source: https://github.com/pikamug/quests/wiki/Expert-‐-Storage Example configuration for storing player data in a MySQL database. Specify connection details and optional table prefix. ```yaml storage-data: address: localhost database: minecraft username: root password: myComplexPassword table_prefix: quests_ pool-settings: max-pool-size: 10 min-idle: 10 max-lifetime: 1800000 connection-timeout: 5000 ``` -------------------------------- ### Java Custom Objective Example Source: https://github.com/pikamug/quests/wiki/Master-‐-Custom-Quest-API Example of a custom objective that tracks block breaking. It demonstrates setting objective properties and handling block break events to increment quest progress. ```java package xyz.janedoe; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; public class AnyBreakBlockObjective extends CustomObjective { private static Quests quests = (Quests) Bukkit.getServer().getPluginManager().getPlugin("Quests"); public AnyBreakBlockObjective() { setName("Break Blocks Objective"); setAuthor("Jane Doe"); this.addItem("DIRT", 0); // Quests 4.0.0+ only setShowCount(true); addStringPrompt("Obj Name", "Set a name for the objective", "Break ANY block"); setCountPrompt("Set the amount of blocks to break"); setDisplay("%Obj Name%: %count%"); } @EventHandler(priority = EventPriority.LOW) public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); for (Quest q : quests.getQuester(player.getUniqueId()).getCurrentQuests().keySet()) { incrementObjective(player, this, 1, q); return; } } } ``` -------------------------------- ### Configure New Year's Celebration Quest Availability Source: https://github.com/pikamug/quests/wiki/Beginner-‐-Planner Set up a quest for a specific annual event, like a New Year's celebration. This example shows a quest available for a short duration on New Year's Eve/Day, with an annual repeat cycle and a one-hour player cooldown. ```yaml custom1: name: PrepareForNewYears ... planner: start: 31:12:2020:23:0:0:SystemV/EST5 end: 1:1:2021:0:0:0:SystemV/EST5 repeat: 31536000 cooldown: 3600 override: false ``` -------------------------------- ### Create Experience Objective - Java Source: https://github.com/pikamug/quests/wiki/Master-‐-Custom-Quest-API Implement a custom objective that tracks player experience gain. This requires listening to PlayerExpChangeEvent and using incrementObjective to update quest progress. ```Java package xyz.janedoe; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerExpChangeEvent; public class ExperienceObjective extends CustomObjective implements Listener { // Get the Quests plugin Quests qp = (Quests)Bukkit.getServer().getPluginManager().getPlugin("Quests"); // Construct the objective public ExperienceObjective() { this.setName("Experience Objective"); this.setAuthor("Jane Doe"); this.addItem("BOOK", 0); // Quests 4.0.0+ only this.setShowCount(true); this.setCountPrompt("Enter the experience points that the player must acquire:"); this.setDisplay("Acquire experience points: %count%"); } // Catch the Bukkit event for a player gaining/losing exp @EventHandler public void onPlayerExpChange(PlayerExpChangeEvent evt){ // Make sure to evaluate for all of the player's current quests for (Quest quest : qp.getQuester(evt.getPlayer().getUniqueId()).getCurrentQuests().keySet()) { // Check if the player gained exp, rather than lost if (evt.getAmount() > 0) { // Add to the objective's progress, completing it if requirements were met incrementObjective(evt.getPlayer(), this, evt.getAmount(), quest); } } } } ``` -------------------------------- ### Create a Custom Requirement in Java Source: https://github.com/pikamug/quests/wiki/Master-‐-Custom-Quest-API Extend the CustomRequirement class to create a new requirement. Use the constructor to set metadata and define prompts. Implement testRequirement to define the logic for checking if a player meets the condition. ```java package xyz.janedoe; import java.util.Map; import org.bukkit.entity.Player; import me.blackvein.quests.CustomRequirement; public class NameRequirement extends CustomRequirement { // Construct the requirement public NameRequirement() { this.setName("Name Requirement"); this.setAuthor("Jane Doe"); this.addItem("NAME_TAG", 0); // Quests 4.0.0+ only this.addStringPrompt("Name", "Enter value that player's name must contain in order to take the Quest", null); this.addStringPrompt("Case-Sensitive", "Should the check be case-sensitive or not? (Enter 'true' or 'false'", null); } // Test whether a player has met the requirement @Override public boolean testRequirement(Player player, Map data) { String caseSensitive = (String) data.get("Case-Sensitive"); // Check whether the name must be case-sensitive if (caseSensitive.equalsIgnoreCase("true")) { // Mark the requirement as satisfied if name matches return player.getName().contains((String)data.get("Name")); } else { // Mark the requirement as satisfied if name matches, ignoring case return player.getName().toLowerCase().contains(((String)data.get("Name")).toLowerCase()); } } } ``` -------------------------------- ### Create a Custom Loot Reward Source: https://github.com/pikamug/quests/wiki/Master-‐-Custom-Quest-API Extend CustomReward to create a new reward type. Use the constructor to set reward properties and prompts. Implement giveReward to define the logic for dispensing the reward, handling player data, and opening inventories. ```java package xyz.janedoe; import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import me.blackvein.quests.CustomReward; public class LootReward extends CustomReward { // Construct the reward public LootReward() { this.setName("Loot Reward"); this.setAuthor("Jane Doe"); this.addItem("CHEST", 0); // Quests 4.0.0+ only this.setRewardName("Loot Chest: %Title%"); this.addStringPrompt("Title", "Title of the loot inventory interface.", null); this.addStringPrompt("NumIron", "Enter the number of iron ingots to give in the loot chest.", null); this.addStringPrompt("NumGold", "Enter the number of gold ingots to give in the loot chest.", null); this.addStringPrompt("NumDiamond", "Enter the number of diamonds to give in the loot chest.", null); } // Give loot reward to a player @Override public void giveReward(Player player, Map data) { String title = (String) data.get("Title"); int numIron = 0; int numGold = 0; int numDiamond = 0; // Attempt to load user input as integers try { numIron = Integer.parseInt((String) data.get("NumIron")); } catch (NumberFormatException nfe) { Bukkit.getLogger().severe("Loot Reward has invalid Iron number: " + numIron); } try { numGold = Integer.parseInt((String) data.get("NumGold")); } catch (NumberFormatException nfe) { Bukkit.getLogger().severe("Loot Reward has invalid Gold number: " + numGold); } try { numDiamond = Integer.parseInt((String) data.get("NumDiamond")); } catch (NumberFormatException nfe) { Bukkit.getLogger().severe("Loot Reward has invalid Diamond number: " + numDiamond); } // Create a temporary inventory to add items to Inventory inv = Bukkit.getServer().createInventory(player, 3, title); int slot = 0; // Check if amount is greater than default value if (numIron > 0) { // Add item to current slot in temporary inventory, then get next slot ready inv.setItem(slot, new ItemStack(Material.IRON_INGOT, numIron > 64 ? 64 : numIron)); slot++; } if (numGold > 0) { inv.setItem(slot, new ItemStack(Material.GOLD_INGOT, numGold > 64 ? 64 : numGold)); slot++; } if (numDiamond > 0) { inv.setItem(slot, new ItemStack(Material.DIAMOND, numDiamond > 64 ? 64 : numDiamond)); } // Open temporary inventory for player to accept items player.openInventory(inv); } } ``` -------------------------------- ### List Configuration for Block Breaking Source: https://github.com/pikamug/quests/wiki/Ye-Ol'-Legacy-Documentation Use lists to define blocks to break, their amounts, and durability for quest stages. Durability specifies block variations and is unused in MC 1.13+. ```yaml break-block-names: - stone break-block-amounts: - 10 break-block-durability: - 1 ``` -------------------------------- ### Create Drop Item Objective - Java Source: https://github.com/pikamug/quests/wiki/Master-‐-Custom-Quest-API Implement a custom objective for dropping specific items. This involves listening to PlayerDropItemEvent, validating the item type, and updating quest progress. ```Java package xyz.janedoe; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.inventory.ItemStack; public class DropItemObjective extends CustomObjective { // Get the Quests plugin Quests qp = (Quests)Bukkit.getServer().getPluginManager().getPlugin("Quests"); // Construct the objective public DropItemObjective() { this.setName("Drop Item Objective"); this.setAuthor("Jane Doe"); this.addItem("ANVIL", 0); // Quests 4.0.0+ only this.setShowCount(true); this.setCountPrompt("Enter the amount that the player must drop:"); this.setDisplay("Drop %Item Name%: %count%"); this.addStringPrompt("Item Name", "Enter the name of the item that the player must drop", "DIRT"); } // Catch the Bukkit event for a player dropping an item @EventHandler public void onPlayerDropItem(PlayerDropItemEvent evt){ // Make sure to evaluate for all of the player's current quests for (Quest quest : qp.getQuester(evt.getPlayer().getUniqueId()).getCurrentQuests().keySet()) { Map map = getDataForPlayer(evt.getPlayer(), this, quest); ItemStack stack = evt.getItemDrop().getItemStack(); String userInput = (String) map.get("Item Name"); EntityType type = EntityType.fromName(userInput); // Display error if user-specified item name is invalid if (type == null) { Bukkit.getLogger().severe("Drop Item Objective has invalid item name: " + userInput); continue; } // Check if the item the player dropped is the one user specified if (evt.getItemDrop().getItemStack().getType().equals(type)) { // Add to the objective's progress, completing it if requirements were met incrementObjective(evt.getPlayer(), this, stack.getAmount(), quest); } } } } ``` -------------------------------- ### Configure Daily Quest Availability Source: https://github.com/pikamug/quests/wiki/Beginner-‐-Planner Set a quest to be available daily between specific hours, with a daily repeat cycle and player cooldown. The 'override' setting allows players to take the quest immediately after the repeat cycle ends, regardless of their cooldown. ```yaml custom1: name: OnceDaily ... planner: start: 11:1:2020:9:0:0:SystemV/EST5 end: 11:1:2020:17:0:0:SystemV/EST5 repeat: 86400 cooldown: 32400 override: true ``` -------------------------------- ### ItemStack Configuration with Data Value for Variation Source: https://github.com/pikamug/quests/wiki/Ye-Ol'-Legacy-Documentation Configure an ItemStack specifying its name, amount, a data value for item variation (like Charcoal from Coal), a custom display name, and lore. ```yaml items: - name-DIRT:amount-3:data-2:displayname-Spectacular Dirt:lore-Top notch topsoil! ``` -------------------------------- ### ItemStack Configuration with Enchantments and Custom Display Source: https://github.com/pikamug/quests/wiki/Ye-Ol'-Legacy-Documentation Define an ItemStack with a specific name, amount, enchantments, custom display name, and lore. Colons are supported in lore since Quests 3.2.5, but avoid using the 'charSemi' value. ```yaml items: - name-DIAMOND_SWORD:amount-1:enchantment-Sharpness 3:enchantment-Looting 2:displayname-Eviscerator:lore-It is said that this sword is:lore-so sharp that it can cut through:lore-obsidian. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.