summaryrefslogtreecommitdiff
path: root/tag.py
diff options
context:
space:
mode:
authorNEMESIS13cz <seke94@seznam.cz>2015-09-04 20:51:28 +0200
committerNEMESIS13cz <seke94@seznam.cz>2015-09-04 20:51:28 +0200
commitaa3f76e897cf44481e7e1db13fff396ea7799566 (patch)
tree6e29da56435c9d415b8563fa5a6fc717989f393b /tag.py
parent75a78dfef090227720d1675cf799ee511ebb1452 (diff)
Added note deletion in tag
Diffstat (limited to 'tag.py')
-rw-r--r--tag.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/tag.py b/tag.py
index 78a51fd..0a312aa 100644
--- a/tag.py
+++ b/tag.py
@@ -1,6 +1,7 @@
from helpers import *
add_perm = "utils.tag.add"
+del_perm = "utils.tag.del"
check_perm = "utils.tag.check"
data = open_json_file("tag", {})
@@ -24,12 +25,34 @@ def command(sender, command, label, args):
msg(sender, "&a-&c Usage: /tag check <name>")
else:
noperm(sender)
+ elif str(args[0]) == "del":
+ if sender.hasPermission(del_perm):
+ if len(args) == 3:
+ delete(sender, args[1:])
+ else:
+ msg(sender, "&a-&c Usage: /tag del <id>")
else:
- msg(sender, "&a-&c Unknown subcommand! (add, check)")
+ msg(sender, "&a-&c Unknown subcommand! (add, check, del)")
else:
msg(sender, "&a&c Usage: /tag add/check")
return True
+def delete(sender, args):
+ player = server.getPlayer(args[0])
+ uuid = uid(player)
+ try:
+ if data[uuid] == None:
+ pass
+ except:
+ msg(sender, "&a-&e There are no notes about this player")
+ return
+ if int(args[1]) - 1 >= len(data[uuid]):
+ msg(sender, "&a-&c Id of note is out of range")
+ return
+ del (data[uuid])[int(args[1]) - 1]
+ save_json_file("tag", data)
+ msg(sender, "&a-&e Deleted note at %s" % args[1])
+
def add(sender, args):
player = server.getPlayer(args[0])
uuid = uid(player)
@@ -46,8 +69,10 @@ def check(sender, args):
player = server.getPlayer(args[0])
uuid = uid(player)
try:
+ num = 0
for tag in data[uuid]:
- msg(sender, "&a-&e %s" % str(tag))
+ num += 1
+ msg(sender, "&a-&e %s: %s" % (str(num), str(tag)))
except:
msg(sender, "&a-&e There are no notes about this player")