Upating a plugin

Discussion in 'Plugin Development' started by emcitement, May 30, 2012.

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

    emcitement

  2. Offline

    hawkfalcon

    Want me to update it for you?
     
  3. Offline

    emcitement

    if you/ anyone else knows of any similar plugins, I could use those instead.
    I simply want an item that can be placed that functions as a permanent food restorer. (They give restaurants a purpose rather than just being there for looks)

    if it's not too much trouble I'd really appreciate you updating it though :D
     
  4. Offline

    hawkfalcon

    @emcitement
    How about I remake this completely? This is quite outdated. What should I call it?:D
    And how about I just make any cake infinite? Or any cake that is on top of a specific block? (What block?)
    Ill finish it by Monday:D Not too hard
     
  5. Offline

    Digi

    Here's a quick update on it:
    classes (open)

    Bake.java:
    Code:
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.*;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Bake extends JavaPlugin implements Listener
    {
    	@Override
    	public void onEnable()
    	{
    		getServer().getPluginManager().registerEvents(this, this);
    		getCommand("bake").setExecutor(new CommandBake());
    	}
    	
    	@EventHandler
    	public void playerInteract(final PlayerInteractEvent event)
    	{
    		if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
    		{
    			final Block block = event.getClickedBlock();
    			
    			if(block.getType() == Material.CAKE_BLOCK)
    			{
    				final Block below = block.getRelative(0, -1, 0);
    				
    				if(below.getType() == Material.WOOL && below.getData() == 3) // in the original plugin, it's 4 here instead, I dunno why...
    				{
    					final Player player = event.getPlayer();
    					
    					if(player.hasPermission("bakecake.use"))
    					{
    						if(block.getData() != 0)
    						{
    							block.setData((byte)0);
    							player.sendMessage("Nom...");
    						}
    					}
    					else
    					{
    						event.setCancelled(true);
    						player.sendMessage("Hey! That's not your cake!");
    					}
    				}
    			}
    		}
    	}
    }
    CommandBake.java:
    Code:
    import org.bukkit.*;
    import org.bukkit.block.Block;
    import org.bukkit.command.*;
    import org.bukkit.entity.Player;
    
    public class CommandBake implements CommandExecutor
    {
    	public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    	{
    		if(sender instanceof Player)
    		{
    			if(!sender.hasPermission("bakecake.create"))
    			{
    				sender.sendMessage(ChatColor.RED + "No permission to do that.");
    				return true;
    			}
    			
    			Block block = ((Player)sender).getTargetBlock(null, 10);
    			
    			if(block != null && block.getType() == Material.WOOL && block.getData() == 3)
    			{
    				Block above = block.getRelative(0, 1, 0);
    				
    				if(above.getType() == Material.AIR)
    				{
    					above.setType(Material.CAKE_BLOCK);
    					sender.sendMessage("The air fills with the smell of baking...");
    				}
    				else
    					sender.sendMessage("There must be room above the block to bake the cake!");
    			}
    			else
    				sender.sendMessage("You must aim at a light-blue wool block while using this command!");
    		}
    		else
    			sender.sendMessage("Only players can use this command!");
    		
    		return true;
    	}
    }

    The code is smaller because Bukkit API became better organized :}
     
  6. Offline

    Technius

    Oh, and you spell "Updating" wrong in the thread title.
     
  7. Offline

    hawkfalcon

    o.o That works too. I kinda want to make a InfiniteCake plugin though, may I use some of this code?
     
  8. Offline

    Digi

    hawkfalcon
    Sure, it's fairly easy tough, just remove the data == 0 condition in the event and set data to.. 4 I belive, you'll have to check the wiki for cake's data to force it always to be full.... or you could just cancel the event and heal the player manually, but that'll be tricky against other plugins.
     
  9. Offline

    hawkfalcon

    Well I wanna make it so when there is one slice left it goes back to full, so I'm only going to use part of this:D Thanks.
     
  10. Offline

    emcitement

    thanks a lot :D it's nice to see what you changed too.

    and speaking of that, I've noticed lots of other great changes to Bukkit since last year.. :]

    anyways, much appreciated

    LOL I seriously didn't even notice that.

    Haha, sure. :D
    I'm not sure on a decent name. Hmmm. What's all new to Minecraft? Can cakes only be placed on plain blocks or in other places too? It could maybe look okay on a furnace or a pressure plate + ladder.
    but I'm not sure if either of those can done, especially the latter.

    If you make one then it'd be nice to have your alternative to the abandoned ezbake xD
     
    hawkfalcon likes this.
  11. Offline

    Digi

    Hmm, it would've been better if it were on top of a furnace instead and it would slowly "grow" whenever the furnace is burning (even after it's completly gone)... this requires a task and research :p
     
  12. Offline

    hawkfalcon

    I am going to make it:D I'm still not sure what the cake would be on though ;/ xD yes furnace, no to the other two. Actually maybe not furnace ;o
    Digi
    That would be cool - maybe another plugin.
    Im looking at setSlicesRemaining and getSlicesRemaining
    :D
     
  13. Offline

    hawkfalcon

    Okay I made it!:D it's a very simplistic version, so when you eat the last slice it magically regenerates. :D dev.bukkit.org/server-mods/infinitecake/
     
  14. Offline

    emcitement

    nice. that's cool :D
    though I still will stick with the original one
     
Thread Status:
Not open for further replies.

Share This Page