Initial commit.

This commit is contained in:
Trixkz 2024-09-20 02:14:31 -04:00
commit b1b828257d
168 changed files with 12962 additions and 0 deletions

131
pom.xml Normal file
View File

@ -0,0 +1,131 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.loganmagnan</groupId>
<artifactId>LifeStealCore</artifactId>
<version>1.0</version>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui</artifactId>
<version>1.5.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.github.bananapuncher714</groupId>
<artifactId>nbteditor</artifactId>
<version>7.18.1</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.decentsoftware-eu</groupId>
<artifactId>decentholograms</artifactId>
<version>2.7.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,179 @@
package aether;
import aether.event.BoardCreateEvent;
import aether.scoreboard.Board;
import aether.scoreboard.BoardAdapter;
import aether.scoreboard.BoardEntry;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
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.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import static aether.AetherOptions.defaultOptions;
public class Aether implements Listener {
@Getter BoardAdapter adapter;
@Getter private JavaPlugin plugin;
@Getter private AetherOptions options;
public Aether(JavaPlugin plugin, BoardAdapter adapter, AetherOptions options) {
this.options = options;
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
setAdapter(adapter);
run();
}
public Aether(JavaPlugin plugin, BoardAdapter adapter) {
this(plugin, adapter, defaultOptions());
}
public Aether(JavaPlugin plugin) {
this(plugin, null, defaultOptions());
}
private void run() {
new BukkitRunnable() {
@Override
public void run() {
if (adapter == null) return;
for (Player player : Bukkit.getOnlinePlayers()) {
Board board = Board.getByPlayer(player);
if (board != null) {
List<String> scores = adapter.getScoreboard(player, board, board.getCooldowns());
List<String> translatedScores = new ArrayList<>();
if (scores == null) {
if (!board.getEntries().isEmpty()) {
for (BoardEntry boardEntry : board.getEntries()) {
boardEntry.remove();
}
board.getEntries().clear();
}
continue;
}
for (String line : scores) {
translatedScores.add(ChatColor.translateAlternateColorCodes('&', line));
}
if (!options.scoreDirectionDown()) {
Collections.reverse(scores);
}
Scoreboard scoreboard = board.getScoreboard();
Objective objective = board.getObjective();
if (!(objective.getDisplayName().equals(adapter.getTitle(player)))) {
objective.setDisplayName(ChatColor.translateAlternateColorCodes('&', adapter.getTitle(player)));
}
outer:
for (int i = 0; i < scores.size(); i++) {
String text = scores.get(i);
int position;
if (options.scoreDirectionDown()) {
position = 15 - i;
} else {
position = i + 1;
}
Iterator<BoardEntry> iterator = new ArrayList<>(board.getEntries()).iterator();
while (iterator.hasNext()) {
BoardEntry boardEntry = iterator.next();
Score score = objective.getScore(boardEntry.getKey());
if (score != null && boardEntry.getText().equals(ChatColor.translateAlternateColorCodes('&', text))) {
if (score.getScore() == position) {
continue outer;
}
}
}
int positionToSearch = options.scoreDirectionDown() ? 15 - position : position - 1;
iterator = board.getEntries().iterator();
while (iterator.hasNext()) {
BoardEntry boardEntry = iterator.next();
int entryPosition = scoreboard.getObjective(DisplaySlot.SIDEBAR).getScore(boardEntry.getKey()).getScore();
if (!options.scoreDirectionDown()) {
if (entryPosition > scores.size()) {
iterator.remove();
boardEntry.remove();
}
}
}
BoardEntry entry = board.getByPosition(positionToSearch);
if (entry == null) {
new BoardEntry(board, text).send(position);
} else {
entry.setText(text).setup().send(position);
}
if (board.getEntries().size() > scores.size()) {
iterator = board.getEntries().iterator();
while (iterator.hasNext()) {
BoardEntry boardEntry = iterator.next();
if ((!translatedScores.contains(boardEntry.getText())) || Collections.frequency(board.getBoardEntriesFormatted(), boardEntry.getText()) > 1) {
iterator.remove();
boardEntry.remove();
}
}
}
}
adapter.onScoreboardCreate(player, scoreboard);
player.setScoreboard(scoreboard);
}
}
}
}.runTaskTimerAsynchronously(plugin, 20L, 2L);
}
public void setAdapter(BoardAdapter adapter) {
this.adapter = adapter;
for (Player player : Bukkit.getOnlinePlayers()) {
Board board = Board.getByPlayer(player);
if (board != null) {
Board.getBoards().remove(board);
}
Bukkit.getPluginManager().callEvent(new BoardCreateEvent(new Board(player, this, options), player));
}
}
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
if (Board.getByPlayer(event.getPlayer()) == null) {
Bukkit.getPluginManager().callEvent(new BoardCreateEvent(new Board(event.getPlayer(), this, options), event.getPlayer()));
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuitEvent(PlayerQuitEvent event) {
Board board = Board.getByPlayer(event.getPlayer());
if (board != null) {
Board.getBoards().remove(board);
}
}
}

View File

@ -0,0 +1,18 @@
package aether;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter
@Setter
@Accessors(chain = true, fluent = true)
public class AetherOptions {
private boolean hook;
private boolean scoreDirectionDown;
static AetherOptions defaultOptions() {
return new AetherOptions().hook(false).scoreDirectionDown(false);
}
}

View File

@ -0,0 +1,27 @@
package aether.event;
import aether.scoreboard.Board;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class BoardCreateEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
@Getter private final Board board;
@Getter private final Player player;
public BoardCreateEvent(Board board, Player player) {
this.board = board;
this.player = player;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
public HandlerList getHandlers() {
return HANDLERS;
}
}

View File

@ -0,0 +1,128 @@
package aether.scoreboard;
import aether.Aether;
import aether.AetherOptions;
import aether.scoreboard.cooldown.BoardCooldown;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Board {
@Getter private static Set<Board> boards = new HashSet<>();
private final Aether aether;
private final AetherOptions options;
@Getter private Scoreboard scoreboard;
@Getter private Player player;
@Getter private Objective objective;
@Getter private Set<String> keys;
@Getter private List<BoardEntry> entries;
private Set<BoardCooldown> cooldowns;
public Board(Player player, Aether aether, AetherOptions options) {
this.player = player;
this.aether = aether;
this.options = options;
this.keys = new HashSet<>();
this.entries = new ArrayList<>();
this.cooldowns = new HashSet<>();
setup();
}
public static Board getByPlayer(Player player) {
for (Board board : boards) {
if (board.getPlayer().getName().equals(player.getName())) {
return board;
}
}
return null;
}
private void setup() {
if (options.hook() && !player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
scoreboard = player.getScoreboard();
} else {
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
}
objective = scoreboard.registerNewObjective("glaedr_is_shit", "dummy");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
if (aether.getAdapter() != null) {
objective.setDisplayName(ChatColor.translateAlternateColorCodes('&', aether.getAdapter().getTitle(player)));
} else {
objective.setDisplayName("Default Title");
}
boards.add(this);
}
public String getNewKey(BoardEntry entry) {
for (ChatColor color : ChatColor.values()) {
String colorText = color + "" + ChatColor.WHITE;
if (entry.getText().length() > 16) {
String sub = entry.getText().substring(0, 16);
colorText = colorText + ChatColor.getLastColors(sub);
}
if (!keys.contains(colorText)) {
keys.add(colorText);
return colorText;
}
}
throw new IndexOutOfBoundsException("No more keys available!");
}
public List<String> getBoardEntriesFormatted() {
List<String> toReturn = new ArrayList<>();
for (BoardEntry entry : new ArrayList<>(entries)) {
toReturn.add(entry.getText());
}
return toReturn;
}
public BoardEntry getByPosition(int position) {
int i = 0;
for (BoardEntry board : entries) {
if (i == position) {
return board;
}
i++;
}
return null;
}
public BoardCooldown getCooldown(String id) {
for (BoardCooldown cooldown : getCooldowns()) {
if (cooldown.getId().equals(id)) {
return cooldown;
}
}
return null;
}
public Set<BoardCooldown> getCooldowns() {
cooldowns.removeIf(cooldown -> System.currentTimeMillis() >= cooldown.getEnd());
return cooldowns;
}
}

View File

@ -0,0 +1,17 @@
package aether.scoreboard;
import aether.scoreboard.cooldown.BoardCooldown;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import java.util.List;
import java.util.Set;
public interface BoardAdapter {
String getTitle(Player player);
List<String> getScoreboard(Player player, Board board, Set<BoardCooldown> cooldowns);
void onScoreboardCreate(Player player, Scoreboard board);
}

View File

@ -0,0 +1,90 @@
package aether.scoreboard;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
@Accessors(chain = true)
public class BoardEntry {
@Getter private Board board;
@Getter @Setter private String text;
@Getter private String originalText;
@Getter private String key;
@Getter private Team team;
public BoardEntry(Board board, String text) {
this.board = board;
this.text = text;
this.originalText = text;
this.key = board.getNewKey(this);
setup();
}
public BoardEntry setup() {
Scoreboard scoreboard = board.getScoreboard();
text = ChatColor.translateAlternateColorCodes('&', text);
String teamName = key;
if (teamName.length() > 16) {
teamName = teamName.substring(0, 16);
}
if (scoreboard.getTeam(teamName) != null) {
team = scoreboard.getTeam(teamName);
} else {
team = scoreboard.registerNewTeam(teamName);
}
if (!(team.getEntries().contains(key))) {
team.addEntry(key);
}
if (!(board.getEntries().contains(this))) {
board.getEntries().add(this);
}
return this;
}
public BoardEntry send(int position) {
Objective objective = board.getObjective();
if (text.length() > 16) {
boolean fix = text.toCharArray()[15] == ChatColor.COLOR_CHAR;
String prefix = fix ? text.substring(0, 15) : text.substring(0, 16);
String suffix = fix ? text.substring(15) : ChatColor.getLastColors(prefix) + text.substring(16);
team.setPrefix(prefix);
if (suffix.length() > 16) {
team.setSuffix(suffix.substring(0, 16));
} else {
team.setSuffix(suffix);
}
} else {
team.setPrefix(text);
team.setSuffix("");
}
Score score = objective.getScore(key);
score.setScore(position);
return this;
}
public void remove() {
board.getKeys().remove(key);
board.getScoreboard().resetScores(key);
}
}

View File

@ -0,0 +1,42 @@
package aether.scoreboard.cooldown;
import aether.scoreboard.Board;
import lombok.Getter;
import org.apache.commons.lang3.time.DurationFormatUtils;
import java.text.DecimalFormat;
public class BoardCooldown {
private static final DecimalFormat SECONDS_FORMATTER = new DecimalFormat("#0.0");
@Getter private final Board board;
@Getter private final String id;
@Getter private final double duration;
@Getter private final long end;
public BoardCooldown(Board board, String id, double duration) {
this.board = board;
this.id = id;
this.duration = duration;
this.end = (long) (System.currentTimeMillis() + (duration * 1000));
board.getCooldowns().add(this);
}
public String getFormattedString(BoardFormat format) {
if (format == null) {
throw new NullPointerException();
}
if (format == BoardFormat.SECONDS) {
return SECONDS_FORMATTER.format(((end - System.currentTimeMillis()) / 1000.0f));
} else {
return DurationFormatUtils.formatDuration(end - System.currentTimeMillis(), "mm:ss");
}
}
public void cancel() {
board.getCooldowns().remove(this);
}
}

View File

@ -0,0 +1,5 @@
package aether.scoreboard.cooldown;
public enum BoardFormat {
SECONDS, MINUTES, HOURS
}

View File

@ -0,0 +1,196 @@
package me.trixkz.lifestealcore;
import aether.Aether;
import lombok.Getter;
import me.trixkz.lifestealcore.listeners.*;
import me.trixkz.lifestealcore.managers.*;
import me.trixkz.lifestealcore.managers.chatgames.ChatGameManager;
import me.trixkz.lifestealcore.managers.clans.ClanManager;
import me.trixkz.lifestealcore.managers.envoys.EnvoyManager;
import me.trixkz.lifestealcore.managers.killstreaks.KillstreakManager;
import me.trixkz.lifestealcore.managers.koth.KOTHManager;
import me.trixkz.lifestealcore.managers.leaderboards.LeaderboardManager;
import me.trixkz.lifestealcore.managers.pvpclass.PvPClassManager;
import me.trixkz.lifestealcore.normalmenusystem.PlayerMenuUtil;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.runnables.*;
import me.trixkz.lifestealcore.scoreboard.ScoreboardProvider;
import me.trixkz.lifestealcore.utils.ColorUtils;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import me.trixkz.lifestealcore.utils.config.FileConfig;
import me.trixkz.lifestealcore.utils.config.file.Config;
import net.luckperms.api.LuckPerms;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
@Getter
public class LifeStealCore extends JavaPlugin {
@Getter public static LifeStealCore instance;
private Config settingsConfig;
private FileConfig messagesConfig;
private FileConfig kothsConfig;
private FileConfig lootboxConfig;
private FileConfig envoysConfig;
private CommandManager commandManager;
private ClanManager clanManager;
private ChunkManager chunkManager;
private PvPClassManager pvpClassManager;
private KOTHManager kothManager;
private SpawnManager spawnManager;
private MongoManager mongoManager;
private PlayerDataManager playerDataManager;
private LootboxManager lootboxManager;
private LeaderboardManager leaderboardManager;
private ChatGameManager chatGameManager;
private CombatManager combatManager;
private CooldownManager cooldownManager;
private KillstreakManager killstreakManager;
private EnvoyManager envoyManager;
private LuckPerms luckPerms;
private HashMap<Player, PlayerMenuUtil> playerMenuUtilMap = new HashMap<Player, PlayerMenuUtil>();
private List<UUID> players = new ArrayList<UUID>();
public void onEnable() {
instance = this;
this.saveDefaultConfig();
this.settingsConfig = new Config("config", this);
this.messagesConfig = new FileConfig(this, "messages.yml");
this.kothsConfig = new FileConfig(this, "koths.yml");
this.lootboxConfig = new FileConfig(this, "lootbox.yml");
this.envoysConfig = new FileConfig(this, "envoys.yml");
Bukkit.getConsoleSender().sendMessage("------------------------------------------------");
Bukkit.getConsoleSender().sendMessage(Utils.translate("&dLifestealCore &8- &av" + this.getDescription().getVersion()));
Bukkit.getConsoleSender().sendMessage(Utils.translate("&7Made by &eLoganM Development"));
Bukkit.getConsoleSender().sendMessage("------------------------------------------------");
new Constants();
new ColorUtils();
this.loadManagers();
this.loadListeners();
this.loadRunnables();
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity.getType() != EntityType.PLAYER && entity.getType() != EntityType.ITEM_FRAME) {
entity.remove();
}
}
world.setGameRuleValue("doDaylightCycle", "false");
world.setTime(0L);
world.setStorm(false);
}
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
luckPerms = provider.getProvider();
}
}
public void onDisable() {
for (Player player : this.getServer().getOnlinePlayers()) {
PlayerData playerData = this.playerDataManager.getPlayerData(player.getUniqueId());
this.playerDataManager.savePlayerData(playerData);
}
this.getServer().getScheduler().cancelTask(this.leaderboardManager.getLeaderboard().getHologramTaskId());
this.envoyManager.saveEnvoyLocations();
this.mongoManager.disconnect();
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity.getType() == EntityType.DROPPED_ITEM) {
entity.remove();
}
}
for (Chunk chunk : world.getLoadedChunks()) {
chunk.unload(true);
}
}
instance = null;
}
private void loadManagers() {
this.commandManager = new CommandManager();
this.clanManager = new ClanManager();
this.chunkManager = new ChunkManager();
this.pvpClassManager = new PvPClassManager();
this.kothManager = new KOTHManager();
this.spawnManager = new SpawnManager();
this.mongoManager = new MongoManager();
this.playerDataManager = new PlayerDataManager();
this.lootboxManager = new LootboxManager();
this.leaderboardManager = new LeaderboardManager();
this.chatGameManager = new ChatGameManager();
this.combatManager = new CombatManager();
this.cooldownManager = new CooldownManager();
this.killstreakManager = new KillstreakManager();
this.envoyManager = new EnvoyManager();
}
private void loadListeners() {
Arrays.asList(
new MenuListener(),
new ButtonListener(),
new ClanListeners(),
this.pvpClassManager,
new EventListeners(),
new KOTHListener(),
new RandomListeners(),
new PlayerDataListener(),
new BlockBreakListener(),
new BlockExplodeListener(),
new BlockPlaceListener(),
new BlockSpreadListener(),
new BucketListener(),
new EntityChangeBlockListener(),
new PlayerDeathListener(),
new EntityDamageByEntityListener(),
new EntityDeathListener()
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));
}
private void loadRunnables() {
new Aether(this, new ScoreboardProvider());
new SpawnRunnable();
new ClearLagRunnable();
new CombatTagRunnable();
new EnvoyRunnable();
}
public PlayerMenuUtil getPlayerMenuUtil(Player player) {
PlayerMenuUtil playerMenuUtil;
if (playerMenuUtilMap.containsKey(player)) {
return playerMenuUtilMap.get(player);
} else {
playerMenuUtil = new PlayerMenuUtil(player);
playerMenuUtilMap.put(player, playerMenuUtil);
return playerMenuUtil;
}
}
}

