def onCommandClaim(sender, args): if not sender.hasPermission("plotmanager.claim"): sender.sendMessage("You don't have enough permissions to execute this command") return if len(args) == 1: x = Manager.getPlotX(sender.getLocation().getX()) z = Manager.getPlotZ(sender.getLocation().getZ()) elif len(args) == 3: x = int(args[1]) z = int(args[2]) else: sender.sendMessage("Usage: /plot claim [x] [z]") return if Manager.isOutOfRange(x, z): sender.sendMessage(''.join(["Plot ", str(x), ", ", str(z), " is out of range"])) return if Manager.claim(sender.getName(), x, z): sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)])) else: sender.sendMessage(''.join(["Failed to unclaim plot ", str(x), ", ", str(z), ". Make sure that this is a free plot and that you are allowed to claim plots"]))
def onCommandAuto(sender, args): if not sender.hasPermission("plotmanager.claim"): sender.sendMessage("You don't have enough permissions to execute this command") return if len(args) != 1: sender.sendMessage("Usage: /plot auto") return x = 0 z = 0 step = 1 name = sender.getName() while True: for i in xrange(0, step): if Manager.claim(name, x, z): sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)])) return x -= 1 for i in xrange(0, step): if Manager.claim(name, x, z): sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)])) return z -= 1 step += 2 for i in xrange(0, step): if Manager.claim(name, x, z): sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)])) return x += 1 for i in xrange(0, step): if Manager.claim(name, x, z): sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)])) return x -= 1 sender.sendMessage(''.join(["You successfully claimed plot ", str(x), ", ", str(z)]))
def onCommandPlotmap(sender, args): if len(args) == 0: showHelp(sender) return True cmd = args[0] plotCoords = getPlotCoords(int(sender.getLocation().getX()), int(sender.getLocation().getZ())) if Manager.isOutOfRange(plotCoords[0], plotCoords[1]): sender.sendMessage("Out of range") return True if cmd == "claim": if Manager.claim(sender.getName(), plotCoords[0], plotCoords[1]): sender.sendMessage(''.join(["You successfully claimed plot ", str(plotCoords[0]), ", ", str(plotCoords[1])])) else: sender.sendMessage(''.join(["Failed to unclaim plot ", str(plotCoords[0]), ", ", str(plotCoords[1]), ". Make sure that this is a free plot and that you are allowed to claim plots"])) return True elif cmd == "unclaim": if Manager.unclaim(sender.getName(), plotCoords[0], plotCoords[1]): sender.sendMessage(''.join(["You successfully unclaimed plot ", str(plotCoords[0]), ", ", str(plotCoords[1])])) else: sender.sendMessage(''.join(["Failed to unclaim plot ", str(plotCoords[0]), ", ", str(plotCoords[1]), ". Make sure that you are the owner of this plot"])) return True elif cmd == "info": plot = Manager.getPlot(plotCoords[0], plotCoords[1]) sender.sendMessage(''.join(["--- Plot ", str(plotCoords[0]), ", ", str(plotCoords[1]), " ---"])) if plot.status == Manager.PlotStatus.FREE: sender.sendMessage("Status: Free") elif plot.status == Manager.PlotStatus.CLAIMED: sender.sendMessage(''.join(["Status: Claimed by ", plot.owner])) sender.sendMessage(''.join(["Claimed at: ", plot.date])) elif plot.status == Manager.PlotStatus.TEMP: sender.sendMessage(''.join(["Status: Temporarily claimed by ", plot.owner])) sender.sendMessage(''.join(["Claimed at: ", plot.date])) elif plot.status == Manager.PlotStatus.RESERVED: sender.sendMessage("Status: Reserved") elif plot.status == Manager.PlotStatus.SPECIAL: sender.sendMessage(''.join(["Status: ", plot.description])) return True elif cmd == "tp": loc = sender.getLocation() x = Manager.getCentreX(plotCoords[0]) z = Manager.getCentreZ(plotCoords[1]) loc.setX(x) loc.setZ(z) sender.teleport(loc) return True elif cmd == "generate": if not sender.hasPermission("plotmanager.generate"): sender.sendMessage("You don't have enough permissions to execute this command") return True for x in xrange(-Manager.radius, Manager.radius): for z in xrange(-Manager.radius, Manager.radius): unclaim(x, z) return True elif cmd == "update": if not sender.hasPermission("plotmanager.generate"): sender.sendMessage("You don't have enough permissions to execute this command") return True for pos, plot in Manager.plots.iteritems(): position = getMapCoords(pos[0], pos[1]) if plot.status == Manager.PlotStatus.FREE: unclaim(pos[0], pos[1]) else: claim(pos[0], pos[1]) elif cmd == "reserve": if not sender.hasPermission("plotmanager.reserve"): sender.sendMessage("You don't have enough permissions to execute this command") return True if Manager.reserve(plotCoords[0], plotCoords[1]): sender.sendMessage(''.join(["You successfully reserved plot ", str(plotCoords[0]), ", ", str(plotCoords[1])])) else: sender.sendMessage(''.join(["Failed to reserve plot ", str(plotCoords[0]), ", ", str(plotCoords[1]), ". Make sure that this is a free plot"])) return True elif cmd == "special": if not sender.hasPermission("plotmanager.reserve"): sender.sendMessage("You don't have enough permissions to execute this command") return True del args[0] if Manager.special(plotCoords[0], plotCoords[1], ' '.join(args)): sender.sendMessage(''.join(["You successfully reserved plot ", str(plotCoords[0]), ", ", str(plotCoords[1])])) else: sender.sendMessage(''.join(["Failed to reserve plot ", str(plotCoords[0]), ", ", str(plotCoords[1]), ". Make sure that this is a free plot"])) return True elif cmd == "forceUnclaim": if not sender.hasPermission("plotmanager.admin"): sender.sendMessage("You don't have enough permissions to execute this command") return True Manager.forceUnclaim(plotCoords[0], plotCoords[1]) return True return True