To put it simply, this is just a lucky blocks plugin that allows you to easily create 'random blocks' and 'events' for them with the RandomBlocks api as an 'addon'.
If you already heard of lucky blocks then you will know what happens when you break them in game, for those that don't it simply picks a weight/chance based event to occur from the type of random block that was broken.
Although luck is implemented, crafting with luck upgrades is currently disabled due to how spigot handles crafting and causes duplication issues.
I've attempted to fix/find a way around this with several different ways with no success, so until I can find a way to fix it, crafting with luck upgrades is going to be disabled.
root command = /randomblocks
alias command = /rbs
permission = randomblocks.admin
Comes with tab completion
/rbs help - gives this list
/rbs give <player> <random block> <amount> - give random blocks to a player
/rbs edit <random block> <event> <field> <value> - edit a random blocks' field for an event
/rbs test <random block> <event> - test a random blocks' event
/rbs enable <random block> - enables a random block
/rbs enable <random block> <event> - enables a random blocks event
/rbs disable <random block> - disables a random block
/rbs disable <random block> <event> - disables a random blocks event
/rbs savedata - saves current data
/rbs buggered <fix/remove> fixes or removes random blocks that have an incorrect block
/rbs delete <random block/@all> <world/@all> deletes all random blocks in a world
Code (YAML):
#How often to check for buggered random blocks checkBuggeredInterval: 20
#The action to take once a buggered random block is found - true = fix, false = remove fixOrRemove: false
#Should random blocks trigger if they are broken in creative triggerInCreative: false
#If random blocks should trigger when it fades - true = trigger, false = drop #For more info: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/block/BlockFadeEvent.html triggerOnFade: true
Code (YAML):
#List of all random block locations and data blockLocs: []
//String = random block name - must be alphanumeric and/or underscores //ItemStack = the itemstack that players hold - must be a block //Material = the type of block that represents a placed random block - must be solid RandomBlock testBlock
=new RandomBlock
("Test_Block",
new ItemStack
(Material.
CARROT),Material.
SAND){ @Override
publicvoid onPlace
(RandomBlockPlaceEvent e
){ e.
getRandomBlock();//The random block type that was placed e.
getWorld();//The world the random block was placed in e.
getBlock();//The block that was placed e.
getCenter();//The center of the block that was placed e.
getEntity();//The entity that placed the block (might be null) e.
getDisplayStand();//The display armor stand (might be null) e.
getInnerStand();//The inner armor stand (might be null)
//THE BELOW SETTINGS ARE OPTIONAL //IF YOU ARE USING DISPLAY STAND, SET THE DISPLAY NAME //IF YOU ARE USING INNER STAND, SET THE INNER TEXTURE
//Sets the recipe to make the random block (no recipe by default) the recipe result is irrelevant as it will be changed to the random blocks' itemstack testBlock.
setRecipe(new FurnaceRecipe
(new NamespacedKey
(this,
"test_block"),
new ItemStack
(Material.
STONE),Material.
TNT,
10,
160)); testBlock.
setTriggerOnExplode(false);//If this random block should trigger if it gets exploded (false by default) testBlock.
setTriggerOnBurn(true);//If this random block should trigger if it gets burned (false by default) testBlock.
setDisplayName(C.
parse("&aTest &bBlock"));//Sets the display name for the display armor stand (null by default) testBlock.
setUseDisplayStand(true);//If should use display armor stand (false by default) //Sets the texture of the inner armor stand (value/url/uuid/username/material/itemstack) testBlock.
setInnerTexture("http://textures.minecraft.net/texture/87c63d9079b75f90979783cf07ca726f65e3024415ac622a7c906cd25082af"); testBlock.
setSmallInnerStand(true);//If the inner armor stand should be small (false by default) testBlock.
setUseInnerStand(true);//If should use inner armor stand (false by default)
//Event Manager is where events are stored and handled testBlock.
getEventManager();//Gets the event manager testBlock.
getEventManager().
setIsUsingLuck(false);//Sets if picking events uses luck (false by default) //If you are not using luck, then don't worry about the next 4 options //Adds a luck upgrade for increasing luck in the crafting table by the set amount, add as many as you want. Amount must be between -100 and 100 inclusive testBlock.
getEventManager().
addLuckUpgrade(Material.
IRON_INGOT,
1); //Sets the chance of getting a good/neutral/bad event at a luck of 0, must add up to 100 (default 25/50/25) testBlock.
getEventManager().
setChanceAt0(25,
50,
25); //Sets the chance of getting a good/neutral/bad event at a luck of 100, must add up to 100 (default 75/20/5) testBlock.
getEventManager().
setChanceAt0(75,
20,
5); //Sets the chance of getting a good/neutral/bad event at a luck of -100, must add up to 100 (default 5/20/75) testBlock.
getEventManager().
setChanceAt0(5,
20,
75);
//Add as many events as you want //Event - The event to occur testBlock.
addEvent(newEvent(){ //Non final public primitive fields + strings are editable in game publicint speed
=2; publicint explosionRadius
=5; publicint fuseTicks
=50; publicdouble health
=10; publicboolean powered
=true; publicboolean glowing
=true; publicString customName
="&bSuper Creeper";
//The name of the event - must be alphanumeric and/or underscores @Override
publicString getName
(){ return"super_creeper"; }
//The weight/chance of the event to happen, must be >= 0 @Override
publicdouble getWeight
(){ return .1
; }
//The type of event, GOOD - NEUTRAL - BAD //If you are not using luck, then set this to whatever because it doesn't really matter @Override
public EventType getType
(){ return EventType.
BAD; }
//What happens when you break the block @Override
publicvoid onBreak
(RandomBlockBreakEvent e
){ //+ the above methods in the onPlace method e.
isRemoveDisplayStand();//If the display armor stand is going to be removed e.
isRemoveInnerStand();//If the inner armor stand is going to be removed e.
setRemoveDisplayStand(true);//Set if the display armor stand should be removed (true by default) e.
setRemoveInnerStand(true);//Set if the inner armor stand should be removed (true by default)
//Example usage e.
getWorld().
playSound(e.
getCenter(), Sound.
ENTITY_CREEPER_DEATH,
1,.5F
);