Custom Drops

• Custom Drops •

- First off, download latest version of luckyblock plugin.
- Open your project.
- Add plugin to your libraries
(Right click your project>Properties>Java build path>Libraries>Add external JARs>Then add this plugin)
- Create your custom drop class and make it implements CustomDrop.
- Available methods (Suggest more):

        public String getName(); // Drop name

        public boolean isVisible(); // Whether this drop is visible by commands.

        public DropOption[] getDefaultOptions(); // Default drop options (Optional, Return null if you don't want to use this).

        public String[] getDescription(); // Description is shown when using /lb dropslist command.

        public boolean isEnabledByCommands(); // Whether drop can be set by commands

        public void function(LB lb, Player player); // Function method.


- Example (EffectsDrop):

        public class EffectsDrop implements CustomDrop {

        @Override
        public String getName(){
        return "EFFECTS_DROP";
        }
	
	@Override
	public boolean isVisible(){
	return true;
	}
	
	@Override
	public boolean isEnabledByCommands(){
	return true;
	}
	
	@Override
	public String[] getDescription(){
	return new String[]{"This is a custom drop","Spawns random particles"};
	}
	
	@Override
	public DropOption[] getDefaultOptions(){
	return new DropOption[]{new DropOption("Particles",new String[]{"BARRIER","CLOUD","CRIT",
        "CRIT_MAGIC","DRIP_LAVA","DRIP_WATER",
	"FIREWORKS_SPARK","FLAME","FOOTSTEP","HEART","LAVA","NOTE","ENCHANTMENT_TABLE",
        "PORTAL","REDSTONE","SLIME","SMOKE_NORMAL","SPELL","SPELL_MOB","SPELL_MOB_AMBIENT",
	"SPELL_WITCH","SUSPENDED_DEPTH","TOWN_AURA","VILLAGER_ANGRY","VILLAGER_HAPPY"})};
	}
	
	@Override
	public void function(final LB lb, Player player){
	if(lb.hasDropOption("Particles")){
	final String[] s = (String[]) lb.getDropOption("Particles").getValues();
	final SchedulerTask task = new SchedulerTask();
	task.setId(LuckyBlock.instance.getServer().getScheduler().scheduleSyncRepeatingTask(
        LuckyBlock.instance, new Runnable(){
	int x = 10;
	@Override
	public void run(){
	int r = new Random().nextInt(s.length);
	Particle e = Particle.valueOf(s[r].toUpperCase());
	lb.getBlock().getWorld().spawnParticle(e, lb.getBlock().getLocation(), 100, 0.3, 0.3, 0.3, 0);
	x--;
	if(x < 1){
	task.run();
	}
	}
	}, 5L, 5L));
	}
	}

        }

- Add this to onEnable() method:

CustomDropManager.registerDrop(new EffectsDrop());

- You are done! Use /lb dropslist to see your custom drop.
- You can also use /lb setdrop [YourCustomDropName].


Comments

Posts Quoted:
Reply
Clear All Quotes