myne / myne / plugins /

from myne.plugins import ProtocolPlugin
from myne.decorators import *
from myne.constants import *

class AdminBlocksPlugin(ProtocolPlugin):
    commands = {
        "solid": "commandSolid",
        "adminblocks": "commandAdminblocks",
    hooks = {
        "blockchange": "blockChanged",
        "rankchange": "sendAdminBlockUpdate",
        "canbreakadmin": "canBreakAdminBlocks",
    def gotClient(self):
        self.building_solid = False
    def blockChanged(self, x, y, z, block, selected_block):
        "Hook trigger for block changes."
        # Admincrete hack check
        if not self.canBreakAdminBlocks():
            def check_block(block):
                if ord(block) == BLOCK_GROUND_ROCK:
                    self.client.sendError("Don't build admincrete!")
          [x, y, z] = chr(BLOCK_AIR)
        # See if they are in solid-building mode
        if self.building_solid and block == BLOCK_ROCK:
            return BLOCK_GROUND_ROCK
    def canBreakAdminBlocks(self):
        "Shortcut for checking permissions."
        return (not or self.client.isOp()
    def sendAdminBlockUpdate(self):
        "Sends a packet that updates the client's admin-building ability"
        self.client.sendPacked(TYPE_INITIAL, 6, "Admincrete Update", "If you see this, it's a bug", self.canBreakAdminBlocks() and 100 or 0)
    def commandAdminblocks(self, onoff):
        "/adminblocks on|off - Turns on/off unbreakable admin/op blocks."
        if onoff == "on":
   = True
            self.client.sendWorldMessage("Admin blocks are now enabled here.")
            self.client.sendServerMessage("Admin Blocks on in %s" %
   = False
            self.client.sendWorldMessage("Admin blocks are now disabled here.")
            self.client.sendServerMessage("Admin Blocks off in %s" %
        for client in
    def commandSolid(self, parts):
        "/solid - Toggles admincrete creation."
        if self.building_solid:
            self.client.sendServerMessage("You are now placing normal rock.")
            self.client.sendServerMessage("You are now placing admin rock.")
        self.building_solid = not self.building_solid
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.