Initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ProjectCranked</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>SlotBot</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>Utils</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>LootTable</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>LootFilter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.crankedpvp.slotbot;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import net.crankedpvp.crankedutils.utils.CustomItemUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.loottable.LootTableAPI;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import net.crankedpvp.slotbot.struct.SlotBotType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SlotBotAPI {
|
||||
|
||||
public static boolean isSlotBot(final ItemStack itemStack) {
|
||||
return CustomItemUtils.getCrankedCustomItem(itemStack).equals("slotBotTicket");
|
||||
}
|
||||
|
||||
public static SlotBotType getSlotBotType(ItemStack itemStack) {
|
||||
if(ItemUtils.isAirOrNull(itemStack)) return null;
|
||||
if(!isSlotBot(itemStack)) return null;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if (nbtItem.getString("slotBotType") == null) return SlotBotType.SLOT_BOT;
|
||||
if (nbtItem.getString("slotBotType").equals("")) return SlotBotType.SLOT_BOT;
|
||||
return SlotBotType.valueOf(nbtItem.getString("slotBotType"));
|
||||
}
|
||||
|
||||
public static List<ItemStack> getRewards() {
|
||||
return LootTableAPI.getAllLootFromLootTable(LootTableType.SLOTBOT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.crankedpvp.slotbot;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.mattstudios.mf.base.CommandManager;
|
||||
import net.crankedpvp.slotbot.commands.SlotBotCommand;
|
||||
import net.crankedpvp.slotbot.listeners.SlotBotTempFix;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SlotBotPlugin extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static SlotBotPlugin instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
instance = this;
|
||||
CommandManager commandManager = new CommandManager(this);
|
||||
commandManager.register(new SlotBotCommand(this));
|
||||
|
||||
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new SlotBotTempFix(this), this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.crankedpvp.slotbot.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.slotbot.SlotBotPlugin;
|
||||
import net.crankedpvp.slotbot.inventory.SlotBotInventory;
|
||||
import net.crankedpvp.slotbot.struct.SlotBotType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("slot")
|
||||
@Alias({"slotbot", "bot", "roll", "rollbot"})
|
||||
public class SlotBotCommand extends CommandBase {
|
||||
|
||||
private final SlotBotPlugin plugin;
|
||||
public SlotBotCommand(SlotBotPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void defaultCommand(final CommandSender commandSender) {
|
||||
|
||||
final SlotBotInventory slotBotInventory = new SlotBotInventory((Player) commandSender);
|
||||
slotBotInventory.getSlotBotInventory().open((Player)commandSender);
|
||||
|
||||
}
|
||||
|
||||
@SubCommand("give")
|
||||
@Permission("cranked.admin")
|
||||
@WrongUsage("&c/slotbot give <player> [amount]")
|
||||
public void giveCommand(final CommandSender commandSender, @Completion("#players") final Player receiver, @Optional Integer amount) {
|
||||
if(amount == null) amount = 1;
|
||||
receiver.getInventory().addItem(SlotBotType.SLOT_BOT.build(amount));
|
||||
}
|
||||
|
||||
@SubCommand("heroic")
|
||||
@Permission("cranked.admin")
|
||||
@WrongUsage("&c/slotbot give <player> [amount]")
|
||||
public void giveHeroicCommand(final CommandSender commandSender, @Completion("#players") final Player receiver, @Optional Integer amount) {
|
||||
if(amount == null) amount = 1;
|
||||
receiver.getInventory().addItem(SlotBotType.HEROIC_SLOT_BOT.build(amount));
|
||||
}
|
||||
|
||||
@SubCommand("mastery")
|
||||
@Permission("cranked.admin")
|
||||
@WrongUsage("&c/slotbot give <player> [amount]")
|
||||
public void giveMasteryCommand(final CommandSender commandSender, @Completion("#players") final Player receiver, @Optional Integer amount) {
|
||||
if(amount == null) amount = 1;
|
||||
receiver.getInventory().addItem(SlotBotType.MASTERY_SLOT_BOT.build(amount));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.crankedpvp.slotbot.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import dev.triumphteam.gui.guis.PaginatedGui;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.slotbot.SlotBotAPI;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class LootPreviewInventory {
|
||||
|
||||
private final PaginatedGui slotBotPreviewInventory;
|
||||
|
||||
public PaginatedGui getUI() {
|
||||
return this.slotBotPreviewInventory;
|
||||
}
|
||||
|
||||
|
||||
public LootPreviewInventory(Player player) {
|
||||
|
||||
this.slotBotPreviewInventory = new PaginatedGui(6, 28, "Roll Bot Loot");
|
||||
this.slotBotPreviewInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
this.slotBotPreviewInventory.getFiller().fillBorder(new GuiItem(createFillerItem()));
|
||||
ItemStack prevPage = new ItemBuilder(Material.ARROW, "&c<- Previous Page", "&7Right-Click&7 to go to the previous page.").colorize().build();
|
||||
ItemStack nextPage = new ItemBuilder(Material.ARROW, "&aNext Page ->", "&7Right-Click&7 to go to the next page.").colorize().build();
|
||||
this.slotBotPreviewInventory.setItem(6, 1, new GuiItem(prevPage, event -> {
|
||||
this.slotBotPreviewInventory.previous();
|
||||
event.setCancelled(true);
|
||||
}));
|
||||
this.slotBotPreviewInventory.setItem(6, 9, new GuiItem(nextPage, event -> {
|
||||
this.slotBotPreviewInventory.next();
|
||||
event.setCancelled(true);
|
||||
}));
|
||||
|
||||
|
||||
this.slotBotPreviewInventory.updateItem(6, 5, new GuiItem(new ItemBuilder(Material.BED, "&cReturn to Roll Bot").colorize().build(), event -> {
|
||||
player.closeInventory();
|
||||
SlotBotInventory slotBotInventory = new SlotBotInventory(player);
|
||||
slotBotInventory.getSlotBotInventory().open(player);
|
||||
}));
|
||||
|
||||
SlotBotAPI.getRewards().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(ItemStack::hasItemMeta)
|
||||
.forEach(itemStack -> this.slotBotPreviewInventory.addItem(new GuiItem(itemStack, event -> {
|
||||
if(player.hasPermission("cranked.admin")) player.getInventory().addItem(itemStack);
|
||||
})));
|
||||
;
|
||||
}
|
||||
|
||||
private ItemStack createFillerItem() {
|
||||
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(CC.translate("&cCranked&fPvP"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
package net.crankedpvp.slotbot.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.lootfilter.LootFilterAPI;
|
||||
import net.crankedpvp.loottable.LootTableAPI;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import net.crankedpvp.slotbot.SlotBotAPI;
|
||||
import net.crankedpvp.slotbot.SlotBotPlugin;
|
||||
import net.crankedpvp.slotbot.struct.GameStatus;
|
||||
import net.crankedpvp.slotbot.struct.SlotBotType;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class SlotBotInventory {
|
||||
|
||||
private GameStatus gameStatus = GameStatus.WAITING;
|
||||
private final Player player;
|
||||
private boolean isSpinning = false;
|
||||
private int insertedTickets = 0;
|
||||
private int taskID = 0;
|
||||
private boolean given = false;
|
||||
|
||||
private SlotBotType slotBotType = null;
|
||||
|
||||
@Getter
|
||||
private final Gui slotBotInventory;
|
||||
|
||||
public SlotBotInventory(Player player) {
|
||||
this.player = player;
|
||||
this.slotBotInventory = new Gui(3, "Slot Bot");
|
||||
this.slotBotInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
handleInventoryClosure();
|
||||
enableSlotBotAddition();
|
||||
setupHowToPlayItem();
|
||||
setupLootTableItem();
|
||||
updateSpinItem();
|
||||
setupGlassSlots();
|
||||
}
|
||||
|
||||
|
||||
private void putSlotBotInMenu() {
|
||||
ItemStack itemStack = this.slotBotType.build();
|
||||
int index = (3 + this.insertedTickets);
|
||||
this.slotBotInventory.updateItem(1, index, new GuiItem(getAvailableRollGlass()));
|
||||
this.slotBotInventory.updateItem(3, index, new GuiItem(getAvailableRollGlass()));
|
||||
this.slotBotInventory.updateItem(2, index, new GuiItem(itemStack, event -> {
|
||||
this.slotBotInventory.updateItem(2, index, new GuiItem(getRewardSlot()));
|
||||
this.slotBotInventory.updateItem(1, index, new GuiItem(getFillingGlass()));
|
||||
this.slotBotInventory.updateItem(3, index, new GuiItem(getFillingGlass()));
|
||||
this.insertedTickets--;
|
||||
this.player.getInventory().addItem(itemStack);
|
||||
this.updateSpinItem();
|
||||
}));
|
||||
}
|
||||
|
||||
private void updateSpinItem() {
|
||||
ItemStack spinItem = getSpinItem();
|
||||
this.slotBotInventory.updateItem(2, 9, new GuiItem(spinItem, event -> {
|
||||
if(this.isSpinning) {
|
||||
handleItemRewarding();
|
||||
return;
|
||||
}
|
||||
|
||||
if(checkNoInsertedTickets()) return;
|
||||
this.gameStatus = GameStatus.SPINNING;
|
||||
this.isSpinning = true;
|
||||
updateSpinItem();
|
||||
updateItemTask(player);
|
||||
this.slotBotInventory.updateItem(2, 3, new GuiItem(getRewardRowGlass()));
|
||||
this.slotBotInventory.updateItem(2, 7, new GuiItem(getRewardRowGlass()));
|
||||
}));
|
||||
}
|
||||
|
||||
private boolean checkNoInsertedTickets() {
|
||||
if(this.insertedTickets == 0) {
|
||||
this.player.sendMessage(CC.translate("&cYou have no tickets inserted"));
|
||||
this.player.playSound(this.player.getLocation(), Sound.ANVIL_LAND, 2.0F, 2.0F);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleItemRewarding() {
|
||||
SlotBotPlugin plugin = SlotBotPlugin.getInstance();
|
||||
plugin.getServer().getScheduler().cancelTask(this.taskID);
|
||||
int rewards = this.insertedTickets;
|
||||
this.insertedTickets = 0;
|
||||
this.isSpinning = false;
|
||||
this.gameStatus = GameStatus.FINISHING;
|
||||
if(this.player.getOpenInventory().getTopInventory().getTitle().equals("Slot Bot")) {
|
||||
for(int i = 0; i < rewards; i++) {
|
||||
ItemStack randomReward = LootTableAPI.getRandomLootItem(LootTableType.SLOTBOT);
|
||||
this.slotBotInventory.updateItem(12 + i, new GuiItem(randomReward));
|
||||
LootFilterAPI.giveLootTableItem(player, LootTableType.SLOTBOT, randomReward);
|
||||
}
|
||||
resetSlotBotInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < rewards; i++) {
|
||||
ItemStack randomReward = this.slotBotType.getRandomItem();
|
||||
LootFilterAPI.giveLootTableItem(player, LootTableType.SLOTBOT, randomReward);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveItemSlotsDownOneRow() {
|
||||
for(int i = 0; i < this.insertedTickets; i++) {
|
||||
this.slotBotInventory.updateItem(21 + i, Objects.requireNonNull(this.slotBotInventory.getGuiItem(21 + i - 9)));
|
||||
this.slotBotInventory.updateItem(21 + i - 9, Objects.requireNonNull(this.slotBotInventory.getGuiItem(21 + i - 9 - 9)));
|
||||
this.slotBotInventory.updateItem(21 + i - 9 - 9, new GuiItem(this.slotBotType.getRandomItem()));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItemTask(Player player) {
|
||||
SlotBotPlugin plugin = SlotBotPlugin.getInstance();
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
this.taskID = player.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, () -> {
|
||||
if(!player.getOpenInventory().getTopInventory().getTitle().contains("Slot Bot")) plugin.getServer().getScheduler().cancelTask(this.taskID);
|
||||
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1.0F, 1.0F);
|
||||
moveItemSlotsDownOneRow();
|
||||
counter.getAndIncrement();
|
||||
if(counter.get() == 20) {
|
||||
plugin.getServer().getScheduler().cancelTask(this.taskID);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, this::handleItemRewarding, 5L);
|
||||
}
|
||||
}, 0L, 4L);
|
||||
}
|
||||
|
||||
private void resetSlotBotInventory() {
|
||||
SlotBotPlugin.getInstance().getServer().getScheduler().runTaskLater(SlotBotPlugin.getInstance(), () -> {
|
||||
setupGlassSlots();
|
||||
updateSpinItem();
|
||||
this.isSpinning = false;
|
||||
this.slotBotInventory.removeItem(2, 3);
|
||||
this.slotBotInventory.removeItem(2, 7);
|
||||
this.gameStatus = GameStatus.WAITING;
|
||||
}, 40L);
|
||||
}
|
||||
|
||||
private ItemStack getSpinItem() {
|
||||
Material material = this.insertedTickets == 0 ? Material.MAGMA_CREAM : Material.SLIME_BALL;
|
||||
String name = this.gameStatus == GameStatus.SPINNING ? "&a&lSpinning..." : this.insertedTickets == 0 ? "&c&lSpin (&7Missing Ticket&c&l)" : "&a&lSpin (&7" + this.insertedTickets + " Tickets&a&l)";
|
||||
|
||||
List<String> lore =
|
||||
this.isSpinning ?
|
||||
Arrays.asList(
|
||||
"&7Your roll bot tickets are",
|
||||
"&7currently rolling in the machine",
|
||||
"",
|
||||
"&7Click to skip the animation")
|
||||
|
||||
: this.insertedTickets == 0 ? Arrays.asList(
|
||||
"&7You must insert at least",
|
||||
"&7one ticket before you can",
|
||||
"&7roll the roll bot machine") : Collections.singletonList("&7Click to spin the bot");
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder(material, name, lore).colorize();
|
||||
return itemBuilder.colorize().build();
|
||||
}
|
||||
|
||||
private void enableSlotBotAddition() {
|
||||
this.slotBotInventory.setPlayerInventoryAction(event -> {
|
||||
if(this.isSpinning) return;
|
||||
if(this.gameStatus == GameStatus.FINISHING) return;
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
if(!SlotBotAPI.isSlotBot(clickedItem)) return;
|
||||
if(this.slotBotType != null && !this.slotBotType.equals(clickedItem)) return;
|
||||
if(this.insertedTickets == 3) return;
|
||||
this.insertedTickets++;
|
||||
final int amount = clickedItem.getAmount();
|
||||
this.slotBotType = SlotBotAPI.getSlotBotType(clickedItem);
|
||||
if (amount <= 1) {
|
||||
event.setCurrentItem(null);
|
||||
} else {
|
||||
clickedItem.setAmount(amount - 1);
|
||||
event.setCurrentItem(clickedItem);
|
||||
}
|
||||
putSlotBotInMenu();
|
||||
this.updateSpinItem();
|
||||
this.player.updateInventory();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void setupLootTableItem() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.BEACON, "&b&lLoot Table",
|
||||
"&7Click to view all of the possible",
|
||||
"&7loot inside of the roll bot machine"
|
||||
);
|
||||
this.slotBotInventory.setItem(1, 1, new GuiItem(itemBuilder.colorize().build(), event -> {
|
||||
this.player.closeInventory();
|
||||
LootPreviewInventory lootPreviewInventory = new LootPreviewInventory(this.player);
|
||||
lootPreviewInventory.getUI().open(this.player);
|
||||
}));
|
||||
}
|
||||
|
||||
private void handleInventoryClosure() {
|
||||
this.slotBotInventory.setCloseGuiAction(inventoryCloseEvent -> {
|
||||
if(inventoryCloseEvent.getPlayer().hasMetadata("SlotBotReturnTickets") || this.given) {
|
||||
System.out.println("[SlotBot] RETURNING INVENTORY CLOSURE - DUPE PREVENTION");
|
||||
return;
|
||||
}
|
||||
if(this.isSpinning) {
|
||||
SlotBotPlugin.getInstance().getServer().getScheduler().cancelTask(this.taskID);
|
||||
for(int i = 0; i < this.insertedTickets; i++) {
|
||||
ItemStack randomReward = this.slotBotType.getRandomItem();
|
||||
LootFilterAPI.giveLootTableItem(player, LootTableType.SLOTBOT, randomReward);
|
||||
}
|
||||
this.given = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(insertedTickets == 0) return;
|
||||
this.player.getInventory().addItem(this.slotBotType.build(this.insertedTickets));
|
||||
this.player.sendMessage(CC.translate("&aYour &n" + this.insertedTickets + "&r &aroll tickets were returned to your inventory"));
|
||||
this.given = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void setupHowToPlayItem() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.BOOK, "&b&lHow to Play",
|
||||
"&e&l1. &7Insert up to 3 roll tickets",
|
||||
"&7into the machine from your inventory",
|
||||
"",
|
||||
"&e&l2. &7Click \"Spin\" (on the right) to roll.",
|
||||
"&7the bot or, click \"Return\" (on the left)",
|
||||
"&7to withdraw all inserted tickets",
|
||||
"",
|
||||
"&e&l3. &7Watch as the bot spins items.",
|
||||
"&7The item which lands on the reward slot",
|
||||
"&7when the bot finishes spinning, is the item",
|
||||
"&7that you'll receive.",
|
||||
"",
|
||||
"&e&lTIP: &7Exiting the machine early will",
|
||||
"&7give you the rewards you would of won if",
|
||||
"&7you had stayed in the machine while spinning.",
|
||||
"&7If the machine is not spinning when you exit,",
|
||||
"&7your tickets will be refunded and no items will",
|
||||
"&7be given."
|
||||
);
|
||||
|
||||
this.slotBotInventory.setItem(3, 1, new GuiItem(itemBuilder.colorize().build()));
|
||||
}
|
||||
|
||||
private ItemStack getRewardSlot() {
|
||||
return new ItemBuilder(Material.STAINED_GLASS_PANE, 1, DyeColor.LIME.getData(), "&a&lReward Slot",
|
||||
"&7The item which lands on this slot",
|
||||
"&7will be the item that you receive").colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack getRewardRowGlass() {
|
||||
return new ItemBuilder(Material.STAINED_GLASS_PANE, 1, DyeColor.BLACK.getData(), "&a&lReward Row",
|
||||
"&7The item(s) which land in this row",
|
||||
"&7are the item(s) you will receive").setGlowing().colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack getFillingGlass() {
|
||||
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("");
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack getAvailableRollGlass() {
|
||||
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.WHITE.getData());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(" ");
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private void setupGlassSlots() {
|
||||
this.slotBotInventory.updateItem(2, 4, new GuiItem(getRewardSlot()));
|
||||
this.slotBotInventory.updateItem(2, 5, new GuiItem(getRewardSlot()));
|
||||
this.slotBotInventory.updateItem(2, 6, new GuiItem(getRewardSlot()));
|
||||
|
||||
this.slotBotInventory.updateItem(1, 4, new GuiItem(getFillingGlass()));
|
||||
this.slotBotInventory.updateItem(1, 5, new GuiItem(getFillingGlass()));
|
||||
this.slotBotInventory.updateItem(1, 6, new GuiItem(getFillingGlass()));
|
||||
|
||||
this.slotBotInventory.updateItem(3, 4, new GuiItem(getFillingGlass()));
|
||||
this.slotBotInventory.updateItem(3, 5, new GuiItem(getFillingGlass()));
|
||||
this.slotBotInventory.updateItem(3, 6, new GuiItem(getFillingGlass()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.crankedpvp.slotbot.listeners;
|
||||
|
||||
import net.crankedpvp.slotbot.SlotBotPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class SlotBotTempFix implements Listener {
|
||||
|
||||
private SlotBotPlugin plugin;
|
||||
public SlotBotTempFix(SlotBotPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerJoin(PlayerJoinEvent event) {
|
||||
if(event.getPlayer() == null) return;
|
||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
|
||||
if(!event.getPlayer().isOnline()) return;
|
||||
event.getPlayer().removeMetadata("SlotBotReturnTickets", this.plugin);
|
||||
}, 50L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerQuit(PlayerQuitEvent event) {
|
||||
if(event.getPlayer() == null) return;
|
||||
event.getPlayer().setMetadata("SlotBotReturnTickets", new FixedMetadataValue(this.plugin, "SlotBotReturnTickets"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.crankedpvp.slotbot.struct;
|
||||
|
||||
public enum GameStatus {
|
||||
SPINNING, FINISHING, WAITING
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.crankedpvp.slotbot.struct;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.LootTableAPI;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import net.crankedpvp.slotbot.SlotBotAPI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public enum SlotBotType {
|
||||
SLOT_BOT("", Material.PAPER, Collections.emptyList()),
|
||||
HEROIC_SLOT_BOT("&5&ki&r&d&lHeroic&5&ki&r ", Material.PAPER, Arrays.asList("", "&7This /slot ticket will &fnot &7give", "&7common or uncommon rewards.")),
|
||||
MASTERY_SLOT_BOT("&c&ki&r&4&lMastery&c&ki&r ", Material.PAPER, Arrays.asList("", "&7This /slot ticket will &fnot &7give", "&7common, uncommon or rare rewards.")),
|
||||
;
|
||||
|
||||
private final String fancyName;
|
||||
private final Material material;
|
||||
private final List<String> additionalLore;
|
||||
|
||||
SlotBotType(String fancyName, Material material, List<String> additionalLore) {
|
||||
this.fancyName = fancyName;
|
||||
this.material = material;
|
||||
this.additionalLore = additionalLore;
|
||||
}
|
||||
|
||||
public boolean equals(ItemStack itemStack) {
|
||||
return (this == SlotBotAPI.getSlotBotType(itemStack));
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
return this.build(1);
|
||||
}
|
||||
|
||||
public ItemStack build(int amount) {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(this.getMaterial(), this.fancyName + "&c&lSlot &f&lBot &c&lTicket",
|
||||
"&7Right-Click the Slot Bot located",
|
||||
"&7at &f/spawn &7or use &f/bot &7to",
|
||||
"&7open the slot bot machinery.",
|
||||
"",
|
||||
"&7Left-Click to insert a slot bot",
|
||||
"&7ticket into the machine");
|
||||
itemBuilder.addLore(this.additionalLore);
|
||||
ItemStack itemStack = itemBuilder.colorize().build();
|
||||
itemStack.setAmount(amount);
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
nbtItem.setString("crankedCustomItem", "slotBotTicket");
|
||||
nbtItem.setString("slotBotType", this.name());
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public ItemStack getRandomItem() {
|
||||
return LootTableAPI.getRandomLootItem(LootTableType.SLOTBOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name: CrankedSlotBot
|
||||
main: net.crankedpvp.slotbot.SlotBotPlugin
|
||||
version: ${git.total.commit.count}.0
|
||||
description: "§fCommit ID: §a${git.commit.id.abbrev}"
|
||||
website: https://crankedpvp.net/
|
||||
depend:
|
||||
- CrankedUtils
|
||||
Reference in New Issue
Block a user