def OnCommandInv(sender, args): if not sender.hasPermission("ore.inv"): SendError(sender, "No permission!") return True if len(args) == 2: cmd = args[0] name = args[1] player = Presets.Ensure(sender.getName()) if cmd == "save": if len(args) != 2: return False player[args[1]] = GetItems(sender) SendInfo(sender, "Preset " + args[1] + " saved.") elif cmd == "load": if len(args) != 2: return False if args[1] in player: items = player[args[1]] SetItems(sender, items) else: SendInfo(sender, "No such preset!") elif cmd == "remove": if len(args) != 2: return False if args[1] in player: del player[args[1]] SendInfo(sender, "Removed preset " + args[1]) else: SendError(sender, "No such preset!") elif cmd == "list": if player: sender.sendMessage("Presets:") for name in player: sender.sendMessage("- " + name) else: SendError(sender, "No presets!") else: SendError(sender, "Invalid action") else: SendError(sender, "Usage: /inv (save|load|remove|list) <name>") return True
def OnCommandCCAdmin(sender, args): if not sender.hasPermission("ore.cchat.admin"): SendError(sender, "No permission") return True if len(args) == 0: return False cmd = args[0] if cmd == "list": sender.sendMessage("Active channels:") for chan in Chans.Channels.iterkeys(): sender.sendMessage(chan) return True elif cmd == "playerinfo": if len(args) != 2: SendError(sender, "Usage: /ccadmin playerinfo <player>") return True sender.sendMessage("Player " + args[1] + ":") for chanName, chan in Chans.Channels.iteritems(): for player in chan.players: if player.getName() == args[1]: sender.sendMessage(chanName) return True elif cmd == "kick": if len(args) != 3: SendError(sender, "Usage: /ccadmin kick <player> <channel>") return True chan = Chans.Channels.get(args[2]) if chan == None: SendError(sender, "No such channel") return True for player in chan.players: if player.getName() == args[1]: SendInfo(player, "You have been kicked from channel " + args[2]) SendInfo(sender, "Kicked player " + args[1] + " from channel " + args[2]) chan.Leave(player) return True return False
def OnCommandCChat(sender, args): if len(args) != 2: return False cmd = args[0] chan = args[1] if cmd == "join": if Chans.Join(sender, chan): SendInfo(sender, "Welcome to channel " + Color("9") + chan) else: SendError(sender, "You are already in that channel") return True elif cmd == "leave": if Chans.Leave(sender, chan): SendInfo(sender, "You have left the channel") else: SendError(sender, "You are not in that channel") return True elif cmd == "info": if chan not in Chans.Channels: SendError(sender, "No such channel") return True msg = ', '.join([x.getName() for x in Chans.Channels[chan].players]) SendInfo(sender, "Players in channel " + chan + ": " + msg) return True elif cmd == "switch": if chan not in Chans.Channels: SendError(sender, "No such channel") return True if sender not in Chans.Channels[chan].players: SendError(sender, "You are not in that channel") return True Chans.ActiveChannel[sender.getName()] = chan return True return False
def OnCommandDerp(sender, args): if len(Derps) == 0: SendError(sender, "No registered derps!") return True if len(args) > 0 and args[0].isdigit(): Index = int(args[0]) if Index >= len(Derps) or Index < 0: SendError(sender, "Index out of range") return True BroadcastDerp(sender, Derps[Index]) return True if len(args) > 0 and not args[0].isdigit() and sender.hasPermission( 'ore.derp.reload'): if args[0] == "reload": LoadDerps() SendInfo(sender, "Derps reloaded") return True BroadcastDerp(sender, random.choice(Derps)) return True
def OnCommandBusWaypoint(sender, args): if not sender.hasPermission("ore.bus"): SendError(sender, "No permission!") return True first = LastPos.get(sender.getName()) if first == None: SendError(sender, "No starting point selected!") return True second = sender.getLocation() if first.loc.getWorld() != second.getWorld(): SendError(sender, "World mismatch!") else: SendInfo(sender, "Waypoint: %d %d %d" % (second.getX(), second.getY(), second.getZ())) b = Bus(first.loc.getBlockX(), first.loc.getBlockY(), first.loc.getBlockZ(), \ second.getBlockX(), second.getBlockY(), second.getBlockZ(), \ first.loc.getWorld(), first.power) LastPos[sender.getName()] = LastPoint(second, b.power) return True
def OnPlayerJoinEvent(event): sender = event.getPlayer() sender.setPlayerTime(6000, 0) SendInfo(sender, "Your time was set to day.") return True
def OnCommandFixLag(sender, args): Bukkit.dispatchCommand(sender, "rem items -1") Bukkit.dispatchCommand(sender, "rem arrows -1") Bukkit.dispatchCommand(sender, "rem boats -1") Bukkit.dispatchCommand(sender, "rem xp -1") Bukkit.dispatchCommand(sender, "butcher -f") SendInfo(sender, "T3h lagz, they be gone!") return True
def OnCommandBusStart(sender, args): if not sender.hasPermission("ore.bus"): SendError(sender, "No permission!") return True loc = sender.getLocation() LastPos[sender.getName()] = LastPoint(loc) SendInfo(sender, "Bus start: %d %d %d" % (loc.getX(), loc.getY(), loc.getZ())) return True
def OnCommandFast(sender, args): for potion in sender.getActivePotionEffects(): sender.removePotionEffect(potion.getType()) sender.addPotionEffect(PotionEffect(PotionEffectType.SPEED, 5000, 50, True)) sender.addPotionEffect( PotionEffect(PotionEffectType.FAST_DIGGING, 5000, 50, True)) sender.addPotionEffect(PotionEffect(PotionEffectType.JUMP, 5000, 8, True)) SendInfo(sender, "SUPER SPEED!") return True
def OnCommandQuick(sender, args): for potion in sender.getActivePotionEffects(): sender.removePotionEffect(potion.getType()) sender.addPotionEffect(PotionEffect(PotionEffectType.SPEED, 50000, 3, True)) sender.addPotionEffect(PotionEffect(PotionEffectType.JUMP, 50000, 2, True)) sender.addPotionEffect( PotionEffect(PotionEffectType.NIGHT_VISION, 50000, 2, True)) sender.addPotionEffect( PotionEffect(PotionEffectType.INCREASE_DAMAGE, 50000, 2, True)) SendInfo(sender, "Super powers!") return True
def OnPlayerClick(event): if event.getItem() == None: return False player = event.getPlayer() ItemPermission = "ore.ban." + str(event.getItem().getTypeId()) if player.hasPermission(ItemPermission): if not player.hasPermission("ore.ban.override"): event.setCancelled(True) SendInfo(player, "You are not allowed to use this item.") return True
def OnCommandExecBook(sender, args): if not sender.hasPermission("ore.execbook"): SendError(sender, "No permission!") return item = sender.getItemInHand() if item.getTypeId() not in (386, 387): SendError(sender, 'You must have a book') return True meta = item.getItemMeta() pages = [] for page in meta.getPages(): pages.append(page) program = '\n'.join(pages) for i in xrange(len(args)): program = program.replace('#a' + str(i), args[i]) program = program.replace("#a", ' '.join(args)) program = program.replace("#m", sender.getName()) program = program.replace("#p", "ping &b") cmds = program.split('\n') if len(cmds) > 3 and not sender.hasPermission("ore.execbook.admin"): SendError(sender, "Cannot execute more than three commands") return True for cmd in cmds: if cmd in ("execbook", ""): continue dispatchCommand(sender, cmd) SendInfo(sender, "Exectued %d commands!" % len(cmds)) return True
def OnCommandRename(sender, args): if not args: return False argstring = Colorify(' '.join(args)) item = sender.getItemInHand() meta = item.getItemMeta() if meta == None: SendError(sender, "No item in hand") return True meta.setDisplayName(argstring) item.setItemMeta(meta) SendInfo(sender, "Renamed item!") return True