Compare commits
18 Commits
plotter
...
commandman
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cf1be67e9 | ||
|
|
e184a6d4e1 | ||
|
|
2310c9143a | ||
|
|
fcda622259 | ||
|
|
e400f9999a | ||
|
|
d76b0aaf37 | ||
|
|
45008c0443 | ||
|
|
34eed808dc | ||
|
|
fe56d1e2f4 | ||
|
|
6d7bd233da | ||
|
|
ae02f14c4b | ||
|
|
9e3cd6828e | ||
|
|
c137ef93c6 | ||
|
|
f1ae0c4189 | ||
|
|
6aa7cf40aa | ||
|
|
66ab0c1468 | ||
|
|
11cbd08480 | ||
|
|
c05e56d307 |
12
adminchat.py
12
adminchat.py
@@ -50,12 +50,12 @@ def get_key(uuid):
|
||||
key = ac_keys.get(uuid)
|
||||
return key if key != None else ac_defaultkey
|
||||
|
||||
@simplecommand("adminchatkey",
|
||||
aliases = ["ackey"],
|
||||
senderLimit = 0,
|
||||
helpNoargs = True,
|
||||
helpSubcmd = True,
|
||||
description = "Sets a key character for adminchat",
|
||||
@simplecommand("adminchatkey",
|
||||
aliases = ["ackey"],
|
||||
senderLimit = 0,
|
||||
helpNoargs = True,
|
||||
helpSubcmd = True,
|
||||
description = "Sets a key character for adminchat",
|
||||
usage = "<key>")
|
||||
def adminchatkey_command(sender, command, label, args):
|
||||
key = " ".join(args)
|
||||
|
||||
@@ -92,7 +92,7 @@ def adminnotes_command(sender, command, label, args):
|
||||
show_an_help(sender)
|
||||
return
|
||||
if not args[1].isdigit():
|
||||
msg(sender, "&cThe ID has to be numeric (check /an if you're unsure)")
|
||||
msg(sender, "&cThe ID has to be numeric (check /an if you're unsure)")
|
||||
return
|
||||
note_id = int(args[1])-1
|
||||
if note_id >= len(notes):
|
||||
|
||||
@@ -20,13 +20,13 @@ def helpMsg(sender, cmd, description, usage, aliases, permission):
|
||||
|
||||
|
||||
def simplecommand(cmd,
|
||||
aliases = [],
|
||||
usage = "[args...]",
|
||||
aliases = [],
|
||||
usage = "[args...]",
|
||||
description = None,
|
||||
senderLimit = -1,
|
||||
amin = 0,
|
||||
amax = -1,
|
||||
helpNoargs = False,
|
||||
senderLimit = -1,
|
||||
amin = 0,
|
||||
amax = -1,
|
||||
helpNoargs = False,
|
||||
helpSubcmd = False):
|
||||
cmd = cmd.lower()
|
||||
permission = "utils." + cmd
|
||||
@@ -107,4 +107,4 @@ class Validate():
|
||||
if not checkargs(sender, args, amin, amax):
|
||||
raise CommandException("")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ settingInformation = dict( #[setting type, identifying description, detailed des
|
||||
)
|
||||
|
||||
defaults = {
|
||||
0: list,
|
||||
0: list,
|
||||
1: dict,
|
||||
2: list
|
||||
}
|
||||
@@ -87,8 +87,8 @@ def getSettingDetails(arg):
|
||||
raise CommandException(" &cThat setting could not be found.\n For command help, use &o/toggle &cor &o/set")
|
||||
|
||||
@simplecommand("toggle",
|
||||
aliases = ["setting", "set", "config"],
|
||||
usage = "<setting> [value|info]",
|
||||
aliases = ["setting", "set", "config"],
|
||||
usage = "<setting> [value|info]",
|
||||
description = "Toggles or sets your preferences for our redstone \nutilities. The following settings are available:\n" + ", ".join([x for x in settingInformation]),
|
||||
senderLimit = 0,
|
||||
helpNoargs = True,
|
||||
@@ -144,13 +144,13 @@ def toggle_command(sender, command, label, args):
|
||||
if arg2 == "details":
|
||||
return " &aSetting %s:\n &9%s \n&6Accepted arguments: [<slot>|clear|details]" % (setting, details[2])
|
||||
|
||||
slot = int(arg2) if arg2.isdigit() else 0
|
||||
slot = int(arg2) if arg2.isdigit() else 0
|
||||
if not (0 <= slot <= details[4]):
|
||||
return " &cSlot number must be more than or equal to 0 and less than or equal to %s!" % details[4]
|
||||
|
||||
item = fromStack(player.getItemInHand())
|
||||
if item[0] == 0 or item[1] <= 0:
|
||||
if enabled:
|
||||
if enabled:
|
||||
items = values[uuid]
|
||||
if slot in items:
|
||||
del items[slot]
|
||||
@@ -197,16 +197,16 @@ def on_block_place(event):
|
||||
material = block.getType()
|
||||
|
||||
|
||||
if (material in (Material.WOOD_STEP, Material.STEP)
|
||||
and isEnabled("slab", uuid)
|
||||
and player.hasPermission("utils.toggle.slab")
|
||||
if (material in (Material.WOOD_STEP, Material.STEP)
|
||||
and isEnabled("slab", uuid)
|
||||
and player.hasPermission("utils.toggle.slab")
|
||||
and block.getData() < 8
|
||||
):
|
||||
block.setData(block.getData() + 8) # Flip upside down
|
||||
|
||||
|
||||
elif (material == Material.CAULDRON
|
||||
and isEnabled("cauldron", uuid)
|
||||
elif (material == Material.CAULDRON
|
||||
and isEnabled("cauldron", uuid)
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
):
|
||||
block.setData(3) #3 layers of water, 3 signal strength
|
||||
@@ -214,7 +214,7 @@ def on_block_place(event):
|
||||
|
||||
elif ((material == Material.FURNACE and player.hasPermission("utils.toggle.furnace"))
|
||||
or (material == Material.DROPPER and player.hasPermission("utils.toggle.dropper"))
|
||||
or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper"))
|
||||
or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper"))
|
||||
):
|
||||
stacks = get(str(material).lower()).get(uuid)
|
||||
if stacks != None: # Enabled
|
||||
@@ -227,7 +227,7 @@ def on_block_place(event):
|
||||
"""
|
||||
elif (material == Material.REDSTONE_TORCH_ON
|
||||
and event.getBlockAgainst().getType() == Material.REDSTONE_BLOCK
|
||||
and isEnabled("torch", uuid)
|
||||
and isEnabled("torch", uuid)
|
||||
and player.hasPermission("utils.toggle.torch")
|
||||
):
|
||||
torches_to_break.append(block)
|
||||
@@ -244,8 +244,8 @@ def on_block_place(event):
|
||||
@hook.event("player.PlayerInteractEvent", "monitor")
|
||||
def on_interact(event):
|
||||
player = event.getPlayer()
|
||||
if (isEnabled("cauldron", uid(player))
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
if (isEnabled("cauldron", uid(player))
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
and is_creative(player)
|
||||
and event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||
and (not event.hasItem() or event.getItem().getType() == Material.REDSTONE)
|
||||
@@ -269,7 +269,7 @@ def stop_breaking_torches():
|
||||
class torch_breaker(Runnable):
|
||||
|
||||
def run():
|
||||
|
||||
|
||||
try:
|
||||
if break_torches:
|
||||
for i in range(len(torches_to_break)):
|
||||
|
||||
@@ -97,12 +97,12 @@ def on_chat(event):
|
||||
groupchat(sender, msge)
|
||||
event.setCancelled(True)
|
||||
|
||||
@simplecommand("chatgroupkey",
|
||||
aliases = ["cgkey"],
|
||||
senderLimit = 0,
|
||||
helpNoargs = True,
|
||||
helpSubcmd = True,
|
||||
description = "Sets a key character for chatting to your chatgroup",
|
||||
@simplecommand("chatgroupkey",
|
||||
aliases = ["cgkey"],
|
||||
senderLimit = 0,
|
||||
helpNoargs = True,
|
||||
helpSubcmd = True,
|
||||
description = "Sets a key character for chatting to your chatgroup",
|
||||
usage = "<key>")
|
||||
def chatgroupkey_command(sender, command, label, args):
|
||||
key = " ".join(args)
|
||||
|
||||
@@ -126,7 +126,7 @@ def runas(player, cmd):
|
||||
player.chat("/" + cmd)
|
||||
else:
|
||||
server.dispatchCommand(player, cmd)
|
||||
|
||||
|
||||
|
||||
def is_player(obj):
|
||||
"""
|
||||
|
||||
87
hypercommand.py
Normal file
87
hypercommand.py
Normal file
@@ -0,0 +1,87 @@
|
||||
# can't import * because that's not working with nested functions & decorators
|
||||
import helpers
|
||||
|
||||
# cmd = the actual command
|
||||
# tree = e.g. [{ "name": "subcommand", "perm": "utils.cmd.command.subcommand", "func": <function>, "type": "cmd", "cont": [<tree>] }]
|
||||
# helpnoargs = print help if no args given, else run the command function below decorator
|
||||
# console = can be ran by console
|
||||
def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
||||
def help_msg_get(tree):
|
||||
holder = ""
|
||||
for data in tree:
|
||||
if len(data["cont"]) > 0:
|
||||
holder += ("(" + help_msg_get(data["cont"]) + ")")
|
||||
else:
|
||||
holder += (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">"))
|
||||
return holder
|
||||
|
||||
def help_msg(sender, tree):
|
||||
for data in tree:
|
||||
if len(data["cont"]) > 0:
|
||||
helpers.msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">")) + " " + help_msg_get(data["cont"]))
|
||||
else:
|
||||
helpers.msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">")))
|
||||
return None
|
||||
|
||||
has_help = False
|
||||
for data in tree:
|
||||
if data["name"] == "help" and data["type"] == "cmd":
|
||||
has_help = True
|
||||
break
|
||||
cmd = cmd.lower()
|
||||
if not has_help:
|
||||
tree.append({"name": "help", "perm": "utils." + cmd + ".help", "func": help_msg, "type": "cmd", "cont": []}) # type = "cmd" for subcommands or "arg" for arguments
|
||||
|
||||
def decorator(function):
|
||||
def get_next(sender, tree, args, all_args):
|
||||
if len(args) == 0: # ran out of arguments but command is supposed to continue, print usage
|
||||
data = []
|
||||
for comm in tree:
|
||||
if comm["type"] == "cmd":
|
||||
data.append(comm["name"])
|
||||
else:
|
||||
data.append("<" + comm["name"] + ">")
|
||||
return "&c" + " ".join(all_args) + " " + "/".join(data) + "..."
|
||||
for comm in tree:
|
||||
if comm["type"] == "cmd":
|
||||
if comm["name"] == args[0]: # argument exists as a subcommand
|
||||
if sender.hasPermission(comm["perm"]):
|
||||
if len(comm["cont"]) > 0: # command continues
|
||||
return get_next(sender, comm["cont"], args[1:], all_args) # continue in the recursive stack
|
||||
else:
|
||||
return comm["func"](sender, args[1:]) # run function with sender and all trailing arguments incase they are relevant
|
||||
else:
|
||||
return "&cNo permission"
|
||||
for comm in tree:
|
||||
if comm["type"] == "arg":
|
||||
if len(comm["cont"]) > 0: # command continues, but this is an argument
|
||||
# run the function its pointing at and substitute itself with the returned subcommand to chose
|
||||
# continue in stack as if the arg was a subcommand returned by its pointer function
|
||||
return get_next(sender, comm["cont"], args[0:(len(args) - 1)].insert(0, comm["func"](sender, args[0])), all_args)
|
||||
else:
|
||||
return comm["func"](sender, args) # run the function arg is pointing at with current arguments including this one as args[0]
|
||||
return get_next(sender, tree, [], all_args[0:(len(all_args) - 1)])
|
||||
|
||||
@hook.command(cmd)
|
||||
def call(sender, command, label, args):
|
||||
message = run(sender, command, label, args)
|
||||
if message:
|
||||
helpers.msg(sender, message)
|
||||
return True
|
||||
|
||||
def run(sender, command, label, args):
|
||||
if not helpers.is_player(sender) and not console:
|
||||
return "&cThis command can only be executed by players"
|
||||
try:
|
||||
if len(args) == 0:
|
||||
if helpnoargs:
|
||||
help_msg(sender, tree)
|
||||
return None
|
||||
else:
|
||||
return function(sender, command, label, args)
|
||||
return get_next(sender, tree, args, args)
|
||||
except:
|
||||
helpers.error(helpers.trace())
|
||||
return "&cInternal Error. Please report to staff!"
|
||||
return call
|
||||
return decorator
|
||||
@@ -34,10 +34,10 @@ def matches_thread(password, user):
|
||||
|
||||
|
||||
@simplecommand("cgpass",
|
||||
usage = "<password> <new password>",
|
||||
description = "Changes your password",
|
||||
senderLimit = 0,
|
||||
helpNoargs = True)
|
||||
usage = "<password> <new password>",
|
||||
description = "Changes your password",
|
||||
senderLimit = 0,
|
||||
helpNoargs = True)
|
||||
def change_pass_command(sender, command, label, args):
|
||||
if sender.getName() in logging_in:
|
||||
return "&cYou are not logged in"
|
||||
@@ -52,9 +52,9 @@ def change_pass_command(sender, command, label, args):
|
||||
return "&cYou are not registered"
|
||||
|
||||
@simplecommand("login",
|
||||
usage = "<password>",
|
||||
usage = "<password>",
|
||||
description = "Logs you in if <password> matches your password.",
|
||||
senderLimit = 0,
|
||||
senderLimit = 0,
|
||||
helpNoargs = True)
|
||||
def login_command(sender, command, label, args):
|
||||
password = args[0]
|
||||
@@ -195,7 +195,7 @@ def kick_thread():
|
||||
if name in logging_in:
|
||||
del logging_in[name]
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
thread = threading.Thread(target = kick_thread)
|
||||
|
||||
10
main.py
10
main.py
@@ -15,6 +15,8 @@ except:
|
||||
print("[RedstonerUtils] ERROR: Failed to import helpers:")
|
||||
print(print_traceback())
|
||||
|
||||
|
||||
|
||||
@hook.enable
|
||||
def on_enable():
|
||||
info("RedstonerUtils enabled!")
|
||||
@@ -36,8 +38,8 @@ shared["load_modules"] = [
|
||||
"adminchat",
|
||||
# Adds /badge, allows to give players achievements
|
||||
"badges",
|
||||
# Adds a few block placement corrections/mods
|
||||
"blockplacemods",
|
||||
# Adds a few block placement corrections/mods
|
||||
"blockplacemods",
|
||||
# Adds /calc, toggles automatic solving of Math expressions in chat
|
||||
"calc",
|
||||
# Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities
|
||||
@@ -77,9 +79,7 @@ shared["load_modules"] = [
|
||||
# Replacement for LoginSecurity
|
||||
"loginsecurity",
|
||||
# Centralized Player class
|
||||
"playermanager",
|
||||
# Plots
|
||||
"plotter"
|
||||
"playermanager"
|
||||
]
|
||||
shared["modules"] = {}
|
||||
for module in shared["load_modules"]:
|
||||
|
||||
13
misc.py
13
misc.py
@@ -116,7 +116,6 @@ def rs_material_broken_by_flow(material):
|
||||
|
||||
|
||||
|
||||
|
||||
@simplecommand("sudo",
|
||||
usage = "<player> [cmd..]",
|
||||
description = "Makes <player> write [cmd..] in chat",
|
||||
@@ -132,14 +131,14 @@ def on_sudo_command(sender, command, label, args):
|
||||
server.dispatchCommand(server.getConsoleSender(), cmd[1:] if is_cmd else cmd)
|
||||
return None
|
||||
target_player = server.getPlayer(target)
|
||||
if target_player:
|
||||
if target_player and uid(target_player) not in pythoners:
|
||||
target_player.chat(cmd)
|
||||
return None
|
||||
return "&cPlayer %s not found!" % target
|
||||
|
||||
|
||||
|
||||
@simplecommand("me",
|
||||
@simplecommand("me",
|
||||
usage = "[message..]",
|
||||
description = "Sends a message in third person",
|
||||
helpNoargs = True)
|
||||
@@ -196,11 +195,19 @@ def eval_thread(sender, code):
|
||||
msg(sender, ">>> %s: %s" % (eclass.__name__, e) + "\n ", False, "c")
|
||||
thread.exit()
|
||||
|
||||
pythoners = [
|
||||
"e452e012-2c82-456d-853b-3ac8e6b581f5", # Nemes
|
||||
"ae795aa8-6327-408e-92ab-25c8a59f3ba1", # jomo
|
||||
"305ccbd7-0589-403e-a45b-d791dcfdee7d" # PanFritz
|
||||
]
|
||||
|
||||
@simplecommand("pyeval",
|
||||
usage = "[code..]",
|
||||
description = "Runs python [code..] and returns the result",
|
||||
helpNoargs = True)
|
||||
def on_pyeval_command(sender, command, label, args):
|
||||
if is_player(sender) and uid(sender) not in pythoners:
|
||||
return noperm(sender)
|
||||
msg(sender, " ".join(args), False, "e")
|
||||
thread.start_new_thread(eval_thread, (sender, " ".join(args)))
|
||||
return None
|
||||
|
||||
20
player.py
20
player.py
@@ -4,24 +4,24 @@ players = []
|
||||
|
||||
class py_player:
|
||||
|
||||
def __init__(player):
|
||||
self.player = player
|
||||
def __init__(player):
|
||||
self.player = player
|
||||
|
||||
#Properties TODO
|
||||
#Example:
|
||||
self.logging_in = False
|
||||
#Properties TODO
|
||||
#Example:
|
||||
self.logging_in = False
|
||||
|
||||
def get_py_player(player):
|
||||
py_player = players[players.index(player)]
|
||||
return py_player
|
||||
py_player = players[players.index(player)]
|
||||
return py_player
|
||||
|
||||
|
||||
@hook.event("player.PlayerJoinEvent","highest")
|
||||
def on_join(event):
|
||||
player = py_player(event.getPlayer())
|
||||
players.append(player)
|
||||
player = py_player(event.getPlayer())
|
||||
players.append(player)
|
||||
|
||||
|
||||
@hook.event("player.PlayerQuitEvent","highest")
|
||||
def on_leave(event):
|
||||
players.remove(get_py_player(event.getPlayer()))
|
||||
players.remove(get_py_player(event.getPlayer()))
|
||||
|
||||
66
plotter.py
66
plotter.py
@@ -5,50 +5,26 @@
|
||||
on hold because the PlotMe developer continued to develop PlotMe
|
||||
"""
|
||||
|
||||
from helpers import *
|
||||
from basecommands import simplecommand
|
||||
import sys
|
||||
|
||||
x_plot_size = 3
|
||||
z_plot_size = 3
|
||||
padding = 1
|
||||
|
||||
def base_coords(x, z):
|
||||
pid = plot_id(x, z)
|
||||
return [pid[0] * (x_plot_size + padding), pid[1] * (z_plot_size + padding)]
|
||||
|
||||
def bounds(x, z):
|
||||
base = base_coords(x, z)
|
||||
return [base, [base[0] + x_plot_size, base[1] + z_plot_size]]
|
||||
|
||||
def plot_id(x, z):
|
||||
return [x // (x_plot_size + padding), z // (z_plot_size + padding)]
|
||||
|
||||
|
||||
@simplecommand("plotter",
|
||||
aliases = ["pt"],
|
||||
senderLimit = 0,
|
||||
description = "Plot commands")
|
||||
def plotter_command(sender, command, label, args):
|
||||
loc = sender.getLocation()
|
||||
x = loc.getX()
|
||||
z = loc.getZ()
|
||||
plot = Plot.get(x, z)
|
||||
|
||||
if plot:
|
||||
msg(sender, "id: %s" % [plot.idx, plot.idz])
|
||||
msg(sender, "bottom: %s" % [plot.bottomx, plot.bottomz])
|
||||
msg(sender, "top: %s" % [plot.topx, plot.topz])
|
||||
else:
|
||||
msg(sender, "&cThis is not a plot.")
|
||||
|
||||
class Plot:
|
||||
plot_size = 20
|
||||
padding = 3
|
||||
padded_size = plot_size + padding
|
||||
|
||||
def __init__(self, x, z):
|
||||
x = int(x)
|
||||
z = int(z)
|
||||
self.idx = x
|
||||
self.idz = z
|
||||
self.bottomx = x * self.padded_size
|
||||
self.bottomz = z * self.padded_size
|
||||
self.topx = self.bottomx + self.plot_size
|
||||
self.topz = self.bottomz + self.plot_size
|
||||
|
||||
@staticmethod
|
||||
def is_border(x, z):
|
||||
xborder = Plot.plot_size < x % Plot.padded_size < Plot.padded_size
|
||||
zborder = Plot.plot_size < z % Plot.padded_size < Plot.padded_size
|
||||
return xborder or zborder
|
||||
|
||||
@staticmethod
|
||||
def get(x, z):
|
||||
idx = x // Plot.padded_size
|
||||
idz = z // Plot.padded_size
|
||||
return None if Plot.is_border(x, z) else Plot(idx, idz)
|
||||
x = int(sys.argv[1])
|
||||
z = int(sys.argv[2])
|
||||
print "id: %s" % plot_id(x, z)
|
||||
print "base: %s" % base_coords(x, z)
|
||||
print "bounds: %s" % bounds(x, z)
|
||||
|
||||
212
scriptutils.py
Normal file
212
scriptutils.py
Normal file
@@ -0,0 +1,212 @@
|
||||
from helpers import *
|
||||
|
||||
"""
|
||||
Prints server restart message
|
||||
arg 0 timeout
|
||||
arg 1 $(whoami)
|
||||
arg 2: reason
|
||||
"""
|
||||
@hook.command("script_restart")
|
||||
def print_restart(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&2&l=============================================")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&9%s is restarting the server." % args[1])
|
||||
broadcast(None, "&a&lServer is going to restart in %s seconds." % args[0])
|
||||
broadcast(None, "&6&l%s" % " ".join(args[2:]))
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&2&l=============================================")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the server shut down message
|
||||
arg 0 timeout
|
||||
arg 1 $(whoami)
|
||||
arg 2: reason
|
||||
"""
|
||||
@hook.command("script_stop")
|
||||
def print_stop(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&2&l=============================================")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&9%s is shutting down the server." % args[1])
|
||||
broadcast(None, "&a&lServer is going to shut down in %s seconds." % args[0])
|
||||
broadcast(None, "&6&l%s" % " ".join(args[2:]))
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&r")
|
||||
broadcast(None, "&2&l=============================================")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the shut down abort message
|
||||
"""
|
||||
@hook.command("script_stop_abort")
|
||||
def abort_stop(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4&oShut down has been aborted.")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the restart abort message
|
||||
"""
|
||||
@hook.command("script_restart_abort")
|
||||
def abort_restart(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4&oRestart has been aborted.")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the backup started message, saves all worlds and turns off world saving
|
||||
"""
|
||||
@hook.command("script_backup_begin")
|
||||
def print_backup_begin(sender, command, lable, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4 =&2 Starting backup now.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-all")
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-off")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the backup finished message and turns on world saving
|
||||
"""
|
||||
@hook.command("script_backup_end")
|
||||
def print_backup_end(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4 =&2 Backup completed.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the backup error message and turns on world saving
|
||||
"""
|
||||
@hook.command("script_backup_error")
|
||||
def print_backup_error(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4 =&c&l Error while backing up!")
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the world trimming started message and starts trimming
|
||||
"""
|
||||
@hook.command("script_trim")
|
||||
def print_backup_trim(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4 =&3 Deleting all chunks beyond border now.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "wb Creative trim 1000000 15")
|
||||
server.dispatchCommand(server.getConsoleSender(), "wb trim confirm")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the thimming finished message
|
||||
arg 0 size difference of world
|
||||
arg 1: world border trim data
|
||||
"""
|
||||
@hook.command("script_trim_result")
|
||||
def print_backup_trim_res(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&4 =&3 Chunk deletion saved %s (&a%sMB&3)" % (" ".join(args[1:]), args[0]))
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the database backup started message and admin-chat warning
|
||||
"""
|
||||
@hook.command("script_backup_database_begin")
|
||||
def print_backup_db_begin(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&6 =&2 Starting database backup now.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &aLogblock may be unavailable!")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the database dumps compression started message
|
||||
"""
|
||||
@hook.command("script_backup_database_dumps")
|
||||
def print_backup_db_dumps(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &aDumps completed, logblock available again.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &aNow compressing dumps, will take a while...")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the database finished message and backup size in admin-chat
|
||||
arg 0 size of backup
|
||||
"""
|
||||
@hook.command("script_backup_database_end")
|
||||
def print_backup_db_end(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&6 =&2 Databse backup completed.")
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &abackup size: &2%sMB&a." % args[0])
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the database backup error message
|
||||
"""
|
||||
@hook.command("script_backup_database_error")
|
||||
def print_backup_db_error(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&6 =&c&l Error while backing up database!")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the database backup abort message
|
||||
"""
|
||||
@hook.command("script_backup_database_abort")
|
||||
def print_backup_db_abort(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&6 =&2 Database backup aborted.")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the spigot update message
|
||||
"""
|
||||
@hook.command("script_spigot_update")
|
||||
def print_update(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
broadcast(None, "&9 =&2 A new Spigot version has been downloaded!")
|
||||
broadcast(None, "&9 =&2 Update will be applied after the next reboot.")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Prints the admin-chat warning for disk is filled
|
||||
arg 0 fill percentage
|
||||
"""
|
||||
@hook.command("script_disk_filled")
|
||||
def print_disk_filled(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &4&lWARNING:&6 Disk is filled > 96% (" + args[0] + "%)")
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &4 Server will shut down at 98%!")
|
||||
server.dispatchCommand(server.getConsoleSender(), "ac &4 Contact an admin &nimmediately&4!")
|
||||
else:
|
||||
noperm(sender)
|
||||
|
||||
"""
|
||||
Saves all worlds, kicks players and shuts down the server
|
||||
arg 0: reason
|
||||
"""
|
||||
@hook.command("script_shutdown")
|
||||
def shutdown(sender, command, label, args):
|
||||
if not is_player(sender):
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-all")
|
||||
server.dispatchCommand(server.getConsoleSender(), "kickall %s" % " ".join(args))
|
||||
server.dispatchCommand(server.getConsoleSender(), "stop")
|
||||
else:
|
||||
noperm(sender)
|
||||
175
setup.sh
Executable file
175
setup.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# exit on failure
|
||||
set -e
|
||||
|
||||
for cmd in curl java unzip git pip; do
|
||||
if ! which -s "$cmd"; then
|
||||
tput setf 4 >&2
|
||||
echo "Error: please install '$cmd' to proceed" >&2
|
||||
tput sgr0 >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "> This will only set up Spigot and all the plugins, configuration files are still up to you to manage"
|
||||
echo -e "> Press enter to coninue"
|
||||
read
|
||||
|
||||
mkdir -v "redstoner"
|
||||
cd "redstoner"
|
||||
|
||||
mkdir -v "server"
|
||||
|
||||
mkdir -v "build"
|
||||
cd "build"
|
||||
|
||||
echo -e "\n> Downloading Spigot build tools"
|
||||
curl --progress-bar -Lo "buildtools.jar" "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar"
|
||||
|
||||
echo -e "\n> Building Spigot, this will take a while ..."
|
||||
java -jar BuildTools.jar > /dev/null
|
||||
|
||||
cp -v spigot-*.jar "../server/spigot.jar"
|
||||
rm spigot-*.jar
|
||||
cd "../server/"
|
||||
|
||||
mkdir -v "plugins"
|
||||
cd "plugins"
|
||||
|
||||
echo ">> Downloading essentials.jar ..."
|
||||
curl --progress-bar -Lo "essentials.jar" "https://github.com/RedstonerServer/Essentials/releases/download/stable-2.9.6-REDSTONER/Essentials-2.x-REDSTONER.jar"
|
||||
echo ">> Downloading essentialschat.jar ..."
|
||||
curl --progress-bar -Lo "essentialschat.jar" "https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsChat/target/EssentialsChat-2.x-SNAPSHOT.jar"
|
||||
echo ">> Downloading imageonmap.jar ..."
|
||||
curl --progress-bar -Lo "imageonmap.jar." "https://dev.bukkit.org/media/files/772/680/imageonmap.jar"
|
||||
echo ">> Downloading logblock.jar ..."
|
||||
curl --progress-bar -Lo "logblock.jar." "https://dev.bukkit.org/media/files/757/963/LogBlock.jar"
|
||||
echo ">> Downloading logblockquestioner.zip ..."
|
||||
curl --progress-bar -Lo "logblockquestioner.zip" "https://cloud.github.com/downloads/DiddiZ/LogBlockQuestioner/LogBlockQuestioner%20v0.03.zip"
|
||||
echo ">> Downloading multiverse-core.jar ..."
|
||||
curl --progress-bar -Lo "multiverse-core.jar" "https://dev.bukkit.org/media/files/588/781/Multiverse-Core-2.4.jar"
|
||||
echo ">> Downloading multiverse-portals.jar ..."
|
||||
curl --progress-bar -Lo "multiverse-portals.jar." "https://dev.bukkit.org/media/files/588/790/Multiverse-Portals-2.4.jar"
|
||||
echo ">> Downloading multiverse-netherportals.jar ..."
|
||||
curl --progress-bar -Lo "multiverse-netherportals.jar." "https://dev.bukkit.org/media/files/589/64/Multiverse-NetherPortals-2.4.jar"
|
||||
echo ">> Downloading multiverse-inventories.jar ..."
|
||||
curl --progress-bar -Lo "multiverse-inventories.jar." "https://dev.bukkit.org/media/files/663/303/Multiverse-Inventories-2.5.jar"
|
||||
echo ">> Downloading permissionsex.jar ..."
|
||||
curl --progress-bar -Lo "permissionsex.jar" "https://dev.bukkit.org/media/files/882/992/PermissionsEx-1.23.3.jar"
|
||||
echo ">> Downloading plotme.jar ..."
|
||||
curl --progress-bar -Lo "plotme.jar" "http://ci.worldcretornica.com/job/PlotMe-Core/244/artifact/target/PlotMe-Core.jar"
|
||||
echo ">> Downloading plotme-defaultgenerator.jar ..."
|
||||
curl --progress-bar -Lo "plotme-defaultgenerator.jar" "http://ci.worldcretornica.com/job/PlotMe-DefaultGenerator/83/artifact/target/PlotMe-DefaultGenerator.jar"
|
||||
echo ">> Downloading serversigns.jar ..."
|
||||
curl --progress-bar -Lo "serversigns.jar." "https://dev.bukkit.org/media/files/876/381/ServerSigns.jar"
|
||||
echo ">> Downloading redstoneclockdetector.jar ..."
|
||||
curl --progress-bar -Lo "redstoneclockdetector.jar." "https://dev.bukkit.org/media/files/577/253/RedstoneClockDetector.jar"
|
||||
echo ">> Downloading vault.jar ..."
|
||||
curl --progress-bar -Lo "vault.jar" "https://dev.bukkit.org/media/files/837/976/Vault.jar"
|
||||
echo ">> Downloading worldborder.jar ..."
|
||||
curl --progress-bar -Lo "worldborder.jar." "https://dev.bukkit.org/media/files/883/629/WorldBorder.jar"
|
||||
echo ">> Downloading worldguard.jar ..."
|
||||
curl --progress-bar -Lo "worldguard.jar." "https://github.com/RedstonerServer/WorldGuard/releases/download/6.0.0-redstoner/worldguard-6.0.0-REDSTONER.jar"
|
||||
echo ">> Downloading worldedit.jar ..."
|
||||
curl --progress-bar -Lo "worldedit.jar" "https://dev.bukkit.org/media/files/880/435/worldedit-bukkit-6.1.jar"
|
||||
echo ">> Downloading pythonpluginloader.jar ..."
|
||||
curl --progress-bar -Lo "pythonpluginloader.jar" "https://bamboo.gserv.me/browse/PLUG-PYPL/latestSuccessful/artifact/JOB1/Version-agnostic-jar/PyPluginLoader.jar"
|
||||
|
||||
echo -e "\n> Unpacking LogBlockQuestioner"
|
||||
unzip -q "logblockquestioner.zip" "LogBlockQuestioner.jar"
|
||||
rm "logblockquestioner.zip"
|
||||
mv -v "LogBlockQuestioner.jar" "logblockquestioner.jar."
|
||||
|
||||
echo -e "\n> Pulling redstoner-utils ..."
|
||||
git clone -q "git@github.com:RedstonerServer/redstoner-utils.git" "redstoner-utils.py.dir" > /dev/null
|
||||
|
||||
echo -e "\n> Installing dependencies"
|
||||
pip install passlib
|
||||
|
||||
echo -e "\n> All plugins downloaded"
|
||||
|
||||
cd "redstoner-utils.py.dir"
|
||||
echo -e "\n> Duplicating sample files"
|
||||
for file in ls ./*.example; do
|
||||
cp -v "$file" "$(echo "$file" | rev | cut -d "." -f 2- | rev)"
|
||||
done
|
||||
|
||||
cd "../.."
|
||||
|
||||
mkdir -v "lib"
|
||||
cd "lib"
|
||||
|
||||
echo -e "\n> Downloading MySQL Connector ..."
|
||||
curl --progress-bar -Lo "mysql-connector.zip" "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.36.zip"
|
||||
echo "> Extracting MySQL Connector"
|
||||
unzip -p mysql-connector.zip "mysql-connector-java-5.1.36/mysql-connector-java-5.1.36-bin.jar" > mysql-connector.jar
|
||||
rm "mysql-connector.zip"
|
||||
|
||||
cd ".."
|
||||
|
||||
echo -e "\n> Creating startup script"
|
||||
|
||||
cat > start.sh <<EOF
|
||||
#!/usr/bin/env bash
|
||||
java -Xms512m -Xmx1g -jar spigot.jar
|
||||
EOF
|
||||
chmod +x start.sh
|
||||
|
||||
port="25565"
|
||||
re='^[0-9]+$'
|
||||
if [[ "$1" =~ $re ]]; then
|
||||
port="$1"
|
||||
fi
|
||||
|
||||
echo "> Setting port to $port"
|
||||
echo "> Generating server.properties"
|
||||
|
||||
cat > server.properties <<EOF
|
||||
#Minecraft server properties
|
||||
#Sat Jul 25 15:42:21 CEST 2015
|
||||
spawn-protection=16
|
||||
generator-settings=
|
||||
force-gamemode=false
|
||||
allow-nether=true
|
||||
gamemode=1
|
||||
broadcast-console-to-ops=true
|
||||
enable-query=false
|
||||
player-idle-timeout=0
|
||||
difficulty=1
|
||||
spawn-monsters=true
|
||||
op-permission-level=4
|
||||
resource-pack-hash=
|
||||
announce-player-achievements=true
|
||||
pvp=true
|
||||
snooper-enabled=true
|
||||
level-type=FLAT
|
||||
hardcore=false
|
||||
enable-command-block=false
|
||||
max-players=20
|
||||
network-compression-threshold=256
|
||||
max-world-size=29999984
|
||||
server-port=$port
|
||||
server-ip=
|
||||
spawn-npcs=true
|
||||
allow-flight=false
|
||||
level-name=world
|
||||
view-distance=10
|
||||
resource-pack=
|
||||
spawn-animals=true
|
||||
white-list=false
|
||||
generate-structures=true
|
||||
online-mode=true
|
||||
max-build-height=256
|
||||
level-seed=
|
||||
use-native-transport=true
|
||||
motd=Redstoner dev server
|
||||
enable-rcon=false
|
||||
EOF
|
||||
|
||||
echo -e "> Generating eula.txt"
|
||||
echo "eula=true" > eula.txt
|
||||
|
||||
echo -e "\n> $(tput setf 2)All Done! $(tput sgr0)Don't forget to configure plugins for your needs."
|
||||
echo "> Run redstoner/server/start.sh to start the server"
|
||||
echo "> Our plugins are in redstoner/server/plugins/redstoner-utils.py.dir"
|
||||
44
snowbrawl.py
44
snowbrawl.py
@@ -49,7 +49,7 @@ class Arena(object):
|
||||
self.match_goal = None # amount of deaths or time until the match ends (depends on arena_type)
|
||||
self.arena_type = None # arena type (death or time)
|
||||
self.explosion_damage = None
|
||||
|
||||
|
||||
self.player_stats = {}
|
||||
self.players = Queue()
|
||||
self.spawn_location = []
|
||||
@@ -60,7 +60,7 @@ class Arena(object):
|
||||
self.corner1 = None # The corner1 given by the player (really bad for 3D position compare)
|
||||
self.corner2 = None # The corner2 given by the player (really bad for 3D position compare)
|
||||
self.tpp = None # The top, positive x, positive z corner
|
||||
self.bnn = None # The bottom, negative x, negative z corner
|
||||
self.bnn = None # The bottom, negative x, negative z corner
|
||||
|
||||
#set corners of arena
|
||||
def set_corner(self, sender, type):
|
||||
@@ -75,21 +75,21 @@ class Arena(object):
|
||||
#Compares the corner1 and corner2 locations and figures out tpp and bnn so that we dont have to do it everytime we run in_arena()
|
||||
def update_corner_points(self):
|
||||
self.tpp = None
|
||||
self.bnn = None
|
||||
self.bnn = None
|
||||
if self.corner1 == None or self.corner2 == None:
|
||||
return
|
||||
corn1 = self.corner1.get_location()
|
||||
corn2 = self.corner2.get_location()
|
||||
if not corn1.getWorld().getName() == corn2.getWorld().getName():
|
||||
return
|
||||
|
||||
|
||||
top = corn1.y if corn1.y > corn2.y else corn2.y
|
||||
bottom = corn1.y if corn1.y < corn2.y else corn2.y
|
||||
pos_x = corn1.x if corn1.x > corn2.x else corn2.x
|
||||
pos_z = corn1.z if corn1.z > corn2.z else corn2.z
|
||||
neg_x = corn1.x if corn1.x < corn2.x else corn2.x
|
||||
neg_z = corn1.z if corn1.z < corn2.z else corn2.z
|
||||
|
||||
|
||||
self.tpp = Coords(corn1.getWorld(), pos_x, top, pos_z, 0, 0)
|
||||
self.bnn = Coords(corn2.getWorld(), neg_x, bottom, neg_z, 0, 0)
|
||||
|
||||
@@ -118,9 +118,9 @@ class Arena(object):
|
||||
self.start_match()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
#remove a player from the queue
|
||||
def remove_player(self, player):
|
||||
def remove_player(self, player):
|
||||
if self.queue.contains(player):
|
||||
self.queue.remove(player)
|
||||
return True
|
||||
@@ -132,7 +132,7 @@ class Arena(object):
|
||||
return False
|
||||
loc_tpp = self.tpp.get_location()
|
||||
loc_bnn = self.bnn.get_location()
|
||||
|
||||
|
||||
if loc.y > loc_tpp.y:
|
||||
return False
|
||||
if loc.y < loc_bnn.y:
|
||||
@@ -179,12 +179,12 @@ class Arena(object):
|
||||
alist[i] = alist[i+1]
|
||||
alist[i+1] = temp
|
||||
return alist
|
||||
|
||||
|
||||
@make_synchronized #Jython synchronized block
|
||||
def end_match(self): #End match, sort the players and print the 3 players with least amount of deaths
|
||||
|
||||
|
||||
sorted_list = self.bubbleSort(self.players.read())
|
||||
|
||||
|
||||
for player in self.players.read():
|
||||
if player.isOnline():
|
||||
loc = self.sign_location[0].get_location().get_location()
|
||||
@@ -256,7 +256,7 @@ class Arena(object):
|
||||
|
||||
def get_click_signs(self):
|
||||
return self.sign_click
|
||||
|
||||
|
||||
#Check if player is in the queue
|
||||
def in_queue(self,player):
|
||||
if self.queue.contains(player):
|
||||
@@ -307,7 +307,7 @@ class Arena(object):
|
||||
sign.get_location().set_location(location)
|
||||
break
|
||||
|
||||
#Remove location out of location
|
||||
#Remove location out of location
|
||||
def delete_location(self, name, type):
|
||||
if type == "spawn":
|
||||
for spawn in self.spawn_location[:]:
|
||||
@@ -472,16 +472,16 @@ class Queue(object):
|
||||
|
||||
def __init__(self):
|
||||
self.queue = []
|
||||
|
||||
|
||||
#Appends to queue
|
||||
def put(self,args):
|
||||
self.queue.append(args)
|
||||
|
||||
|
||||
#Returns the first item in the queue and removes it
|
||||
def get(self):
|
||||
if len(self.queue) > 0:
|
||||
return self.queue.pop(0)
|
||||
|
||||
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -498,7 +498,7 @@ class Queue(object):
|
||||
if player in self.queue:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
#Clear the queue
|
||||
def clear(self):
|
||||
self.queue = []
|
||||
@@ -532,7 +532,7 @@ class timings_runnable(Runnable):
|
||||
self.arena = arena
|
||||
|
||||
def run(self):
|
||||
self.arena.end_match()
|
||||
self.arena.end_match()
|
||||
|
||||
#timings thread to end arenas if their type is time
|
||||
def timings():
|
||||
@@ -545,10 +545,10 @@ def timings():
|
||||
if arena.start_time + arena.match_goal < current_time:
|
||||
timing = timings_runnable(arena)
|
||||
server.getScheduler().runTask(server.getPluginManager().getPlugin("RedstonerUtils"), timing)
|
||||
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
|
||||
timingsThread = threading.Thread(target = timings)
|
||||
timingsThread.daemon = True #Thread dies if main thread dies
|
||||
timingsThread.start()
|
||||
@@ -561,7 +561,7 @@ timingsThread.start()
|
||||
# Events
|
||||
##############################################################################################
|
||||
|
||||
@hook.event("player.PlayerMoveEvent", "high")
|
||||
@hook.event("player.PlayerMoveEvent", "low")
|
||||
def onMove(event):
|
||||
if event.getPlayer().getWorld().getName() != "minigames":
|
||||
return
|
||||
@@ -663,7 +663,7 @@ def on_quit(event):
|
||||
|
||||
##############################################################################################
|
||||
# Command handling
|
||||
##############################################################################################
|
||||
##############################################################################################
|
||||
|
||||
|
||||
def create_arena(sender, args):
|
||||
|
||||
Reference in New Issue
Block a user