codename_B's list of plugins under 50 lines of code AKA the under 50 challenge

Discussion in 'Resources' started by codename_B, Aug 23, 2011.

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

    V10lator

    Not at all as the java compiler filters out unused imports. :p
     
  2. Offline

    ZachBora

    It seems you're not using the logger you declared.
    You're also using twice the player and send declaration, might be able to save lines somewhere. Also might do error if no arguments provided to the command.
     
  3. Offline

    codename_B

    Why using PermissionsEx? EW! I banish you!
     
    thehutch likes this.
  4. Offline

    ZachBora

    It's not me it's @EdenCampo 's code
     
  5. Offline

    Zaros

    You hint a bit of GENIUS.
     
  6. Offline

    user_43347

    You're missing the point where its just for fun. Also, we're doing this to see what can be done in 50 lines or less, its a challenge. And users can just compile it themselves, we didn't make this ready to deploy. And yes, none of these have plugin.ymls, because we don't need them, why? Because this is for fun.
     
  7. Offline

    md_5

    My exact point, some user got all serious about it when it ISNT
    We are on the same team
    --Discussion ended--
     
  8. Offline

    user_43347

    Except you didn't understand that in your comment, you were serious about it.
    --Discussion started--
     
  9. Offline

    ZachBora

  10. Offline

    thehutch


    Lol this was already pointed out so both fail :D
     
  11. Offline

    Zaros

    Code:java
    1. import *
     
  12. Offline

    codename_B

    Plugins that would actually work given a plugin.yml please.
     
    V10lator likes this.
  13. Offline

    md_5

    Even better:
    The plugin that does anything and everything

    Code:java
    1. *
     
    r3Fuze and VADemon like this.
  14. Offline

    Fishrock123

    We get the point, can we stay with making useful stuff instead of spamming 1 lined stuff?
     
  15. Offline

    ACStache

    but imagine the possibilities of that 1 line of code! it's endless! it's the "all permissions granted" of java coding!
    but in all seriousness, I agree. back to the actual plugins! :D
     
  16. Offline

    zhuowei

    TypingIsWinning: The first plugin that will only run on Glowstone, and not on CraftBukkit. Take that, people who call net.minecraft.server methods!
    Type /win to see the End Poem.
    Code:java
    1. package net.zhuoweizhang.typingiswinning;
    2.  
    3. import org.bukkit.command.*;
    4. import net.glowstone.entity.*;
    5. import net.glowstone.msg.*;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class TypingIsWinningPlugin extends JavaPlugin {
    9. public void onDisable() {
    10. }
    11.  
    12. public void onEnable() {
    13. }
    14. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    15. if (sender instanceof GlowPlayer) {
    16. GlowPlayer player = (GlowPlayer) sender;
    17. player.getSession().send(new StateChangeMessage((byte)4, (byte)0));
    18. return true;
    19. }
    20. return false;
    21. }
    22. }

    And because you wanted, plugin.yml:
    Show Spoiler
    Code:
    author: zhuowei
    database: false
    description: Display the Minecraft win message when you type /win.
    main: net.zhuoweizhang.typingiswinning.TypingIsWinningPlugin
    name: TypingisWinning
    startup: postworld
    version: '1.0'
    commands:
        win:
            description: Type to win the game!
            usage: /<command>

    When the 1.0RC2 Bukkit gets released, I'll add CraftBukkit support.
     
  17. Offline

    Unlucky4ever

    No EXP orbs dropped 36 lines

    Code:java
    1. package com.unlucky4ever.exp;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.event.Event;
    6. import org.bukkit.event.entity.EntityDeathEvent;
    7. import org.bukkit.event.entity.EntityListener;
    8. import org.bukkit.plugin.PluginDescriptionFile;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class RemoveEXP extends JavaPlugin {
    12. Logger log = Logger.getLogger("Minecraft");
    13.  
    14. @Override
    15. public void onDisable() {
    16. PluginDescriptionFile file = this.getDescription();
    17. log.info("[" + file.getName() + "] version " + file.getVersion() + " Disabled!");
    18.  
    19. }
    20.  
    21. @Override
    22. public void onEnable() {
    23. getServer().getPluginManager().registerEvent(Event.Type.ENTITY_DEATH, new DeathListener(), Event.Priority.Low, this);
    24. PluginDescriptionFile file = this.getDescription();
    25. log.info("[" + file.getName() + "] version " + file.getVersion() + " Enabled!");
    26.  
    27. }
    28.  
    29. public class DeathListener extends EntityListener {
    30. public void onDeath(EntityDeathEvent exp) {
    31. exp.setDroppedExp(0);
    32. }
    33.  
    34. }
    35.  
    36. }


    And plugin.yml
    Code:
    author: unlucky4ever
    description: Makes mobs not drop any EXP on death.
    name: RemoveEXP
    version: 0.1
    main: com.unlucky4ever.exp.RemoveEXP
     
  18. Offline

    Orcem12

    Has anyone else noticed this the plugins being made here are actually being submitted?

    Just saying ... :p
     
  19. Offline

    user_43347

    @Unlucky4ever
    Now in less lines! :p
    Code:
    package com.unlucky4ever.exp;
    import java.util.logging.Logger;
    import org.bukkit.event.Event;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.entity.EntityListener;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    public class NoEXP extends JavaPlugin {
        Logger log = Logger.getLogger("Minecraft");
        public void onDisable() { }
        public void onEnable() {
            getServer().getPluginManager().registerEvent(Event.Type.ENTITY_DEATH, new DeathListener(), Event.Priority.Low, this);
            PluginDescriptionFile file = this.getDescription();
            log.info("[" + file.getName() + "] version "  + file.getVersion() + " Enabled!");
        }
        public class DeathListener extends EntityListener {
            public void onDeath(EntityDeathEvent exp) {
                exp.setDroppedExp(0);
            }
        }
    }
     
  20. Offline

    Fishrock123

    You mean, by us (The Authors), or by other people?
     
  21. Offline

    Unlucky4ever

    @steaks4uce
    Haha, I could have done that too, but I like my code a bit more spaced out so I can read it better.

    I did manage to take out some un-needed white space tho, clearning up 2 more lines :p
     
  22. Offline

    Orcem12

  23. Offline

    Zaros

    I lol'd at the thought of this.

    Still waiting for some one to have an everything plugin that consists of '*'.
     
    thehutch likes this.
  24. Offline

    md_5

    I think we established not to do that :)
     
    thehutch likes this.
  25. Offline

    thehutch

    The first ever 10 line spout plugin ever (I think :D )
    This plugin basically sends an Spout MOTD (notification) to the player o joining whilst using spout :D
    Code:
    import org.*
    public class TSNPlugin extends JavaPlugin {
        public onEnable(){
        getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, new SpoutListener() {
                public void onSpoutCraftEnable(SpoutCraftEnableEvent ev) {
                    ev.getPlayer().sendNotification("Welcome to " ev.getPlayer().getWorld().getName() , "enjoy your stay" , Material.MAP);
                }
        },Event.Priority.Normal, this);}
        public onDisable(){}
    }
     
  26. Offline

    Perdog

    Just came up with some thing interesting after our server experienced some "Hackers" that were rejoining once we banned them.

    Players with the permission type /banip [Player] and the plugin will get the players IP for them, then ban it. That way the server owner doesn't need to look up the players IP.

    Code:java
    1. package me.Perdog.BanIP;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class BanIP extends JavaPlugin {
    12. Logger log = Logger.getLogger("Minecraft");
    13. public String name;
    14. public Player banning;
    15. public void onEnable() {
    16. this.name = this.getDescription().getFullName();
    17. this.log.info(name + " has been enabled");
    18. }
    19. public void onDisable() {
    20. this.log.info(name + " has been disabled");
    21. }
    22. public boolean onCommand (CommandSender sender, Command cmd, String label, String[] split) {
    23. Player player = null;
    24. if (sender instanceof Player) {
    25. player = (Player) sender;
    26. }
    27. if (cmd.getName().equalsIgnoreCase("banip") && player.hasPermission("ban.IP")) {
    28. this.banning = this.getServer().getPlayerExact(split[0]);
    29. String IP = String.valueOf(banning.getAddress());
    30. this.getServer().banIP(IP);
    31. banning.kickPlayer("Your IP has been banned by " + player.getName() + ". Please contact the server administrator to have this ban removed.");
    32. return true;
    33. }
    34. else {
    35. player.sendMessage(ChatColor.RED + "You are not permitted to use this command!");
    36. }
    37. return false;
    38. }
    39. }

    Don't know if anyone has actually made a plugin like this before but it was something I custom coded for a server and saw that it fit the criteria of this challenge :)
     
  27. Offline

    md_5

    @Perdog Essentials does it afaik
     
  28. Offline

    Perdog

    Damn essentials ... taking all the good ideas lol
     
  29. Offline

    zhuowei

    I'm pretty sure that import org.* doesn't work. I would love to be proved wrong, though. (Less typing for me if that works!)
     
  30. Offline

    zhuowei

    SpawnBabyMobs: A SpawnMob plugin with the added feature that all animals (cows, sheep, pigs, mooshrooms, and wolves) are spawned as baby animals. (Monsters spawn normally.)
    Code:java
    1. package net.zhuoweizhang.spawnbabymob;
    2.  
    3. import org.bukkit.*;
    4. import org.bukkit.block.*;
    5. import org.bukkit.command.*;
    6. import org.bukkit.entity.*;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class SpawnBabyMobPlugin extends JavaPlugin {
    10. public void onDisable() {}
    11. public void onEnable() {}
    12. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    13. if (!(args.length == 1 || args.length == 2) || !(sender instanceof Player)) {
    14. return false;
    15. }
    16. CreatureType type = null;
    17. for (CreatureType t: CreatureType.values()) {
    18. if (t.getName().equalsIgnoreCase(args[0])) {
    19. type = t;
    20. break;
    21. }
    22. }
    23. if (type == null) {
    24. sender.sendMessage("Mob type " + args[0] + " not found.");
    25. return false;
    26. }
    27. int amount = 1;
    28. if (args.length == 2) {
    29. try {
    30. amount = Integer.parseInt(args[1]);
    31. }
    32. catch(Exception e) {}
    33. }
    34. Player player = (Player) sender;
    35. Block block = player.getTargetBlock(null, 32);
    36. Location loc = player.getLocation();
    37. if (block != null)
    38. loc = block.getLocation();
    39. for (int i = 0; i < amount; i++) {
    40. LivingEntity e = player.getWorld().spawnCreature(loc, type);
    41. if (e instanceof Animals)
    42. ((Animals) e).setAge(-24000);
    43. }
    44. return true;
    45. }
    46. }

    plugin.yml:
    Show Spoiler
    Code:
    author: zhuowei
    database: false
    description: Spawns baby versions of mobs
    main: net.zhuoweizhang.spawnbabymob.SpawnBabyMobPlugin
    name: SpawnBabyMob
    startup: postworld
    version: '1.0'
    commands:
        spawnbabymob:
            description: Spawns baby mobs
            usage: /<command> <CreatureType> [amount]
            permission: spawnbabymob.use
    permissions:
        spawnbabymob.use:
            description: Allows a player to spawn a baby mob
            default: op
     
    SOCIALISTICmeow likes this.
Thread Status:
Not open for further replies.

Share This Page