mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #267 from speedxx/development
fix exceptions, properly teleport player in /ride
This commit is contained in:
commit
f42e047723
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,7 +16,9 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Ride on the top of the specified player.", usage = "/<command> <playername | mode <normal | off | ask>>")
|
@CommandParameters(description = "Ride on the top of the specified player.", usage = "/<command> <playername | mode <normal | off | ask>>")
|
||||||
public class Command_ride extends FreedomCommand
|
public class Command_ride extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Map<Player, Player> RIDE_REQUESTS = new HashMap<>(); // requested, requester
|
private final Map<Player, Player> RIDE_REQUESTS = new HashMap<>(); // requested, requester
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -40,6 +41,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
msg("You don't have a request currently.");
|
msg("You don't have a request currently.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||||
if (requester == null)
|
if (requester == null)
|
||||||
{
|
{
|
||||||
@ -47,8 +49,15 @@ public class Command_ride extends FreedomCommand
|
|||||||
RIDE_REQUESTS.remove(playerSender);
|
RIDE_REQUESTS.remove(playerSender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Request accepted.");
|
msg("Request accepted.");
|
||||||
requester.sendMessage(ChatColor.GRAY + "Your request has been accepted.");
|
requester.sendMessage(ChatColor.GRAY + "Your request has been accepted.");
|
||||||
|
|
||||||
|
if (requester.getWorld() != playerSender.getWorld())
|
||||||
|
{
|
||||||
|
requester.teleport(playerSender);
|
||||||
|
}
|
||||||
|
|
||||||
playerSender.addPassenger(requester);
|
playerSender.addPassenger(requester);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -73,6 +82,8 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
if (args[0].equalsIgnoreCase("mode"))
|
if (args[0].equalsIgnoreCase("mode"))
|
||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
||||||
@ -84,6 +95,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0], true);
|
final Player player = getPlayer(args[0], true);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -133,17 +145,11 @@ public class Command_ride extends FreedomCommand
|
|||||||
|
|
||||||
if (player.getWorld() != playerSender.getWorld())
|
if (player.getWorld() != playerSender.getWorld())
|
||||||
{
|
{
|
||||||
msg("Player is in another world. (" + player.getWorld().getName() + ")");
|
playerSender.teleport(player);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Location loc = player.getLocation();
|
|
||||||
playerSender.teleport(new Location(loc.getWorld(),loc.getX(), loc.getY(), loc.getZ()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.addPassenger(playerSender);
|
player.addPassenger(playerSender);
|
||||||
|
msg(player, playerSender.getName() + " is now riding you, run /eject to eject them.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,30 +18,36 @@ public class Command_stopsound extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
Sound sound = Sound.valueOf(args[0].toUpperCase());
|
Sound sound = null;
|
||||||
if (sound != null)
|
|
||||||
|
for (Sound loop : Sound.values())
|
||||||
{
|
{
|
||||||
playerSender.stopSound(sound);
|
if (loop != null && loop.name().equalsIgnoreCase(args[0]))
|
||||||
msg("Stopped all " + sound.name() + " sounds", ChatColor.GREEN);
|
{
|
||||||
|
sound = Sound.valueOf(args[0].toUpperCase());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if (sound == null)
|
||||||
{
|
{
|
||||||
msg(args[0] + " is not a valid sound.", ChatColor.RED);
|
msg(args[0] + " is not a valid sound.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerSender.stopSound(sound);
|
||||||
|
msg("Stopped all " + sound.name() + " sounds", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
for (Sound sound : Sound.values())
|
for (Sound sound : Sound.values())
|
||||||
{
|
{
|
||||||
playerSender.stopSound(sound);
|
playerSender.stopSound(sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Stopped all sounds.", ChatColor.GREEN);
|
msg("Stopped all sounds.", ChatColor.GREEN);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user