Exel

Untitled

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