mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #292 from speedxx/development
fix ride request expire messages
This commit is contained in:
commit
49f7c6e8c3
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimerTask;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -12,6 +11,7 @@ import org.bukkit.ChatColor;
|
|||||||
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;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@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>>")
|
||||||
@ -39,7 +39,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||||
{
|
{
|
||||||
msg("You don't have a request currently.");
|
msg("You don't have any pending requests.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
PaperLib.teleportAsync(requester, playerSender.getLocation());
|
PaperLib.teleportAsync(requester, playerSender.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RIDE_REQUESTS.remove(playerSender);
|
||||||
playerSender.addPassenger(requester);
|
playerSender.addPassenger(requester);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ public class Command_ride extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!RIDE_REQUESTS.containsKey(playerSender))
|
if (!RIDE_REQUESTS.containsKey(playerSender))
|
||||||
{
|
{
|
||||||
msg("You don't have a request currently.");
|
msg("You don't have any pending requests.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player requester = RIDE_REQUESTS.get(playerSender);
|
Player requester = RIDE_REQUESTS.get(playerSender);
|
||||||
@ -125,22 +126,23 @@ public class Command_ride extends FreedomCommand
|
|||||||
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
|
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you.");
|
||||||
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.");
|
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.");
|
||||||
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
|
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
|
||||||
player.sendMessage(ChatColor.AQUA + "Request will expire after 30 seconds.");
|
player.sendMessage(ChatColor.AQUA + "Request will expire in 30 seconds.");
|
||||||
RIDE_REQUESTS.put(player, playerSender);
|
RIDE_REQUESTS.put(player, playerSender);
|
||||||
timer.schedule(new TimerTask()
|
|
||||||
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!RIDE_REQUESTS.containsKey(player))
|
if (!RIDE_REQUESTS.containsKey(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RIDE_REQUESTS.remove(player);
|
RIDE_REQUESTS.remove(player);
|
||||||
msg("Request expired.", ChatColor.RED);
|
playerSender.sendMessage(ChatColor.RED + "It has been 30 seconds and " + player.getName() + " has not accepted your request.");
|
||||||
player.sendMessage(ChatColor.RED + "Request expired.");
|
player.sendMessage(ChatColor.RED + "Request expired.");
|
||||||
}
|
}
|
||||||
}, 30000);
|
}.runTaskLater(plugin, 20 * 30);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user