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

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

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

revision 1809 by torben, Sun Jun 3 20:34:42 2012 UTC revision 1854 by torben, Tue Oct 2 18:39:29 2012 UTC
# Line 76  public class AdvancedChest  implements L Line 76  public class AdvancedChest  implements L
76                                    
77                  if (args.length == 0) {                  if (args.length == 0) {
78                          player.sendMessage("Usage:");                          player.sendMessage("Usage:");
79                          player.sendMessage("/chest (status|lock|snitch|remove|addplayer|removeplayer) [player]");                          player.sendMessage("/chest (status|lock|snitch|remove|addplayer|removeplayer|setowner) [player]");
80                          return true;                          return true;
81                  }                  }
82                                    
# Line 140  public class AdvancedChest  implements L Line 140  public class AdvancedChest  implements L
140                  }                  }
141                                    
142                  if (cmd.equals("remove")) {                  if (cmd.equals("remove")) {
143                          if (chest != null) {                          if (chest == null) {
144                                  player.sendMessage("[LockedChest] Removing protection from chest");                                  player.sendMessage("This chest is not protected");
145                                  removeChest(loc);                                                                return true;
146                          } else {                          }
147                                  player.sendMessage("This chest is not protected");                                if (! chest.getOwner().equals( player.getName() ) ) {
148                                    player.sendMessage("You can not remove lock from a chest you don't own");
149                                    return true;
150                          }                          }
151    
152                            player.sendMessage("[LockedChest] Removing protection from chest");
153                            removeChest(loc);                              
154    
155                            return true;
156                    }
157    
158                    if (cmd.equals("setowner")) {
159                            if (chest == null) {
160                                    player.sendMessage("This chest is not protected");
161                                    return true;
162                            }
163                            if (! chest.getOwner().equals( player.getName() ) ) {
164                                    player.sendMessage("You can not set new owner of a chest you dont own");
165                                    return true;
166                            }
167                            if (args.length != 2) {
168                                    player.sendMessage("You need to specify which player should own this chest");
169                                    return true;
170                            }
171                            OfflinePlayer p2 = server.getOfflinePlayer(args[1]);
172                            if ( p2.hasPlayedBefore() == false && p2.isOnline() == false) {
173                                    player.sendMessage("Unknown user: " + args[1] );
174                                    return true;
175                            }
176                            chest.setOwner( p2.getName() );
177                            plugin.getDatabase().save( chest );
178                            player.sendMessage("ok");
179                          return true;                          return true;
180                  }                  }
181                                    
# Line 154  public class AdvancedChest  implements L Line 184  public class AdvancedChest  implements L
184                                  player.sendMessage("This chest is not protected");                                  player.sendMessage("This chest is not protected");
185                                  return true;                                  return true;
186                          }                          }
187                            if (! chest.getOwner().equals( player.getName() ) ) {
188                                    player.sendMessage("You can not add/remove players from a chest you don't own");
189                                    return true;
190                            }
191                          if (args.length != 2) {                          if (args.length != 2) {
192                                  player.sendMessage("You need to specify which player to add or remove");                                  player.sendMessage("You need to specify which player to add or remove");
193                                  return true;                                  return true;
# Line 216  public class AdvancedChest  implements L Line 250  public class AdvancedChest  implements L
250                          } else {                          } else {
251                                  event.setCancelled(true);                                  event.setCancelled(true);
252                                  event.getPlayer().sendMessage("You can't destroy that chest");                                  event.getPlayer().sendMessage("You can't destroy that chest");
253                                    server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried breaking a chest owned by " + chest.getOwner() );
254                          }                          }
255                  }                  }
256          }          }
# Line 264  public class AdvancedChest  implements L Line 299  public class AdvancedChest  implements L
299                    
300          void loadChests() {                      void loadChests() {            
301                  int count = loadChestsWorker();                  int count = loadChestsWorker();
302                  plugin.getLogger().info("[AdvancedChest] loaded " + count + " chests");                  server.getLogger().info("[AdvancedChest] loaded " + count + " chests");
303          }          }
304                    
305                    
# Line 365  public class AdvancedChest  implements L Line 400  public class AdvancedChest  implements L
400                  for (Block b : event.blockList() ) {                  for (Block b : event.blockList() ) {
401                          ChestBean chest = chestMap.get( b.getLocation() );                          ChestBean chest = chestMap.get( b.getLocation() );
402                          if (chest != null) {                          if (chest != null) {
403                                    server.getLogger().info( "[AdvancedChest] Prevented an explosion from destroying chest owned by " + chest.getOwner() );
404                                  event.setCancelled( true );                                  event.setCancelled( true );
405                                  return;                                  return;
406                          }                          }
# Line 401  public class AdvancedChest  implements L Line 437  public class AdvancedChest  implements L
437                                  }                                  }
438    
439    
440                                                            server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried opening a chest owned by " + chest.getOwner() );
441                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");
442                                  event.setCancelled(true);                                  event.setCancelled(true);
443                          }                          }
# Line 511  public class AdvancedChest  implements L Line 547  public class AdvancedChest  implements L
547                                          }                                          }
548                                                                    
549                                                                    
550                                          plugin.getLogger().info(msg);                                          server.getLogger().info( "[AdvancedChest]" + msg);
551                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);
552                                  }                                  }
553                                                                    

Legend:
Removed from v.1809  
changed lines
  Added in v.1854

  ViewVC Help
Powered by ViewVC 1.1.20