View File

@ -0,0 +1,52 @@
package me.trixkz.lifestealcore.advancedmenusystem;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public abstract class Button {
public static Button placeholder(final Material material, final byte data, String... title) {
return (new Button() {
public ItemStack getButtonItem(Player player) {
ItemStack it = new ItemStack(material, 1, data);
ItemMeta meta = it.getItemMeta();
meta.setDisplayName(StringUtils.join(title));
it.setItemMeta(meta);
return it;
}
});
}
public static void playFail(Player player) {
player.playSound(player.getLocation(), Sound.BLOCK_GRASS_BREAK, 20F, 0.1F);
}
public static void playSuccess(Player player) {
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 20F, 15F);
}
public static void playNeutral(Player player) {
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 20F, 1F);
}
public abstract ItemStack getButtonItem(Player player);
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
}
public boolean shouldCancel(Player player, int slot, ClickType clickType) {
return (true);
}
public boolean shouldUpdate(Player player, int slot, ClickType clickType) {
return (false);
}
}

View File

@ -0,0 +1,151 @@
package me.trixkz.lifestealcore.advancedmenusystem;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.Bukkit;
import org.bukkit.Material;
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.BukkitTask;
import java.util.HashMap;
import java.util.Map;
@Getter @Setter
public abstract class Menu {
private LifeStealCore main = LifeStealCore.getInstance();
public static Map<String, Menu> currentlyOpenedMenus = new HashMap<>();
@Getter private Map<Integer, Button> buttons = new HashMap<>();
private boolean autoUpdate = false;
private boolean updateAfterClick = true;
private boolean closedByMenu = false;
private boolean placeholder = false;
private Button placeholderButton = Button.placeholder(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (byte) 0, " ");
private BukkitTask task;
private ItemStack createItemStack(Player player, Button button) {
ItemStack item = button.getButtonItem(player);
if (item.getType() != Material.PLAYER_HEAD) {
ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasDisplayName()) {
meta.setDisplayName(meta.getDisplayName() + "§b§c§d§e");
}
item.setItemMeta(meta);
}
return item;
}
public void openMenu(final Player player) {
this.buttons = this.getButtons(player);
Menu previousMenu = Menu.currentlyOpenedMenus.get(player.getName());
Inventory inventory = null;
int size = this.getSize() == -1 ? this.size(this.buttons) : this.getSize();
boolean update = false;
String title = this.getTitle(player);
if (title.length() > 32) {
title = title.substring(0, 32);
}
if (player.getOpenInventory() != null) {
if (previousMenu == null) {
player.closeInventory();
} else {
int previousSize = player.getOpenInventory().getTopInventory().getSize();
if (previousSize == size && player.getOpenInventory().getTopInventory().toString().equals(title)) {
inventory = player.getOpenInventory().getTopInventory();
update = true;
} else {
previousMenu.setClosedByMenu(true);
player.closeInventory();
}
}
}
if (inventory == null) {
inventory = Bukkit.createInventory(player, size, title);
}
inventory.setContents(new ItemStack[inventory.getSize()]);
currentlyOpenedMenus.put(player.getName(), this);
for (Map.Entry<Integer, Button> buttonEntry : this.buttons.entrySet()) {
inventory.setItem(buttonEntry.getKey(), createItemStack(player, buttonEntry.getValue()));
}
if (this.isPlaceholder()) {
for (int index = 0; index < size; index++) {
if (this.buttons.get(index) == null) {
this.buttons.put(index, this.placeholderButton);
inventory.setItem(index, this.placeholderButton.getButtonItem(player));
}
}
}
if (update) {
player.updateInventory();
} else {
player.openInventory(inventory);
}
this.setClosedByMenu(false);
if (autoUpdate && task == null) {
task = this.main.getServer().getScheduler().runTaskTimer(this.main, () -> this.openMenu(player), 0, 20L);
}
}
public int size(Map<Integer, Button> buttons) {
int highest = 0;
for (int buttonValue : buttons.keySet()) {
if (buttonValue > highest) {
highest = buttonValue;
}
}
return (int) (Math.ceil((highest + 1) / 9D) * 9D);
}
public int getSlot(int x, int y) {
return ((9 * y) + x);
}
public int getSize() {
return -1;
}
public abstract String getTitle(Player player);
public abstract Map<Integer, Button> getButtons(Player player);
public void onClose(Player player) {
if (task != null) {
task.cancel();
}
}
public void fillEmptySlots(Map<Integer, Button> buttons, ItemStack itemStack) {
int bound = getSize();
for (int slot = 0; slot < bound; slot++) {
if (buttons.get(slot) == null) {
buttons.put(slot, new Button() {
@Override
public ItemStack getButtonItem(Player player) {
return itemStack;
}
});
}
}
}
}

View File

@ -0,0 +1,32 @@
package me.trixkz.lifestealcore.advancedmenusystem.buttons;
import lombok.AllArgsConstructor;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
@AllArgsConstructor
public class BackButton extends Button {
private Menu back;
@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.RED_BED)
.name("&cGo Back")
.lore(Arrays.asList(" ", "&9Click to go back."))
.hideFlags()
.build();
}
@Override
public void clicked(Player player, int i, ClickType clickType, int hb) {
this.back.openMenu(player);
playNeutral(player);
}
}

View File

@ -0,0 +1,31 @@
package me.trixkz.lifestealcore.advancedmenusystem.buttons;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@AllArgsConstructor @Getter @Setter
public class DisplayButton extends Button {
private ItemStack itemStack;
private boolean cancel;
@Override
public ItemStack getButtonItem(Player player) {
if (this.itemStack == null) {
return new ItemStack(Material.AIR);
} else {
return this.itemStack;
}
}
@Override
public boolean shouldCancel(Player player, int slot, ClickType clickType) {
return this.cancel;
}
}

View File

@ -0,0 +1,44 @@
package me.trixkz.lifestealcore.advancedmenusystem.pagination;
import lombok.AllArgsConstructor;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
@AllArgsConstructor
public class JumpToPageButton extends Button {
private int page;
private PaginatedMenu menu;
private boolean current;
@Override
public ItemStack getButtonItem(Player player) {
List<String> lore = new ArrayList<>();
lore.add(" ");
if (this.current) {
lore.add("&9Current page");
} else {
lore.add("&9Other page");
}
lore.add(" ");
return new ItemBuilder(this.current ? Material.LIME_DYE : Material.GRAY_DYE)
.name("&d&lPage: &e" + this.page)
.lore(lore)
.hideFlags()
.build();
}
@Override
public void clicked(Player player, int i, ClickType clickType, int hb) {
this.menu.modPage(player, this.page - this.menu.getPage());
playNeutral(player);
}
}

View File

@ -0,0 +1,54 @@
package me.trixkz.lifestealcore.advancedmenusystem.pagination;
import lombok.AllArgsConstructor;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
@AllArgsConstructor
public class PageButton extends Button {
private int mod;
private PaginatedMenu menu;
@Override
public ItemStack getButtonItem(Player player) {
List<String> lore = new ArrayList<>();
lore.add(" ");
lore.add("&9Right Click to");
lore.add("&9switch to a page.");
lore.add(" ");
return new ItemBuilder(this.hasNext(player) ? (this.mod > 0 ? Material.PURPLE_CARPET : Material.ORANGE_CARPET) : Material.GRAY_CARPET)
.name(this.hasNext(player) ? (this.mod > 0 ? "&aNext Page" : "&cPrevious Page") : (this.mod > 0 ? "&7Last Page" : "&7First Page"))
.lore(lore)
.hideFlags()
.build();
}
@Override
public void clicked(Player player, int i, ClickType clickType, int hb) {
if (clickType == ClickType.RIGHT) {
new ViewAllPagesMenu(this.menu).openMenu(player);
playNeutral(player);
} else {
if (hasNext(player)) {
this.menu.modPage(player, this.mod);
playNeutral(player);
} else {
playFail(player);
}
}
}
private boolean hasNext(Player player) {
int pg = this.menu.getPage() + this.mod;
return pg > 0 && this.menu.getPages(player) >= pg;
}
}

View File

@ -0,0 +1,117 @@
package me.trixkz.lifestealcore.advancedmenusystem.pagination;
import lombok.Getter;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
public abstract class PaginatedMenu extends Menu {
@Getter private int page = 1;
{
setUpdateAfterClick(false);
}
@Override
public String getTitle(Player player) {
return getPrePaginatedTitle(player) + " - " + page + "/" + getPages(player);
}
/**
* Changes the page number
*
* @param player player viewing the inventory
* @param mod delta to modify the page number by
*/
public final void modPage(Player player, int mod) {
page += mod;
getButtons().clear();
openMenu(player);
}
/**
* @param player player viewing the inventory
*/
public final int getPages(Player player) {
int buttonAmount = getAllPagesButtons(player).size();
if (buttonAmount == 0) {
return 1;
}
return (int) Math.ceil(buttonAmount / (double) getMaxItemsPerPage(player));
}
@Override
public final Map<Integer, Button> getButtons(Player player) {
int minIndex = (int) ((double) (page - 1) * getMaxItemsPerPage(player));
int maxIndex = (int) ((double) (page) * getMaxItemsPerPage(player));
HashMap<Integer, Button> buttons = new HashMap<>();
buttons.put(0, new PageButton(-1, this));
buttons.put(8, new PageButton(1, this));
for (Map.Entry<Integer, Button> entry : getAllPagesButtons(player).entrySet()) {
int ind = entry.getKey();
if (ind >= minIndex && ind < maxIndex) {
ind -= (int) ((double) (getMaxItemsPerPage(player)) * (page - 1)) - 9;
buttons.put(ind, entry.getValue());
}
}
Map<Integer, Button> global = getGlobalButtons(player);
if (global != null) {
for (Map.Entry<Integer, Button> gent : global.entrySet()) {
buttons.put(gent.getKey(), gent.getValue());
}
}
return buttons;
}
public int getMaxItemsPerPage(Player player) {
return 18;
}
/**
* @param player player viewing the inventory
*
* @return a Map of buttons that returns items which will be present on all pages
*/
public Map<Integer, Button> getGlobalButtons(Player player) {
return null;
}
protected void bottomTopButtons(boolean full, Map buttons, ItemStack itemStack) {
IntStream.range(0, getSize()).filter(slot -> buttons.get(slot) == null).forEach(slot -> {
if (slot < 9 || slot > getSize() - 10 || full && (slot % 9 == 0 || (slot + 1) % 9 == 0)) {
buttons.put(slot, new Button() {
@Override
public ItemStack getButtonItem(Player player) {
return itemStack;
}
});
}
});
}
/**
* @param player player viewing the inventory
*
* @return title of the inventory before the page number is added
*/
public abstract String getPrePaginatedTitle(Player player);
/**
* @param player player viewing the inventory
*
* @return a map of buttons that will be paginated and spread across pages
*/
public abstract Map<Integer, Button> getAllPagesButtons(Player player);
}

View File

@ -0,0 +1,56 @@
package me.trixkz.lifestealcore.advancedmenusystem.pagination;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.buttons.BackButton;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
@RequiredArgsConstructor
public class ViewAllPagesMenu extends Menu {
@NonNull @Getter
PaginatedMenu menu;
@Override
public String getTitle(Player player) {
return Utils.translate("&eSwitch to page...");
}
@Override
public Map<Integer, Button> getButtons(Player player) {
HashMap<Integer, Button> buttons = new HashMap<>();
buttons.put(0, new BackButton(menu));
int index = 10;
for (int i = 1; i <= menu.getPages(player); i++) {
buttons.put(index++, new JumpToPageButton(i, menu, menu.getPage() == i));
if ((index - 8) % 9 == 0) {
index += 2;
}
}
fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).durability(0).name(" ").build());
return buttons;
}
@Override
public boolean isAutoUpdate() {
return true;
}
@Override
public int getSize() {
return 3 * 9;
}
}

View File

@ -0,0 +1,25 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public class GoBackButton extends Button {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.BARRIER).name(Utils.translate("&4Go back")).amount(1).build();
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
new ShopMenu().openMenu(player);
}
}

View File

