Initial commit
This commit is contained in:
parent
3a759dd0b6
commit
1a64fa6daa
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.loganmagnan</groupId>
|
||||
<artifactId>PluginBase</artifactId>
|
||||
<artifactId>UnlimitedItems</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
|
@ -1,201 +0,0 @@
|
||||
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 java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static aether.AetherOptions.defaultOptions;
|
||||
|
||||
public class Aether implements Listener {
|
||||
|
||||
@Getter BoardAdapter adapter;
|
||||
@Getter private JavaPlugin plugin;
|
||||
@Getter private AetherOptions options;
|
||||
|
||||
private Pattern HEX_PATTERN = Pattern.compile("&#([A-Fa-f0-9]{6})");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public String colorize(String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
public String translateHexColorCodes(String message) {
|
||||
char colorChar = '§';
|
||||
Matcher matcher = HEX_PATTERN.matcher(message);
|
||||
StringBuffer buffer = new StringBuffer(message.length() + 32);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
matcher.appendReplacement(buffer, "§x§" + group
|
||||
.charAt(0) + '§' + group.charAt(1) + '§' + group
|
||||
.charAt(2) + '§' + group.charAt(3) + '§' + group
|
||||
.charAt(4) + '§' + group.charAt(5));
|
||||
}
|
||||
return matcher.appendTail(buffer).toString();
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package aether.scoreboard.cooldown;
|
||||
|
||||
public enum BoardFormat {
|
||||
SECONDS, MINUTES, HOURS
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.loganmagnan.pluginbase.commands;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.utils.ColorUtils;
|
||||
import com.loganmagnan.pluginbase.utils.CustomLocation;
|
||||
import com.loganmagnan.pluginbase.utils.command.BaseCommand;
|
||||
import com.loganmagnan.pluginbase.utils.command.Command;
|
||||
import com.loganmagnan.pluginbase.utils.command.CommandArguments;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ExampleCommand extends BaseCommand {
|
||||
|
||||
private PluginBase main = PluginBase.getInstance();
|
||||
|
||||
@Command(name = "example", permission = "permission.example")
|
||||
@Override
|
||||
public void executeAs(CommandArguments command) {
|
||||
Player player = command.getPlayer();
|
||||
|
||||
String[] args = command.getArgs();
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ColorUtils.getMessageType("&aThis is an example command."));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
|
||||
public abstract class BaseCommand {
|
||||
|
||||
public BaseCommand() {
|
||||
PluginBase.getInstance().getCommandFramework().registerCommands(this, null);
|
||||
}
|
||||
|
||||
public abstract void executeAs(CommandArguments command);
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.loganmagnan.pluginbase;
|
||||
package com.loganmagnan.unlimiteditems;
|
||||
|
||||
import com.loganmagnan.pluginbase.menusystem.PlayerMenuUtil;
|
||||
import com.loganmagnan.pluginbase.utils.ClassRegistrationUtils;
|
||||
import com.loganmagnan.pluginbase.utils.ColorUtils;
|
||||
import com.loganmagnan.pluginbase.utils.Utils;
|
||||
import com.loganmagnan.pluginbase.utils.command.CommandFramework;
|
||||
import com.loganmagnan.pluginbase.utils.config.FileConfig;
|
||||
import com.loganmagnan.pluginbase.utils.config.file.Config;
|
||||
import com.loganmagnan.unlimiteditems.managers.PlayerDataManager;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.PlayerMenuUtil;
|
||||
import com.loganmagnan.unlimiteditems.utils.ClassRegistrationUtils;
|
||||
import com.loganmagnan.unlimiteditems.utils.ColorUtils;
|
||||
import com.loganmagnan.unlimiteditems.utils.Utils;
|
||||
import com.loganmagnan.unlimiteditems.utils.command.CommandFramework;
|
||||
import com.loganmagnan.unlimiteditems.utils.config.FileConfig;
|
||||
import com.loganmagnan.unlimiteditems.utils.config.file.Config;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,16 +16,18 @@ import java.util.HashMap;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PluginBase extends JavaPlugin {
|
||||
public class UnlimitedItems extends JavaPlugin {
|
||||
|
||||
// Main class instance
|
||||
@Getter private static PluginBase instance;
|
||||
@Getter private static UnlimitedItems instance;
|
||||
|
||||
// Configuration files
|
||||
private Config mainConfig;
|
||||
private FileConfig messagesConfig;
|
||||
private FileConfig menusConfig;
|
||||
|
||||
// Managers
|
||||
private PlayerDataManager playerDataManager;
|
||||
|
||||
// Menu system
|
||||
private HashMap<Player, PlayerMenuUtil> playerMenuUtilMap = new HashMap<>();
|
||||
@ -42,10 +45,11 @@ public class PluginBase extends JavaPlugin {
|
||||
this.saveDefaultConfig();
|
||||
this.mainConfig = new Config("config", this, true);
|
||||
this.messagesConfig = new FileConfig(this, "messages.yml", true);
|
||||
this.menusConfig = new FileConfig(this, "menus.yml", true);
|
||||
|
||||
// Say the plugin's name
|
||||
this.getServer().getConsoleSender().sendMessage(Utils.chatBar);
|
||||
this.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&dPluginBase &7- &av" + this.getDescription().getVersion()));
|
||||
this.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&dUnlimitedItems &7- &av" + this.getDescription().getVersion()));
|
||||
this.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&7Made by &eLoganM Development"));
|
||||
this.getServer().getConsoleSender().sendMessage(Utils.chatBar);
|
||||
|
||||
@ -65,17 +69,17 @@ public class PluginBase extends JavaPlugin {
|
||||
|
||||
// Load commands function
|
||||
private void loadCommands() {
|
||||
ClassRegistrationUtils.loadCommands("com.loganmagnan.pluginbase.commands");
|
||||
ClassRegistrationUtils.loadCommands("com.loganmagnan.unlimiteditems.commands");
|
||||
}
|
||||
|
||||
// Load managers function
|
||||
private void loadManagers() {
|
||||
|
||||
this.playerDataManager = new PlayerDataManager();
|
||||
}
|
||||
|
||||
// Load listeners function
|
||||
private void loadListeners() {
|
||||
ClassRegistrationUtils.loadListeners("com.loganmagnan.pluginbase.listeners");
|
||||
ClassRegistrationUtils.loadListeners("com.loganmagnan.unlimiteditems.listeners");
|
||||
}
|
||||
|
||||
// Load runnables function
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.chatcolor;
|
||||
package com.loganmagnan.unlimiteditems.chatcolor;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.chatcolor;
|
||||
package com.loganmagnan.unlimiteditems.chatcolor;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -0,0 +1,25 @@
|
||||
package com.loganmagnan.unlimiteditems.commands;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.menu.SettingsSelectorMenu;
|
||||
import com.loganmagnan.unlimiteditems.utils.command.BaseCommand;
|
||||
import com.loganmagnan.unlimiteditems.utils.command.Command;
|
||||
import com.loganmagnan.unlimiteditems.utils.command.CommandArguments;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SettingsCommand extends BaseCommand {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
@Command(name = "settings", permission = "unlimiteditems.command.settings", aliases = {"settingsmenu"})
|
||||
@Override
|
||||
public void executeAs(CommandArguments command) {
|
||||
Player player = command.getPlayer();
|
||||
|
||||
String[] args = command.getArgs();
|
||||
|
||||
if (args.length == 0) {
|
||||
new SettingsSelectorMenu(this.main.getPlayerMenuUtil(player)).open(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package com.loganmagnan.unlimiteditems.listeners;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerData;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerSettings;
|
||||
import org.bukkit.Material;
|
||||
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.EntityPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EntityPickupItemListener implements Listener {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPickupItem(EntityPickupItemEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) entity;
|
||||
|
||||
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||
|
||||
PlayerSettings playerSettings = playerData.getPlayerSettings();
|
||||
|
||||
if (!playerSettings.isUnlimitedItems()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack itemStackOne = event.getItem().getItemStack();
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
if (player.getInventory().contains(itemStackOne.getType())) {
|
||||
int amount = this.getMaterialAmount(player, itemStackOne.getType());
|
||||
|
||||
ItemStack itemStackTwo = new ItemStack(itemStackOne.getType(), itemStackOne.getAmount() + amount);
|
||||
|
||||
this.removeMaterial(player, itemStackOne.getType(), amount);
|
||||
|
||||
player.getInventory().addItem(itemStackTwo);
|
||||
} else {
|
||||
player.getInventory().addItem(itemStackOne);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaterialAmount(Player player, Material material) {
|
||||
int amount = 0;
|
||||
|
||||
for (ItemStack item : player.getInventory().getContents()) {
|
||||
if (item != null && item.getType() == material) {
|
||||
amount += item.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void removeMaterial(Player player, Material material, int amount) {
|
||||
ItemStack[] contents = player.getInventory().getContents();
|
||||
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack item = contents[i];
|
||||
|
||||
if (item != null && item.getType() == material && amount > 0) {
|
||||
int itemAmount = item.getAmount();
|
||||
|
||||
if (itemAmount <= amount) {
|
||||
amount -= itemAmount;
|
||||
player.getInventory().setItem(i, null);
|
||||
|
||||
} else {
|
||||
item.setAmount(itemAmount - amount);
|
||||
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.listeners;
|
||||
package com.loganmagnan.unlimiteditems.listeners;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.menusystem.Menu;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.Menu;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -9,7 +9,7 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class MenuListener implements Listener {
|
||||
|
||||
private PluginBase main = PluginBase.getInstance();
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
@EventHandler
|
||||
public void onMenuClick(InventoryClickEvent event) {
|
@ -0,0 +1,82 @@
|
||||
package com.loganmagnan.unlimiteditems.listeners;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerData;
|
||||
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.player.*;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class PlayerDataListener implements Listener {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
Player player = Bukkit.getPlayer(event.getUniqueId());
|
||||
|
||||
if (player != null) {
|
||||
if (player.isOnline()) {
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage("§cYou tried to login too quickly after disconnecting.\n§cTry again in a few seconds.");
|
||||
|
||||
this.main.getServer().getScheduler().runTask(this.main, () -> player.kickPlayer("§cDuplicate Login"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@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()) {
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage("§cAn error has occurred while loading your profile. Please reconnect.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||
|
||||
this.handleLeave(player);
|
||||
this.handleDataSave(playerData);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.loganmagnan.unlimiteditems.managers;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerData;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerDataManager {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
@Getter private final 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) {
|
||||
playerData.setLoaded(true);
|
||||
}
|
||||
|
||||
public void savePlayerData(PlayerData playerData) {
|
||||
|
||||
}
|
||||
|
||||
public void deletePlayer(UUID uniqueId) {
|
||||
this.main.getServer().getScheduler().runTaskAsynchronously(this.main, () -> {
|
||||
this.savePlayerData(this.players.get(uniqueId));
|
||||
this.players.remove(uniqueId);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.menusystem;
|
||||
package com.loganmagnan.unlimiteditems.menusystem;
|
||||
|
||||
import com.loganmagnan.pluginbase.utils.ColorUtils;
|
||||
import com.loganmagnan.pluginbase.utils.ItemBuilder;
|
||||
import com.loganmagnan.unlimiteditems.utils.ColorUtils;
|
||||
import com.loganmagnan.unlimiteditems.utils.ItemBuilder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -10,6 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ -18,12 +19,12 @@ import java.util.Arrays;
|
||||
public class ItemStackButton {
|
||||
|
||||
private String name;
|
||||
private String[] lore;
|
||||
private List<String> lore;
|
||||
private Material material;
|
||||
private int data;
|
||||
private int amount;
|
||||
|
||||
public ItemStack makeItemStack() {
|
||||
return new ItemBuilder(this.material).name(ColorUtils.getMessageType(this.name)).lore(ColorUtils.getMessageType(Arrays.asList(this.lore))).durability(this.data).amount(this.amount).build();
|
||||
return new ItemBuilder(this.material).name(ColorUtils.getMessageType(this.name)).lore(ColorUtils.getMessageType(this.lore)).durability(this.data).amount(this.amount).build();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.loganmagnan.pluginbase.menusystem;
|
||||
package com.loganmagnan.unlimiteditems.menusystem;
|
||||
|
||||
import com.loganmagnan.pluginbase.utils.ItemBuilder;
|
||||
import com.loganmagnan.unlimiteditems.utils.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
@ -1,6 +1,6 @@
|
||||
package com.loganmagnan.pluginbase.menusystem;
|
||||
package com.loganmagnan.unlimiteditems.menusystem;
|
||||
|
||||
import com.loganmagnan.pluginbase.utils.ColorUtils;
|
||||
import com.loganmagnan.unlimiteditems.utils.ColorUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.menusystem;
|
||||
package com.loganmagnan.unlimiteditems.menusystem;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -0,0 +1,79 @@
|
||||
package com.loganmagnan.unlimiteditems.menusystem.menu;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.ItemStackButton;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.Menu;
|
||||
import com.loganmagnan.unlimiteditems.menusystem.PlayerMenuUtil;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerData;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.PlayerSettings;
|
||||
import com.loganmagnan.unlimiteditems.utils.ColorUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SettingsSelectorMenu extends Menu {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
public SettingsSelectorMenu(PlayerMenuUtil playerMenuUtil) {
|
||||
super(playerMenuUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMenuName() {
|
||||
return ColorUtils.getMessageType(this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.TITLE"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return this.main.getMenusConfig().getConfig().getInt("MENUS.SETTINGS.SIZE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMenu(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||
|
||||
PlayerSettings playerSettings = playerData.getPlayerSettings();
|
||||
|
||||
if (event.getView().getTitle().equalsIgnoreCase(ColorUtils.getMessageType(this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.TITLE")))) {
|
||||
switch (event.getCurrentItem().getType()) {
|
||||
case NETHER_STAR:
|
||||
playerSettings.setUnlimitedItems(!playerSettings.isUnlimitedItems());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
new SettingsSelectorMenu(this.playerMenuUtil).open(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuItems(Player player) {
|
||||
PlayerData playerData = this.main.getPlayerDataManager().getPlayerData(player.getUniqueId());
|
||||
|
||||
PlayerSettings playerSettings = playerData.getPlayerSettings();
|
||||
|
||||
this.setFillerGlass();
|
||||
|
||||
List<String> unlimitedItemsLore = new ArrayList<String>(this.main.getMenusConfig().getConfig().getStringList("MENUS.SETTINGS.SETTINGS.UNLIMITED-ITEMS.LORE"));
|
||||
unlimitedItemsLore.add((playerSettings.isUnlimitedItems() ? this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.ENABLED") : this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.UNSELECTED")) + " Unlimited items enabled");
|
||||
unlimitedItemsLore.add((!playerSettings.isUnlimitedItems() ? this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.DISABLED") : this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.UNSELECTED")) + " Unlimited items disabled");
|
||||
|
||||
ItemStackButton unlimitedItemsItemStackButton = new ItemStackButton(
|
||||
this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.SETTINGS.UNLIMITED-ITEMS.NAME"),
|
||||
unlimitedItemsLore,
|
||||
Material.getMaterial(this.main.getMenusConfig().getConfig().getString("MENUS.SETTINGS.SETTINGS.UNLIMITED-ITEMS.MATERIAL")),
|
||||
0,
|
||||
1);
|
||||
|
||||
ItemStack unlimitedItemsItemStack = unlimitedItemsItemStackButton.makeItemStack();
|
||||
|
||||
this.inventory.setItem(this.main.getMenusConfig().getConfig().getInt("MENUS.SETTINGS.SETTINGS.UNLIMITED-ITEMS.SLOT"), unlimitedItemsItemStack);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.loganmagnan.unlimiteditems.playerdata;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.managers.PlayerDataManager;
|
||||
import com.loganmagnan.unlimiteditems.playerdata.currentgame.PlayerCurrentGameData;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlayerData {
|
||||
|
||||
private PlayerDataManager playerDataManager = UnlimitedItems.getInstance().getPlayerDataManager();
|
||||
private PlayerState playerState = PlayerState.SPAWN;
|
||||
|
||||
private PlayerSettings playerSettings = new PlayerSettings();
|
||||
private PlayerCurrentGameData currentGameData = new PlayerCurrentGameData();
|
||||
|
||||
private final UUID uniqueId;
|
||||
private boolean loaded;
|
||||
|
||||
private List<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
private Effect effect;
|
||||
|
||||
public PlayerData(UUID uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
this.loaded = false;
|
||||
this.playerDataManager.loadPlayerData(this);
|
||||
}
|
||||
|
||||
public boolean isInSpawn() {
|
||||
return this.playerState == PlayerState.SPAWN;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.loganmagnan.unlimiteditems.playerdata;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlayerSettings {
|
||||
|
||||
private boolean unlimitedItems = false;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.loganmagnan.unlimiteditems.playerdata;
|
||||
|
||||
public enum PlayerState {
|
||||
|
||||
SPAWN;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.loganmagnan.unlimiteditems.playerdata.currentgame;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlayerCurrentGameData {
|
||||
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import lombok.experimental.UtilityClass;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
public class Cache<T> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -19,7 +19,7 @@ public class ClassRegistrationUtils {
|
||||
for (Class<?> clazz : getClassesInPackage(packageName)) {
|
||||
if (isListener(clazz)) {
|
||||
try {
|
||||
PluginBase.getInstance().getServer().getPluginManager().registerEvents((Listener) clazz.newInstance(), PluginBase.getInstance());
|
||||
UnlimitedItems.getInstance().getServer().getPluginManager().registerEvents((Listener) clazz.newInstance(), UnlimitedItems.getInstance());
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
@ -50,7 +50,7 @@ public class ClassRegistrationUtils {
|
||||
public static Collection<Class<?>> getClassesInPackage(String packageName) {
|
||||
JarFile jarFile;
|
||||
Collection<Class<?>> classes = new ArrayList<>();
|
||||
CodeSource codeSource = PluginBase.getInstance().getClass().getProtectionDomain().getCodeSource();
|
||||
CodeSource codeSource = UnlimitedItems.getInstance().getClass().getProtectionDomain().getCodeSource();
|
||||
URL resource = codeSource.getLocation();
|
||||
|
||||
String relPath = packageName.replace('.', '/');
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
@ -1,6 +1,6 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.loganmagnan.pluginbase.chatcolor.ColorSet;
|
||||
import com.loganmagnan.unlimiteditems.chatcolor.ColorSet;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
public class KeyUtils {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
public enum TeamAction {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
public interface TtlHandler<E> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private PluginBase main = PluginBase.getInstance();
|
||||
private UnlimitedItems main = UnlimitedItems.getInstance();
|
||||
|
||||
public static String scoreboardBar = org.bukkit.ChatColor.GRAY.toString() + org.bukkit.ChatColor.STRIKETHROUGH + "----------------------";
|
||||
public static String chatBar = org.bukkit.ChatColor.GRAY.toString() + org.bukkit.ChatColor.STRIKETHROUGH + "--------------------------------------------";
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils;
|
||||
package com.loganmagnan.unlimiteditems.utils;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
@ -0,0 +1,12 @@
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
|
||||
public abstract class BaseCommand {
|
||||
|
||||
public BaseCommand() {
|
||||
UnlimitedItems.getInstance().getCommandFramework().registerCommands(this, null);
|
||||
}
|
||||
|
||||
public abstract void executeAs(CommandArguments command);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.command.Command;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.utils.ColorUtils;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.utils.ColorUtils;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -20,11 +20,11 @@ import java.util.Map.Entry;
|
||||
|
||||
public class CommandFramework implements CommandExecutor {
|
||||
|
||||
private PluginBase plugin;
|
||||
private UnlimitedItems plugin;
|
||||
private Map<String, Entry<Method, Object>> commandMap = new HashMap<>();
|
||||
private CommandMap map;
|
||||
|
||||
public CommandFramework(PluginBase plugin) {
|
||||
public CommandFramework(UnlimitedItems plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
if (plugin.getServer().getPluginManager() instanceof SimplePluginManager) {
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.command;
|
||||
package com.loganmagnan.unlimiteditems.utils.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.config;
|
||||
package com.loganmagnan.unlimiteditems.utils.config;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.utils.config;
|
||||
package com.loganmagnan.unlimiteditems.utils.config;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.utils.ConfigUpdater;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.utils.ConfigUpdater;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -41,7 +41,7 @@ public class FileConfig {
|
||||
|
||||
try {
|
||||
if (update) {
|
||||
ConfigUpdater.update(PluginBase.getInstance(), fileName, this.file);
|
||||
ConfigUpdater.update(UnlimitedItems.getInstance(), fileName, this.file);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.utils.config.file;
|
||||
package com.loganmagnan.unlimiteditems.utils.config.file;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.utils.ConfigUpdater;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.utils.ConfigUpdater;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -31,7 +31,7 @@ public class Config {
|
||||
|
||||
try {
|
||||
if (update) {
|
||||
ConfigUpdater.update(PluginBase.getInstance(), name + ".yml", this.configFile);
|
||||
ConfigUpdater.update(UnlimitedItems.getInstance(), name + ".yml", this.configFile);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
@ -1,7 +1,7 @@
|
||||
package com.loganmagnan.pluginbase.utils.config.file;
|
||||
package com.loganmagnan.unlimiteditems.utils.config.file;
|
||||
|
||||
import com.loganmagnan.pluginbase.PluginBase;
|
||||
import com.loganmagnan.pluginbase.utils.ConfigUpdater;
|
||||
import com.loganmagnan.unlimiteditems.UnlimitedItems;
|
||||
import com.loganmagnan.unlimiteditems.utils.ConfigUpdater;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -27,7 +27,7 @@ public class ConfigFile {
|
||||
plugin.saveResource(name + ".yml", false);
|
||||
|
||||
try {
|
||||
ConfigUpdater.update(PluginBase.getInstance(), name + ".yml", this.file);
|
||||
ConfigUpdater.update(UnlimitedItems.getInstance(), name + ".yml", this.file);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.cuboid;
|
||||
package com.loganmagnan.unlimiteditems.utils.cuboid;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.*;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.cuboid;
|
||||
package com.loganmagnan.unlimiteditems.utils.cuboid;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.cuboid;
|
||||
package com.loganmagnan.unlimiteditems.utils.cuboid;
|
||||
|
||||
public enum CuboidDirection {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.loganmagnan.pluginbase.utils.cuboid;
|
||||
package com.loganmagnan.unlimiteditems.utils.cuboid;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
16
src/main/resources/menus.yml
Normal file
16
src/main/resources/menus.yml
Normal file
@ -0,0 +1,16 @@
|
||||
MENUS:
|
||||
SETTINGS:
|
||||
TITLE: "&bSettings Selector"
|
||||
SIZE: 27
|
||||
ENABLED: "&a►"
|
||||
DISABLED: "&c►"
|
||||
UNSELECTED: "&7►"
|
||||
SETTINGS:
|
||||
UNLIMITED-ITEMS:
|
||||
NAME: "&bUnlimited Items"
|
||||
LORE:
|
||||
- "&7If enabled, then you'll be"
|
||||
- "&7able to have a stack size of 99."
|
||||
- ""
|
||||
MATERIAL: "NETHER_STAR" # Don't change this value
|
||||
SLOT: 13
|
@ -1,5 +1,5 @@
|
||||
name: PluginBase
|
||||
name: UnlimitedItems
|
||||
author: Trixkz
|
||||
version: 1.0
|
||||
api-version: 1.13
|
||||
main: com.loganmagnan.pluginbase.PluginBase
|
||||
main: com.loganmagnan.unlimiteditems.UnlimitedItems
|
Loading…
Reference in New Issue
Block a user