Guest User

Punishment yml

a guest
Sep 23rd, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.03 KB | None | 0 0
  1. # █▀▀█ █░░█ █▀▀▄ ░▀░ █▀▀ █░░█ █▀▄▀█ █▀▀ █▀▀▄ ▀▀█▀▀
  2. # █░░█ █░░█ █░░█ ▀█▀ ▀▀█ █▀▀█ █░▀░█ █▀▀ █░░█ ░░█░░
  3. # █▀▀▀ ░▀▀▀ ▀░░▀ ▀▀▀ ▀▀▀ ▀░░▀ ▀░░░▀ ▀▀▀ ▀░░▀ ░░▀░░
  4. #
  5. # author: HiiqhFive
  6. # version: 1.0.000
  7.  
  8. options:
  9. path_punishments: plugins/Punishments/config.yml
  10. version: 1.0.000
  11.  
  12. # setting up your SQL-database connection.
  13. # script options:
  14. # $ db url jdbc:mysql://ms1215.nitrado.net:3306/ni359528_1_DB
  15. # $ db username ni359528_1_DB
  16. # $ db password zb7ml2YN
  17.  
  18. function createConfig(~: INT=0):
  19. set yaml value "punish.servername" of file "{@path_punishments}" to "SERVERNAME"
  20. set yaml value "punish.tag" of file "{@path_punishments}" to "SVRNM"
  21. set yaml value "punish.permission" of file "{@path_punishments}" to "punishment.execute"
  22. set yaml value "punish.log-executed-punishment" of file "{@path_punishments}" to true
  23. set yaml value "punish.log-path" of file "{@path_punishments}" to "plugins/Punishments/punishments.txt"
  24. add "---------------- <SERVERNAME> ----------------" to yaml list "punish.alert-for-target" of file "{@path_punishments}"
  25. add "You were punished by <EXECUTOR> due to <REASON>." to yaml list "punish.alert-for-target" of file "{@path_punishments}"
  26. add "---------------- <SERVERNAME> ----------------" to yaml list "punish.alert-for-target" of file "{@path_punishments}"
  27. set yaml value "punish.gui.gui-name" of file "{@path_punishments}" to "Punish: <TARGET>"
  28. set yaml value "punish.gui.rows" of file "{@path_punishments}" to 1
  29. set yaml value "punish.gui.slots.0.item" of file "{@path_punishments}" to "redstone"
  30. set yaml value "punish.gui.slots.0.title" of file "{@path_punishments}" to "Spam"
  31. set yaml value "punish.gui.slots.0.lore" of file "{@path_punishments}" to "Punish the player <TARGET> for Spam."
  32. add "mute <TARGET>" to yaml list "punish.gui.slots.0.cmds" of file "{@path_punishments}"
  33. add "kick <TARGET> spam" to yaml list "punish.gui.slots.0.cmds" of file "{@path_punishments}"
  34. set yaml value "punish.gui.slots.1.item" of file "{@path_punishments}" to "iron ingot"
  35. set yaml value "punish.gui.slots.1.title" of file "{@path_punishments}" to "Capslock"
  36. set yaml value "punish.gui.slots.1.lore" of file "{@path_punishments}" to "Punish the player <TARGET> for Capslock."
  37. add "mute <TARGET>" to yaml list "punish.gui.slots.1.cmds" of file "{@path_punishments}"
  38. add "kick <TARGET> spam" to yaml list "punish.gui.slots.1.cmds" of file "{@path_punishments}"
  39.  
  40. function loadScript(~: INT=0):
  41. if existence of "{@path_punishments}" is false:
  42. createConfig()
  43. set {punishments::servername} to yaml value "punish.servername" of file "{@path_punishments}"
  44. set {punishments::tag} to yaml value "punish.tag" of file "{@path_punishments}"
  45. set {punishments::inventory_name} to yaml value "punish.gui.gui-name" of file "{@path_punishments}"
  46. set {punishments::permission} to yaml value "punish.permission" of file "{@path_punishments}"
  47.  
  48. function getGUI(executor: player, target: offline player):
  49. set {punishments::%{_executor}%::target} to {_target}
  50. set {_title} to yaml value "punish.gui.gui-name" of file "{@path_punishments}"
  51. replace all "<TARGET>" in {_title} with "%{_target}%"
  52. set {_rows} to yaml value "punish.gui.rows" of file "{@path_punishments}"
  53. open chest with {_rows} rows named "%{_title}%" to {_executor}
  54. set {_items::*} to yaml nodes "punish.gui.slots" of file "{@path_punishments}"
  55. wait a tick
  56. loop {_items::*}:
  57. set {_slot} to loop-value parsed as integer
  58. set {_item} to yaml value "punish.gui.slots.%loop-value%.item" of file "{@path_punishments}"
  59. set {_item} to {_item} parsed as item
  60. set {_title} to yaml value "punish.gui.slots.%loop-value%.title" of file "{@path_punishments}"
  61. set {_lore} to yaml value "punish.gui.slots.%loop-value%.lore" of file "{@path_punishments}"
  62. replace all "<TARGET>" in {_lore} with "%{_target}%"
  63. set slot {_slot} of {_executor}'s current inventory to {_item} named "&c%{_title}%" with lore "&7%{_lore}%"
  64.  
  65. function logExecutedPunishment(executor: player, target: offline player, reason: text):
  66. set {_settings} to yaml value "punish.log-executed-punishment" of file "{@path_punishments}"
  67. {_settings} is true:
  68. set {_path} to yaml value "punish.log-path" of file "{@path_punishments}"
  69. existence of "%{_path}%" is false:
  70. create file "%{_path}%"
  71. write "[%now%] %{_executor}% punished %{_target}% for %{_reason}%." to "%{_path}%"
  72. add "[%now%] ""%{_reason}%"" by %{_executor}%." to {records::%{_target}%::*}
  73.  
  74. function executeCommands(executor: player, slot: integer) :: objects:
  75. set {_commands::*} to yaml list "punish.gui.slots.%{_slot}%.cmds" of file "{@path_punishments}"
  76. set {_alerts::*} to yaml list "punish.alert-for-target" of file "{@path_punishments}"
  77. loop {_alerts::*}:
  78. set {_alert} to loop-value
  79. set {_reason} to yaml value "punish.gui.slots.%{_slot}%.title" of file "{@path_punishments}"
  80. replace all "<SERVERNAME>" in {_alert} with "%{punishments::servername}%"
  81. replace all "<EXECUTOR>" in {_alert} with "%{_executor}%"
  82. replace all "<REASON>" in {_alert} with "%{_reason}%"
  83. send "%{_alert}%" to {punishments::%{_executor}%::target}
  84. logExecutedPunishment({_executor}, {punishments::%{_executor}%::target}, {_reason})
  85. wait a second
  86. loop {_commands::*}:
  87. set {_execute} to loop-value
  88. replace all "<TARGET>" in {_execute} with "%{punishments::%{_executor}%::target}%"
  89. execute {_executor} command "%{_execute}%"
  90. on load:
  91. loadScript()
  92.  
  93. on inventory click:
  94. set {_gui-name} to {punishments::inventory_name}
  95. replace all "<TARGET>" in {_gui-name} with "%{punishments::%player%::target}%"
  96. if inventory name of player's current inventory contains "%{_gui-name}%":
  97. cancel the event
  98. clicked item is not air
  99. set {_slot} to "%clicked slot%" parsed as integer
  100. executeCommands(player, {_slot})
  101. close player's inventory
  102. send "%{punishments::tag}% | You're punishment was executed."
  103.  
  104. command /punish [<offline player>]:
  105. permission: {punishment::permission}
  106. permission message: You don't have the required permission to use that command.
  107. trigger:
  108. arg 1 is set:
  109. getGUI(player, arg 1)
  110. else:
  111. send "%{punishments::tag}% | Please name a target."
  112.  
  113. command /records [<offline player>]:
  114. trigger:
  115. arg 1 is not set:
  116. size of {records::%player%::*} is more than 0:
  117. send "%{punishments::tag}% | You have the following records:"
  118. loop {records::%player%::*}:
  119. send "%{punishments::tag}% | %loop-value%"
  120. else:
  121. send "%{punishments::tag}% | You don't have any records."
  122. else:
  123. player has permission "%{punishments::permission}%":
  124. size of {records::%arg 1%::*} is more than 0:
  125. send "%{punishments::tag}% | %arg 1% has the following records:"
  126. loop {records::%arg 1%::*}:
  127. send "%{punishments::tag}% | %loop-value%"
  128. else:
  129. send "%{punishments::tag}% | %arg 1% doesn't have any records."
  130. else:
  131. execute player command "records"
Add Comment
Please, Sign In to add comment