mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
add magical saddle to shop
This commit is contained in:
parent
417a0c39dd
commit
6f2d5aa08d
@ -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 magical saddle.", usage = "/<command>")
|
||||
public class Command_magicalsaddle extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.MAGICAL_SADDLE))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getMagicalSaddle());
|
||||
msg("You have been given a Magical Saddle", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Magical Saddle! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class Command_smite extends FreedomCommand
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
Boolean silent = false;
|
||||
boolean silent = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
@ -76,18 +76,21 @@ public class Command_smite extends FreedomCommand
|
||||
|
||||
public static void smite(CommandSender sender, Player player, String reason, Boolean silent)
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
if (reason != null)
|
||||
{
|
||||
FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Smitten " + player.getName() + " quietly.");
|
||||
}
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
|
@ -103,6 +103,7 @@ public enum ConfigEntry
|
||||
SHOP_PRICES_RIDEABLE_PEARL(Integer.class, "shop.prices.rideable_pearl"),
|
||||
SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"),
|
||||
SHOP_PRICES_CLOWN_FISH(Integer.class, "shop.prices.clown_fish"),
|
||||
SHOP_PRICES_MAGICAL_SADDLE(Integer.class, "shop.prices.magical_saddle"),
|
||||
//
|
||||
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
|
||||
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),
|
||||
|
@ -11,7 +11,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -43,13 +42,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ItemFun extends FreedomService
|
||||
{
|
||||
|
||||
public List<Player> explosivePlayers = new ArrayList<Player>();
|
||||
public List<Player> explosivePlayers = new ArrayList<>();
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@ -71,7 +69,7 @@ public class ItemFun extends FreedomService
|
||||
{
|
||||
cooldownTracker.get(player.getName()).add(item.getDataName());
|
||||
}
|
||||
BukkitTask thing = new BukkitRunnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -105,22 +103,36 @@ public class ItemFun extends FreedomService
|
||||
{
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
|
||||
if (player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
|
||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory().getItemInMainHand(), plugin.sh.getStackingPotato()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.addPassenger(entity);
|
||||
player.sendMessage("Stacked " + entity.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (onCooldown(player, ShopItem.MAGICAL_SADDLE))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You're currently on a cool-down for 15 seconds.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getInventory().getItemInMainHand().getType().equals(Material.SADDLE) || player.getInventory().getItemInOffHand().getType().equals(Material.SADDLE) || entity.getType().equals(EntityType.PLAYER))
|
||||
{
|
||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.MAGICAL_SADDLE, player.getInventory().getItemInMainHand(), plugin.sh.getMagicalSaddle()) || plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.MAGICAL_SADDLE, player.getInventory().getItemInOffHand(), plugin.sh.getMagicalSaddle()))
|
||||
{
|
||||
entity.addPassenger(player);
|
||||
cooldown(player, ShopItem.MAGICAL_SADDLE, 15);
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
entity.sendMessage(ChatColor.GRAY + player.getName() + " is now riding you, run /eject to eject them.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||||
@ -210,7 +222,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
if (onCooldown(player, ShopItem.LIGHTNING_ROD))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You're are currently on a cooldown for 10 seconds.");
|
||||
player.sendMessage(ChatColor.RED + "You're currently on a cool-down for 10 seconds.");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -234,7 +246,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
if (onCooldown(player, ShopItem.FIRE_BALL))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 5 seconds.");
|
||||
player.sendMessage(ChatColor.RED + "You're currently on a cool-down for 5 seconds.");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -245,6 +257,7 @@ public class ItemFun extends FreedomService
|
||||
cooldown(player, ShopItem.FIRE_BALL, 5);
|
||||
break;
|
||||
}
|
||||
|
||||
case TROPICAL_FISH:
|
||||
{
|
||||
final int RADIUS_HIT = 5;
|
||||
@ -257,7 +270,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
if (onCooldown(player, ShopItem.CLOWN_FISH))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 30 seconds.");
|
||||
player.sendMessage(ChatColor.RED + "You're currently on a cool-down for 30 seconds.");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -451,5 +464,4 @@ public class ItemFun extends FreedomService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.shop;
|
||||
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -21,6 +19,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -28,6 +27,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class Shop extends FreedomService
|
||||
{
|
||||
|
||||
private BukkitTask reactions;
|
||||
public String reactionString = "";
|
||||
public Date reactionStartTime;
|
||||
@ -248,6 +248,18 @@ public class Shop extends FreedomService
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public ItemStack getMagicalSaddle()
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(Material.SADDLE);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.DARK_GREEN + "Magical Saddle");
|
||||
itemMeta.setLore(Arrays.asList(ChatColor.GREEN + "Ride anything you want..."));
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public boolean canAfford(int price, int coins)
|
||||
{
|
||||
if (coins >= price)
|
||||
|
@ -12,17 +12,18 @@ public enum ShopItem
|
||||
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall", "/fireball"),
|
||||
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl", "/rideablepearl"),
|
||||
STACKING_POTATO("Stacking Potato", Material.POTATO, 20, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato"),
|
||||
MAGICAL_SADDLE("Magical Saddle", Material.SADDLE, 22, ConfigEntry.SHOP_PRICES_MAGICAL_SADDLE, ChatColor.DARK_GREEN, "magicalSaddle", "/magicalsaddle"),
|
||||
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 24, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish");
|
||||
|
||||
/*
|
||||
Shop GUI Layout:
|
||||
|
||||
Dimensions: 9x4 = 36
|
||||
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, s = Stacking Potato, c = Clown Fish, $ = Coins}
|
||||
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, s = Stacking Potato, c = Clown Fish, m = Magical Saddle $ = Coins}
|
||||
|
||||
---------
|
||||
-g-l-f-r-
|
||||
--s---c--
|
||||
--s-m-c--
|
||||
--------$
|
||||
*/
|
||||
|
||||
|
@ -124,6 +124,7 @@ shop:
|
||||
rideable_pearl: 700
|
||||
stacking_potato: 300
|
||||
clown_fish: 1500
|
||||
magical_saddle: 250
|
||||
|
||||
# Admin list
|
||||
adminlist:
|
||||
|
Loading…
Reference in New Issue
Block a user