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

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

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

revision 1850 by torben, Fri Jan 27 12:21:27 2012 UTC revision 1851 by torben, Sun Sep 23 18:56:24 2012 UTC
# Line 51  public class HomeCommand implements Comm Line 51  public class HomeCommand implements Comm
51                  String name = p.getName();                  String name = p.getName();
52    
53                  if ( command.getName().equals("home") ) {                  if ( command.getName().equals("home") ) {
54                            tpUser(p, name);
55                          String worldName = config.getString( name + ".world");                  }
56                          if (worldName != null) {                  if ( command.getName().equals("ophome") ) {
57                                  double yaw = config.getDouble( name + ".yaw", 0.0);                              if (args.length != 1) {
58                                  double pitch = config.getDouble( name + ".pitch", 0.0);                                  p.sendMessage("Usage: /ophome <player>");
59                                  double x = config.getDouble( name + ".x", 0.0);                                  return true;
60                                  double y = config.getDouble( name + ".y", 0.0);                          }
61                                  double z = config.getDouble( name + ".z", 0.0);                          if ( p.isOp() ) {
62                                    tpUser(p, args[0]);
                                 World world = p.getServer().getWorld(worldName);  
                                 int blockX = (int) Math.floor(x);  
                                 int blockZ = (int) Math.floor(z);  
                                 world.loadChunk(blockX, blockZ);          
   
                                 final Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch);  
   
                                 Runnable r = new Runnable() {  
                                         public void run() {  
                                                 p.teleport(loc);  
                                         }  
                                 };  
                                 int tickCount = 2; // 2 ticks = 100ms  
   
                                 p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, r, tickCount);  
   
63                          } else {                          } else {
64                                  p.sendMessage(ChatColor.YELLOW + "You haven't set a home yet!");                                  p.sendMessage("Only operators may use this command");
65                          }                          }
66                  }                  }
67    
# Line 100  public class HomeCommand implements Comm Line 84  public class HomeCommand implements Comm
84                                    
85                  return true;                  return true;
86          }          }
87            
88            private void tpUser(final Player p, String name) {
89                    String worldName = config.getString( name + ".world");
90                    if (worldName != null) {
91                            double yaw = config.getDouble( name + ".yaw", 0.0);    
92                            double pitch = config.getDouble( name + ".pitch", 0.0);
93                            double x = config.getDouble( name + ".x", 0.0);
94                            double y = config.getDouble( name + ".y", 0.0);
95                            double z = config.getDouble( name + ".z", 0.0);
96    
97                            World world = p.getServer().getWorld(worldName);
98                            int blockX = (int) Math.floor(x);
99                            int blockZ = (int) Math.floor(z);
100                            world.loadChunk(blockX, blockZ);        
101    
102                            final Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch);
103    
104                            Runnable r = new Runnable() {
105                                    public void run() {
106                                            p.teleport(loc);
107                                    }
108                            };
109                            int tickCount = 2; // 2 ticks = 100ms
110    
111                            p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, r, tickCount);
112    
113                    } else {
114                            p.sendMessage(ChatColor.YELLOW + "You haven't set a home yet!");
115                    }
116                    
117            }
118  }  }

Legend:
Removed from v.1850  
changed lines
  Added in v.1851

  ViewVC Help
Powered by ViewVC 1.1.20