mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
more epic !
This commit is contained in:
parent
fbcb6da30d
commit
035acbfa19
@ -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 + "Request will expire after 30 seconds.");
|
||||
RIDE_REQUESTS.put(player, playerSender);
|
||||
timer.schedule(new TimerTask()
|
||||
FreedomCommandExecutor.timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -1,7 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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.rank.Rank;
|
||||
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>")
|
||||
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
|
||||
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());
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
@ -33,7 +32,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
//
|
||||
public final Timer timer = new Timer();
|
||||
|
||||
public FreedomCommand()
|
||||
{
|
||||
|
@ -25,8 +25,8 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
|
||||
|
||||
private final TotalFreedomMod plugin;
|
||||
//
|
||||
private Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>();
|
||||
private final Timer timer = new Timer();
|
||||
public static Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>();
|
||||
public static final Timer timer = new Timer();
|
||||
|
||||
public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.util;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
Loading…
Reference in New Issue
Block a user