def onCommandTp(sender, args): if not sender.hasPermission("plotmanager.tp"): sender.sendMessage("You don't have enough permissions to execute this command") return if len(args) == 3: x = Manager.getCentreX(int(args[1])) z = Manager.getCentreZ(int(args[2])) if Manager.isOutOfRange(int(args[1]), int(args[2])): sender.sendMessage(''.join(["Plot ", args[1], ", ", args[2], " is out of range"])) return elif len(args) == 2: name = str(args[1]) exists = False for pos, plot in Manager.plots.iteritems(): if plot.status == Manager.PlotStatus.CLAIMED and plot.owner == name: x = Manager.getCentreX(pos[0]) z = Manager.getCentreZ(pos[1]) exists = True if not exists: sender.sendMessage(''.join(["Can't find player ", name])) return True else: sender.sendMessage("Usage: /plot tp <x> <z> OR <name>") return loc = sender.getLocation() loc.setX(x) loc.setZ(z) sender.teleport(loc)
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