CommandHelper

CommandHelper

46.5k Downloads

location_shift() world parameter weird behaviour

LadyCailinBot opened this issue ยท 1 comments

commented

CMDHELPER-3050 - Reported by Pieter12345

Current workings:

  • locationArray location_shift(location_from, location_to, distance)
  • Returns the location, traveling the given distance from location_from to location_to. Throws a RangeException when the distance exceeds the maximum 32 bits value of an integer.
  • Throws: InvalidWorldException, FormatException, RangeException.

Problem/bug/weird behaviour:
The function does not throw an error if location_from[world] != location_to[world]. Instead, it just always uses location_from[world]. This could be intended, but it also throws an error when the location_to[world] is not supplied. My suggestion is either to remove the location_to[world] requirement or check if both locations are in the same world and throw an exception when that's not the case.

I'm using CommandHelper 3.3.1 SNAPSHOT build 2837.

PS: I'm not sure if this should be a bug or an enhancement. I've labeled it as a minor bug for now.

commented

Comment by PseudoKnight

Okay, I fixed the exception when a world isn't provided to location_to, and updated the docs more.

And since I had a hard time finding uses for this function, I also let us use doubles instead of just integers for the distance, including negative values. These were odd restrictions that limited its utility.