Solved force player to say somthing

Discussion in 'Plugin Development' started by fondelaar, Sep 29, 2012.

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

    fondelaar

    ok so this is what im trying to do:

    1. player places a block
    2. plugin checks block id
    3. if block id matches a certain id, wich i put in the code (not a variable in a config) it makes the player who placed the block say a message in chat.
    how do i do this?
     
  2. Offline

    Timr

    kroltan likes this.
  3. Offline

    jojohnson1

    Code:java
    1.  
    2. if (blockID = ID) {
    3.  
    4. Player player = e.getPlayer();
    5. player.chat("I just placed a block with the ID " + ID + "!");
    6.  
    7. }
    8.  
     
  4. Offline

    fondelaar

    ok im nearly done with the first version of my plugin. i just cant get the plugin.yml to work D:

    this is the error:

    Code:
    2012-09-30 11:01:19 [SEVERE] Could not load 'plugins\NN_beta_0.1.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:310)
        at forge.bukkit.ForgePluginManager.loadPlugin(ForgePluginManager.java:55)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:231)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:221)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:197)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:59)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:177)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NullPointerException
        at org.bukkit.plugin.PluginLogger.<init>(PluginLogger.java:22)
        at org.bukkit.plugin.java.JavaPlugin.getLogger(JavaPlugin.java:359)
        at com.gmail.fondelaar.NukeNotifier.main.<init>(main.java:17)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145)
        ... 9 more
    this is the plugin.yml:

    Code:
    name: NukeNotifier
    main: com.gmail.fondelaar.NukeNotifier.main
    version: 0.1
    #this plugin has been made by fondelaar, who is RadioHasNoFuture at the tekkit forums.
    
    and this is my code:

    Code:
    package com.gmail.fondelaar.NukeNotifier;
     
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin{
     
        public String PlayerInfo = "";
        public int BlockId;
        public int Playername;
       
        public boolean onEnable;{
     
            getLogger().info("I placed a nuke has been enabled!!");
        }
       
        public boolean onDisable;{
            getLogger().info("I placed a nuke has been disabled. Have a nice day!!");
        }
       
        public void PlayerInfo(BlockPlaceEvent event){
            Player player = event.getPlayer();
            Block block = event.getBlock();
            Material mat = block.getType();
           
            if (mat.equals("X237"))
                player.chat("i just placed a nuke!");
        }
           
    }
    
     
  5. Offline

    gamerzap

    Is the plugin.yml in <default package>, becuase it should be. That happened to me when I made my first plugin.

    Oh wait, never mind. It says your problem is a NullPointerException at line 17. Do getServer().getLogger() instead of getLogger()

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  6. Offline

    fondelaar

    well, thanks for the reply. but it didnt help.

    im still getting the same error...
     
  7. Offline

    gamerzap

    Is the plugin.yml in the correct place?
     
  8. Offline

    fondelaar

    yes it is. i solved it. i wrote the onEnabke and onDisable wrong
     
  9. Offline

    Deonasoto

    You wrote onEnable wrong again ;)
     
    fondelaar likes this.
  10. Offline

    fondelaar

    ;)

    but in the code i wrote onEnable;
    instead of onEnable()
     
  11. Offline

    Deonasoto

    Ohh, lol!
     
Thread Status:
Not open for further replies.

Share This Page