TripwirehookDupeFix.sk

Created by MattyHD0

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

options:
	prefix: &4&lTDF: &r

	cancelPhysics: &ePossible duplicate/place attempt, player(s) nearby: &c%{_atd.dupeList::*}% &e(%{playerNearbyDetection}%&e blocks)
	noNearbyPlayers: &cNone

	noPermission: &cYou do not have permissions to execute this command

	notifications: true

	version: 1.0.0

variables:
	playersNearbyDetection = 10






command /tripwirehookdupefix [<text>]:
	aliases: tdf
	permission: tdf.admin
	permission message: {@noPermission}
	trigger:
		if arg-1 is "version":
			send "&a%script% &fversion &a{@version}"
			send "Fix a minecraft bug that makes it possible to duplicate tripwire hooks"
			send "&fAuthor: &aMattyHD0"
		else if arg-1 is "reload":
			execute player command "sk reload %script%"
		else:
			send "{@prefix}&cThat subcommand does not exist"
			send "&c/tdf version"
			send "&c/tdf reload"

on block physics:
	if event-block is tripwire hook:
		set {_c} to event-block's location
		if event-block's facing is north:
			add 1 to {_c}'s z-coordinate
		else if event-block's facing is east:
			remove 1 from {_c}'s x-coordinate
		else if event-block's facing is south:
			remove 1 from {_c}'s z-coordinate
		else if event-block's facing is west:
			add 1 to {_c}'s x-coordinate
		if block at {_c} is trapdoor:
			set {_atd.detected} to true
	if {_atd.detected} is true:
		cancel the event
		set block at event-block to air
		loop all players in radius {playersNearbyDetection} of event-block:
			add loop-player's name to {_atd.dupeList::*}
		if {_atd.dupeList::*} is not set:
			set {_atd.dupeList::*} to "{@noNearbyPlayers}"
		if {@notifications} is true:
			loop all players:
				send "{@prefix}{@cancelPhysics}" to loop-player if loop-player has permission "tdf.notify"
		else if {@notifications} is false:
			stop
		else:
			loop all players:
				send "{@prefix}&cError: ""notifications"" is not specified as true or false in TripwirehookDupeFix configuration" to loop-player if loop-player has permission "tdf.notify"