[Completed] MagicEgg

Discussion in 'Plugin Requests' started by ExoNeon, Jan 24, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    ExoNeon

    Plugin category: Fun

    Suggested name: MagicEgg

    What I want: Hey guys! I've got a plugin idea that is pretty cool and I think you will love! here it is:
    So basically every hour there are 5 (configurable to desired amount) dragon eggs scattered around spawn with a holographic display above them that says Magic Egg. Once a player right clicks this egg it shoots a firework, drops some awesome items then despawns to another random place where this cycle continues.

    Features:
    • Easily input items and chances in the configs
    • Hourly clock that says a broadcast 5 minutes prior to starting the event
    • Somewhere whether its in-game or in the config file where i can input the coordinates

    Ideas for commands:
    /me force (forces the event to start)
    /me time (shows time till event starts)
    /me stop (stops plugin from operating)
    /me start (starts plugin)


    Ideas for permissions: Whatever you think (keep in mind this will only be used for admins)

    When I'd like it by: 1 month if possible

    let me know if theres any comments, questions, or concerns.

    THANKS!!!:D

    Still looking!
    Bump
     
    Last edited: Jan 25, 2016
  2. Offline

    ExoNeon

    sweet 2 likes :p
     
  3. Offline

    Puzikovs

    @ExoNeon that still doesnt make any java coder create that plugin xD But i really hope they will... Great idea! I would love to use it for my SkyPvP as well...
     
  4. Offline

    pie_flavor

    @ExoNeon A good idea would be to post your Java version and Minecraft version, since in MC 1.7 there are no armor stands so we use wither skulls for holograms, but in 1.8 wither skulls look glitchy so we use armor stands.
     
  5. Offline

    ExoNeon

    Thanks for the info guys!:rolleyes:
     
  6. Offline

    ExoNeon

    Still lookin for any takers
     
  7. Offline

    ExoNeon

    Still lookin, not quittin
     
  8. Offline

    Puzikovs

    Im still waiting for someone to work on this as well :D
     
  9. Offline

    TheMrJezza

    I might be able to make the eggs if someone would like to tackle the random location parts. Also like @pie_flavor said, is it for Minecraft 1.7 or 1.8??

    Edit:
    I've made methods for spawning the egg and also taken care of the fireworks and unspawning the egg when its right clicked.

    The method for spawning eggs is spawnEgg(Location);


    [​IMG]
    If someone would like to finish this off, as in handle where the eggs get spawned and when I'll leave the code here.
    Code (open)
    Code:
    package me.TheMrJezza;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Random;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Color;
    import org.bukkit.FireworkEffect;
    import org.bukkit.FireworkEffect.Type;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.ArmorStand;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Firework;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerToggleSneakEvent;
    import org.bukkit.inventory.meta.FireworkMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class MagicEggs extends JavaPlugin implements Listener {
    
        Map<Block, ArmorStand> map = new HashMap<Block, ArmorStand>();
    
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(this, this);
        }
    
        private int id;
    
        public void spawnEgg(Location loc) {
            Location blockLoc = new Location(loc.getWorld(), Double.valueOf(loc.getBlockX()),
                    Double.valueOf(loc.getBlockY()), Double.valueOf(loc.getBlockZ()));
            Block egg = loc.getWorld().getBlockAt(loc);
            if (!map.containsKey(egg)) {
                ArmorStand as = (ArmorStand) blockLoc.getWorld().spawnEntity(blockLoc.add(.5, 1, .5),
                        EntityType.ARMOR_STAND);
                blockLoc.add(0, -1, 0).getBlock().setType(Material.DRAGON_EGG);
                as.setGravity(false);
                as.setVisible(false);
                as.setArms(false);
                as.setBasePlate(false);
                as.setRemoveWhenFarAway(false);
                as.setSmall(true);
                as.setCustomNameVisible(true);
                as.setCustomName("§5M§8a§5g§8i§5c §8E§5g§8g.");
                map.put(egg, as);
            }
        }
    
        public void deleteEgg(Block egg) {
            map.get(egg).remove();
            egg.setType(Material.AIR);
            map.remove(egg);
        }
    
        public void fireworks(final Location loc) {
    
            id = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                int theInt = 0;
    
                public void run() {
                    if (theInt == 5) {
                        Bukkit.getScheduler().cancelTask(id);
                    } else {
                        theInt++;
                        Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
                        FireworkMeta fwm = fw.getFireworkMeta();
                        Random r = new Random();
                        int rt = r.nextInt(5) + 1;
                        Type type = Type.BALL;
                        if (rt == 1)
                            type = Type.BALL;
                        if (rt == 2)
                            type = Type.BALL_LARGE;
                        if (rt == 3)
                            type = Type.BURST;
                        if (rt == 4)
                            type = Type.CREEPER;
                        if (rt == 5)
                            type = Type.STAR;
                        int r1i = r.nextInt(17) + 1;
                        int r2i = r.nextInt(17) + 1;
                        Color c1 = getColor(r1i);
                        Color c2 = getColor(r2i);
                        FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2)
                                .with(type).trail(r.nextBoolean()).build();
                        fwm.addEffect(effect);
                        int rp = r.nextInt(2) + 1;
                        fwm.setPower(rp);
                        fw.setFireworkMeta(fwm);
                    }
                }
            }, 1, 2);
        }
    
        private Color getColor(int i) {
            Color c = null;
            if (i == 1) {
                c = Color.AQUA;
            }
            if (i == 2) {
                c = Color.BLACK;
            }
            if (i == 3) {
                c = Color.BLUE;
            }
            if (i == 4) {
                c = Color.FUCHSIA;
            }
            if (i == 5) {
                c = Color.GRAY;
            }
            if (i == 6) {
                c = Color.GREEN;
            }
            if (i == 7) {
                c = Color.LIME;
            }
            if (i == 8) {
                c = Color.MAROON;
            }
            if (i == 9) {
                c = Color.NAVY;
            }
            if (i == 10) {
                c = Color.OLIVE;
            }
            if (i == 11) {
                c = Color.ORANGE;
            }
            if (i == 12) {
                c = Color.PURPLE;
            }
            if (i == 13) {
                c = Color.RED;
            }
            if (i == 14) {
                c = Color.SILVER;
            }
            if (i == 15) {
                c = Color.TEAL;
            }
            if (i == 16) {
                c = Color.WHITE;
            }
            if (i == 17) {
                c = Color.YELLOW;
            }
            return c;
        }
    
        @EventHandler(priority = EventPriority.LOWEST)
        public void onRightClickOne(PlayerInteractEvent evt) {
            Block block = evt.getClickedBlock();
            evt.setCancelled(true);
            if (map.containsKey(block)) {
                if (block.getType() == Material.DRAGON_EGG) {
                    if (evt.getAction() == Action.RIGHT_CLICK_BLOCK || evt.getAction() == Action.LEFT_CLICK_BLOCK) {
                        deleteEgg(block);
                        fireworks(block.getLocation().add(.5, 0, .5));
                        return;
                    } else evt.setCancelled(false);
                } else evt.setCancelled(false);
            } else evt.setCancelled(false);
        }
    }

    For my convenience I found the code for the fireworks instead of coming up with a whole way to create random fireworks from scratch.

    Also this will work on Java 7 and 8, but it will only work on Minecraft 1.8
     
    Last edited: Jan 30, 2016
  10. Offline

    MarinD99

    I'll take a shot at this. Let you know of the progress.
     
  11. Offline

    TheMrJezza

    @MarinD99 Okay, well if you use the code I posted, I just wanted to tell you I just fixed a mistake I made and edited the code in my post, so if you copied it a few minutes ago, you might want to copy it again.
     
  12. Offline

    MarinD99

    @TheMrJezza I didn't copy your code. I have noticed that you added the method you found promising, but I believe I have a way around it. Still, thanks for the help :)
     
  13. Offline

    Lampades

    I'd really love to see this be a thing. PLEASE SOMEONE CONTINUE @TheMrJezza 's plugin. I would do it myself but i'd confuse myself in the process of doing so lol.
     
  14. Offline

    MarinD99

     
    Lampades likes this.
  15. Offline

    MarinD99

    A little bump to let everyone know that this project's active.

    [​IMG] [​IMG] [​IMG]
    [​IMG]

    Currently, the egg itself can be spawned via a command to bind it to a specific location, or just random ones. I'm currently handling particle effects which occur when the egg is broken. The project should be done this week, as I'm busy with real life and schoolwork. If you have any questions, suggestions, addons, please let me know.
     
    Last edited: Feb 1, 2016
  16. Offline

    Lampades

    Could you please make the item that drops customizable along with the name? If not, i'll try to decompile and edit it myself :) Thank you for your effort!
     
  17. Offline

    MarinD99

  18. Offline

    Lampades

    We are all lucky enough to have a MarinD99 in our lives.
     
  19. Offline

    MarinD99

    As requested, the eggs now drop mutliple random items, which have a configurable amount. What I did not implement, though, is dropping specific items. I might do that later on, but not right now(personal reasons).

    [​IMG]
     
  20. Offline

    Puzikovs

    @MarinD99 Seems legit enough, when this week do you think you will be releasing it?
     
  21. Offline

    MarinD99

    Probably Friday. I would have released it sooner, but I have other things to take care of first. Another questions, for
    @Puzikovs , @Lampades , and @ExoNeon - would you all mind if I published this resource on my Bukkit Dev profile?
     
  22. Offline

    Puzikovs

    @MarinD99 Ive got some things to tell you.
    The first would be a question tho, why are you even asking that?
    The second is that i wouldnt mind at all, you took your time to make this idea, you worked on it and you have the rights to publish it as your own, but 1 thing that would be nice of you, is that you would somewhere mention that this plugin wasnt your own idea, but that you worked on it. Since an empty idea without any help is just an idea, then you can have the credit for working on this and making it.
    Since this was a plugin request, this plugin will be tagged here afterwards as done, and anybody who checks this, will be able to download your custom plugin, so you might say, that someone else might as well publish it somewhere, and even take credit for it.

    So do publish it and take credit for it. It is your custom made plugin from somebodys custom idea.
    Ive heard that people have great ideas, but if they cant find the people to work with to make those great ideas, they wont be able to get them done and they will stay only ideas.
    My Point is, you made it, from somebodys idea, give them a heads up for the idea on your post of the plugin and publish it. More then just us will like this fun plugin. And its great that im going to be the first latvian server who has this feature!
     
    Lampades and MarinD99 like this.
  23. Offline

    Lampades

    Don't ask us, it's your right to do so, it's not like you've sniped the code from somewhere online. Go ahead and thank you!
     
  24. Offline

    MarinD99

    Quick update, I'll post the resource tomorrow, as I'm unsure when I'll get home today.
     
  25. Offline

    ExoNeon

    AWESOME WORK!!!!! CANT WAIT!!!
     
  26. Offline

    Lampades

    Is this being released anytime today? :D
     
  27. Offline

    MarinD99

    I'll have to apologize for the delay, I was visiting a parent in the hospital. Plese don't fret, I'll be releasing the plugin soon.
     
  28. Offline

    Lampades

    Alright, I hope your parent is alright? (Don't want to go too off-topic, but anyways :p)
     
  29. Offline

    Lampades

    Anything new...?
     
  30. Offline

    Puzikovs

    @Lampades im guessing we should simply give him some more time dude, since he is doing good work on helping you. just give him some time. Its not as easy as it seems to you.
     
    0566 likes this.
Thread Status:
Not open for further replies.

Share This Page