Problem with Events

Discussion in 'Plugin Development' started by RightLegRed, Jan 16, 2011.

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


    I've got my plugin almost working. It gets loaded, but in game, nothing happens.

    Here's what I'm doing:

        public void onBlockPlace(BlockPlaceEvent event) {
            Player player = event.getPlayer();
            Block block = event.getBlock();

        public void onCommand(PlayerChatEvent event){
            Player players = event.getPlayer();
            String message = event.getMessage();
            players.sendMessage("Hello" + players.getName());

    in BlockListener and PlayerListener. In my I've done this to register the events:

    PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);

    Could anyone tell me why, when I place a block or say something, nothing happens?
  2. Offline


    I just started plugin writing today and ran into the same problem. I finally got it fixed by assuming that the javadocs were dead wrong and added a 'd' to the event in the listener. Use the following signature:
    public void onBlockPlaced(BlockPlaceEvent event);

    I'm not sure about onCommand, I haven't used it yet. BTW, if anyone sees an onSignChanged event, it'd be appreciated. Meantime, I guess I'll have to reverse engineer the class files or something. I hope its implemented.
  3. Offline


    They changed the names of the events to the present tense.

    onBlockPlaced -> onBlockPlace

    You may have an older version which still uses the old names.
  4. Offline


    public void onBlockPlace(BlockPlaceEvent event);
    is actually from BigBrother. So it should work.

    --- merged: Jan 16, 2011 5:32 PM ---
    Ah OK, thanks. I'm currently using the latest build.
    --- merged: Jan 16, 2011 5:53 PM ---
    Sorry about this guys. But it gives me this error now

    SEVERE: while scanning for the next token; found character      '\t' that cannot
     start any token (Is it up to date?)
    while scanning for the next token
    found character         '\t' that cannot start any token
     in "<reader>", line 3, column 7:
            at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.ja
            at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(
            at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(P
            at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(
            at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(
            at org.yaml.snakeyaml.composer.Composer.composeNode(
            at org.yaml.snakeyaml.composer.Composer.composeMappingNode(
            at org.yaml.snakeyaml.composer.Composer.composeNode(
            at org.yaml.snakeyaml.composer.Composer.composeDocument(
            at org.yaml.snakeyaml.composer.Composer.getSingleNode(
            at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
            at org.yaml.snakeyaml.Yaml.load(
            at org.yaml.snakeyaml.Yaml.load(
            at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(
            at net.minecraft.server.MinecraftServer.e(
            at net.minecraft.server.MinecraftServer.c(
            at net.minecraft.server.MinecraftServer.d(
  5. Offline


    I grabbed the jar on the site, but I guess I need to find a source repository or something. Thanks for the pointer to the sign block; I've seen that, however. Specifically, I'm trying to figure out what (if any) event is called when their is an edit of the sign's text. I'm hoping that I don't have to setup polling on another thread and do a custom event push or something silly like that. Sorry for the n00bishness, but new API, so still learning here.
  6. Offline


    @RightLegRed this error means that you used a tab character in your plugin.yml
    You should use spaces instead.
  7. Offline


    This was the problem, but I had accidentally backspaced the main: part of my .yml.

    Don't worry man, we're all learning. I don't think there are any text changed events at the moment though.

    I'm still experiencing nothing happening when placing a block.

    @redmasq, I think a way round there being no sign changer would be to see if there's something that happens every few ticks (e.g. time change or something) and use that along with "getText" to check the text against an array with the old text values in it.
Thread Status:
Not open for further replies.

Share This Page