Plugin will load, but none of the events or commands work

Discussion in 'Plugin Development' started by epicfacecreeper, Apr 1, 2012.

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

    epicfacecreeper

    My plugin loads all right, but none of the commands work and no events trigger when they're supposed to. There are no errors. For example, I have a PlayerJoinEvent listener that generates a config file for that player and tells them that it's running BlockMagic. This message does not appear, and neither does the config file. If you want the code, I'll give it, but it's 507 lines. Thanks for your help.
     
  2. Offline

    mmiillkkaa

    Did you put @EventHandler above each of the event methods?

    EDIT: Wow, I can't spell today.
     
  3. Offline

    ferrybig

    you registered the event, you added the commands to plugin.yml?
     
  4. Offline

    epicfacecreeper

    Both of those things.
     
  5. Offline

    Cooliojazz

    Code would probably help then...
     
  6. Offline

    epicfacecreeper

    Code:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package net.cyberninjapiggy.blockmagic;
     
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.nio.channels.FileChannel;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.List;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerExpChangeEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.util.BlockIterator;
    import org.bukkit.util.Vector;
     
    public class BlockMagic extends JavaPlugin {
    private FileConfiguration customConfig = null;
    private File customConfigFile = null;
    static final Logger log = Logger.getLogger("Minecraft");
    String[] bm = {"BlockMagic help:", "/bm spells - Show all of the spells it's possible to learn.",
    "/bm teach <player> <spell> - Teach a player a spell", "/bm setmana <player> <mana> - Set the player's mana.", "/bm mana [player] - View your mana or another player's"};
    String[] spells = {"fire", "heal", "confuse", "tele", "jump", "force", "sap"};
    @Override
    public void onEnable() {
    log.info("[BlockMagic] BlockMagic enabled.");
    }
    @Override
    public void onDisable() {
    log.info("[BlockMagic] BlockMagic disabled.");
    }
    public boolean onCommand(CommandSender sender, Command command, String[] args) {
    if ("bm".equals(command.getName())) {
    if (args.length==0) {
    if (sender instanceof Player) {
    for (String s : bm) {
    sender.sendMessage(ChatColor.DARK_PURPLE + s);
    }
    }
    else {
    for (String s : bm) {
    getServer().getConsoleSender().sendMessage(ChatColor.DARK_PURPLE + s);
    }
     
    }
    }
    else {
    if ("mana".equals(args[0]) && sender.hasPermission("blockmagic.mana")) {
    if (sender instanceof Player) {
     
    if (args.length == 1) {
    String msg = getCustomConfig(sender.getName()).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "Your mana is "+ChatColor.BLACK+msg);
    }
    else {
    String msg = getCustomConfig(args[1]).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[1]+"+ is "+ChatColor.BLACK+msg);
    }
    }
    else {
    if (args.length == 0) {
    getServer().getConsoleSender().sendMessage("Consoles don't have mana!");
    }
    else {
    String msg = getCustomConfig(args[1]).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[1]+"+ is "+ChatColor.BLACK+msg);
    }
     
    }
    }
    if ("setmana".equals(args[0]) && sender.hasPermission("blockmagic.setmana")
    ) {
    if (sender instanceof Player) {
     
    if (args.length != 3) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    getCustomConfig(args[1]).set("mana", args[2]);
    sender.sendMessage(ChatColor.DARK_PURPLE + "Mana set.");
    }
    }
    else {
    if (args.length != 3) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    getCustomConfig(args[1]).set("mana", args[2]);
    sender.sendMessage(ChatColor.DARK_PURPLE + "Mana set.");
    }
    }
    }
    if ("teach".equals(args[0]) && sender.hasPermission("blockmagic.teach")) {
    if (sender instanceof Player) {
     
    if (args.length != 3) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    getCustomConfig(args[1]).set("spells", getCustomConfig(args[1]).getStringList("spells").add(args[2]));
    sender.sendMessage(ChatColor.DARK_PURPLE + "Spell taught.");
    }
    }
    else {
    if (args.length != 3) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    getCustomConfig(args[1]).set("spells", getCustomConfig(args[1]).getStringList("spells").add(args[2]));
    sender.sendMessage(ChatColor.DARK_PURPLE + "Spell taught.");
    }
    }
    }
    if ("spells".equals(args[0]) && sender.hasPermission("blockmagic.spells")) {
    if (sender instanceof Player) {
     
    if (args.length != 1) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    for (String s : spells) {
    sender.sendMessage(s);
    }
    }
    }
    else {
    if (args.length != 1) {
     
    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
    }
    else {
    for (String s : spells) {
    getServer().getConsoleSender().sendMessage(s);
    }
    }
    }
    }
    }
    }
    if ("fire".equals(command.getName()) && sender.hasPermission("blockmagic.fire")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("fire")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.RED+"Fire" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.RED + "Fire" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
    if ("heal".equals(command.getName()) && sender.hasPermission("blockmagic.heal")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("heal")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.WHITE+"heal" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "heal");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.WHITE + "Heal" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
    if ("tele".equals(command.getName()) && sender.hasPermission("blockmagic.tele")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("tele")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.GOLD+"Tele" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "tele");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.GOLD + "Tele" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
    if ("confuse".equals(command.getName()) && sender.hasPermission("blockmagic.confuse")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("confuse")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.GREEN+"Confuse" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "confuse");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.GREEN + "Confuse" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
     
    if ("sap".equals(command.getName()) && sender.hasPermission("blockmagic.sap")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("sap")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.BLACK+"LifeSap" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.BLACK + "LifeSap" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
    if ("jump".equals(command.getName()) && sender.hasPermission("blockmagic.jump")) {
    if (sender instanceof Player) {
    if (getCustomConfig(sender.getName()).getStringList("spells").contains("jump")) {
    sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.BLUE+"Jump" + ChatColor.DARK_PURPLE + " equipped.");
    getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
    }
    else {
    sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.BLUE + "Jump" + ChatColor.DARK_PURPLE + " yet!");
    }
    }
    else {
     
    getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
     
     
    }
    }
    if ("mana".equals(command.getName()) && sender.hasPermission("blockmagic.mana")) {
    if (sender instanceof Player) {
     
    if (args.length == 0) {
    String msg = getCustomConfig(sender.getName()).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "Your mana is "+ChatColor.BLACK+msg);
    }
    else {
    String msg = getCustomConfig(args[1]).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[0]+"+ is "+ChatColor.BLACK+msg);
    }
    }
    else {
    if (args.length == 0) {
    getServer().getConsoleSender().sendMessage("Consoles don't have mana!");
    }
    else {
    String msg = getCustomConfig(args[1]).getInt("mana") + "";
    sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[0]+"+ is "+ChatColor.BLACK+msg);
    }
     
    }
    }
    //Listeners
    // Player join listener, to tell them the massage and to generate a new config for them.
    getServer().getPluginManager().registerEvents(new Listener() {
    @EventHandler
    public void playerJoin(PlayerJoinEvent evt) throws IOException {
    evt.getPlayer().sendMessage(ChatColor.DARK_PURPLE + "This server is running " + ChatColor.BLACK + "BlockMagic v0.1." + ChatColor.DARK_PURPLE +
    " For more info, type " + ChatColor.GREEN + "/bm.");
     
    if (!playerHasConfig(evt.getPlayer().getName())) {
    getServer().getConsoleSender().sendMessage("[BlockMagic] Generating config file for " + evt.getPlayer().getName() + ".");
    File src = new File(getDataFolder(), "BlockMagic/players/playerdef.yml");
    File dest = new File("BlockMagic/players/" + evt.getPlayer().getName() + ".yml");
    copyFile(src,dest);
    if (evt.getPlayer().getLevel() > getCustomConfig(evt.getPlayer().getName()).getInt("highest-level")) {
    getCustomConfig(evt.getPlayer().getName()).set("highest-level", evt.getPlayer().getLevel());
    }
     
    }
    }
    }, this);
    //Listener for drinking potions
    getServer().getPluginManager().registerEvents(new Listener() {
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent evt) {
    Calendar c = Calendar.getInstance();
    int sec = c.get(Calendar.SECOND);
    if (evt.getPlayer().getItemInHand().getTypeId()==Integer.parseInt("373:16")) {
     
    if (evt.getPlayer().getItemInHand().getTypeId()==374) {
    if (c.get(Calendar.SECOND) >= sec + 2) {
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("mana") + 500);
    if (getCustomConfig(evt.getPlayer().getName()).getInt("mana")>getConfig().getInt("maxmana")) {
    getCustomConfig(evt.getPlayer().getName()).set("mana", getConfig().getInt("maxmana"));
    }
    }
    }
    }
    }
    }, this);
    //Listener for learning spells
    getServer().getPluginManager().registerEvents(new Listener() {
    @EventHandler
    public void playerExpChange(PlayerExpChangeEvent evt) {
    getCustomConfig(evt.getPlayer().getName()).set("highest-level", evt.getPlayer().getLevel());
    if (evt.getPlayer().getLevel() >= getCustomConfig(evt.getPlayer().getName()).getInt("highest-level") + 5) {
    evt.getPlayer().sendMessage(ChatColor.DARK_PURPLE+"You have learned a new spell, " + ChatColor.BLACK + spells[getCustomConfig(evt.getPlayer().getName()).getInt("next-spell")] + ChatColor.DARK_PURPLE + "!");
    getCustomConfig(evt.getPlayer().getName()).set("spells", getCustomConfig(evt.getPlayer().getName()).getStringList("spells").add(spells[getCustomConfig(evt.getPlayer().getName()).getInt("next-spell")]));
    getCustomConfig(evt.getPlayer().getName()).set("next-spell", getCustomConfig(evt.getPlayer().getName()).getInt("next-spell") + 1);
    }
    }
    }, this);
    //Listener for spells that need a player
    getServer().getPluginManager().registerEvents(new Listener() {
    @EventHandler
    public void playerRightClick(PlayerInteractEntityEvent evt){
    if (evt.getPlayer().getItemInHand().getTypeId()==getConfig().getInt("wandID")) {
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("fire")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("fire")) {
    LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
    Double d = new Double(Math.random()*1000);
    int i = d.intValue();
    target.setFireTicks(i);
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-200);
    }
    }
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("heal")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("heal")) {
    LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
    target.setHealth(20);
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-100);
    }
    }
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("confuse")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("confuse")) {
    LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
    PotionEffect p = new PotionEffect(PotionEffectType.CONFUSION, 100, 0);
    target.addPotionEffect(p);
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-300);
    }
    }
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("sap")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("sap")) {
    LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
    int thealth = target.getHealth();
    target.setHealth(Math.round(thealth/2));
    evt.getPlayer().setHealth(evt.getPlayer().getHealth() + Math.round(thealth / 2));
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-400);
    }
    }
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("throw")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("throw")) {
    LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
    Vector direction = evt.getPlayer().getEyeLocation().getDirection();
    target.setVelocity(direction.multiply(5.0));
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-300);
    }
    }
    }
    }
    }, this);
    //Listener for spells WITHOUT a player
    getServer().getPluginManager().registerEvents(new Listener() {
    @EventHandler
    public void playerRightClick(PlayerInteractEvent evt){
    if (evt.getPlayer().getItemInHand().getTypeId()==getConfig().getInt("wandID")) {
    Action action = evt.getAction();
    if (Action.RIGHT_CLICK_BLOCK.equals(evt.getAction())) {
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("tele")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("tele")) {
    evt.getPlayer().teleport(evt.getPlayer().getEyeLocation());
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-200);
    }
    }
    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("jump")) {
    if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("jump")) {
    Vector v = new Vector(evt.getPlayer().getVelocity().getX(), 100, evt.getPlayer().getVelocity().getZ());
    getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-100);
    evt.getPlayer().setVelocity(v);
    }
    }
    }
    }
    }
    }, this);
     
    return true;
    }
    public boolean playerHasConfig(String player) {
    File f = new File("BlockMagic/players/" + player + ".yml");
    if(f.exists()) { return true; }
    else {
    return false;
    }
    }
    public LivingEntity getTarget(String player, double range) {
    List<Entity> nearbyE = getServer().getPlayer(player).getNearbyEntities(range,
    range, range);
    ArrayList<LivingEntity> livingE = new ArrayList<LivingEntity>();
     
    for (Entity e : nearbyE) {
    if (e instanceof LivingEntity) {
    livingE.add((LivingEntity) e);
    }
    }
     
    LivingEntity target = null;
    BlockIterator bItr = new BlockIterator(getServer().getPlayer(player).getLocation(), range);
    Block block;
    Location loc;
    int bx, by, bz;
    double ex, ey, ez;
    // loop through player's line of sight
    while (bItr.hasNext()) {
    block = bItr.next();
    bx = block.getX();
    by = block.getY();
    bz = block.getZ();
    // check for entities near this block in the line of sight
    for (LivingEntity e : livingE) {
    loc = e.getLocation();
    ex = loc.getX();
    ey = loc.getY();
    ez = loc.getZ();
    if ((bx-.75 <= ex && ex <= bx+1.75) && (bz-.75 <= ez && ez <= bz+1.75) && (by-1 <= ey && ey <= by+2.5)) {
    // entity is close enough, set target and stop
    target = e;
    break;
    }
    }
    }
    return target;
    }
    public static void copyFile(File sourceFile, File destFile) throws IOException {
    if(!destFile.exists()) {
    destFile.createNewFile();
    }
     
    FileChannel source = null;
    FileChannel destination = null;
     
    try {
    source = new FileInputStream(sourceFile).getChannel();
    destination = new FileOutputStream(destFile).getChannel();
    destination.transferFrom(source, 0, source.size());
    }
    finally {
    if(source != null) {
    source.close();
    }
    if(destination != null) {
    destination.close();
    }
    }
    }
    public FileConfiguration getCustomConfig(String player) {
    if (customConfig == null) {
    reloadCustomConfig(player);
    }
    return customConfig;
    }
    public void reloadCustomConfig(String player) {
    if (customConfigFile == null) {
    customConfigFile = new File(getDataFolder(), "BlockMagic/players/" + player + ".yml");
    }
    customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
     
    // Look for defaults in the jar
    InputStream defConfigStream = getResource("customConfig.yml");
    if (defConfigStream != null) {
    YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
    customConfig.setDefaults(defConfig);
    }
    }
    }
    
    Plugin.yml:
    Code:
    name: BlockMagic
    main: net.cyberninjapiggy.blockmagic.BlockMagic
    version: 0.1
    commands:
      bm:
        description: BlockMagic Commands
        usage: /<command>
      blackmagic:
        description: BlockMagic Commands
        usage: /<command> 
      fire:
        description: Equip the fire spell.
        usage: /<command>
      heal:
        description: Equip the heal spell.
        usage: /<command>
      tele:
        description: Equip the teleport spell.
        usage: /<command>
      confuse:
        description: Equip the confusion spell.
        usage: /<command>
      sap:
        description: Equip the lifesap spell.
        usage: /<command>
      force:
        description: Equip the throw spell.
        usage: /<command>
      jump:
        description: Equip the jump spell.
        usage: /<command> 
      mana:
        description: Check your mana or another player's.
        usage: /<command> [player]
    Here. If you can help, please do.
     
  7. Offline

    ferrybig

    Code:java
    1. @Override
    2. public void onEnable() {
    3. log.info("[BlockMagic] BlockMagic enabled.");
    4. }
    5.  

    missing event registering
    plz give also your plugin.yml
     
  8. Offline

    epicfacecreeper

    Plugin.yml is now there.

    I fixed it! i accidentaly had the listeners in onCommand().

    I'm now getting a new error:
    Code:
    2012-04-01 13:03:09 [INFO] [BlockMagic] Generating config file for nickbrickmaster.
    2012-04-01 13:03:09 [SEVERE] Could not pass event PlayerJoinEvent to BlockMagic
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:303)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:459)
        at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:132)
        at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:129)
        at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:41)
        at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:61)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:554)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.io.IOException: The system cannot find the path specified
        at java.io.WinNTFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(Unknown Source)
        at net.cyberninjapiggy.blockmagic.BlockMagic.copyFile(BlockMagic.java:470)
        at net.cyberninjapiggy.blockmagic.BlockMagic$1.playerJoin(BlockMagic.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301)
        ... 9 more
    And my code is:
    Code:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package net.cyberninjapiggy.blockmagic;
     
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.nio.channels.FileChannel;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.List;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerExpChangeEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.util.BlockIterator;
    import org.bukkit.util.Vector;
     
    public class BlockMagic extends JavaPlugin {
        private FileConfiguration customConfig = null;
        private File customConfigFile = null;
        static final Logger log = Logger.getLogger("Minecraft");
        String[] bm = {"BlockMagic help:", "/bm spells - Show all of the spells it's possible to learn.",
        "/bm teach <player> <spell> - Teach a player a spell", "/bm setmana <player> <mana> - Set the player's mana.", "/bm mana [player] - View your mana or another player's"};
        String[] spells = {"fire", "heal", "confuse", "tele", "jump", "force", "sap"};
        @Override
          public void onEnable() {
              log.info("[BlockMagic] BlockMagic enabled.");
              //Listeners
            // Player join listener, to tell them the massage and to generate a new config for them.
            getServer().getPluginManager().registerEvents(new Listener() {
                @EventHandler
                public void playerJoin(PlayerJoinEvent evt) throws IOException {
                    evt.getPlayer().sendMessage(ChatColor.DARK_PURPLE + "This server is running " + ChatColor.BLACK + "BlockMagic v0.1." + ChatColor.DARK_PURPLE +
                            " For more info, type " + ChatColor.GREEN + "/bm.");
                           
                    if (!playerHasConfig(evt.getPlayer().getName())) {
                        getServer().getConsoleSender().sendMessage("[BlockMagic] Generating config file for " + evt.getPlayer().getName() + ".");
                        File src = new File(getDataFolder(), "/BlockMagic/players/playerdef.yml");
                        File dest = new File("/BlockMagic/players/" + evt.getPlayer().getName() + ".yml");
                        copyFile(src,dest);
                        if (evt.getPlayer().getLevel() > getCustomConfig(evt.getPlayer().getName()).getInt("highest-level")) {
                            getCustomConfig(evt.getPlayer().getName()).set("highest-level", evt.getPlayer().getLevel());
                        }
                       
                    }
                }
            }, this);
            //Listener for drinking potions
            getServer().getPluginManager().registerEvents(new Listener() {
                @EventHandler
                public void onPlayerInteract(PlayerInteractEvent evt) {
                    Calendar c = Calendar.getInstance();
                    int sec = c.get(Calendar.SECOND);
                    if (evt.getPlayer().getItemInHand().getTypeId()==Integer.parseInt("373:16")) {
                       
                        if (evt.getPlayer().getItemInHand().getTypeId()==374) {
                            if (c.get(Calendar.SECOND) >= sec + 2) {
                            getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("mana") + 500);
                            if (getCustomConfig(evt.getPlayer().getName()).getInt("mana")>getConfig().getInt("maxmana")) {
                                getCustomConfig(evt.getPlayer().getName()).set("mana", getConfig().getInt("maxmana"));
                            }
                            }
                    }
                    }
                }
            }, this);
            //Listener for learning spells
            getServer().getPluginManager().registerEvents(new Listener() {
                @EventHandler
                public void playerExpChange(PlayerExpChangeEvent evt) {
                    getCustomConfig(evt.getPlayer().getName()).set("highest-level", evt.getPlayer().getLevel());
                    if (evt.getPlayer().getLevel() >= getCustomConfig(evt.getPlayer().getName()).getInt("highest-level") + 5) {
                        evt.getPlayer().sendMessage(ChatColor.DARK_PURPLE+"You have learned a new spell, " + ChatColor.BLACK + spells[getCustomConfig(evt.getPlayer().getName()).getInt("next-spell")] + ChatColor.DARK_PURPLE + "!");
                        getCustomConfig(evt.getPlayer().getName()).set("spells", getCustomConfig(evt.getPlayer().getName()).getStringList("spells").add(spells[getCustomConfig(evt.getPlayer().getName()).getInt("next-spell")]));
                        getCustomConfig(evt.getPlayer().getName()).set("next-spell", getCustomConfig(evt.getPlayer().getName()).getInt("next-spell") + 1);
                    }
                }
            }, this);
            //Listener for spells that need a player
            getServer().getPluginManager().registerEvents(new Listener() {
                @EventHandler
                public void playerRightClick(PlayerInteractEntityEvent evt){
                if (evt.getPlayer().getItemInHand().getTypeId()==getConfig().getInt("wandID")) {
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("fire")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("fire")) {                   
                        LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
                        Double d = new Double(Math.random()*1000);
                        int i = d.intValue();
                        target.setFireTicks(i);
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-200);
                        }
                    }
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("heal")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("heal")) {
                        LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
                        target.setHealth(20);
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-100);
                    }
                    }
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("confuse")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("confuse")) {
                        LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
                        PotionEffect p = new PotionEffect(PotionEffectType.CONFUSION, 100, 0);
                        target.addPotionEffect(p);
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-300);
                    }
                    }
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("sap")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("sap")) {
                        LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
                        int thealth = target.getHealth();
                        target.setHealth(Math.round(thealth/2));
                        evt.getPlayer().setHealth(evt.getPlayer().getHealth() + Math.round(thealth / 2));
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-400);
                    }
                    }
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("throw")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("throw")) {
                        LivingEntity target = getTarget(evt.getPlayer().getName(), 30.0);
                        Vector direction = evt.getPlayer().getEyeLocation().getDirection();
                        target.setVelocity(direction.multiply(5.0));
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-300);
                    }
                    }
                }
                }
            }, this);
            //Listener for spells WITHOUT a player
            getServer().getPluginManager().registerEvents(new Listener() {
                @EventHandler
                public void playerRightClick(PlayerInteractEvent evt){
                if (evt.getPlayer().getItemInHand().getTypeId()==getConfig().getInt("wandID")) {
                    Action action = evt.getAction();
                    if (Action.RIGHT_CLICK_BLOCK.equals(evt.getAction())) {
                        if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("tele")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("tele")) {
                        evt.getPlayer().teleport(evt.getPlayer().getEyeLocation());
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-200);
                    }
                    }
                    if (getCustomConfig(evt.getPlayer().getName()).getString("equipped-spell").equals("jump")) {
                        if (getCustomConfig(evt.getPlayer().getName()).getStringList("spells").contains("jump")) {
                        Vector v = new Vector(evt.getPlayer().getVelocity().getX(), 100, evt.getPlayer().getVelocity().getZ());
                        getCustomConfig(evt.getPlayer().getName()).set("mana", getCustomConfig(evt.getPlayer().getName()).getInt("maan")-100);
                        evt.getPlayer().setVelocity(v);
                    }
                    }   
                    }
                }
                }
            }, this);
          }
        @Override
          public void onDisable() {
              log.info("[BlockMagic] BlockMagic disabled.");
          }
        public boolean onCommand(CommandSender sender, Command command, String[] args) {
            if ("bm".equals(command.getName())) {
                if (args.length==0) {
                if (sender instanceof Player) {
                    for (String s : bm) {
                          sender.sendMessage(ChatColor.DARK_PURPLE + s);
                      }
                }
                else {
                    for (String s : bm) {
                          getServer().getConsoleSender().sendMessage(ChatColor.DARK_PURPLE + s);
                      }
     
                }
                }
                else {
                  if ("mana".equals(args[0]) && sender.hasPermission("blockmagic.mana")) {
                      if (sender instanceof Player) {
                   
                    if (args.length == 1) {
                    String msg = getCustomConfig(sender.getName()).getInt("mana") + "";
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Your mana is "+ChatColor.BLACK+msg);
                    }
                    else {
                        String msg = getCustomConfig(args[1]).getInt("mana") + "";
                        sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[1]+"+ is "+ChatColor.BLACK+msg);
                    }
                }
                else {
                    if (args.length == 0) {
                    getServer().getConsoleSender().sendMessage("Consoles don't have mana!");
                    }
                    else {
                        String msg = getCustomConfig(args[1]).getInt("mana") + "";
                        sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[1]+"+ is "+ChatColor.BLACK+msg);
                    }
     
                }
                  }
                if ("setmana".equals(args[0]) && sender.hasPermission("blockmagic.setmana")
                    ) {
                      if (sender instanceof Player) {
                   
                    if (args.length != 3) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        getCustomConfig(args[1]).set("mana", args[2]);
                        sender.sendMessage(ChatColor.DARK_PURPLE + "Mana set.");
                    }
                }
                else {
                if (args.length != 3) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        getCustomConfig(args[1]).set("mana", args[2]);
                        sender.sendMessage(ChatColor.DARK_PURPLE + "Mana set.");
                    }
                }
                  }
                if ("teach".equals(args[0]) && sender.hasPermission("blockmagic.teach")) {
                      if (sender instanceof Player) {
                   
                    if (args.length != 3) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        getCustomConfig(args[1]).set("spells", getCustomConfig(args[1]).getStringList("spells").add(args[2]));
                        sender.sendMessage(ChatColor.DARK_PURPLE + "Spell taught.");
                    }
                }
                else {
                if (args.length != 3) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        getCustomConfig(args[1]).set("spells", getCustomConfig(args[1]).getStringList("spells").add(args[2]));
                        sender.sendMessage(ChatColor.DARK_PURPLE + "Spell taught.");
                    }
                }
                  }
                if ("spells".equals(args[0]) && sender.hasPermission("blockmagic.spells")) {
                      if (sender instanceof Player) {
                   
                    if (args.length != 1) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        for (String s : spells) {
                            sender.sendMessage(s);
                        }
                    }
                }
                else {
                if (args.length != 1) {
                   
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Invalid number of arguements.");
                    }
                    else {
                        for (String s : spells) {
                            getServer().getConsoleSender().sendMessage(s);
                        }
                    }
                }
                  }
                }
            }
            if ("fire".equals(command.getName()) && sender.hasPermission("blockmagic.fire")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("fire")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.RED+"Fire" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.RED + "Fire" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
            if ("heal".equals(command.getName()) && sender.hasPermission("blockmagic.heal")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("heal")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.WHITE+"heal" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "heal");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.WHITE + "Heal" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
            if ("tele".equals(command.getName()) && sender.hasPermission("blockmagic.tele")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("tele")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.GOLD+"Tele" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "tele");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.GOLD + "Tele" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
            if ("confuse".equals(command.getName()) && sender.hasPermission("blockmagic.confuse")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("confuse")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.GREEN+"Confuse" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "confuse");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.GREEN + "Confuse" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
           
            if ("sap".equals(command.getName()) && sender.hasPermission("blockmagic.sap")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("sap")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.BLACK+"LifeSap" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.BLACK + "LifeSap" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
            if ("jump".equals(command.getName()) && sender.hasPermission("blockmagic.jump")) {
                if (sender instanceof Player) {
                    if (getCustomConfig(sender.getName()).getStringList("spells").contains("jump")) {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"Spell "+ ChatColor.BLUE+"Jump" + ChatColor.DARK_PURPLE + " equipped.");
                        getCustomConfig(sender.getName()).set("equipped-spell", "Fire");
                    }
                    else {
                        sender.sendMessage(ChatColor.DARK_PURPLE+"You haven't learned the spell " + ChatColor.BLUE + "Jump" + ChatColor.DARK_PURPLE + " yet!");
                    }
                }
                else {
                   
                          getServer().getConsoleSender().sendMessage("Consoles can't equip spells!");
                     
     
                }
            }
            if ("mana".equals(command.getName()) && sender.hasPermission("blockmagic.mana")) {
                if (sender instanceof Player) {
                   
                    if (args.length == 0) {
                    String msg = getCustomConfig(sender.getName()).getInt("mana") + "";
                    sender.sendMessage(ChatColor.DARK_PURPLE + "Your mana is "+ChatColor.BLACK+msg);
                    }
                    else {
                        String msg = getCustomConfig(args[1]).getInt("mana") + "";
                        sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[0]+"+ is "+ChatColor.BLACK+msg);
                    }
                }
                else {
                    if (args.length == 0) {
                    getServer().getConsoleSender().sendMessage("Consoles don't have mana!");
                    }
                    else {
                        String msg = getCustomConfig(args[1]).getInt("mana") + "";
                        sender.sendMessage(ChatColor.DARK_PURPLE + "The mana of "+args[0]+"+ is "+ChatColor.BLACK+msg);
                    }
     
                }
            }
           
           
            return true;
        }
       
        public boolean playerHasConfig(String player) {
        File f = new File("BlockMagic/players/" + player + ".yml");
        if(f.exists()) { return true; }
        else {
            return false;
        }
        }
        public LivingEntity getTarget(String player, double range) {
            List<Entity> nearbyE = getServer().getPlayer(player).getNearbyEntities(range,
                    range, range);
            ArrayList<LivingEntity> livingE = new ArrayList<LivingEntity>();
     
            for (Entity e : nearbyE) {
                if (e instanceof LivingEntity) {
                    livingE.add((LivingEntity) e);
                }
            }
     
            LivingEntity target = null;
            BlockIterator bItr = new BlockIterator(getServer().getPlayer(player).getLocation(), range);
            Block block;
            Location loc;
            int bx, by, bz;
            double ex, ey, ez;
            // loop through player's line of sight
            while (bItr.hasNext()) {
                    block = bItr.next();
                    bx = block.getX();
                    by = block.getY();
                    bz = block.getZ();
                            // check for entities near this block in the line of sight
                            for (LivingEntity e : livingE) {
                                    loc = e.getLocation();
                                    ex = loc.getX();
                                    ey = loc.getY();
                                    ez = loc.getZ();
                                    if ((bx-.75 <= ex && ex <= bx+1.75) && (bz-.75 <= ez && ez <= bz+1.75) && (by-1 <= ey && ey <= by+2.5)) {
                                            // entity is close enough, set target and stop
                                            target = e;
                                            break;
                                    }
                            }
                    }
                return target;
                }
        public static void copyFile(File sourceFile, File destFile) throws IOException {
        if(!destFile.exists()) {
            destFile.createNewFile();
        }
     
        FileChannel source = null;
        FileChannel destination = null;
     
        try {
            source = new FileInputStream(sourceFile).getChannel();
            destination = new FileOutputStream(destFile).getChannel();
            destination.transferFrom(source, 0, source.size());
        }
        finally {
            if(source != null) {
                source.close();
            }
            if(destination != null) {
                destination.close();
            }
        }
    }
        public FileConfiguration getCustomConfig(String player) {
        if (customConfig == null) {
            reloadCustomConfig(player);
        }
        return customConfig;
        } 
        public void reloadCustomConfig(String player) {
        if (customConfigFile == null) {
        customConfigFile = new File(getDataFolder(), "/BlockMagic/players/" + player + ".yml");
        }
        customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
     
        // Look for defaults in the jar
        InputStream defConfigStream = getResource("customConfig.yml");
        if (defConfigStream != null) {
            YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
            customConfig.setDefaults(defConfig);
        }
    }
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  9. Offline

    Cooliojazz

    File dest = new File("/BlockMagic/players/" + evt.getPlayer().getName() + ".yml");
    Did you mean to put that file in the top level directory "BlockMagic"?... Windows may not like you trying to reference files like that... (WinNTFileSystem, so windows) =P
     
  10. Offline

    epicfacecreeper

    I'm trying to get it to save in the /plugins/BlockMagic/<playername>.yml.
     
  11. Offline

    Cooliojazz

    Yeah but you're trying to access /BlockMagic/players/<playername>.yml, which should be interpreted as C:\BlockMagic\players\<playername>.yml on your machine... did you mean ./BlockMagic/<...>? Or was it supossed to be like the source, so
    File dest = new File(getDataFolder(), "/BlockMagic/players/<playername>.yml");
     
  12. Offline

    ferrybig

    its not recommends accessing files from the main server thread, as the disk can be buszzy, so the code can block for an long time, but you also cant sending messages to an player from not the main thread, so read the file at onenable, thats more recommand
     
  13. Offline

    Cooliojazz

    Actually, you can send players messages from outside the main thread...
     
  14. Offline

    epicfacecreeper

    I have no way of knowing what the path will be, so i wouldn't use an absolute reference. Is it possible to get relative references in java? Also, I got most of the config-reading code from the config tutorial, so i have no idea what it means.
     
  15. Offline

    Cooliojazz

    /Folder1/Folder2/<...> is an absolute path. ./Folder1/Folder2/<...> or just Folder1/Folder2/<...> is relative.
     
  16. Offline

    Technius

    In windows, the file separator character is "\". Linux, it's "/". Don't confuse the two.

    I strongly recommend you do this:
    Code:java
    1. File file = new File("Folder1" + File.seperator + "Folder2");

    On windows, that will look like "Folder1\Folder2"
     
  17. Offline

    Cooliojazz

    Wrong, on windows it's "\" OR "/". Basically the only time / is not allowed on windows is starting a path at the command line, as / is used for switches.
     
  18. Offline

    epicfacecreeper

    I epically fail at doing this. Can someone just tell me, if the path is BlockMagic/players/, where the BlockMagic folder should be, Inside the jar, or out?
     
  19. Offline

    Cooliojazz

    It will be outside the jar.
     
  20. Offline

    epicfacecreeper

    I put in some new copy code, and now I've fixed it!
     
  21. Offline

    Lolmewn Retired Staff

    You can also use Bukkit's method getDataFolder(), and create a file like this:
    Code:
    File newFile = new File(getDataFolder(), "someFile.yml");
     
  22. Offline

    epicfacecreeper

    Thanks Lolmewn! That's excactly what I'm looking for.
     
Thread Status:
Not open for further replies.

Share This Page