Commits

Andrew Godwin  committed 276d00d

More fixes

  • Participants
  • Parent commits de1e8cb

Comments (0)

Files changed (3)

File myne/plugins/adminblocks.py

     
     def canBreakAdminBlocks(self):
         "Shortcut for checking permissions."
-        if self.client.world:
+        if hasattr(self.client, "world"):
             return (not self.client.world.admin_blocks) or self.client.isOp()
         else:
             return False

File myne/protocol.py

         # Check for IP bans
         ip = self.transport.getPeer().host
         if self.factory.isIpBanned(ip):
-            self.sendError("Your IP (%s) is banned from this server." % ip)
+            self.sendError("You are banned for: %s" % self.factory.ipBanReason(ip))
             return
         
         self.log("Assigned ID %i" % self.id, level=logging.DEBUG)
                 self.log("Connected, as '%s'" % self.username)
                 # Are they banned?
                 if self.factory.isBanned(self.username):
-                    self.sendError("You have been banned from this server.")
+                    self.sendError("You are banned for: %s" % self.factory.banReason(self.username))
                     return
                 # OK, see if there's anyone else with that username
                 if not self.factory.duplicate_logins and self.username.lower() in self.factory.usernames:
         "Starts the process of sending a level to the client."
         self.factory.recordPresence(self.username)
         # Ask the World to flush the level and get a gzip handle back to us.
-        self.world.get_gzip_handle().addCallback(self.sendLevelStart)
+        if hasattr(self, "world"):
+            self.world.get_gzip_handle().addCallback(self.sendLevelStart)
     
     def sendLevelStart(self, (gzip_handle, zipped_size)):
         "Called when the world is flushed and the gzip is ready to read."

File myne/server.py

                     if isinstance(source_client, World):
                         world = source_client
                     else:
-                        world = source_client.world
+                        try:
+                            world = source_client.world
+                        except AttributeError:
+                            logging.log(logging.WARN, "Source client for message has no world. Ignoring.")
+                            continue
                 
                     # Someone built/deleted a block
                     if task is TASK_BLOCKSET: