/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/HomeCommand.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/HomeCommand.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1613 by torben, Wed Aug 24 18:45:40 2011 UTC revision 1614 by torben, Thu Oct 20 17:06:20 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3  import java.io.File;  import java.io.File;
4    import java.io.IOException;
5    
6  import org.bukkit.ChatColor;  import org.bukkit.ChatColor;
7  import org.bukkit.Location;  import org.bukkit.Location;
# Line 10  import org.bukkit.command.CommandExecuto Line 11  import org.bukkit.command.CommandExecuto
11  import org.bukkit.command.CommandSender;  import org.bukkit.command.CommandSender;
12  import org.bukkit.entity.Player;  import org.bukkit.entity.Player;
13  import org.bukkit.plugin.Plugin;  import org.bukkit.plugin.Plugin;
14  import org.bukkit.util.config.Configuration;  import org.bukkit.configuration.file.YamlConfiguration;
15    
16  public class HomeCommand implements CommandExecutor {  public class HomeCommand implements CommandExecutor {
17    
18          Plugin plugin;          Plugin plugin;
19    
20          Configuration config;          YamlConfiguration config;
21    
22            File file;
23    
24          public HomeCommand(Plugin plugin) {          public HomeCommand(Plugin plugin) {
25                  this.plugin = plugin;                  this.plugin = plugin;
26    
27                  File file = new File( plugin.getDataFolder(), "homes.yml");                  file = new File( plugin.getDataFolder(), "homes.yml");
28    
29                  config = new Configuration( file );                  config = new YamlConfiguration();
30                  config.load();                  try {
31                            config.load(file);
32                    } catch (Exception e) {
33                            System.out.println("[HoerupUtils] exception loading config file: " + e.getMessage() );
34                    }
35          }          }
36                    
37    
# Line 39  public class HomeCommand implements Comm Line 46  public class HomeCommand implements Comm
46                  String name = p.getName();                  String name = p.getName();
47    
48                  if ( command.getName().equals("home") ) {                  if ( command.getName().equals("home") ) {
                         config.load();  
49    
50                          String worldName = config.getString( name + ".world");                          String worldName = config.getString( name + ".world");
51                          if (worldName != null) {                          if (worldName != null) {
# Line 61  public class HomeCommand implements Comm Line 67  public class HomeCommand implements Comm
67    
68                  if (command.getName().equals("sethome") ) {                  if (command.getName().equals("sethome") ) {
69                          Location loc = p.getLocation();                          Location loc = p.getLocation();
70                          config.setProperty( name + ".yaw", loc.getYaw() );                          config.set( name + ".yaw", loc.getYaw() );
71                          config.setProperty( name + ".pitch", loc.getPitch() );                          config.set( name + ".pitch", loc.getPitch() );
72                          config.setProperty( name + ".world", loc.getWorld().getName() );                          config.set( name + ".world", loc.getWorld().getName() );
73                          config.setProperty( name + ".x", loc.getX() );                          config.set( name + ".x", loc.getX() );
74                          config.setProperty( name + ".y", loc.getY() );                          config.set( name + ".y", loc.getY() );
75                          config.setProperty( name + ".z", loc.getZ() );                          config.set( name + ".z", loc.getZ() );
76    
77                          config.save();                          try {
78                          p.sendMessage(ChatColor.YELLOW + "home is set");                                  config.save(file);
79                                    p.sendMessage(ChatColor.YELLOW + "home is set");
80                            } catch (IOException e) {
81                                    System.out.println("[HoerupUtils] : /sethome save threw an IO exception: " + e.getMessage() );
82                            }
83                  }                  }
84                                    
85                  return true;                  return true;

Legend:
Removed from v.1613  
changed lines
  Added in v.1614

  ViewVC Help
Powered by ViewVC 1.1.20