Skip to content

Instantly share code, notes, and snippets.

View KoalaOnCaffeine's full-sized avatar

Tom Newton KoalaOnCaffeine

View GitHub Profile
package me.koalaoncaffeine.itemstack;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public final class TimeParser {
private static final long MINUTE = 60;
private static final long HOUR = MINUTE * 60;
private static final long DAY = HOUR * 24;
private static final long WEEK = DAY * 7;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.nio.file.Path;
public class FileHandler {
private FileConfiguration config = new YamlConfiguration();
private File file;
@KoalaOnCaffeine
KoalaOnCaffeine / DependencyInjection.java
Last active February 16, 2024 17:16
Constructor dependency injection
public final class CustomCommandPlugin extends JavaPlugin {
@Override
public final void onEnable() {
getCommand("command").setExecutor(new CommandClass(getConfig().getString("Hello-Message")));
// creating a new instance of the command class, passing in the hello message parameter as the String from the command class' constructor.
// getCommand being an inherited method from JavaPlugin.
// setExecutor being a method which every PluginCommand has, defining where it will run to.
// new CommandClass being the constructor of the class below.
// getConfig().getString("Hello-Message"); being a String located in the config, if this string is not there: