Added /mmocore admin reset waypoints <player>

This commit is contained in:
Indyuce 2020-05-01 19:28:47 +02:00
parent 4453525900
commit b630205cef
3 changed files with 36 additions and 5 deletions

View File

@ -320,7 +320,7 @@ public class PlayerData extends OfflinePlayerData {
waypoints.add(waypoint.getId());
}
public long getNextWaypointMillis() {
public long getWaypointCooldown() {
return Math.max(0, lastWaypoint + 5000 - System.currentTimeMillis());
}
@ -377,7 +377,14 @@ public class PlayerData extends OfflinePlayerData {
}
public void warp(Waypoint waypoint) {
/*
* this cooldown is only used internally to make sure the player is not
* spamming waypoints. there is no need to reset it when resetting the
* player waypoints data
*/
lastWaypoint = System.currentTimeMillis();
giveStellium(-waypoint.getStelliumCost());
new BukkitRunnable() {

View File

@ -22,6 +22,7 @@ public class ResetCommandMap extends CommandMap {
addFloor(new ResetSkillsCommandMap(this));
addFloor(new ResetAllCommandMap(this));
addFloor(new ResetAttributesCommandMap(this));
addFloor(new ResetWaypointsCommandMap(this));
}
@Override
@ -73,6 +74,32 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetWaypointsCommandMap extends CommandEnd {
public ResetWaypointsCommandMap(CommandMap parent) {
super(parent, "waypoints");
addParameter(Parameter.PLAYER);
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 4)
return CommandResult.THROW_USAGE;
Player player = Bukkit.getPlayer(args[3]);
if (player == null) {
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
return CommandResult.FAILURE;
}
PlayerData data = PlayerData.get(player);
data.getWaypoints().clear();
MMOCore.plugin.waypointManager.getAll().stream().filter(waypoint -> waypoint.isDefault())
.forEach(waypoint -> data.unlockWaypoint(waypoint));
return CommandResult.SUCCESS;
}
}
public class ResetQuestsCommandMap extends CommandEnd {
public ResetQuestsCommandMap(CommandMap parent) {
super(parent, "quests");

View File

@ -199,11 +199,8 @@ public class WaypointViewer extends EditableInventory {
return;
}
double next = (double) playerData.getNextWaypointMillis() / 1000;
if (next < 0) {
MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "cooldown", decimal.format(next)).send(player);
if (playerData.getWaypointCooldown() > 0)
return;
}
player.closeInventory();
playerData.warp(waypoint);