I made a plugin that should take 250 coins from the players iConomy account when placeing a minecart track, and add it to another account. The plugin gives some warnings in Eclipse about stuff not being read localy so it want to remove stuff, but other then that craftbukkit runs it, and it gets connected to iConnomy, but when I place a RAIL nothing happens, this is my BlockListener Code: package net.ourforums.andret.RAILTAX; import org.bukkit.block.Block; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPlaceEvent; import com.nijiko.coelho.iConomy.iConomy; import com.nijiko.coelho.iConomy.system.Account; public class RAILTAXBlockListener extends BlockListener { private final RAILTAX plugin; public RAILTAXBlockListener(final RAILTAX plugin) { this.plugin = plugin; } public void onBlockPlace(BlockPlaceEvent event) { //Get the player doing the placing Player player = event.getPlayer(); //Get the block that was placed Block block = event.getBlockPlaced(); if(block.getType() == Material.RAILS){ //Take 250 from players account Account account = iConomy.getBank().getAccount(player.getName()); int amount = 250; account.subtract(amount); account.save(); player.sendMessage("250 was taken from your account, and given to Nologium"); Account nologium = iConomy.getBank().getAccount("nation_Nologium"); int give = 250; nologium.add(give); nologium.save(); } } } If you need anything else, tell me, and thanks in advance
Did you make the Hook onEnable() ? Code: pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Monitor, this); This code is just an example, can be different in your case
This is my main class file: Code: package net.ourforums.andret.RAILTAX; import java.io.File; import java.util.HashMap; import org.bukkit.plugin.Plugin; import org.bukkit.entity.Player; import org.bukkit.Server; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.PluginManager; import com.nijiko.coelho.iConomy.iConomy; import org.bukkit.event.Listener; import org.bukkit.event.server.PluginEvent; import org.bukkit.event.server.ServerListener; public class RAILTAX extends JavaPlugin { private final RAILTAXPlayerListener playerListener = new RAILTAXPlayerListener(this); private final RAILTAXBlockListener blockListener = new RAILTAXBlockListener(this); private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>(); private static PluginListener PluginListener = null; private static iConomy iConomy = null; private static Server Server = null; @Override public void onDisable() { System.out.println("Nologium RailTax disabled"); } public void onEnable() { PluginManager pm = getServer().getPluginManager(); Server = getServer(); PluginListener = new PluginListener(); pm.registerEvent(Event.Type.PLUGIN_ENABLE, PluginListener, Event.Priority.Monitor, this); pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Event.Priority.Highest, this); PluginDescriptionFile pdfFile = this.getDescription(); System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); } public static Server getBukkitServer() { return Server; } public static iConomy getiConomy() { return iConomy; } public static boolean setiConomy(iConomy plugin) { if (iConomy == null) { iConomy = plugin; } else { return false; } return true; } } Wierd thing was if I use pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this); I get errors, but if I use pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Event.Priority.Highest, this); it flags out okay, I will try it nontheless Did not work Anyone have any ideas? --- merged: Mar 6, 2011 11:37 PM --- Problem solved, I had put BLOCK_BREAK instead of BLOCK_PLACED, Well, a noob soloution to a noob question Thanks to those viewing this thread anyway
I spotted another error in your first code: Code: block.getType() == Material.RAIL should be: Code: block.getType().equals(Material.RAIL) (I'm pretty sure)