Login messages for players. Still need to come up with login messaghes

This commit is contained in:
Seth
2020-10-02 02:27:06 -07:00
parent f8304aecd7
commit 533e4fe369
16 changed files with 228 additions and 134 deletions

View File

@ -35,6 +35,7 @@ public class Shop extends FreedomService
public final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] ";
public BukkitTask countdownTask;
private BossBar countdownBar = null;
private final String LOGIN_MESSAGE_GUI_TITLE = ChatColor.DARK_GREEN + ChatColor.BOLD.toString() + "Login Messages";
@Override
public void onStart()
@ -174,6 +175,27 @@ public class Shop extends FreedomService
return gui;
}
public Inventory generateLoginMessageGUI(Player player)
{
Inventory gui = server.createInventory(null, 36, LOGIN_MESSAGE_GUI_TITLE);
int slot = 0;
for (String loginMessage : ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList())
{
ItemStack icon = new ItemStack(Material.NAME_TAG);
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName(FUtil.colorize(plugin.rm.craftLoginMessage(player, loginMessage)));
icon.setItemMeta(meta);
gui.setItem(slot, icon);
slot++;
}
ItemStack clear = new ItemStack(Material.BARRIER);
ItemMeta meta = clear.getItemMeta();
meta.setDisplayName(ChatColor.RED + "Clear login message");
clear.setItemMeta(meta);
gui.setItem(35, clear);
return gui;
}
public boolean isRealItem(PlayerData data, ShopItem shopItem, PlayerInventory inventory, ItemStack realItem)
{
if (isRealItem(data, shopItem, inventory.getItemInMainHand(), realItem) || isRealItem(data, shopItem, inventory.getItemInOffHand(), realItem))
@ -306,7 +328,7 @@ public class Shop extends FreedomService
}
@EventHandler(priority = EventPriority.HIGH)
public void onInventoryClick(InventoryClickEvent event)
public void onShopGUIClick(InventoryClickEvent event)
{
if (!(event.getWhoClicked() instanceof Player))
{
@ -350,6 +372,44 @@ public class Shop extends FreedomService
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onLoginMessageGUIClick(InventoryClickEvent event)
{
if (!(event.getWhoClicked() instanceof Player))
{
return;
}
Inventory inventory = event.getInventory();
if (inventory.getSize() != 36 || !event.getView().getTitle().equals(LOGIN_MESSAGE_GUI_TITLE))
{
return;
}
event.setCancelled(true);
int slot = event.getSlot();
Player player = (Player)event.getWhoClicked();
PlayerData data = plugin.pl.getData(player);
if (slot == 35)
{
data.setLoginMessage(null);
plugin.pl.save(data);
player.sendMessage(ChatColor.GREEN + "Removed your login message");
}
else
{
String message = ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList().get(slot);
data.setLoginMessage(message);
plugin.pl.save(data);
player.sendMessage(ChatColor.GREEN + "Your login message is now the following:\n" + plugin.rm.craftLoginMessage(player, message));
}
player.closeInventory();
}
public ShopItem getShopItem(int slot)
{
for (ShopItem shopItem : ShopItem.values())

View File

@ -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"),
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 24, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish");
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 22, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish"),
LOGIN_MESSAGES("Login Messages", Material.NAME_TAG, 24, ConfigEntry.SHOP_PRICES_LOGIN_MESSAGES, ChatColor.DARK_GREEN, "loginMessages", "/loginmessage");
/*
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, x = Login Messages $ = Coins}
---------
-g-l-f-r-
--s---c--
--s-c-x--
--------$
*/