@ -0,0 +1,74 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopButton extends Button {
private ItemStack itemStack;
private int data;
private int buyPrice;
private int sellPrice;
private boolean sellable;
@Override
public ItemStack getButtonItem(Player player) {
PlayerData playerData = LifeStealCore.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId());
this.itemStack.setDurability((short) (this.data));
ItemMeta itemMeta = this.itemStack.getItemMeta();
itemMeta.setDisplayName(Utils.translate("&d" + this.itemStack.getType().name()));
List<String> lore = new ArrayList<String>();
lore.add("&9Buy price: &d" + this.buyPrice + " &7&o(Left click)");
if (this.sellable) {
lore.add("&9Sell price: &d" + this.sellPrice + " &7&o(Right click)");
} else {
lore.add("&9Not sellable");
}
itemMeta.setLore(Utils.translate(lore));
this.itemStack.setItemMeta(itemMeta);
return this.itemStack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
PlayerData playerData = LifeStealCore.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId());
this.itemStack.setDurability((short) (this.data));
switch (clickType) {
case LEFT:
new ShopBuyMenu(this.itemStack, this.buyPrice).openMenu(player);
break;
case RIGHT:
if (this.sellable) {
new ShopSellMenu(this.itemStack, this.sellPrice).openMenu(player);
}
break;
}
}
}

View File

@ -0,0 +1,55 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopBuyMenu extends Menu {
private ItemStack itemStack;
private int buyPrice;
@Override
public String getTitle(Player player) {
return Utils.translate("&eBuying " + this.itemStack.getItemMeta().getDisplayName() + "...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
buttons.put(22, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.ITEM));
buttons.put(18, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.SET_TO_ONE));
buttons.put(19, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.REMOVE_TEN));
buttons.put(20, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.REMOVE_ONE));
buttons.put(24, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.ADD_ONE));
buttons.put(25, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.ADD_TEN));
buttons.put(26, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.SET_TO_SIXTY_FOUR));
buttons.put(39, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.CONFIRM));
buttons.put(41, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.CANCEL));
// buttons.put(49, new ShopItemButton(this.itemStack, this.buyPrice, 0, true, ShopItemType.MORE));
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,232 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopItemButton extends Button {
private ItemStack itemStack;
private int buyPrice;
private int sellPrice;
private boolean buy;
private ShopItemType shopItemType;
@Override
public ItemStack getButtonItem(Player player) {
PlayerData playerData = LifeStealCore.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId());
if (this.buy) {
this.buyPrice *= this.itemStack.getAmount();
} else {
this.sellPrice *= this.itemStack.getAmount();
}
ItemStack itemStackCopy = new ItemStack(this.itemStack.getType());
ItemMeta itemMeta = itemStackCopy.getItemMeta();
List<String> lore = new ArrayList<String>();
switch (this.shopItemType) {
case ITEM:
ItemMeta itemMetaCopy = itemStackCopy.getItemMeta();
itemMetaCopy.setDisplayName(Utils.translate("&d" + this.itemStack.getType().name()));
if (this.buy) {
lore.add("&9Buy price: &d" + this.buyPrice);
} else {
lore.add("&9Sell price: &d" + this.sellPrice);
}
itemMetaCopy.setLore(Utils.translate(lore));
this.itemStack.setItemMeta(itemMetaCopy);
break;
case CONFIRM:
if (this.buy) {
lore.add(playerData.getCoins() >= this.buyPrice ? "&aClick to buy" : "&cNot enough coins");
} else {
int itemStacks = 0;
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
if (this.itemStack.getType() == itemStack.getType()) {
itemStacks += itemStack.getAmount();
}
}
lore.add(itemStacks >= this.itemStack.getAmount() ? "&aClick to sell" : "&cNot enough items");
}
itemStackCopy.setType(Material.GREEN_STAINED_GLASS);
itemMeta.setDisplayName(Utils.translate("&aConfirm"));
itemMeta.setLore(Utils.translate(lore));
break;
case CANCEL:
itemStackCopy.setType(Material.RED_STAINED_GLASS);
itemMeta.setDisplayName(Utils.translate("&cCancel"));
break;
case ADD_ONE:
itemStackCopy.setAmount(1);
itemStackCopy.setType(Material.GREEN_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&aAdd 1"));
break;
case ADD_TEN:
itemStackCopy.setAmount(10);
itemStackCopy.setType(Material.GREEN_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&aAdd 10"));
break;
case SET_TO_SIXTY_FOUR:
itemStackCopy.setAmount(64);
itemStackCopy.setType(Material.GREEN_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&aSet to 64"));
break;
case REMOVE_ONE:
itemStackCopy.setAmount(1);
itemStackCopy.setType(Material.RED_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&cRemove 1"));
break;
case REMOVE_TEN:
itemStackCopy.setAmount(10);
itemStackCopy.setType(Material.RED_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&cRemove 10"));
break;
case SET_TO_ONE:
itemStackCopy.setAmount(1);
itemStackCopy.setType(Material.RED_STAINED_GLASS_PANE);
itemMeta.setDisplayName(Utils.translate("&cSet to 1"));
break;
case MORE:
itemStackCopy.setAmount(this.itemStack.getAmount() + 64);
if (this.buy) {
itemStackCopy.setType(Material.GREEN_STAINED_GLASS_PANE);
} else {
itemStackCopy.setType(Material.RED_STAINED_GLASS_PANE);
}
itemMeta.setDisplayName(Utils.translate(this.buy ? "&aBuy more" : "&cSell more"));
break;
}
itemStackCopy.setItemMeta(itemMeta);
return this.shopItemType == ShopItemType.ITEM ? this.itemStack : itemStackCopy;
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
PlayerData playerData = LifeStealCore.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId());
switch (this.shopItemType) {
case ITEM:
break;
case CONFIRM:
if (this.buy) {
if (playerData.getCoins() >= this.buyPrice) {
player.getInventory().addItem(new ItemStack(this.itemStack.getType(), this.itemStack.getAmount()));
playerData.setCoins(playerData.getCoins() - this.buyPrice);
}
} else {
int itemStacks = 0;
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
if (this.itemStack.getType() == itemStack.getType()) {
itemStacks += itemStack.getAmount();
}
}
if (itemStacks >= this.itemStack.getAmount()) {
player.getInventory().removeItem(new ItemStack(this.itemStack.getType(), this.itemStack.getAmount()));
playerData.setCoins(playerData.getCoins() + this.itemStack.getAmount());
}
}
break;
case CANCEL:
player.closeInventory();
break;
case ADD_ONE:
this.itemStack.setAmount(this.itemStack.getAmount() + 1);
break;
case ADD_TEN:
this.itemStack.setAmount(this.itemStack.getAmount() + 10);
break;
case SET_TO_SIXTY_FOUR:
this.itemStack.setAmount(64);
break;
case REMOVE_ONE:
this.itemStack.setAmount(this.itemStack.getAmount() - 1);
if (this.itemStack.getAmount() < 1) {
this.itemStack.setAmount(1);
}
break;
case REMOVE_TEN:
this.itemStack.setAmount(this.itemStack.getAmount() - 10);
if (this.itemStack.getAmount() < 1) {
this.itemStack.setAmount(1);
}
break;
case SET_TO_ONE:
this.itemStack.setAmount(1);
break;
case MORE:
break;
}
player.updateInventory();
}
}

View File

@ -0,0 +1,39 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ShopItemMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public String getTitle(Player player) {
return Utils.translate("&eShop menu");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
for (ShopType shopType : ShopType.values()) {
buttons.put(shopType.getSlot(), new ShopTypeButton(shopType));
}
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,19 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopItemSet<Material, Data, BuyPrice, SellPrice, Sellable> {
private Material material = null;
private Data data = null;
private BuyPrice buyPrice = null;
private SellPrice sellPrice = null;
private Sellable sellable = null;
}

View File

@ -0,0 +1,15 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
public enum ShopItemType {
ITEM,
CONFIRM,
CANCEL,
ADD_ONE,
ADD_TEN,
SET_TO_SIXTY_FOUR,
REMOVE_ONE,
REMOVE_TEN,
SET_TO_ONE,
MORE;
}

View File

@ -0,0 +1,39 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ShopMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public String getTitle(Player player) {
return Utils.translate("&eShop menu");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
for (ShopType shopType : ShopType.values()) {
buttons.put(shopType.getSlot(), new ShopTypeButton(shopType));
}
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,55 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopSellMenu extends Menu {
private ItemStack itemStack;
private int sellPrice;
@Override
public String getTitle(Player player) {
return Utils.translate("&eSelling " + this.itemStack.getItemMeta().getDisplayName() + "...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
buttons.put(22, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.ITEM));
buttons.put(18, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.SET_TO_ONE));
buttons.put(19, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.REMOVE_TEN));
buttons.put(20, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.REMOVE_ONE));
buttons.put(24, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.ADD_ONE));
buttons.put(25, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.ADD_TEN));
buttons.put(26, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.SET_TO_SIXTY_FOUR));
buttons.put(39, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.CONFIRM));
buttons.put(41, new ShopItemButton(this.itemStack, 0, this.sellPrice, false, ShopItemType.CANCEL));
// buttons.put(49, new ShopItemButton(this.itemStack, 0, this.sellPrice, true, ShopItemType.MORE));
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,144 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material;
import java.util.Arrays;
import java.util.List;
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum ShopType {
BLOCKS(
"&dBlocks",
Arrays.asList(
"&9Click to open the &dBlocks &9section"
),
Material.GRASS,
0,
11
),
FOOD(
"&dFood",
Arrays.asList(
"&9Click to open the &dFood &9section"
),
Material.COOKED_BEEF,
0,
12
),
COLORFUL_BLOCKS(
"&dColorful blocks",
Arrays.asList(
"&9Click to open the &dColorful blocks &9section"
),
Material.STONE,
0,
13
),
ORES(
"&dOres",
Arrays.asList(
"&9Click to open the &dOres &9section"
),
Material.DIAMOND,
0,
14
),
COMBAT(
"&dCombat",
Arrays.asList(
"&9Click to open the &dCombat &9section"
),
Material.DIAMOND_SWORD,
0,
15
),
FARMING(
"&dFarming",
Arrays.asList(
"&9Click to open the &dFarming &9section"
),
Material.WHEAT,
0,
20
),
MOB_DROPS(
"&dMob drops",
Arrays.asList(
"&9Click to open the &dMob drops &9section"
),
Material.ROTTEN_FLESH,
0,
21
),
DYES_AND_PLANTS(
"&dDyes and plants",
Arrays.asList(
"&9Click to open the &dDyes and plants &9section"
),
Material.INK_SAC,
14,
22
),
POTIONS(
"&dPotions",
Arrays.asList(
"&9Click to open the &dPotions &9section"
),
Material.POTION,
8229,
23
),
REDSTONE(
"&dRedstone",
Arrays.asList(
"&9Click to open the &dRedstone &9section"
),
Material.REDSTONE,
0,
24
),
CUSTOM_ITEMS(
"&dCustom items",
Arrays.asList(
"&9Click to open the &dCustom items &9section"
),
Material.NETHER_STAR,
0,
30
),
SPAWNERS(
"&dSpawners",
Arrays.asList(
"&9Click to open the &dSpawners &9section"
),
Material.SPAWNER,
0,
32
);
private String name;
private List<String> lore;
private Material material;
private int data;
private int slot;
public static ShopType getShopByName(String name) {
return Arrays.stream(values()).filter(shopType -> shopType.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
}
}

View File

@ -0,0 +1,92 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.shop.blocks.BlocksMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.colorfulblocks.ColorfulBlocksMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.combat.CombatMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.customitems.CustomItemsMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.dyesandplants.DyesAndPlantsMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.farming.FarmingMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.food.FoodMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.mobdrops.MobDropsMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ores.OresMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.potions.PotionsMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.redstone.RedstoneMenu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.spawners.SpawnersMenu;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ShopTypeButton extends Button {
private ShopType shopType;
@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(this.shopType.getMaterial()).name(Utils.translate(this.shopType.getName())).lore(Utils.translate(this.shopType.getLore())).durability(this.shopType.getData()).build();
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
switch (this.shopType) {
case BLOCKS:
new BlocksMenu().openMenu(player);
break;
case FOOD:
new FoodMenu().openMenu(player);
break;
case COLORFUL_BLOCKS:
new ColorfulBlocksMenu().openMenu(player);
break;
case ORES:
new OresMenu().openMenu(player);
break;
case COMBAT:
new CombatMenu().openMenu(player);
break;
case FARMING:
new FarmingMenu().openMenu(player);
break;
case MOB_DROPS:
new MobDropsMenu().openMenu(player);
break;
case DYES_AND_PLANTS:
new DyesAndPlantsMenu().openMenu(player);
break;
case POTIONS:
new PotionsMenu().openMenu(player);
break;
case REDSTONE:
new RedstoneMenu().openMenu(player);
break;
case CUSTOM_ITEMS:
new CustomItemsMenu().openMenu(player);
break;
case SPAWNERS:
new SpawnersMenu().openMenu(player);
break;
}
}
}

View File

