Skip to content

Instantly share code, notes, and snippets.

@DarkBlade12
DarkBlade12 / Line.java
Last active May 12, 2022 02:25
This class allows you to iterate over the blocks that are between two locations
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector;
@DarkBlade12
DarkBlade12 / InventoryFactory.java
Last active August 29, 2015 13:56
This class allows you to serialize an inventory to single string and vice-versa!
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
public final class InventoryFactory {
private InventoryFactory() {}
@DarkBlade12
DarkBlade12 / ReflectionUtils.java
Last active August 8, 2019 23:49
These are utils which make dealing with reflection much easier.
package com.darkblade12.particledemo.particle;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
@DarkBlade12
DarkBlade12 / MetadataUtil.java
Last active January 3, 2016 06:49
This a little util which allows you to easily use Metadata
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.Metadatable;
import org.bukkit.plugin.Plugin;
public final class MetadataUtil {
private Plugin plugin;
private String pluginName;
public MetadataUtil(Plugin plugin) {
this.plugin = plugin;
@DarkBlade12
DarkBlade12 / BlockCrackData.java
Last active December 28, 2015 08:39
These classes provide a way to store a ParticleEffect with methods for serializing/deserializing.
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
* This class is part of the ParticleEffect library and follows the same usage conditions
*
* @author DarkBlade12
*/
public class BlockCrackData extends ParticleEffectData {
private static final String FORMAT = "\\d+@\\d+(@\\d+(\\.\\d+)?){3}@\\d+";
@DarkBlade12
DarkBlade12 / ScrollingString.java
Last active November 5, 2017 21:03
Implementation of a scrolling string.
public class ScrollingString {
private String original;
private int width;
private int position;
public ScrollingString(String original, int width) {
if (width <= 0)
throw new IllegalArgumentException("Width value has to be greater than 0");
else if (original.length() < width)
throw new IllegalArgumentException("String length has to be greater than the width value");
@DarkBlade12
DarkBlade12 / ParticleEffect.java
Last active December 23, 2023 16:20
This is a little library which allows you to display all possible particle effects in Minecraft with your plugin.
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;