Skip to content
Browse files

The plugin actually works now, so bumped to version 0.7 from 0.1 Turns

out I was not actually listening for events at all. Thanks to the folks
from #bukkitdev. This commit closes issue #1
  • Loading branch information...
1 parent 72b38cc commit ebdac83c489a4bb49d4910ff0db7aee30214ac0c @agargiulo committed May 11, 2012
Showing with 13 additions and 52 deletions.
  1. +3 −2 plugin.yml
  2. BIN respawn-item.jar
  3. +10 −50 src/com/agargiulo/code/bukkit/respawn_item/RespawnItem.java
View
5 plugin.yml
@@ -1,5 +1,6 @@
name: respawn-item
main: com.agargiulo.code.bukkit.respawn_item.RespawnItem
-version: 0.1
+version: 0.7
author: anthony@agargiulo.com
-website: https://github.com/agargiulo/respawn-item
+website: https://github.com/agargiulo/respawn-item
+description: Gives every player a single gold nugget when they respawn
View
BIN respawn-item.jar
Binary file not shown.
View
60 src/com/agargiulo/code/bukkit/respawn_item/RespawnItem.java
@@ -1,76 +1,36 @@
-/**
- * File: RespawnItem.java
- * Date created: May 10, 2012
- *
- */
package com.agargiulo.code.bukkit.respawn_item;
-import java.util.logging.Logger;
-
import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin;
/**
* @author Anthony Gargiulo (anthony@agargiulo.com)
*
*/
-public class RespawnItem extends JavaPlugin
+public class RespawnItem extends JavaPlugin implements Listener
{
- /**
- * @param args
- */
- public static void main(String[] args)
- {
- // TODO Auto-generated method stub
-
- }
-
- private Logger log;
-
- @Override
- public void onDisable()
- {
- log = getLogger();
- log.info("Your plugin has been disabled");
-
- }
-
@Override
public void onEnable()
{
- log = getLogger();
- log.info("Your plugin has been enabled.");
- }
-
- /**
- * @param event
- */
- public void onPlayerJoin(PlayerJoinEvent event)
- {
- log.info("Player " + event.getPlayer().getDisplayName()
- + " has joined the game");
+ getServer().getPluginManager().registerEvents(this, this);
}
/**
- * @param event
+ * Give every player that respawns a single gold nugget.
*
+ * @param event
*/
+ @EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event)
{
- Player player = event.getPlayer(); // The player who respawned
- PlayerInventory playerInv = player.getInventory(); // Their items
- ItemStack items = new ItemStack(Material.GOLD_NUGGET);
- playerInv.addItem(items);
- player.getInventory().setContents(playerInv.getContents());
- player.sendMessage("You just respawned, have some gold.");
- log.info("Player respawned");
+ event.getPlayer().getInventory()
+ .addItem(new ItemStack(Material.GOLD_NUGGET));
}
-}
+}

0 comments on commit ebdac83

Please sign in to comment.
Something went wrong with that request. Please try again.