@ -0,0 +1,105 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.blocks;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class BlocksMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public BlocksMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 0, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 1, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 2, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 3, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 4, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 5, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE, 6, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.OBSIDIAN, 0, 3500, 450, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GRASS, 0, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.DIRT, 0, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.DIRT, 1, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.DIRT, 2, 8, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COBBLESTONE, 0, 8, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.LOG, 0, 3000, 2500, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.LOG, 1, 3000, 2500, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.LOG, 2, 3000, 2500, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.LOG, 3, 3000, 2500, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 0, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 1, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 2, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 3, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 4, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD, 5, 30, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.LEAVES, 0, 60, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.LEAVES, 1, 60, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.LEAVES, 2, 60, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.LEAVES, 3, 60, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.SAND, 0, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SAND, 1, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SANDSTONE, 0, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SANDSTONE, 1, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SANDSTONE, 2, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RED_SANDSTONE, 0, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RED_SANDSTONE, 1, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RED_SANDSTONE, 2, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GLASS, 0, 4, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SNOW_BLOCK, 0, 25, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.ICE, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.PACKED_ICE, 0, 40, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.NETHERRACK, 0, 15, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SOUL_SAND, 0, 80, 15, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GLOWSTONE, 0, 20, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.QUARTZ_BLOCK, 0, 15, 10, true));
this.shopItemSets.add(new ShopItemSet<>(Material.QUARTZ_BLOCK, 1, 15, 5, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,109 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.colorfulblocks;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class ColorfulBlocksMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public ColorfulBlocksMenu() {
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 1, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 2, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 3, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 4, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 5, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 6, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 7, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 8, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 9, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 10, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 11, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 12, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 13, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 14, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_CLAY, 15, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 1, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 2, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 3, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 4, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 5, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 6, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 7, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 8, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 9, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 10, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 11, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 12, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 13, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 14, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STAINED_GLASS, 15, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 1, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 2, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 3, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 4, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 5, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 6, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 7, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 8, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 9, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 10, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 11, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 12, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 13, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 14, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOL, 15, 75, 0, false));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,81 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.combat;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class CombatMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public CombatMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_SWORD, 0, 8000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_SWORD, 0, 200, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.BOW, 0, 150, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.FISHING_ROD, 0, 150, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_PICKAXE, 0, 12000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_AXE, 0, 12000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_SHOVEL, 0, 4000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_HOE, 0, 8000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_PICKAXE, 0, 325, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_AXE, 0, 300, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_SHOVEL, 0, 100, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_HOE, 0, 200, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_HELMET, 0, 20000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_CHESTPLATE, 0, 32000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_LEGGINGS, 0, 28000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_BOOTS, 0, 16000, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_HELMET, 0, 500, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_CHESTPLATE, 0, 800, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_LEGGINGS, 0, 700, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_BOOTS, 0, 400, 0, false));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,62 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.customitems;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class CustomItemsMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public CustomItemsMenu() {
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,93 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.dyesandplants;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class DyesAndPlantsMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public DyesAndPlantsMenu() {
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 0, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 1, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 2, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 3, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 4, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 5, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 6, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 7, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 8, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 9, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 10, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 11, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 12, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 13, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 14, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.INK_SACK, 15, 50, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 0, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 1, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 2, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 3, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 4, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 5, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 6, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 7, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 8, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.YELLOW_FLOWER, 0, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 0, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 1, 15, 2, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 2, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 3, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 4, 20, 1, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.DOUBLE_PLANT, 5, 20, 1, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,84 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.farming;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class FarmingMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public FarmingMenu() {
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 0, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 1, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 2, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 3, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 4, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SAPLING, 5, 2000, 200, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.SEEDS, 0, 150, 1, true));
this.shopItemSets.add(new ShopItemSet<>(Material.MELON_SEEDS, 0, 100, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.PUMPKIN_SEEDS, 0, 100, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.NETHER_WARTS, 0, 150, 70, true));
this.shopItemSets.add(new ShopItemSet<>(Material.INK_SAC, 3, 20, 1, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BROWN_MUSHROOM, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RED_MUSHROOM, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SUGAR_CANE, 0, 2700, 2000, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BOOK, 0, 30, 15, true));
this.shopItemSets.add(new ShopItemSet<>(Material.PAPER, 0, 20, 10, true));
this.shopItemSets.add(new ShopItemSet<>(Material.WHEAT, 0, 150, 50, true));
this.shopItemSets.add(new ShopItemSet<>(Material.VINE, 0, 10, 1, true));
this.shopItemSets.add(new ShopItemSet<>(Material.CACTUS, 0, 50, 10, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.MELON_BLOCK, 0, 1000, 100, true));
this.shopItemSets.add(new ShopItemSet<>(Material.PUMPKIN, 0, 500, 150, true));
this.shopItemSets.add(new ShopItemSet<>(Material.WATER_BUCKET, 0, 75, 150, false));
this.shopItemSets.add(new ShopItemSet<>(Material.LAVA_BUCKET, 0, 8000, 400, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,78 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.food;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class FoodMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public FoodMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.COOKED_CHICKEN, 0, 25, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COOKED_BEEF, 0, 25, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.GRILLED_PORK, 0, 25, 4, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.COOKED_FISH, 0, 40, 6, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COOKED_RABBIT, 0, 30, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COOKED_MUTTON, 0, 25, 3, true));
this.shopItemSets.add(new ShopItemSet<>(Material.ROTTEN_FLESH, 0, 25, 6, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BAKED_POTATO, 0, 25, 9, true));
this.shopItemSets.add(new ShopItemSet<>(Material.POTATO, 0, 25, 9, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BREAD, 0, 40, 13, true));
this.shopItemSets.add(new ShopItemSet<>(Material.CARROT, 0, 150, 50, true));
this.shopItemSets.add(new ShopItemSet<>(Material.MELON, 0, 200, 10, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.MUSHROOM_SOUP, 0, 40, 4, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RABBIT_STEW, 0, 100, 18, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GOLDEN_APPLE, 0, 4250, 500, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GOLDEN_APPLE, 1, 36000, 2750, true));
this.shopItemSets.add(new ShopItemSet<>(Material.APPLE, 0, 250, 5, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a food to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,81 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.mobdrops;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class MobDropsMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public MobDropsMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.GHAST_TEAR, 0, 5000, 50, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GOLD_NUGGET, 0, 1000, 10, true));
this.shopItemSets.add(new ShopItemSet<>(Material.FEATHER, 0, 15, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.LEATHER, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.EGG, 0, 50, 35, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RED_ROSE, 0, 15, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BONE, 0, 25, 5, true));
this.shopItemSets.add(new ShopItemSet<>(Material.ROTTEN_FLESH, 0, 25, 5, true));
this.shopItemSets.add(new ShopItemSet<>(Material.ARROW, 0, 15, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.SPIDER_EYE, 0, 20, 5, true));
this.shopItemSets.add(new ShopItemSet<>(Material.STRING, 0, 15, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.RABBIT_HIDE, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.ENDER_PEARL, 0, 100, 10, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.EYE_OF_ENDER, 0, 50, 5, true));
this.shopItemSets.add(new ShopItemSet<>(Material.BLAZE_ROD, 0, 50, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RAW_BEEF, 0, 20, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.PORK, 0, 20, 5, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.RAW_CHICKEN, 0, 20, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.MUTTON, 0, 20, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.NETHER_STAR, 0, 10000, 3000, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,76 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.ores;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class OresMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public OresMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_INGOT, 0, 200, 5, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GOLD_INGOT, 0, 800, 40, true));
this.shopItemSets.add(new ShopItemSet<>(Material.EMERALD, 0, 3000, 100, true));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND, 0, 4000, 70, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COAL, 0, 25, 2, true));
this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE, 0, 55, 10, true));
this.shopItemSets.add(new ShopItemSet<>(Material.INK_SAC, 4, 50, 1, true));
this.shopItemSets.add(new ShopItemSet<>(Material.IRON_BLOCK, 0, 6000, 45, true));
this.shopItemSets.add(new ShopItemSet<>(Material.GOLD_BLOCK, 0, 8000, 440, true));
this.shopItemSets.add(new ShopItemSet<>(Material.EMERALD_BLOCK, 0, 20000, 900, true));
this.shopItemSets.add(new ShopItemSet<>(Material.DIAMOND_BLOCK, 0, 40000, 770, true));
this.shopItemSets.add(new ShopItemSet<>(Material.COAL_BLOCK, 0, 675, 22, true));
this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE_BLOCK, 0, 3000, 80, true));
this.shopItemSets.add(new ShopItemSet<>(Material.LAPIS_BLOCK, 0, 1350, 10, true));
this.shopItemSets.add(new ShopItemSet<>(Material.QUARTZ, 0, 500, 6, true));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,62 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.potions;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class PotionsMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public PotionsMenu() {
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,80 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.redstone;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class RedstoneMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public RedstoneMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE, 0, 50, 10, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE_TORCH_ON, 0, 50, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE_COMPARATOR, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.PISTON_BASE, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.PISTON_STICKY_BASE, 0, 75, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.HOPPER, 0, 12500, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DISPENSER, 0, 75, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.DROPPER, 0, 75, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.LEVER, 0, 25, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.STONE_BUTTON, 0, 25, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD_BUTTON, 0, 25, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.STONE_PLATE, 0, 50, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.WOOD_PLATE, 0, 50, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.CARPET, 0, 150, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.TRIPWIRE_HOOK, 0, 75, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE_BLOCK, 0, 3000, 75, true));
// this.shopItemSets.add(new ShopItemSet<>(Material.REDSTONE_LAMP_ON, 0, 75, 0, false));
this.shopItemSets.add(new ShopItemSet<>(Material.FURNACE, 0, 75, 0, false));
// this.shopItemSets.add(new ShopItemSet<>(Material.TRAP_DOOR, 0, 50, 0, false));
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,75 @@
package me.trixkz.lifestealcore.advancedmenusystem.shop.spawners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import me.trixkz.lifestealcore.advancedmenusystem.shop.GoBackButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopButton;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopItemSet;
import me.trixkz.lifestealcore.utils.ItemBuilder;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class SpawnersMenu extends Menu {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ShopItemSet<Material, Integer, Integer, Integer, Boolean>> shopItemSets = new ArrayList<ShopItemSet<Material, Integer, Integer, Integer, Boolean>>();
public SpawnersMenu() {
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 1460000, 0, false)); // pig
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 1300000, 0, false)); // chicken
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 920000, 0, false)); // sheep
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 2000000, 0, false)); // cow
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 2750000, 0, false)); // zombie
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 4000000, 0, false)); // rabbit
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 8500000, 0, false)); // skeleton
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 6000000, 0, false)); // spider
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 12000000, 0, false)); // zombie pigman
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 18000000, 0, false)); // blaze
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 15000000, 0, false)); // creeper
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 10000000, 0, false)); // enderman
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 28000000, 0, false)); // iron golem
this.shopItemSets.add(new ShopItemSet<>(Material.SPAWNER, 0, 36000000, 0, false)); // guardian
}
@Override
public String getTitle(Player player) {
return Utils.translate("&eClick a block to buy or sell...");
}
@Override
public int getSize() {
return 54;
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = new HashMap<Integer, Button>();
AtomicInteger atomicInteger = new AtomicInteger(0);
this.shopItemSets.forEach((shopItemSet) -> {
if (atomicInteger.get() == 49) {
atomicInteger.addAndGet(1);
}
buttons.put(atomicInteger.get(), new ShopButton(new ItemStack(shopItemSet.getMaterial(), 1), shopItemSet.getData(), shopItemSet.getBuyPrice(), shopItemSet.getSellPrice(), shopItemSet.getSellable()));
atomicInteger.addAndGet(1);
});
buttons.put(49, new GoBackButton());
this.fillEmptySlots(buttons, new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(Utils.translate("")).durability(0).build());
return buttons;
}
}

View File

@ -0,0 +1,17 @@
package me.trixkz.lifestealcore.chatcolor;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class ColorSet<R, G, B> {
private R red = null;
private G green = null;
private B blue = null;
}

View File

@ -0,0 +1,16 @@
package me.trixkz.lifestealcore.chatcolor;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class GradientColor {
private ColorSet<Integer, Integer, Integer> colorCodeOne;
private ColorSet<Integer, Integer, Integer> colorCodeTwo;
}

View File

@ -0,0 +1,53 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public abstract class BaseCommand implements CommandExecutor {
private LifeStealCore main = LifeStealCore.getInstance();
private CommandInfo commandInfo;
public BaseCommand() {
this.commandInfo = this.getClass().getDeclaredAnnotation(CommandInfo.class);
}
public abstract void executeAs(Player player, String[] args);
public abstract void executeAs(CommandSender sender, String[] args);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!this.commandInfo.permission().equals("")) {
if (!sender.hasPermission(this.commandInfo.permission())) {
sender.sendMessage(Utils.translate(Constants.PREFIX + "No permission"));
return true;
}
}
if (this.commandInfo.player()) {
if (!(sender instanceof Player)) {
sender.sendMessage(Utils.translate(Constants.PREFIX + "You have to be a player to do this"));
return true;
}
Player player = (Player) sender;
this.executeAs(player, args);
return true;
}
this.executeAs(sender, args);
return true;
}
}

View File

@ -0,0 +1,16 @@
package me.trixkz.lifestealcore.commands;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandInfo {
String name();
String permission();
boolean player();
}

View File

@ -0,0 +1,44 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.CustomLocation;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@CommandInfo(name = "envoy", permission = "skyblock.admin", player = true)
public class EnvoyCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
FileConfiguration config = this.main.getEnvoysConfig().getConfig();
if (args.length == 0) {
player.sendMessage(Utils.translate("&cUsage:"));
player.sendMessage(Utils.translate(" &c/envoy start"));
player.sendMessage(Utils.translate(" &c/envoy addlocation"));
} else {
switch (args[0].toLowerCase()) {
case "start":
this.main.getEnvoyManager().startEnvoyEvent();
break;
case "addlocation":
this.main.getEnvoyManager().getEnvoyLocations().add(CustomLocation.fromBukkitLocation(player.getLocation()));
player.sendMessage(ChatColor.GREEN + "Successfully added another location");
break;
}
}
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,46 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "lootbox", permission = "lifestealcore.admin", player = true)
public class LootboxCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
if (args.length == 0) {
player.sendMessage(Utils.translate("&cUsage:"));
player.sendMessage(Utils.translate(" &c/lootbox give <player> <amount>"));
} else {
switch (args[0].toLowerCase()) {
case "give":
Player target = this.main.getServer().getPlayer(args[1]);
if (target == null) {
return;
}
if (!Utils.isNumeric(args[2])) {
return;
}
int amount = Integer.parseInt(args[2]);
target.getInventory().addItem(this.main.getLootboxManager().getLootboxItemStack(player, amount));
player.sendMessage(Utils.translate(Constants.PREFIX + "You have given " + target.getName() + " " + amount + " lootbox" + (amount == 1 ? "" : "es")));
break;
}
}
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,41 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.UUID;
@CommandInfo(name = "sethearts", permission = "lifestealcore.admin", player = false)
public class SetHeartsCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
}
@Override
public void executeAs(CommandSender sender, String[] args) {
Player target = this.main.getServer().getPlayer(args[0]);
if (target == null) {
return;
}
UUID targetUUID = target.getUniqueId();
PlayerData targetData = this.main.getPlayerDataManager().getPlayerData(targetUUID);
double amount = Double.parseDouble(args[1]);
target.setMaxHealth(amount);
targetData.setHearts(target.getMaxHealth());
sender.sendMessage(Utils.translate("&eYou have set &d" + target.getName() + " &ehearts to &d" + target.getMaxHealth()));
}
}

View File

