Best way to learn Java.

Discussion in 'Plugin Development' started by calebbfmv, Jul 26, 2012.

?

What is the best way to learn programing?

  1. Videos, and reading?

    29.2%
  2. Diving and learning as you do it?

    58.3%
  3. Something else? Post it!

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

    Zachster

    It really depends on you. What is the best way you learn anything else? However, something such as Bukkit is good for started bigger projects, because a lot of code is prewritten. This gets all the annoying, boring stuff out of the way, plus it's open source so you can learn by example.
     
  2. Offline

    calebbfmv

    Code:
    package me.calebbfmv.StopAskingOp;
     
    import java.util.logging.Logger;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class StopOP extends JavaPlugin {
       
        private static final Logger log = Logger.getLogger("Minecraft");
       
        public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
            if(sender instanceof Player) {
            }
        @EventHandler
        public void onPlayerChat(PlayerChatEvent event;{
            Player p = (Player) sender;
           
            String m = event.getMessage();
            String mlow = m.toLowerCase();
       
            if (mlow.contains("Can I be OP?")){
                if(p.hasPermission("No.Op.exempt"));
                    p.sendMessage("You know better!");
                }
                }
           
        }
     
    }
    Thanks, I am putting that aside for now while I get on my first release!
    But again It is errored! Here is the code,
     
  3. Offline

    Jnorr44

    You cannot put an event inside a command, instead, try using the command to set a boolean to true, then do the event.
     
  4. Offline

    calebbfmv

    No no thats not quite what I want, I just removed the command, but Player p = (Player) sender; <--- Sender is wrong?
     
  5. Offline

    Jnorr44

    if you remove the command, sender is undefined. Therefore, you need to do:
    Player sender = event.getPlayer();
     
  6. Offline

    calebbfmv

    @EventHandler
    public void onPlayerChat(PlayerChatEvent event){
    String msg = event.getMessage().toLowerCase();
    if(msg.contains("Can I be OP")){
    event.getPlayer().kick("No!");
    }

    }
    }

    I changed it to this. Sorry I didn't tell you!
     
  7. Offline

    Jnorr44

    Did you test it?
    It looks like it should work.
     
  8. Offline

    calebbfmv

    Yeah, all but the .kick
     
Thread Status:
Not open for further replies.

Share This Page