more epic !

This commit is contained in:
Super_ 2020-01-07 15:53:31 -05:00
parent fbcb6da30d
commit 035acbfa19
5 changed files with 59 additions and 5 deletions

View File

@ -112,7 +112,7 @@ public class Command_ride extends FreedomCommand
player.sendMessage(ChatColor.GRAY + "Type " + ChatColor.DARK_GRAY + "/ride deny" + ChatColor.GRAY + " to deny the player permission."); player.sendMessage(ChatColor.GRAY + "Type " + ChatColor.DARK_GRAY + "/ride deny" + ChatColor.GRAY + " to deny the player permission.");
player.sendMessage(ChatColor.GRAY + "Request will expire after 30 seconds."); player.sendMessage(ChatColor.GRAY + "Request will expire after 30 seconds.");
RIDE_REQUESTS.put(player, playerSender); RIDE_REQUESTS.put(player, playerSender);
timer.schedule(new TimerTask() FreedomCommandExecutor.timer.schedule(new TimerTask()
{ {
@Override @Override
public void run() public void run()

View File

@ -1,7 +1,12 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TimerTask;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopData; import me.totalfreedom.totalfreedommod.shop.ShopData;
@ -19,6 +24,9 @@ import org.bukkit.inventory.meta.ItemMeta;
@CommandParameters(description = "Access the shop", usage = "/<command> <buy> <item>") @CommandParameters(description = "Access the shop", usage = "/<command> <buy> <item>")
public class Command_shop extends FreedomCommand public class Command_shop extends FreedomCommand
{ {
private final List<String> locations = Arrays.asList("Sofa", "Car", "Bed", "Kitchen", "Garage", "Basement", "Home Study");
private Map<CommandSender, String> featureCooldown = new HashMap<>();
@Override @Override
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
@ -34,6 +42,40 @@ public class Command_shop extends FreedomCommand
msg(prefix + ChatColor.GREEN + "Balance: " + ChatColor.RED + sd.getCoins()); msg(prefix + ChatColor.GREEN + "Balance: " + ChatColor.RED + sd.getCoins());
return true; return true;
} }
if (args.length == 1)
{
if (featureCooldown.containsKey(sender) && featureCooldown.containsValue(args[0]))
{
msg("You're on cooldown for this feature.", ChatColor.RED);
return true;
}
Random r = new Random();
switch (args[0])
{
case "daily":
{
sd.setCoins(sd.getCoins() + 100);
plugin.sh.save(sd);
msg(prefix + ChatColor.GREEN + "You received your 100 coins!");
cooldown(86400, args[0]);
return true;
}
case "search":
{
int amount = FUtil.random(5, 10);
String location = locations.get(r.nextInt(locations.size()));
sd.setCoins(sd.getCoins() + amount);
plugin.sh.save(sd);
msg(prefix + ChatColor.AQUA + location + ChatColor.GREEN + " - Found " + ChatColor.RED + amount + ChatColor.GREEN + " coins!");
cooldown(30, args[0]);
return true;
}
default:
{
return false;
}
}
}
if (args.length != 2) if (args.length != 2)
{ {
return false; return false;
@ -98,4 +140,17 @@ public class Command_shop extends FreedomCommand
} }
} }
private void cooldown(int seconds, String feature)
{
featureCooldown.put(sender, feature);
FreedomCommandExecutor.timer.schedule(new TimerTask()
{
@Override
public void run()
{
featureCooldown.remove(sender);
}
}, seconds * 1000);
}
} }

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.List; import java.util.List;
import java.util.Timer;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
@ -33,7 +32,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
@Getter @Getter
private final CommandPermissions perms; private final CommandPermissions perms;
// //
public final Timer timer = new Timer();
public FreedomCommand() public FreedomCommand()
{ {

View File

@ -25,8 +25,8 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
private final TotalFreedomMod plugin; private final TotalFreedomMod plugin;
// //
private Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>(); public static Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>();
private final Timer timer = new Timer(); public static final Timer timer = new Timer();
public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command) public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command)
{ {

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.util;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.security.SecureRandom;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;