def onPortalCreateEvent(self, event): #Check to make sure that it's a portal being lit, not one automatically created by a teleport. if event.getReason() == PortalCreateEvent.CreateReason.FIRE: #Check if the player near has the permission to light, if so light it. for player in Bukkit.getServer().getOnlinePlayers(): if player.hasPermission("omneity.portal.light"): distance = player.getLocation().distanceSquared(event.getBlocks()[0].getLocation()) if 5 <= distance <= 25: event.setCancelled(True) player.sendMessage("-") player.sendMessage(chatcolor.YELLOW + "You, or someone quite near, tried to light a portal.") player.sendMessage(chatcolor.GREEN + "You were able to light that portal!") player.sendMessage(chatcolor.RED + "If it was you that tried to light the portal,") player.sendMessage(chatcolor.RED + "stand inside the portal and light it.") player.sendMessage(chatcolor.GRAY + "This is very finicky - you might have to move up or sideways,") player.sendMessage(chatcolor.GRAY + "especially for really large portals.") player.sendMessage(chatcolor.GRAY + str(distance) + " square meters off - need to be under 5.") player.sendMessage(chatcolor.YELLOW + "Otherwise, ask them to request your assistance in lighting it.") player.sendMessage("-") return player.sendMessage(chatcolor.GREEN + "Portal successfully lit.") return #Not able to light - continue on. event.setCancelled(True) for player in Bukkit.getServer().getOnlinePlayers(): if player.getLocation().distanceSquared(event.getBlocks()[0].getLocation()) <= 25: player.sendMessage("-") player.sendMessage(chatcolor.YELLOW + "You, or someone quite near, tried to light a portal.") player.sendMessage(chatcolor.RED + "You'll have to modreq for one, as lighting your own is disabled.") player.sendMessage("-") return
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(color("c") + "You must specify who you are to throw food at.") return False Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(color("c") + 'No such player.') return False Sudo("give " + args[0] + ' ' + Item[1] + " 1") Singular = ('a ', 'an ')[Item[0][0] in vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage(color("5") + Name + color("e") + " threw "+ Singular + color("6") + Item[0] + color("c") + " at " + color("5") + RName) if random.randint(1,5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(color("5") + "Headshot!") return True
def OnCommandFoodfight(sender,args): if len(args) == 0: SendError(sender, "You must specify who you are to throw food at.") return True Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: SendError(sender, 'No such player.') return True GiveItem(receiver, Item[1]) Singular = ('a ', 'an ')[Item[0][0] in Vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage(Color("5") + Name + Color("e") + " threw " + Singular + Color("6") + Item[0] + Color("c") + " at " + Color("5") + RName) if random.randint(1, 5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(Color("5") + "Headshot!") return True
def onPayGem(self, sender, args): if self.iconomy is None: sender.sendMessage("Vault not found!") return if not sender.isOp(): sender.sendMessage("Only for OP!") return if len(args) < 3: sender.sendMessage("Usage: paygem <player> <cost> <gemname>") return namePlayer = args[0] cost = float(args[1]) nameGem = args[2] player = Bukkit.getPlayer(namePlayer) if not self.iconomy.has(namePlayer, cost): player.sendMessage(u"%sНе хватает денег на покупку. Требуется %d голд." % (ChatColor.RED, cost)) return self.iconomy.withdrawPlayer(namePlayer, cost) server = Bukkit.getServer() server.dispatchCommand(server.getConsoleSender(), "md gem %s -a 1 -g %s" % (namePlayer, nameGem))
def OnCommandFoodfight(sender, args): if len(args) == 0: SendError(sender, "You must specify who you are to throw food at.") return True Item = random.choice(Food.items()) receiver = Bukkit.getPlayer(args[0]) if receiver == None: SendError(sender, 'No such player.') return True GiveItem(receiver, Item[1]) Singular = ('a ', 'an ')[Item[0][0] in Vowels] Name = sender.getName() RName = receiver.getName() Bukkit.broadcastMessage( Color("5") + Name + Color("e") + " threw " + Singular + Color("6") + Item[0] + Color("c") + " at " + Color("5") + RName) if random.randint(1, 5) == 1: receiver.addPotionEffect( PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(Color("5") + "Headshot!") return True
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(color("c") + "/slap [Player] [Thing]") return False receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(color("c") + 'No such player.') return False if len(args) > 1: item = ' '.join(args[1:]) number = '1' for i in args[1:]: if not i.isdigit() and i != 'some': if number != 1: if i[len(i)-1:] == 's': sudo(' '.join(('give',receiver.getName(),i[:len(i)-1],number))) if i[len(i)-2:] == 'es': Sudo(' '.join(('give',receiver.getName(),i[:len(i)-2],number))) else: Sudo(' '.join(('give ',receiver.getName(),i,number))) else: Sudo(' '.join(('give ',receiver.getName(),i,'1'))) number = 1 if i == 'some': number = str(random.randint(2,8)) if i.isdigit(): number = i Word1 = args[1] else: item = 'large trout' Sudo('give '+receiver.getName()+' fish 1') i = 'fishy' Word1 = 'large' material = None if receiver == sender: receiverName = 'themselves' else: receiverName = receiver.getName() if not (Word1 == 'some' or Word1.isdigit()): if Word1[0].lower() in vowels: amount = 'an ' else: amount = 'a ' else: amount = '' Bukkit.broadcastMessage(color("5") + sender.getName() + color("c") + " slapped " + color("5") + receiverName + color("c") + " about a bit with " + amount + color("6") + item) if random.randint(0,1): receiver.addPotionEffect(PotionEffect(PotionEffectType.CONFUSION, 160, 3, True)) else: receiver.addPotionEffect(PotionEffect(PotionEffectType.SLOW, 40, 1, True)) return True
def OnCommandRaw(sender, args): if not sender.hasPermission("ore.raw"): SendError(sender, "No permission!") return True Bukkit.broadcastMessage(Colorify(' '.join(args))) return True
def onCommandRaw(sender, args): if not sender.hasPermission("ore.raw"): sender.sendMessage("No permission!") return True Bukkit.broadcastMessage(' '.join(args).replace('&', u'\u00A7')) return True
def onCommandCake(sender, args): Bukkit.dispatchCommand(sender,"eff rem") sender.sendMessage(''.join([color("9"),"You take a slice of cake - it looks so",color("6")," soft and moist"])) sender.sendMessage(''.join([color(str(random.randint(4,6))),random.choice(cakesayings)])) sender.addPotionEffect(PotionEffect(eval(''.join(["PotionEffectType.",random.choice(cakeeffects)])), 300, 3, True)) return True
def onCommandMushroom(sender, args): Bukkit.dispatchCommand(sender,"eff rem") sender.sendMessage(''.join([color("a"),"You find some mushrooms on the floor ... mmm",color("2")," tasty"])) sender.sendMessage(''.join([color(str(random.randint(1,3))),random.choice(mushroomsayings)])) sender.addPotionEffect(PotionEffect(eval(''.join(["PotionEffectType.",random.choice(mushroomeffects)])), 300, 3, True)) return True
def OnCommandItemname(sender,args): if len(args) == 0: SendError(sender, "You must have an argument -" + Color("6") + " /eff [effect] [power] [duration]" + Color("c") + " you can also use 'rem' and 'list' as effects, for special functions") return True if args[0] == "rem": if len(args) < 2: for effect in sender.getActivePotionEffects(): sender.removePotionEffect(effect.getType()) return True elif int(args[1]) < sender.getActivePotionEffects(): effect = sender.getActivePotionEffects()[int(args[1])] sender.removePotionEffect(effect.getType()) return True if args[0] == "list": if len(args) < 2: Bukkit.dispatchCommand(sender, "e") else: Bukkit.dispatchCommand(sender, "e " + args[1]) return True if len(args) < 3: SendError(sender, "You must have the correct amount of arguments -" + Color("6") + " /eff [effect] [power] [duration]") return True for i in range(1,2): if args[i].isdigit() == False: sender.sendMessage(Color("c") + "Your power and duration must be integers -" + Color("6") + " /eff [effect] [power] [duration]") return False args[0] = args[0].upper() args[0] = args[0].replace(" ", "") args[0] = args[0].replace(".", "") if len(args) == 4: receiver = Bukkit.getPlayer(args[3]) if receiver == None: SendError("Invalid player") return True else: receiver = sender EffectStr = "PotionEffectType." + args[0] try: receiver.addPotionEffect(PotionEffect(eval(EffectStr), int(args[2]), int(args[1] - 1))) except: sender.sendMessage("Invalid effect") return True
def onCommandHate(sender, args): hates = "Redgame" if len(args) > 0: hates = ' '.join(args) Bukkit.broadcastMessage(''.join([color("a"),sender.getName(),color("2"),color("l")," hates ",color("a"),hates])) return True
def onCommandLove(sender, args): loves = "RSW" if len(args) > 0: loves = ' '.join(args) Bukkit.broadcastMessage(''.join([color("d"),sender.getName(),color("4"),color("l")," <3 ",color("d"),loves])) return True
def onCommandFast(sender, args): Bukkit.dispatchCommand(sender,"eff rem") sender.addPotionEffect(PotionEffect(PotionEffectType.SPEED, 50000, 50, True)) sender.addPotionEffect(PotionEffect(PotionEffectType.JUMP, 50000, 9, True)) sender.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 30, 2, True)) sender.sendMessage(''.join([color("5"),color("l"),"SUPER",color("6")," speed! :D"])) return True
def tick(self): if self.player.getScoreboardTags().contains('totem'): totem_id = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem', None) if not totem_id is None: for e in self.player.getWorld().getEntities(): if e.getEntityId() == totem_id: e.remove() holo_id = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem_holo', None) if not holo_id is None: for e in self.player.getWorld().getEntities(): if e.getEntityId() == holo_id: e.remove() totem_task = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem_task', None) if not totem_task is None: Bukkit.getScheduler().cancelTask(totem_task) self.player.addScoreboardTag('totem') self.sound(Sound.ENTITY_PLAYER_ATTACK_WEAK, .8, .3) self.sound(Sound.ENTITY_IRON_GOLEM_HURT, 1, .8) if self.clone: self.sound(Sound.ENTITY_BLAZE_SHOOT, 1, .9) self.sound(Sound.ENTITY_BLAZE_AMBIENT, .1, .7) dir = self.player.getEyeLocation().getDirection().clone().setY( self.player.getEyeLocation().getDirection().getY()) totem = self.player.getWorld().spawnEntity( self.player.getLocation().clone().add(0, 1, 0).add(dir), EntityType.ARMOR_STAND) totem.addScoreboardTag('totem') totem.setGravity(True) totem.setInvulnerable(True) totem.setVisible(True) totem_item = ItemStack(Material.STONE_SHOVEL) totem_meta = totem_item.getItemMeta() totem_meta.setUnbreakable(True) totem_meta.setDamage(29 if self.clone else 28) totem_item.setItemMeta(totem_meta) totem.getEquipment().setHelmet(totem_item) totem.setVelocity(dir.setY(1)) PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player), 'totem', totem.getEntityId()) self.castSpell('SHAMAN', 5, totem, None, False)
def on_quit(event): uuid = uid(event.getPlayer()) if uuid in toggle_dict: del toggle_dict[uuid] for pid in list(toggle_dict): if toggle_dict[pid] == uuid: del toggle_dict[pid] msg( Bukkit.getPlayer(juuid(pid)), "%s &cwent off so your Private Message Toggle has been disabled!" % Bukkit.getPlayer(juuid(uuid)).getDisplayName())
def onCommandLeave(sender, args): if not sender.hasPermission("ore.fun.join"): sender.sendMessage("No permission!") return True if not len(args): return False Bukkit.broadcastMessage(color("e") + args[0] + " left the game.") 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") sender.sendMessage(Color("5") + "T3h lagz, they be gone!") return True
def OnCommandLeave(sender, args): if not sender.hasPermission("ore.fun.join"): SendError(sender, "No permission!") return True if len(args) < 1: return False Bukkit.broadcastMessage(Color("e") + args[0] + " left the game.") 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 onEnable(self): global WORLD_HEROES global WORLD_OUTCAST WORLD_HEROES = Bukkit.getWorld("Overworld") WORLD_OUTCAST = Bukkit.getWorld("DeepWorld") if WORLD_HEROES is None: WORLD_HEROES = Bukkit.getWorlds().get(0) if WORLD_OUTCAST is None: WORLD_OUTCAST = Bukkit.getWorlds().get(0)
def on_quit(event): uuid = uid(event.getPlayer()) if uuid in toggle_dict: del toggle_dict[uuid] for pid in list(toggle_dict): if toggle_dict[pid] == uuid: del toggle_dict[pid] msg( Bukkit.getPlayer(juuid(pid)), "%s &cwent off so your Private Message Toggle has been disabled!" % Bukkit.getPlayer(juuid(uuid)).getDisplayName(), )
def onCommandQuick(sender, args): Bukkit.dispatchCommand(sender,"eff rem") 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)) sender.sendMessage(''.join([color("9"),"Super powers!"])) return True
def onCommandFixme(sender, args): if len(args) == 1: receiver = Bukkit.getPlayer(args[0]) else: receiver = sender Bukkit.dispatchCommand(receiver,"eff rem") receiver.sendMessage("Removed potion effects") return True
def _setup(): from com.platymuus.bukkit.minipython.loader import PythonPlugin from org.bukkit.event import EventPriority, Listener from org.bukkit import Bukkit # redirect Python stdout through Bukkit logger import sys class StdoutRedirect(object): def __init__(self, func, name): self.buffer = '' self.func = func self.name = name def write(self, text): self.buffer += text.replace('\r', '') index = self.buffer.find('\n') while index >= 0: self.func('[%s] %s' % (self.name, self.buffer[:index])) self.buffer = self.buffer[index+1:] index = self.buffer.find('\n') sys.stdout = StdoutRedirect(Bukkit.getLogger().info, _plugin_name) sys.stderr = StdoutRedirect(Bukkit.getLogger().severe, _plugin_name) # decorator that marks functions as event handlers # apply to functions on classes extending Listener and register normally def EventHandler(event, priority=EventPriority.NORMAL, ignore_cancelled=False): # we let the Java side handle resolving type to a class # resolve the priority to Bukkit form if not isinstance(priority, EventPriority): priority = str(priority).upper() if not priority in ('LOWEST', 'LOW', 'NORMAL', 'HIGH', 'HIGHEST', 'MONITOR'): raise KeyError("No such priority " + priority) priority = getattr(EventPriority, priority) # wrap the function def wrap(func): handlers = getattr(func, 'bukkit_eventhandler', []) handlers.append((event, priority, ignore_cancelled)) func.bukkit_eventhandler = handlers return func return wrap # place a few essentials into builtins import __builtin__ __builtin__.PythonPlugin = PythonPlugin __builtin__.Listener = Listener __builtin__.EventHandler = EventHandler __builtin__.Bukkit = Bukkit
def onCommandJoin(sender, args): if not sender.hasPermission("ore.fun.join"): sender.sendMessage("No permission!") return True if len(args) < 1: return False Bukkit.broadcastMessage(Color("e") + args[0] + " joined the game.") if len(args) > 1: Bukkit.broadcastMessage("Player " + args[0] + " comes from " + ' '.join(args[1:])) return True
def OnCommandJoin(sender, args): if not sender.hasPermission("ore.fun.join"): SendError(sender, "No permission!") return True if len(args) < 1: return False Bukkit.broadcastMessage(Color("e") + args[0] + " joined the game.") if len(args) > 1: Bukkit.broadcastMessage("Player " + args[0] + " comes from " + ' '.join(args[1:])) return True
def onCommandItemname(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"You must have an argument -",color("6")," /eff [effect] [power] [duration]",color("c")," you can also use 'rem' and 'list' as effects, for special functions"])) return False if args[0] == "rem": if len(args) < 2: for effect in sender.getActivePotionEffects(): sender.removePotionEffect(effect.getType()) return True elif int(args[1]) < sender.getActivePotionEffects(): effect = sender.getActivePotionEffects()[int(args[1])] sender.removePotionEffect(effect.getType()) return True if args[0] == "list" and len(args) > 0: if len(args) < 2: Bukkit.dispatchCommand(sender,"e") else: Bukkit.dispatchCommand(sender,''.join(["e ",args[1]])) return True if len(args) < 3: sender.sendMessage(''.join([color("c"),"You must have the correct amount of arguments -",color("6")," /eff [effect] [power] [duration]"])) return False for i in range(1,2): if args[i].isdigit() == False: sender.sendMessage(''.join([color("c"),"Your power and duration must be integers -",color("6")," /eff [effect] [power] [duration]"])) return False args[0] = args[0].upper() args[0] = args[0].replace(" ","") args[0] = args[0].replace(".","") if len(args) == 4: receiver = Bukkit.getPlayer(args[3]) if receiver == None: sender.sendMessage(''.join([color("c"),"Invalid player"])) return False else: receiver = sender receiver.addPotionEffect(PotionEffect(eval(''.join(["PotionEffectType.",args[0]])), int(args[2]), (int(args[1])-1))) return True
def tick(self): v = self.player.getEyeLocation().getDirection() self.player.setVelocity(v.clone().setY( v.getY() * (.6 if v.getY() >= 0 else .2)).multiply(1.3).add( Vector(0, .5, 0))) self.player.addPotionEffect( PotionEffect(PotionEffectType.SPEED, 100, 4, True, False, True)) self.player.addPotionEffect( PotionEffect(PotionEffectType.INCREASE_DAMAGE, 100, 4, True, False, True)) self.player.addPotionEffect( PotionEffect(PotionEffectType.INVISIBILITY, 100, 0, True, False, True)) self.particle(self.player.getEyeLocation(), Particle.SQUID_INK, 30, 1, 2, 1, .2) self.particle(self.player.getEyeLocation(), Particle.SPELL_WITCH, 40, 1, 2, 1, .5) self.sound(Sound.ENTITY_EVOKER_CAST_SPELL, 1, 1.6) self.sound(Sound.ENTITY_GHAST_SHOOT, .6, 1) self.player.addScoreboardTag('invis') for p in Bukkit.getOnlinePlayers(): p.hidePlayer(plugin, self.player)
def on_toggle_message_command(sender, command, label, args): if not sender.hasPermission(permission) or not is_player(sender): noperm(sender) return True plugin_header(sender, "Private Message Toggle") uuid = uid(sender) if len(args) > 0: if len(args) > 1: msg(sender, "&cToo many arguments!") return True target = Bukkit.getPlayer(args[0]) if target: toggle_dict[uuid] = uid(target) msg( sender, "&2Enabled toggle so that you're now sending only to %s &2by default" % target.getDisplayName()) else: msg(sender, "&cThat player could not be found") elif uuid in toggle_dict: del toggle_dict[uuid] msg(sender, "&2Disabled toggle successfully") else: msg(sender, "&cExpected a player as argument") return True
def onGetExp(self, sender, args): if self.pheroes is None: sender.sendMessage("Heroes not found!") return if not sender.isOp(): sender.sendMessage("Only for OP!") return if len(args) < 2: sender.sendMessage("Usage: getexp <player> <exp>") return namePlayer = args[0] exp = int(args[1]) player = Bukkit.getPlayer(namePlayer) if player is None: sender.sendMessage("%sPlayer not found!" % ChatColor.RED) return hero = self.pheroes.getCharacterManager().getHero(player) if hero is None: sender.sendMessage("%sHero not found!" % ChatColor.RED) return heroClass = hero.getHeroClass() heroLevel = hero.getLevel(heroClass) if heroLevel >= heroClass.getMaxLevel(): player.sendMessage(u"%sУ вас уже максимальный уровень." % ChatColor.RED) else: hero.addExp(exp, heroClass, player.getLocation()) player.sendMessage(u"%sПолучено %d опыта." % (ChatColor.GREEN, exp))
def clean_sessions(): players = [ str(x.getUniqueId().toString()) for x in Bukkit.getOnlinePlayers() ] for k, v in PlayerSession.sessions.items(): if k not in players: del PlayerSession.sessions[k]
def OnChanMsg(self, name, message): if name in self.Muted: return alias = self.GetAlias(name) if alias.IsServer: args = message.split() if args[0].endswith(':'): Bukkit.broadcastMessage(alias.GetTag(args[0][:-1]) + " ".join(args[1:])) else: Bukkit.broadcastMessage(str(ChatColor.YELLOW) + " ".join(args[:2]) + " " + alias.Name.lower()) else: args = message.split(' ') if args[0].startswith('%'): channel = args[0][1:] ChannelChat.GetChan().ChanMsgIRC('&1[&3IRC&1]&f'+name, channel, ' '.join(args[1:])) elif args[0].startswith('@'): reciever = args[0][1:] for player in Bukkit.getServer().getOnlinePlayers(): if player.getName() == reciever: player.sendMessage(str(ChatColor.BLUE) + "[" + str(ChatColor.AQUA) + "IRC " + name + " -> me" + str(ChatColor.BLUE) + "]" + str(ChatColor.WHITE) + " " + " ".join(args[1:])) else: Bukkit.broadcastMessage(alias.GetTag(name) + message)
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"You must specify who you are to throw food at."])) return False food = random.randint(1,(len(foodlistitem)-1)) receiver = Bukkit.getPlayer(args[0]) if receiver == None: sender.sendMessage(''.join([color('c'),'No such player.'])) return False sudo(''.join(["give ",args[0],foodlistitem[food]," 1"])) if food == 1: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," threw an ",color("6"),"apple",color("c")," at ",color("5"),receiver.getName()])) else: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," threw a ",color("6"),foodlistname[food],color("c")," at ",color("5"),receiver.getName()])) if random.randint(1,5) == 1: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 40, 1, True)) Bukkit.broadcastMessage(''.join([color("5"),"Headshot!"])) return True
def on_chat(event): if event.isCancelled(): return player = event.getPlayer() uuid = uid(player) if uuid in toggle_dict: event.setCancelled(True) target = Bukkit.getPlayer(juuid(toggle_dict[uuid])).getName() runas(player, "msg %s %s" % (target, event.getMessage()))
def onEnable(self): try: self.pheroes = Bukkit.getServer().getPluginManager().getPlugin("Heroes") except: print "Heroes plugin ploblems!" self.iconomy = PluginVault.setupEconomy() if self.iconomy is None: print "Vault not found!"
def tick(self): if self.t % 20 > 0: return self.particle(self.player.getLocation().clone().add(0, .5, 0), Particle.PORTAL, 144, 4, 0, 4, .1) self.particle(self.player.getLocation().clone().add(0, .3, 0), Particle.CRIT_MAGIC, 144, 4, 0, 4, .1) self.particle(self.player.getLocation().clone().add(0, 1, 0), Particle.FIREWORKS_SPARK, 16, .3, 1, .3, .05) self.sound(Sound.ENTITY_EVOKER_CAST_SPELL, .5, 1.5) self.sound(Sound.BLOCK_LAVA_EXTINGUISH, 1, 1) self.player.setHealth(Math.min(self.player.getHealth() + 50, self.player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())) for p in self.player.getNearbyEntities(4, 4, 4): if not isinstance(p, Player): continue p.setHealth(Math.min(p.getHealth() + 50, p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())) Bukkit.getPluginManager().callEvent(EntityRegainHealthEvent(p, 50, EntityRegainHealthEvent.RegainReason.CUSTOM)) self.particle(p.getLocation().clone().add(0, 1, 0), Particle.FIREWORKS_SPARK, 16, .3, 1, .3, .05)
def __init__(self, player): if type(player) == str or type(player) == unicode: self.name = player self.b = bukkit.getPlayerExact(self.name) # bukkit class for player elif type(player) == org.bukkit.craftbukkit.entity.CraftPlayer: self.name = player.getName() self.b = player elif type(player) == org.bukkit.craftbukkit.command.ColouredConsoleSender: self.b = player self.name = "Console" elif player == Player: self.b = player.b self.name = player.name else: #last ditch attempt try: self.name = str(player) self.b = bukkit.getPlayerExact(self.name) except: print "ERROR: Could not find player", type(player), player raise ValueError
def onCommandHug(sender, args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"You must have an argument -",color("6")," /hug [thing]"])) return False if Bukkit.getPlayer(args[0]) != None: receiverPlayer = Bukkit.getPlayer(args[0]) receiverPlayer.sendMessage(''.join([color("d"),"You were hugged by ",sender.getName()])) receiver = receiverPlayer.getName() sender.sendMessage(''.join([color("d"),"You hugged ",receiver])) else: receiver = args[0] Bukkit.broadcastMessage(''.join([color(str(hex(random.randint(1,15)))[2]),color(str(hex(random.randint(1,15)))[2]),sender.getName(),color(str(hex(random.randint(1,15)))[2])," hugged ",color(str(hex(random.randint(1,15)))[2]),receiver])) return True
def spawn(dispname, sender, x, y, z): """ Sends the actual player to sender """ server = bukkit.getServer().getServer() world = server.getWorldServer(0) # main world profile = GameProfile(dispname, dispname) # set player details manager = PlayerInteractManager(world) entity = EntityPlayer(server, world, profile, manager) # create Player's entity entity.setPosition(x, y, z) packet = PacketPlayOutNamedEntitySpawn(entity) # create packet for entity spawn sender.getHandle().playerConnection.sendPacket(packet) # send packet
def onCommandFoodfight(sender,args): if len(args) == 0: sender.sendMessage(''.join([color("c"),"/slap [Player] [Thing]"])) return False receiver = Bukkit.getPlayer(args[0]) if len(args) == 2: item = args[1] else: item = 'large trout' material = Material.matchMaterial(args[1]) if receiver == None: sender.sendMessage(''.join([color('c'),'No such player.'])) return False if receiver == sender: receiverName = 'themself' else: reveiverName = receiver.getName() if item[0] in vowels: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," slapped ",color("5"),receiverName,color("c")," about a bit with an ",color("5"),item])) else: Bukkit.broadcastMessage(''.join([color("5"),sender.getName(),color("c")," slapped ",color("5"),receiverName,color("c")," about a bit with a ",color("5"),item])) if random.randint(0,1): receiver.addPotionEffect(PotionEffect(PotionEffectType.CONFUSION, 160, 3, True)) else: receiver.addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 20, 3, True)) if material != None: sudo(' '.join(['give',receiver.getName(),material.getId()])) return True
def spawn(dispname, sender, x, y, z): """ Sends the actual player to sender """ server = bukkit.getServer().getServer() world = server.getWorldServer(0) # main world profile = GameProfile(dispname, dispname) # set player details manager = PlayerInteractManager(world) entity = EntityPlayer(server, world, profile, manager) # create Player's entity entity.setPosition(x, y, z) packet = PacketPlayOutNamedEntitySpawn( entity) # create packet for entity spawn sender.getHandle().playerConnection.sendPacket(packet) # send packet
def __init__(self, player): if type(player) == str or type(player) == unicode: self.name = player self.b = bukkit.getPlayerExact( self.name) # bukkit class for player elif type(player) == org.bukkit.craftbukkit.entity.CraftPlayer: self.name = player.getName() self.b = player elif type(player ) == org.bukkit.craftbukkit.command.ColouredConsoleSender: self.b = player self.name = "Console" elif player == Player: self.b = player.b self.name = player.name else: #last ditch attempt try: self.name = str(player) self.b = bukkit.getPlayerExact(self.name) except: print "ERROR: Could not find player", type(player), player raise ValueError
def tick(self): self.player.removeScoreboardTag('invis') self.player.removePotionEffect(PotionEffectType.SPEED) self.player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE) self.player.removePotionEffect(PotionEffectType.INVISIBILITY) self.particle(self.player.getEyeLocation(), Particle.SQUID_INK, 30, 1, 2, 1, .2) self.particle(self.player.getEyeLocation(), Particle.SPELL_WITCH, 40, 1, 2, 1, .5) self.sound(Sound.ENTITY_EVOKER_CAST_SPELL, 1, 1.6) self.sound(Sound.ENTITY_GHAST_SHOOT, .6, 1) for p in Bukkit.getOnlinePlayers(): p.showPlayer(plugin, self.player)
def OnPrivMsg(self, name, message): Helper.Info("Private IRC message from %s: %s" % (name, message)) alias = self.GetAlias(name) args = message.split(' ') if args[0].startswith('%'): channel = args[0][1:] ChannelChat.GetChan().ChanMsgIRC('&1[&3IRC&1]&f'+name, channel, ' '.join(args[1:])) elif args[0].startswith('@'): reciever = args[0][1:] for player in Bukkit.getServer().getOnlinePlayers(): if player.getName() == reciever: player.sendMessage(str(ChatColor.BLUE) + "[" + str(ChatColor.AQUA) + "IRC " + name + " -> me" + str(ChatColor.BLUE) + "]" + str(ChatColor.WHITE) + " " + " ".join(args[1:]))
def OnChanMsg(self, name, message): if name in self.Muted: return alias = self.GetAlias(name) if alias.IsServer: args = message.split() if args[0].endswith(':'): Bukkit.broadcastMessage(alias.GetTag(args[0][:-1]) + " ".join(args[1:])) else: Bukkit.broadcastMessage(str(ChatColor.YELLOW) + " ".join(args[:2]) + " " + alias.Name.lower()) else: Bukkit.broadcastMessage(alias.GetTag(name) + message)
def Info(Message): Bukkit.getServer().getLogger().log(Level.INFO, Message)
def event_resident_add(self, event): residentJoined = event.getResident() if residentJoined is None: return town = event.getTown() if town is None: return player = Bukkit.getPlayer(residentJoined.getName()) if (player is None) or (not player.isOnline()) or player.hasPermission(PERM_ADMIN): return hasResidentsInTown = False findedResident = False playerInTown = None for resTown in town.getResidents(): if (resTown == residentJoined): continue hasResidentsInTown = True if resTown.isNPC(): continue playerInTown = Bukkit.getPlayer(resTown.getName()) if (playerInTown is None) or (not playerInTown.isOnline()) or (playerInTown.hasPermission(PERM_ADMIN)): # Если игрок не в сети, или этот игрок Админ, тогда продолжаем поиск. # Из-за админа мы не можем заинвайтить игрока в город, ибо может начаться каша в городе! continue findedResident = True break # Если событие вызывается когда игрок создает город, # то надо игнорировать все проверки и просто ничего не делать if not hasResidentsInTown: return needRemove = False if findedResident: isTownHero = playerInTown.hasPermission(PERM_HEROES) isTownOutcast = playerInTown.hasPermission(PERM_OUTCAST) isResHero = player.hasPermission(PERM_HEROES) isResOutcast = player.hasPermission(PERM_OUTCAST) isResAdmin = player.hasPermission(PERM_ADMIN) # print "isTownHero: %s, isTownOutcast: %s, isResHero: %s, isResOutcast: %s, isResAdmin: %s" % (isTownHero, isTownOutcast, isResHero, isResOutcast, isResAdmin) isCorrect = isResAdmin or (isTownHero and isResHero) or (isTownOutcast and isResOutcast) if not isCorrect: needRemove = True player.sendMessage(u"%sВы не можете вступить в город противоположной фракции." % ChatColor.RED) else: needRemove = True player.sendMessage(u"%sВ данный момент в городе нет игроков в онлайн! Подождите пока кто-нибудь появится онлайн." % ChatColor.RED) if needRemove: try: town.removeResident(residentJoined) except: pass
print('Importing command definitions...') from jycraft.plugin.interpreter import PyContext from org.bukkit import Bukkit from org.bukkit import Location from org.bukkit import Material from org.bukkit import Effect from org.bukkit.command import Command from org.bukkit.event import Listener, EventPriority from random import * SERVER = Bukkit.getServer() WORLD = SERVER.getWorlds().get(0) MORNING = 2000 NOON = 6000 EVENING = 14000 NIGHT = 18000 # reflection to get command map _commandMapField = SERVER.getClass().getDeclaredField("commandMap") _commandMapField.setAccessible(True) _commandMap = _commandMapField.get(SERVER) #full list of BlockTypes available in JavaDocs on canarymod.net AIR = Material.AIR STONE = Material.STONE GRASS = Material.GRASS DIRT = Material.DIRT COBBLESTONE = Material.COBBLESTONE
def OnCommandFoodfight(sender, args): if len(args) == 0: SendError(sender, "Usage: /slap [Player] [Object]") return True receiver = Bukkit.getPlayer(args[0]) if receiver == None: SendError(sender, 'No such player.') return True if len(args) > 1: item = ' '.join(args[1:]) number = '1' for i in args[1:]: if not i.isdigit() and i != 'some': if number != 1: if i[len(i) - 1:] == 's': Sudo(' '.join(('give', receiver.getName(), i[:len(i) - 1], number))) if i[len(i) - 2:] == 'es': Sudo(' '.join(('give', receiver.getName(), i[:len(i) - 2], number))) else: Sudo(' '.join( ('give ', receiver.getName(), i, number))) else: Sudo(' '.join(('give ', receiver.getName(), i, '1'))) number = 1 if i == 'some': number = str(random.randint(2, 8)) if i.isdigit(): number = i Word1 = args[1] else: item = 'large trout' i = 'fishy' Word1 = 'large' material = None GiveItem(receiver, 349) # Fish if receiver == sender: receiverName = 'themselves' else: receiverName = receiver.getName() if not (Word1 == 'some' or Word1.isdigit()): if Word1[0].lower() in Vowels: amount = 'an ' else: amount = 'a ' else: amount = '' Bukkit.broadcastMessage( Color("5") + sender.getName() + Color("c") + " slapped " + Color("5") + receiverName + Color("c") + " about a bit with " + amount + Color("6") + item) if random.randint(0, 1): receiver.addPotionEffect( PotionEffect(PotionEffectType.CONFUSION, 160, 3, True)) else: receiver.addPotionEffect( PotionEffect(PotionEffectType.SLOW, 40, 1, True)) return True
def task(): for player in Bukkit.getOnlinePlayers(): player.sendMessage(ChatColor.translateAlternateColorCodes( '&', message))
def write(self, text): # TODO: Remove duplication for print() Bukkit.getServer().getLogger().info("[PyPlugins] [PRINT]: {}".format( text.rstrip()))
def OnCommandItemname(sender, args): if len(args) == 0: SendError( sender, "You must have an argument -" + Color("6") + " /eff [effect] [power] [duration]" + Color("c") + " you can also use 'rem' and 'list' as effects, for special functions" ) return True if args[0] == "rem": if len(args) < 2: for effect in sender.getActivePotionEffects(): sender.removePotionEffect(effect.getType()) return True elif int(args[1]) < sender.getActivePotionEffects(): effect = sender.getActivePotionEffects()[int(args[1])] sender.removePotionEffect(effect.getType()) return True if args[0] == "list": if len(args) < 2: Bukkit.dispatchCommand(sender, "e") else: Bukkit.dispatchCommand(sender, "e " + args[1]) return True if len(args) < 3: SendError( sender, "You must have the correct amount of arguments -" + Color("6") + " /eff [effect] [power] [duration]") return True for i in range(1, 2): if args[i].isdigit() == False: sender.sendMessage( Color("c") + "Your power and duration must be integers -" + Color("6") + " /eff [effect] [power] [duration]") return False args[0] = args[0].upper() args[0] = args[0].replace(" ", "") args[0] = args[0].replace(".", "") if len(args) == 4: receiver = Bukkit.getPlayer(args[3]) if receiver == None: SendError("Invalid player") return True else: receiver = sender EffectStr = "PotionEffectType." + args[0] try: receiver.addPotionEffect( PotionEffect(eval(EffectStr), int(args[2]), int(args[1] - 1))) except: sender.sendMessage("Invalid effect") return True
def Sudo(Command): Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Command)
def tick(self): if self.t == 0 and self.player.getScoreboardTags().contains('totem'): # Find totem totem = None totem_id = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem', None) for e in self.player.getWorld().getEntities(): if e.getEntityId() == totem_id: totem = e if totem is None: self.t += 1 return # Reset Totem totem_loc = totem.getLocation() totem.remove() holo_id = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem_holo', None) if not holo_id is None: for e in self.player.getWorld().getEntities(): if e.getEntityId() == holo_id: e.remove() task_id = PersistentDataAPI.getInt( PersistentDataAPI.getData(self.player), 'totem_task', None) if not task_id is None: Bukkit.getScheduler().cancelTask(task_id) totem = self.player.getWorld().spawnEntity(totem_loc, EntityType.ARMOR_STAND) totem.setGravity(True) totem.setInvulnerable(True) totem.setVisible(True) totem.addScoreboardTag('totem') totem_item = ItemStack(Material.STONE_SHOVEL) totem_meta = totem_item.getItemMeta() totem_meta.setUnbreakable(True) totem_meta.setDamage(29 if self.clone else 28) totem_item.setItemMeta(totem_meta) totem.getEquipment().setHelmet(totem_item) PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player), 'totem', totem.getEntityId()) holo = self.player.getWorld().spawnEntity( totem.getLocation().clone().add(0, 2.7, 0), EntityType.ARMOR_STAND) holo.setMarker(True) holo.setVisible(False) holo.setInvulnerable(True) holo.setCustomName(PySpell.colorText('20s', 'c')) holo.setCustomNameVisible(True) PersistentDataAPI.setInt(PersistentDataAPI.getData(self.player), 'totem_holo', holo.getEntityId()) self.castSpell('SHAMAN', 5, totem, holo, True) v = self.player.getEyeLocation().getDirection() vr = Vector(1, 0, 0) if v.getY() == 0 else ( v.clone().setY(0).normalize().rotateAroundY(Math.PI / 2)) vi = v.clone().rotateAroundAxis(vr, Math.PI / 2) l = self.player.getEyeLocation().clone().add(v.clone().multiply( self.t)) if self.t < 20: self.catch_mobs = self.catchable_mobs(l) if self.catch_mobs.size() > 0: self.catch(l, v, vi) self.cancel() l1 = l.clone().add(vi.clone().multiply(2).rotateAroundAxis( v, self.t / 4)) l2 = l.clone().add(vi.clone().multiply(2).rotateAroundAxis( v, (self.t / 4) + Math.PI)) self.particle( l1, Particle.FIREWORKS_SPARK if self.clone else Particle.TOTEM, 2, 0, 0, 0, .1) self.particle( l2, Particle.FIREWORKS_SPARK if self.clone else Particle.TOTEM, 2, 0, 0, 0, .1) self.sound(l, Sound.BLOCK_LAVA_EXTINGUISH, .1, .7) else: self.catch(l, v, vi)
def Severe(Message): Bukkit.getServer().getLogger().log(Level.SEVERE, Message)