I would like a plugin that when typing /kn kill will kill the closest player to a configured point like x:0.0, y:0.0 and z:0.0 Configurations: world-name-here: __coordinates: ____x: 0 ____y: 63 ____z: 0 __enable-y-axis: true __# This toggles whether or not /killnear will check the player's y-axis to see if he's closest multiple-worlds-are-also-allowed: __coordinates: ____x: 300 ____y: 63 ____z: 200 __enable-y-axis: false Math for enable-y-axis: true: x = playerX - configuredX y = playerY - configuredY z = playerZ - configuredZ all = x^2 + y^2 + z^2 distance = √all Math for enable-y-axis: false: x = playerX - configuredX z = playerZ - configuredZ all = x^2 + z^2 distance = √all The player with the lowest distance value gets killed. Bob's distance: 100 - not killed Carl's distance: 80 - not killed Jeff's distance: 40 - KILLED Commands: /kn kill - kills the player closest to a configured point /kn reload - reloads the config file /kn <world[optional]> setpoint <x> <y> <z> /kn <world[optional]> toggleyaxis /kn info <world[optional]> /kn help Permissions: killnear.admin.reload - reloads the killnear config file killnear.admin.setpoint - lets the player set the area killnear.admin.toggleyaxis - lets the player toggle y axis checking killnear.use - lets the player use /killnear killnear.bypass - makes it so the player doesn't get affected by /killnear killnear.help - brings up a help menu for killnear commands killnear.info - brings up information about the world's killnear configurations such as the killnear point coordinates and whether or not y-axis-checking is enabled or disabled
What happens if 2 players have the same distance, kill them both? Why don't just use x = playerX - configuredX y = playerY - configuredY z = playerZ - configuredZ all = x^2 + y^2 + z^2 distance = √all Short version: qrt[ (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2 ] instead of your formule? it is easier to implement and I think it is more logical.
@jokie666 Bukkit also has a distance method. And how big is the chance that 2 players are at exactly the same distance?
@timtower Highly unlikely, but it's good to be extra safe and add a random kill method if two players are the exact same distance away from the set point.
@timtower I noticed the distance method of bukkit and it is fine to use it when the y axis is enabled. If the y axis is disabled I need to modify it slightly. I only put the math there to explain how it would be calculated The chance of 2 players having the same distance is small and it wouldn't break the plugin. I just got teached to think about possible errors before starting programming @kirbsrob here you go, it should work. I only have 1 minecraft account to test with but reply to me if there are any bugs https://www.dropbox.com/s/ndryqnl31urito1/KillNear.jar?dl=0