diff --git a/.gitignore b/.gitignore index be9bf00..f2c0185 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc *.class +*sublime* # these are player/ingame specific files/chatgroups.json diff --git a/main.py b/main.py index a99b5e5..49e4682 100644 --- a/main.py +++ b/main.py @@ -2,50 +2,27 @@ __plugin_name__ = "RedstonerUtils" __plugin_version__ = "3.0" __plugin_mainclass__ = "foobar" +# damn pythonloader changed the PATH import sys - -print("Loading RedstonerUtils...") - -# damn pythonloader changed this... sys.path += ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '/usr/lib/pyshared/python2.7'] -try: - import adminchat -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import adminchat: %s" % e) -try: - import lagchunks -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import lagchunks: %s" % e) -try: - import reports -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import reports: %s" % e) -try: - import chatgroups -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import chatgroups: %s" % e) -try: - import webtoken -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import webtoken: %s" % e) -try: - import saylol -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import saylol: %s" % e) -try: - import skullclick -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import skullclick: %s]" % e) -try: - import tilehelper -except Exception, e: - print("[RedstonerUtils] ERROR: Failed to import tilehelper: %s]" % e) try: from helpers import * except Exception, e: print("[RedstonerUtils] ERROR: Failed to import helpers: %s" % e) +log("Loading RedstonerUtils...") + +# Import all modules +modules = ["adminchat", "lagchunks", "reports", "chatgroups", "webtoken", "saylol", "skullclick", "tilehelper"] +for module in modules: + try: + __import__(module) + log("Module %s loaded." % module) + except Exception, e: + error("Failed to import module %s: '%s'" % (module, e)) + + import thread import org.bukkit.entity.Player as Player diff --git a/tilehelper.py b/tilehelper.py index 527c114..3d129b4 100644 --- a/tilehelper.py +++ b/tilehelper.py @@ -1,4 +1,5 @@ import org.bukkit as bukkit +import bukkit.event.block.BlockPlaceEvent as BlockPlaceEvent from helpers import * tilehelpers = [ # Front Right Back Left Down Up @@ -7,15 +8,16 @@ tilehelpers = [ @hook.event("block.BlockPlaceEvent", "high") def onPlaceBlock(event): - player = event.getPlayer() - block = event.getBlockPlaced() - for th in tilehelpers: - area = th.get("area") - if th.get("owner") == str(player.getUniqueId()) and str(block.getWorld().getUID()) == th.get("world") and block.getX() in range(area[0][0], area[0][1]+1) and block.getY() in range(area[1][0], area[1][1]+1) and block.getZ() in range(area[2][0], area[2][1]+1) and event.canBuild(): - - # stack block in directions - msg(player, "&ayus") - - - -# server.getPluginManager().callEvent(event); + if not event.isCancelled(): + player = event.getPlayer() + block = event.getBlockPlaced() + for th in tilehelpers: + area = th.get("area") + if th.get("owner") == str(player.getUniqueId()) and str(block.getWorld().getUID()) == th.get("world") and block.getX() in range(area[0][0], area[0][1]+1) and block.getY() in range(area[1][0], area[1][1]+1) and block.getZ() in range(area[2][0], area[2][1]+1) and event.canBuild(): + + # stack block in directions + msg(player, "&ayus") + + event = BlockPlaceEvent(block, block.getState(), event.getBlockAgainst(), event.getItemInHand(), player, event.canBuild()) + + # server.getPluginManager().callEvent(event);