Advanced Map Options - OresomeCraft/MapsPlugin GitHub Wiki

There are many more things you can do with these map configurations, this is one of the great benefits of having it coded in Java. Please note that these examples will have less documentation than the configuration explained above.

Wait what? Why don't you guys import the classes in these examples?? To make it more copy/paste friendly. Many people were submitting maps containing this code, without importing the required classes. Remember, at the top of the page of your configuration file, you need to import (required class);

If you need any help with this, feel free to ask for help from one of our map configuration team members. See https://github.com/OresomeCraft/MapsPlugin for a list of team members.

Inventory Utilities

Colour leather armour according to team

Armour can be coloured according to a player's team by adding the following code before their armour is set:

ArmourUtils.colourArmourAccordingToTeam(p, new ItemStack[]{LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_PANTS, LEATHER_BOOTS});

LEATHER_HELMET, etc being the armour variables you defined. Make sure this is run before p.setBoots(), etc is called!

Naming an item

An item can easily be named by running the following code before adding the item to their inventory (This code needs to be added before i.setItem() etc):

ItemUtils.nameItem(IRON_SWORD, ChatColor.RED + "Blade of death!");

IRON_SWORD being the declared variable for an iron sword.


Abilities / Effects

Disable breaking of certain blocks

    @EventHandler
    public void protection(org.bukkit.event.block.BlockBreakEvent event) {
        org.bukkit.block.Block b = event.getBlock();
        int mat = b.getTypeId();
        if (event.getBlock().getLocation().getWorld().getName().equals(name)) {
            if (mat == 43 || mat == 44 || mat == 35 || mat == 42
                    || mat == 49 || mat == 123 || mat == 69 || mat == 124) {
                event.setCancelled(true);
            }
        }
    }

This will disable the breaking block of these specific blocks.

Key:

mat - Get the block being hit

|| - Or operator

Again, these topics are more suited for people who have more of a clue what they're doing. If you would like to have this but don't know how to do it yourself, just leave a comment (using // ) in the class file explaining what blocks you don't want them to be able to break, or ask for help from one of our map configuration team members. See https://github.com/OresomeCraft/OresomeBattles-Maps for a list of team members.

Setting an item's description

Not only can you set the item's name, but you can also give it a description (lore). The description is basically shown where an enchantment would be shown.

    ItemMeta egg_hypno = EGG_HYPNO.getItemMeta(); // Get the item's metadata
    egg_hypno.setDisplayName(ChatColor.BLUE + "Flash bang grenade"); // Set the name

    List<String> eggLore = new ArrayList<String>(); // ArrayList to store the lore
    eggLore.add(org.bukkit.ChatColor.BLUE + "Everyone's favourite item!"); // Lore (Description)
    egg_hypno.setLore(eggLore); // Set the lore
    EGG_HYPNO.setItemMeta(egg_hypno); // Set the metadata

You can also have multiple lines of lore. To add a new line just do 'lore.add("Stuff here");' on the line below the first one to add another line!

Creating particles where a projectile hits

This can help create some oresome visual effects. I highly recommend people experiment with this if they're in the advanced category of people.

    @EventHandler
    public void arrowBoom(org.bukkit.event.entity.ProjectileHitEvent event) {
        org.bukkit.entity.Entity arrow = event.getEntity();
        World world = Bukkit.getWorld(name);
        if (getArena().equals(name)) {
            if (arrow instanceof org.bukkit.entity.Arrow) {
                world.playEffect(arrow.getLocation(), org.bukkit.Effect.STEP_SOUND, 8);
            }
        }
    }

You can make this play any sort of particles, but you'll need to do your own research to find them. The example above makes a block breaking particle effect. The number defined at the end is the ID of the block, so in this case water. If you wanted a golden explosion, you would change that number to the ID of a gold block.

You may also notice the if statement that makes sure this is an arrow, you could change this to say snowballs, it's up to you!

Making particles follow an entity (in this case an arrow)

    public int particles;
    @EventHandler
    public void arrowParticles(org.bukkit.event.world.WorldLoadEvent event) {
        if (event.getWorld().getName().equals(name)) {
            particles = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                public void run() {
                    World world = Bukkit.getWorld(name);
                    if (getArena().equals(name)) {
                        for (org.bukkit.entity.Entity arrow : world.getEntities()) {
                            if (arrow != null) {
                                if (arrow instanceof org.bukkit.entity.Arrow) {
                                    world.playEffect(arrow.getLocation(), org.bukkit.Effect.SMOKE, 10);
                                }
                            }
                        }
                    }
                }
            }, 5L, 5L);
        }
    }

    @EventHandler
    public void cancelParticles(com.oresomecraft.OresomeBattles.api.events.BattleEndEvent event) {
        Bukkit.getScheduler().cancelTask(particles);
    }

This code will make a trail of smoke follow the arrow once it is fired. In fact, this code will create smoke around ALL loaded arrow entities in the world. To prevent this (if you don't want that happening), check out the code example below to automatically remove arrow entities.

Automatically remove arrows

Getting lots of arrows everywhere? They can be automatically removed!

    @EventHandler
    public void arrowAway(org.bukkit.event.entity.ProjectileHitEvent event) {
        org.bukkit.entity.Entity projectile = event.getEntity();
        Location loc = projectile.getLocation();
        if (loc.getWorld().getName().equals(name)) {
            if (projectile instanceof org.bukkit.entity.Arrow) {
                org.bukkit.entity.Arrow a = (org.bukkit.entity.Arrow) projectile;
                a.remove();
            }
        }
    }

I want stuff like the Grappling hook in my map!

You can easily add that to your map! The code for all our abilities open source and can easily be accessed via this repo. Simply navigate to that classes configuration file and copy it! Be careful though, as many of these classes use imports, so make sure you're including the required imports!

Alternatively you can get a copy of most of the effects here

⚠️ **GitHub.com Fallback** ⚠️