@ -0,0 +1,25 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.shop.ShopMenu;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "shop", permission = "", player = true)
public class ShopCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
new ShopMenu().openMenu(player);
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,21 @@
package me.trixkz.lifestealcore.commands;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "spawn", permission = "", player = true)
public class SpawnCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
this.main.getSpawnManager().getPlayers().put(player.getUniqueId(), 5);
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,141 @@
package me.trixkz.lifestealcore.commands.clan;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.clans.Clan;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.UUID;
@CommandInfo(name = "clan", permission = "", player = true)
public class ClanCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
private ArrayList<String> message = new ArrayList<String>();
@Override
public void executeAs(Player player, String[] args) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (args.length == 0) {
if (!this.main.getClanManager().isAClanMember(player)) {
player.sendMessage(Utils.translate(Constants.PREFIX + Constants.NO_CLAN_MESSAGE));
return;
}
// to do
// new IslandManageMenu(this.main.getPlayerMenuUtil(player)).open(player);
} else {
switch (args[0].toLowerCase()) {
case "help":
this.message.add(Utils.chatBar);
this.message.add("&dClan Commands &7(&fPlayer&7)");
this.message.add(Utils.chatBar);
// to do
//this.message.add("&7⚫ &9/clan &7- &eOpen the clan manage menu");
this.message.add("&7⚫ &9/clan create &7- &eCreate your clan");
this.message.add("&7⚫ &9/clan delete &7- &eDelete your clan");
this.message.add("&7⚫ &9/clan join <player> &7- &eJoin a player's clan that you have been invited to");
this.message.add("&7⚫ &9/clan leave &7- &eLeave your clan");
this.message.add("&7⚫ &9/clan invite <player> &7- &eGive a player access to your clan");
this.message.add("&7⚫ &9/clan uninvite <player> &7- &eRemove a player's access to your clan");
this.message.add("&7⚫ &9/clan top &7- &eOpen the top clans menu");
this.message.add("&7⚫ &9/clan kick <player> &7- &eKick a player from your clan");
this.message.add("&7⚫ &9/clan level &7- &eLook at your clan's level");
this.message.add("&7⚫ &9/clan setname <name> &7- &eSet a name for your clan");
this.message.add(Utils.chatBar);
for (String string : this.message) {
player.sendMessage(Utils.translate(string));
}
this.message.clear();
break;
case "create":
this.main.getClanManager().makeClan(player);
break;
case "delete":
this.main.getClanManager().deleteIsland(player);
break;
case "join":
UUID joinTarget = this.main.getServer().getPlayer(args[1]).getUniqueId();
PlayerData joinTargetPlayerData = this.main.getPlayerDataManager().getPlayerData(joinTarget);
this.main.getClanManager().joinClan(joinTargetPlayerData.getClanOwner(), player);
break;
case "leave":
this.main.getClanManager().leaveClan(playerData.getClanOwner(), player);
break;
case "invite":
Player inviteTarget = this.main.getServer().getPlayer(args[1]);
this.main.getClanManager().createClanInvite(player, inviteTarget);
break;
case "uninvite":
Utils.getOfflinePlayer(args[1], (offlinePlayer) -> {
this.main.getClanManager().removeClanInvite(player, offlinePlayer);
});
break;
case "top":
// new ClanTopMenu(this.main.getPlayerMenuUtil(player)).open(player);
break;
case "kick":
Utils.getOfflinePlayer(args[1], (offlinePlayer) -> {
this.main.getClanManager().kickPlayerFromClan(player, offlinePlayer);
});
break;
case "level":
this.main.getClanManager().lookAtClanLevel(player);
break;
case "setname":
if (!this.main.getClanManager().isOwner(player)) {
player.sendMessage(Utils.translate(Constants.PREFIX + "No permission, you have to be the owner of the island"));
return;
}
Clan clan = this.main.getClanManager().getClan(playerData.getClanOwner());
String name = args[1];
if (name == null) {
return;
}
clan.setName(name);
clan.sendMessageToAllClanMembers(Utils.translate(Constants.CLAN_PREFIX + "The island's name is &9" + name));
break;
}
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,151 @@
package me.trixkz.lifestealcore.commands.coins;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
@CommandInfo(name = "coins", permission = "", player = true)
public class CoinsCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
private ArrayList<String> message = new ArrayList<String>();
@Override
public void executeAs(Player player, String[] args) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
DecimalFormat decimalFormat = new DecimalFormat("##.##");
if (args.length == 0) {
player.sendMessage(Utils.translate(Constants.PREFIX + this.main.getMessagesConfig().getConfig().getString("COINS.BALANCE").replace("%coins%", decimalFormat.format(playerData.getCoins()))));
return;
} else {
switch (args[0].toLowerCase()) {
case "help":
for (String string : this.main.getMessagesConfig().getConfig().getStringList("COINS.HELP_MESSAGE.PLAYER")) {
this.message.add(string.replace("%line%", Utils.chatBar));
}
if (player.hasPermission("skyblock.admin")) {
for (String string : this.main.getMessagesConfig().getConfig().getStringList("COINS.HELP_MESSAGE.ADMIN")) {
this.message.add(string.replace("%line%", Utils.chatBar));
}
}
for (String string : this.message) {
player.sendMessage(Utils.translate(string));
}
this.message.clear();
return;
case "pay":
Player payTarget = this.main.getServer().getPlayer(args[1]);
if (payTarget == null) {
return;
}
PlayerData payTargetPlayerData = this.main.getPlayerDataManager().getPlayerData(payTarget.getUniqueId());
if (!Utils.isNumeric(args[2])) {
return;
}
double payAmount = Double.parseDouble(args[2]);
if (playerData.getCoins() >= payAmount) {
playerData.setCoins(playerData.getCoins() - payAmount);
payTargetPlayerData.setCoins(payTargetPlayerData.getCoins() + payAmount);
}
player.sendMessage(Utils.translate("&aPaid &a&l" + payTarget.getName() + "&a's &a&l" + decimalFormat.format(payAmount) + " &acoins"));
payTarget.sendMessage(Utils.translate("&a&l" + player.getName() + " &ahas paid you &a&l" + decimalFormat.format(payAmount) + " &acoins"));
return;
case "set":
case "add":
case "remove":
if (!player.hasPermission("skyblock.admin")) {
player.sendMessage(Utils.translate("&cNo permission"));
return;
}
Player target = this.main.getServer().getPlayer(args[1]);
if (target == null) {
return;
}
PlayerData targetPlayerData = this.main.getPlayerDataManager().getPlayerData(target.getUniqueId());
if (!Utils.isNumeric(args[2])) {
return;
}
double amount = Double.parseDouble(args[2]);
switch (args[0].toLowerCase()) {
case "set":
targetPlayerData.setCoins(amount);
player.sendMessage(Utils.translate("&aSet &a&l" + target.getName() + " &acoins balance to &a&l" + decimalFormat.format(amount)));
target.sendMessage(Utils.translate("&aCoins balance updated, you now have &a&l" + decimalFormat.format(targetPlayerData.getCoins()) + " &acoins"));
break;
case "add":
targetPlayerData.setCoins(targetPlayerData.getCoins() + amount);
player.sendMessage(Utils.translate("&aAdded &a&l" + decimalFormat.format(amount) + " &acoins to &a&l" + target.getName() + "&a's coins balance"));
target.sendMessage(Utils.translate("&aCoins balance updated, you now have &a&l" + decimalFormat.format(targetPlayerData.getCoins()) + " &acoins"));
break;
case "remove":
if (targetPlayerData.getCoins() >= amount) {
targetPlayerData.setCoins(targetPlayerData.getCoins() - amount);
}
player.sendMessage(Utils.translate("&aRemoved &a&l" + decimalFormat.format(amount) + " &acoins to &a&l" + target.getName() + "&a's coins balance"));
target.sendMessage(Utils.translate("&aCoins balance updated, you now have &a&l" + decimalFormat.format(targetPlayerData.getCoins()) + " &acoins"));
break;
}
break;
}
if (!player.hasPermission("skyblock.admin")) {
player.sendMessage(Utils.translate("&cNo permission"));
return;
}
Player target = this.main.getServer().getPlayer(args[0]);
if (target == null) {
return;
}
PlayerData targetPlayerData = this.main.getPlayerDataManager().getPlayerData(target.getUniqueId());
player.sendMessage(Utils.translate("&a&l" + target.getName() + " &ahas &a&l" + decimalFormat.format(targetPlayerData.getCoins()) + " &acoins"));
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,37 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.CustomLocation;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class CreateCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = new KOTH(name, CustomLocation.fromBukkitLocation(player.getLocation()));
player.sendMessage(Utils.translate(Constants.PREFIX + "You have made a KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,48 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.event.EventScheduledTime;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Date;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class DisableCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
koth.disable();
EventScheduledTime eventScheduledTime = EventScheduledTime.parse(new Date());
this.main.getKothManager().getKothSchedule().remove(eventScheduledTime);
player.sendMessage(Utils.translate(Constants.PREFIX + "You have disabled the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,50 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class EnableCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH kothOne = this.main.getKothManager().getKOTH(name);
if (kothOne == null) {
return;
}
for (KOTH kothTwo : this.main.getKothManager().getKoths().values()) {
if (kothTwo.isActive()) {
player.sendMessage(Utils.translate(Constants.PREFIX + "&d" + kothTwo.getName() + " &eis active"));
return;
}
}
kothOne.enable();
player.sendMessage(Utils.translate(Constants.PREFIX + "You have enabled the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,68 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class KOTHCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
if (args.length == 0) {
} else {
switch (args[0].toLowerCase()) {
case "create":
new CreateCommand().executeAs(player, args);
break;
case "remove":
new RemoveCommand().executeAs(player, args);
break;
case "enable":
new EnableCommand().executeAs(player, args);
break;
case "disable":
new DisableCommand().executeAs(player, args);
break;
case "setlocation":
new SetLocationCommand().executeAs(player, args);
break;
case "settime":
new SetTimeCommand().executeAs(player, args);
break;
case "setdistance":
new SetDistanceCommand().executeAs(player, args);
break;
case "list":
break;
case "teleport":
new TeleportCommand().executeAs(player, args);
break;
case "player":
new PlayerCommand().executeAs(player, args);
break;
}
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,48 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class PlayerCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
if (koth.isActive()) {
if (koth.getPlayer() == null) {
player.sendMessage(Utils.translate(Constants.PREFIX + "There is no player capping the KOTH called &d" + koth.getName()));
} else {
player.sendMessage(Utils.translate(Constants.PREFIX + "&d" + this.main.getServer().getPlayer(koth.getPlayer()) + " &eis capping the KOTH called &d" + koth.getName()));
}
} else {
player.sendMessage(Utils.translate(Constants.PREFIX + "There is no KOTH active"));
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,36 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class RemoveCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
this.main.getKothManager().removeKOTH(name);
this.main.getKothManager().saveKOTHs();
player.sendMessage(Utils.translate(Constants.PREFIX + "You have removed the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,48 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class SetDistanceCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
if (!Utils.isNumeric(args[2])) {
return;
}
int distance = Integer.parseInt(args[2]);
koth.setDistance(distance);
player.sendMessage(Utils.translate(Constants.PREFIX + "You have set the distance to &d" + distance + " &e for the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,43 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.CustomLocation;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class SetLocationCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
koth.setLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
player.sendMessage(Utils.translate(Constants.PREFIX + "You have set the location for the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,48 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class SetTimeCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
if (!Utils.isNumeric(args[2])) {
return;
}
int time = Integer.parseInt(args[2]);
koth.setTime(time);
player.sendMessage(Utils.translate(Constants.PREFIX + "You have set the time to &d" + time + " &e for the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,41 @@
package me.trixkz.lifestealcore.commands.koth;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandInfo(name = "koth", permission = "lifestealcore.admin", player = true)
public class TeleportCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
String name = args[1];
if (name == null) {
return;
}
KOTH koth = this.main.getKothManager().getKOTH(name);
if (koth == null) {
return;
}
player.teleport(koth.getCustomLocation().toBukkitLocation());
player.sendMessage(Utils.translate(Constants.PREFIX + "You have teleported to the KOTH called &d" + name));
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,36 @@
package me.trixkz.lifestealcore.commands.setspawn;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.utils.CustomLocation;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@CommandInfo(name = "setspawn", permission = "lifestealcore.admin", player = true)
public class MaxCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
this.saveLocation(player, "spawn.max");
player.sendMessage(ChatColor.GREEN + "Successfully set the max location.");
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
private void saveLocation(Player player, String location) {
FileConfiguration config = this.main.getSettingsConfig().getConfig();
config.set(location, CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
}
}

View File

@ -0,0 +1,36 @@
package me.trixkz.lifestealcore.commands.setspawn;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.utils.CustomLocation;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@CommandInfo(name = "setspawn", permission = "lifestealcore.admin", player = true)
public class MinCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
this.saveLocation(player, "spawn.min");
player.sendMessage(ChatColor.GREEN + "Successfully set the min location.");
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
private void saveLocation(Player player, String location) {
FileConfiguration config = this.main.getSettingsConfig().getConfig();
config.set(location, CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
}
}

View File

@ -0,0 +1,84 @@
package me.trixkz.lifestealcore.commands.setspawn;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.utils.CustomLocation;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@CommandInfo(name = "setspawn", permission = "lifestealcore.admin", player = true)
public class SetSpawnCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
FileConfiguration config = this.main.getSettingsConfig().getConfig();
if (args.length == 0) {
player.sendMessage(Utils.translate("&cUsage:"));
player.sendMessage(Utils.translate(" &c/setspawn spawn"));
player.sendMessage(Utils.translate(" &c/setspawn min"));
player.sendMessage(Utils.translate(" &c/setspawn max"));
player.sendMessage(Utils.translate(" &c/setspawn holograms"));
return;
}
switch (args[0].toLowerCase()) {
case "spawn":
new SpawnCommand().executeAs(player, args);
break;
case "min":
new MinCommand().executeAs(player, args);
break;
case "max":
new MaxCommand().executeAs(player, args);
break;
case "cornermin":
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
config.set("corner.min", CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
player.sendMessage(ChatColor.GREEN + "Successfully set the corner min location.");
break;
case "cornermax":
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
config.set("corner.max", CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
player.sendMessage(ChatColor.GREEN + "Successfully set the corner max location.");
break;
case "holograms":
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
config.set("holograms.location", CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
player.sendMessage(ChatColor.GREEN + "Successfully set the holograms location");
break;
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,36 @@
package me.trixkz.lifestealcore.commands.setspawn;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.utils.CustomLocation;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@CommandInfo(name = "setspawn", permission = "lifestealcore.admin", player = true)
public class SpawnCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
@Override
public void executeAs(Player player, String[] args) {
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
this.saveLocation(player, "spawn.location");
player.sendMessage(ChatColor.GREEN + "Successfully set the spawn location.");
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
private void saveLocation(Player player, String location) {
FileConfiguration config = this.main.getSettingsConfig().getConfig();
config.set(location, CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getSettingsConfig().save();
}
}

View File

@ -0,0 +1,155 @@
package me.trixkz.lifestealcore.commands.tokens;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.BaseCommand;
import me.trixkz.lifestealcore.commands.CommandInfo;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@CommandInfo(name = "tokens", permission = "", player = true)
public class TokensCommand extends BaseCommand {
private LifeStealCore main = LifeStealCore.getInstance();
private ArrayList<String> message = new ArrayList<String>();
@Override
public void executeAs(Player player, String[] args) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (args.length == 0) {
player.sendMessage(Utils.translate("&dTokens: &f" + playerData.getTokens()));
return;
} else {
switch (args[0].toLowerCase()) {
case "help":
this.message.add(Utils.chatBar);
this.message.add("&dTokens Commands &7(&fPlayer&7)");
this.message.add(Utils.chatBar);
this.message.add("&7⚫ &9/tokens &7- &eLook at your tokens balance");
this.message.add("&7⚫ &9/tokens pay <player> <amount> &7- &eSend the specified amount of tokens to the specified player");
if (player.hasPermission("skyblock.admin")) {
this.message.add(Utils.chatBar);
this.message.add("&dTokens Commands &7(&fAdmin&7)");
this.message.add(Utils.chatBar);
this.message.add("&7⚫ &9/tokens <player> &7- &eLook at the specified player's tokens balance");
this.message.add("&7⚫ &9/tokens set <player> <amount> &7- &eSet the specified amount of tokens to the specified player");
this.message.add("&7⚫ &9/tokens add <player> <amount> &7- &eAdd the specified amount of tokens to the specified player");
this.message.add("&7⚫ &9/tokens remove <player> <amount> &7- &eRemove the specified amount of tokens to the specified player");
}
this.message.add(Utils.chatBar);
for (String string : this.message) {
player.sendMessage(Utils.translate(string));
}
this.message.clear();
return;
case "pay":
Player payTarget = this.main.getServer().getPlayer(args[1]);
if (payTarget == null) {
return;
}
PlayerData payTargetPlayerData = this.main.getPlayerDataManager().getPlayerData(payTarget.getUniqueId());
if (!Utils.isNumeric(args[2])) {
return;
}
int payAmount = Integer.parseInt(args[2]);
if (playerData.getTokens() >= payAmount) {
playerData.setTokens(playerData.getTokens() - payAmount);
payTargetPlayerData.setTokens(payTargetPlayerData.getTokens() + payAmount);
}
player.sendMessage(Utils.translate("&aPaid &a&l" + payTarget.getName() + "&a's &a&l" + payAmount + " &atokens"));
payTarget.sendMessage(Utils.translate("&a&l" + player.getName() + " &ahas paid you &a&l" + payAmount + " &atokens"));
return;
case "set":
case "add":
case "remove":
if (!player.hasPermission("skyblock.admin")) {
player.sendMessage(Utils.translate("&cNo permission"));
return;
}
Player target = this.main.getServer().getPlayer(args[1]);
if (target == null) {
return;
}
PlayerData targetPlayerData = this.main.getPlayerDataManager().getPlayerData(target.getUniqueId());
if (!Utils.isNumeric(args[2])) {
return;
}
int amount = Integer.parseInt(args[2]);
switch (args[0].toLowerCase()) {
case "set":
targetPlayerData.setTokens(amount);
player.sendMessage(Utils.translate("&aSet &a&l" + target.getName() + " &atokens balance to &a&l" + amount));
target.sendMessage(Utils.translate("&aTokens balance updated, you now have &a&l" + targetPlayerData.getTokens() + " &atokens"));
break;
case "add":
targetPlayerData.setTokens(targetPlayerData.getTokens() + amount);
player.sendMessage(Utils.translate("&aAdded &a&l" + amount + " &atokens to &a&l" + target.getName() + "&a's tokens balance"));
target.sendMessage(Utils.translate("&aTokens balance updated, you now have &a&l" + targetPlayerData.getTokens() + " &atokens"));
break;
case "remove":
if (targetPlayerData.getTokens() >= amount) {
targetPlayerData.setTokens(targetPlayerData.getTokens() - amount);
}
player.sendMessage(Utils.translate("&aRemoved &a&l" + amount + " &atokens to &a&l" + target.getName() + "&a's tokens balance"));
target.sendMessage(Utils.translate("&aTokens balance updated, you now have &a&l" + targetPlayerData.getTokens() + " &atokens"));
break;
}
break;
}
if (!player.hasPermission("skyblock.admin")) {
player.sendMessage(Utils.translate("&cNo permission"));
return;
}
Player target = this.main.getServer().getPlayer(args[0]);
if (target == null) {
return;
}
PlayerData targetPlayerData = this.main.getPlayerDataManager().getPlayerData(target.getUniqueId());
player.sendMessage(Utils.translate("&a&l" + target.getName() + " &ahas &a&l" + targetPlayerData.getTokens() + " &atokens"));
}
return;
}
@Override
public void executeAs(CommandSender sender, String[] args) {
}
}

View File

@ -0,0 +1,29 @@
package me.trixkz.lifestealcore.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class KOTHCapLostEvent extends Event {
private static HandlerList handlersList = new HandlerList();
private KOTH koth;
@Override
public HandlerList getHandlers() {
return handlersList;
}
public static HandlerList getHandlerList() {
return handlersList;
}
}

View File

@ -0,0 +1,29 @@
package me.trixkz.lifestealcore.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class KOTHCapTickEvent extends Event {
private static HandlerList handlersList = new HandlerList();
private KOTH koth;
@Override
public HandlerList getHandlers() {
return handlersList;
}
public static HandlerList getHandlerList() {
return handlersList;
}
}

View File

@ -0,0 +1,35 @@
package me.trixkz.lifestealcore.events;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
@Getter
@Setter
public class KOTHCappedEvent extends PlayerEvent implements Cancellable {
private static HandlerList handlersList = new HandlerList();
private KOTH koth;
private boolean cancelled;
public KOTHCappedEvent(Player player, KOTH koth) {
super(player);
this.koth = koth;
}
@Override
public HandlerList getHandlers() {
return handlersList;
}
public static HandlerList getHandlerList() {
return handlersList;
}
}

View File

@ -0,0 +1,29 @@
package me.trixkz.lifestealcore.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class KOTHDisabledEvent extends Event {
private static HandlerList handlersList = new HandlerList();
private KOTH koth;
@Override
public HandlerList getHandlers() {
return handlersList;
}
public static HandlerList getHandlerList() {
return handlersList;
}
}

View File

@ -0,0 +1,29 @@
package me.trixkz.lifestealcore.events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class KOTHEnabledEvent extends Event {
private static HandlerList handlersList = new HandlerList();
private KOTH koth;
@Override
public HandlerList getHandlers() {
return handlersList;
}
public static HandlerList getHandlerList() {
return handlersList;
}
}

View File

@ -0,0 +1,25 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData.getPlayerState() == PlayerState.SPAWN) {
// event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,23 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
public class BlockExplodeListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent event) {
Block blockOne = event.getBlock();
// change to work in the spawn of the server
// this.main.getIslandManager().getIslandByLocation(blockOne.getLocation()).ifPresent((island) -> {
// event.blockList().removeIf(blockTwo -> !island.isLocationInIsland(blockTwo.getLocation()));
// });
}
}

View File

@ -0,0 +1,25 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class BlockPlaceListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData.getPlayerState() == PlayerState.SPAWN) {
// event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,27 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockSpreadEvent;
public class BlockSpreadListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) {
Block block = event.getBlock();
// change to work in the spawn of the server
// this.main.getIslandManager().getIslandByLocation(block.getLocation()).ifPresent((island) -> {
// if (event.getSource().getType() != Material.FIRE) {
// return;
// }
//
// event.setCancelled(true);
// });
}
}

View File

@ -0,0 +1,39 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
public class BucketListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent event) {
this.getBucketEvent(event);
}
@EventHandler(ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
this.getBucketEvent(event);
}
public void getBucketEvent(PlayerBucketEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
Block block = event.getBlockClicked();
if (playerData.getPlayerState() == PlayerState.SPAWN) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,88 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.advancedmenusystem.Button;
import me.trixkz.lifestealcore.advancedmenusystem.Menu;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
public class ButtonListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(priority = EventPriority.HIGHEST)
public void onButtonPress(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
Menu menu = Menu.currentlyOpenedMenus.get(player.getName());
if (menu != null) {
if (event.getSlot() != event.getRawSlot()) {
if ((event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT)) {
event.setCancelled(true);
}
return;
}
if (menu.getButtons().containsKey(event.getSlot())) {
Button button = menu.getButtons().get(event.getSlot());
boolean cancel = button.shouldCancel(player, event.getSlot(), event.getClick());
if (!cancel && (event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT)) {
event.setCancelled(true);
if (event.getCurrentItem() != null) {
player.getInventory().addItem(event.getCurrentItem());
}
} else {
event.setCancelled(cancel);
}
button.clicked(player, event.getSlot(), event.getClick(), event.getHotbarButton());
if (Menu.currentlyOpenedMenus.containsKey(player.getName())) {
Menu newMenu = Menu.currentlyOpenedMenus.get(player.getName());
if (newMenu == menu && menu.isUpdateAfterClick()) {
menu.setClosedByMenu(true);
newMenu.openMenu(player);
}
} else if (button.shouldUpdate(player, event.getSlot(), event.getClick())) {
menu.setClosedByMenu(true);
menu.openMenu(player);
}
if (event.isCancelled()) {
Bukkit.getScheduler().runTaskLater(this.main, player::updateInventory, 1L);
}
} else {
if ((event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT || event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || event.getAction().equals(InventoryAction.HOTBAR_MOVE_AND_READD) || event.getAction().equals(InventoryAction.HOTBAR_SWAP))) {
event.setCancelled(true);
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onInventoryClose(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
Menu menu = Menu.currentlyOpenedMenus.get(player.getName());
if (menu != null) {
menu.onClose(player);
Menu.currentlyOpenedMenus.remove(player.getName());
}
}
}

View File

@ -0,0 +1,116 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.managers.clans.Clan;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.UUID;
public class ClanListeners implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.setJoinMessage(null);
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
player.setMaxHealth(playerData.getHearts());
if (playerData.getClanOwner() == null) {
return;
}
Clan clan = this.main.getClanManager().getClan(playerData.getClanOwner());
if (clan == null) {
this.main.getClanManager().loadClan(player);
return;
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData.getClanOwner() == null) {
return;
}
Clan clan = this.main.getClanManager().getClan(playerData.getClanOwner());
if (clan == null) {
return;
}
int playersOnline = 0;
Player owner = this.main.getServer().getPlayer(clan.getOwner());
if (owner != null) {
playersOnline++;
}
for (UUID uuid : this.main.getClanManager().getClan(playerData.getClanOwner()).getPlayersAdded()) {
Player playerAdded = this.main.getServer().getPlayer(uuid);
if (playerAdded != null) {
playersOnline++;
}
}
if (playersOnline == 1) {
this.main.getClanManager().saveClan(player);
}
}
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData.getClanOwner() == null) {
return;
}
Clan clan = this.main.getClanManager().getClan(playerData.getClanOwner());
if (clan == null) {
return;
}
int playersOnline = 0;
Player owner = this.main.getServer().getPlayer(clan.getOwner());
if (owner != null) {
playersOnline++;
}
for (UUID uuid : this.main.getClanManager().getClan(playerData.getClanOwner()).getPlayersAdded()) {
Player playerAdded = this.main.getServer().getPlayer(uuid);
if (playerAdded != null) {
playersOnline++;
}
}
if (playersOnline == 1) {
this.main.getClanManager().saveClan(player);
}
}
}

View File

@ -0,0 +1,25 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityChangeBlockEvent;
public class EntityChangeBlockListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Block block = event.getBlock();
// change to work in the spawn of the server
// this.main.getIslandManager().getIslandByLocation(block.getLocation()).ifPresent((island) -> {
// if (event.getEntityType() == EntityType.ENDERMAN) {
// event.setCancelled(true);
// }
// });
}
}

View File

@ -0,0 +1,53 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.managers.clans.Clan;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class EntityDamageByEntityListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity entity = event.getEntity();
if (!(damager instanceof Player)) {
return;
}
if (!(entity instanceof Player)) {
return;
}
Player player = (Player) damager;
Player target = (Player) entity;
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
PlayerData targetData = this.main.getPlayerDataManager().getPlayerData(target.getUniqueId());
if (playerData.getClanOwner() == null) {
return;
}
if (targetData.getClanOwner() == null) {
return;
}
Clan clan = this.main.getClanManager().getClan(playerData.getClanOwner());
if (clan.getOwner().equals(target.getUniqueId()) || clan.getPlayersAdded().contains(target.getUniqueId())) {
event.setCancelled(true);
player.sendMessage(Utils.translate(Constants.PREFIX + "&9" + target.getName() + " &eis apart of your clan"));
}
}
}

View File

@ -0,0 +1,27 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
public class EntityDeathListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
Entity entity = event.getEntity();
Player player = event.getEntity().getKiller();
if (player == null) {
return;
}
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
}
}

View File

@ -0,0 +1,162 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.events.KOTHCapLostEvent;
import me.trixkz.lifestealcore.events.KOTHCappedEvent;
import me.trixkz.lifestealcore.events.KOTHDisabledEvent;
import me.trixkz.lifestealcore.events.KOTHEnabledEvent;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EventListeners implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onEventEnabled(KOTHEnabledEvent event) {
if (event.getKoth().isHidden()) {
return;
}
KOTH koth = event.getKoth();
String[] messageOne = null;
switch (event.getKoth().getName()) {
default:
String location = "";
String world = "";
String eventType = "";
location = Utils.translate("&8(" + koth.getCustomLocation().toBukkitLocation().getBlockX() + "&8, " + koth.getCustomLocation().toBukkitLocation().getBlockZ() + "&8)");
world = this.getWorldName(koth.getWorld());
eventType = "KOTH";
messageOne = new String[]{
Utils.translate("&8███████"),
Utils.translate("&8█&e█&8███&e█&8█"),
Utils.translate("&8█&e█&8██&e█&8██"),
Utils.translate("&8█&e███&8███ &d" + event.getKoth().getName() + " " + eventType),
Utils.translate("&8█&e█&8██&e█&8██"),
Utils.translate("&8█&e█&8███&e█&8█"),
Utils.translate("&8█&e█&8███&e█&8█"),
Utils.translate("&8███████")
};
break;
}
String[] messageTwo = messageOne;
this.main.getServer().getScheduler().runTaskAsynchronously(this.main, new BukkitRunnable() {
@Override
public void run() {
for (Player player : main.getServer().getOnlinePlayers()) {
player.sendMessage(messageTwo);
}
}
});
}
@EventHandler
public void onEventDisabled(KOTHDisabledEvent event) {
}
@EventHandler
public void onEventCapped(KOTHCappedEvent event) {
Player player = event.getPlayer();
if (event.getKoth().isHidden()) {
return;
}
KOTH koth = event.getKoth();
String[] messageOne = null;
String[] fillerMessage = {"", "", "", "", "", "", "", "", "", ""};
messageOne = new String[]{
Utils.translate("&8[&9KOTH&8] &d" + koth.getName() + " &ehas been capped by &d" + player.getName()),
Utils.translate("&8[&9KOTH&8] &eAwarded a &dKOTH crate key &eto" + player.getName())
};
this.main.getServer().dispatchCommand(this.main.getServer().getConsoleSender(), "crate givekey " + player.getName() + " koth 1");
ItemStack itemStack = this.getKOTHCappedSign(player, koth);
player.getInventory().addItem(itemStack);
if (!player.getInventory().contains(itemStack)) {
player.getWorld().dropItemNaturally(player.getLocation(), itemStack);
}
String[] messageTwo = messageOne;
this.main.getServer().getScheduler().runTaskAsynchronously(this.main, new BukkitRunnable() {
@Override
public void run() {
for (Player player : main.getServer().getOnlinePlayers()) {
player.sendMessage(fillerMessage);
player.sendMessage(messageTwo);
}
}
});
}
@EventHandler
public void onKOTHCapLost(KOTHCapLostEvent event) {
KOTH koth = event.getKoth();
if (koth.getRemainingTime() <= (koth.getTime() - 30)) {
this.main.getServer().broadcastMessage(Utils.translate("&8[&9KOTH&8] &eCap of &d" + koth.getName() + " &ehas been lost"));
}
}
public String getWorldName(String world) {
switch (world) {
case "world":
return "Overworld";
case "world_the_end":
return "The end";
case "world_nether":
return "The nether";
}
return world;
}
public ItemStack getKOTHCappedSign(Player player, KOTH koth) {
ItemStack itemStack = new ItemStack(Material.OAK_SIGN);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(Utils.translate("&eKOTH Capped sign"));
List<String> lore = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("M/d HH:mm:ss");
lore.add(Utils.translate("&d" + koth.getName()));
lore.add(Utils.translate("&eCapped by"));
lore.add(Utils.translate("&d" + player.getName()));
lore.add(Utils.translate(dateFormat.format(new Date()).replace(" AM", "").replace(" PM", "")));
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}

View File

@ -0,0 +1,23 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.events.KOTHCapTickEvent;
import me.trixkz.lifestealcore.managers.koth.KOTH;
import me.trixkz.lifestealcore.utils.TimeUtils;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class KOTHListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onEventCapTick(KOTHCapTickEvent event) {
KOTH koth = event.getKoth();
if (koth.getRemainingTime() % 180 == 0 && koth.getRemainingTime() <= (koth.getTime() - 30)) {
this.main.getServer().broadcastMessage(Utils.translate("&8[&9KOTH&8] &eSomeone is trying to cap &d" + koth.getName() + " &8(&d" + TimeUtils.formatIntoMMSS(koth.getRemainingTime()) + "&8)"));
}
}
}

View File

@ -0,0 +1,26 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.normalmenusystem.Menu;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.InventoryHolder;
public class MenuListener implements Listener {
@EventHandler
public void onMenuClick(InventoryClickEvent event) {
InventoryHolder holder = event.getInventory().getHolder();
if (holder instanceof Menu) {
event.setCancelled(true);
if (event.getCurrentItem() == null) {
return;
}
Menu menu = (Menu) holder;
menu.handleMenu(event);
}
}
}

View File

@ -0,0 +1,74 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
public class PlayerDataListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(event.getUniqueId());
if (playerData.getDeathBanTime() == 0) {
return;
}
if (((playerData.getDeathBanTime() + playerData.getDeathBanTimeAddedAt()) - System.currentTimeMillis()) <= 0) {
playerData.setDeathBanTime(0);
return;
}
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(Utils.translate("&cYou have been death banned for &c&l" + Utils.makeTimeReadable(((playerData.getDeathBanTime() + playerData.getDeathBanTimeAddedAt()) - System.currentTimeMillis()))));
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
PlayerData playerData = this.main.getPlayerDataManager().getOrCreate(event.getPlayer().getUniqueId());
if (playerData == null) {
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage("§cAn error has occurred while loading your profile. Please reconnect.");
return;
}
if (!playerData.isLoaded()) {
this.main.getPlayerDataManager().savePlayerData(playerData);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage("§cAn error has occurred while loading your profile. Please reconnect.");
}
}
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
this.handleLeave(player);
this.handleDataSave(playerData);
}
private void handleLeave(Player player) {
}
private void handleDataSave(PlayerData playerData) {
if (playerData != null) {
this.main.getPlayerDataManager().deletePlayer(playerData.getUniqueId());
}
}
}

View File

@ -0,0 +1,99 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.managers.killstreaks.Killstreak;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class PlayerDeathListener implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getPlayer();
Player killer = event.getEntity().getKiller();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData == null) {
this.main.getLogger().warning(player.getName() + "'s player data is null");
return;
}
if (killer != null) {
PlayerData killerData = this.main.getPlayerDataManager().getPlayerData(killer.getUniqueId());
this.main.getServer().broadcastMessage(Utils.translate("&9" + player.getName() + " &ewas killed by &9" + killer.getName()));
playerData.setPlayerState(PlayerState.SPAWN);
playerData.setDeaths(playerData.getDeaths() + 1);
killerData.setKills(killerData.getKills() + 1);
killerData.setCoins(killerData.getCoins() + this.main.getSettingsConfig().getConfig().getInt("COINS-GIVEN-PER-KILL"));
if (player.getMaxHealth() <= 2) {
player.setMaxHealth(20);
long deathBanTime = Utils.parseTime("2d");
// for (String string : this.main.getSettingsConfig().getConfig().getConfigurationSection("DEATH-BAN-TIMES")) {
//
// }
//
// for (int i = 0; i < this.main.getSettingsConfig().getConfig().getConfigurationSection("DEATH-BAN-TIMES").getKeys(false).size(); i++) {
//
// }
playerData.setHearts(player.getMaxHealth());
playerData.setCurrentKillstreak(0);
playerData.setDeathBanTime(deathBanTime);
playerData.setDeathBanTimeAddedAt(System.currentTimeMillis());
player.kickPlayer(Utils.translate("&cYou have been death banned for &c&l" + Utils.makeTimeReadable(((playerData.getDeathBanTime() + playerData.getDeathBanTimeAddedAt()) - System.currentTimeMillis()))));
} else {
player.setMaxHealth(player.getMaxHealth() - 2);
}
killer.setMaxHealth(killer.getMaxHealth() + 2);
playerData.setHearts(player.getMaxHealth());
killerData.setHearts(killer.getMaxHealth());
playerData.setCurrentKillstreak(0);
killerData.setCurrentKillstreak(killerData.getCurrentKillstreak() + 1);
if (playerData.getBounty() > 0) {
killerData.setCoins(killerData.getCoins() + playerData.getBounty());
this.main.getServer().broadcastMessage(Utils.translate("&8[&6&lBounty&8] &d" + killer.getName() + " &ehas taken &d" + player.getName() + "&e's bounty for &d" + playerData.getBounty() + " &ecoins"));
playerData.setBounty(0);
}
for (Killstreak killstreak : this.main.getKillstreakManager().getKillstreaks()) {
if (killstreak.getKillstreak() == killerData.getCurrentKillstreak()) {
killstreak.getKillstreaksCallable().executeAs(killer, killerData);
}
}
if (killerData.getCurrentKillstreak() > killerData.getHighestKillstreak()) {
killerData.setHighestKillstreak(killerData.getCurrentKillstreak());
}
} else {
this.main.getServer().broadcastMessage(Utils.translate("&9" + player.getName() + " &edied"));
playerData.setPlayerState(PlayerState.SPAWN);
playerData.setDeaths(playerData.getDeaths() + 1);
playerData.setCurrentKillstreak(0);
if (playerData.getBounty() > 0) {
playerData.setBounty(0);
}
}
}
}

View File

@ -0,0 +1,97 @@
package me.trixkz.lifestealcore.listeners;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class RandomListeners implements Listener {
private LifeStealCore main = LifeStealCore.getInstance();
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE) {
return;
}
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (playerData == null) {
this.main.getLogger().warning(player.getName() + "'s player data is null");
return;
}
if (playerData.getPlayerState() != PlayerState.SPAWN) {
return;
}
if (!Utils.getPlayer(player, this.main.getSpawnManager().getSpawnMin(), this.main.getSpawnManager().getSpawnMax())) {
return;
}
playerData.setPlayerState(PlayerState.WARZONE);
}
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
if (event.toWeatherState()) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onBlockForm(BlockFormEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onBlockBurn(BlockBurnEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onBlockSpread(BlockSpreadEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event) {
if (event.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
}
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
}
}

View File

@ -0,0 +1,56 @@
package me.trixkz.lifestealcore.managers;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.CustomLocation;
import org.bukkit.Chunk;
import org.bukkit.scheduler.BukkitRunnable;
public class ChunkManager {
private LifeStealCore main = LifeStealCore.getInstance();
public ChunkManager() {
new BukkitRunnable() {
@Override
public void run() {
loadChunks();
}
}.runTaskLater(this.main, 1);
}
private void loadChunks() {
CustomLocation spawnMin = this.main.getSpawnManager().getSpawnMin();
CustomLocation spawnMax = this.main.getSpawnManager().getSpawnMax();
if (spawnMin != null && spawnMax != null) {
int spawnMinX = spawnMin.toBukkitLocation().getBlockX() >> 4;
int spawnMinZ = spawnMin.toBukkitLocation().getBlockZ() >> 4;
int spawnMaxX = spawnMax.toBukkitLocation().getBlockX() >> 4;
int spawnMaxZ = spawnMax.toBukkitLocation().getBlockZ() >> 4;
if (spawnMinX > spawnMaxX) {
int lastSpawnMinX = spawnMinX;
spawnMinX = spawnMaxX;
spawnMaxX = lastSpawnMinX;
}
if (spawnMinZ > spawnMaxZ) {
int lastSpawnMinZ = spawnMinZ;
spawnMinZ = spawnMaxZ;
spawnMaxZ = lastSpawnMinZ;
}
for (int x = spawnMinX; x <= spawnMaxX; x++) {
for (int z = spawnMinZ; z <= spawnMaxZ; z++) {
Chunk chunk = spawnMin.toBukkitWorld().getChunkAt(x, z);
if (!chunk.isLoaded()) {
chunk.load();
}
}
}
}
}
}

View File

@ -0,0 +1,104 @@
package me.trixkz.lifestealcore.managers;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
@Getter
@Setter
public class CombatManager {
private LifeStealCore main = LifeStealCore.getInstance();
private Set<UUID> combatSet = new HashSet<UUID>();
private Map<UUID, Integer> timeMap = new HashMap<UUID, Integer>();
private Map<Player, Map<Player, BukkitTask>> assists = new HashMap<Player, Map<Player, BukkitTask>>();
private Map<Player, Pair<Boolean, DamageModifier>> fallDamageModifiers = new HashMap<Player, Pair<Boolean, DamageModifier>>();
private Map<Player, BukkitTask> fallDamageTasks = new HashMap<Player, BukkitTask>();
private int count = 0;
// public CombatManager() {
// this.main.getServer().getScheduler().runTaskTimer(this.main, () -> this.combatSet.forEach((key) -> {
// this.count++;
//
// for (Player player : this.main.getServer().getOnlinePlayers()) {
// if (this.isInCombat(player)) {
// int count = this.getCombatTime(player);
//
// Bukkit.broadcastMessage("Count - " + count);
//
// count--;
//
// this.setCombatTime(player, count);
//
// if (count == 0) {
// this.combatSet.remove(player);
// this.timeMap.remove(player);
// }
// }
//
// if (this.count == 160) {
// this.count = 0;
// }
// }
// }), 20, 20);
// }
public void setCombatSet(UUID player, boolean inSpawn) {
if (inSpawn) {
this.combatSet.add(player);
this.timeMap.put(player, 16);
} else {
this.combatSet.remove(player);
this.timeMap.remove(player);
}
}
public void setCombatTime(UUID player, int time) {
this.timeMap.remove(player);
this.timeMap.put(player, time);
}
public boolean isInCombat(UUID player) {
return this.combatSet.contains(player);
}
public int getCombatTime(UUID player) {
return this.timeMap.get(player);
}
public void cancelNextFallDamage(Player player, int ticks) {
setNextFallDamage(player, damage -> 0.0D, ticks);
}
public void setNextFallDamage(Player player, DamageModifier modifier, int ticks) {
setNextFallDamage(player, modifier, ticks, true);
}
public void setNextFallDamage(Player player, DamageModifier modifier, int ticks, boolean reset) {
removeFallProtection(player);
this.fallDamageModifiers.put(player, Pair.of(reset, modifier));
if (ticks > 0)
this.fallDamageTasks.put(player, Bukkit.getScheduler().runTaskLaterAsynchronously(this.main, () -> {
this.fallDamageTasks.remove(player);
this.fallDamageModifiers.remove(player);
}, ticks));
}
public void removeFallProtection(Player player) {
this.fallDamageModifiers.remove(player);
if (this.fallDamageTasks.containsKey(player))
((BukkitTask)this.fallDamageTasks.remove(player)).cancel();
}
public static interface DamageModifier {
double modify(double param1Double);
}
}

View File

@ -0,0 +1,31 @@
package me.trixkz.lifestealcore.managers;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.commands.*;
import me.trixkz.lifestealcore.commands.clan.ClanCommand;
import me.trixkz.lifestealcore.commands.coins.CoinsCommand;
import me.trixkz.lifestealcore.commands.koth.KOTHCommand;
import me.trixkz.lifestealcore.commands.setspawn.SetSpawnCommand;
import me.trixkz.lifestealcore.commands.tokens.TokensCommand;
public class CommandManager {
private LifeStealCore main = LifeStealCore.getInstance();
public CommandManager() {
this.registerCommands();
}
private void registerCommands() {
this.main.getCommand("lootbox").setExecutor(new LootboxCommand());
this.main.getCommand("clan").setExecutor(new ClanCommand());
this.main.getCommand("koth").setExecutor(new KOTHCommand());
this.main.getCommand("spawn").setExecutor(new SpawnCommand());
this.main.getCommand("setspawn").setExecutor(new SetSpawnCommand());
this.main.getCommand("coins").setExecutor(new CoinsCommand());
this.main.getCommand("tokens").setExecutor(new TokensCommand());
this.main.getCommand("shop").setExecutor(new ShopCommand());
this.main.getCommand("envoy").setExecutor(new EnvoyCommand());
this.main.getCommand("sethearts").setExecutor(new SetHeartsCommand());
}
}

View File

@ -0,0 +1,74 @@
package me.trixkz.lifestealcore.managers;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Getter
@Setter
public class CooldownManager {
private LifeStealCore main = LifeStealCore.getInstance();
private Set<Player> cooldownSet = new HashSet<Player>();
private Map<Player, Integer> cooldownTimeMap = new HashMap<Player, Integer>();
private Set<Player> refillSet = new HashSet<Player>();
private Map<Player, Integer> refillTimeMap = new HashMap<Player, Integer>();
private int cooldownCount = 0;
private int refillCount = 0;
public void setCooldownSet(Player player, boolean inSpawn, int number) {
if (inSpawn) {
this.cooldownSet.add(player);
this.cooldownTimeMap.put(player, number);
} else {
this.cooldownSet.remove(player);
this.cooldownTimeMap.remove(player);
}
}
public int getCooldownTime(Player player) {
return this.cooldownTimeMap.get(player);
}
public void setCooldownTime(Player player, int time) {
this.cooldownTimeMap.remove(player);
this.cooldownTimeMap.put(player, time);
}
public boolean isOnCooldown(Player player) {
return this.cooldownSet.contains(player);
}
public void setRefillSet(Player player, boolean inSpawn) {
if (inSpawn) {
this.refillSet.add(player);
this.refillTimeMap.put(player, 60);
} else {
this.refillSet.remove(player);
this.refillTimeMap.remove(player);
}
}
public int getRefillTime(Player player) {
return this.refillTimeMap.get(player);
}
public void setRefillTime(Player player, int time) {
this.refillTimeMap.remove(player);
this.refillTimeMap.put(player, time);
}
public boolean isOnRefillCooldown(Player player) {
return this.refillSet.contains(player);
}
}

View File

@ -0,0 +1,93 @@
package me.trixkz.lifestealcore.managers;
import io.github.bananapuncher714.nbteditor.NBTEditor;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.normalmenusystem.ItemStackButton;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.*;
@Getter
@Setter
public class LootboxManager {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ItemStack> itemStacks = new ArrayList<ItemStack>();
public LootboxManager() {
FileConfiguration fileConfiguration = this.main.getLootboxConfig().getConfig();
ConfigurationSection configurationSection = fileConfiguration.getConfigurationSection("lootbox");
if (configurationSection == null) {
return;
}
configurationSection.getKeys(false).forEach((number) -> {
String name = configurationSection.getString(number + ".name");
List<String> loreArrayList = configurationSection.getStringList(number + ".lore");
String[] lore = new String[loreArrayList.size()];
for (int i = 0; i < loreArrayList.size(); i++) {
lore[i] = loreArrayList.get(i);
}
Material material = Material.getMaterial(configurationSection.getString(number + ".material"));
int data = configurationSection.getInt(number + ".data");
int amount = configurationSection.getInt(number + ".amount");
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>();
if (configurationSection.getStringList(number + ".enchantments") != null) {
configurationSection.getStringList(number + ".enchantments").forEach((string) -> {
String[] stringArray = string.split(":");
enchantments.put(Enchantment.getByName(stringArray[0]), Integer.parseInt(stringArray[1]));
});
}
ItemStackButton itemStackButton = new ItemStackButton(name, lore, material, data, amount);
ItemStack itemStack = itemStackButton.makeItemStack();
if (enchantments.size() >= 1) {
itemStack.addEnchantments(enchantments);
}
this.itemStacks.add(itemStack);
});
}
public ItemStack getLootboxItemStack(Player player, int amount) {
ItemStack itemStack = new ItemStack(Material.ENDER_CHEST, amount);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(Utils.translate("&dLootbox"));
itemMeta.setLore(Utils.translate(Arrays.asList("&9Right click to use")));
itemStack.setItemMeta(itemMeta);
itemStack = NBTEditor.set(itemStack, "Lootbox", player.getUniqueId().toString() + "Lootbox");
return itemStack;
}
public boolean isLootboxItemStack(Player player, ItemStack itemStack) {
if (itemStack.getItemMeta() == null) {
return false;
}
return NBTEditor.contains(itemStack, player.getUniqueId().toString() + "Lootbox");
}
}

View File

@ -0,0 +1,84 @@
package me.trixkz.lifestealcore.managers;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import lombok.Getter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.Utils;
import me.trixkz.lifestealcore.utils.config.file.Config;
import org.bson.Document;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
@Getter
public class MongoManager {
private final MongoManager instance;
private final LifeStealCore main = LifeStealCore.getInstance();
private final Config configFile = this.main.getSettingsConfig();
private final FileConfiguration fileConfig = configFile.getConfig();
private final ConfigurationSection config = fileConfig.getConfigurationSection("mongo");
private MongoClient mongoClient;
private MongoDatabase mongoDatabase;
private final String host = config.getString("host");
private final int port = config.getInt("port");
private final String database = config.getString("database");
private final boolean auth = config.getBoolean("auth.enabled");
private final String user = config.getString("auth.username");
private final String password = config.getString("auth.password");
private final String authDatabase = config.getString("auth.auth-database");
private boolean connected;
private MongoCollection<Document> players;
private MongoCollection<Document> clans;
private Gson gson = new Gson();
private Type type = (new TypeToken<List<String>>() {
}).getType();
public MongoManager() {
instance = this;
try {
if (auth) {
final MongoCredential credential = MongoCredential.createCredential(user, authDatabase, password.toCharArray());
mongoClient = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential));
} else {
mongoClient = new MongoClient(host, port);
}
connected = true;
mongoDatabase = mongoClient.getDatabase(database);
Bukkit.getConsoleSender().sendMessage(Utils.translate("&d[LifestealCore] &aSuccessfully connected to the database!"));
this.players = this.mongoDatabase.getCollection("players");
this.clans = this.mongoDatabase.getCollection("clans");
} catch (Exception exception) {
connected = false;
Bukkit.getConsoleSender().sendMessage(Utils.translate("&d[LifestealCore] &cFailed to connect to the database!"));
exception.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this.main);
Bukkit.getConsoleSender().sendMessage(Utils.translate("&b[LifestealCore] &cDisabling LifestealCore..."));
}
}
public void disconnect() {
if (this.mongoClient != null) {
this.mongoClient.close();
this.connected = false;
Bukkit.getConsoleSender().sendMessage(Utils.translate("&d[LifestealCore] &aSuccessfully disconnected from the database!"));
}
}
}

View File

@ -0,0 +1,100 @@
package me.trixkz.lifestealcore.managers;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.UpdateOptions;
import lombok.Getter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.playerdata.PlayerState;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.CustomLocation;
import org.bson.Document;
import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PlayerDataManager {
private LifeStealCore main = LifeStealCore.getInstance();
@Getter private Map<UUID, PlayerData> players = new HashMap<>();
public PlayerData getOrCreate(UUID uniqueId) {
return this.players.computeIfAbsent(uniqueId, PlayerData::new);
}
public PlayerData getPlayerData(UUID uniqueId) {
return this.players.getOrDefault(uniqueId, new PlayerData(uniqueId));
}
public Collection<PlayerData> getAllPlayers() {
return this.players.values();
}
public void loadPlayerData(PlayerData playerData) {
Document document = this.main.getMongoManager().getPlayers().find(Filters.eq(Constants.PLAYER_DATA_UNIQUE_ID, playerData.getUniqueId().toString())).first();
if (document != null) {
playerData.setCoins(document.getDouble(Constants.PLAYER_DATA_COINS));
playerData.setTokens(document.getInteger(Constants.PLAYER_DATA_TOKENS));
playerData.setClanOwner((document.getString(Constants.PLAYER_DATA_CLAN_OWNER) == null ? null : UUID.fromString(document.getString(Constants.PLAYER_DATA_CLAN_OWNER))));
playerData.setKills(document.getInteger(Constants.PLAYER_DATA_KILLS));
playerData.setDeaths(document.getInteger(Constants.PLAYER_DATA_DEATHS));
playerData.setHearts(document.getDouble(Constants.PLAYER_DATA_HEARTS));
playerData.setBounty(document.getInteger(Constants.PLAYER_DATA_BOUNTY));
playerData.setCurrentKillstreak(document.getInteger(Constants.PLAYER_DATA_CURRENT_KILLSTREAK));
playerData.setHighestKillstreak(document.getInteger(Constants.PLAYER_DATA_HIGHEST_KILLSTREAK));
playerData.setDeathBanTime(document.getLong(Constants.PLAYER_DATA_DEATH_BAN_TIME));
playerData.setDeathBanTimeAddedAt(document.getLong(Constants.PLAYER_DATA_DEATH_BAN_TIME_ADDED_AT));
}
playerData.setLoaded(true);
}
public void savePlayerData(PlayerData playerData) {
Document document = new Document();
document.put(Constants.PLAYER_DATA_UNIQUE_ID, playerData.getUniqueId().toString());
document.put(Constants.PLAYER_DATA_COINS, playerData.getCoins());
document.put(Constants.PLAYER_DATA_TOKENS, playerData.getTokens());
document.put(Constants.PLAYER_DATA_CLAN_OWNER, (playerData.getClanOwner() == null ? null : playerData.getClanOwner().toString()));
document.put(Constants.PLAYER_DATA_KILLS, playerData.getKills());
document.put(Constants.PLAYER_DATA_DEATHS, playerData.getDeaths());
document.put(Constants.PLAYER_DATA_HEARTS, playerData.getHearts());
document.put(Constants.PLAYER_DATA_BOUNTY, playerData.getBounty());
document.put(Constants.PLAYER_DATA_CURRENT_KILLSTREAK, playerData.getCurrentKillstreak());
document.put(Constants.PLAYER_DATA_HIGHEST_KILLSTREAK, playerData.getHighestKillstreak());
document.put(Constants.PLAYER_DATA_DEATH_BAN_TIME, playerData.getDeathBanTime());
document.put(Constants.PLAYER_DATA_DEATH_BAN_TIME_ADDED_AT, playerData.getDeathBanTimeAddedAt());
this.main.getMongoManager().getPlayers().replaceOne(Filters.eq(Constants.PLAYER_DATA_UNIQUE_ID, playerData.getUniqueId().toString()), document, new UpdateOptions().upsert(true));
}
public void deletePlayer(UUID uniqueId) {
this.savePlayerData(getPlayerData(uniqueId));
this.getPlayers().remove(uniqueId);
}
public void sendToSpawnAndResetPlayer(Player player) {
if (!player.isOnline()) {
return;
}
PlayerData playerData = this.getPlayerData(player.getUniqueId());
player.teleport(CustomLocation.stringToLocation(this.main.getSettingsConfig().getConfig().getString("spawn.location")).toBukkitLocation());
playerData.setPlayerState(PlayerState.SPAWN);
}
public MongoCursor<Document> getPlayersSorted(String stat) {
Document sort = new Document();
sort.put(stat, -1);
return this.main.getMongoManager().getPlayers().find().sort(sort).limit(10).iterator();
}
}

View File

@ -0,0 +1,64 @@
package me.trixkz.lifestealcore.managers;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.utils.CustomLocation;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Getter
@Setter
public class SpawnManager {
private LifeStealCore main = LifeStealCore.getInstance();
private FileConfiguration config = this.main.getSettingsConfig().getConfig();
private CustomLocation spawnLocation;
private CustomLocation spawnMin;
private CustomLocation spawnMax;
private CustomLocation cornerMin;
private CustomLocation cornerMax;
private CustomLocation hologramsLocation;
private Map<UUID, Integer> players = new HashMap<UUID, Integer>();
public SpawnManager() {
this.loadConfig();
}
private void loadConfig() {
if (this.config.contains("spawn.location")) {
try {
this.spawnLocation = CustomLocation.stringToLocation(this.config.getString("spawn.location"));
this.spawnMin = CustomLocation.stringToLocation(this.config.getString("spawn.min"));
this.spawnMax = CustomLocation.stringToLocation(this.config.getString("spawn.max"));
this.cornerMin = CustomLocation.stringToLocation(this.config.getString("corner.min"));
this.cornerMax = CustomLocation.stringToLocation(this.config.getString("corner.max"));
} catch (NullPointerException exception) {
Bukkit.getConsoleSender().sendMessage(Utils.translate("&cSpawn min & max locations not found!"));
}
}
if (this.config.contains("holograms.location")) {
// this.hologramsLocation = CustomLocation.stringToLocation(this.config.getString("holograms.location"));
}
}
public void saveConfig() {
this.config.set("spawn.location", CustomLocation.locationToString(this.spawnLocation));
this.config.set("spawn.min", CustomLocation.locationToString(this.spawnMin));
this.config.set("spawn.max", CustomLocation.locationToString(this.spawnMax));
this.config.set("corner.min", CustomLocation.locationToString(this.cornerMin));
this.config.set("corner.max", CustomLocation.locationToString(this.cornerMax));
// this.config.set("holograms.location", CustomLocation.locationToString(this.hologramsLocation));
this.main.getSettingsConfig().save();
}
}

View File

@ -0,0 +1,18 @@
package me.trixkz.lifestealcore.managers.chatgames;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.event.Listener;
@Getter
@Setter
public abstract class ChatGame implements Listener {
private boolean started = false;
public abstract String getName();
public abstract void startGame();
public abstract void stopGame();
}

View File

@ -0,0 +1,37 @@
package me.trixkz.lifestealcore.managers.chatgames;
import lombok.Getter;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.managers.chatgames.chatquestion.ChatQuestion;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
@Getter
@Setter
public class ChatGameManager {
private LifeStealCore main = LifeStealCore.getInstance();
private List<ChatGame> chatGames = new ArrayList<ChatGame>();
public ChatGameManager() {
this.chatGames.add(new ChatQuestion());
// this.chatGames.add(new ChatMath());
this.chatGames.forEach((chatGame) -> {
this.main.getServer().getPluginManager().registerEvents(chatGame, this.main);
});
new BukkitRunnable() {
@Override
public void run() {
int random = ThreadLocalRandom.current().nextInt(chatGames.size());
ChatGame chatGame = chatGames.get(random);
chatGame.startGame();
}
}.runTaskTimerAsynchronously(this.main, 6000L, 6000L);
}
}

View File

@ -0,0 +1,4 @@
package me.trixkz.lifestealcore.managers.chatgames.chatmath;
public class ChatMath {
}

View File

@ -0,0 +1,153 @@
package me.trixkz.lifestealcore.managers.chatgames.chatquestion;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.trixkz.lifestealcore.LifeStealCore;
import me.trixkz.lifestealcore.managers.chatgames.ChatGame;
import me.trixkz.lifestealcore.playerdata.PlayerData;
import me.trixkz.lifestealcore.utils.Constants;
import me.trixkz.lifestealcore.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class ChatQuestion extends ChatGame {
private LifeStealCore main = LifeStealCore.getInstance();
private List<Question> questions = new ArrayList<Question>();
private Question question = null;
private double time = 0;
public ChatQuestion() {
for (int i = 0; i < this.main.getSettingsConfig().getConfig().getConfigurationSection("CHAT-GAMES.QUESTIONS").getKeys(false).size(); i++) {
this.questions.add(new Question(this.main.getSettingsConfig().getConfig().getString("CHAT-GAMES.QUESTIONS." + i + ".QUESTION"), this.main.getSettingsConfig().getConfig().getStringList("CHAT-GAMES.QUESTIONS." + i + ".ANSWERS")));
}
}
@Override
public String getName() {
return Utils.translate("&d&lChat question");
}
@Override
public void startGame() {
this.setStarted(true);
new BukkitRunnable() {
@Override
public void run() {
if (!isStarted()) {
cancel();
return;
}
time += 0.10;
}
}.runTaskTimer(this.main, 5L, 5L);
int random = ThreadLocalRandom.current().nextInt(this.questions.size());
Question question = this.questions.get(random);
this.question = question;
List<String> message = new ArrayList<String>(
Arrays.asList(
"",
this.getName(),
"",
"&7┃ &9Question: &d" + this.question.getQuestion(),
"&7┃ &9Respond with the right answer",
"&7┃ &9to get 10 thousand coins",
""
)
);
message.forEach((string) -> {
this.main.getServer().broadcastMessage(Utils.translate(string));
});
new BukkitRunnable() {
@Override
public void run() {
if (!isStarted()) {
cancel();
return;
}
stopGame();
}
}.runTaskLater(this.main, 300L);
}
@Override
public void stopGame() {
this.setStarted(false);
this.main.getServer().broadcastMessage(Utils.translate(Constants.PREFIX + "&eNo one answered the question in time"));
}
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class Question {
private String question;
private List<String> answers;
}
@EventHandler
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
if (!this.isStarted()) {
return;
}
if (this.question == null) {
return;
}
String answer = event.getMessage();
if (!this.question.getAnswers().contains(answer)) {
return;
}
this.setStarted(false);
event.setCancelled(true);
List<String> message = new ArrayList<String>(
Arrays.asList(
"",
this.getName(),
"",
"&7┃ &9Answer: &d" + answer,
"&7┃ &9Winner: &d" + player.getName(),
"&7┃ &9Time: &d" + this.time,
""
)
);
message.forEach((string) -> {
this.main.getServer().broadcastMessage(Utils.translate(string));
});
playerData.setCoins(playerData.getCoins() + 10000);
}
}

Some files were not shown because too many files have changed in this diff Show More