mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
shops stuffs
This commit is contained in:
@ -49,7 +49,7 @@ public class Command_coins extends FreedomCommand
|
||||
}
|
||||
}
|
||||
ShopData sd = plugin.sh.getData(p);
|
||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins." + " This will be in use shortly.");
|
||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Makes random sounds to everyone online.", usage = "/<command>")
|
||||
public class Command_deafen extends FreedomCommand
|
||||
{
|
||||
@ -20,7 +20,6 @@ public class Command_deafen extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
||||
{
|
||||
@ -31,7 +30,7 @@ public class Command_deafen extends FreedomCommand
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.playSound(randomOffset(player.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
playerSender.playSound(randomOffset(playerSender.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
}
|
||||
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -19,14 +20,14 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Sends the specified player to their doom.", usage = "/<command> <playername>")
|
||||
@CommandParameters(description = "Sends the specified player to their doom.", usage = "/<command> <playername> [reason]")
|
||||
public class Command_doom extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -89,8 +90,17 @@ public class Command_doom extends FreedomCommand
|
||||
// Shoot the player in the sky
|
||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
|
||||
|
||||
String reason = null;
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||
}
|
||||
|
||||
final String kickReason = (reason == null ? "FUCKOFF, and get your shit together!" : reason);
|
||||
|
||||
// Log doom
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, null));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@ -115,10 +125,10 @@ public class Command_doom extends FreedomCommand
|
||||
msg(sender, player.getName() + " has been banned and IP is: " + ip);
|
||||
|
||||
// generate explosion
|
||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||
player.getWorld().createExplosion(player.getLocation(), 0F, false);;
|
||||
|
||||
// kick player
|
||||
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||
player.kickPlayer(ChatColor.RED + kickReason);
|
||||
}
|
||||
}.runTaskLater(plugin, 3L * 20L);
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
||||
public class Command_fireball extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
||||
msg("You have been given a Fire Ball", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Fire Ball! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a grappling hook", usage = "/<command>")
|
||||
public class Command_grapplinghook extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
|
||||
msg("You have been given a Grappling Hook", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Grappling Hook! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import java.util.Random;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "i dont fucking know, what even", usage = "thot if you dont know what this does then dont use it")
|
||||
public class Command_idfk extends FreedomCommand
|
||||
{
|
||||
|
||||
public static final String[] DRUNK_LINES = new String[]{"i is thy best bitch in teh world xD xD xD",
|
||||
"ooga boga ooga boga ooga boga ooga boga", "jake u dog fukr", "nero is a nice black pussy",
|
||||
"robin has a perfect penis", "ABABABABABABABABABA ABAOBOABOBA", "agge is a fuckin egg",
|
||||
"explosive errors == explosive arrows", "sync; echo 3 > /proc/sys/vm/drop_caches", "yeet",
|
||||
"si", "bubble bass thicc :weary::sweat_drops: :ok_hand:", "diabeetus", "McDiabeto", "oh",
|
||||
"say heck to diabetes im having chocolate cake"};
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case "killmepls":
|
||||
playerSender.setHealth(0);
|
||||
msg("ok u wanted die u now die");
|
||||
break;
|
||||
case "robin":
|
||||
msg("robin is a meme xD xD xD");
|
||||
break;
|
||||
case "succ":
|
||||
playerSender.chat("mmmmm *suckle* *suckle* daddy");
|
||||
break;
|
||||
case "drunk":
|
||||
msg(DRUNK_LINES[random.nextInt(DRUNK_LINES.length)]);
|
||||
break;
|
||||
case "zero":
|
||||
msg("WATCH ZERO KARA HAJIMERU MAHOU NO SHO (GRIMOIRE OF ZERO) TODAY! https://kissanime.ru/anime/zero-kara-hajimeru-mahou-no-sho");
|
||||
break;
|
||||
case "boom":
|
||||
msg("allahu akbar bitch");
|
||||
playerSender.getWorld().createExplosion(playerSender.getLocation(), 0F);
|
||||
break;
|
||||
case "rocket":
|
||||
playerSender.setVelocity(new Vector(0, 1000, 0));
|
||||
msg("*insert shooting stars meme here*");
|
||||
break;
|
||||
case "fuck":
|
||||
playerSender.chat("wow robin is gay xdxdxd");
|
||||
msg("i tried");
|
||||
msg("and as in i tried as in robin tried to code this in");
|
||||
msg("lol xd");
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a lightning rod", usage = "/<command>")
|
||||
public class Command_lightningrod extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
|
||||
msg("You have been given a Lightning Rod", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Lightning Rod! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,212 +1,200 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | remove> <player> <item>>", aliases = "ms")
|
||||
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
||||
public class Command_manageshop extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
if (args.length > 3)
|
||||
if (args.length < 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("coins"))
|
||||
return false;
|
||||
}
|
||||
if (args[0].equals("coins"))
|
||||
{
|
||||
if (args.length < 4)
|
||||
{
|
||||
if (getPlayer(args[3]) != null || args[3].equals("all"))
|
||||
{
|
||||
Player p = null;
|
||||
ShopData sd = null;
|
||||
if (!args[3].equals("all"))
|
||||
return false;
|
||||
}
|
||||
switch (args[1])
|
||||
{
|
||||
|
||||
case "add":
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[3]);
|
||||
sd = plugin.sh.getData(p);
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
plugin.sh.save(shopData);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + shopData.getCoins());
|
||||
}
|
||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int newAmount;
|
||||
int num;
|
||||
switch (args[1])
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
case "add":
|
||||
try
|
||||
{
|
||||
num = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
newAmount = sd.getCoins() + num;
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
msg(prefix + ChatColor.GREEN + "Gave " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins to " + p.getName() + ", " + p.getName() + " now has " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
p.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " gave you " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins, you now have " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
sd = plugin.sh.getData(player);
|
||||
newAmount = sd.getCoins() + num;
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
player.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " gave you " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins, you now have " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
}
|
||||
msg(prefix + ChatColor.GREEN + "Gave " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins to everyone.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
case "set":
|
||||
try
|
||||
{
|
||||
newAmount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
msg(prefix + ChatColor.GREEN + "Set " + p.getName() + "'s coin amount to " + ChatColor.RED + newAmount + ChatColor.GREEN + ".");
|
||||
p.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " set your coin amount to " + args[2] + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newAmount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
sd = plugin.sh.getData(player);
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
player.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " set your coin amount to " + args[2] + ChatColor.GREEN + ".");
|
||||
}
|
||||
msg(prefix + ChatColor.GREEN + "Set everyones's coin amount to " + ChatColor.RED + newAmount + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
case "remove":
|
||||
try
|
||||
{
|
||||
num = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
if (num > sd.getCoins())
|
||||
{
|
||||
msg(prefix + "You can't give a player a negative amount of coins, I'm sorry, you can't put anyone in debt.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
newAmount = sd.getCoins() - num;
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
msg(prefix + ChatColor.GREEN + "Took " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins from " + p.getName() + ", " + p.getName() + " now has " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
p.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " took " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins from you, you now have " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
sd = plugin.sh.getData(player);
|
||||
if (num > sd.getCoins())
|
||||
{
|
||||
sd.setCoins(0);
|
||||
}
|
||||
newAmount = sd.getCoins() - num;
|
||||
sd.setCoins(newAmount);
|
||||
plugin.sh.save(sd);
|
||||
player.sendMessage(prefix + ChatColor.GREEN + sender.getName() + " took " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins from you, you now have " + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||
}
|
||||
msg(prefix + ChatColor.GREEN + "Took " + ChatColor.RED + args[2] + ChatColor.GREEN + " coins from everyone.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
case "remove":
|
||||
try
|
||||
{
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() + amount);
|
||||
if (shopData.getCoins() < 0)
|
||||
{
|
||||
shopData.setCoins(0);
|
||||
}
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + shopData.getCoins(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(shopData.getCoins() - amount);
|
||||
if (shopData.getCoins() < 0)
|
||||
{
|
||||
shopData.setCoins(0);
|
||||
}
|
||||
plugin.sh.save(shopData);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + shopData.getCoins());
|
||||
}
|
||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
case "set":
|
||||
try
|
||||
{
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.setCoins(amount);
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[0].equals("items"))
|
||||
{
|
||||
if (args[1].equals("list"))
|
||||
{
|
||||
msg("List of all shop items: " + StringUtils.join(ShopItem.values(), ", "));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[1].equals("give"))
|
||||
{
|
||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||
if (item == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("items"))
|
||||
{
|
||||
switch (args[1])
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
{
|
||||
case "give":
|
||||
{
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopItem item = ShopItem.findItem(args[3]);
|
||||
if (item == null)
|
||||
{
|
||||
msg("Invalid item: " + item);
|
||||
return true;
|
||||
}
|
||||
ShopData sd = plugin.sh.getData(player);
|
||||
if (sd.hasItem(item))
|
||||
{
|
||||
msg("That player already has a(n) " + item.getName() + "!");
|
||||
return true;
|
||||
}
|
||||
String key = sd.giveItem(item);
|
||||
plugin.sh.save(sd);
|
||||
FUtil.give(player, item, ChatColor.DARK_GRAY + key);
|
||||
msg(prefix + ChatColor.GREEN + "Gave " + ChatColor.RED + player.getName() + ChatColor.GREEN + " a(n) " + item.getColoredName());
|
||||
return true;
|
||||
}
|
||||
case "remove":
|
||||
{
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopItem item = ShopItem.findItem(args[3]);
|
||||
if (item == null)
|
||||
{
|
||||
msg("Invalid item: " + item);
|
||||
return true;
|
||||
}
|
||||
ShopData sd = plugin.sh.getData(player);
|
||||
if (!sd.hasItem(item))
|
||||
{
|
||||
msg("That player doesn't have a(n) " + item.getName() + "!");
|
||||
return true;
|
||||
}
|
||||
sd.takeItem(item);
|
||||
plugin.sh.save(sd);
|
||||
msg(prefix + ChatColor.GREEN + "Took " + ChatColor.RED + player.getName() + ChatColor.GREEN + "'s " + item.getColoredName());
|
||||
return true;
|
||||
}
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.giveItem(item);
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
||||
return true;
|
||||
}
|
||||
else if (args[1].equals("take"))
|
||||
{
|
||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||
if (item == null)
|
||||
{
|
||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
ShopData shopData = plugin.sh.getData(player);
|
||||
shopData.removeItem(item);
|
||||
plugin.sh.save(shopData);
|
||||
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -104,13 +104,19 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.getName().equals("Catholic_Mario"))
|
||||
{
|
||||
msg("no", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vPlayer.getRideMode().equals("ask") && !isAdmin(sender))
|
||||
{
|
||||
msg("Sent a request to the player.");
|
||||
player.sendMessage(ChatColor.GRAY + sender.getName() + " has requested to ride you.");
|
||||
player.sendMessage(ChatColor.GRAY + "Type " + ChatColor.DARK_GRAY + "/ride accept" + ChatColor.GRAY + " to allow the player to ride you.");
|
||||
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.");
|
||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||
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.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
|
||||
player.sendMessage(ChatColor.AQUA + "Request will expire after 30 seconds.");
|
||||
RIDE_REQUESTS.put(player, playerSender);
|
||||
FreedomCommandExecutor.timer.schedule(new TimerTask()
|
||||
{
|
||||
@ -122,8 +128,8 @@ public class Command_ride extends FreedomCommand
|
||||
return;
|
||||
}
|
||||
RIDE_REQUESTS.remove(player);
|
||||
msg("Request expired.");
|
||||
player.sendMessage(ChatColor.GRAY + "Request expired.");
|
||||
msg("Request expired.", ChatColor.RED);
|
||||
player.sendMessage(ChatColor.RED + "Request expired.");
|
||||
}
|
||||
}, 30000);
|
||||
return true;
|
||||
|
@ -0,0 +1,29 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
||||
public class Command_rideablepearl extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
||||
msg("You have been given a Rideable Ender Pearl", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Rideable Ender Pearl! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,175 +1,26 @@
|
||||
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 me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Access the shop - this will be much simplified in the future.", usage = "/<command> <buy <item> | action | list>")
|
||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||
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)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
ShopData sd = plugin.sh.getData(playerSender);
|
||||
if (args.length == 0)
|
||||
{
|
||||
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, sender, 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, sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
case "list":
|
||||
case "items":
|
||||
{
|
||||
msg(prefix + ChatColor.GREEN + "Available items:");
|
||||
for (ShopItem item : ShopItem.values())
|
||||
{
|
||||
if (!item.isPurchaseable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
msg(prefix + ChatColor.AQUA + item.getName() + ChatColor.GREEN + " - " + ChatColor.RED + item.getCost());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
ShopData psd = plugin.sh.getData(player);
|
||||
msg(prefix + ChatColor.AQUA + player.getName() + ChatColor.GREEN + "'s balance: " + ChatColor.RED + psd.getCoins());
|
||||
return true;
|
||||
}
|
||||
if (args.length != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (args[0])
|
||||
{
|
||||
case "buy":
|
||||
{
|
||||
ShopItem item = ShopItem.findItem(args[1]);
|
||||
if (item == null || !item.isPurchaseable())
|
||||
{
|
||||
msg("Invalid item: " + item);
|
||||
return true;
|
||||
}
|
||||
if (sd.hasItem(item))
|
||||
{
|
||||
msg(prefix + ChatColor.GREEN + "You already have that item! To get it, use " + ChatColor.RED + "/shop get " + item.name() + ChatColor.GREEN + "!");
|
||||
return true;
|
||||
}
|
||||
if (item.getCost() > sd.getCoins())
|
||||
{
|
||||
msg(prefix + ChatColor.GREEN + "You don't have enough money for this item!");
|
||||
return true;
|
||||
}
|
||||
String signature = sd.giveItem(item);
|
||||
sd.setCoins(sd.getCoins() - item.getCost());
|
||||
plugin.sh.save(sd);
|
||||
ItemStack stack = new ItemStack(item.getMaterial(), 1);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(item.getColoredName());
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(ChatColor.DARK_GRAY + signature);
|
||||
meta.setLore(lore);
|
||||
stack.setItemMeta(meta);
|
||||
Inventory inv = playerSender.getInventory();
|
||||
inv.setItem(inv.firstEmpty(), stack);
|
||||
msg(prefix + ChatColor.GREEN + "You bought a " + item.getColoredName() + ChatColor.GREEN + "!");
|
||||
return true;
|
||||
}
|
||||
case "get":
|
||||
{
|
||||
ShopItem item = ShopItem.findItem(args[1]);
|
||||
if (item == null)
|
||||
{
|
||||
msg("Invalid item: " + item);
|
||||
return true;
|
||||
}
|
||||
if (!sd.hasItem(item))
|
||||
{
|
||||
msg(prefix + ChatColor.GREEN + "You don't have that item! To buy it, use " + ChatColor.RED + "/shop buy " + item.name() + ChatColor.GREEN + "!");
|
||||
return true;
|
||||
}
|
||||
Inventory inv = playerSender.getInventory();
|
||||
inv.setItem(inv.firstEmpty(), sd.getItem(item));
|
||||
msg(prefix + ChatColor.GREEN + "You got your " + item.getColoredName() + ChatColor.GREEN + "!");
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
playerSender.openInventory(plugin.sh.generateShopGUI(plugin.sh.getData(playerSender)));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cooldown(int seconds, CommandSender sender, String feature)
|
||||
{
|
||||
featureCooldown.put(sender, feature);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
featureCooldown.remove(sender);
|
||||
}
|
||||
}.runTaskLater(plugin, seconds * 20);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user