more code cleanup

This commit is contained in:
jomo
2014-07-16 00:49:55 +02:00
parent 195cf2c7ec
commit 1a6e60fec4
14 changed files with 35 additions and 36 deletions

View File

@@ -6,7 +6,7 @@ Redstoner's custom plugins, written in python.
# Installation / Set-up # Installation / Set-up
1-line-install-script for bash: 1-line-install-script for bash:
`wget -O install.sh "http://pastie.org/pastes/9310905/download?key=6byp4mrqmiui8yqeo3s6yw"; md5sum --check <<<"3499671c0832e561bc9c7d476d2167cb install.sh" && sh install.sh` `wget -O install.sh "http://pastie.org/pastes/9310905/download?key = 6byp4mrqmiui8yqeo3s6yw"; md5sum --check <<<"3499671c0832e561bc9c7d476d2167cb install.sh" && sh install.sh`
Detailed description: Detailed description:
@@ -14,7 +14,7 @@ Detailed description:
0. Download [the latest spigot](http://ci.md-5.net/job/Spigot/lastStableBuild/artifact/Spigot-Server/target/spigot.jar) 0. Download [the latest spigot](http://ci.md-5.net/job/Spigot/lastStableBuild/artifact/Spigot-Server/target/spigot.jar)
0. Run it once inside redstoner, then shut it down again 0. Run it once inside redstoner, then shut it down again
0. Create a new directory (inside redstoner) called 'lib' 0. Create a new directory (inside redstoner) called 'lib'
0. Download [jython](http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7-b2/jython-standalone-2.7-b2.jar) and save it as 'jython.jar' inside lib 0. Download [jython](http://search.maven.org/remotecontent?filepath = org/python/jython-standalone/2.7-b2/jython-standalone-2.7-b2.jar) and save it as 'jython.jar' inside lib
0. Download [mysql-connector](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.zip), extract 'mysql-connector-java-X.X.XX-bin.jar 0. Download [mysql-connector](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.zip), extract 'mysql-connector-java-X.X.XX-bin.jar
' and save it as 'mysql-connector.jar' inside lib ' and save it as 'mysql-connector.jar' inside lib
0. Download [PyPluginLoader](http://gserv.me/static/PyPluginLoader-0.3.5.jar) (we're using [this fork](https://github.com/gdude2002/Python-Plugin-Loader)) into the plugins directory 0. Download [PyPluginLoader](http://gserv.me/static/PyPluginLoader-0.3.5.jar) (we're using [this fork](https://github.com/gdude2002/Python-Plugin-Loader)) into the plugins directory

View File

@@ -23,9 +23,9 @@ def list_answers(sender):
msg(sender, "&e{") msg(sender, "&e{")
msg(sender, " &eregex:") msg(sender, " &eregex:")
for regex in answer["regex"]: for regex in answer["regex"]:
msg(sender, " " + regex.pattern, basecolor="a", usecolor=False) msg(sender, " " + regex.pattern, basecolor="a", usecolor = False)
msg(sender, " &epermission:") msg(sender, " &epermission:")
msg(sender, " " + str(answer["hide-perm"]), basecolor="a", usecolor=False) msg(sender, " " + str(answer["hide-perm"]), basecolor="a", usecolor = False)
msg(sender, " &emessage:") msg(sender, " &emessage:")
msg(sender, " " + "\n ".join(answer["message"].split("\n"))) msg(sender, " " + "\n ".join(answer["message"].split("\n")))
msg(sender, "&e}") msg(sender, "&e}")

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from helpers import * from helpers import *
ac_permission = "utils.ac" ac_permission = "utils.ac"

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from helpers import * from helpers import *
from java.util.UUID import fromString as juuid from java.util.UUID import fromString as juuid
import json import json
@@ -67,7 +67,7 @@ def on_cgt_command(sender, args):
return True return True
def groupchat(sender, message, ann=False): def groupchat(sender, message, ann = False):
#try: #try:
group = groups.get(str(sender.getUniqueId())) group = groups.get(str(sender.getUniqueId()))
if group == None: if group == None:

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from helpers import * from helpers import *
from time import time as now from time import time as now
import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent

View File

@@ -3,10 +3,9 @@ from java.util.UUID import fromString as java_uuid
forcefield_permissions = ["utils.forcefield", "utils.forcefield.ignore"] forcefield_permissions = ["utils.forcefield", "utils.forcefield.ignore"]
forcefield_prefix = "&8[&aFF&8]" forcefield_prefix = "&8[&aFF&8]"
fd = 4 # forcefield distance
forcefield_toggle = [] forcefield_toggle = []
forcefield_whitelist = {} forcefield_whitelist = {}
fd = 4 # forcefield distance
@hook.command("forcefield") @hook.command("forcefield")
@@ -77,7 +76,7 @@ def whitelist_list(sender, sender_id):
if not sender_id in forcefield_whitelist or len(forcefield_whitelist[sender_id]) == 0: if not sender_id in forcefield_whitelist or len(forcefield_whitelist[sender_id]) == 0:
msg(sender, "&c Your whitelist has no entries.") msg(sender, "&c Your whitelist has no entries.")
else: else:
c=0 c = 0
for uid in forcefield_whitelist[sender_id]: for uid in forcefield_whitelist[sender_id]:
c+=1 c+=1
msg(sender, "&a %s. &f%s" % (c, server.getPlayer(java_uuid(uid)).getDisplayName())) msg(sender, "&a %s. &f%s" % (c, server.getPlayer(java_uuid(uid)).getDisplayName()))
@@ -157,7 +156,7 @@ def set_velocity_away(player, entity): #Moves entity away from player
@hook.event("player.PlayerQuitEvent") @hook.event("player.PlayerQuitEvent")
def on_quit(event): def on_quit(event):
try: player = event.getPlayer()
forcefield_toggle.remove(str(event.getPlayer().getUniqueId())) uid = str(player.getUniqueId())
except: if uid in forcefield_toggle:
pass forcefield_toggle.remove(uid)

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from re import sub from re import sub
import org.bukkit as bukkit import org.bukkit as bukkit
import org.bukkit.Location as Location import org.bukkit.Location as Location
@@ -54,7 +54,7 @@ def safetp(player, world, x, y, z, yaw = 0, pitch = 0):
safetp(player, world, x, y+1, z, yaw, pitch) safetp(player, world, x, y+1, z, yaw, pitch)
def plugin_header(sender=None, name="Redstoner Utils"): def plugin_header(sender = None, name="Redstoner Utils"):
""" """
sends the recipient a "Plugin Header", in the format of: sends the recipient a "Plugin Header", in the format of:

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
import org.bukkit as bukkit import org.bukkit as bukkit
from helpers import * from helpers import *
@@ -21,7 +21,7 @@ def scan_chunks(amount):
ents = chunk.getEntities() ents = chunk.getEntities()
# [0]world [1]X [2]Y [3]Z [4]amount # [0]world [1]X [2]Y [3]Z [4]amount
chunks.append([chunk.getWorld(), int(ents[-1].getLocation().getX()), int(ents[0].getLocation().getY()), int(ents[0].getLocation().getZ()), len(ents)]) chunks.append([chunk.getWorld(), int(ents[-1].getLocation().getX()), int(ents[0].getLocation().getY()), int(ents[0].getLocation().getZ()), len(ents)])
chunks.sort(key=lambda entry: entry[4], reverse=True) chunks.sort(key = lambda entry: entry[4], reverse = True)
lagchunks = chunks lagchunks = chunks
except Exception, e: except Exception, e:
error(e) error(e)

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from helpers import * from helpers import *
from time import time as now from time import time as now
import thread import thread
@@ -100,7 +100,7 @@ def on_player_entity_interact(event):
def on_pluginversions_command(sender, args): def on_pluginversions_command(sender, args):
plugin_header(sender, "Plugin versions") plugin_header(sender, "Plugin versions")
plugins = list(server.getPluginManager().getPlugins()) plugins = list(server.getPluginManager().getPlugins())
plugins.sort(key=lambda pl: pl.getDescription().getName()) plugins.sort(key = lambda pl: pl.getDescription().getName())
msg(sender, "&3Listing all " + str(len(plugins)) + " plugins and their version:") msg(sender, "&3Listing all " + str(len(plugins)) + " plugins and their version:")
for plugin in plugins: for plugin in plugins:
msg(sender, "&6" + plugin.getDescription().getName() + "&r: &e" + plugin.getDescription().getVersion()) msg(sender, "&6" + plugin.getDescription().getName() + "&r: &e" + plugin.getDescription().getVersion())

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
from helpers import * from helpers import *
motd = server.getMotd() motd = server.getMotd()
@@ -7,7 +7,7 @@ motd = server.getMotd()
@hook.command("getmotd") @hook.command("getmotd")
def on_getmotd_command(sender, args): def on_getmotd_command(sender, args):
plugin_header(sender, "MOTD") plugin_header(sender, "MOTD")
msg(sender, motd, usecolor=False) msg(sender, motd, usecolor = False)
@hook.command("setmotd") @hook.command("setmotd")

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
import java.lang.reflect.Method import java.lang.reflect.Method
import java.io.File import java.io.File
import java.net.URL import java.net.URL

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
import org.bukkit as bukkit import org.bukkit as bukkit
from helpers import msg from helpers import msg

View File

@@ -1,4 +1,4 @@
#pylint: disable=F0401 #pylint: disable = F0401
import org.bukkit.event.block.BlockPlaceEvent as BlockPlaceEvent import org.bukkit.event.block.BlockPlaceEvent as BlockPlaceEvent
import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent
import org.bukkit.event.player.PlayerInteractEvent as PlayerInteractEvent import org.bukkit.event.player.PlayerInteractEvent as PlayerInteractEvent

View File

@@ -1,5 +1,5 @@
#pylint: disable=F0401 #pylint: disable = F0401
import mysqlhack #pylint: disable=unused-import import mysqlhack #pylint: disable = unused-import
import thread import thread
from re import match from re import match
from com.ziclix.python.sql import zxJDBC from com.ziclix.python.sql import zxJDBC
@@ -17,7 +17,7 @@ from random import randrange
# string "email", null: false # string "email", null: false
def mysql_query(query, args, fetch=True): def mysql_query(query, args, fetch = True):
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
curs = conn.cursor() curs = conn.cursor()
curs.execute(query, args) curs.execute(query, args)