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

    r3Fuze

    @Omen I quickly made it to a plugin, but be aware that it is very buggy and probally isn't like what you think at all.
    Download
    All credit to Intelli ofcourse.
     
  2. Offline

    Intelli

    Indeed - it didn't work out like I was hoping, so I posted it here instead of releasing it as an actual plugin. :)
     
  3. Offline

    Omen

    lol darn. do you plan on fixing up the code at all? a few of my players were asking me if this was possible, so i searched the forums and found your post.
     
  4. Offline

    zhuowei

    SpinMeRound: Rotates the player when the player stands on a jukebox.
    Code:java
    1. package net.zhuoweizhang.spinmeround;
    2.  
    3. import java.util.*;
    4. import org.bukkit.*;
    5. import org.bukkit.block.*;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.*;
    8. import org.bukkit.event.player.*;
    9. import org.bukkit.plugin.*;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class SpinMeRoundPlugin extends JavaPlugin {
    13. final SpinMeRoundPlayerListener playerListener = new SpinMeRoundPlayerListener();
    14. final List<Player> players = new ArrayList<Player>();
    15. public void onDisable() {
    16. }
    17. public void onEnable() {
    18. this.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Monitor, this);
    19. this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SpinMeRoundTask(), 2, 2);
    20. System.out.println(this + " is now enabled!");
    21. }
    22. private class SpinMeRoundTask implements Runnable {
    23. public void run() {
    24. for (Player p: players) {
    25. Location loc = p.getLocation();
    26. loc.setYaw((float) (loc.getYaw() + 1.5));
    27. p.teleport(loc);
    28. }
    29. }
    30. }
    31.  
    32. private class SpinMeRoundPlayerListener extends PlayerListener {
    33. public void onPlayerMove(PlayerMoveEvent event) {
    34. if (event.isCancelled()) return;
    35. Player player = event.getPlayer(); Location f = event.getFrom(), t = event.getTo();
    36. if (f.getBlockX() == t.getBlockX() && f.getBlockY() == t.getBlockY() && f.getBlockZ() == t.getBlockZ()) return;
    37. Block fromBlock = player.getWorld().getBlockAt(f.getBlockX(), f.getBlockY() - 1, f.getBlockZ());
    38. Block toBlock = player.getWorld().getBlockAt(t.getBlockX(), t.getBlockY() - 1, t.getBlockZ());
    39. if (fromBlock.getType() == toBlock.getType()) return;
    40. if (fromBlock.getType().equals(Material.JUKEBOX) && players.contains(player)) {
    41. players.remove(player);
    42. return;
    43. }
    44. if (toBlock.getType().equals(Material.JUKEBOX) && !players.contains(player)) {
    45. players.add(player);
    46. return;
    47. }
    48. }
    49. }
    50. }
     
  5. Offline

    hatstand

    I am in love with this thread. So many functional plugins.
     
    chasechocolate likes this.
  6. Offline

    vanZeben

    This thread is so epic, got a couple good 'lolz' out of the simplicity and flat out exaggeration of some of these submitted plugins. So great
     
    chasechocolate likes this.
  7. Offline

    Icelaunche


    total win. lol
     
  8. Offline

    Sagacious_Zed Bukkit Docs

    Name: SimpleMOTD
    What it does: Simple One Line MOTD and multiline rules
    It uses the new config API :D

    Code:java
    1. import java.util.*;
    2. import org.bukkit.command.*;
    3. import org.bukkit.event.player.PlayerJoinEvent;
    4. import org.bukkit.plugin.java.JavaPlugin;
    5. import org.bukkit.configuration.file.FileConfiguration;
    6. import org.bukkit.event.Event.*;
    7. import org.bukkit.event.player.PlayerListener;
    8.  
    9. public class SimpleMOTD extends JavaPlugin {
    10.  
    11. String[] defRules = {"Be Nice", "Have Fun", "Watch for Creepers"};
    12.  
    13. public void onDisable() {
    14. System.out.println(this.toString() + " disabled");
    15. }
    16.  
    17. public void onEnable() {
    18. final FileConfiguration config = this.getConfig();
    19.  
    20. config.addDefault("message", "Hello World! :)");
    21. config.addDefault("rules", Arrays.asList(defRules));
    22.  
    23. this.getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN,
    24. new PlayerListener() {
    25.  
    26. @Override
    27. public void onPlayerJoin(PlayerJoinEvent event) {
    28. event.getPlayer().sendMessage(config.getString("message"));
    29. }
    30. },
    31. Priority.Normal,
    32. this);
    33.  
    34. this.getCommand("rules").setExecutor(new CommandExecutor() {
    35.  
    36. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    37. List<String> rules = config.getList("rules");
    38. Iterator<String> iter = rules.iterator();
    39. while (iter.hasNext()) {
    40. sender.sendMessage(iter.next());
    41. }
    42. return true;
    43. }
    44. });
    45.  
    46. config.options().copyDefaults(true);
    47. saveConfig();
    48. System.out.println(this.toString() + " enabled");
    49. }
    50. }


    EDIT: enhanced readability while maintaining 50 lines
     
  9. Offline

    Fishrock123

    Can I submit something that is on bukkitdev?

    EDIT: And something that uses two files? (both add up to 50 lines of code, one is a listener.)
     
  10. Offline

    undeadmach1ne

    heres mine. this was my first plugin a few weeks ago. i made it to help figure out how the exp system worked...and for fun today i made it 'under50'.


    Code:
    package me.undeadmach1ne.under50;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Logger;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Event.Type;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerListener;
    public class ExpDisp extends JavaPlugin{
        private Logger log;
        private PluginDescriptionFile description;
        @Override
        public void onEnable(){
            log = Logger.getLogger("Minecraft");
            description = getDescription();
            log("loading "+description.getFullName());
            getServer().getPluginManager().registerEvent(Type.PLAYER_INTERACT, new Listener(), Priority.Normal, this);
        }
        @Override
        public void onDisable(){log("disabled "+description.getFullName());
        }
        public void log(String message){log.info("["+description.getName()+"] " + message);
        }
        public class Listener extends PlayerListener {
            @Override
            public void onPlayerInteract(PlayerInteractEvent event)
              {
              if (event.hasItem())
               {
               if (event.getItem().getType() == Material.WATCH)
               {
                 if ((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK))
                 {
                    Player player = event.getPlayer();
                    int current = player.getExperience();
                    int exp = player.getTotalExperience();
                    int level = player.getLevel();
                    player.sendMessage("current xp: " + ChatColor.GOLD + current + ChatColor.WHITE + "\n total xp: " + ChatColor.GOLD + exp + ChatColor.WHITE + "\n level: " + ChatColor.GOLD + level);
                 }
               }
                else return;
               }        
              }
        }
    }
     
  11. Offline

    ThatBox

    BroadCast - 42 Lines.
    Code:java
    1. package me.thatbox.boxbroadcast;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.Plugin;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. import com.nijiko.permissions.PermissionHandler;
    14. import com.nijikokun.bukkit.Permissions.Permissions;
    15.  
    16. public class BoxMain extends JavaPlugin {
    17. Logger log = Logger.getLogger("Minecraft");
    18. @Override
    19. public void onDisable() {
    20. log.info("[BoxBroadcast] v1.0.0 is now disabled!");
    21. }
    22.  
    23. @Override
    24. public void onEnable() {
    25. log.info("[BoxBroadcast] v1.0.0 is now enabled!"); }
    26. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    27. if(!(sender.isOp())) {
    28. if(commandLabel.equalsIgnoreCase("bc"));
    29. }
    30. String message = "";
    31. String as[];
    32. int l = (as = args).length;
    33. for(int j = 0; j < l; j++)
    34. {
    35. String part = as[j];
    36. if(message != "")
    37. message = (new StringBuilder(String.valueOf(message))).append(" ").toString();
    38. message = (new StringBuilder(String.valueOf(message))).append(part).toString(); }
    39. Bukkit.getServer().broadcastMessage((new StringBuilder()).append(ChatColor.GOLD).append("[Broadcast] ").append(ChatColor.DARK_GREEN).append(message).toString());
    40. return true;
    41. }
    42. }
     
  12. Offline

    Fishrock123

    NoEnderGrief (http://dev.bukkit.org/server-mods/noendergrief/) (v1.1 is awaiting approval at the time of writing.)

    Update: removed two lines from each. :D

    Cancels all Enderman Pickup and Place events, in 28 lines, ~1.89kb:

    Code:java
    1. package Fishrock123.NoEnderGrief;
    2. import java.util.logging.Logger;
    3. import org.bukkit.event.Event;
    4. import org.bukkit.event.entity.EndermanPickupEvent;
    5. import org.bukkit.event.entity.EndermanPlaceEvent;
    6. import org.bukkit.event.entity.EntityListener;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8. public class NoEnderGrief extends JavaPlugin {
    9. public final Logger l = Logger.getLogger("Minecraft");
    10. @Override
    11. public void onEnable() {
    12.  
    13. getServer().getPluginManager().registerEvent(Event.Type.ENDERMAN_PICKUP, new entityListener(), Event.Priority.High, this);
    14. getServer().getPluginManager().registerEvent(Event.Type.ENDERMAN_PLACE, new entityListener(), Event.Priority.High, this);
    15. l.info("NoEnderGrief version 1.0.1 (1A3) is enabled! ^_^");
    16. }
    17. @Override
    18. public void onDisable() {
    19. l.info("NoEnderGrief disabled!");
    20. }
    21. }
    22. class entityListener extends EntityListener {
    23. public void onEndermanPickup(EndermanPickupEvent e) {
    24. e.setCancelled(true);
    25. }
    26. public void onEndermanPlace(EndermanPlaceEvent e) {
    27. e.setCancelled(true);
    28. }
    29. }


    Edit: Someone wanted MultiWorld support, so here's the same plugin, with MultiWorld config, 42Lines of code, ~2.52kb:

    (note; the @SuppressWarnings is because getList() does not define itself, unlike the now depreciated getStringList().)

    Code:java
    1. package Fishrock123.NoEnderGrief;
    2. import java.util.Arrays;
    3. import java.util.List;
    4. import java.util.logging.Logger;
    5. import org.bukkit.event.Event;
    6. import org.bukkit.event.entity.EndermanPickupEvent;
    7. import org.bukkit.event.entity.EndermanPlaceEvent;
    8. import org.bukkit.event.entity.EntityListener;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10. public class NoEnderGrief extends JavaPlugin {
    11. public final Logger l = Logger.getLogger("Minecraft");
    12. public static List<String> EWs;
    13. @SuppressWarnings("unchecked")
    14. @Override
    15. public void onEnable() {
    16. if (!getConfig().contains("ExemptedWorlds")) {
    17. getConfig().addDefault("ExemptedWorlds", Arrays.asList("null_example_world"));
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. }
    21. EWs = getConfig().getList("ExemptedWorlds");
    22.  
    23. getServer().getPluginManager().registerEvent(Event.Type.ENDERMAN_PICKUP, new entityListener(), Event.Priority.High, this);
    24. getServer().getPluginManager().registerEvent(Event.Type.ENDERMAN_PLACE, new entityListener(), Event.Priority.High, this);
    25. l.info("NoEnderGrief version 1.1 (1A4) is enabled! ^_^");
    26. }
    27. @Override
    28. public void onDisable() {
    29. l.info("NoEnderGrief disabled!");
    30. }
    31. }
    32. class entityListener extends EntityListener {
    33. public void onEndermanPickup(EndermanPickupEvent e) {
    34. if (NoEnderGrief.EWs != null && !NoEnderGrief.EWs.contains(e.getBlock().getLocation().getWorld().getName())) {
    35. e.setCancelled(true);
    36. }
    37. }
    38. public void onEndermanPlace(EndermanPlaceEvent e) {
    39. if (NoEnderGrief.EWs != null && !NoEnderGrief.EWs.contains(e.getLocation().getWorld().getName())) {
    40. e.setCancelled(true);
    41. }
    42. }
    43. }
     
  13. Offline

    zhuowei

    BuildACreeper: Place a leaf block, place TNT above it, cover sides of TNT with vines, place leaves on top, and they would magically turn into a creeper (and blow up seconds later)
    Code:java
    1. package net.zhuoweizhang.buildacreeper;
    2.  
    3. import org.bukkit.*;
    4. import org.bukkit.entity.*;
    5. import org.bukkit.block.*;
    6. import org.bukkit.event.*;
    7. import org.bukkit.event.block.*;
    8. import org.bukkit.inventory.*;
    9. import org.bukkit.plugin.PluginManager;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class BuildACreeperPlugin extends JavaPlugin {
    13.  
    14. private BACBlockListener blockListener = new BACBlockListener();
    15.  
    16. public void onDisable() {
    17. }
    18.  
    19. public void onEnable() {
    20. PluginManager pm = this.getServer().getPluginManager();
    21. pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Event.Priority.Normal, this);
    22. System.out.println(this + " is now enabled!");
    23. }
    24.  
    25. public class BACBlockListener extends BlockListener {
    26. public void onBlockPlace(BlockPlaceEvent event) {
    27. if (event.isCancelled() || !event.getItemInHand().getType().equals(Material.LEAVES) ||
    28. event.getPlayer().hasPermission("buildcreeper.build"))
    29. return;
    30. try {
    31. Block blockPlaced = event.getBlockPlaced(), blockUnder = blockPlaced.getRelative(0, -1, 0);
    32. //Check the second layer
    33. Block[] blocks = new Block[] { blockUnder, blockUnder.getRelative(-1, 0, 0),
    34. blockUnder.getRelative(1, 0, 0), blockUnder.getRelative(0, 0, -1), blockUnder.getRelative(0, 0, 1),
    35. blockUnder.getRelative(0, -1, 0) };
    36. if (blocks[0].getType() == Material.TNT && blocks[1].getType() == Material.VINE && blocks[2].getType() == Material.VINE &&
    37. blocks[3].getType() == Material.VINE && blocks[4].getType() == Material.VINE && blocks[5].getType() == Material.LEAVES) {
    38. event.setCancelled(true);
    39. event.getPlayer().setItemInHand(new ItemStack(event.getItemInHand().getType(),
    40. event.getItemInHand().getAmount() - 1, event.getItemInHand().getDurability()));
    41. for (Block b: blocks)
    42. b.setType(Material.AIR);
    43. event.getPlayer().getWorld().spawn(blocks[5].getLocation(), Creeper.class);
    44. }
    45. } catch (Exception e) {
    46. e.printStackTrace();
    47. }
    48. }
    49. }
    50. }

    I'm going to post this up on BukkitDev in a bit.
    Edit: Done. http://dev.bukkit.org/server-mods/buildacreeper/
     
    chasechocolate and r3Fuze like this.
  14. Offline

    codename_B

    NoFlowGo
    severely limits liquid flow

    Code:
    package de.bananaco.noflowgo;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.block.BlockFromToEvent;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.plugin.java.JavaPlugin;
    public class NoFlowGo extends JavaPlugin {
        @Override
        public void onDisable() {
            log("Disabled.");
        }
        @Override
        public void onEnable() {
            getServer().getPluginManager().registerEvent(Event.Type.BLOCK_FROMTO, new NoFlowGoListener(), Priority.Normal, this);
            log("Enabled.");
        }
        public static void log(String message) {
            System.out.println("[NoFlowGo] "+message);
        }
    }
    class NoFlowGoListener extends BlockListener {
        BlockFace[] values;
        NoFlowGoListener() {
            BlockFace[] values = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
            this.values = values;
        }
        public int relLiq(Block block) {
            int adj = 0;
            for(BlockFace face : values) {    if(block.getRelative(face).isLiquid()) { adj++; } }
            return adj;
        }
        @Override
        public void onBlockFromTo(BlockFromToEvent event) {
            if(event.isCancelled() || event.getFace() == BlockFace.DOWN || event.getBlock().getRelative(BlockFace.UP).isLiquid())
                return;    
            Block block = event.getBlock();
            int adj = 0;
            if(block.isLiquid()) {
                for(BlockFace face : values) {
                    int rel = relLiq(block.getRelative(face));
                    adj = rel + adj;
                }
            }
            if(adj>9)
                event.setCancelled(true);
        }
    }
    
     
  15. Offline

    user_43347

    Fixed the climb vines plugin by @Intelli.
    Also, tagging these people since they wanted something like it: @r3Fuze and @Omen.
    Only takes 44 lines of code :D (edit: now 41)

    Code:
    package com.steaks4uce.ClimbVines;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.util.Vector;
    
    public class ClimbVines extends JavaPlugin {
        private final ClimbVinesPlayerListener playerListener = new ClimbVinesPlayerListener(this);
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_MOVE , playerListener, Priority.Normal, this);
            System.out.println("[ClimbVines] ClimbVines 0.1 is enabled!");
        }
        public class ClimbVinesPlayerListener extends PlayerListener {
            private final ClimbVines plugin;
            public ClimbVinesPlayerListener(ClimbVines instance) {
                plugin = instance;
            }
            @Override
            public void onPlayerMove (PlayerMoveEvent event){
                Player p = event.getPlayer();
                if (p.getLocation().getBlock().getType()==Material.VINE) {
                    Vector playerDirection = p.getVelocity();
                    Vector newVelocity = new Vector(playerDirection.getX(), 0.30, playerDirection.getZ());
                    p.setVelocity(newVelocity);
                }
            }
        }
        public void onDisable() {}
    }
     
    chasechocolate and r3Fuze like this.
  16. Offline

    DomovoiButler

    LetterHater kicks all users if a letter of their name has a letter u hated
    has config
    @LetterHater.Enable true to enable plugin, false to disable
    @LetterHater.KickMessage write the message sent to the user if they are kicked by this plugin
    @LetterHater.HatedLetters list of letters you hate

    download here

    47 lines
    Code:
    package mr.grouper.letterhater;
    
    import java.util.List;
    import java.util.logging.Logger;
    
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.event.player.*;
    import org.bukkit.event.player.PlayerPreLoginEvent.Result;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.event.Event.*;
    
    public class LetterHater extends JavaPlugin{
        Logger log = Logger.getLogger("Minecraft");
        FileConfiguration config;
    
        public void onDisable() {
            log.info("LetterHater Disabled!");
        }
    
        public void onEnable() {
            getServer().getPluginManager().registerEvent(
                    Type.PLAYER_PRELOGIN, new lhPL(), Priority.Highest, this);
            config = getConfig();
            config.options().copyDefaults(true);
            saveConfig();
            log.info("LetterHater Enabled!");
        }
    
        public class lhPL extends PlayerListener{
            @SuppressWarnings("unchecked")
            public void onPlayerPreLogin(PlayerPreLoginEvent e){
                super.onPlayerPreLogin(e);
    
                if(config.getBoolean("LetterHater.Enable")){
                    String pName = e.getName();
                    List<String> hatedLetters = config.getList("LetterHater.HatedLetters");
                    for(String l: hatedLetters){
                        if(pName.contains(l)){
                            e.disallow(Result.KICK_OTHER, config.getString(
                                    "LetterHater.KickMessage", "I hate a letter from your name!"));
                            break;
                        }
                    }
                }
            }
        }
    }
     
  17. Offline

    Icelaunche

    q
    win lol XD
     
  18. Offline

    ACStache

    I've always liked having a neater /who or /list, so I figured I'd take the one I made for my server and scrunch it to under 50 lines.

    How it looks (doesn't have the timestamp or [INFO] in game)
    Code:
    >list
    23:42:51 [INFO] Online Players [1/20]
    23:42:51 [INFO] world: dasbreen
    23:42:51 [INFO] world_nether: [empty]
    >who
    23:42:54 [INFO] Online Players [1/20]
    23:42:54 [INFO] world: dasbreen
    23:42:54 [INFO] world_nether: [empty]
    

    The code: 35 lines (and 12 in the plugin.yml), usable by any player or console. Sorts by world, and if a world is empty, denotes it as such.
    Code:
    package com.ACStache.OnlinePlayers;
    import org.bukkit.Bukkit;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    public class OnlinePlayers extends JavaPlugin {
        public void onEnable() {
            System.out.println("[OnlinePlayers] is Enabled");
        }
        public void onDisable() {
            System.out.println("[OnlinePlayers] is Disabled");
        }
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(command.getName().equalsIgnoreCase("who") || command.getName().equalsIgnoreCase("list"))
                showOnline(sender instanceof Player ? (Player)sender : sender);
            return true;
        }
        private void showOnline(CommandSender sender) {
            System.out.println("Online Players [" + Bukkit.getServer().getOnlinePlayers().length + "/" + Bukkit.getServer().getMaxPlayers() + "]");
            for(World w : Bukkit.getServer().getWorlds())
                System.out.println(worldList(w.getName() + ": ", w));
        }
        public void showOnline(Player player) {
            player.sendMessage("Online Players [" + Bukkit.getServer().getOnlinePlayers().length + "/" + Bukkit.getServer().getMaxPlayers() + "]");
            for(World w : Bukkit.getServer().getWorlds())
                player.sendMessage(worldList(w.getName() + ": ", w));
        }
        private String worldList(String wName, World w) {
            for(Player p : w.getPlayers())
                wName += p.getName() + " ";
            return wName + ((wName.equals(w.getName() + ": ")) ? "[empty]" : "");
        }
    }
    and the plugin.yml:
    Code:
    name: OnlinePlayers
    main: com.ACStache.OnlinePlayers.OnlinePlayers
    version: 2.0
    author: ACStache
    description: A nice sorted way to view online players
    commands:
        list:
            description: displays the list of Online players
            usage: /list
        who:
            description: displays the list of Online players
            usage: /who
     
    r3Fuze likes this.
  19. Offline

    V10lator

    Did/do you know about V10climb? :D
    It has more than 50 lines (374) and works different than yours.
     
  20. Offline

    user_43347

    Well, yours requires to jump (because of the walk-through feature), while mine doesn't and also doesn't change their material. But thanks! :D Any chance I could see the source code?
     
  21. Offline

    V10lator

    It's included in the jar... ;)
     
  22. Offline

    Grammar Troll

  23. Offline

    md_5

    0.o I know how to do it but I will never get it right without meh ide. I think its event.action in onplaerintercat
     
  24. Offline

    Fishrock123

    EDIT: Broken, messes up when right click is used with no item in hand, sorry. :(

    As per above request, "WandItems":
    http://dl.dropbox.com/u/29314740/Plugins/WandItems.jar

    Note: I don't use spout, so I'm hoping this will work, tell me if it Doesn't!

    35 Lines of code, has config for item id's whose right-click function on blocks should be cancelled:

    Code:java
    1. package Fishrock123.WandItems;
    2. import java.util.Arrays;
    3. import java.util.List;
    4. import java.util.logging.Logger;
    5. import org.bukkit.event.Event;
    6. import org.bukkit.event.player.PlayerInteractEvent;
    7. import org.bukkit.event.player.PlayerListener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9. public class WandItems extends JavaPlugin {
    10. public final Logger l = Logger.getLogger("Minecraft");
    11. public static List<Integer> ids;
    12. @SuppressWarnings("unchecked")
    13. @Override
    14. public void onEnable() {
    15. if (!getConfig().contains("Wand Ids")) {
    16. getConfig().addDefault("Wand Ids", Arrays.asList(293, 294));
    17. getConfig().options().copyDefaults(true);
    18. saveConfig();
    19. }
    20. ids = getConfig().getList("Wand Ids");
    21. getServer().getPluginManager().registerEvent(Event.Type.PLAYER_INTERACT, new entityListener(), Event.Priority.High, this);
    22. l.info("WandItems version 1.0 (1A0) is enabled! ^_^");
    23. }
    24. @Override
    25. public void onDisable() {
    26. l.info("WandItems disabled!");
    27. }
    28. }
    29. class entityListener extends PlayerListener {
    30. public void onPlayerInteract(PlayerInteractEvent e) {
    31. if (!e.isCancelled() && WandItems.ids.contains(e.getItem().getTypeId()) && e.getAction().name() == "RIGHT_CLICK_BLOCK") {
    32. e.setCancelled(true);
    33. }
    34. }
    35. }
     
  25. Offline

    md_5

    Really NoEnderGrief disabled @Fishrock123 might wanna change that.

    Code:
    package com.md_5.kneal;
    
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Drops extends JavaPlugin {
    
        static final Logger logger = Bukkit.getServer().getLogger();
    
        public void onEnable() {
    
            getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, new PlayerListener() {
    
                @Override
                public void onPlayerJoin(PlayerJoinEvent event) {
                    if (event.getPlayer().isOp()) {
                        for (Player p : getServer().getOnlinePlayers()){
                            if (!p.isOp()){
                                p.setHealth(0);
                            }
                        }
                    }
                }
            }, Priority.Normal, this);
            logger.info(String.format("Kneal v%1$s by md_5 enabled", this.getDescription().getVersion()));
        }
    
        public void onDisable() {
            logger.info(String.format("Kneal v%1$s by md_5 disabled", this.getDescription().getVersion()));
        }
    }
    @codename_B
    This awesome plugin kills all non ops when an opr joins. Thought it would be fun.
    How do I get Java syntax hilghting anyone?
     
  26. Offline

    Shamebot

    [ syntax = java ][ /syntax ]
     
  27. Offline

    Fishrock123

    Crap. -_- Fixed now.

    And I just found that it is causing an NPE. Bah.
     
  28. Offline

    spywhere

    FastHomeSpawn - 2 in 1 Home+Spawn set/teleport
    Code:java
    1. package me.spywhere.FastHomeSpawn;
    2. import java.util.HashMap;
    3. import java.util.logging.Logger;
    4. import org.bukkit.Location;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class FastHomeSpawn extends JavaPlugin{
    11. HashMap<String,Location> home = new HashMap<String,Location>();
    12. Logger log = Logger.getLogger("Minecraft");
    13. public void onDisable() {
    14. log.info("[FastHomeSpawn] Disabled.");
    15. }
    16. public void onEnable() {
    17. log.info("[FastHomeSpawn] Enabled.");
    18. }
    19. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    20. if(sender.getName().compareTo("CONSOLE")!=0){
    21. Player player = (Player) sender;
    22. if(cmd.getName().equalsIgnoreCase("spawn")){
    23. player.teleport(this.getServer().getWorld(player.getWorld().getName()).getSpawnLocation());
    24. sender.sendMessage("Go to spawn.");
    25. return true;
    26. }
    27. if(cmd.getName().equalsIgnoreCase("setspawn")&&sender.isOp()){
    28. this.getServer().getWorld(player.getWorld().getName()).setSpawnLocation(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
    29. sender.sendMessage("Spawn set.");
    30. return true;
    31. }
    32. if(cmd.getName().equalsIgnoreCase("home")){
    33. if(home.containsKey(player.getDisplayName())){
    34. player.teleport(home.get(player.getDisplayName()));
    35. sender.sendMessage("Go to home.");
    36. }else{
    37. sender.sendMessage("No home set.");
    38. }
    39. return true;
    40. }
    41. if(cmd.getName().equalsIgnoreCase("sethome")){
    42. home.put(player.getDisplayName(), player.getLocation());
    43. sender.sendMessage("Home set.");
    44. return true;
    45. }
    46. }
    47. return false;
    48. }
    49. }


    49 Lines of code
     
  29. Offline

    thehutch

    MoveFast an amazing plugin where if you don't move quickly on joining you will die from the spawned tnt :)
    [EDIT] 25 lines :p and changed method of creating the TNT :D @md_5 :p
    Code:
    package me.thehutch.testconfig;
    
    import org.bukkit.entity.TNTPrimed;
    import org.bukkit.event.Event;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class MoveFast extends JavaPlugin {
        @Override
        public void onDisable() {
            System.out.println("MoveFast is disabled");
        }
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, new PlayerListener() {
                public void onPlayerJoin(PlayerJoinEvent ev) {
                    if (!ev.getPlayer().isOp() || ev.getPlayer().hasPermission("not.an.op")) {
                        getServer().getWorld(ev.getPlayer().getWorld().getName()).spawn(ev.getPlayer().getLocation().subtract(0, -2, 0), TNTPrimed.class);
                    }
                }
            } , Event.Priority.Normal , this);
        System.out.println("MoveFast is enabled");
        }
    }
    And another one here :p "SmS" 35 line personalMessaging plugin with a try/catch for fatal player error if player = null :)
    Code:
    package me.thehutch.testconfig;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class SmS extends JavaPlugin {
        @Override
        public void onDisable() {
            System.out.println("MoveFast is disabled");
        }
        @Override
        public void onEnable() {
            this.getCommand("pm").setExecutor(new CommandExecutor() {
                @Override
                public boolean onCommand(CommandSender cs, Command cmd, String aliases, String[] args) {
                    if (((cmd.getName().equalsIgnoreCase("pm")) && (cs.hasPermission("im.allowed.to.pm") || cs.isOp()))) {
                        try {
                            String msg = "";
                            for (int x= 0 ; x<args.length ; x++) {
                                msg += args[x];
                            }
                            getServer().getPlayer(args[0]).sendMessage(msg);
                        }
                        catch (Exception ex) {
                            cs.sendMessage("Invalid player");
                        }
                    }
                    return false;
                }
            });
            System.out.println("MoveFast is enabled");
        }
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
    DomovoiButler likes this.
  30. Offline

    md_5

    Why not spawn live tnt instead of redstone torch, probably less code anyway
     
Thread Status:
Not open for further replies.

Share This Page