file_name stringlengths 6 86 | file_path stringlengths 45 249 | content stringlengths 47 6.26M | file_size int64 47 6.26M | language stringclasses 1 value | extension stringclasses 1 value | repo_name stringclasses 767 values | repo_stars int64 8 14.4k | repo_forks int64 0 1.17k | repo_open_issues int64 0 788 | repo_created_at stringclasses 767 values | repo_pushed_at stringclasses 767 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
TeamSetupCommands.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/setup/TeamSetupCommands.java | package me.patothebest.gamecore.commands.setup;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.arena.AbstractArena;
import me.patothebest.gamecore.arena.AbstractGameTeam;
import me.patothebest.gamecore.arena.ArenaManager;
import me.patothebest.gamecore.chat.CommandPagination;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.CommandsManager;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.command.NestedCommand;
import me.patothebest.gamecore.modules.ParentCommandModule;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.DyeColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
public class TeamSetupCommands {
private final ArenaManager arenaManager;
@Inject
private TeamSetupCommands(ArenaManager arenaManager) {
this.arenaManager = arenaManager;
}
@ChildOf(ArenaSetupCommands.class)
public static class Parent implements ParentCommandModule {
private final CommandsManager<CommandSender> commandsManager;
@Inject
private Parent(CommandsManager<CommandSender> commandsManager) {
this.commandsManager = commandsManager;
}
@Command(
aliases = "teams",
langDescription = @LangDescription(
element = "TEAMS_COMMAND_DESCRIPTION",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.SETUP)
@NestedCommand(
value = TeamSetupCommands.class,
defaultToBody = true
)
public void teams(CommandContext args, CommandSender sender) throws CommandException {
new CommandPagination(commandsManager, args).display(sender);
}
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"create", "add", "new"},
usage = "<arena> <team name> <team color>",
min = 3,
max = 3,
langDescription = @LangDescription(
element = "NEW_TEAM",
langClass = CoreLang.class
)
)
public List<String> addGameTeam(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
if(args.getSuggestionContext() != null) {
switch(args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.complete(args.getString(0), arenaManager);
case 2:
return CommandUtils.complete(args.getString(2), DyeColor.values());
default:
return null;
}
}
AbstractArena arena = CommandUtils.getDisabledArena(args, 0, arenaManager);
DyeColor dyeColor = Utils.getEnumValueFromString(DyeColor.class, args.getString(2));
CommandUtils.validateNotNull(dyeColor, CoreLang.TEAM_COLOR_NOT_FOUND);
CommandUtils.validateTrue(!arena.containsTeam(args.getString(0)), CoreLang.TEAM_COLOR_ALREADY_EXIST);
// create and add the game team
arena.createTeam(args.getString(1), dyeColor);
player.sendMessage(CoreLang.TEAM_CREATED.getMessage(player));
arena.save();
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"setspawn", "setteamspawn"},
usage = "<arena> <team name>",
min = 2,
max = 2,
langDescription = @LangDescription(
element = "NEW_TEAM_SPAWN",
langClass = CoreLang.class
)
)
public List<String> setTeamSpawn(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
if(args.getSuggestionContext() != null) {
switch(args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.complete(args.getString(0), arenaManager);
case 1:
return CommandUtils.completeNameable(args.getString(1), CommandUtils.getDisabledArena(args, 0, arenaManager).getTeams().values());
default:
return null;
}
}
AbstractArena arena = CommandUtils.getDisabledArena(args, 0, arenaManager);
AbstractGameTeam gameTeam = CommandUtils.getTeam(arena, args, 1);
gameTeam.setSpawn(player.getLocation());
player.sendMessage(CoreLang.TEAM_SPAWN_SET.getMessage(player));
arena.save();
return null;
}
}
| 5,075 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
GeneralSetupCommands.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/setup/GeneralSetupCommands.java | package me.patothebest.gamecore.commands.setup;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.file.CoreConfig;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
public class GeneralSetupCommands {
private final CoreConfig coreConfig;
@Inject private GeneralSetupCommands(CoreConfig coreConfig) {
this.coreConfig = coreConfig;
}
@Command(
aliases = {"setmainlobby"},
max = 0,
langDescription = @LangDescription(
element = "SET_MAIN_LOBBY",
langClass = CoreLang.class
)
)
public void setMainLobby(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
// set the main lobby in the config cache and file
coreConfig.setUseMainLobby(true);
coreConfig.setMainLobby(player.getLocation());
coreConfig.set("MainLobby", coreConfig.getMainLobby().serialize());
coreConfig.set("teleport.location", "MainLobby");
// save the file
coreConfig.save();
player.sendMessage(CoreLang.MAIN_LOBBY_SET.getMessage(player));
}
@Command(
aliases = {"spawn", "lobby", "mainlobby"},
max = 0,
langDescription = @LangDescription(
element = "TP_MAIN_LOBBY",
langClass = CoreLang.class
)
)
public void spawn(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
if (coreConfig.isUseMainLobby() && coreConfig.getMainLobby() != null) {
player.teleport(coreConfig.getMainLobby());
player.sendMessage(CoreLang.MAIN_LOBBY_TP.getMessage(player));
} else {
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
}
}
} | 2,265 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CreateArenaCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/setup/CreateArenaCommand.java | package me.patothebest.gamecore.commands.setup;
import me.patothebest.gamecore.PluginConfig;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.arena.AbstractArena;
import me.patothebest.gamecore.arena.ArenaManager;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.modules.ParentCommandModule;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.io.File;
@ChildOf(SetupCommand.class)
public class CreateArenaCommand implements ParentCommandModule {
private final ArenaManager arenaManager;
@Inject private CreateArenaCommand(ArenaManager arenaManager) {
this.arenaManager = arenaManager;
}
@Command(
aliases = {"createarena", "newarena"},
usage = "<arena>",
min = 1,
max = 1,
langDescription = @LangDescription(
element = "NEW_ARENA",
langClass = CoreLang.class
)
)
public void createArena(CommandContext args, CommandSender sender) throws CommandException {
String arenaName = args.getString(0);
// requirements
CommandUtils.validateTrue(arenaManager.getArena(arenaName) == null, CoreLang.ARENA_ALREADY_EXIST);
// create the arena
AbstractArena arena = arenaManager.createArena(arenaName);
CoreLang.ARENA_CREATED.sendMessage(sender);
if(sender instanceof Player) {
Player player = CommandUtils.getPlayer(sender);
player.teleport(new Location(arena.getWorld(), 0, 100, 0));
}
}
@Command(
aliases = {"import", "importarena"},
usage = "<arena>",
min = 1,
max = 1,
langDescription = @LangDescription(
element = "IMPORT_ARENA",
langClass = CoreLang.class
)
)
public void importArena(CommandContext args, CommandSender sender) throws CommandException {
String arenaName = args.getString(0);
// requirements
CommandUtils.validateTrue(arenaManager.getArena(arenaName) == null, CoreLang.ARENA_ALREADY_EXIST);
File worldFolder = new File(arenaName + File.separatorChar);
CommandUtils.validateTrue(worldFolder.exists(), CoreLang.FOLDER_DOESNT_EXIST);
CommandUtils.validateTrue(worldFolder.isDirectory(), CoreLang.ARENA_IS_FILE);
CommandUtils.validateTrue(worldFolder.renameTo(new File(PluginConfig.WORLD_PREFIX + arenaName + File.separatorChar)), CoreLang.SOMETHING_WENT_WRONG_IMPORTING);
// create the arena
AbstractArena arena = arenaManager.createArena(arenaName);
CoreLang.ARENA_IMPORTED.sendMessage(sender);
if(sender instanceof Player) {
Player player = CommandUtils.getPlayer(sender);
player.teleport(new Location(arena.getWorld(), 0, 100, 0));
}
}
}
| 3,257 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
SetupCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/setup/SetupCommand.java | package me.patothebest.gamecore.commands.setup;
import com.google.inject.Inject;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.chat.CommandPagination;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.CommandsManager;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.command.NestedCommand;
import org.bukkit.command.CommandSender;
public class SetupCommand {
private final CommandsManager<CommandSender> commandsManager;
@Inject
private SetupCommand(CommandsManager<CommandSender> commandsManager) {
this.commandsManager = commandsManager;
}
@Command(
aliases = "setup",
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "SETUP_COMMAND_DESCRIPTION"
)
)
@CommandPermissions(permission = Permission.SETUP)
@NestedCommand(value = {
ArenaSetupCommands.class,
GeneralSetupCommands.class
},
defaultToBody = true
)
public void signs(CommandContext args, CommandSender sender) throws CommandException {
new CommandPagination(commandsManager, args).display(sender);
}
} | 1,488 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
KitCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/kit/KitCommand.java | package me.patothebest.gamecore.commands.kit;
import me.patothebest.gamecore.guis.kit.KitUIFactory;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.chat.CommandPagination;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.CommandsManager;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.command.NestedCommand;
import me.patothebest.gamecore.kit.Kit;
import me.patothebest.gamecore.kit.KitManager;
import me.patothebest.gamecore.modules.Module;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
public class KitCommand implements Module {
private final KitManager kitManager;
private final KitUIFactory kitUIFactory;
private final PlayerManager playerManager;
@Inject private KitCommand(KitManager kitManager, KitUIFactory kitUIFactory, PlayerManager playerManager) {
this.kitManager = kitManager;
this.kitUIFactory = kitUIFactory;
this.playerManager = playerManager;
}
@ChildOf(BaseCommand.class)
public static class Parent implements RegisteredCommandModule {
private final CommandsManager<CommandSender> commandsManager;
@Inject
private Parent(CommandsManager<CommandSender> commandsManager) {
this.commandsManager = commandsManager;
}
@Command(
aliases = "kits",
langDescription = @LangDescription(
element = "KIT_COMMAND_DESCRIPTION",
langClass = CoreLang.class
)
)
@NestedCommand(value = KitCommand.class)
public void signs(CommandContext args, CommandSender sender) throws CommandException {
new CommandPagination(commandsManager, args).display(sender);
}
}
@Command(
aliases = {"create", "new"},
usage = "<name>",
min = 1,
max = 1,
langDescription = @LangDescription(
element = "KIT_CREATE",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.SETUP)
public void create(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
// requirements
String kitName = args.getString(0);
if(kitManager.kitExists(kitName)) {
player.sendMessage(CoreLang.KIT_ALREADY_EXISTS.getMessage(player));
return;
}
// create the kit
kitManager.createKit(kitName, player.getInventory());
player.sendMessage(CoreLang.KIT_CREATED.getMessage(player));
}
@Command(
aliases = {"gui", "menu"},
max = 0,
langDescription = @LangDescription(
element = "KIT_GUI",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.SETUP)
public void openGUI(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
kitUIFactory.createChooseKitToEditGUI(player);
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"give", "add"},
usage = "<player> <item> [amount] [-p(ermanent)]",
flags = "p",
min = 2,
max = 3,
langDescription = @LangDescription(
element = "SHOP_ITEMS_GIVE_COMMAND",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> giveShopItems(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
switch (args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.completePlayers(args.getString(0));
case 1:
return CommandUtils.complete(args.getString(1), Utils.toList(kitManager.getEnabledKits()));
default:
return null;
}
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
Kit kit = kitManager.getKits().get(args.getString(1));
CommandUtils.validateNotNull(kit, CoreLang.SHOP_ITEM_NOT_FOUND);
if (!kit.isOneTimeKit()) {
player.buyPermanentKit(kit);
CoreLang.SHOP_ITEMS_GIVEN_PERMANENT.replaceAndSend(sender, player.getName(), kit.getName(), "kit");
} else {
int amount = args.getInteger(2, -1);
CommandUtils.validateTrue(amount > 0, CoreLang.SHOP_ITEMS_GIVE_MUST_BE_POSITIVE);
player.addKitUses(kit, amount);
CoreLang.SHOP_ITEMS_GIVEN.replaceAndSend(sender, player.getName(), amount, kit.getName(), "kit");
}
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"giveall", "addall"},
usage = "<player> [amount] [-p(ermanent]",
flags = "p",
min = 1,
max = 2,
langDescription = @LangDescription(
element = "SHOP_ITEMS_GIVE_ALL_COMMAND",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> giveAll(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.completePlayers(args.getString(0));
}
return null;
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
int amount = -1;
if (args.isInBounds(1)) {
amount = args.getInteger(1, -1);
CommandUtils.validateTrue(amount > 0, CoreLang.SHOP_ITEMS_GIVE_MUST_BE_POSITIVE);
}
for (Kit kit : kitManager.getEnabledKits()) {
if (args.hasFlag('p')) {
player.buyPermanentKit(kit);
CoreLang.SHOP_ITEMS_GIVEN_PERMANENT.replaceAndSend(sender, player.getName(), kit.getName(), "kit");
} else if (amount != -1 && kit.isOneTimeKit()) {
player.addKitUses(kit, amount);
CoreLang.SHOP_ITEMS_GIVEN.replaceAndSend(sender, player.getName(), amount, kit.getName(), "kit");
}
}
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"set"},
usage = "<player> <item> <amount>",
min = 3,
max = 3,
langDescription = @LangDescription(
element = "SHOP_ITEMS_SET_COMMAND",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> setShopItems(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
switch (args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.completePlayers(args.getString(0));
case 1:
return CommandUtils.complete(args.getString(1), Utils.toList(kitManager.getEnabledKits()));
default:
return null;
}
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
Kit kit = kitManager.getKits().get(args.getString(1));
CommandUtils.validateNotNull(kit, CoreLang.SHOP_ITEM_NOT_FOUND);
CommandUtils.validateTrue(kit.isOneTimeKit(), CoreLang.SHOP_ITEM_IS_PERMANENT);
int amount = args.getInteger(2);
CommandUtils.validateTrue(amount > 0, CoreLang.SHOP_ITEMS_GIVE_MUST_BE_POSITIVE);
player.setKitUses(kit, amount);
CoreLang.SHOP_ITEMS_GIVEN.replaceAndSend(sender, player.getName(), amount, kit.getName(), "kit");
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"remove", "take", "reset"},
usage = "<player> <item> [amount]",
min = 2,
max = 3,
langDescription = @LangDescription(
element = "SHOP_ITEMS_REMOVE_COMMAND",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> removeShopItems(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
switch (args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.completePlayers(args.getString(0));
case 1:
return CommandUtils.complete(args.getString(1), Utils.toList(kitManager.getEnabledKits()));
default:
return null;
}
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
Kit kit = kitManager.getKits().get(args.getString(1));
CommandUtils.validateNotNull(kit, CoreLang.SHOP_ITEM_NOT_FOUND);
CommandUtils.validateTrue(kit.isOneTimeKit(), CoreLang.SHOP_ITEM_IS_PERMANENT);
if (!kit.isOneTimeKit()) {
player.removeKit(kit);
CoreLang.SHOP_ITEMS_REMOVED_PERMANENT.replaceAndSend(sender, player.getName(), kit.getName(), "kit");
} else {
if (args.isInBounds(2)) {
int amount = args.getInteger(2, -1);
CommandUtils.validateTrue(amount > 0, CoreLang.SHOP_ITEMS_TAKE_MUST_BE_POSITIVE);
player.removeKit(kit, args.getInteger(2));
CoreLang.SHOP_ITEMS_REMOVED.replaceAndSend(sender, player.getName(), amount, kit.getName(), "kit");
} else {
player.removeKit(kit);
CoreLang.SHOP_ITEMS_REMOVED_PERMANENT.replaceAndSend(sender, player.getName(), kit.getName(), "kit");
}
}
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"removeall", "takeall", "resetall"},
usage = "<player> [amount]",
min = 1,
max = 2,
langDescription = @LangDescription(
element = "SHOP_ITEMS_REMOVE_ALL_COMMAND",
langClass = CoreLang.class
)
)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> removeAll(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.completePlayers(args.getString(0));
}
return null;
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
int amount = -1;
if (args.isInBounds(1)) {
amount = args.getInteger(1, -1);
CommandUtils.validateTrue(amount > 0, CoreLang.SHOP_ITEMS_TAKE_MUST_BE_POSITIVE);
}
for (Kit kit : kitManager.getEnabledKits()) {
if (amount == -1) {
player.removeKit(kit);
CoreLang.SHOP_ITEMS_REMOVED_PERMANENT.replaceAndSend(sender, player.getName(), kit.getName(), "kit");
} else {
player.removeKit(kit, amount);
CoreLang.SHOP_ITEMS_REMOVED.replaceAndSend(sender, player.getName(), amount, kit.getName(), "kit");
}
}
return null;
}
} | 12,293 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
AdminCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/admin/AdminCommand.java | package me.patothebest.gamecore.commands.admin;
import com.google.inject.Inject;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.chat.CommandPagination;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.CommandsManager;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.command.NestedCommand;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import org.bukkit.command.CommandSender;
import java.util.List;
@ChildOf(BaseCommand.class)
public class AdminCommand implements RegisteredCommandModule {
private final CommandsManager<CommandSender> commandsManager;
@Inject private AdminCommand(CommandsManager<CommandSender> commandsManager) {
this.commandsManager = commandsManager;
}
@Command(
aliases = {"admin"},
langDescription = @LangDescription(
element = "ADMIN_COMMAND_DESC",
langClass = CoreLang.class
)
)
@NestedCommand(defaultToBody = true)
@CommandPermissions(permission = Permission.ADMIN)
public List<String> execute(CommandContext args, CommandSender sender) throws CommandException {
new CommandPagination(commandsManager, args).display(sender);
return null;
}
} | 1,659 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RenameCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/admin/RenameCommand.java | package me.patothebest.gamecore.commands.admin;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.command.HiddenCommand;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.gui.anvil.AnvilGUI;
import me.patothebest.gamecore.gui.anvil.AnvilSlot;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ChildOf(BaseCommand.class)
public class RenameCommand implements RegisteredCommandModule {
private final Map<String, ItemStack> items = new HashMap<>();
private final CorePlugin plugin;
@Inject private RenameCommand(CorePlugin plugin) {
this.plugin = plugin;
}
@Command(
aliases = {"rename"},
max = 0,
langDescription = @LangDescription(
element = "Rename an item in hand",
langClass = CoreLang.class
)
)
@HiddenCommand
@CommandPermissions(permission = Permission.ADMIN)
public List<String> rename(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
AnvilGUI gui = new AnvilGUI(plugin, player, event -> {
if(event.getSlot() == AnvilSlot.OUTPUT){
event.setWillClose(true);
ItemStack item = items.get(event.getPlayerName());
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(event.getName().replace("&", "§"));
item.setItemMeta(itemMeta);
Bukkit.getPlayer(event.getPlayerName()).setItemInHand(item);
items.remove(event.getPlayerName());
} else {
event.setWillClose(true);
Bukkit.getPlayer(event.getPlayerName()).setItemInHand(items.get(event.getPlayerName()));
items.remove(event.getPlayerName());
}
});
gui.setSlot(AnvilSlot.INPUT_LEFT, player.getItemInHand());
items.put(player.getName(), player.getItemInHand());
player.closeInventory();
player.setItemInHand(null);
gui.open();
return null;
}
}
| 2,909 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
AdminArenaCommands.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/admin/AdminArenaCommands.java | package me.patothebest.gamecore.commands.admin;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.arena.AbstractArena;
import me.patothebest.gamecore.arena.ArenaManager;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.guis.AdminGUIFactory;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
import java.util.stream.Collectors;
@ChildOf(AdminCommand.class)
public class AdminArenaCommands implements RegisteredCommandModule {
private final AdminGUIFactory adminGUIFactory;
private final ArenaManager arenaManager;
@Inject private AdminArenaCommands(AdminGUIFactory adminGUIFactory, ArenaManager arenaManager) {
this.adminGUIFactory = adminGUIFactory;
this.arenaManager = arenaManager;
}
@Command(
aliases = {"join"},
langDescription = @LangDescription(
element = "JOIN_ARENA",
langClass = CoreLang.class
)
)
public List<String> joinArena(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
adminGUIFactory.createMenu(player);
return null;
}
@Command(
aliases = {"forcestart"},
usage = "<arena>",
min = 1,
max = 1,
langDescription = @LangDescription(
element = "FORCE_START",
langClass = CoreLang.class
)
)
public List<String> forcestart(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
return CommandUtils.complete(args.getString(0), arenaManager
.getArenas()
.values()
.stream()
.filter(AbstractArena::isEnabled)
.filter(arena -> !arena.isInGame())
.map(AbstractArena::getName)
.collect(Collectors.toList()));
}
AbstractArena arena = CommandUtils.getEnabledArena(args, 0, arenaManager);
CommandUtils.validateTrue(!arena.isInGame(), CoreLang.ARENA_ALREADY_STARTED);
arena.nextPhase();
CoreLang.ARENA_FORCE_STARTED.sendMessage(sender);
return null;
}
@Command(
aliases = {"forceend"},
usage = "<arena>",
min = 1,
max = 1,
langDescription = @LangDescription(
element = "FORCE_END",
langClass = CoreLang.class
)
)
public List<String> forceend(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
return CommandUtils.complete(args.getString(0), arenaManager
.getArenas()
.values()
.stream()
.filter(AbstractArena::isEnabled)
.filter(AbstractArena::isInGame)
.map(AbstractArena::getName)
.collect(Collectors.toList()));
}
AbstractArena arena = CommandUtils.getEnabledArena(args, 0, arenaManager);
CommandUtils.validateTrue(arena.isInGame(), CoreLang.ARENA_NOT_STARTED);
// end the arena
arena.endArena(true);
CoreLang.ARENA_FORCE_ENDED.sendMessage(sender);
return null;
}
}
| 3,855 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
GeneralAdminCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/admin/GeneralAdminCommand.java | package me.patothebest.gamecore.commands.admin;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.PluginConfig;
import me.patothebest.gamecore.command.ChatColor;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.modules.ModuleName;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.modules.ParentCommandModule;
import me.patothebest.gamecore.modules.ReloadPriority;
import me.patothebest.gamecore.modules.ReloadableModule;
import me.patothebest.gamecore.storage.StorageManager;
import me.patothebest.gamecore.util.CommandUtils;
import me.patothebest.gamecore.util.Priority;
import org.bukkit.command.CommandSender;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Manifest;
@Singleton
@ChildOf(AdminCommand.class)
@ModuleName("General Admin Command")
public class GeneralAdminCommand implements ParentCommandModule, ActivableModule {
private final List<ReloadableModule> reloadableModules = new ArrayList<>();
private final List<String> reloadableModuleNames = new ArrayList<>();
private final CorePlugin corePlugin;
private final StorageManager storageManager;
@Inject private GeneralAdminCommand(CorePlugin corePlugin, StorageManager storageManager) {
this.corePlugin = corePlugin;
this.storageManager = storageManager;
}
@Override
public void onPostEnable() {
corePlugin.getModuleInstances().forEach(classModuleEntry -> {
if(classModuleEntry.getValue() instanceof ReloadableModule) {
reloadableModules.add((ReloadableModule) classModuleEntry.getValue());
reloadableModuleNames.add(((ReloadableModule) classModuleEntry.getValue()).getReloadName());
}
});
reloadableModules.sort((module1, module2) -> {
Priority module1Priority = Priority.NORMAL;
Priority module2Priority = Priority.NORMAL;
if(module1.getClass().isAnnotationPresent(ReloadPriority.class)) {
module1Priority = module1.getClass().getAnnotation(ReloadPriority.class).priority();
}
if(module2.getClass().isAnnotationPresent(ReloadPriority.class)) {
module2Priority = module2.getClass().getAnnotation(ReloadPriority.class).priority();
}
return module1Priority.compareTo(module2Priority);
});
reloadableModuleNames.add("all");
}
@Command(
aliases = {"reload", "rl"},
usage = "<module|all>",
max = 1,
langDescription = @LangDescription(
element = "RELOAD_COMMAND_DESC",
langClass = CoreLang.class
)
)
public List<String> onReload(CommandContext args, CommandSender sender) throws CommandException {
if(args.getSuggestionContext() != null) {
return CommandUtils.complete(args.getString(0), reloadableModuleNames);
}
if(args.argsLength() == 0) {
CoreLang.RELOADABLE_MODULES.replaceAndSend(sender);
for (String reloadableModuleName : reloadableModuleNames) {
sender.sendMessage(ChatColor.BLUE + "- " + ChatColor.YELLOW + reloadableModuleName);
}
return null;
}
CommandUtils.validateTrue(reloadableModuleNames.contains(args.getString(0)), CoreLang.RELOAD_UNKNOWN);
if(args.getString(0).equalsIgnoreCase("all")) {
long total = 0;
for (ReloadableModule reloadableModule : reloadableModules) {
long reloadTime = reloadModule(reloadableModule);
if(reloadTime != -1) {
total += reloadTime;
CoreLang.RELOADED_MODULE.replaceAndSend(sender, Utils.capitalizeFirstLetter(reloadableModule.getReloadName()), reloadTime);
} else {
CoreLang.RELOADED_MODULE_FAIL.replaceAndSend(sender, Utils.capitalizeFirstLetter(reloadableModule.getReloadName()));
}
}
CoreLang.RELOADED_MODULE.replaceAndSend(sender, "All", total);
} else {
for (ReloadableModule reloadableModule : reloadableModules) {
if(reloadableModule.getReloadName().equalsIgnoreCase(args.getString(0))) {
long reloadTime = reloadModule(reloadableModule);
// if(reloadableModule instanceof ShopManager) {
// reloadTime += reloadModule(storageManager); // Fix for shop object mapping
// }
if(reloadTime != -1) {
CoreLang.RELOADED_MODULE.replaceAndSend(sender, Utils.capitalizeFirstLetter(reloadableModule.getReloadName()), reloadTime);
} else {
CoreLang.RELOADED_MODULE_FAIL.replaceAndSend(sender, Utils.capitalizeFirstLetter(reloadableModule.getReloadName()));
}
}
}
}
return null;
}
@Command(
aliases = {"version", "ver"},
max = 0,
langDescription = @LangDescription(
element = "VERSION_COMMAND_DESC",
langClass = CoreLang.class
)
)
public void verion(CommandContext args, CommandSender sender) throws CommandException {
URLClassLoader cl = (URLClassLoader) getClass().getClassLoader();
try {
// get the MANIFEST.MF
URL url = cl.findResource("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(url.openStream());
// send the details of the build
sender.sendMessage(format("Version: " + org.bukkit.ChatColor.GOLD + manifest.getMainAttributes().getValue("Implementation-Version")));
sender.sendMessage(format("Built By: " + org.bukkit.ChatColor.GOLD + manifest.getMainAttributes().getValue("Built-By")));
sender.sendMessage(format("Built On: " + org.bukkit.ChatColor.GOLD + manifest.getMainAttributes().getValue("Build-Time")));
sender.sendMessage(format("Built With: " + org.bukkit.ChatColor.GOLD + "Java " + manifest.getMainAttributes().getValue("Build-Jdk")));
} catch (IOException ignored) {
}
}
private String format(String s) {
return org.bukkit.ChatColor.DARK_GRAY + "[" + org.bukkit.ChatColor.RED + PluginConfig.LANG_PREFIX + org.bukkit.ChatColor.DARK_GRAY + "] » " + org.bukkit.ChatColor.GRAY + s;
}
private long reloadModule(ReloadableModule reloadableModule) {
long start = System.currentTimeMillis();
try {
reloadableModule.onReload();
return System.currentTimeMillis() - start;
} catch (Throwable t) {
return -1;
}
}
}
| 7,298 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ArenaUserCommands.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/user/ArenaUserCommands.java | package me.patothebest.gamecore.commands.user;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.event.player.RandomArenaJoinEvent;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.arena.AbstractArena;
import me.patothebest.gamecore.arena.ArenaManager;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.event.EventRegistry;
import me.patothebest.gamecore.guis.UserGUIFactory;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
public class ArenaUserCommands {
private final PlayerManager playerManager;
private final ArenaManager arenaManager;
private final UserGUIFactory userGUIFactory;
private final EventRegistry eventRegistry;
@Inject private ArenaUserCommands(PlayerManager playerManager, ArenaManager arenaManager, UserGUIFactory userGUIFactory, CorePlugin corePlugin, EventRegistry eventRegistry) {
this.playerManager = playerManager;
this.arenaManager = arenaManager;
this.userGUIFactory = userGUIFactory;
this.eventRegistry = eventRegistry;
}
@Command(
aliases = {"join", "j"},
usage = "[arena] [-r(andom)]",
flags = "r",
max = 1,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "JOIN_ARENA"
)
)
public List<String> joinCommand(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
if (args.getSuggestionContext() != null) {
return CommandUtils.complete(args.getString(0, ""), Utils.toList(arenaManager.getArenas().values()));
}
if (args.hasFlag('r')) {
List<AbstractArena> joinableArenas = arenaManager.getJoinableArenas(player, arena -> !arena.isFull());
CommandUtils.validateTrue(!joinableArenas.isEmpty(), CoreLang.NO_ARENAS);
RandomArenaJoinEvent arenaJoinEvent = eventRegistry.callEvent(new RandomArenaJoinEvent(player, joinableArenas.get(0)));
CommandUtils.validateNotNull(arenaJoinEvent.getArena(), CoreLang.NO_ARENAS);
AbstractArena currentArena = playerManager.getPlayer(player.getName()).getCurrentArena();
if (currentArena == arenaJoinEvent.getArena()) {
return null;
}
if (currentArena != null) {
currentArena.removePlayer(player);
}
arenaJoinEvent.getArena().addPlayer(player);
return null;
}
// check args
if (!args.isInBounds(0)) {
userGUIFactory.createJoinArenaUI(player);
return null;
}
CommandUtils.validateTrue(playerManager.getPlayer(player.getName()).getCurrentArena() == null, CoreLang.ALREADY_IN_ARENA);
AbstractArena arena = CommandUtils.getArena(args, 0, arenaManager);
CommandUtils.validateTrue(arena.isEnabled(), CoreLang.ARENA_IS_NOT_PLAYABLE);
CommandUtils.validateTrue(arena.canJoinArena(), CoreLang.ARENA_IS_RESTARTING);
if (arena.getPhase().canJoin()) {
if (arena.isFull()) {
player.sendMessage(CoreLang.ARENA_IS_FULL.getMessage(player));
return null;
}
arena.addPlayer(player);
} else if(arena.canJoinArena()){
player.sendMessage(CoreLang.ARENA_HAS_STARTED.getMessage(player));
} else {
player.sendMessage(CoreLang.ARENA_IS_RESTARTING.getMessage(player));
}
return null;
}
@Command(
aliases = {"spec", "spectate", "s"},
usage = "<arena>",
min = 1,
max = 1,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "SPEC_ARENA"
)
)
public List<String> spectateCommand(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
if (args.getSuggestionContext() != null) {
return CommandUtils.complete(args.getString(0), Utils.toList(arenaManager.getArenas().values()));
}
CommandUtils.validateTrue(playerManager.getPlayer(player.getName()).getCurrentArena() == null, CoreLang.ALREADY_IN_ARENA);
AbstractArena arena = CommandUtils.getArena(args, 0, arenaManager);
CommandUtils.validateTrue(arena.isEnabled(), CoreLang.ARENA_IS_NOT_PLAYABLE);
CommandUtils.validateTrue(arena.canJoinArena(), CoreLang.ARENA_IS_RESTARTING);
arena.addSpectator(player);
return null;
}
@Command(
aliases = {"leave", "l"},
max = 0,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "LEAVE_ARENA"
)
)
public List<String> leaveCommand(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
AbstractArena arena = playerManager.getPlayer(player.getName()).getCurrentArena();
CommandUtils.validateNotNull(arena, CoreLang.NOT_IN_AN_ARENA);
arena.removePlayer(player);
return null;
}
@Command(
aliases = {"list", "arenas"},
max = 0,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "LIST_ARENAS"
)
)
public List<String> listArenas(CommandContext args, CommandSender sender) throws CommandException {
sender.sendMessage("§6Oo-----------------------oOo-----------------------oO");
for (AbstractArena arena : arenaManager.getArenas().values()) {
sender.sendMessage(arena.getWorldName() + " " + (arena.isEnabled() ? ChatColor.GREEN + CoreLang.ARENA_ENABLED_SHORT.getMessage(sender) : ChatColor.RED + CoreLang.ARENA_DISABLED_SHORT.getMessage(sender)));
}
sender.sendMessage("§6Oo-----------------------oOo-----------------------oO");
return null;
}
}
| 6,574 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
UserKitCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/user/UserKitCommand.java | package me.patothebest.gamecore.commands.user;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.HiddenCommand;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.guis.UserGUIFactory;
import me.patothebest.gamecore.kit.Kit;
import me.patothebest.gamecore.kit.KitManager;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import me.patothebest.gamecore.util.Utils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
@ChildOf(BaseCommand.class)
public class UserKitCommand implements RegisteredCommandModule {
private final CorePlugin corePlugin;
private final KitManager kitManager;
private final PlayerManager playerManager;
private final UserGUIFactory userGUIFactory;
@Inject private UserKitCommand(CorePlugin corePlugin, KitManager kitManager, PlayerManager playerManager, UserGUIFactory userGUIFactory) {
this.corePlugin = corePlugin;
this.kitManager = kitManager;
this.playerManager = playerManager;
this.userGUIFactory = userGUIFactory;
}
@Command(
aliases = {"kit"},
max = 2,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "KIT_COMMAND"
)
)
public void kitCommand(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
// new ArenaKitShopUI(corePlugin, kitManager, playerManager, player);
userGUIFactory.openKitShop(player);
}
@Command(
aliases = {"layout"},
min = 1,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "KIT_COMMAND"
)
)
@HiddenCommand
public List<String> kitLayoutCommand(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.complete(args.getString(0), Utils.toList(kitManager.getEnabledKits()));
}
return null;
}
Player player = CommandUtils.getPlayer(sender);
Kit kit = kitManager.getKits().get(args.remainingString(0));
CommandUtils.validateNotNull(kit, CoreLang.SHOP_ITEM_NOT_FOUND);
IPlayer player1 = playerManager.getPlayer(player);
userGUIFactory.openKitLayoutEditor(player1, kit, player::closeInventory);
return null;
}
}
| 3,124 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LocaleCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/commands/user/LocaleCommand.java | package me.patothebest.gamecore.commands.user;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.guis.user.ChooseLocale;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
public class LocaleCommand {
private final CorePlugin plugin;
private final PlayerManager playerManager;
@Inject private LocaleCommand(CorePlugin plugin, PlayerManager playerManager) {
this.plugin = plugin;
this.playerManager = playerManager;
}
@Command(
aliases = {"lang", "language", "locale"},
max = 0,
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "LOCALE_COMMAND"
)
)
public void openLocale(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
new ChooseLocale(plugin, playerManager, player);
}
}
| 1,364 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureManager.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureManager.java | package me.patothebest.gamecore.treasure;
import com.google.inject.Inject;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.modules.ModuleName;
import me.patothebest.gamecore.treasure.chest.TreasureChest;
import me.patothebest.gamecore.treasure.chest.TreasureChestLocation;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.logger.InjectLogger;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.modules.ListenerModule;
import me.patothebest.gamecore.modules.ReloadableModule;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CacheCollection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@ModuleName("Treasure Chest Manager")
public class TreasureManager implements ActivableModule, ListenerModule, ReloadableModule {
private final List<TreasureChestLocation> treasureLocations = new ArrayList<>();
private final CacheCollection<Player> playerCache = new CacheCollection<>(cacheBuilder -> cacheBuilder.expireAfterWrite(1, TimeUnit.MINUTES));
private final TreasureFile treasureFile;
private final TreasureConfigFile treasureConfigFile;
private final TreasureFactory treasureFactory;
private final PlayerManager playerManager;
@InjectLogger private Logger logger;
@Inject private TreasureManager(TreasureFile treasureFile, TreasureConfigFile treasureConfigFile, TreasureFactory treasureFactory, PlayerManager playerManager) {
this.treasureFile = treasureFile;
this.treasureConfigFile = treasureConfigFile;
this.treasureFactory = treasureFactory;
this.playerManager = playerManager;
}
@SuppressWarnings("unchecked")
@Override
public void onEnable() {
treasureLocations.clear();
if (treasureFile.get("chests") == null) {
return;
}
treasureLocations.addAll(Utils.deserializeList((List<Map<String, Object>>) treasureFile.get("chests"), treasureFactory::createLocation));
}
@Override
public void onDisable() {
treasureLocations.forEach(treasureLocation -> {
if(treasureLocation.getHologram() != null && treasureLocation.getHologram().isAlive()) {
treasureLocation.getHologram().delete();
}
TreasureChest currentTreasureChest = treasureLocation.getCurrentTreasureChest();
if (currentTreasureChest != null) {
currentTreasureChest.forceDestroy();
}
});
treasureFile.set("chests", Utils.serializeList(treasureLocations));
treasureFile.save();
}
@Override
public void onReload() {
onDisable();
treasureFile.load();
treasureConfigFile.load();
treasureConfigFile.onPreEnable();
onEnable();
}
@Override
public String getReloadName() {
return "treasure";
}
@EventHandler
public void openChest(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
if (event.getClickedBlock().getType() != Material.CHEST.parseMaterial()) {
return;
}
for (TreasureChestLocation treasureLocation : treasureLocations) {
if(treasureLocation.getLocation().equals(event.getClickedBlock().getLocation())) {
event.setCancelled(true);
if(TreasureType.VOTE.isEnabled()) {
treasureFactory.createMenuWithVote(playerManager.getPlayer(event.getPlayer()), treasureLocation);
} else {
treasureFactory.createMenuWithoutVote(playerManager.getPlayer(event.getPlayer()), treasureLocation);
}
}
}
}
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
if (event.getClickedBlock() == null) {
return;
}
if (event.getClickedBlock().getType() != Material.CHEST.parseMaterial()) {
return;
}
if (!playerCache.contains(event.getPlayer())) {
return;
}
TreasureChestLocation location = treasureFactory.createLocation(event.getClickedBlock().getLocation());
treasureLocations.add(location);
playerCache.remove(event.getPlayer());
CoreLang.TREASURE_ADDED.sendMessage(event.getPlayer());
}
@SuppressWarnings("SuspiciousMethodCalls")
@EventHandler
public void onChestOpen(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
if (event.getClickedBlock().getType() != Material.CHEST.parseMaterial()) {
return;
}
TreasureChest treasureChest = getChest(event.getPlayer());
if (treasureChest == null) {
return;
}
if (!treasureChest.getChests().contains(event.getClickedBlock().getState())) {
return;
}
event.setCancelled(true);
treasureChest.openChest(event.getClickedBlock());
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
return;
}
for (TreasureChestLocation treasureLocation : treasureLocations) {
if(treasureLocation.canOpen()) {
continue;
}
if (Utils.offset(treasureLocation.getLocation(), event.getTo()) > 2 && event.getPlayer().getName().equalsIgnoreCase(treasureLocation.getCurrentTreasureChest().getPlayer().getName())) {
//Utils.bounceTo(event.getPlayer(), treasureLocation.getLocation());
event.getPlayer().teleport(event.getFrom());
}
}
}
@EventHandler
public void onMove2(PlayerMoveEvent event) {
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
return;
}
for (TreasureChestLocation treasureLocation : treasureLocations) {
if(treasureLocation.canOpen()) {
continue;
}
if (Utils.offset(treasureLocation.getLocation(), event.getTo()) < 4 && !event.getPlayer().getName().equalsIgnoreCase(treasureLocation.getCurrentTreasureChest().getPlayer().getName())) {
event.getPlayer().setVelocity(new Vector(treasureLocation.getLocation().getX() - event.getFrom().getBlockX(), -4, treasureLocation.getLocation().getZ() - event.getFrom().getBlockZ()).normalize().multiply(-1));
}
}
}
@EventHandler
public void onPickup(PlayerPickupItemEvent event) {
for (TreasureChest treasureChest : getTreasureChests()) {
for (Entity item : treasureChest.getItems()) {
if (item.getUniqueId() == event.getItem().getUniqueId()) {
event.setCancelled(true);
return;
}
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
TreasureChest treasureChest = getChest(event.getPlayer());
if (treasureChest == null) {
return;
}
treasureChest.forceDestroy();
}
private List<TreasureChest> getTreasureChests() {
return treasureLocations.stream().filter(TreasureChestLocation::isNotAvailable).map(TreasureChestLocation::getCurrentTreasureChest).collect(Collectors.toList());
}
private TreasureChest getChest(Player player) {
return Utils.getFromCollection(getTreasureChests(), treasureChest -> treasureChest != null && treasureChest.getPlayer().getPlayer() == player);
}
/**
* Gets the player cache used to know which player should
* we listen to, when they right click a chest
* <p>
* This collection is a cache which automatically removes
* any element added withing 1 minute of write
*
* @return the player cache
*/
public Collection<Player> getPlayerCache() {
return playerCache;
}
}
| 9,114 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureCommand.java | package me.patothebest.gamecore.treasure;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.permission.Permission;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.chat.CommandPagination;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.CommandPermissions;
import me.patothebest.gamecore.command.CommandsManager;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.command.NestedCommand;
import me.patothebest.gamecore.modules.Module;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
public class TreasureCommand implements Module {
private final TreasureManager treasureManager;
private final PlayerManager playerManager;
@Inject private TreasureCommand(TreasureManager treasureManager, PlayerManager playerManager) {
this.treasureManager = treasureManager;
this.playerManager = playerManager;
}
@ChildOf(BaseCommand.class)
public static class Parent implements RegisteredCommandModule {
private final CommandsManager<CommandSender> commandsManager;
@Inject private Parent(CommandsManager<CommandSender> commandsManager) {
this.commandsManager = commandsManager;
}
@Command(
aliases = {"treasure", "treasurechests", "chests"},
langDescription = @LangDescription(
langClass = CoreLang.class,
element = "TREASURE_CHESTS_COMMAND_DESCRIPTION"
)
)
@CommandPermissions(permission = Permission.SETUP)
@NestedCommand(value = TreasureCommand.class)
public void signs(CommandContext args, CommandSender sender) throws CommandException {
new CommandPagination(commandsManager, args).display(sender);
}
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"give", "add"},
usage = "<player> <type> <amount>",
min = 3,
max = 3,
langDescription = @LangDescription(
element = "GIVE_TREASURE_CHESTS_COMMAND",
langClass = CoreLang.class
)
)
public List<String> giveTreasureChest(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
switch (args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.completePlayers(args.getString(0));
case 1:
return CommandUtils.complete(args.getString(1), TreasureType.values());
default:
return null;
}
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
TreasureType treasureType = CommandUtils.getEnumValueFromString(TreasureType.class, args.getString(1), CoreLang.INVALID_TREASURE_CHEST);
player.setKeys(treasureType, player.getKeys(treasureType) + args.getInteger(2));
CoreLang.TREASURE_CHESTS_GIVEN.replaceAndSend(sender, player.getName(), player.getKeys(treasureType), treasureType.getName());
return null;
}
@Command(
aliases = {"giveall", "addall"},
usage = "<player> <amount>",
min = 2,
max = 2,
langDescription = @LangDescription(
element = "GIVE_ALL_TREASURE_CHESTS_COMMAND",
langClass = CoreLang.class
)
)
public List<String> giveAllTreasureChests(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.completePlayers(args.getString(0));
}
return null;
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
for (TreasureType type : TreasureType.values()) {
player.setKeys(type, player.getKeys(type) + args.getInteger(1));
CoreLang.TREASURE_CHESTS_GIVEN.replaceAndSend(sender, player.getName(), player.getKeys(type), type.getName());
}
return null;
}
@SuppressWarnings("Duplicates")
@Command(
aliases = {"set"},
usage = "<player> <type> <amount>",
min = 3,
max = 3,
langDescription = @LangDescription(
element = "SET_TREASURE_CHEST_COMMAND",
langClass = CoreLang.class
)
)
public List<String> setTreasureChest(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
switch (args.getSuggestionContext().getIndex()) {
case 0:
return CommandUtils.completePlayers(args.getString(0));
case 1:
return CommandUtils.complete(args.getString(1), TreasureType.values());
default:
return null;
}
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
TreasureType treasureType = CommandUtils.getEnumValueFromString(TreasureType.class, args.getString(1), CoreLang.INVALID_TREASURE_CHEST);
player.setKeys(treasureType, args.getInteger(2));
CoreLang.TREASURE_CHESTS_GIVEN.replaceAndSend(sender, player.getName(), player.getKeys(treasureType), treasureType.getName());
return null;
}
@Command(
aliases = {"setall"},
usage = "<player> <amount>",
min = 2,
max = 2,
langDescription = @LangDescription(
element = "SET_ALL_TREASURE_CHEST_COMMAND",
langClass = CoreLang.class
)
)
public List<String> giveAllCages(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.completePlayers(args.getString(0));
}
return null;
}
IPlayer player = CommandUtils.getPlayer(args, playerManager, 0);
for (TreasureType type : TreasureType.values()) {
player.setKeys(type, args.getInteger(1));
CoreLang.TREASURE_CHESTS_GIVEN.replaceAndSend(sender, player.getName(), player.getKeys(type), type.getName());
}
return null;
}
@Command(
aliases = {"addlocation"},
max = 0,
langDescription = @LangDescription(
element = "TREASURE_ADD_DESC",
langClass = CoreLang.class
)
)
public void addChest(CommandContext args, CommandSender sender) throws CommandException {
Player player = CommandUtils.getPlayer(sender);
treasureManager.getPlayerCache().add(player);
CoreLang.TREASURE_ADD.sendMessage(player);
}
} | 7,584 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureModule.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureModule.java | package me.patothebest.gamecore.treasure;
import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.multibindings.Multibinder;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.treasure.chest.TreasureChestStructureFile;
import me.patothebest.gamecore.treasure.entities.TreasureFlatFileEntity;
import me.patothebest.gamecore.treasure.entities.TreasureMySQLEntity;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardFile;
import me.patothebest.gamecore.treasure.reward.RewardProvider;
import me.patothebest.gamecore.treasure.reward.rewards.CommandReward;
import me.patothebest.gamecore.treasure.reward.rewards.ItemReward;
import me.patothebest.gamecore.treasure.reward.rewards.MoneyReward;
import me.patothebest.gamecore.treasure.reward.rewards.PermissionReward;
import me.patothebest.gamecore.treasure.reward.rewards.ShopReward;
import me.patothebest.gamecore.injector.AbstractBukkitModule;
import me.patothebest.gamecore.injector.InstanceProvider;
import me.patothebest.gamecore.storage.flatfile.FlatFileEntity;
import me.patothebest.gamecore.storage.mysql.MySQLEntity;
public class TreasureModule extends AbstractBukkitModule<CorePlugin> {
public TreasureModule(CorePlugin plugin) {
super(plugin);
}
@Override
protected void configure() {
install(new FactoryModuleBuilder().build(TreasureFactory.class));
registerModule(TreasureFile.class);
registerModule(TreasureCommand.Parent.class);
registerModule(TreasureManager.class);
registerModule(RewardFile.class);
registerModule(TreasureChestStructureFile.class);
registerModule(TreasureConfigFile.class);
MapBinder<String, InstanceProvider<Reward>> mapBinder = MapBinder.newMapBinder(binder(), new TypeLiteral<String>() {}, new TypeLiteral<InstanceProvider<Reward>>() {});
mapBinder.addBinding("command").toInstance(new RewardProvider(CommandReward.class));
mapBinder.addBinding("item").toInstance(new RewardProvider(ItemReward.class));
mapBinder.addBinding("money").toInstance(new RewardProvider(MoneyReward.class));
mapBinder.addBinding("permission").toInstance(new RewardProvider(PermissionReward.class));
mapBinder.addBinding("shop-item").toInstance(new RewardProvider(ShopReward.class));
Multibinder<MySQLEntity> mySQLEntityMultibinder = Multibinder.newSetBinder(binder(), MySQLEntity.class);
mySQLEntityMultibinder.addBinding().to(TreasureMySQLEntity.class);
Multibinder<FlatFileEntity> flatFileEntityMultibinder = Multibinder.newSetBinder(binder(), FlatFileEntity.class);
flatFileEntityMultibinder.addBinding().to(TreasureFlatFileEntity.class);
}
}
| 2,874 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureFactory.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureFactory.java | package me.patothebest.gamecore.treasure;
import me.patothebest.gamecore.treasure.chest.TreasureChest;
import me.patothebest.gamecore.treasure.chest.TreasureChestLocation;
import me.patothebest.gamecore.treasure.reward.RewardRandomizer;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.treasure.ui.BuyTreasureChestsUI;
import me.patothebest.gamecore.treasure.ui.OpenChestButton;
import me.patothebest.gamecore.treasure.ui.OpenChestNoVoteUI;
import me.patothebest.gamecore.treasure.ui.OpenChestVoteUI;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.util.Callback;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.Map;
public interface TreasureFactory {
TreasureChest createChest(IPlayer player, TreasureType treasureType, TreasureChestLocation treasureLocation, Callback<TreasureChestLocation> callback);
TreasureChestLocation createLocation(Location location);
TreasureChestLocation createLocation(Map<String, Object> location);
RewardRandomizer createRewardRandomizer(IPlayer iPlayer, Player player, TreasureType treasureType);
OpenChestVoteUI createMenuWithVote(IPlayer player, TreasureChestLocation treasureLocation);
OpenChestNoVoteUI createMenuWithoutVote(IPlayer player, TreasureChestLocation treasureLocation);
BuyTreasureChestsUI createBuyMenu(IPlayer player, TreasureType treasureType);
OpenChestButton createMenuButton(TreasureType chestType, IPlayer player, TreasureChestLocation location);
}
| 1,548 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureConfigFile.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureConfigFile.java | package me.patothebest.gamecore.treasure;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.file.FlatFile;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.player.IPlayer;
import org.bukkit.configuration.ConfigurationSection;
import java.io.BufferedWriter;
import java.io.IOException;
@Singleton
public class TreasureConfigFile extends FlatFile implements ActivableModule {
private final CorePlugin plugin;
// messages
private String canOpenChests;
private String mustBuyToOpen;
private String notObtainable;
@Inject private TreasureConfigFile(CorePlugin plugin) {
super("treasure-chests-config");
this.plugin = plugin;
this.header = "Chests Config";
load();
}
@Override
public void onPreEnable() {
for (TreasureType treasureType : TreasureType.values()) {
ConfigurationSection treasureConfigSection = getConfigurationSection("types." + treasureType.getConfigPath());
treasureType.setName(treasureConfigSection.getString("name"));
treasureType.setCanBeBought(treasureConfigSection.getBoolean("can-be-bought"));
treasureType.setDescription(treasureConfigSection.getStringList("description"));
treasureType.setPrice(treasureConfigSection.getInt("price"));
treasureType.setEnabled(treasureConfigSection.getBoolean("enabled", true));
}
canOpenChests = getString("messages.can-open-chest");
mustBuyToOpen = getString("messages.must-buy-to-open");
notObtainable = getString("messages.not-obtainable");
}
@Override
public void writeFile(BufferedWriter writer) throws IOException {
super.writeFile(writer);
Utils.writeFileToWriter(writer, plugin.getResource("treasure-chests-config.yml"));
}
public String getMessage(IPlayer player, TreasureType treasureType) {
if(player.getKeys(treasureType) > 0) {
return canOpenChests;
}
return treasureType.canBeBought() ? mustBuyToOpen : notObtainable;
}
}
| 2,288 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureFile.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/TreasureFile.java | package me.patothebest.gamecore.treasure;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.file.FlatFile;
import me.patothebest.gamecore.modules.Module;
@Singleton
public class TreasureFile extends FlatFile implements Module {
@Inject private TreasureFile() {
super("treasure-chests");
this.header = "Chests";
load();
}
}
| 408 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RewardData.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/RewardData.java | package me.patothebest.gamecore.treasure.reward;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
public class RewardData {
private final String name;
private final ItemStack itemStack;
private boolean rareItem;
public RewardData(String name, ItemStack itemStack) {
this.name = ChatColor.translateAlternateColorCodes('&', name);
this.itemStack = itemStack;
}
/**
* Gets the name of the item
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the item representing the reward
*
* @return the item
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* Gets if the reward is a rare item
*
* @return if it is rare
*/
public boolean isRareItem() {
return rareItem;
}
public RewardData rareItem(boolean rare) {
this.rareItem = rare;
return this;
}
}
| 985 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RewardRandomizer.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/RewardRandomizer.java | package me.patothebest.gamecore.treasure.reward;
import com.google.inject.assistedinject.Assisted;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.type.TreasureType;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class RewardRandomizer {
private final IPlayer iPlayer;
private final TreasureType treasureType;
private final RewardFile rewardFile;
@Inject private RewardRandomizer(@Assisted IPlayer iPlayer, @Assisted TreasureType treasureType, RewardFile rewardFile) {
this.iPlayer = iPlayer;
this.treasureType = treasureType;
this.rewardFile = rewardFile;
}
public RewardData giveRandomThing() {
List<Reward> rewards = new ArrayList<>();
double totalChance = 0;
for (Reward reward : rewardFile.getRewards().get(treasureType)) {
if(reward.canGiveReward(iPlayer)) {
for (int i = 0; i < reward.getChance(); i++) {
rewards.add(reward);
totalChance++;
}
}
}
if(rewards.isEmpty()) {
return new RewardData("ERROR: Check log and rewards.yml", new ItemStackBuilder(Material.BARRIER));
}
Collections.shuffle(rewards);
Reward reward = rewards.get(0);
return reward.give(iPlayer).rareItem(reward.getChance()/totalChance < 0.01);
}
}
| 1,580 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RewardProvider.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/RewardProvider.java | package me.patothebest.gamecore.treasure.reward;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import me.patothebest.gamecore.injector.InstanceProvider;
public class RewardProvider implements InstanceProvider<Reward> {
private final Class<? extends Reward> rewardClass;
@Inject private Provider<Injector> injectorProvider;
public RewardProvider(Class<? extends Reward> rewardClass) {
this.rewardClass = rewardClass;
}
/**
* Provides an instance of {@link Reward}. Must never return {@code null}.
*/
@Override
public Reward newInstance() {
return injectorProvider.get().getInstance(rewardClass);
}
}
| 719 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Reward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/Reward.java | package me.patothebest.gamecore.treasure.reward;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.player.IPlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
public abstract class Reward {
private int chance;
protected String hologramMessage;
protected ItemStack displayItem;
/**
* Gives the reward to the player
*
* @param player the player to give the reward
*/
public abstract RewardData give(IPlayer player);
/**
* Parses the reward information from the config
*
* @param configurationSection the configuration section
* @return true if the reward has been parsed successfully
*/
public boolean parse(ConfigurationSection configurationSection) {
if(!configurationSection.isSet("chance")) {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing chance!");
return false;
}
if(configurationSection.isSet("hologram-message")) {
hologramMessage = configurationSection.getString("hologram-message");
} else {
if(hologramMessage == null || hologramMessage.isEmpty()) {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing hologram-message!");
return false;
}
}
if(configurationSection.isSet("display-item")) {
displayItem = Utils.itemStackFromString(configurationSection.getString("display-item"));
} else {
if(displayItem == null) {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing display-item!");
return false;
}
}
chance = configurationSection.getInt("chance");
return true;
}
/**
* Checks to see if the player can get this reward or not
*
* @return true if the player can get the reward
*/
public boolean canGiveReward(IPlayer player) {
return true;
}
/**
* Sets the chance
*/
public void setChance(int chance) {
this.chance = chance;
}
/**
* Gets the chance
*
* @return the chance
*/
public int getChance() {
return chance;
}
}
| 2,339 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RewardFile.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/RewardFile.java | package me.patothebest.gamecore.treasure.reward;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.file.FlatFile;
import me.patothebest.gamecore.injector.InstanceProvider;
import me.patothebest.gamecore.logger.InjectParentLogger;
import me.patothebest.gamecore.logger.Logger;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.modules.ModulePriority;
import me.patothebest.gamecore.modules.ReloadableModule;
import me.patothebest.gamecore.treasure.TreasureManager;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.util.Priority;
import org.bukkit.configuration.ConfigurationSection;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Singleton
@ModulePriority(priority = Priority.HIGHEST)
public class RewardFile extends FlatFile implements ActivableModule, ReloadableModule {
private final CorePlugin plugin;
private final Map<TreasureType, List<Reward>> rewards = new HashMap<>();
private final Map<String, InstanceProvider<Reward>> rewardProviders;
@InjectParentLogger(parent = TreasureManager.class) private Logger logger;
@Inject private RewardFile(CorePlugin plugin, Map<String, InstanceProvider<Reward>> rewardProviders) {
super("rewards");
this.rewardProviders = rewardProviders;
this.header = "Rewards";
this.plugin = plugin;
load();
}
@Override
public void onReload() {
load();
onPostEnable();
}
@Override
public String getReloadName() {
return "rewards";
}
@Override
public void onPostEnable() {
rewards.clear();
for (TreasureType treasureType : TreasureType.values()) {
ConfigurationSection treasureConfigSection = getConfigurationSection(treasureType.name().toLowerCase());
rewards.put(treasureType, new ArrayList<>());
if(treasureConfigSection == null) {
continue;
}
for (String rewardName : treasureConfigSection.getKeys(false)) {
ConfigurationSection rewardConfigSection = treasureConfigSection.getConfigurationSection(rewardName);
InstanceProvider<Reward> rewardProvider = rewardProviders.get(rewardConfigSection.getString("type"));
if(rewardProvider == null) {
System.err.println("Reward " + rewardName + " has unknown reward type!");
continue;
}
Reward reward = rewardProvider.newInstance();
if(!reward.parse(rewardConfigSection)) {
logger.severe("Could not parse reward {0}!", rewardName);
continue;
}
List<Reward> rewardList = rewards.get(treasureType);
rewardList.add(reward);
}
}
}
/**
* Gets rewards
*
* @return value of rewards
*/
public Map<TreasureType, List<Reward>> getRewards() {
return rewards;
}
@Override
protected void writeFile(BufferedWriter writer) throws IOException {
super.writeFile(writer);
Utils.writeFileToWriter(writer, plugin.getResource("rewards.yml"));
}
}
| 3,472 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ShopReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/ShopReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import com.google.inject.Inject;
import me.patothebest.gamecore.cosmetics.shop.ShopItem;
import me.patothebest.gamecore.cosmetics.shop.ShopManager;
import me.patothebest.gamecore.cosmetics.shop.ShopRegistry;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.logger.InjectParentLogger;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.treasure.TreasureManager;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ShopReward extends Reward {
private int minAmount = 1;
private int maxAmount = 1;
private final List<ShopItem> shopItems = new ArrayList<>();
private final ShopRegistry shopRegistry;
private final PlayerManager playerManager;
@InjectParentLogger(parent = TreasureManager.class) private Logger logger;
@Inject private ShopReward(ShopRegistry shopRegistry, PlayerManager playerManager) {
this.shopRegistry = shopRegistry;
this.playerManager = playerManager;
hologramMessage = "%amount%%shop-name% %item%";
displayItem = new ItemStackBuilder(Material.BARRIER);
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsedSuper = super.parse(configurationSection);
boolean parsed = false;
if(configurationSection.isSet("shop-type")) {
String shopType = configurationSection.getString("shop-type");
ShopManager<?> shopManager = shopRegistry.getShopManagersNamesMap().get(shopType);
if(shopManager != null) {
if (configurationSection.isSet("shop-item")) {
ShopItem shopItem = shopManager.getShopItemsMap().get(configurationSection.getString("shop-item"));
if(shopItem != null) {
shopItems.add(shopItem);
parsed = true;
} else {
logger.log(Level.SEVERE, "Shop item {0} is not found in reward {1}", new Object[]{ configurationSection.getString("shop-item"), configurationSection.getCurrentPath() });
}
}
if (configurationSection.isSet("shop-items")) {
for (String shopItemName : configurationSection.getStringList("shop-items")) {
ShopItem shopItem = shopManager.getShopItemsMap().get(shopItemName);
if(shopItem != null) {
shopItems.add(shopItem);
parsed = true;
} else {
logger.log(Level.SEVERE, "Shop item {0} is not found in reward {1}", new Object[]{ configurationSection.getString("shop-item"), configurationSection.getCurrentPath() });
}
}
}
} else {
parsed = false;
logger.log(Level.SEVERE, "Reward {0} shop-type is invalid! Unknown shop-type {1}", new Object[]{ configurationSection.getCurrentPath(), shopType });
}
} else {
parsed = false;
logger.log(Level.SEVERE, "Reward {0} is missing shop-type!", new Object[]{ configurationSection.getCurrentPath() });
}
if (configurationSection.isSet("min-amount")) {
minAmount = configurationSection.getInt("min-amount");
} else {
parsed = false;
logger.log(Level.SEVERE, "Reward {0} is missing min-amount!", new Object[]{ configurationSection.getCurrentPath() });
}
if (configurationSection.isSet("max-amount")) {
maxAmount = configurationSection.getInt("max-amount");
} else {
parsed = false;
logger.log(Level.SEVERE, "Reward {0} is missing max-amount!", new Object[]{ configurationSection.getCurrentPath() });
}
return parsed && parsedSuper;
}
@Override
public boolean canGiveReward(IPlayer player) {
List<ShopItem> shopItemsForPlayer = new ArrayList<>(shopItems);
shopItemsForPlayer.removeIf(shopItem -> shopItem.isPermanent() && player.canUse(shopItem));
return !shopItemsForPlayer.isEmpty();
}
@Override
public RewardData give(IPlayer player) {
List<ShopItem> shopItemsForPlayer = new ArrayList<>(shopItems);
shopItemsForPlayer.removeIf(shopItem -> shopItem.isPermanent() && player.canUse(shopItem));
ShopItem shopItem = Utils.getRandomElementFromList(shopItemsForPlayer);
if(shopItem == null) {
logger.log(Level.WARNING, "Shop Item is null in reward ShopReward for player!", player.getName());
return new RewardData("Error", new ItemStackBuilder(Material.BARRIER));
}
int amount = -1;
if(!shopItem.isPermanent()) {
amount = Utils.randInt(minAmount, maxAmount);
player.buyItemUses(shopItem, amount);
} else {
player.buyItemPermanently(shopItem);
}
return new RewardData(hologramMessage
.replace("%item%", shopItem.getDisplayName())
.replace("%amount%", amount == -1 ? "" : amount + " ")
.replace("%shop-name%", shopRegistry.getShopItemsManagers().get(shopItem.getClass()).getName().getMessage(player)), shopItem.getDisplayItem());
}
} | 5,796 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PermissionReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/PermissionReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.configuration.ConfigurationSection;
import javax.inject.Inject;
import javax.inject.Provider;
import java.util.ArrayList;
import java.util.List;
public class PermissionReward extends Reward {
private final List<String> permissions = new ArrayList<>();
private final Provider<Permission> permissionProvider;
@Inject private PermissionReward(Provider<Permission> permissionProvider) {
this.permissionProvider = permissionProvider;
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsedSuper = super.parse(configurationSection);
boolean parsed = false;
if(configurationSection.isSet("permission")) {
permissions.add(configurationSection.getString("permission"));
parsed = true;
}
if(configurationSection.isSet("permissions")) {
permissions.addAll(configurationSection.getStringList("permissions"));
parsed = true;
}
if(!parsed) {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing either a permission or a permission list!");
}
return parsed && parsedSuper;
}
@Override
public RewardData give(IPlayer player) {
if(permissionProvider.get() == null) {
System.err.println("No compatible permission plugin has been found!");
return new RewardData("Error", new ItemStackBuilder(Material.BARRIER));
}
for (String permission : permissions) {
permissionProvider.get().playerAdd(player.getPlayer(), permission);
}
return new RewardData(hologramMessage, displayItem);
}
} | 2,093 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
MoneyReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/MoneyReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import org.bukkit.configuration.ConfigurationSection;
import javax.inject.Inject;
public class MoneyReward extends Reward {
private int minAmount = 1;
private int maxAmount = 1;
@Inject private MoneyReward() {
hologramMessage = "+%amount% Coins";
displayItem = new ItemStackBuilder(Material.SUNFLOWER);
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsedSuper = super.parse(configurationSection);
boolean parsed = true;
if (configurationSection.isSet("min-amount")) {
minAmount = configurationSection.getInt("min-amount");
} else {
parsed = false;
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing min-amount!");
}
if (configurationSection.isSet("max-amount")) {
maxAmount = configurationSection.getInt("max-amount");
} else {
parsed = false;
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing max-amount!");
}
return parsed && parsedSuper;
}
@Override
public RewardData give(IPlayer player) {
int amount = Utils.randInt(minAmount, maxAmount);
if (player.giveMoney(amount)) {
System.err.println("No compatible economy plugin has been found!");
return new RewardData("Error", new ItemStackBuilder(Material.BARRIER));
}
return new RewardData(hologramMessage.replace("%amount%", amount + ""), displayItem);
}
/**
* Sets the minimum amount of items the player should get
*/
public void setMinAmount(int minAmount) {
this.minAmount = minAmount;
}
/**
* Sets the maximum amount of items the player should get
*/
public void setMaxAmount(int maxAmount) {
this.maxAmount = maxAmount;
}
}
| 2,288 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
KitReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/KitReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import com.google.inject.Inject;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.kit.Kit;
import me.patothebest.gamecore.kit.KitManager;
import me.patothebest.gamecore.logger.InjectParentLogger;
import me.patothebest.gamecore.logger.Logger;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.treasure.TreasureManager;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.List;
public class KitReward extends Reward {
private int minAmount = 1;
private int maxAmount = 1;
private final List<Kit> kits = new ArrayList<>();
private final KitManager kitManager;
private final PlayerManager playerManager;
@InjectParentLogger(parent = TreasureManager.class) private Logger logger;
@Inject private KitReward(KitManager kitManager, PlayerManager playerManager) {
this.kitManager = kitManager;
this.playerManager = playerManager;
hologramMessage = "%amount%Kit %kit%";
displayItem = new ItemStackBuilder(Material.BARRIER);
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsedSuper = super.parse(configurationSection);
boolean parsed = false;
if (configurationSection.isSet("kit")) {
Kit kit = kitManager.getKits().get(configurationSection.getString("kit"));
if(kit != null) {
kits.add(kit);
parsed = true;
} else {
logger.severe("Reward {0} tried to register kit {1} that doesn't exist.", configurationSection.getString("kit"), configurationSection.getCurrentPath());
}
}
if (configurationSection.isSet("kits")) {
for (String kitName : configurationSection.getStringList("kits")) {
Kit kit = kitManager.getKits().get(kitName);
if(kit != null) {
kits.add(kit);
parsed = true;
} else {
logger.severe("Reward {0} tried to register kit {1} that doesn't exist.", kitName, configurationSection.getCurrentPath());
}
}
}
if (configurationSection.isSet("min-amount")) {
minAmount = configurationSection.getInt("min-amount");
} else {
parsed = false;
logger.severe("Reward {0} is missing min-amount!", configurationSection.getCurrentPath());
}
if (configurationSection.isSet("max-amount")) {
maxAmount = configurationSection.getInt("max-amount");
} else {
parsed = false;
logger.severe("Reward {0} is missing max-amount!", configurationSection.getCurrentPath());
}
return parsed && parsedSuper;
}
@Override
public boolean canGiveReward(IPlayer player) {
List<Kit> kitsForPlayer = new ArrayList<>(kits);
kitsForPlayer.removeIf(kit -> !kit.isOneTimeKit() && player.canUseKit(kit));
return !kitsForPlayer.isEmpty();
}
@Override
public RewardData give(IPlayer player) {
List<Kit> kitsForPlayer = new ArrayList<>(kits);
kitsForPlayer.removeIf(kit -> !kit.isOneTimeKit() && player.canUseKit(kit));
Kit kit = Utils.getRandomElementFromList(kitsForPlayer);
if(kit == null) {
System.err.println("Kit is null in reward KitReward for player " + player.getName());
return new RewardData("Error", new ItemStackBuilder(Material.BARRIER));
}
int amount = -1;
if(kit.isOneTimeKit()) {
amount = Utils.randInt(minAmount, maxAmount);
player.addKitUses(kit, amount);
} else {
player.buyPermanentKit(kit);
}
return new RewardData(hologramMessage.replace("%kit%", kit.getKitName()).replace("%amount%", amount == -1 ? "" : amount + " "), kit.getDisplayItem());
}
} | 4,299 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CommandReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/CommandReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.List;
public class CommandReward extends Reward {
private final List<String> commands = new ArrayList<>();
public CommandReward() {
displayItem = new ItemStackBuilder(Material.COMMAND_BLOCK);
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsedSuper = super.parse(configurationSection);
boolean parsed = false;
if (configurationSection.isSet("command")) {
commands.add(configurationSection.getString("command"));
parsed = true;
}
if (configurationSection.isSet("commands")) {
commands.addAll(configurationSection.getStringList("commands"));
parsed = true;
}
if (!parsed) {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing either a command or a command list!");
}
return parsed && parsedSuper;
}
@Override
public RewardData give(IPlayer player) {
for (String command : commands) {
String parsed = command.replace("%player%", player.getName());
if (command.startsWith("{msg}")) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', parsed));
} else {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parsed);
}
}
return new RewardData(hologramMessage, displayItem);
}
} | 1,929 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ItemReward.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/reward/rewards/ItemReward.java | package me.patothebest.gamecore.treasure.reward.rewards;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.reward.Reward;
import me.patothebest.gamecore.treasure.reward.RewardData;
import org.bukkit.configuration.ConfigurationSection;
public class ItemReward extends Reward {
private Material material;
private int minAmount = 1;
private int maxAmount = 1;
public ItemReward() {
hologramMessage = "%amount% %material%";
}
@Override
public boolean parse(ConfigurationSection configurationSection) {
boolean parsed = true;
if(configurationSection.isSet("material")) {
material = Material.matchMaterial(configurationSection.getString("material").toUpperCase()).orElse(Material.DIRT);
displayItem = new ItemStackBuilder(material);
} else {
System.err.println("Reward " + configurationSection.getCurrentPath() + " is missing material!");
parsed = false;
}
if (configurationSection.isSet("min-amount")) {
minAmount = configurationSection.getInt("min-amount");
}
if (configurationSection.isSet("max-amount")) {
maxAmount = configurationSection.getInt("max-amount");
}
return parsed && super.parse(configurationSection);
}
@Override
public RewardData give(IPlayer player) {
int amount = Utils.randInt(minAmount, maxAmount);
player.getPlayer().getInventory().addItem(new ItemStackBuilder(material).amount(amount));
return new RewardData(hologramMessage.replace("%amount%", amount + "").replace("%material%", Utils.capitalizeFirstLetter(material.name())), displayItem);
}
}
| 1,885 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureMySQLEntity.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/entities/TreasureMySQLEntity.java | package me.patothebest.gamecore.treasure.entities;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.player.modifiers.PlayerModifier;
import me.patothebest.gamecore.player.modifiers.TreasureModifier;
import me.patothebest.gamecore.storage.mysql.MySQLEntity;
import me.patothebest.gamecore.treasure.type.TreasureType;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class TreasureMySQLEntity implements MySQLEntity {
/**
* Loads a player's treasure keys
* <p>
* A record is inserted if the record doesn't
* exist.
*
* @param player the player loaded
* @param connection the database connection
*/
@Override
public void loadPlayer(CorePlayer player, Connection connection) throws SQLException {
PreparedStatement selectUser = connection.prepareStatement(Queries.SELECT);
selectUser.setInt(1, player.getPlayerId());
ResultSet resultSet = selectUser.executeQuery();
if (!resultSet.next()) {
PreparedStatement createUser = connection.prepareStatement(Queries.INSERT_RECORD);
createUser.setInt(1, player.getPlayerId());
createUser.executeUpdate();
for (TreasureType treasureType : TreasureType.values()) {
player.setKeys(treasureType, 0);
}
} else for (TreasureType treasureType : TreasureType.values()) {
player.setKeys(treasureType, resultSet.getInt(treasureType.name().toLowerCase()));
}
resultSet.close();
selectUser.close();
}
/**
* Updates a player's treasure keys in the database
*
* @param player the player to save
* @param connection the database connection
*/
@Override
public void savePlayer(CorePlayer player, Connection connection) throws SQLException {
PreparedStatement updateUser = connection.prepareStatement(Queries.UPDATE);
for (int i = 0; i < TreasureType.values().length; i++) {
updateUser.setInt(i + 1, player.getKeys(TreasureType.values()[i]));
}
updateUser.setInt(6, player.getPlayerId());
updateUser.executeUpdate();
updateUser.close();
}
@Override
public void updatePlayer(CorePlayer player, Connection connection, PlayerModifier updatedType, Object... args) throws SQLException {
if(updatedType != TreasureModifier.MODIFY) {
return;
}
savePlayer(player, connection);
}
/**
* Gets all the statements needed to create the
* table(s) for the specific entity.
*
* @return the create table statements
*/
@Override
public String[] getCreateTableStatements() {
return new String[]{Queries.CREATE_TABLE};
}
} | 2,860 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Queries.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/entities/Queries.java | package me.patothebest.gamecore.treasure.entities;
import me.patothebest.gamecore.PluginConfig;
class Queries {
private static final String TABLE_NAME = PluginConfig.SQL_PREFIX + "_treasure_chests";
static final String CREATE_TABLE =
"CREATE TABLE IF NOT EXISTS `" + TABLE_NAME + "` (\n" +
" `player_id` int(11) NOT NULL,\n" +
" `normal` int(11) NOT NULL,\n" +
" `rare` int(11) NOT NULL,\n" +
" `epic` int(11) NOT NULL,\n" +
" `legendary` int(11) NOT NULL,\n" +
" `vote` int(11) NOT NULL,\n" +
" PRIMARY KEY (`player_id`),\n" +
" UNIQUE KEY `player_id` (`player_id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=latin1;\n";
final static String INSERT_RECORD = "INSERT INTO " + TABLE_NAME + " VALUES (?, '0', '0', '0', '0', '0')";
final static String SELECT = "SELECT * FROM " + TABLE_NAME + " WHERE player_id=?";
final static String DELETE = "DELETE FROM " + TABLE_NAME + " WHERE player_id=?";
final static String UPDATE = "UPDATE " + TABLE_NAME + " SET normal=?, rare=?, epic=?, legendary=?, vote=? WHERE player_id=?;";
}
| 1,246 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureFlatFileEntity.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/entities/TreasureFlatFileEntity.java | package me.patothebest.gamecore.treasure.entities;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.storage.StorageException;
import me.patothebest.gamecore.storage.flatfile.FlatFileEntity;
import me.patothebest.gamecore.storage.flatfile.PlayerProfileFile;
import me.patothebest.gamecore.treasure.type.TreasureType;
public class TreasureFlatFileEntity implements FlatFileEntity {
/**
* Loads a player's treasure keys
*
* @param player the player loaded
* @param file the player's profile file
*/
@Override
public void loadPlayer(CorePlayer player, PlayerProfileFile file) throws StorageException {
for (TreasureType treasureType : TreasureType.values()) {
player.setKeys(treasureType, file.getInt("keys." + treasureType.name().toLowerCase(), 0));
}
}
/**
* Saves a player's treasure keys
*
* @param player the player being saved
* @param file the player's profile file
*/
@Override
public void savePlayer(CorePlayer player, PlayerProfileFile file) throws StorageException {
for (TreasureType treasureType : TreasureType.values()) {
file.set("keys." + treasureType.name().toLowerCase(), player.getTreasureKeyMap().containsKey(treasureType) ? player.getKeys(treasureType) : 0);
}
}
}
| 1,360 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
OpenChestNoVoteUI.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/ui/OpenChestNoVoteUI.java | package me.patothebest.gamecore.treasure.ui;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.StainedGlassPane;
import me.patothebest.gamecore.treasure.chest.TreasureChestLocation;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.gui.inventory.GUIPage;
import me.patothebest.gamecore.gui.inventory.button.PlaceHolder;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.TreasureFactory;
import org.bukkit.ChatColor;
public class OpenChestNoVoteUI extends GUIPage {
private final TreasureChestLocation location;
private final TreasureFactory treasureFactory;
private final IPlayer player;
@Inject private OpenChestNoVoteUI(CorePlugin plugin, @Assisted IPlayer player, @Assisted TreasureChestLocation location, TreasureFactory treasureFactory) {
super(plugin, player.getPlayer(), ChatColor.GOLD + "Abrir un cofre", 27);
this.location = location;
this.player = player;
this.treasureFactory = treasureFactory;
build();
}
public void buildPage() {
int slot = 10;
for(TreasureType type : TreasureType.values()) {
if(type == TreasureType.VOTE) {
continue;
}
addButton(treasureFactory.createMenuButton(type, player, location), slot);
slot++;
if(slot == 17) {
continue;
}
addButton(new PlaceHolder(new ItemStackBuilder(StainedGlassPane.BLACK).name("")), slot);
slot++;
}
for (int i = 0; i < 27; i++) {
if(isFree(i)) {
addButton(new PlaceHolder(new ItemStackBuilder(StainedGlassPane.WHITE).name("")), i);
}
}
}
} | 1,940 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
OpenChestButton.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/ui/OpenChestButton.java | package me.patothebest.gamecore.treasure.ui;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.treasure.chest.TreasureChestLocation;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.gui.inventory.GUIButton;
import me.patothebest.gamecore.gui.inventory.GUIPage;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.TreasureConfigFile;
import me.patothebest.gamecore.treasure.TreasureFactory;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public class OpenChestButton implements GUIButton {
private final TreasureType chestType;
private final IPlayer player;
private final TreasureChestLocation location;
private final TreasureConfigFile treasureConfigFile;
private final TreasureFactory treasureFactory;
@Inject private OpenChestButton(@Assisted TreasureType chestType, @Assisted IPlayer player, @Assisted TreasureChestLocation location, TreasureConfigFile treasureConfigFile, TreasureFactory treasureFactory) {
this.chestType = chestType;
this.player = player;
this.location = location;
this.treasureConfigFile = treasureConfigFile;
this.treasureFactory = treasureFactory;
}
public ItemStack getItem() {
ItemStackBuilder item = new ItemStackBuilder()
.customSkull(chestType.getUrl())
.name(ChatColor.GREEN + chestType.getName());
for (String s : chestType.getDescription()) {
if(s == null || s.isEmpty()) {
item.blankLine();
} else {
item.addLore(s.replace("%owned%", player.getKeys(chestType) + "").replace("%open_message%", treasureConfigFile.getMessage(player, chestType)));
}
}
return item;
}
public void click(ClickType clickType, GUIPage page) {
if (player.getKeys(chestType) <= 0) {
if(chestType.canBeBought()) {
treasureFactory.createBuyMenu(player, chestType);
}
return;
}
if (!location.openChest(player, chestType)) {
return;
}
player.setKeys(chestType, player.getKeys(chestType) - 1);
player.sendMessage("Abriendo un " + ChatColor.GOLD + "Cofre " + chestType.getName());
player.getPlayer().closeInventory();
}
@Override
public void destroy() {
}
} | 2,583 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
OpenChestVoteUI.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/ui/OpenChestVoteUI.java | package me.patothebest.gamecore.treasure.ui;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.StainedGlassPane;
import me.patothebest.gamecore.treasure.chest.TreasureChestLocation;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.gui.inventory.GUIPage;
import me.patothebest.gamecore.gui.inventory.button.PlaceHolder;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.TreasureFactory;
import org.bukkit.ChatColor;
public class OpenChestVoteUI extends GUIPage {
private final TreasureChestLocation location;
private final TreasureFactory treasureFactory;
private final IPlayer player;
@Inject private OpenChestVoteUI(CorePlugin plugin, @Assisted IPlayer player, @Assisted TreasureChestLocation location, TreasureFactory treasureFactory) {
super(plugin, player.getPlayer(), ChatColor.GOLD + "Abrir un cofre", 45);
this.location = location;
this.player = player;
this.treasureFactory = treasureFactory;
build();
}
public void buildPage() {
for(int i = 10; i <= 16; i++) {
if(i == 13) {
continue;
}
addButton(new PlaceHolder(new ItemStackBuilder(StainedGlassPane.BLACK).name("")), i);
}
int slot = 28;
for(TreasureType type : TreasureType.values()) {
if(type == TreasureType.VOTE) {
addButton(treasureFactory.createMenuButton(type, player, location), 13);
continue;
}
addButton(treasureFactory.createMenuButton(type, player, location), slot);
slot++;
if(slot == 35) {
continue;
}
addButton(new PlaceHolder(new ItemStackBuilder(StainedGlassPane.BLACK).name("")), slot);
slot++;
}
for (int i = 0; i < 45; i++) {
if(isFree(i)) {
addButton(new PlaceHolder(new ItemStackBuilder(StainedGlassPane.WHITE).name("")), i);
}
}
}
} | 2,241 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
BuyTreasureChestsUI.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/ui/BuyTreasureChestsUI.java | package me.patothebest.gamecore.treasure.ui;
import com.google.inject.assistedinject.Assisted;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.gui.inventory.button.SimpleButton;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.itemstack.StainedGlassPane;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.gui.inventory.GUIPage;
import me.patothebest.gamecore.gui.inventory.button.IncrementingButton;
import me.patothebest.gamecore.gui.inventory.button.IncrementingButtonAction;
import me.patothebest.gamecore.gui.inventory.button.PlaceHolder;
import me.patothebest.gamecore.guis.UserGUIFactory;
import me.patothebest.gamecore.player.IPlayer;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.ChatColor;
import javax.inject.Inject;
import javax.inject.Provider;
public class BuyTreasureChestsUI extends GUIPage {
private final IPlayer iPlayer;
private final Provider<Economy> economy;
private final UserGUIFactory userGUIFactory;
private final TreasureType treasureType;
private int treasureChestAmount = 1;
private final static int[] GRAY_STAINED_PANES = new int[]{3, 5, 28, 29, 30, 32, 33, 34, 37, 39, 41, 43, 46, 47, 48, 50, 51, 52};
@Inject private BuyTreasureChestsUI(CorePlugin plugin, Provider<Economy> economy, UserGUIFactory userGUIFactory, @Assisted IPlayer iPlayer, @Assisted TreasureType treasureType) {
super(plugin, iPlayer.getPlayer(), CoreLang.GUI_TREASURE_CHEST_TITLE.getMessage(iPlayer), 54);
this.iPlayer = iPlayer;
this.economy = economy;
this.userGUIFactory = userGUIFactory;
this.treasureType = treasureType;
build();
}
@Override
public void buildPage() {
if (economy.get() == null) {
CoreLang.GUI_BUY_TREASURE_CHEST_ECONOMY_PLUGIN_ERROR.sendMessage(iPlayer);
getPlayer().closeInventory();
return;
}
IncrementingButtonAction onUpdateItemSize = (amount) -> {
if (treasureChestAmount + amount <= 0) {
treasureChestAmount = 1;
} else {
treasureChestAmount += amount;
}
refresh();
};
addButton(new IncrementingButton(-10, onUpdateItemSize), 19);
addButton(new IncrementingButton(-5, onUpdateItemSize), 20);
addButton(new IncrementingButton(-1, onUpdateItemSize), 21);
addButton(new IncrementingButton(1, onUpdateItemSize), 23);
addButton(new IncrementingButton(5, onUpdateItemSize), 24);
addButton(new IncrementingButton(10, onUpdateItemSize), 25);
addButton(new SimpleButton(new ItemStackBuilder(Material.EMERALD).name(ChatColor.GREEN + (economy.get() != null ? economy.get().currencyNamePlural() : "")).lore(ChatColor.GRAY.toString() + (treasureType.getPrice() * treasureChestAmount) + (economy.get() != null ? " " + economy.get().currencyNamePlural() : "") + " will be deducted from your account")), 4);
addButton(new PlaceHolder(new ItemStackBuilder().customSkull(treasureType.getUrl()).name(ChatColor.GREEN + treasureType.getName()).amount(treasureChestAmount)), 22);
addButton(new SimpleButton(new ItemStackBuilder().createCancelItem()).action(() -> userGUIFactory.openKitShop(player)), 38);
if (iPlayer.getMoney() >= treasureType.getPrice() * treasureChestAmount) {
addButton(new SimpleButton(new ItemStackBuilder().createConfirmItem()).action(() -> {
EconomyResponse economyResponse = economy.get().withdrawPlayer(player, treasureType.getPrice() * treasureChestAmount);
if (!economyResponse.transactionSuccess()) {
player.sendMessage(CoreLang.GUI_BUY_TREASURE_CHEST_ERROR_OCCURRED.getMessage(player));
player.sendMessage(ChatColor.RED + "ERROR: " + economyResponse.errorMessage);
return;
}
iPlayer.setKeys(treasureType, iPlayer.getKeys(treasureType) + treasureChestAmount);
player.sendMessage(CoreLang.GUI_BUY_TREASURE_CHEST_YOU_PURCHASED.replace(player, treasureChestAmount, treasureType.getName()));
player.closeInventory();
}), 42);
} else {
addPlaceholder(new ItemStackBuilder().material(Material.BARRIER).name(iPlayer, CoreLang.GUI_BUY_TREASURE_CHEST_NOT_ENOUGH_MONEY), 42);
}
for (int grayStainedPane : GRAY_STAINED_PANES) {
addPlaceholder(new ItemStackBuilder(StainedGlassPane.GRAY).name(""), grayStainedPane);
}
for (int i = 0; i < 54; i++) {
if (isFree(i)) {
addPlaceholder(new ItemStackBuilder(StainedGlassPane.WHITE).name(""), i);
}
}
}
}
| 4,968 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Rarity.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/type/Rarity.java | package me.patothebest.gamecore.treasure.type;
public enum Rarity {
COMMON,
RARE,
EPIC,
LEGENDARY
} | 118 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureType.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/type/TreasureType.java | package me.patothebest.gamecore.treasure.type;
import java.util.List;
public enum TreasureType {
NORMAL("normal", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBiMDY4NzA5NzkwZDQxYjg5MjdiODQyMmQyMWJiNTI0MDRiNTViNGNhMzUyY2RiN2M2OGU0YjM2NTkyNzIxIn19fQ=="),
RARE("rare", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDhjMWUxYzYyZGM2OTVlYjkwZmExOTJkYTZhY2E0OWFiNGY5ZGZmYjZhZGI1ZDI2MjllYmZjOWIyNzg4ZmEyIn19fQ=="),
EPIC("epic", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzhmODhiMTYxNzYzZjYyZTRjNTFmNWViMWQzOGZhZjNiODJjNDhhODM5YWMzMTcxMjI5NTU3YWRlNDI3NDM0In19fQ=="),
LEGENDARY("legendary", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGNjNzk5NTRkMzUwYTk4YzcyMTcyNTY4MzFmNjVjNjJhNDI4MDc0YjZlNGFlOWVlZGU3YTQ0ZjlkZTRhNyJ9fX0="),
VOTE("vote", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDVjNmRjMmJiZjUxYzM2Y2ZjNzcxNDU4NWE2YTU2ODNlZjJiMTRkNDdkOGZmNzE0NjU0YTg5M2Y1ZGE2MjIifX19");
private final String configPath;
private final String url;
private String name;
private List<String> description;
private int price;
private boolean enabled;
private boolean canBeBought;
TreasureType(String configPath, String url) {
this.configPath = configPath;
this.url = url;
}
/**
* Gets name
*
* @return rhe name
*/
public String getName() {
return name;
}
/**
* Gets price
*
* @return the price
*/
public int getPrice() {
return price;
}
/**
* Gets the skin url
*
* @return the skin url
*/
public String getUrl() {
return url;
}
/**
* Gets the config path
*
* @return the config path
*/
public String getConfigPath() {
return configPath;
}
/**
* Sets the name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the description
*
* @return the description
*/
public List<String> getDescription() {
return description;
}
/**
* Sets the description
*/
public void setDescription(List<String> description) {
this.description = description;
}
/**
* Sets the price
*/
public void setPrice(int price) {
this.price = price;
}
/**
* Gets the enabled
*
* @return the enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* Sets the enabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* Gets if the chest can be bought or not
*
* @return if can be bought
*/
public boolean canBeBought() {
return canBeBought;
}
/**
* Sets if the chest can be bought
*/
public void setCanBeBought(boolean canBeBought) {
this.canBeBought = canBeBought;
}
} | 3,101 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChestStructure.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChestStructure.java | package me.patothebest.gamecore.treasure.chest;
import me.patothebest.gamecore.treasure.type.TreasureType;
import java.util.HashMap;
import java.util.Map;
public class TreasureChestStructure {
public final static char[][][][] STRUCTURE;
public final static Map<TreasureType, Map<TreasureChestStructurePiece, TreasureChestPiece>> PIECES = new HashMap<>();
private TreasureChestStructure() {}
static {
char[][][] structure1;
structure1 = new char[10][][];
structure1[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure1[1] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure1[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure1[3] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'g', 'a', 'a', 'a'}};
structure1[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure1[5] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure1[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
char[][][] structure2;
structure2 = new char[10][][];
structure2[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure2[1] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure2[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'i', 'i', 'i', 'a', 'a'}};
structure2[3] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'i', 'a', 'i', 'a', 'a'}};
structure2[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'i', 'i', 'i', 'a', 'a'}};
structure2[5] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure2[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
char[][][] structure3;
structure3 = new char[10][][];
structure3[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure3[1] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'o', 'o', 'a', 'o', 'o', 'a'}};
structure3[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'o', 'a', 'a', 'a', 'o', 'a'}};
structure3[3] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure3[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'o', 'a', 'a', 'a', 'o', 'a'}};
structure3[5] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'o', 'o', 'a', 'o', 'o', 'a'}};
structure3[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
char[][][] structure4;
structure4 = new char[10][][];
structure4[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure4[1] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'c', 'a', 'a', 'a'}};
structure4[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure4[3] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'c', 'a', 'a', 'a', 'c', 'a'}};
structure4[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure4[5] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'c', 'a', 'a', 'a'}};
structure4[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
char[][][] structure5;
structure5 = new char[10][][];
structure5[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[1] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'w', 'w', 'a', 'w', 'w', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'w', 'a', 'a', 'a', 'w', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[3] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'w', 'a', 'a', 'a', 'w', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[5] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'w', 'w', 'a', 'w', 'w', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure5[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
char[][][] structure6;
structure6 = new char[10][][];
structure6[0] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'u', 'a', 'a', 'a'}, {'a', 'a', 'a', 'p', 'a', 'a', 'a'}, {'a', 'a', 'a', 'p', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[1] = new char[][]{{'a', 'a', 'a', 't', 'a', 'a', 'a'}, {'a', 'a', 'a', 'd', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[2] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[3] = new char[][]{{'a', 't', 'a', 'a', 'a', 't', 'a'}, {'u', 'd', 'a', 'a', 'a', 'd', 'u'}, {'p', 'a', 'a', 'a', 'a', 'a', 'p'}, {'p', 'a', 'a', 'a', 'a', 'a', 'p'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[4] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[5] = new char[][]{{'a', 'a', 'a', 't', 'a', 'a', 'a'}, {'a', 'a', 'a', 'd', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
structure6[6] = new char[][]{{'a', 'a', 'a', 'a', 'a', 'a', 'a'}, {'a', 'a', 'a', 'u', 'a', 'a', 'a'}, {'a', 'a', 'a', 'p', 'a', 'a', 'a'}, {'a', 'a', 'a', 'p', 'a', 'a', 'a'}, {'a', 'a', 'a', 'a', 'a', 'a', 'a'}};
STRUCTURE = new char[][][][]{structure1, structure2, structure3, structure4, structure5, structure6};
}
}
| 10,332 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChestStructureFile.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChestStructureFile.java | package me.patothebest.gamecore.treasure.chest;
import com.google.inject.Inject;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.file.FlatFile;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.modules.ReloadableModule;
import me.patothebest.gamecore.treasure.type.TreasureType;
import org.bukkit.configuration.ConfigurationSection;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class TreasureChestStructureFile extends FlatFile implements ActivableModule, ReloadableModule {
private final CorePlugin plugin;
@Inject private TreasureChestStructureFile(CorePlugin plugin) {
super("treasure-chest-structure");
this.plugin = plugin;
load();
}
@Override
protected void writeFile(BufferedWriter writer) throws IOException {
super.writeFile(writer);
Utils.writeFileToWriter(writer, plugin.getResource("treasure-chest-structure.yml"));
}
@Override
public void onEnable() {
TreasureChestStructure.PIECES.clear();
for (TreasureType treasureType : TreasureType.values()) {
ConfigurationSection treasureConfigSection = getConfigurationSection(treasureType.name().toLowerCase());
Map<TreasureChestStructurePiece, TreasureChestPiece> treasureChestStructurePieceTreasureChestPieceMap = new HashMap<>();
for (TreasureChestStructurePiece treasureChestStructurePiece : TreasureChestStructurePiece.values()) {
String material = treasureConfigSection.getString(treasureChestStructurePiece.getConfigPath());
try {
if(material.contains(":")) {
String[] split = material.split(":");
treasureChestStructurePieceTreasureChestPieceMap.put(treasureChestStructurePiece, new TreasureChestPiece(Material.matchMaterial(split[0]), Byte.valueOf(split[1])));
} else {
treasureChestStructurePieceTreasureChestPieceMap.put(treasureChestStructurePiece, new TreasureChestPiece(Material.matchMaterial(material)));
}
} catch (Exception e) {
Utils.printError("Could not parse item " + treasureConfigSection.getCurrentPath() + "." + treasureChestStructurePiece.getConfigPath(), e);
}
}
TreasureChestStructure.PIECES.put(treasureType, treasureChestStructurePieceTreasureChestPieceMap);
}
}
@Override
public void onReload() {
load();
onEnable();
}
@Override
public String getReloadName() {
return "treasure-structure";
}
}
| 2,843 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChestLocation.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChestLocation.java | package me.patothebest.gamecore.treasure.chest;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import me.patothebest.gamecore.itemstack.Material;
import me.patothebest.gamecore.hologram.Hologram;
import me.patothebest.gamecore.nms.NMS;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.title.Title;
import me.patothebest.gamecore.title.TitleManager;
import me.patothebest.gamecore.treasure.TreasureFactory;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.util.SerializableObject;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Chest;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.util.Map;
public class TreasureChestLocation implements SerializableObject {
private final Provider<NMS> nmsProvider;
private final Location location;
private final Chest chest;
private final TreasureFactory treasureFactory;
private Hologram hologram;
private TreasureChest currentTreasureChest;
@AssistedInject private TreasureChestLocation(Provider<NMS> nmsProvider, TreasureFactory treasureFactory, @Assisted Location location) {
this.nmsProvider = nmsProvider;
this.location = location;
this.location.getBlock().setType(Material.CHEST.parseMaterial());
this.treasureFactory = treasureFactory;
chest = (Chest) location.getBlock().getState();
createHologram();
}
@SuppressWarnings("unchecked")
@AssistedInject private TreasureChestLocation(Provider<NMS> nmsProvider, TreasureFactory treasureFactory, @Assisted Map<String, Object> data) {
this.nmsProvider = nmsProvider;
this.location = Location.deserialize((Map<String, Object>) data.get("location"));
this.location.getBlock().setType(Material.CHEST.parseMaterial());
this.treasureFactory = treasureFactory;
chest = (Chest) location.getBlock().getState();
createHologram();
}
public boolean openChest(IPlayer player, TreasureType treasureType) {
if(currentTreasureChest != null) {
return false;
}
currentTreasureChest = treasureFactory.createChest(player, treasureType, this, (location) -> location.currentTreasureChest = null);
currentTreasureChest.playAnimation(location.clone().add(-3, 3, -3));
player.getPlayer().teleport(location.clone().add(0.5, 1, 0.5));
Title title = TitleManager.newInstance(ChatColor.GREEN + "Cofre " + treasureType.getName());
title.setFadeInTime(1);
title.setStayTime(3);
title.setFadeOutTime(1);
title.send(player.getPlayer());
return true;
}
public void createHologram() {
hologram = nmsProvider.get().createHologram(location.clone().add(0.5, 1, 0.5));
hologram.setName(ChatColor.GREEN + "Cofre de Tesoros");
}
/**
* Gets the location
*
* @return the location
*/
public Location getLocation() {
return location;
}
/**
* Gets the bukkit chest
*
* @return the chest
*/
public Chest getChest() {
return chest;
}
/**
* Gets hologram
*
* @return the hologram
*/
public Hologram getHologram() {
return hologram;
}
/**
* @return true if another player is not opening the chest
*/
public boolean canOpen() {
return currentTreasureChest == null;
}
/**
* @return true if another player is opening the chest
*/
public boolean isNotAvailable() {
return currentTreasureChest != null;
}
/**
* @return the current treasure chest
*/
public TreasureChest getCurrentTreasureChest() {
return currentTreasureChest;
}
/**
* Creates a Map representation of this class.
* <p>
* This class must provide a method to restore this class, as defined in
* the {@link ConfigurationSerializable} interface javadocs.
*
*/
@Override
public void serialize(Map<String, Object> data) {
data.put("location", location.serialize());
}
} | 4,252 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChest.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChest.java | package me.patothebest.gamecore.treasure.chest;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import fr.mrmicky.fastparticle.FastParticle;
import fr.mrmicky.fastparticle.ParticleType;
import me.patothebest.gamecore.itemstack.ItemStackBuilder;
import me.patothebest.gamecore.scheduler.PluginScheduler;
import me.patothebest.gamecore.treasure.reward.RewardData;
import me.patothebest.gamecore.treasure.reward.RewardRandomizer;
import me.patothebest.gamecore.block.BlockRestorer;
import me.patothebest.gamecore.nms.NMS;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.treasure.TreasureFactory;
import me.patothebest.gamecore.treasure.type.TreasureType;
import me.patothebest.gamecore.util.Callback;
import me.patothebest.gamecore.util.Sounds;
import me.patothebest.gamecore.util.WrappedBukkitRunnable;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* The code was originally used in MineBone network when
* I was the developer. This code is about a year old and
* was adapted for the game core. Some things can definitely
* be improved and some others can be left alone.
* <p>
* An addition to the original code was Guice, you can now
* create a TreasureChest by using the TreasureFactory.createChest
* method by passing the necessary parameters.
*
*/
public class TreasureChest {
private final PluginScheduler scheduler;
private final IPlayer player;
private final BlockRestorer blockRestore;
private final TreasureType treasureType;
private final TreasureChestLocation treasureLocation;
private final TreasureFactory treasureFactory;
private final NMS nms;
private final Callback<TreasureChestLocation> callback;
private Location center;
private RewardRandomizer randomizer;
private int stage;
private int chestIndex = 4;
private BukkitTask task;
private final List<Block> blocksToRestore = new ArrayList<>();
private final List<Entity> items = new ArrayList<>();
private final List<Chest> chests = new CopyOnWriteArrayList<>();
private final List<ArmorStand> holograms = new ArrayList<>();
@Inject private TreasureChest(PluginScheduler scheduler, @Assisted IPlayer player, BlockRestorer blockRestore, @Assisted TreasureType treasureType, @Assisted TreasureChestLocation treasureLocation, TreasureFactory treasureFactory, NMS nms, @Assisted Callback<TreasureChestLocation> callback) {
this.scheduler = scheduler;
this.player = player;
this.blockRestore = blockRestore;
this.treasureType = treasureType;
this.treasureLocation = treasureLocation;
this.treasureFactory = treasureFactory;
this.nms = nms;
this.callback = callback;
}
public void playAnimation(Location location) {
stage = 0;
treasureLocation.getHologram().hide();
this.randomizer = treasureFactory.createRewardRandomizer(player, player.getPlayer(), treasureType);
task = scheduler.runTaskTimer(() -> {
if (stage >= 6) {
task.cancel();
playChestAnimation();
return;
}
makeSchematic(location, TreasureChestStructure.STRUCTURE[stage], stage == 0);
stage++;
}, 0L, 20L);
}
private void playChestAnimation() {
task = scheduler.runTaskTimer(() -> {
if (chestIndex == 0) {
task.cancel();
task = scheduler.runTaskLater(this::forceOpen, 1200L);
return;
}
playHelix(getChestLocation(chestIndex, center.clone()), 0.0F, ParticleType.FLAME);
playHelix(getChestLocation(chestIndex, center.clone()), 3.5F, ParticleType.FLAME);
scheduler.runTaskLater(() -> {
Block b = getChestLocation(chestIndex, center.clone()).getBlock();
b.setType(Material.CHEST);
Sounds.BLOCK_ANVIL_LAND.play(player.getPlayer(), 2, 1);
FastParticle.spawnParticle(b.getWorld(), ParticleType.SMOKE_LARGE, b.getLocation(), 5);
FastParticle.spawnParticle(b.getWorld(), ParticleType.LAVA, b.getLocation(), 5);
BlockFace blockFace = BlockFace.SOUTH;
switch (chestIndex) {
case 4:
blockFace = BlockFace.SOUTH;
break;
case 3:
blockFace = BlockFace.NORTH;
break;
case 2:
blockFace = BlockFace.EAST;
break;
case 1:
blockFace = BlockFace.WEST;
break;
}
nms.setDirectionalBlockData(b, blockFace, false);
BlockState state = b.getState();
chests.add((Chest) state);
chestIndex--;
}, 20L);
}, 0L, 50L);
}
public void playHelix(final Location loc, final float i, final ParticleType effect) {
BukkitRunnable runnable = new WrappedBukkitRunnable() {
double radius = 0;
double step;
final double y = loc.getY();
final Location location = loc.clone().add(0, 3, 0);
@Override
public void run() {
double inc = (2 * Math.PI) / 50;
double angle = step * inc + i;
Vector v = new Vector();
v.setX(Math.cos(angle) * radius);
v.setZ(Math.sin(angle) * radius);
if (effect == ParticleType.REDSTONE) {
FastParticle.spawnParticle(loc.getWorld(), ParticleType.REDSTONE, loc.add(v), -1, -1, 1, 1, 0);
} else {
FastParticle.spawnParticle(loc.getWorld(), effect, location.add(v), 1, 0, 0, 0, 0);
}
location.subtract(v);
location.subtract(0, 0.1d, 0);
if (location.getY() <= y) {
cancel();
}
step += 4;
radius += 1 / 30f;
}
};
scheduler.runTaskTimer(runnable, 0, 1);
}
@SuppressWarnings("deprecation")
private void makeSchematic(final Location loc, char[][][] structure, boolean clear) {
Block centerBlock = loc.getBlock();
final org.bukkit.World world = centerBlock.getWorld();
int bX = centerBlock.getX();
int bY = centerBlock.getY();
int bZ = centerBlock.getZ();
for (char[][] structurePiece : structure) {
if (structurePiece == null) {
continue;
}
for (char[] aStructurePiece : structurePiece) {
for (char anAStructurePiece : aStructurePiece) {
Block block = world.getBlockAt(bX, bY, bZ);
if (clear) {
blocksToRestore.add(block);
if (block.getType() != Material.AIR && bY != loc.getBlockY() - 4) {
FastParticle.spawnParticle(world, ParticleType.BLOCK_CRACK, bX, bY, bZ, 1, new MaterialData(block.getType(), block.getData()));
world.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
if (bY != loc.getBlockY() - 4) {
blockRestore.changeBlockTemporarily(block, new ItemStack(Material.AIR), 150000L);
} else {
blockRestore.changeBlockTemporarily(block, new ItemStackBuilder(block.getType()), 150000L);
}
}
if (anAStructurePiece == 'a') {
if(clear && bY != loc.getBlockY() - 4){
blockRestore.changeBlockTemporarily(centerBlock, new ItemStack(Material.AIR), 150000L);
}
} else {
Map<TreasureChestStructurePiece, TreasureChestPiece> treasureChestStructurePieceTreasureChestPieceMap = TreasureChestStructure.PIECES.get(treasureType);
TreasureChestStructurePiece treasureChestStructurePiece = TreasureChestStructurePiece.getStructurePiece(anAStructurePiece);
TreasureChestPiece treasureChestPiece = treasureChestStructurePieceTreasureChestPieceMap.get(treasureChestStructurePiece);
if(treasureChestPiece == null) {
System.err.println("Unknown treasure piece " + anAStructurePiece);
continue;
}
blockRestore.changeBlockTemporarily(centerBlock, new ItemStack(Material.AIR), 150000L);
nms.setBlock(block, new ItemStackBuilder(treasureChestPiece.getMaterial()));
if(treasureChestStructurePiece.getTreasureChestCallBack() != null) {
treasureChestStructurePiece.getTreasureChestCallBack().call(this, block);
}
FastParticle.spawnParticle(block.getWorld(), ParticleType.BLOCK_CRACK, block.getLocation(), 1, new MaterialData(block.getType()));
world.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
bX++;
}
bX -= aStructurePiece.length;
--bY;
}
bY += 5;
bZ++;
}
if(stage == 0) {
Block relative = center.getBlock().getRelative(BlockFace.DOWN);
blockRestore.changeBlockTemporarily(relative, null, 150000L);
blocksToRestore.add(relative);
Map<TreasureChestStructurePiece, TreasureChestPiece> treasureChestStructurePieceTreasureChestPieceMap = TreasureChestStructure.PIECES.get(treasureType);
TreasureChestStructurePiece treasureChestStructurePiece = TreasureChestStructurePiece.getStructurePiece('l');
TreasureChestPiece treasureChestPiece = treasureChestStructurePieceTreasureChestPieceMap.get(treasureChestStructurePiece);
nms.setBlock(relative, new ItemStackBuilder(treasureChestPiece.getMaterial()));
Block redstoneBlock = relative.getRelative(BlockFace.DOWN);
blockRestore.changeBlockTemporarily(redstoneBlock, null, 150000L);
blocksToRestore.add(redstoneBlock);
redstoneBlock.setType(Material.REDSTONE_BLOCK);
}
}
public void setStairsDirection(Block block) {
Location blockLocation = block.getLocation();
if (center.getBlockX() < blockLocation.getBlockX()) {
setDirectionalBlockData(block, BlockFace.EAST, false);
return;
}
if (center.getBlockX() > blockLocation.getBlockX()) {
setDirectionalBlockData(block, BlockFace.WEST, false);
return;
}
if (center.getBlockZ() < blockLocation.getBlockZ()) {
setDirectionalBlockData(block, BlockFace.SOUTH, false);
return;
}
if (center.getBlockZ() > blockLocation.getBlockZ()) {
setDirectionalBlockData(block, BlockFace.NORTH, false);
}
}
public void setUpsideDownStairsDirection(Block block) {
Location blockLocation = block.getLocation();
if (center.getBlockX() < blockLocation.getBlockX()) {
setDirectionalBlockData(block, BlockFace.WEST, true);
return;
}
if (center.getBlockX() > blockLocation.getBlockX()) {
setDirectionalBlockData(block, BlockFace.EAST, true);
return;
}
if (center.getBlockZ() < blockLocation.getBlockZ()) {
setDirectionalBlockData(block, BlockFace.NORTH, true);
return;
}
if (center.getBlockZ() > blockLocation.getBlockZ()) {
setDirectionalBlockData(block, BlockFace.SOUTH, true);
}
}
private void setDirectionalBlockData(Block block, BlockFace dir, boolean upsidedown) {
nms.setDirectionalBlockData(block, dir.getOppositeFace(), upsidedown);
}
public void forceDestroy() {
for (Chest chest : chests) {
randomizer.giveRandomThing();
chests.remove(chest);
}
clear();
}
private void forceOpen() {
for (Chest chest : chests) {
openChest(chest.getBlock());
}
}
public void openChest(Block chest) {
RewardData rewardData = randomizer.giveRandomThing();
org.bukkit.inventory.ItemStack is = rewardData.getItemStack();
ItemMeta itemMeta = is.getItemMeta();
itemMeta.setDisplayName(UUID.randomUUID().toString());
is.setItemMeta(itemMeta);
Entity itemEntity = nms.spawnItem(is, chest.getLocation());
this.items.add(itemEntity);
final String name = rewardData.getName();
scheduler.runTaskLater(() -> spawnHologram(chest.getLocation().add(0.5D, -0.7, 0.5D), name), 15L);
if(rewardData.isRareItem()) {
FireworkEffect effect = FireworkEffect.builder().trail(false).flicker(false).withColor(Color.RED).withFade(Color.ORANGE).with(FireworkEffect.Type.BALL).build();
Firework fw = chest.getLocation().getWorld().spawn(chest.getLocation().add(0.5D, 0, 0.5D), Firework.class);
FireworkMeta meta = fw.getFireworkMeta();
meta.addEffect(effect);
meta.setPower(0);
fw.setFireworkMeta(meta);
scheduler.runTaskLater(fw::detonate, 2L);
}
playChestAction(chest, true);
chests.remove(chest.getState());
if (chests.isEmpty() && chestIndex == 0) {
scheduler.runTaskLater(this::clear, 100L);
}
}
@SuppressWarnings("deprecation")
private void clear() {
task.cancel();
holograms.forEach(Entity::remove);
holograms.clear();
items.forEach(Entity::remove);
items.clear();
blocksToRestore.forEach(block -> {
if (block.getType() != Material.AIR) {
FastParticle.spawnParticle(block.getWorld(), ParticleType.BLOCK_CRACK, block.getLocation(), 1, new MaterialData(block.getType(), block.getData()));
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
blockRestore.restore(block);
});
blocksToRestore.clear();
chests.clear();
callback.call(treasureLocation);
if(treasureLocation.getHologram().isAlive()) {
treasureLocation.getHologram().show();
}
}
public void addItem(Entity entity) {
this.items.add(entity);
}
public void playChestAction(Block b, boolean open) {
nms.playChestAction(b, open);
}
private Location getChestLocation(int i, Location loc) {
Location chestLocation = this.center.clone();
chestLocation.setX(loc.getBlockX() + 0.5D);
chestLocation.setY(loc.getBlockY() + 1.0D);
chestLocation.setZ(loc.getBlockZ() + 0.5D);
switch (i) {
case 1:
chestLocation.add(2.0D, 0.0D, 0.0D);
break;
case 2:
chestLocation.add(-2.0D, 0.0D, 0.0D);
break;
case 3:
chestLocation.add(0.0D, 0.0D, 2.0D);
break;
case 4:
chestLocation.add(0.0D, 0.0D, -2.0D);
}
return chestLocation;
}
private void spawnHologram(Location location, String s) {
location.setY(location.getY() + 1);
ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
armorStand.setSmall(true);
armorStand.setVisible(false);
armorStand.setGravity(false);
armorStand.setBasePlate(false);
armorStand.setCustomName(s);
armorStand.setCustomNameVisible(true);
this.holograms.add(armorStand);
}
/**
* Gets the player
*
* @return the player
*/
public IPlayer getPlayer() {
return player;
}
/**
* Gets the dropped item entities
*
* @return the dropped item entities
*/
public List<Entity> getItems() {
return items;
}
/**
* Gets the chests that haven't been opened
*
* @return the chests that haven't been opened
*/
public List<Chest> getChests() {
return chests;
}
/**
* Sets the center location
*/
public void setCenter(Location center) {
this.center = center;
}
} | 17,592 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChestStructurePiece.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChestStructurePiece.java | package me.patothebest.gamecore.treasure.chest;
import me.patothebest.gamecore.util.DoubleCallback;
import org.bukkit.block.Block;
public enum TreasureChestStructurePiece {
// The lamp block
LAMP('l', "lamp"),
// The base block where the player will be standing
BASE('g', "base", (treasureChest, block) -> treasureChest.setCenter(block.getLocation())),
// The inner ring surrounding the base block
INNER('i', "inner"),
// The outer ring surrounding the inner ring excluding the blocks below the chest
OUTER('o', "outer"),
// The blocks below the chests
BELOW_CHESTS('c', "below-chests"),
// The blocks enclosing the chests
WALLS('w', "walls"),
// The pillars from the sides
PILLARS('p', "pillars"),
// The stairs
NORMAL_STAIRS('u', "stairs", TreasureChest::setStairsDirection),
UPSIDE_DOWN_STAIRS('d', "stairs", TreasureChest::setUpsideDownStairsDirection),
// The block that goes on top of the stairs that is on top of the pillars
TOP('t', "top")
;
private final char keyChar;
private final String configPath;
private DoubleCallback<TreasureChest, Block> doubleCallback;
TreasureChestStructurePiece(char keyChar, String configPath) {
this.keyChar = keyChar;
this.configPath = configPath;
}
TreasureChestStructurePiece(char keyChar, String configPath, DoubleCallback<TreasureChest, Block> doubleCallback) {
this.keyChar = keyChar;
this.configPath = configPath;
this.doubleCallback = doubleCallback;
}
public static TreasureChestStructurePiece getStructurePiece(char keyChar) {
for (TreasureChestStructurePiece treasureChestStructurePiece : TreasureChestStructurePiece.values()) {
if(treasureChestStructurePiece.keyChar == keyChar) {
return treasureChestStructurePiece;
}
}
return null;
}
/**
* Gets the config path
*
* @return the config path
*/
public String getConfigPath() {
return configPath;
}
/**
* Gets the TreasureChest Callback
* <p>
* This callback is used for things like the glass
* block being set as the center block and the stairs
* having to be set in a specific direction, facing the
* center block.
*
* @return value of treasureChestCallback
*/
public DoubleCallback<TreasureChest, Block> getTreasureChestCallBack() {
return doubleCallback;
}
}
| 2,503 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TreasureChestPiece.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/treasure/chest/TreasureChestPiece.java | package me.patothebest.gamecore.treasure.chest;
import me.patothebest.gamecore.itemstack.Material;
import java.util.Optional;
public class TreasureChestPiece {
private final Material material;
private final byte data;
public TreasureChestPiece(Optional<Material> material) {
this.material = material.orElse(null);
this.data = 0;
}
public TreasureChestPiece(Optional<Material> material, byte data) {
this.material = material.orElse(null);
this.data = data;
}
/**
* Gets the piece material
*
* @return the material
*/
public Material getMaterial() {
return material;
}
/**
* Gets the piece data
*
* @return the data
*/
public byte getData() {
return data;
}
} | 801 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PluginScheduler.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/scheduler/PluginScheduler.java | package me.patothebest.gamecore.scheduler;
import com.google.inject.Inject;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.modules.Module;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scheduler.BukkitWorker;
import java.util.List;
public class PluginScheduler implements Module {
private final CorePlugin plugin;
@Inject public PluginScheduler(CorePlugin plugin) {
this.plugin = plugin;
}
/**
* Schedules a once off task to occur after a delay.
* <p>
* This task will be executed by the main server thread.
*
* @param task Task to be executed
* @param delay Delay in server ticks before executing task
* @return Task id number (-1 if scheduling failed)
*/
public int scheduleSyncDelayedTask(Runnable task, long delay) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, task, delay);
}
/**
* Schedules a once off task to occur as soon as possible.
* <p>
* This task will be executed by the main server thread.
*
* @param task Task to be executed
* @return Task id number (-1 if scheduling failed)
*/
public int scheduleSyncDelayedTask(Runnable task) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, task);
}
/**
* Schedules a repeating task.
* <p>
* This task will be executed by the main server thread.
*
* @param task Task to be executed
* @param delay Delay in server ticks before executing first repeat
* @param period Period in server ticks of the task
* @return Task id number (-1 if scheduling failed)
*/
public int scheduleSyncRepeatingTask(Runnable task, long delay, long period) {
return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
}
/**
* Removes task from scheduler.
*
* @param taskId Id number of task to be removed
*/
public void cancelTask(int taskId) {
Bukkit.getScheduler().cancelTask(taskId);
}
/**
* Removes all tasks associated with a particular plugin from the
* scheduler.
*
* @param plugin Owner of tasks to be removed
*/
public void cancelTasks(Plugin plugin) {
Bukkit.getScheduler().cancelTasks(plugin);
}
/**
* Check if the task currently running.
* <p>
* A repeating task might not be running currently, but will be running in
* the future. A task that has finished, and does not repeat, will not be
* running ever again.
* <p>
* Explicitly, a task is running if there exists a thread for it, and that
* thread is alive.
*
* @param taskId The task to check.
* <p>
* @return If the task is currently running.
*/
public boolean isCurrentlyRunning(int taskId) {
return Bukkit.getScheduler().isCurrentlyRunning(taskId);
}
/**
* Check if the task queued to be run later.
* <p>
* If a repeating task is currently running, it might not be queued now
* but could be in the future. A task that is not queued, and not running,
* will not be queued again.
*
* @param taskId The task to check.
* <p>
* @return If the task is queued to be run.
*/
public boolean isQueued(int taskId) {
return Bukkit.getScheduler().isQueued(taskId);
}
/**
* Returns a list of all active workers.
* <p>
* This list contains async tasks that are being executed by separate
* threads.
*
* @return Active workers
*/
public List<BukkitWorker> getActiveWorkers() {
return Bukkit.getScheduler().getActiveWorkers();
}
/**
* Returns a list of all pending tasks. The ordering of the tasks is not
* related to their order of execution.
*
* @return Active workers
*/
public List<BukkitTask> getPendingTasks() {
return Bukkit.getScheduler().getPendingTasks();
}
/**
* Returns a task that will run on the next server tick.
*
* @param task the task to be run
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTask(Runnable task) throws IllegalArgumentException {
return Bukkit.getScheduler().runTask(plugin, task);
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Returns a task that will run asynchronously.
*
* @param task the task to be run
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskAsynchronously(Runnable task) throws IllegalArgumentException {
return Bukkit.getScheduler().runTaskAsynchronously(plugin, task);
}
/**
* Returns a task that will run after the specified number of server
* ticks.
*
* @param task the task to be run
* @param delay the ticks to wait before running the task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskLater(Runnable task, long delay) throws IllegalArgumentException {
return Bukkit.getScheduler().runTaskLater(plugin, task, delay);
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Returns a task that will run asynchronously after the specified number
* of server ticks.
*
* @param task the task to be run
* @param delay the ticks to wait before running the task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskLaterAsynchronously(Runnable task, long delay) throws IllegalArgumentException {
return Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, task, delay);
}
/**
* Returns a task that will repeatedly run until cancelled, starting after
* the specified number of server ticks.
*
* @param task the task to be run
* @param delay the ticks to wait before running the task
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskTimer(Runnable task, long delay, long period) throws IllegalArgumentException {
return Bukkit.getScheduler().runTaskTimer(plugin, task, delay, period);
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Returns a task that will repeatedly run asynchronously until cancelled,
* starting after the specified number of server ticks.
*
* @param task the task to be run
* @param delay the ticks to wait before running the task for the first
* time
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskTimerAsynchronously(Runnable task, long delay, long period) throws IllegalArgumentException {
return Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, task, delay, period);
}
public void callEvenSync(Event event) {
runTask(() -> Bukkit.getServer().getPluginManager().callEvent(event));
}
public void ensureSync(Runnable runnable) {
if (Bukkit.isPrimaryThread()) {
runnable.run();
} else {
runTask(runnable);
}
}
public void ensureAsync(Runnable runnable) {
if (!Bukkit.isPrimaryThread()) {
runnable.run();
} else {
runTaskAsynchronously(runnable);
}
}
}
| 8,554 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LoggerFactory.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/LoggerFactory.java | package me.patothebest.gamecore.logger;
import me.patothebest.gamecore.CorePlugin;
import java.util.HashMap;
import java.util.Map;
class LoggerFactory {
private final CorePlugin plugin;
private final Map<String, Logger> loggerMap = new HashMap<>();
LoggerFactory(CorePlugin plugin) {
this.plugin = plugin;
}
public Logger getLogger(String name) {
if(loggerMap.containsKey(name)) {
return loggerMap.get(name);
}
Logger coreLogger = new Logger(plugin.getLogger(), name, plugin.getLoggingLevel());
loggerMap.put(name, coreLogger);
return coreLogger;
}
} | 641 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LoggerTypeListener.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/LoggerTypeListener.java | package me.patothebest.gamecore.logger;
import com.google.inject.TypeLiteral;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.modules.ModuleName;
import java.lang.reflect.Field;
class LoggerTypeListener implements TypeListener {
private final LoggerFactory loggerFactory;
LoggerTypeListener(CorePlugin plugin) {
this.loggerFactory = new LoggerFactory(plugin);
}
public <T> void hear(TypeLiteral<T> typeLiteral, TypeEncounter<T> typeEncounter) {
Class<?> clazz = typeLiteral.getRawType();
Class<?> implementationClass = clazz;
while (clazz != null) {
for (Field field : clazz.getDeclaredFields()) {
if (field.getType() == Logger.class || field.getType() == java.util.logging.Logger.class) {
if(field.isAnnotationPresent(InjectLogger.class)) {
String name = field.getAnnotation(InjectLogger.class).name();
if (name.isEmpty()) {
if (clazz.isAnnotationPresent(ModuleName.class)) {
name = field.getDeclaringClass().getAnnotation(ModuleName.class).value();
} else {
name = field.getDeclaringClass().getSimpleName();
}
}
typeEncounter.register(new LoggerMembersInjector<>(field, loggerFactory.getLogger(name)));
} else if(field.isAnnotationPresent(InjectImplementationLogger.class)) {
String name = implementationClass.getSimpleName();
if (implementationClass.isAnnotationPresent(ModuleName.class)) {
name = implementationClass.getAnnotation(ModuleName.class).value();
}
typeEncounter.register(new LoggerMembersInjector<>(field, loggerFactory.getLogger(name)));
} else if(field.isAnnotationPresent(InjectParentLogger.class)) {
Class<?> parentClass = field.getAnnotation(InjectParentLogger.class).parent();
boolean injected = false;
for (Field parentField : parentClass.getDeclaredFields()) {
if ((parentField.getType() == Logger.class || parentField.getType() == java.util.logging.Logger.class) && parentField.isAnnotationPresent(InjectLogger.class)) {
String name = parentField.getAnnotation(InjectLogger.class).name();
if (name.isEmpty()) {
if (parentClass.isAnnotationPresent(ModuleName.class)) {
name = parentClass.getAnnotation(ModuleName.class).value();
} else {
name = parentClass.getSimpleName();
}
}
typeEncounter.register(new LoggerMembersInjector<>(field, loggerFactory.getLogger(name)));
injected = true;
}
}
if(!injected) {
throw new RuntimeException("Could not inject logger for class " + clazz.getSimpleName());
}
}
}
}
clazz = clazz.getSuperclass();
}
}
}
| 3,639 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LoggerMembersInjector.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/LoggerMembersInjector.java | package me.patothebest.gamecore.logger;
import com.google.inject.MembersInjector;
import java.lang.reflect.Field;
class LoggerMembersInjector<T> implements MembersInjector<T> {
private final Field field;
private final Logger logger;
LoggerMembersInjector(Field field, Logger logger) {
this.field = field;
this.logger = logger;
field.setAccessible(true);
}
public void injectMembers(T t) {
try {
field.set(t, logger);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
} | 592 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LoggerModule.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/LoggerModule.java | package me.patothebest.gamecore.logger;
import com.google.inject.matcher.Matchers;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.injector.AbstractBukkitModule;
public class LoggerModule extends AbstractBukkitModule<CorePlugin> {
public LoggerModule(CorePlugin plugin) {
super(plugin);
}
@Override
protected void configure() {
bindListener(Matchers.any(), new LoggerTypeListener(plugin));
}
}
| 460 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
InjectParentLogger.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/InjectParentLogger.java | package me.patothebest.gamecore.logger;
import me.patothebest.gamecore.modules.Module;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface InjectParentLogger {
Class<? extends Module> parent();
}
| 411 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Logger.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/Logger.java | package me.patothebest.gamecore.logger;
import me.patothebest.gamecore.PluginConfig;
import java.util.logging.Level;
import java.util.logging.LogRecord;
public class Logger extends java.util.logging.Logger {
private final String prefix;
Logger(java.util.logging.Logger parent, String name, Level loggingLevel) {
super(PluginConfig.LOGGER_PREFIX, null);
prefix = "[" + name + "] ";
setParent(parent);
setLevel(loggingLevel);
}
@Override
public void log(LogRecord logRecord) {
logRecord.setMessage(prefix + logRecord.getMessage());
if (logRecord.getLevel().intValue() < Level.INFO.intValue()) {
logRecord.setLevel(Level.INFO);
}
super.log(logRecord);
}
public void severe(String msg, Object... objects) {
log(Level.SEVERE, msg, objects);
}
public void severe(String msg, Throwable thrown) {
log(Level.SEVERE, msg, thrown);
}
public void severe(String msg, Throwable thrown, Object... objects) {
log(Level.SEVERE, msg, thrown, objects);
}
public void warning(String msg, Object... objects) {
log(Level.WARNING, msg, objects);
}
public void warning(String msg, Throwable thrown) {
log(Level.WARNING, msg, thrown);
}
public void warning(String msg, Throwable thrown, Object... objects) {
log(Level.WARNING, msg, thrown, objects);
}
public void info(String msg, Object... objects) {
log(Level.INFO, msg, objects);
}
public void info(String msg, Throwable thrown) {
log(Level.INFO, msg, thrown);
}
public void info(String msg, Throwable thrown, Object... objects) {
log(Level.INFO, msg, thrown, objects);
}
public void config(String msg, Object... objects) {
log(Level.CONFIG, msg, objects);
}
public void config(String msg, Throwable thrown) {
log(Level.CONFIG, msg, thrown);
}
public void config(String msg, Throwable thrown, Object... objects) {
log(Level.CONFIG, msg, thrown, objects);
}
public void fine(String msg, Object... objects) {
log(Level.FINE, msg, objects);
}
public void fine(String msg, Throwable thrown) {
log(Level.FINE, msg, thrown);
}
public void fine(String msg, Throwable thrown, Object... objects) {
log(Level.FINE, msg, thrown, objects);
}
public void finer(String msg, Object... objects) {
log(Level.FINER, msg, objects);
}
public void finer(String msg, Throwable thrown) {
log(Level.FINER, msg, thrown);
}
public void finer(String msg, Throwable thrown, Object... objects) {
log(Level.FINER, msg, thrown, objects);
}
public void finest(String msg, Object... objects) {
log(Level.FINEST, msg, objects);
}
public void finest(String msg, Throwable thrown) {
log(Level.FINEST, msg, thrown);
}
public void finest(String msg, Throwable thrown, Object... objects) {
log(Level.FINEST, msg, thrown, objects);
}
private void log(Level level, String msg, Throwable thrown, Object[] objects) {
if (!isLoggable(level)) {
return;
}
LogRecord lr = new LogRecord(level, msg);
lr.setThrown(thrown);
lr.setParameters(objects);
log(lr);
}
}
| 3,387 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
InjectImplementationLogger.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/InjectImplementationLogger.java | package me.patothebest.gamecore.logger;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface InjectImplementationLogger {
}
| 331 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
InjectLogger.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/logger/InjectLogger.java | package me.patothebest.gamecore.logger;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface InjectLogger {
String name() default "";
}
| 349 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PermissionGroup.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/permission/PermissionGroup.java | package me.patothebest.gamecore.permission;
import me.patothebest.gamecore.PluginConfig;
import me.patothebest.gamecore.player.IPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class PermissionGroup {
private final String name;
private final org.bukkit.permissions.Permission bukkitPermission;
PermissionGroup(String name) {
this.name = name;
String perm = PluginConfig.PERMISSION_PREFIX + ".group." + name;
if(Bukkit.getServer().getPluginManager().getPermission(perm) == null) {
Bukkit.getServer().getPluginManager().addPermission(new org.bukkit.permissions.Permission(perm));
}
bukkitPermission = Bukkit.getServer().getPluginManager().getPermission(perm);
}
public boolean hasPermission(IPlayer player) {
return hasPermission(player.getPlayer());
}
public boolean hasPermission(Player player) {
return name.equalsIgnoreCase("default") || player.hasPermission(bukkitPermission);
}
public String getName() {
return name;
}
public org.bukkit.permissions.Permission getBukkitPermission() {
return bukkitPermission;
}
}
| 1,184 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
GroupPermissible.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/permission/GroupPermissible.java | package me.patothebest.gamecore.permission;
public interface GroupPermissible {
PermissionGroup getPermissionGroup();
void setPermissionGroup(PermissionGroup permissionGroup);
}
| 190 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Permission.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/permission/Permission.java | package me.patothebest.gamecore.permission;
import me.patothebest.gamecore.PluginConfig;
import org.bukkit.Bukkit;
public enum Permission {
USER("user"),
CHOOSE_TEAM("choose.team"),
CHOOSE_TEAM_OVERRIDE("choose.team.override"),
CHOOSE_WEATHER("choose.weather"),
CHOOSE_TIME("choose.time"),
CHOOSE_ARENA("choose.arena"),
CHAT_COLORS("chat.colors"),
SETUP("setup", "Setup"),
KIT("kitadmin", "KitAdmin"),
ADMIN("admin", "Admin");
private final org.bukkit.permissions.Permission bukkitPermission;
private final String permissionRaw;
private final String displayName;
Permission(String permissionString) {
this(permissionString, null);
}
Permission(String permissionString, String displayName) {
String perm = PluginConfig.PERMISSION_PREFIX + "." + permissionString;
this.permissionRaw = perm;
if(Bukkit.getServer().getPluginManager().getPermission(perm) == null) {
Bukkit.getServer().getPluginManager().addPermission(new org.bukkit.permissions.Permission(perm));
}
bukkitPermission = Bukkit.getServer().getPluginManager().getPermission(perm);
this.displayName = displayName;
}
public org.bukkit.permissions.Permission getBukkitPermission() {
return bukkitPermission;
}
public String getPermissionRaw() {
return permissionRaw;
}
public String getDisplayName() {
return displayName;
}
}
| 1,476 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PermissionGroupManager.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/permission/PermissionGroupManager.java | package me.patothebest.gamecore.permission;
import com.google.inject.Singleton;
import me.patothebest.gamecore.modules.Module;
import java.util.HashMap;
import java.util.Map;
@Singleton
public class PermissionGroupManager implements Module {
private final Map<String, PermissionGroup> permissionGroups;
private final PermissionGroup defaultPermissionGroup;
public PermissionGroupManager() {
this.permissionGroups = new HashMap<>();
this.defaultPermissionGroup = createGroup("default");
}
public PermissionGroup createGroup(String name) {
if(getPermissionGroup(name) != null) {
return null;
}
PermissionGroup permissionGroup = new PermissionGroup(name);
permissionGroups.put(name, permissionGroup);
return permissionGroup;
}
public PermissionGroup getPermissionGroup(String name) {
return permissionGroups.get(name);
}
public PermissionGroup getOrCreatePermissionGroup(String name) {
if(getPermissionGroup(name) != null) {
return permissionGroups.get(name);
}
return createGroup(name);
}
public PermissionGroup getDefaultPermissionGroup() {
return defaultPermissionGroup;
}
public Map<String, PermissionGroup> getPermissionGroups() {
return permissionGroups;
}
}
| 1,357 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsCommand.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatsCommand.java | package me.patothebest.gamecore.stats;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.command.BaseCommand;
import me.patothebest.gamecore.command.ChildOf;
import me.patothebest.gamecore.command.Command;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.command.LangDescription;
import me.patothebest.gamecore.modules.RegisteredCommandModule;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.util.CommandUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
@ChildOf(BaseCommand.class)
public class StatsCommand implements RegisteredCommandModule {
private final PlayerManager playerManager;
private final StatsManager statsManager;
@Inject private StatsCommand(PlayerManager playerManager, StatsManager statsManager) {
this.playerManager = playerManager;
this.statsManager = statsManager;
}
@Command(
aliases = {"stats"},
usage = "[player]",
min = 0,
max = 1,
langDescription = @LangDescription(
element = "",
langClass = CoreLang.class
)
)
public List<String> stats(CommandContext args, CommandSender sender) throws CommandException {
if (args.getSuggestionContext() != null) {
if (args.getSuggestionContext().getIndex() == 0) {
return CommandUtils.completePlayers(args.getString(0));
}
return null;
}
Player player;
boolean self = false;
if (!args.isInBounds(0)) {
player = CommandUtils.getPlayer(sender);
self = true;
} else {
player = CommandUtils.getPlayer(args, 0);
}
IPlayer corePlayer = playerManager.getPlayer(player);
if (self) {
CoreLang.STATS_WEEK.sendMessage(sender);
} else {
CoreLang.STATS_WEEK_PLAYER.replaceAndSend(sender, player.getName());
}
corePlayer.getStatistics().forEach((statClass, trackedStatistic) -> {
Statistic statistic = statsManager.getStatisticByClass(statClass);
CoreLang.STATS_WEEK_DISPLAY.replaceAndSend(sender, statistic.getStatName(), trackedStatistic.getWeekly());
});
sender.sendMessage("");
if (self) {
CoreLang.STATS_ALL.sendMessage(sender);
} else {
CoreLang.STATS_ALL_PLAYER.replaceAndSend(sender, player.getName());
}
corePlayer.getStatistics().forEach((statClass, trackedStatistic) -> {
Statistic statistic = statsManager.getStatisticByClass(statClass);
CoreLang.STATS_ALL_DISPLAY.replaceAndSend(sender, statistic.getStatName(), trackedStatistic.getAllTime());
});
return null;
}
}
| 3,028 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatRecord.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatRecord.java | package me.patothebest.gamecore.stats;
import me.patothebest.gamecore.util.SerializableObject;
import java.util.Map;
public class StatRecord implements SerializableObject {
private int entryId;
private final int playerId;
private final String statName;
private int stats;
private int week;
private int month;
private int year;
public StatRecord(int entryId, int playerId, String statName) {
this.entryId = entryId;
this.playerId = playerId;
this.statName = statName;
}
public StatRecord(int playerId, Map<String, Object> data) {
this.entryId = -1;
this.playerId = playerId;
this.statName = (String) data.get("stat-name");
this.stats = (int) data.get("stats");
this.week = (int) data.get("week");
this.month = (int) data.get("month");
this.year = (int) data.get("year");
}
public int getEntryId() {
return entryId;
}
public void setEntryId(int entryId) {
this.entryId = entryId;
}
public int getPlayerId() {
return playerId;
}
public int getStats() {
return stats;
}
public void setStats(int stats) {
this.stats = stats;
}
public void addStats(int amount) {
this.stats += amount;
}
public int getWeek() {
return week;
}
public void setWeek(int week) {
this.week = week;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getStatName() {
return statName;
}
@Override
public void serialize(Map<String, Object> data) {
data.put("stat-name", statName);
data.put("stats", stats);
data.put("week", week);
data.put("month", month);
data.put("year", year);
}
}
| 2,007 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsUpdateEvent.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatsUpdateEvent.java | package me.patothebest.gamecore.stats;
import me.patothebest.gamecore.player.IPlayer;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class StatsUpdateEvent extends Event {
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
private final IPlayer player;
private final Statistic statistic;
private final int changed;
// -------------------------------------------- //
// CONSTRUCTOR
// -------------------------------------------- //
public StatsUpdateEvent(IPlayer player, Statistic statistic, int changed) {
this.player = player;
this.statistic = statistic;
this.changed = changed;
}
// -------------------------------------------- //
// GETTERS
// -------------------------------------------- //
/**
* Get's the player that has been loaded
*
* @return the player object
*/
public IPlayer getPlayer() {
return player;
}
/**
* Gets the statistic
*
* @return the statistic
*/
public Statistic getStatistic() {
return statistic;
}
/**
* Gets the amount changed
*
* @return the amount changed
*/
public int getChanged() {
return changed;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
| 1,557 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
TrackedStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/TrackedStatistic.java | package me.patothebest.gamecore.stats;
import me.patothebest.gamecore.util.Utils;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class TrackedStatistic {
private final List<StatRecord> statRecords = new CopyOnWriteArrayList<>();
public List<StatRecord> getStatRecords() {
return statRecords;
}
public int getWeekly() {
for (StatRecord statRecord : statRecords) {
if(statRecord.getWeek() == Utils.getWeekOfTheYear()) {
return statRecord.getStats();
}
}
return 0;
}
public int getMonthly() {
for (StatRecord statRecord : statRecords) {
if(statRecord.getMonth() == Utils.getMonthOfTheYear()) {
return statRecord.getStats();
}
}
return 0;
}
public int getAllTime() {
for (StatRecord statRecord : statRecords) {
if(statRecord.getYear() == 0) {
return statRecord.getStats();
}
}
return 0;
}
}
| 1,067 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatPeriod.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatPeriod.java | package me.patothebest.gamecore.stats;
public enum StatPeriod {
WEEK,
MONTH,
ALL
}
| 98 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsModule.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatsModule.java | package me.patothebest.gamecore.stats;
import com.google.inject.multibindings.Multibinder;
import me.patothebest.gamecore.CorePlugin;
import me.patothebest.gamecore.stats.statistics.BlocksPlacedStatistic;
import me.patothebest.gamecore.stats.statistics.DeathStatistic;
import me.patothebest.gamecore.stats.statistics.KillStatistic;
import me.patothebest.gamecore.stats.statistics.LosesStatistic;
import me.patothebest.gamecore.stats.statistics.WinsStatistic;
import me.patothebest.gamecore.stats.storage.StatsFlatFileEntity;
import me.patothebest.gamecore.stats.storage.StatsMySQLEntity;
import me.patothebest.gamecore.storage.StorageModule;
import me.patothebest.gamecore.storage.flatfile.FlatFileEntity;
import me.patothebest.gamecore.storage.mysql.MySQLEntity;
public class StatsModule extends StorageModule {
public StatsModule(CorePlugin plugin) {
super(plugin);
}
@Override
protected void configure() {
super.configure();
registerModule(StatsManager.class);
registerModule(StatsCommand.class);
Multibinder<Statistic> statisticMultibinder = Multibinder.newSetBinder(binder(), Statistic.class);
statisticMultibinder.addBinding().to(DeathStatistic.class);
statisticMultibinder.addBinding().to(BlocksPlacedStatistic.class);
statisticMultibinder.addBinding().to(KillStatistic.class);
statisticMultibinder.addBinding().to(LosesStatistic.class);
statisticMultibinder.addBinding().to(WinsStatistic.class);
}
@Override
protected Class<? extends FlatFileEntity> getFlatFileEntity() {
return StatsFlatFileEntity.class;
}
@Override
protected Class<? extends MySQLEntity> getSQLEntity() {
return StatsMySQLEntity.class;
}
}
| 1,765 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsManager.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/StatsManager.java | package me.patothebest.gamecore.stats;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.file.CoreConfig;
import me.patothebest.gamecore.logger.InjectLogger;
import me.patothebest.gamecore.logger.Logger;
import me.patothebest.gamecore.modules.ActivableModule;
import me.patothebest.gamecore.modules.ModuleName;
import me.patothebest.gamecore.modules.ModulePriority;
import me.patothebest.gamecore.modules.ReloadableModule;
import me.patothebest.gamecore.event.EventRegistry;
import me.patothebest.gamecore.util.Priority;
import java.util.Set;
@Singleton
@ModulePriority(priority = Priority.HIGH)
@ModuleName("Stats Manager")
public class StatsManager implements ActivableModule, ReloadableModule {
private final CoreConfig coreConfig;
private final Set<Statistic> statistics;
private final EventRegistry registry;
@InjectLogger private Logger logger;
@Inject private StatsManager(CoreConfig coreConfig, Set<Statistic> statistics, EventRegistry registry) {
this.coreConfig = coreConfig;
this.statistics = statistics;
this.registry = registry;
}
@Override
public void onEnable() {
for (Statistic statistic : statistics) {
if(!coreConfig.getBoolean("stats." + statistic.getStatName())) {
continue;
}
registry.registerListener(statistic);
statistic.setEnabled(true);
logger.config("Registered stat {0}", statistic.getStatName());
}
}
public Statistic getStatisticByClass(Class<? extends Statistic> statClass) {
for (Statistic statistic : statistics) {
if(statistic.getClass() == statClass) {
return statistic;
}
}
throw new IllegalArgumentException("Stat " + statClass + " is not registered!");
}
public Statistic getStatisticByName(String name) {
for (Statistic statistic : statistics) {
if(statistic.getStatName().equalsIgnoreCase(name)) {
return statistic;
}
}
return null;
}
@Override
public void onDisable() {
for (Statistic statistic : statistics) {
registry.unRegisterListener(statistic);
statistic.setEnabled(false);
}
}
@Override
public void onReload() {
onDisable();
onEnable();
}
@Override
public String getReloadName() {
return "stats";
}
public Set<Statistic> getStatistics() {
return statistics;
}
}
| 2,587 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
AbstractStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/AbstractStatistic.java | package me.patothebest.gamecore.stats;
import com.google.inject.Inject;
import me.patothebest.gamecore.leaderboards.LeaderboardQueries;
import me.patothebest.gamecore.leaderboards.TopEntry;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.player.modifiers.StatsModifier;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.event.EventRegistry;
import org.bukkit.entity.Player;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
@SuppressWarnings("Duplicates")
public abstract class AbstractStatistic implements Statistic {
@Inject protected PlayerManager playerManager;
@Inject private EventRegistry registry;
private boolean enabled;
protected IPlayer getPlayer(Player player) {
return playerManager.getPlayer(player);
}
@Override
public void updateStat(Player player, int amount) {
updateStat(getPlayer(player), amount);
}
@Override
public void updateStat(IPlayer player, int amount) {
if(!enabled) {
return;
}
if (player.getCurrentArena() != null && player.getCurrentArena().isDisableStats()) {
return;
}
if(!player.getStatistics().containsKey(getClass())) {
player.getStatistics().put(getClass(), new TrackedStatistic());
}
TrackedStatistic trackedStatistic = player.getStatistics().get(getClass());
StatRecord allTimeRecord = null;
StatRecord thisWeekRecord = null;
for (StatRecord statRecord : trackedStatistic.getStatRecords()) {
if(statRecord.getYear() == 0) {
allTimeRecord = statRecord;
continue;
}
if(statRecord.getWeek() == Utils.getWeekOfTheYear()) {
thisWeekRecord = statRecord;
}
}
if(allTimeRecord == null && thisWeekRecord == null) {
allTimeRecord = new StatRecord(-1, player.getPlayerId(), getStatName());
allTimeRecord.setYear(0);
allTimeRecord.setMonth(0);
allTimeRecord.setWeek(0);
allTimeRecord.setStats(amount);
trackedStatistic.getStatRecords().add(allTimeRecord);
thisWeekRecord = new StatRecord(-1, player.getPlayerId(), getStatName());
thisWeekRecord.setYear(Utils.getYear());
thisWeekRecord.setMonth(Utils.getMonthOfTheYear());
thisWeekRecord.setWeek(Utils.getWeekOfTheYear());
thisWeekRecord.setStats(amount);
trackedStatistic.getStatRecords().add(thisWeekRecord);
player.notifyObservers(StatsModifier.INSERT, allTimeRecord, thisWeekRecord);
} else if(allTimeRecord == null) {
allTimeRecord = new StatRecord(-1, player.getPlayerId(), getStatName());
allTimeRecord.setYear(0);
allTimeRecord.setMonth(0);
allTimeRecord.setWeek(0);
allTimeRecord.setStats(amount);
trackedStatistic.getStatRecords().add(allTimeRecord);
player.notifyObservers(StatsModifier.INSERT, allTimeRecord);
thisWeekRecord.addStats(amount);
player.notifyObservers(StatsModifier.UPDATE_ADD, amount, thisWeekRecord);
} else if(thisWeekRecord == null) {
thisWeekRecord = new StatRecord(-1, player.getPlayerId(), getStatName());
thisWeekRecord.setYear(Utils.getYear());
thisWeekRecord.setMonth(Utils.getMonthOfTheYear());
thisWeekRecord.setWeek(Utils.getWeekOfTheYear());
thisWeekRecord.setStats(amount);
trackedStatistic.getStatRecords().add(thisWeekRecord);
player.notifyObservers(StatsModifier.INSERT, thisWeekRecord);
allTimeRecord.addStats(amount);
player.notifyObservers(StatsModifier.UPDATE_ADD, amount, allTimeRecord);
} else {
thisWeekRecord.addStats(amount);
allTimeRecord.addStats(amount);
player.notifyObservers(StatsModifier.UPDATE_ADD, amount, allTimeRecord, thisWeekRecord);
}
registry.callEvent(new StatsUpdateEvent(player, this, amount));
}
@Override
public LinkedList<TopEntry> getTop10Weekly(Connection connection) throws SQLException {
PreparedStatement selectTop10Weekly = connection.prepareStatement(LeaderboardQueries.SELECT_WEEKLY);
selectTop10Weekly.setString(1, getStatName());
selectTop10Weekly.setInt(2, Utils.getWeekOfTheYear());
selectTop10Weekly.setInt(3, Utils.getYear());
ResultSet selectTop10WeeklyResults = selectTop10Weekly.executeQuery();
LinkedList<TopEntry> top10Weekly = new LinkedList<>();
while (selectTop10WeeklyResults.next()) {
top10Weekly.add(new TopEntry(selectTop10WeeklyResults.getString("name"), selectTop10WeeklyResults.getInt("stat")));
}
selectTop10WeeklyResults.close();
selectTop10Weekly.close();
return top10Weekly;
}
@Override
public LinkedList<TopEntry> getTop10Monthly(Connection connection) throws SQLException {
PreparedStatement selectTop10Monthly = connection.prepareStatement(LeaderboardQueries.SELECT_MONTHLY);
selectTop10Monthly.setString(1, getStatName());
selectTop10Monthly.setInt(2, Utils.getMonthOfTheYear());
selectTop10Monthly.setInt(3, Utils.getYear());
ResultSet selectTop10MonthlyResults = selectTop10Monthly.executeQuery();
LinkedList<TopEntry> top10Monthly = new LinkedList<>();
while (selectTop10MonthlyResults.next()) {
top10Monthly.add(new TopEntry(selectTop10MonthlyResults.getString("name"), selectTop10MonthlyResults.getInt("stat")));
}
selectTop10MonthlyResults.close();
selectTop10Monthly.close();
return top10Monthly;
}
@Override
public LinkedList<TopEntry> getTop10AllTime(Connection connection) throws SQLException {
PreparedStatement selectTop10AllTime = connection.prepareStatement(LeaderboardQueries.SELECT_ALL_TIME);
selectTop10AllTime.setString(1, getStatName());
ResultSet selectTop10AllTimeResults = selectTop10AllTime.executeQuery();
LinkedList<TopEntry> top10AllTime = new LinkedList<>();
while (selectTop10AllTimeResults.next()) {
top10AllTime.add(new TopEntry(selectTop10AllTimeResults.getString("name"), selectTop10AllTimeResults.getInt("stat")));
}
selectTop10AllTimeResults.close();
selectTop10AllTime.close();
return top10AllTime;
}
@Override
public boolean hasWeeklyAndMonthlyStats() {
return true;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
| 6,986 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Statistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/Statistic.java | package me.patothebest.gamecore.stats;
import me.patothebest.gamecore.leaderboards.TopEntry;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.util.NameableObject;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;
public interface Statistic extends Listener, NameableObject {
void updateStat(Player player, int amount);
void updateStat(IPlayer player, int amount);
LinkedList<TopEntry> getTop10Weekly(Connection connection) throws SQLException;
LinkedList<TopEntry> getTop10Monthly(Connection connection) throws SQLException;
LinkedList<TopEntry> getTop10AllTime(Connection connection) throws SQLException;
boolean hasWeeklyAndMonthlyStats();
boolean isEnabled();
void setEnabled(boolean enabled);
String getStatName();
@Override
default String getName() {
return getStatName();
}
}
| 984 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsFlatFileEntity.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/storage/StatsFlatFileEntity.java | package me.patothebest.gamecore.stats.storage;
import com.google.inject.Inject;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.storage.StorageException;
import me.patothebest.gamecore.storage.flatfile.FlatFileEntity;
import me.patothebest.gamecore.storage.flatfile.PlayerProfileFile;
import me.patothebest.gamecore.stats.StatRecord;
import me.patothebest.gamecore.stats.Statistic;
import me.patothebest.gamecore.stats.StatsManager;
import me.patothebest.gamecore.stats.TrackedStatistic;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StatsFlatFileEntity implements FlatFileEntity {
private final StatsManager statsManager;
@Inject private StatsFlatFileEntity(StatsManager statsManager) {
this.statsManager = statsManager;
}
/**
* Loads a player's stats
*
* @param player the player loaded
* @param playerProfileFile the player's profile file
*/
@SuppressWarnings("unchecked")
@Override
public void loadPlayer(CorePlayer player, PlayerProfileFile playerProfileFile) throws StorageException {
if (!playerProfileFile.isSet("stats")) {
return;
}
if (true) {return; } // TODO: FIX
Map<String, List<Map<String, Object>>> stats = (Map<String, List<Map<String, Object>>>) playerProfileFile.get("stats");
stats.forEach((statType, records) -> {
Statistic statistic = statsManager.getStatisticByName(statType);
TrackedStatistic trackedStatistic = new TrackedStatistic();
player.getStatistics().put(statistic.getClass(), trackedStatistic);
for (Map<String, Object> record : records) {
StatRecord statRecord = new StatRecord(player.getPlayerId(), record);
trackedStatistic.getStatRecords().add(statRecord);
}
});
}
/**
* Saves a player's stats
*
* @param player the player being saved
* @param playerProfileFile the player's profile file
*/
@Override
public void savePlayer(CorePlayer player, PlayerProfileFile playerProfileFile) throws StorageException {
Map<String, List<Map<String, Object>>> statMap = new HashMap<>();
player.getStatistics().forEach((statisticType, trackedStatistic) -> {
List<Map<String, Object>> specificStats = new ArrayList<>();
for (StatRecord statRecord : trackedStatistic.getStatRecords()) {
specificStats.add(statRecord.serialize());
}
statMap.put(statsManager.getStatisticByClass(statisticType).getStatName(), specificStats);
});
if (!statMap.isEmpty()) {
playerProfileFile.set("stats", statMap);
}
}
}
| 2,828 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsMySQLEntity.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/storage/StatsMySQLEntity.java | package me.patothebest.gamecore.stats.storage;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.player.modifiers.PlayerModifier;
import me.patothebest.gamecore.player.modifiers.StatsModifier;
import me.patothebest.gamecore.storage.mysql.MySQLEntity;
import me.patothebest.gamecore.util.Utils;
import me.patothebest.gamecore.stats.StatRecord;
import me.patothebest.gamecore.stats.Statistic;
import me.patothebest.gamecore.stats.StatsManager;
import me.patothebest.gamecore.stats.TrackedStatistic;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* This class will handle all stats loading/saving
* for MySQL storage tpe
*/
@Singleton
public class StatsMySQLEntity implements MySQLEntity {
private final StatsManager statsManager;
@Inject private StatsMySQLEntity(StatsManager statsManager) {
this.statsManager = statsManager;
}
/**
* Loads a player's extra information
*
* @param player the player loaded
* @param connection connection
*/
@Override
public void loadPlayer(CorePlayer player, Connection connection) throws SQLException {
PreparedStatement preparedStatement = connection.prepareStatement(StatsQueries.SELECT);
preparedStatement.setInt(1, player.getPlayerId());
preparedStatement.setInt(2, Utils.getMonthOfTheYear());
preparedStatement.setInt(3, Utils.getYear());
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
StatRecord statRecord = new StatRecord(resultSet.getInt("entry_id"), player.getPlayerId(), resultSet.getString("stat_name"));
statRecord.setStats(resultSet.getInt("stat"));
statRecord.setWeek(resultSet.getInt("week"));
statRecord.setMonth(resultSet.getInt("month"));
statRecord.setYear(resultSet.getInt("year"));
Statistic statistic = statsManager.getStatisticByName(statRecord.getStatName());
if(statistic == null) {
continue;
}
if (!player.getStatistics().containsKey(statistic.getClass())) {
player.getStatistics().put(statistic.getClass(), new TrackedStatistic());
}
player.getStatistics().get(statistic.getClass()).getStatRecords().add(statRecord);
}
resultSet.close();
preparedStatement.close();
}
/**
* Saves a player's stats
* <p>
* Currently it's not used
*
* @param player the player to save
* @param connection the connection
*/
@Override
public void savePlayer(CorePlayer player, Connection connection) throws SQLException {
// TODO: Figure out if this is needed or not
}
/**
* Updates a player's stats.
* <p>
* The args must be {@link StatRecord} objects
*
* @param player the player
* @param connection the connection to use
* @param updatedType the updated part
* @param args the stat records to manipulate
*
* @throws SQLException in case any exceptions occur
*/
@Override
public void updatePlayer(CorePlayer player, Connection connection, PlayerModifier updatedType, Object... args) throws SQLException {
if (!(updatedType instanceof StatsModifier)) {
return;
}
if (updatedType == StatsModifier.INSERT) {
for (Object arg : args) {
StatRecord statRecord = (StatRecord) arg;
PreparedStatement statement = connection.prepareStatement(StatsQueries.INSERT, Statement.RETURN_GENERATED_KEYS);
statement.setInt(1, player.getPlayerId());
statement.setString(2, statRecord.getStatName());
statement.setInt(3, statRecord.getStats());
statement.setInt(4, statRecord.getWeek());
statement.setInt(5, statRecord.getMonth());
statement.setInt(6, statRecord.getYear());
statement.executeUpdate();
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
statRecord.setEntryId(rs.getInt(1));
} else {
throw new SQLException("Could not get the id of the newly inserted stat record!");
}
}
return;
}
if (updatedType == StatsModifier.UPDATE_ADD) {
PreparedStatement preparedStatement = connection.prepareStatement(StatsQueries.UPDATE);
for (int i = 1; i < args.length; i++) {
StatRecord statRecord = (StatRecord) args[i];
preparedStatement.setInt(1, (Integer) args[0]);
preparedStatement.setInt(2, statRecord.getEntryId());
preparedStatement.addBatch();
}
preparedStatement.executeBatch();
preparedStatement.close();
}
}
/**
* Gets all the statements needed to create the
* table(s) for the stats.
*
* @return the create table statements
*/
@Override
public String[] getCreateTableStatements() {
return new String[]{StatsQueries.CREATE_TABLE};
}
}
| 5,402 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
StatsQueries.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/storage/StatsQueries.java | package me.patothebest.gamecore.stats.storage;
import me.patothebest.gamecore.PluginConfig;
public class StatsQueries {
private final static String TABLE_NAME = PluginConfig.SQL_PREFIX + "_stats";
final static String CREATE_TABLE =
"CREATE TABLE IF NOT EXISTS `" + TABLE_NAME + "` (\n" +
" `entry_id` int(11) NOT NULL AUTO_INCREMENT,\n" +
" `player_id` int(11) NOT NULL DEFAULT 0,\n" +
" `stat_name` varchar(36) NOT NULL,\n" +
" `stat` int(11) NOT NULL,\n" +
" `week` int(11) NOT NULL,\n" +
" `month` int(11) NOT NULL,\n" +
" `year` int(11) NOT NULL,\n" +
" PRIMARY KEY (`entry_id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=latin1;";
final static String SELECT = "SELECT * FROM " + TABLE_NAME + " WHERE player_id=? AND (month=? OR month=0) AND (year=? OR year=0)";
final static String UPDATE = "UPDATE " + TABLE_NAME + " SET stat=stat+? WHERE entry_id=?";
final static String INSERT = "INSERT INTO " + TABLE_NAME + " VALUES (NULL, ?, ?, ?, ?, ?, ?)"; // (`entry_id`, `player_id`, `stat_name`, `stat`, `week`, `month`, `year`)
}
| 1,179 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
DeathStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/statistics/DeathStatistic.java | package me.patothebest.gamecore.stats.statistics;
import me.patothebest.gamecore.combat.CombatDeathEvent;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.stats.AbstractStatistic;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class DeathStatistic extends AbstractStatistic {
@EventHandler(priority = EventPriority.LOWEST)
public void onDeath(CombatDeathEvent event) {
Player player = event.getPlayer();
if(!getPlayer(player).isInArena()) {
return;
}
updateStat(player, 1);
((CorePlayer)playerManager.getPlayer(player)).addGameDeaths(1);
}
@Override
public String getStatName() {
return "deaths";
}
}
| 793 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
KillStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/statistics/KillStatistic.java | package me.patothebest.gamecore.stats.statistics;
import me.patothebest.gamecore.combat.CombatDeathEvent;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.stats.AbstractStatistic;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class KillStatistic extends AbstractStatistic {
@EventHandler(priority = EventPriority.LOWEST)
public void onDeath(CombatDeathEvent event) {
if (event.getKillerPlayer() != null && getPlayer(event.getKillerPlayer()) != null) {
updateStat(event.getKillerPlayer(), 1);
((CorePlayer)playerManager.getPlayer(event.getKillerPlayer())).addGameKills(1);
}
}
@Override
public String getStatName() {
return "kills";
}
}
| 782 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
LosesStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/statistics/LosesStatistic.java | package me.patothebest.gamecore.stats.statistics;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.event.arena.GameEndEvent;
import me.patothebest.gamecore.event.player.PlayerLooseEvent;
import me.patothebest.gamecore.stats.AbstractStatistic;
import org.bukkit.event.EventHandler;
public class LosesStatistic extends AbstractStatistic {
@EventHandler
public void onGameEnd(GameEndEvent event) {
event.getLosers().forEach(loser -> {
IPlayer player = getPlayer(loser);
if(player == null) {
return;
}
updateStat(player, 1);
});
}
@EventHandler
public void onLoose(PlayerLooseEvent event){
updateStat(event.getPlayer(), 1);
}
@Override
public String getStatName() {
return "loses";
}
}
| 849 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
BlocksPlacedStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/statistics/BlocksPlacedStatistic.java | package me.patothebest.gamecore.stats.statistics;
import me.patothebest.gamecore.stats.AbstractStatistic;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
public class BlocksPlacedStatistic extends AbstractStatistic {
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if(!getPlayer(player).isInArena()) {
return;
}
updateStat(player, 1);
}
@Override
public String getStatName() {
return "blocks_placed";
}
}
| 680 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
WinsStatistic.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/stats/statistics/WinsStatistic.java | package me.patothebest.gamecore.stats.statistics;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.event.arena.GameEndEvent;
import me.patothebest.gamecore.stats.AbstractStatistic;
import org.bukkit.event.EventHandler;
public class WinsStatistic extends AbstractStatistic {
@EventHandler
public void onGameEnd(GameEndEvent event) {
event.getWinners().forEach(winner -> {
IPlayer player = playerManager.getPlayer(winner);
if(player == null) {
return;
}
updateStat(player, 1);
});
}
@Override
public String getStatName() {
return "wins";
}
}
| 686 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PlayerObserver.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/PlayerObserver.java | package me.patothebest.gamecore.util;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.player.modifiers.PlayerModifier;
/**
* A class can implement the <code>PlayerObserver</code> interface when it
* wants to be informed of changes in observable objects.
*/
public interface PlayerObserver {
/**
* This method is called whenever the observed object is changed. An
* application calls an <tt>ObservablePlayer</tt> object's
* <code>notifyObservers</code> method to have all the object's
* observers notified of the change.
*
* @param o the observable object.
* @param updatedValue the updated type
*/
void update(CorePlayer o, PlayerModifier updatedValue, Object... extraArgs);
}
| 770 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
IndexedFunction.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/IndexedFunction.java | package me.patothebest.gamecore.util;
@FunctionalInterface
public interface IndexedFunction<T, R> {
R apply(T t, int index);
} | 131 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CryptoUtil.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/CryptoUtil.java | package me.patothebest.gamecore.util;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Base64;
public class CryptoUtil {
// 8-byte Salt
private final byte[] salt = {
(byte) 0xA9, (byte) 0x9B, (byte) 0xC8, (byte) 0x32,
(byte) 0x56, (byte) 0x35, (byte) 0xE3, (byte) 0x03
};
/**
* @param secretKey Key used to decrypt data
* @param encryptedText encrypted text input to decrypt
* @return Returns plain text after decryption
*/
public String decrypt(String secretKey, String encryptedText) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IOException {
//Key generation for enc and desc
int iterationCount = 19;
KeySpec keySpec = new PBEKeySpec(secretKey.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
//Decryption process; same key will be used for decr
Cipher dcipher = Cipher.getInstance(key.getAlgorithm());
dcipher.init(2, key,paramSpec);
byte[] enc = Base64.getDecoder().decode(encryptedText);
byte[] utf8 = dcipher.doFinal(enc);
String charSet="UTF-8";
return new String(utf8, charSet);
}
/**
* @param secretKey Key used to decrypt data
* @param encryptedText encrypted text input to decrypt
* @return Returns plain text after decryption
*/
public String decryptSilently(String secretKey, String encryptedText) {
try {
return decrypt(secretKey, encryptedText);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
} | 2,511 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
RunningRunnable.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/RunningRunnable.java | package me.patothebest.gamecore.util;
public final class RunningRunnable extends WrappedBukkitRunnable {
private final Runnable runnable;
public RunningRunnable(Runnable runnable) {
this.runnable = runnable;
}
@Override
public void run() {
runnable.run();
}
}
| 304 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
MessageCallback.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/MessageCallback.java | package me.patothebest.gamecore.util;
public interface MessageCallback<T> {
String call(T t) ;
} | 103 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Callback.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/Callback.java | package me.patothebest.gamecore.util;
public interface Callback<T> {
void call(T t) ;
} | 94 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ThrowableCallback.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ThrowableCallback.java | package me.patothebest.gamecore.util;
public interface ThrowableCallback<T, E extends Throwable> {
void call(T t) throws E;
} | 132 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
NameableObject.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/NameableObject.java | package me.patothebest.gamecore.util;
/**
* An interface for all objects that should implement the
* getName() method. This is useful especially for abstract
* classes and utility methods that their function is, for
* example, transform a collection of objects to a collection
* of strings that are the names of the objects.
*/
public interface NameableObject {
String getName();
}
| 395 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
PlayerList.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/PlayerList.java | package me.patothebest.gamecore.util;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class PlayerList implements Set<Player> {
private final Map<Integer, Player> players = new ConcurrentHashMap<>();
@Override
public int size() {
return players.size();
}
@Override
public boolean isEmpty() {
return players.isEmpty();
}
@Override
public boolean contains(Object o) {
if (!(o instanceof Player)) {
return false;
}
return players.containsKey(((Player)o).getEntityId());
}
@NotNull
@Override
public Iterator<Player> iterator() {
return players.values().iterator();
}
@Override
public Object[] toArray() {
return players.values().toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return players.values().toArray(a);
}
@Override
public boolean add(Player player) {
players.put(player.getEntityId(), player);
return true;
}
@Override
public boolean remove(Object o) {
if (!(o instanceof Player)) {
throw new IllegalArgumentException("Expected player but instead got: " + o.getClass());
}
return players.remove(((Player)o).getEntityId()) != null;
}
@Override
public boolean containsAll(Collection<?> c) {
return players.values().containsAll(c);
}
@Override
public boolean addAll(Collection<? extends Player> c) {
for (Player player : c) {
add(player);
}
return true;
}
@Override
public boolean removeAll(Collection<?> c) {
for (Object o : c) {
remove(o);
}
return true;
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
players.clear();
}
public List<Player> toJavaList() {
return new ArrayList<>(players.values());
}
} | 2,257 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ReflectionUtil.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ReflectionUtil.java | /*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.patothebest.gamecore.util;
import java.lang.reflect.Field;
/**
* @author zml2008
*/
public final class ReflectionUtil {
private ReflectionUtil() {
}
@SuppressWarnings("unchecked")
public static <T> T getField(Object from, String name) {
Class<?> checkClass = from.getClass();
do {
try {
Field field = checkClass.getDeclaredField(name);
field.setAccessible(true);
return (T) field.get(from);
} catch (Exception e) {
}
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
return null;
}
}
| 1,522 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
FinalSupplier.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/FinalSupplier.java | package me.patothebest.gamecore.util;
import java.util.function.Supplier;
public class FinalSupplier<T> implements Supplier<T> {
private final T object;
public FinalSupplier(T object) {
this.object = object;
}
@Override
public T get() {
return object;
}
}
| 301 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ThrowableBiConsumer.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ThrowableBiConsumer.java | package me.patothebest.gamecore.util;
import java.util.function.BiConsumer;
@FunctionalInterface
public interface ThrowableBiConsumer<K, V> extends BiConsumer<K, V> {
default void accept(K k, V v) {
try {
acceptThrows(k, v);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
void acceptThrows(K k, V v) throws Exception;
}
| 403 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CommandUtils.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/CommandUtils.java | package me.patothebest.gamecore.util;
import me.patothebest.gamecore.arena.AbstractArena;
import me.patothebest.gamecore.arena.AbstractGameTeam;
import me.patothebest.gamecore.command.CommandContext;
import me.patothebest.gamecore.command.CommandException;
import me.patothebest.gamecore.lang.CoreLang;
import me.patothebest.gamecore.lang.interfaces.ILang;
import me.patothebest.gamecore.player.IPlayer;
import me.patothebest.gamecore.player.PlayerManager;
import me.patothebest.gamecore.arena.ArenaManager;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class CommandUtils {
public static void validateNotNull(Object object, String message) throws CommandException {
if(object == null) {
throw new CommandException(message);
}
}
public static void validateTrue(boolean isTrue, String message) throws CommandException {
if(!isTrue) {
throw new CommandException(message);
}
}
public static void validateNotNull(Object object, ILang message) throws CommandException {
if(object == null) {
throw new CommandException(message);
}
}
public static void validateTrue(boolean isTrue, ILang message) throws CommandException {
if(!isTrue) {
throw new CommandException(message);
}
}
public static List<String> complete(String string, Enum[] values) {
return complete(string, Stream.of(values).map(Enum::name).collect(Collectors.toList()));
}
public static List<String> complete(String startingString, ArenaManager arenaManager) {
return completeNameable(startingString, arenaManager.getArenas().values());
}
public static List<String> completeNameable(String startingString, Collection<? extends NameableObject> listOfObjects) {
return complete(startingString, Utils.toList(listOfObjects));
}
public static List<String> completeNameable(String startingString, List<? extends NameableObject> listOfObjects) {
return complete(startingString, Utils.toList(listOfObjects));
}
public static List<String> completePlayers(String startingString) {
return StringUtil.complete(startingString, Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()));
}
public static List<String> complete(String startingString, Iterable<String> completableStrings) {
return StringUtil.complete(startingString, completableStrings);
}
public static Player getPlayer(CommandSender sender) throws CommandException {
if(sender instanceof Player) {
return (Player) sender;
}
throw new CommandException("This command can only be executed by players!");
}
public static Player getPlayer(CommandContext args, int arg) throws CommandException {
Player player = Bukkit.getPlayer(args.getString(arg));
if(player == null) {
throw new CommandException("El jugador '" + args.getString(arg) + "' no esta en linea!");
}
return player;
}
public static <Arena extends AbstractArena> Arena getArena(CommandContext args, int arg, ArenaManager arenaManager) throws CommandException {
Arena arena = (Arena) arenaManager.getArena(args.getString(arg));
if(arena == null) {
throw new CommandException(CoreLang.ARENA_DOES_NOT_EXIST);
}
return arena;
}
public static <Arena extends AbstractArena> Arena getDisabledArena(CommandContext args, int arg, ArenaManager arenaManager) throws CommandException {
Arena arena = getArena(args, arg, arenaManager);
if(arena.isEnabled()) {
throw new CommandException(CoreLang.DISABLE_ARENA_FIRST);
}
return arena;
}
public static <Arena extends AbstractArena> Arena getEnabledArena(CommandContext args, int arg, ArenaManager arenaManager) throws CommandException {
Arena arena = getArena(args, arg, arenaManager);
if(!arena.isEnabled()) {
throw new CommandException(CoreLang.ENABLE_ARENA_FIRST);
}
return arena;
}
public static AbstractGameTeam getTeam(AbstractArena arena, CommandContext args, int arg) throws CommandException {
AbstractGameTeam gameTeam = arena.getTeam(args.getString(arg));
if(gameTeam == null) {
throw new CommandException(CoreLang.TEAM_DOES_NOT_EXIST);
}
return gameTeam;
}
public static Player getPlayer(CommandContext args, int arg, Player fallback) throws CommandException {
if(!args.isInBounds(arg)) {
return fallback;
}
Player player = Bukkit.getPlayer(args.getString(arg));
if(player == null) {
throw new CommandException("The player '" + args.getString(arg) + "' is not online!");
}
return player;
}
public static IPlayer getPlayer(CommandContext args, PlayerManager playerManager, int arg) throws CommandException {
IPlayer player = playerManager.getPlayer(args.getString(arg));
if(player == null) {
throw new CommandException("The player '" + args.getString(arg) + "' is not online!");
}
return player;
}
public static <E extends Enum<E>> E getEnumValueFromString(Class<E> enumClass, String enumString, ILang errorMessage) throws CommandException {
for (E enumElement : EnumSet.allOf(enumClass)) {
if (enumElement.name().equalsIgnoreCase(enumString)) {
return enumElement;
}
}
throw new CommandException(errorMessage);
}
}
| 5,847 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CancellationDetector.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/CancellationDetector.java | package me.patothebest.gamecore.util;
import com.google.common.collect.Lists;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredListener;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
public class CancellationDetector<TEvent extends Event> {
public interface ChangedStatusListener<TEvent extends Event> {
void onCancelled(Plugin plugin, TEvent event, Listener listener);
}
private final Class<TEvent> eventClazz;
private final List<ChangedStatusListener<TEvent>> listeners = Lists.newArrayList();
// For reverting the detector
private EnumMap<EventPriority, ArrayList<RegisteredListener>> backup;
public CancellationDetector(Class<TEvent> eventClazz) {
this.eventClazz = eventClazz;
injectProxy();
}
public void addListener(ChangedStatusListener<TEvent> listener) {
listeners.add(listener);
}
public void removeListener(ChangedStatusListener<TEvent> listener) {
listeners.remove(listener);
}
@SuppressWarnings("unchecked")
private EnumMap<EventPriority, ArrayList<RegisteredListener>> getSlots(HandlerList list) {
try {
return (EnumMap<EventPriority, ArrayList<RegisteredListener>>) getSlotsField(list).get(list);
} catch (Exception e) {
throw new RuntimeException("Unable to retrieve slots.", e);
}
}
private Field getSlotsField(HandlerList list) {
if (list == null)
throw new IllegalStateException("Detected a NULL handler list.");
try {
Field slotField = list.getClass().getDeclaredField("handlerslots");
// Get our slot map
slotField.setAccessible(true);
return slotField;
} catch (Exception e) {
throw new IllegalStateException("Unable to intercept 'handlerslot' in " + list.getClass(), e);
}
}
private void injectProxy() {
HandlerList list = getHandlerList(eventClazz);
EnumMap<EventPriority, ArrayList<RegisteredListener>> slots = getSlots(list);
// Keep a copy of this map
backup = slots.clone();
synchronized (list) {
for (EventPriority p : slots.keySet().toArray(new EventPriority[0])) {
final EventPriority priority = p;
final ArrayList<RegisteredListener> proxyList = new ArrayList<RegisteredListener>() {
private static final long serialVersionUID = 7869505892922082581L;
@Override
public boolean add(RegisteredListener e) {
super.add(injectRegisteredListener(e));
return backup.get(priority).add(e);
}
@Override
public boolean remove(Object listener) {
// Remove this listener
for (Iterator<RegisteredListener> it = iterator(); it.hasNext(); ) {
DelegatedRegisteredListener delegated = (DelegatedRegisteredListener) it.next();
if (delegated.delegate == listener) {
it.remove();
break;
}
}
return backup.get(priority).remove(listener);
}
};
slots.put(priority, proxyList);
proxyList.addAll(backup.get(priority));
}
}
}
// The core of our magic
private RegisteredListener injectRegisteredListener(final RegisteredListener listener) {
return new DelegatedRegisteredListener(listener) {
@SuppressWarnings("unchecked")
@Override
public void callEvent(Event event) throws EventException {
if (event instanceof Cancellable) {
boolean prior = getCancelState(event);
listener.callEvent(event);
// See if this plugin cancelled the event
if (prior != getCancelState(event)) {
invokeChangedStatus(getPlugin(), (TEvent) event, listener.getListener());
}
} else {
listener.callEvent(event);
}
}
};
}
private void invokeChangedStatus(Plugin plugin, TEvent event, Listener listenerObject) {
for (ChangedStatusListener<TEvent> listener : listeners) {
listener.onCancelled(plugin, event, listenerObject);
}
}
private boolean getCancelState(Event event) {
return ((Cancellable) event).isCancelled();
}
public void close() {
if (backup != null) {
try {
HandlerList list = getHandlerList(eventClazz);
getSlotsField(list).set(list, backup);
Field handlers = list.getClass().getDeclaredField("handlers");
handlers.setAccessible(true);
handlers.set(list, null);
} catch (Exception e) {
throw new RuntimeException("Unable to clean up handler list.", e);
}
backup = null;
}
}
/**
* Retrieve the handler list associated with the given class.
*
* @param clazz - given event class.
* @return Associated handler list.
*/
private static HandlerList getHandlerList(Class<? extends Event> clazz) {
// Class must have Event as its superclass
while (clazz.getSuperclass() != null && Event.class.isAssignableFrom(clazz.getSuperclass())) {
try {
Method method = clazz.getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (NoSuchMethodException e) {
// Keep on searching
clazz = clazz.getSuperclass().asSubclass(Event.class);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.getMessage());
}
}
throw new IllegalPluginAccessException("Unable to find handler list for event "
+ clazz.getName());
}
/**
* Represents a registered listener that delegates to a given listener.
* @author Kristian
*/
private static class DelegatedRegisteredListener extends RegisteredListener {
private final RegisteredListener delegate;
public DelegatedRegisteredListener(RegisteredListener delegate) {
// These values will be ignored however'
super(delegate.getListener(), null, delegate.getPriority(), delegate.getPlugin(), false);
this.delegate = delegate;
}
public void callEvent(Event event) throws EventException {
delegate.callEvent(event);
}
public Listener getListener() {
return delegate.getListener();
}
public Plugin getPlugin() {
return delegate.getPlugin();
}
public EventPriority getPriority() {
return delegate.getPriority();
}
public boolean isIgnoringCancelled() {
return delegate.isIgnoringCancelled();
}
}
} | 7,882 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ThrowOnce.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ThrowOnce.java | package me.patothebest.gamecore.util;
import java.util.ArrayList;
import java.util.List;
public class ThrowOnce {
private static final List<Throwable> throwables = new ArrayList<>();
public static void printOnce(Throwable throwable) {
if(throwables.contains(throwable)) {
return;
}
throwables.add(throwable);
throwable.printStackTrace();
}
public static void throwOnce(Throwable throwable) {
if(throwables.contains(throwable)) {
return;
}
throwables.add(throwable);
throw sneakyThrow(throwable);
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> RuntimeException sneakyThrow(Throwable t) throws T {
throw (T)t;
}
}
| 771 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ElementAction.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ElementAction.java | package me.patothebest.gamecore.util;
public enum ElementAction {
ADD,
REMOVE,
MODIFY
}
| 103 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CallableCallback.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/CallableCallback.java | package me.patothebest.gamecore.util;
public interface CallableCallback<T> {
T call(T t);
}
| 99 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Priority.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/Priority.java | package me.patothebest.gamecore.util;
public enum Priority {
LOWEST,
LOW,
NORMAL,
HIGH,
HIGHEST
}
| 121 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ObservablePlayerImpl.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ObservablePlayerImpl.java | package me.patothebest.gamecore.util;
import me.patothebest.gamecore.player.CorePlayer;
import me.patothebest.gamecore.player.modifiers.PlayerModifier;
import java.util.Vector;
public class ObservablePlayerImpl implements ObservablePlayer {
private final Vector<PlayerObserver> obs;
/**
* Construct an ObservablePlayer with zero Observers.
*/
public ObservablePlayerImpl() {
obs = new Vector<>();
}
@Override
public synchronized void addObserver(PlayerObserver o) {
if (o == null)
throw new NullPointerException();
if (!obs.contains(o)) {
obs.addElement(o);
}
}
@Override
public synchronized void deleteObserver(PlayerObserver o) {
obs.removeElement(o);
}
@Override
public void notifyObservers(PlayerModifier modifiedType, Object... args) {
/*
* a temporary array buffer, used as a snapshot of the state of
* current Observers.
*/
Object[] arrLocal;
synchronized (this) {
/* We don't want the PlayerObserver doing callbacks into
* arbitrary code while holding its own Monitor.
* The code where we extract each ObservablePlayer from
* the Vector and store the state of the PlayerObserver
* needs synchronization, but notifying observers
* does not (should not). The worst result of any
* potential race-condition here is that:
* 1) a newly-added PlayerObserver will miss a
* notification in progress
* 2) a recently unregistered PlayerObserver will be
* wrongly notified when it doesn't care
*/
arrLocal = obs.toArray();
}
for (Object anArrLocal : arrLocal) {
((PlayerObserver) anArrLocal).update((CorePlayer) this, modifiedType, args);
}
}
@Override
public synchronized void deleteObservers() {
obs.removeAllElements();
}
@Override
public synchronized int countObservers() {
return obs.size();
}
}
| 2,136 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Levenshtein.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/Levenshtein.java | package me.patothebest.gamecore.util;
public class Levenshtein {
public static String getClosestString(String input, String[] options) {
int lowestDistance = 10;
String lowest = "";
for(String s : options) {
int distance = getLevenshteinDistance(input, s);
if(distance < lowestDistance) {
lowestDistance = distance;
lowest = s;
}
}
return lowest;
}
private static int getLevenshteinDistance(String s, String t) {
if (s == null || t == null) {
return 11;
}
int n = s.length();
int m = t.length();
if (n == 0) {
return m;
} else if (m == 0) {
return n;
}
if (n > m) {
String tmp = s;
s = t;
t = tmp;
n = m;
m = t.length();
}
int[] p = new int[n + 1];
int[] d = new int[n + 1];
int[] _d;
int i;
int j;
char t_j;
int cost;
for (i = 0; i<=n; i++) {
p[i] = i;
}
for (j = 1; j<=m; j++) {
t_j = t.charAt(j-1);
d[0] = j;
for (i=1; i<=n; i++) {
cost = s.charAt(i-1)==t_j ? 0 : 1;
d[i] = Math.min(Math.min(d[i-1]+1, p[i]+1), p[i-1]+cost);
}
_d = p;
p = d;
d = _d;
}
return p[n];
}
} | 1,505 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Sounds.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/Sounds.java | /*
* The MIT License (MIT)
*
* Copyright (c) 2020 Crypto Morin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package me.patothebest.gamecore.util;
import com.google.common.base.Enums;
import com.google.common.base.Strings;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
/**
* <b>XSound</b> - Universal Minecraft Sound Support<br>
* 1.13 and above as priority.
* <p>
* Sounds are thread-safe. But this doesn't mean you should
* use a bukkit async scheduler for every {@link Player#playSound} call.
* <p>
* <b>Volume:</b> 0.0-∞ - 1.0f (normal) - Using higher values increase the distance from which the sound can be heard.<br>
* <b>Pitch:</b> 0.5-2.0 - 1.0f (normal) - How fast the sound is play.
* <p>
* 1.8: http://docs.codelanx.com/Bukkit/1.8/org/bukkit/Sound.html
* Latest: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
* Basics: https://bukkit.org/threads/151517/
* play command: https://minecraft.gamepedia.com/Commands/play
*
* @author Crypto Morin
* @version 3.0.0
* @see Sound
*/
public enum Sounds {
AMBIENT_CAVE("AMBIENCE_CAVE"),
AMBIENT_UNDERWATER_ENTER,
AMBIENT_UNDERWATER_EXIT,
AMBIENT_UNDERWATER_LOOP("AMBIENT_UNDERWATER_EXIT"),
AMBIENT_UNDERWATER_LOOP_ADDITIONS("AMBIENT_UNDERWATER_EXIT"),
AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE("AMBIENT_UNDERWATER_EXIT"),
AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE("AMBIENT_UNDERWATER_EXIT"),
BLOCK_ANVIL_BREAK("ANVIL_BREAK"),
BLOCK_ANVIL_DESTROY,
BLOCK_ANVIL_FALL,
BLOCK_ANVIL_HIT("BLOCK_ANVIL_FALL"),
BLOCK_ANVIL_LAND("ANVIL_LAND"),
BLOCK_ANVIL_PLACE("BLOCK_ANVIL_FALL"),
BLOCK_ANVIL_STEP("BLOCK_ANVIL_FALL"),
BLOCK_ANVIL_USE("ANVIL_USE"),
BLOCK_BAMBOO_BREAK,
BLOCK_BAMBOO_FALL,
BLOCK_BAMBOO_HIT,
BLOCK_BAMBOO_PLACE,
BLOCK_BAMBOO_SAPLING_BREAK,
BLOCK_BAMBOO_SAPLING_HIT,
BLOCK_BAMBOO_SAPLING_PLACE,
BLOCK_BAMBOO_STEP,
BLOCK_BARREL_CLOSE,
BLOCK_BARREL_OPEN,
BLOCK_BEACON_ACTIVATE,
BLOCK_BEACON_AMBIENT,
BLOCK_BEACON_DEACTIVATE("BLOCK_BEACON_AMBIENT"),
BLOCK_BEACON_POWER_SELECT("BLOCK_BEACON_AMBIENT"),
BLOCK_BEEHIVE_DRIP,
BLOCK_BEEHIVE_ENTER,
BLOCK_BEEHIVE_EXIT,
BLOCK_BEEHIVE_SHEAR,
BLOCK_BEEHIVE_WORK,
BLOCK_BELL_RESONATE,
BLOCK_BELL_USE,
BLOCK_BLASTFURNACE_FIRE_CRACKLE,
BLOCK_BREWING_STAND_BREW,
BLOCK_BUBBLE_COLUMN_BUBBLE_POP,
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT,
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE,
BLOCK_CAMPFIRE_CRACKLE,
BLOCK_CHEST_CLOSE("CHEST_CLOSE", "ENTITY_CHEST_CLOSE"),
BLOCK_CHEST_LOCKED,
BLOCK_CHEST_OPEN("CHEST_OPEN", "ENTITY_CHEST_OPEN"),
BLOCK_CHORUS_FLOWER_DEATH,
BLOCK_CHORUS_FLOWER_GROW,
BLOCK_COMPARATOR_CLICK,
BLOCK_COMPOSTER_EMPTY,
BLOCK_COMPOSTER_FILL,
BLOCK_COMPOSTER_FILL_SUCCESS,
BLOCK_COMPOSTER_READY,
BLOCK_CONDUIT_ACTIVATE,
BLOCK_CONDUIT_AMBIENT,
BLOCK_CONDUIT_AMBIENT_SHORT,
BLOCK_CONDUIT_ATTACK_TARGET,
BLOCK_CONDUIT_DEACTIVATE,
BLOCK_CORAL_BLOCK_BREAK,
BLOCK_CORAL_BLOCK_FALL,
BLOCK_CORAL_BLOCK_HIT,
BLOCK_CORAL_BLOCK_PLACE,
BLOCK_CORAL_BLOCK_STEP,
BLOCK_CROP_BREAK,
BLOCK_DISPENSER_DISPENSE,
BLOCK_DISPENSER_FAIL,
BLOCK_DISPENSER_LAUNCH,
BLOCK_ENCHANTMENT_TABLE_USE,
BLOCK_ENDER_CHEST_CLOSE,
BLOCK_ENDER_CHEST_OPEN,
BLOCK_END_GATEWAY_SPAWN,
BLOCK_END_PORTAL_FRAME_FILL,
BLOCK_END_PORTAL_SPAWN,
BLOCK_FENCE_GATE_CLOSE,
BLOCK_FENCE_GATE_OPEN,
BLOCK_FIRE_AMBIENT("FIRE"),
BLOCK_FIRE_EXTINGUISH("FIZZ"),
BLOCK_FURNACE_FIRE_CRACKLE,
BLOCK_GLASS_BREAK("GLASS"),
BLOCK_GLASS_FALL,
BLOCK_GLASS_HIT,
BLOCK_GLASS_PLACE,
BLOCK_GLASS_STEP,
BLOCK_GRASS_BREAK("DIG_GRASS"),
BLOCK_GRASS_FALL,
BLOCK_GRASS_HIT,
BLOCK_GRASS_PLACE,
BLOCK_GRASS_STEP("STEP_GRASS"),
BLOCK_GRAVEL_BREAK("DIG_GRAVEL"),
BLOCK_GRAVEL_FALL,
BLOCK_GRAVEL_HIT,
BLOCK_GRAVEL_PLACE,
BLOCK_GRAVEL_STEP("STEP_GRAVEL"),
BLOCK_GRINDSTONE_USE,
BLOCK_HONEY_BLOCK_BREAK,
BLOCK_HONEY_BLOCK_FALL,
BLOCK_HONEY_BLOCK_HIT,
BLOCK_HONEY_BLOCK_PLACE,
BLOCK_HONEY_BLOCK_SLIDE,
BLOCK_HONEY_BLOCK_STEP,
BLOCK_IRON_DOOR_CLOSE,
BLOCK_IRON_DOOR_OPEN,
BLOCK_IRON_TRAPDOOR_CLOSE,
BLOCK_IRON_TRAPDOOR_OPEN,
BLOCK_LADDER_BREAK,
BLOCK_LADDER_FALL,
BLOCK_LADDER_HIT,
BLOCK_LADDER_PLACE,
BLOCK_LADDER_STEP("STEP_LADDER"),
BLOCK_LANTERN_BREAK,
BLOCK_LANTERN_FALL,
BLOCK_LANTERN_HIT,
BLOCK_LANTERN_PLACE,
BLOCK_LANTERN_STEP,
BLOCK_LAVA_AMBIENT("LAVA"),
BLOCK_LAVA_EXTINGUISH,
BLOCK_LAVA_POP("LAVA_POP"),
BLOCK_LEVER_CLICK,
BLOCK_LILY_PAD_PLACE("BLOCK_WATERLILY_PLACE"),
BLOCK_METAL_BREAK,
BLOCK_METAL_FALL,
BLOCK_METAL_HIT,
BLOCK_METAL_PLACE,
BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF("BLOCK_METAL_PRESSUREPLATE_CLICK_OFF"),
BLOCK_METAL_PRESSURE_PLATE_CLICK_ON("BLOCK_METAL_PRESSUREPLATE_CLICK_ON"),
BLOCK_METAL_STEP,
BLOCK_NETHER_WART_BREAK,
BLOCK_NOTE_BLOCK_BANJO,
BLOCK_NOTE_BLOCK_BASEDRUM("NOTE_BASS_DRUM", "BLOCK_NOTE_BASEDRUM"),
BLOCK_NOTE_BLOCK_BASS("NOTE_BASS", "BLOCK_NOTE_BASS"),
BLOCK_NOTE_BLOCK_BELL("BLOCK_NOTE_BELL"),
BLOCK_NOTE_BLOCK_BIT,
BLOCK_NOTE_BLOCK_CHIME("BLOCK_NOTE_CHIME"),
BLOCK_NOTE_BLOCK_COW_BELL,
BLOCK_NOTE_BLOCK_DIDGERIDOO,
BLOCK_NOTE_BLOCK_FLUTE("BLOCK_NOTE_FLUTE"),
BLOCK_NOTE_BLOCK_GUITAR("NOTE_BASS_GUITAR", "BLOCK_NOTE_GUITAR"),
BLOCK_NOTE_BLOCK_HARP("NOTE_PIANO", "BLOCK_NOTE_HARP"),
BLOCK_NOTE_BLOCK_HAT("NOTE_STICKS", "BLOCK_NOTE_HAT"),
BLOCK_NOTE_BLOCK_IRON_XYLOPHONE,
BLOCK_NOTE_BLOCK_PLING("NOTE_PLING", "BLOCK_NOTE_PLING"),
BLOCK_NOTE_BLOCK_SNARE("NOTE_SNARE_DRUM", "BLOCK_NOTE_SNARE"),
BLOCK_NOTE_BLOCK_XYLOPHONE("BLOCK_NOTE_XYLOPHONE"),
BLOCK_PISTON_CONTRACT("PISTON_RETRACT"),
BLOCK_PISTON_EXTEND("PISTON_EXTEND"),
BLOCK_PORTAL_AMBIENT("PORTAL"),
BLOCK_PORTAL_TRAVEL("PORTAL_TRAVEL"),
BLOCK_PORTAL_TRIGGER("PORTAL_TRIGGER"),
BLOCK_PUMPKIN_CARVE,
BLOCK_REDSTONE_TORCH_BURNOUT,
BLOCK_SAND_BREAK("DIG_SAND"),
BLOCK_SAND_FALL,
BLOCK_SAND_HIT,
BLOCK_SAND_PLACE,
BLOCK_SAND_STEP("STEP_SAND"),
BLOCK_SCAFFOLDING_BREAK,
BLOCK_SCAFFOLDING_FALL,
BLOCK_SCAFFOLDING_HIT,
BLOCK_SCAFFOLDING_PLACE,
BLOCK_SCAFFOLDING_STEP,
BLOCK_SHULKER_BOX_CLOSE,
BLOCK_SHULKER_BOX_OPEN,
BLOCK_SLIME_BLOCK_BREAK("BLOCK_SLIME_BREAK"),
BLOCK_SLIME_BLOCK_FALL("BLOCK_SLIME_FALL"),
BLOCK_SLIME_BLOCK_HIT("BLOCK_SLIME_HIT"),
BLOCK_SLIME_BLOCK_PLACE("BLOCK_SLIME_PLACE"),
BLOCK_SLIME_BLOCK_STEP("BLOCK_SLIME_STEP"),
BLOCK_SMOKER_SMOKE,
BLOCK_SNOW_BREAK("DIG_SNOW"),
BLOCK_SNOW_FALL,
BLOCK_SNOW_HIT,
BLOCK_SNOW_PLACE,
BLOCK_SNOW_STEP("STEP_SNOW"),
BLOCK_STONE_BREAK("DIG_STONE"),
BLOCK_STONE_BUTTON_CLICK_OFF,
BLOCK_STONE_BUTTON_CLICK_ON,
BLOCK_STONE_FALL,
BLOCK_STONE_HIT,
BLOCK_STONE_PLACE,
BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF("BLOCK_STONE_PRESSUREPLATE_CLICK_OFF"),
BLOCK_STONE_PRESSURE_PLATE_CLICK_ON("BLOCK_STONE_PRESSUREPLATE_CLICK_ON"),
BLOCK_STONE_STEP("STEP_STONE"),
BLOCK_SWEET_BERRY_BUSH_BREAK,
BLOCK_SWEET_BERRY_BUSH_PLACE,
BLOCK_TRIPWIRE_ATTACH,
BLOCK_TRIPWIRE_CLICK_OFF,
BLOCK_TRIPWIRE_CLICK_ON,
BLOCK_TRIPWIRE_DETACH,
BLOCK_WATER_AMBIENT("WATER"),
BLOCK_WET_GRASS_BREAK,
BLOCK_WET_GRASS_FALL,
BLOCK_WET_GRASS_HIT,
BLOCK_WET_GRASS_PLACE("BLOCK_WET_GRASS_HIT"),
BLOCK_WET_GRASS_STEP("BLOCK_WET_GRASS_HIT"),
BLOCK_WOODEN_BUTTON_CLICK_OFF("WOOD_CLICK", "BLOCK_WOOD_BUTTON_CLICK_OFF"),
BLOCK_WOODEN_BUTTON_CLICK_ON("WOOD_CLICK", "BLOCK_WOOD_BUTTON_CLICK_ON"),
BLOCK_WOODEN_DOOR_CLOSE("DOOR_CLOSE"),
BLOCK_WOODEN_DOOR_OPEN("DOOR_OPEN"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF("BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON("BLOCK_WOOD_PRESSUREPLATE_CLICK_ON"),
BLOCK_WOODEN_TRAPDOOR_CLOSE,
BLOCK_WOODEN_TRAPDOOR_OPEN,
BLOCK_WOOD_BREAK("DIG_WOOD"),
BLOCK_WOOD_FALL,
BLOCK_WOOD_HIT,
BLOCK_WOOD_PLACE,
BLOCK_WOOD_STEP("STEP_WOOD"),
BLOCK_WOOL_BREAK("DIG_WOOL", "BLOCK_CLOTH_BREAK"),
BLOCK_WOOL_FALL,
BLOCK_WOOL_HIT("BLOCK_WOOL_FALL"),
BLOCK_WOOL_PLACE("BLOCK_WOOL_FALL"),
BLOCK_WOOL_STEP("STEP_WOOL", "BLOCK_CLOTH_STEP"),
ENCHANT_THORNS_HIT,
ENTITY_ARMOR_STAND_BREAK("ENTITY_ARMORSTAND_BREAK"),
ENTITY_ARMOR_STAND_FALL("ENTITY_ARMORSTAND_FALL"),
ENTITY_ARMOR_STAND_HIT("ENTITY_ARMORSTAND_HIT"),
ENTITY_ARMOR_STAND_PLACE("ENTITY_ARMORSTAND_PLACE"),
ENTITY_ARROW_HIT("ARROW_HIT"),
ENTITY_ARROW_HIT_PLAYER("SUCCESSFUL_HIT"),
ENTITY_ARROW_SHOOT("SHOOT_ARROW"),
ENTITY_BAT_AMBIENT("BAT_IDLE"),
ENTITY_BAT_DEATH("BAT_DEATH"),
ENTITY_BAT_HURT("BAT_HURT"),
ENTITY_BAT_LOOP("BAT_LOOP"),
ENTITY_BAT_TAKEOFF("BAT_TAKEOFF"),
ENTITY_BEE_DEATH,
ENTITY_BEE_HURT,
ENTITY_BEE_LOOP,
ENTITY_BEE_LOOP_AGGRESSIVE,
ENTITY_BEE_POLLINATE,
ENTITY_BEE_STING,
ENTITY_BLAZE_AMBIENT("BLAZE_BREATH"),
ENTITY_BLAZE_BURN,
ENTITY_BLAZE_DEATH("BLAZE_DEATH"),
ENTITY_BLAZE_HURT("BLAZE_HIT"),
ENTITY_BLAZE_SHOOT,
ENTITY_BOAT_PADDLE_LAND,
AMBIENT_BASALT_DELTAS_ADDITIONS,
AMBIENT_BASALT_DELTAS_LOOP,
AMBIENT_BASALT_DELTAS_MOOD,
AMBIENT_CRIMSON_FOREST_ADDITIONS,
AMBIENT_CRIMSON_FOREST_LOOP,
AMBIENT_CRIMSON_FOREST_MOOD,
AMBIENT_NETHER_WASTES_ADDITIONS,
AMBIENT_NETHER_WASTES_LOOP,
AMBIENT_NETHER_WASTES_MOOD,
AMBIENT_SOUL_SAND_VALLEY_ADDITIONS,
AMBIENT_SOUL_SAND_VALLEY_LOOP,
AMBIENT_SOUL_SAND_VALLEY_MOOD,
ENTITY_BOAT_PADDLE_WATER,
ENTITY_CAT_AMBIENT("CAT_MEOW"),
ENTITY_CAT_BEG_FOR_FOOD,
AMBIENT_WARPED_FOREST_ADDITIONS,
AMBIENT_WARPED_FOREST_LOOP,
AMBIENT_WARPED_FOREST_MOOD,
BLOCK_ANCIENT_DEBRIS_BREAK,
BLOCK_ANCIENT_DEBRIS_FALL,
BLOCK_ANCIENT_DEBRIS_HIT,
BLOCK_ANCIENT_DEBRIS_PLACE,
BLOCK_ANCIENT_DEBRIS_STEP,
BLOCK_BASALT_BREAK,
BLOCK_BASALT_FALL,
BLOCK_BASALT_HIT,
BLOCK_BASALT_PLACE,
BLOCK_BASALT_STEP,
BLOCK_BONE_BLOCK_BREAK,
BLOCK_BONE_BLOCK_FALL,
BLOCK_BONE_BLOCK_HIT,
BLOCK_BONE_BLOCK_PLACE,
BLOCK_BONE_BLOCK_STEP,
BLOCK_CHAIN_BREAK,
BLOCK_CHAIN_FALL,
BLOCK_CHAIN_HIT,
BLOCK_CHAIN_PLACE,
BLOCK_CHAIN_STEP,
BLOCK_FUNGUS_BREAK,
BLOCK_FUNGUS_FALL,
BLOCK_FUNGUS_HIT,
BLOCK_FUNGUS_PLACE,
BLOCK_FUNGUS_STEP,
BLOCK_LODESTONE_BREAK,
BLOCK_LODESTONE_FALL,
BLOCK_LODESTONE_HIT,
BLOCK_LODESTONE_PLACE,
BLOCK_LODESTONE_STEP,
BLOCK_NETHERITE_BLOCK_BREAK,
BLOCK_NETHERITE_BLOCK_FALL,
BLOCK_NETHERITE_BLOCK_HIT,
BLOCK_NETHERITE_BLOCK_PLACE,
BLOCK_NETHERITE_BLOCK_STEP,
BLOCK_NETHERRACK_BREAK,
BLOCK_NETHERRACK_FALL,
BLOCK_NETHERRACK_HIT,
BLOCK_NETHERRACK_PLACE,
BLOCK_NETHERRACK_STEP,
BLOCK_NETHER_BRICKS_BREAK,
BLOCK_NETHER_BRICKS_FALL,
BLOCK_NETHER_BRICKS_HIT,
BLOCK_NETHER_BRICKS_PLACE,
BLOCK_NETHER_BRICKS_STEP,
BLOCK_NETHER_GOLD_ORE_BREAK,
BLOCK_NETHER_GOLD_ORE_FALL,
BLOCK_NETHER_GOLD_ORE_HIT,
BLOCK_NETHER_GOLD_ORE_PLACE,
BLOCK_NETHER_GOLD_ORE_STEP,
BLOCK_NETHER_ORE_BREAK,
BLOCK_NETHER_ORE_FALL,
BLOCK_NETHER_ORE_HIT,
BLOCK_NETHER_ORE_PLACE,
BLOCK_NETHER_ORE_STEP,
BLOCK_NETHER_SPROUTS_BREAK,
BLOCK_NETHER_SPROUTS_FALL,
BLOCK_NETHER_SPROUTS_HIT,
BLOCK_NETHER_SPROUTS_PLACE,
BLOCK_NETHER_SPROUTS_STEP,
BLOCK_NYLIUM_BREAK,
BLOCK_NYLIUM_FALL,
BLOCK_NYLIUM_HIT,
BLOCK_NYLIUM_PLACE,
BLOCK_NYLIUM_STEP,
BLOCK_RESPAWN_ANCHOR_AMBIENT,
BLOCK_RESPAWN_ANCHOR_CHARGE,
BLOCK_RESPAWN_ANCHOR_DEPLETE,
BLOCK_RESPAWN_ANCHOR_SET_SPAWN,
BLOCK_ROOTS_BREAK,
BLOCK_ROOTS_FALL,
BLOCK_ROOTS_HIT,
BLOCK_ROOTS_PLACE,
BLOCK_ROOTS_STEP,
BLOCK_SHROOMLIGHT_BREAK,
BLOCK_SHROOMLIGHT_FALL,
BLOCK_SHROOMLIGHT_HIT,
BLOCK_SHROOMLIGHT_PLACE,
BLOCK_SHROOMLIGHT_STEP,
BLOCK_SMITHING_TABLE_USE,
BLOCK_SOUL_SAND_BREAK,
BLOCK_SOUL_SAND_FALL,
BLOCK_SOUL_SAND_HIT,
BLOCK_SOUL_SAND_PLACE,
BLOCK_SOUL_SAND_STEP,
BLOCK_SOUL_SOIL_BREAK,
BLOCK_SOUL_SOIL_FALL,
BLOCK_SOUL_SOIL_HIT,
BLOCK_SOUL_SOIL_PLACE,
BLOCK_SOUL_SOIL_STEP,
BLOCK_STEM_BREAK,
BLOCK_STEM_FALL,
BLOCK_STEM_HIT,
BLOCK_STEM_PLACE,
BLOCK_STEM_STEP,
BLOCK_VINE_STEP,
BLOCK_WART_BLOCK_BREAK,
BLOCK_WART_BLOCK_FALL,
BLOCK_WART_BLOCK_HIT,
BLOCK_WART_BLOCK_PLACE,
BLOCK_WART_BLOCK_STEP,
ENTITY_DONKEY_EAT,
ENTITY_FOX_TELEPORT,
ENTITY_HOGLIN_AMBIENT,
ENTITY_HOGLIN_ANGRY,
ENTITY_HOGLIN_ATTACK,
ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED,
ENTITY_HOGLIN_DEATH,
ENTITY_HOGLIN_HURT,
ENTITY_HOGLIN_RETREAT,
ENTITY_HOGLIN_STEP,
ENTITY_MULE_EAT,
ENTITY_MULE_ANGRY,
ENTITY_PARROT_IMITATE_HOGLIN,
ENTITY_PARROT_IMITATE_PIGLIN,
ENTITY_PARROT_IMITATE_ZOGLIN,
ENTITY_PIGLIN_ADMIRING_ITEM,
ENTITY_PIGLIN_AMBIENT,
ENTITY_PIGLIN_ANGRY,
ENTITY_PIGLIN_CELEBRATE,
ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED,
ENTITY_PIGLIN_DEATH,
ENTITY_PIGLIN_HURT,
ENTITY_PIGLIN_JEALOUS,
ENTITY_PIGLIN_RETREAT,
ENTITY_PIGLIN_STEP,
ENTITY_SNOW_GOLEM_SHEAR,
ENTITY_STRIDER_AMBIENT,
ENTITY_STRIDER_DEATH,
ENTITY_STRIDER_EAT,
ENTITY_STRIDER_HAPPY,
ENTITY_STRIDER_HURT,
ENTITY_STRIDER_RETREAT,
ENTITY_STRIDER_SADDLE,
ENTITY_STRIDER_STEP,
ENTITY_STRIDER_STEP_LAVA,
ENTITY_ZOGLIN_AMBIENT,
ENTITY_ZOGLIN_ANGRY,
ENTITY_ZOGLIN_ATTACK,
ENTITY_ZOGLIN_DEATH,
ENTITY_ZOGLIN_HURT,
ENTITY_ZOGLIN_STEP,
BLOCK_WEEPING_VINES_BREAK,
BLOCK_WEEPING_VINES_FALL,
BLOCK_WEEPING_VINES_HIT,
BLOCK_WEEPING_VINES_PLACE,
BLOCK_WEEPING_VINES_STEP,
BLOCK_GILDED_BLACKSTONE_BREAK,
BLOCK_GILDED_BLACKSTONE_FALL,
BLOCK_GILDED_BLACKSTONE_HIT,
BLOCK_GILDED_BLACKSTONE_PLACE,
BLOCK_GILDED_BLACKSTONE_STEP,
ENTITY_CAT_DEATH,
ENTITY_CAT_EAT,
ENTITY_CAT_HISS("CAT_HISS"),
ENTITY_CAT_HURT("CAT_HIT"),
ENTITY_CAT_PURR("CAT_PURR"),
ENTITY_CAT_PURREOW("CAT_PURREOW"),
ENTITY_CAT_STRAY_AMBIENT,
ENTITY_CHICKEN_AMBIENT("CHICKEN_IDLE"),
ENTITY_CHICKEN_DEATH,
ENTITY_CHICKEN_EGG("CHICKEN_EGG_POP"),
ENTITY_CHICKEN_HURT("CHICKEN_HURT"),
ENTITY_CHICKEN_STEP("CHICKEN_WALK"),
ENTITY_COD_AMBIENT,
ENTITY_COD_DEATH,
ENTITY_COD_FLOP,
ENTITY_COD_HURT,
ENTITY_COW_AMBIENT("COW_IDLE"),
ENTITY_COW_DEATH,
ENTITY_COW_HURT("COW_HURT"),
ENTITY_COW_MILK,
ENTITY_COW_STEP("COW_WALK"),
ENTITY_CREEPER_DEATH("CREEPER_DEATH"),
ENTITY_CREEPER_HURT,
ENTITY_CREEPER_PRIMED("CREEPER_HISS"),
ENTITY_DOLPHIN_AMBIENT,
ENTITY_DOLPHIN_AMBIENT_WATER,
ENTITY_DOLPHIN_ATTACK,
ENTITY_DOLPHIN_DEATH,
ENTITY_DOLPHIN_EAT,
ENTITY_DOLPHIN_HURT,
ENTITY_DOLPHIN_JUMP,
ENTITY_DOLPHIN_PLAY,
ENTITY_DOLPHIN_SPLASH,
ENTITY_DOLPHIN_SWIM,
ENTITY_DONKEY_AMBIENT("DONKEY_IDLE"),
ENTITY_DONKEY_ANGRY("DONKEY_ANGRY"),
ENTITY_DONKEY_CHEST,
ENTITY_DONKEY_DEATH("DONKEY_DEATH"),
ENTITY_DONKEY_HURT("DONKEY_HIT"),
ENTITY_DRAGON_FIREBALL_EXPLODE("ENTITY_ENDERDRAGON_FIREBALL_EXPLODE"),
ENTITY_DROWNED_AMBIENT,
ENTITY_DROWNED_AMBIENT_WATER,
ENTITY_DROWNED_DEATH,
ENTITY_DROWNED_DEATH_WATER,
ENTITY_DROWNED_HURT,
ENTITY_DROWNED_HURT_WATER,
ENTITY_DROWNED_SHOOT,
ENTITY_DROWNED_STEP,
ENTITY_DROWNED_SWIM,
ENTITY_EGG_THROW,
ENTITY_ELDER_GUARDIAN_AMBIENT,
ENTITY_ELDER_GUARDIAN_AMBIENT_LAND,
ENTITY_ELDER_GUARDIAN_CURSE,
ENTITY_ELDER_GUARDIAN_DEATH,
ENTITY_ELDER_GUARDIAN_DEATH_LAND,
ENTITY_ELDER_GUARDIAN_FLOP,
ENTITY_ELDER_GUARDIAN_HURT,
ENTITY_ELDER_GUARDIAN_HURT_LAND,
ENTITY_ENDERMAN_AMBIENT("ENDERMAN_IDLE", "ENTITY_ENDERMEN_AMBIENT"),
ENTITY_ENDERMAN_DEATH("ENDERMAN_DEATH", "ENTITY_ENDERMEN_DEATH"),
ENTITY_ENDERMAN_HURT("ENDERMAN_HIT", "ENTITY_ENDERMEN_HURT"),
ENTITY_ENDERMAN_SCREAM("ENDERMAN_SCREAM", "ENTITY_ENDERMEN_SCREAM"),
ENTITY_ENDERMAN_STARE("ENDERMAN_STARE", "ENTITY_ENDERMEN_STARE"),
ENTITY_ENDERMAN_TELEPORT("ENDERMAN_TELEPORT", "ENTITY_ENDERMEN_TELEPORT"),
ENTITY_ENDERMITE_AMBIENT,
ENTITY_ENDERMITE_DEATH,
ENTITY_ENDERMITE_HURT,
ENTITY_ENDERMITE_STEP,
ENTITY_ENDER_DRAGON_AMBIENT("ENDERDRAGON_WINGS", "ENTITY_ENDERDRAGON_AMBIENT"),
ENTITY_ENDER_DRAGON_DEATH("ENDERDRAGON_DEATH", "ENTITY_ENDERDRAGON_DEATH"),
ENTITY_ENDER_DRAGON_FLAP("ENDERDRAGON_WINGS", "ENTITY_ENDERDRAGON_FLAP"),
ENTITY_ENDER_DRAGON_GROWL("ENDERDRAGON_GROWL", "ENTITY_ENDERDRAGON_GROWL"),
ENTITY_ENDER_DRAGON_HURT("ENDERDRAGON_HIT", "ENTITY_ENDERDRAGON_HURT"),
ENTITY_ENDER_DRAGON_SHOOT("ENTITY_ENDERDRAGON_SHOOT"),
ENTITY_ENDER_EYE_DEATH,
ENTITY_ENDER_EYE_LAUNCH("ENTITY_ENDER_EYE_DEATH", "ENTITY_ENDEREYE_DEATH"),
ENTITY_ENDER_PEARL_THROW("ENTITY_ENDERPEARL_THROW"),
ENTITY_EVOKER_AMBIENT("ENTITY_EVOCATION_ILLAGER_AMBIENT"),
ENTITY_EVOKER_CAST_SPELL("ENTITY_EVOCATION_ILLAGER_CAST_SPELL"),
ENTITY_EVOKER_CELEBRATE,
ENTITY_EVOKER_DEATH("ENTITY_EVOCATION_ILLAGER_DEATH"),
ENTITY_EVOKER_FANGS_ATTACK("ENTITY_EVOCATION_FANGS_ATTACK"),
ENTITY_EVOKER_HURT("ENTITY_EVOCATION_ILLAGER_HURT"),
ENTITY_EVOKER_PREPARE_ATTACK("ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK"),
ENTITY_EVOKER_PREPARE_SUMMON("ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON"),
ENTITY_EVOKER_PREPARE_WOLOLO("ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO"),
ENTITY_EXPERIENCE_BOTTLE_THROW,
ENTITY_EXPERIENCE_ORB_PICKUP("ORB_PICKUP"),
ENTITY_FIREWORK_ROCKET_BLAST("FIREWORK_BLAST", "ENTITY_FIREWORK_BLAST"),
ENTITY_FIREWORK_ROCKET_BLAST_FAR("FIREWORK_BLAST2", "ENTITY_FIREWORK_BLAST_FAR"),
ENTITY_FIREWORK_ROCKET_LARGE_BLAST("FIREWORK_LARGE_BLAST", "ENTITY_FIREWORK_LARGE_BLAST"),
ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR("FIREWORK_LARGE_BLAST2", "ENTITY_FIREWORK_LARGE_BLAST_FAR"),
ENTITY_FIREWORK_ROCKET_LAUNCH("FIREWORK_LAUNCH", "ENTITY_FIREWORK_LAUNCH"),
ENTITY_FIREWORK_ROCKET_SHOOT,
ENTITY_FIREWORK_ROCKET_TWINKLE("FIREWORK_TWINKLE", "ENTITY_FIREWORK_TWINKLE"),
ENTITY_FIREWORK_ROCKET_TWINKLE_FAR("FIREWORK_TWINKLE2", "ENTITY_FIREWORK_TWINKLE_FAR"),
ENTITY_FISHING_BOBBER_RETRIEVE,
ENTITY_FISHING_BOBBER_SPLASH("SPLASH2", "ENTITY_BOBBER_SPLASH"),
ENTITY_FISHING_BOBBER_THROW("ENTITY_BOBBER_THROW"),
ENTITY_FISH_SWIM,
ENTITY_FOX_AGGRO,
ENTITY_FOX_AMBIENT,
ENTITY_FOX_BITE,
ENTITY_FOX_DEATH,
ENTITY_FOX_EAT,
ENTITY_FOX_HURT,
ENTITY_FOX_SCREECH,
ENTITY_FOX_SLEEP,
ENTITY_FOX_SNIFF,
ENTITY_FOX_SPIT,
ENTITY_GENERIC_BIG_FALL("FALL_BIG"),
ENTITY_GENERIC_BURN,
ENTITY_GENERIC_DEATH,
ENTITY_GENERIC_DRINK("DRINK"),
ENTITY_GENERIC_EAT("EAT"),
ENTITY_GENERIC_EXPLODE("EXPLODE"),
ENTITY_GENERIC_EXTINGUISH_FIRE,
ENTITY_GENERIC_HURT,
ENTITY_GENERIC_SMALL_FALL("FALL_SMALL"),
ENTITY_GENERIC_SPLASH("SPLASH"),
ENTITY_GENERIC_SWIM("SWIM"),
ENTITY_GHAST_AMBIENT("GHAST_MOAN"),
ENTITY_GHAST_DEATH("GHAST_DEATH"),
ENTITY_GHAST_HURT("GHAST_SCREAM2"),
ENTITY_GHAST_SCREAM("GHAST_SCREAM"),
ENTITY_GHAST_SHOOT("GHAST_FIREBALL"),
ENTITY_GHAST_WARN("GHAST_CHARGE"),
ENTITY_GUARDIAN_AMBIENT,
ENTITY_GUARDIAN_AMBIENT_LAND,
ENTITY_GUARDIAN_ATTACK,
ENTITY_GUARDIAN_DEATH,
ENTITY_GUARDIAN_DEATH_LAND,
ENTITY_GUARDIAN_FLOP,
ENTITY_GUARDIAN_HURT,
ENTITY_GUARDIAN_HURT_LAND,
ENTITY_HORSE_AMBIENT("HORSE_IDLE"),
ENTITY_HORSE_ANGRY("HORSE_ANGRY"),
ENTITY_HORSE_ARMOR("HORSE_ARMOR"),
ENTITY_HORSE_BREATHE("HORSE_BREATHE"),
ENTITY_HORSE_DEATH("HORSE_DEATH"),
ENTITY_HORSE_EAT,
ENTITY_HORSE_GALLOP("HORSE_GALLOP"),
ENTITY_HORSE_HURT("HORSE_HIT"),
ENTITY_HORSE_JUMP("HORSE_JUMP"),
ENTITY_HORSE_LAND("HORSE_LAND"),
ENTITY_HORSE_SADDLE("HORSE_SADDLE"),
ENTITY_HORSE_STEP("HORSE_SOFT"),
ENTITY_HORSE_STEP_WOOD("HORSE_WOOD"),
ENTITY_HOSTILE_BIG_FALL("FALL_BIG"),
ENTITY_HOSTILE_DEATH,
ENTITY_HOSTILE_HURT,
ENTITY_HOSTILE_SMALL_FALL("FALL_SMALL"),
ENTITY_HOSTILE_SPLASH("SPLASH"),
ENTITY_HOSTILE_SWIM("SWIM"),
ENTITY_HUSK_AMBIENT,
ENTITY_HUSK_CONVERTED_TO_ZOMBIE,
ENTITY_HUSK_DEATH,
ENTITY_HUSK_HURT,
ENTITY_HUSK_STEP,
ENTITY_ILLUSIONER_AMBIENT("ENTITY_ILLUSION_ILLAGER_AMBIENT"),
ENTITY_ILLUSIONER_CAST_SPELL("ENTITY_ILLUSION_ILLAGER_CAST_SPELL"),
ENTITY_ILLUSIONER_DEATH("ENTITY_ILLUSIONER_CAST_DEATH", "ENTITY_ILLUSION_ILLAGER_DEATH"),
ENTITY_ILLUSIONER_HURT("ENTITY_ILLUSION_ILLAGER_HURT"),
ENTITY_ILLUSIONER_MIRROR_MOVE("ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE"),
ENTITY_ILLUSIONER_PREPARE_BLINDNESS("ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS"),
ENTITY_ILLUSIONER_PREPARE_MIRROR("ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR"),
ENTITY_IRON_GOLEM_ATTACK("IRONGOLEM_THROW", "ENTITY_IRONGOLEM_ATTACK"),
ENTITY_IRON_GOLEM_DAMAGE,
ENTITY_IRON_GOLEM_DEATH("IRONGOLEM_DEATH", "ENTITY_IRONGOLEM_DEATH"),
ENTITY_IRON_GOLEM_HURT("IRONGOLEM_HIT", "ENTITY_IRONGOLEM_HURT"),
ENTITY_IRON_GOLEM_REPAIR,
ENTITY_IRON_GOLEM_STEP("IRONGOLEM_WALK", "ENTITY_IRONGOLEM_STEP"),
ENTITY_ITEM_BREAK("ITEM_BREAK"),
ENTITY_ITEM_FRAME_ADD_ITEM("ENTITY_ITEMFRAME_ADD_ITEM"),
ENTITY_ITEM_FRAME_BREAK("ENTITY_ITEMFRAME_BREAK"),
ENTITY_ITEM_FRAME_PLACE("ENTITY_ITEMFRAME_PLACE"),
ENTITY_ITEM_FRAME_REMOVE_ITEM("ENTITY_ITEMFRAME_REMOVE_ITEM"),
ENTITY_ITEM_FRAME_ROTATE_ITEM("ENTITY_ITEMFRAME_ROTATE_ITEM"),
ENTITY_ITEM_PICKUP("ITEM_PICKUP"),
ENTITY_LEASH_KNOT_BREAK("ENTITY_LEASHKNOT_BREAK"),
ENTITY_LEASH_KNOT_PLACE("ENTITY_LEASHKNOT_PLACE"),
ENTITY_LIGHTNING_BOLT_IMPACT("AMBIENCE_THUNDER", "ENTITY_LIGHTNING_IMPACT"),
ENTITY_LIGHTNING_BOLT_THUNDER("AMBIENCE_THUNDER", "ENTITY_LIGHTNING_THUNDER"),
ENTITY_LINGERING_POTION_THROW,
ENTITY_LLAMA_AMBIENT,
ENTITY_LLAMA_ANGRY,
ENTITY_LLAMA_CHEST,
ENTITY_LLAMA_DEATH,
ENTITY_LLAMA_EAT,
ENTITY_LLAMA_HURT,
ENTITY_LLAMA_SPIT,
ENTITY_LLAMA_STEP,
ENTITY_LLAMA_SWAG,
ENTITY_MAGMA_CUBE_DEATH("ENTITY_MAGMACUBE_DEATH"),
ENTITY_MAGMA_CUBE_DEATH_SMALL("ENTITY_SMALL_MAGMACUBE_DEATH"),
ENTITY_MAGMA_CUBE_HURT("ENTITY_MAGMACUBE_HURT"),
ENTITY_MAGMA_CUBE_HURT_SMALL("ENTITY_SMALL_MAGMACUBE_HURT"),
ENTITY_MAGMA_CUBE_JUMP("MAGMACUBE_JUMP", "ENTITY_MAGMACUBE_JUMP"),
ENTITY_MAGMA_CUBE_SQUISH("MAGMACUBE_WALK", "ENTITY_MAGMACUBE_SQUISH"),
ENTITY_MAGMA_CUBE_SQUISH_SMALL("MAGMACUBE_WALK2", "ENTITY_SMALL_MAGMACUBE_SQUISH"),
ENTITY_MINECART_INSIDE("MINECART_INSIDE"),
ENTITY_MINECART_RIDING("MINECART_BASE"),
ENTITY_MOOSHROOM_CONVERT,
ENTITY_MOOSHROOM_EAT,
ENTITY_MOOSHROOM_MILK,
ENTITY_MOOSHROOM_SHEAR,
ENTITY_MOOSHROOM_SUSPICIOUS_MILK,
ENTITY_MULE_AMBIENT,
ENTITY_MULE_CHEST("ENTITY_MULE_AMBIENT"),
ENTITY_MULE_DEATH("ENTITY_MULE_AMBIENT"),
ENTITY_MULE_HURT("ENTITY_MULE_AMBIENT"),
ENTITY_OCELOT_AMBIENT,
ENTITY_OCELOT_DEATH,
ENTITY_OCELOT_HURT,
ENTITY_PAINTING_BREAK,
ENTITY_PAINTING_PLACE,
ENTITY_PANDA_AGGRESSIVE_AMBIENT,
ENTITY_PANDA_AMBIENT,
ENTITY_PANDA_BITE,
ENTITY_PANDA_CANT_BREED,
ENTITY_PANDA_DEATH,
ENTITY_PANDA_EAT,
ENTITY_PANDA_HURT,
ENTITY_PANDA_PRE_SNEEZE,
ENTITY_PANDA_SNEEZE,
ENTITY_PANDA_STEP,
ENTITY_PANDA_WORRIED_AMBIENT,
ENTITY_PARROT_AMBIENT,
ENTITY_PARROT_DEATH,
ENTITY_PARROT_EAT,
ENTITY_PARROT_FLY,
ENTITY_PARROT_HURT,
ENTITY_PARROT_IMITATE_BLAZE,
ENTITY_PARROT_IMITATE_CREEPER,
ENTITY_PARROT_IMITATE_DROWNED,
ENTITY_PARROT_IMITATE_ELDER_GUARDIAN,
ENTITY_PARROT_IMITATE_ENDERMAN,
ENTITY_PARROT_IMITATE_ENDERMITE,
ENTITY_PARROT_IMITATE_ENDER_DRAGON,
ENTITY_PARROT_IMITATE_EVOKER,
ENTITY_PARROT_IMITATE_GHAST,
ENTITY_PARROT_IMITATE_GUARDIAN,
ENTITY_PARROT_IMITATE_HUSK,
ENTITY_PARROT_IMITATE_ILLUSIONER,
ENTITY_PARROT_IMITATE_MAGMA_CUBE,
ENTITY_PARROT_IMITATE_PHANTOM,
ENTITY_PARROT_IMITATE_PILLAGER,
ENTITY_PARROT_IMITATE_POLAR_BEAR,
ENTITY_PARROT_IMITATE_RAVAGER,
ENTITY_PARROT_IMITATE_SHULKER,
ENTITY_PARROT_IMITATE_SILVERFISH,
ENTITY_PARROT_IMITATE_SKELETON,
ENTITY_PARROT_IMITATE_SLIME,
ENTITY_PARROT_IMITATE_SPIDER,
ENTITY_PARROT_IMITATE_STRAY,
ENTITY_PARROT_IMITATE_VEX,
ENTITY_PARROT_IMITATE_VINDICATOR,
ENTITY_PARROT_IMITATE_WITCH,
ENTITY_PARROT_IMITATE_WITHER,
ENTITY_PARROT_IMITATE_WITHER_SKELETON,
ENTITY_PARROT_IMITATE_WOLF,
ENTITY_PARROT_IMITATE_ZOMBIE,
ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER,
ENTITY_PARROT_STEP,
ENTITY_PHANTOM_AMBIENT,
ENTITY_PHANTOM_BITE,
ENTITY_PHANTOM_DEATH,
ENTITY_PHANTOM_FLAP,
ENTITY_PHANTOM_HURT,
ENTITY_PHANTOM_SWOOP,
ENTITY_PIG_AMBIENT("PIG_IDLE"),
ENTITY_PIG_DEATH("PIG_DEATH"),
ENTITY_PIG_HURT,
ENTITY_PIG_SADDLE("ENTITY_PIG_HURT"),
ENTITY_PIG_STEP("PIG_WALK"),
ENTITY_PILLAGER_AMBIENT,
ENTITY_PILLAGER_CELEBRATE,
ENTITY_PILLAGER_DEATH,
ENTITY_PILLAGER_HURT,
ENTITY_PLAYER_ATTACK_CRIT,
ENTITY_PLAYER_ATTACK_KNOCKBACK,
ENTITY_PLAYER_ATTACK_NODAMAGE,
ENTITY_PLAYER_ATTACK_STRONG("SUCCESSFUL_HIT"),
ENTITY_PLAYER_ATTACK_SWEEP,
ENTITY_PLAYER_ATTACK_WEAK,
ENTITY_PLAYER_BIG_FALL("FALL_BIG"),
ENTITY_PLAYER_BREATH,
ENTITY_PLAYER_BURP("BURP"),
ENTITY_PLAYER_DEATH,
ENTITY_PLAYER_HURT("HURT_FLESH"),
ENTITY_PLAYER_HURT_DROWN,
ENTITY_PLAYER_HURT_ON_FIRE,
ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH,
ENTITY_PLAYER_LEVELUP("LEVEL_UP"),
ENTITY_PLAYER_SMALL_FALL("FALL_SMALL"),
ENTITY_PLAYER_SPLASH("SLASH"),
ENTITY_PLAYER_SPLASH_HIGH_SPEED("SPLASH"),
ENTITY_PLAYER_SWIM("SWIM"),
ENTITY_POLAR_BEAR_AMBIENT,
ENTITY_POLAR_BEAR_AMBIENT_BABY("ENTITY_POLAR_BEAR_BABY_AMBIENT"),
ENTITY_POLAR_BEAR_DEATH,
ENTITY_POLAR_BEAR_HURT,
ENTITY_POLAR_BEAR_STEP,
ENTITY_POLAR_BEAR_WARNING,
ENTITY_PUFFER_FISH_AMBIENT,
ENTITY_PUFFER_FISH_BLOW_OUT,
ENTITY_PUFFER_FISH_BLOW_UP,
ENTITY_PUFFER_FISH_DEATH,
ENTITY_PUFFER_FISH_FLOP,
ENTITY_PUFFER_FISH_HURT,
ENTITY_PUFFER_FISH_STING,
ENTITY_RABBIT_AMBIENT,
ENTITY_RABBIT_ATTACK,
ENTITY_RABBIT_DEATH,
ENTITY_RABBIT_HURT,
ENTITY_RABBIT_JUMP,
ENTITY_RAVAGER_AMBIENT,
ENTITY_RAVAGER_ATTACK,
ENTITY_RAVAGER_CELEBRATE,
ENTITY_RAVAGER_DEATH,
ENTITY_RAVAGER_HURT,
ENTITY_RAVAGER_ROAR,
ENTITY_RAVAGER_STEP,
ENTITY_RAVAGER_STUNNED,
ENTITY_SALMON_AMBIENT,
ENTITY_SALMON_DEATH,
ENTITY_SALMON_FLOP,
ENTITY_SALMON_HURT("ENTITY_SALMON_FLOP"),
ENTITY_SHEEP_AMBIENT("SHEEP_IDLE"),
ENTITY_SHEEP_DEATH,
ENTITY_SHEEP_HURT,
ENTITY_SHEEP_SHEAR("SHEEP_SHEAR"),
ENTITY_SHEEP_STEP("SHEEP_WALK"),
ENTITY_SHULKER_AMBIENT,
ENTITY_SHULKER_BULLET_HIT,
ENTITY_SHULKER_BULLET_HURT,
ENTITY_SHULKER_CLOSE,
ENTITY_SHULKER_DEATH,
ENTITY_SHULKER_HURT,
ENTITY_SHULKER_HURT_CLOSED,
ENTITY_SHULKER_OPEN,
ENTITY_SHULKER_SHOOT,
ENTITY_SHULKER_TELEPORT,
ENTITY_SILVERFISH_AMBIENT("SILVERFISH_IDLE"),
ENTITY_SILVERFISH_DEATH("SILVERFISH_KILL"),
ENTITY_SILVERFISH_HURT("SILVERFISH_HIT"),
ENTITY_SILVERFISH_STEP("SILVERFISH_WALK"),
ENTITY_SKELETON_AMBIENT("SKELETON_IDLE"),
ENTITY_SKELETON_DEATH("SKELETON_DEATH"),
ENTITY_SKELETON_HORSE_AMBIENT("HORSE_SKELETON_IDLE"),
ENTITY_SKELETON_HORSE_AMBIENT_WATER,
ENTITY_SKELETON_HORSE_DEATH("HORSE_SKELETON_DEATH"),
ENTITY_SKELETON_HORSE_GALLOP_WATER,
ENTITY_SKELETON_HORSE_HURT("HORSE_SKELETON_HIT"),
ENTITY_SKELETON_HORSE_JUMP_WATER,
ENTITY_SKELETON_HORSE_STEP_WATER,
ENTITY_SKELETON_HORSE_SWIM,
ENTITY_SKELETON_HURT("SKELETON_HURT"),
ENTITY_SKELETON_SHOOT,
ENTITY_SKELETON_STEP("SKELETON_WALK"),
ENTITY_SLIME_ATTACK("SLIME_ATTACK"),
ENTITY_SLIME_DEATH,
ENTITY_SLIME_DEATH_SMALL,
ENTITY_SLIME_HURT,
ENTITY_SLIME_HURT_SMALL("ENTITY_SMALL_SLIME_HURT"),
ENTITY_SLIME_JUMP("SLIME_WALK"),
ENTITY_SLIME_JUMP_SMALL("SLIME_WALK2", "ENTITY_SMALL_SLIME_SQUISH"),
ENTITY_SLIME_SQUISH("SLIME_WALK2"),
ENTITY_SLIME_SQUISH_SMALL("ENTITY_SMALL_SLIME_SQUISH"),
ENTITY_SNOWBALL_THROW,
ENTITY_SNOW_GOLEM_AMBIENT("ENTITY_SNOWMAN_AMBIENT"),
ENTITY_SNOW_GOLEM_DEATH("ENTITY_SNOWMAN_DEATH"),
ENTITY_SNOW_GOLEM_HURT("ENTITY_SNOWMAN_HURT"),
ENTITY_SNOW_GOLEM_SHOOT("ENTITY_SNOWMAN_SHOOT"),
ENTITY_SPIDER_AMBIENT("SPIDER_IDLE"),
ENTITY_SPIDER_DEATH("SPIDER_DEATH"),
ENTITY_SPIDER_HURT,
ENTITY_SPIDER_STEP("SPIDER_WALK"),
ENTITY_SPLASH_POTION_BREAK,
ENTITY_SPLASH_POTION_THROW,
ENTITY_SQUID_AMBIENT,
ENTITY_SQUID_DEATH,
ENTITY_SQUID_HURT,
ENTITY_SQUID_SQUIRT,
ENTITY_STRAY_AMBIENT,
ENTITY_STRAY_DEATH,
ENTITY_STRAY_HURT,
ENTITY_STRAY_STEP,
ENTITY_TNT_PRIMED("FUSE"),
ENTITY_TROPICAL_FISH_AMBIENT,
ENTITY_TROPICAL_FISH_DEATH,
ENTITY_TROPICAL_FISH_FLOP("ENTITY_TROPICAL_FISH_DEATH"),
ENTITY_TROPICAL_FISH_HURT,
ENTITY_TURTLE_AMBIENT_LAND,
ENTITY_TURTLE_DEATH,
ENTITY_TURTLE_DEATH_BABY,
ENTITY_TURTLE_EGG_BREAK,
ENTITY_TURTLE_EGG_CRACK,
ENTITY_TURTLE_EGG_HATCH,
ENTITY_TURTLE_HURT,
ENTITY_TURTLE_HURT_BABY,
ENTITY_TURTLE_LAY_EGG,
ENTITY_TURTLE_SHAMBLE,
ENTITY_TURTLE_SHAMBLE_BABY,
ENTITY_TURTLE_SWIM,
ENTITY_VEX_AMBIENT,
ENTITY_VEX_CHARGE,
ENTITY_VEX_DEATH,
ENTITY_VEX_HURT,
ENTITY_VILLAGER_AMBIENT("VILLAGER_IDLE"),
ENTITY_VILLAGER_CELEBRATE,
ENTITY_VILLAGER_DEATH("VILLAGER_DEATH"),
ENTITY_VILLAGER_HURT("VILLAGER_HIT"),
ENTITY_VILLAGER_NO("VILLAGER_NO"),
ENTITY_VILLAGER_TRADE("VILLAGER_HAGGLE", "ENTITY_VILLAGER_TRADING"),
ENTITY_VILLAGER_WORK_ARMORER,
ENTITY_VILLAGER_WORK_BUTCHER,
ENTITY_VILLAGER_WORK_CARTOGRAPHER,
ENTITY_VILLAGER_WORK_CLERIC,
ENTITY_VILLAGER_WORK_FARMER,
ENTITY_VILLAGER_WORK_FISHERMAN,
ENTITY_VILLAGER_WORK_FLETCHER,
ENTITY_VILLAGER_WORK_LEATHERWORKER,
ENTITY_VILLAGER_WORK_LIBRARIAN,
ENTITY_VILLAGER_WORK_MASON,
ENTITY_VILLAGER_WORK_SHEPHERD,
ENTITY_VILLAGER_WORK_TOOLSMITH,
ENTITY_VILLAGER_WORK_WEAPONSMITH,
ENTITY_VILLAGER_YES("VILLAGER_YES"),
ENTITY_VINDICATOR_AMBIENT("ENTITY_VINDICATION_ILLAGER_AMBIENT"),
ENTITY_VINDICATOR_CELEBRATE,
ENTITY_VINDICATOR_DEATH("ENTITY_VINDICATION_ILLAGER_DEATH"),
ENTITY_VINDICATOR_HURT("ENTITY_VINDICATION_ILLAGER_HURT"),
ENTITY_WANDERING_TRADER_AMBIENT,
ENTITY_WANDERING_TRADER_DEATH,
ENTITY_WANDERING_TRADER_DISAPPEARED,
ENTITY_WANDERING_TRADER_DRINK_MILK,
ENTITY_WANDERING_TRADER_DRINK_POTION,
ENTITY_WANDERING_TRADER_HURT,
ENTITY_WANDERING_TRADER_NO,
ENTITY_WANDERING_TRADER_REAPPEARED,
ENTITY_WANDERING_TRADER_TRADE,
ENTITY_WANDERING_TRADER_YES,
ENTITY_WITCH_AMBIENT,
ENTITY_WITCH_CELEBRATE,
ENTITY_WITCH_DEATH,
ENTITY_WITCH_DRINK,
ENTITY_WITCH_HURT,
ENTITY_WITCH_THROW,
ENTITY_WITHER_AMBIENT("WITHER_IDLE"),
ENTITY_WITHER_BREAK_BLOCK,
ENTITY_WITHER_DEATH("WITHER_DEATH"),
ENTITY_WITHER_HURT("WITHER_HURT"),
ENTITY_WITHER_SHOOT("WITHER_SHOOT"),
ENTITY_WITHER_SKELETON_AMBIENT,
ENTITY_WITHER_SKELETON_DEATH,
ENTITY_WITHER_SKELETON_HURT,
ENTITY_WITHER_SKELETON_STEP,
ENTITY_WITHER_SPAWN("WITHER_SPAWN"),
ENTITY_WOLF_AMBIENT("WOLF_BARK"),
ENTITY_WOLF_DEATH("WOLF_DEATH"),
ENTITY_WOLF_GROWL("WOLF_GROWL"),
ENTITY_WOLF_HOWL("WOLF_HOWL"),
ENTITY_WOLF_HURT("WOLF_HURT"),
ENTITY_WOLF_PANT("WOLF_PANT"),
ENTITY_WOLF_SHAKE("WOLF_SHAKE"),
ENTITY_WOLF_STEP("WOLF_WALK"),
ENTITY_WOLF_WHINE("WOLF_WHINE"),
ENTITY_ZOMBIE_AMBIENT("ZOMBIE_IDLE"),
ENTITY_ZOMBIE_ATTACK_IRON_DOOR("ZOMBIE_METAL"),
ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("ZOMBIE_WOOD", "ENTITY_ZOMBIE_ATTACK_DOOR_WOOD"),
ENTITY_ZOMBIE_BREAK_WOODEN_DOOR("ZOMBIE_WOODBREAK", "ENTITY_ZOMBIE_BREAK_DOOR_WOOD"),
ENTITY_ZOMBIE_CONVERTED_TO_DROWNED,
ENTITY_ZOMBIE_DEATH("ZOMBIE_DEATH"),
ENTITY_ZOMBIE_DESTROY_EGG,
ENTITY_ZOMBIE_HORSE_AMBIENT("HORSE_ZOMBIE_IDLE"),
ENTITY_ZOMBIE_HORSE_DEATH("HORSE_ZOMBIE_DEATH"),
ENTITY_ZOMBIE_HORSE_HURT("HORSE_ZOMBIE_HIT"),
ENTITY_ZOMBIE_HURT("ZOMBIE_HURT"),
ENTITY_ZOMBIE_INFECT("ZOMBIE_INFECT"),
ITEM_ARMOR_EQUIP_NETHERITE,
ITEM_LODESTONE_COMPASS_LOCK,
MUSIC_DISC_PIGSTEP,
ENTITY_ZOMBIFIED_PIGLIN_AMBIENT("ZOMBE_PIG_IDLE", "ENTITY_ZOMBIE_PIG_AMBIENT", "ENTITY_ZOMBIE_PIGMAN_AMBIENT"),
ENTITY_ZOMBIFIED_PIGLIN_ANGRY("ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIGMAN_ANGRY"),
ENTITY_ZOMBIFIED_PIGLIN_DEATH("ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIGMAN_DEATH"),
ENTITY_ZOMBIFIED_PIGLIN_HURT("ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIGMAN_HURT"),
ENTITY_ZOMBIE_STEP("ZOMBIE_WALK"),
ENTITY_ZOMBIE_VILLAGER_AMBIENT,
ENTITY_ZOMBIE_VILLAGER_CONVERTED("ZOMBIE_UNFECT"),
ENTITY_ZOMBIE_VILLAGER_CURE("ZOMBIE_REMEDY"),
ENTITY_ZOMBIE_VILLAGER_DEATH,
ENTITY_ZOMBIE_VILLAGER_HURT,
ENTITY_ZOMBIE_VILLAGER_STEP,
EVENT_RAID_HORN,
ITEM_ARMOR_EQUIP_CHAIN,
ITEM_ARMOR_EQUIP_DIAMOND,
ITEM_ARMOR_EQUIP_ELYTRA,
ITEM_ARMOR_EQUIP_GENERIC,
ITEM_ARMOR_EQUIP_GOLD,
ITEM_ARMOR_EQUIP_IRON,
ITEM_ARMOR_EQUIP_LEATHER,
ITEM_ARMOR_EQUIP_TURTLE,
ITEM_AXE_STRIP,
ITEM_BOOK_PAGE_TURN,
ITEM_BOOK_PUT,
ITEM_BOTTLE_EMPTY,
ITEM_BOTTLE_FILL,
ITEM_BOTTLE_FILL_DRAGONBREATH,
ITEM_BUCKET_EMPTY,
ITEM_BUCKET_EMPTY_FISH,
ITEM_BUCKET_EMPTY_LAVA,
ITEM_BUCKET_FILL,
ITEM_BUCKET_FILL_FISH,
ITEM_BUCKET_FILL_LAVA,
ITEM_CHORUS_FRUIT_TELEPORT,
ITEM_CROP_PLANT,
ITEM_CROSSBOW_HIT,
ITEM_CROSSBOW_LOADING_END,
ITEM_CROSSBOW_LOADING_MIDDLE,
ITEM_CROSSBOW_LOADING_START,
ITEM_CROSSBOW_QUICK_CHARGE_1,
ITEM_CROSSBOW_QUICK_CHARGE_2,
ITEM_CROSSBOW_QUICK_CHARGE_3,
ITEM_CROSSBOW_SHOOT,
ITEM_ELYTRA_FLYING,
ITEM_FIRECHARGE_USE,
ITEM_FLINTANDSTEEL_USE("FIRE_IGNITE"),
ITEM_HOE_TILL,
ITEM_HONEY_BOTTLE_DRINK,
ITEM_NETHER_WART_PLANT,
ITEM_SHIELD_BLOCK,
ITEM_SHIELD_BREAK,
ITEM_SHOVEL_FLATTEN,
ITEM_SWEET_BERRIES_PICK_FROM_BUSH,
ITEM_TOTEM_USE,
ITEM_TRIDENT_HIT,
ITEM_TRIDENT_HIT_GROUND,
ITEM_TRIDENT_RETURN,
ITEM_TRIDENT_RIPTIDE_1,
ITEM_TRIDENT_RIPTIDE_2("ITEM_TRIDENT_RIPTIDE_1"),
ITEM_TRIDENT_RIPTIDE_3("ITEM_TRIDENT_RIPTIDE_1"),
ITEM_TRIDENT_THROW,
ITEM_TRIDENT_THUNDER,
MUSIC_CREATIVE,
MUSIC_CREDITS,
MUSIC_DISC_11("RECORD_11"),
MUSIC_DISC_13("RECORD_13"),
MUSIC_DISC_BLOCKS("RECORD_BLOCKS"),
MUSIC_DISC_CAT("RECORD_CAT"),
MUSIC_DISC_CHIRP("RECORD_CHIRP"),
MUSIC_DISC_FAR("RECORD_FAR"),
MUSIC_DISC_MALL("RECORD_MALL"),
MUSIC_DISC_MELLOHI("RECORD_MELLOHI"),
MUSIC_DISC_STAL("RECORD_STAL"),
MUSIC_DISC_STRAD("RECORD_STRAD"),
MUSIC_DISC_WAIT("RECORD_WAIT"),
MUSIC_DISC_WARD("RECORD_WARD"),
MUSIC_DRAGON,
MUSIC_END,
MUSIC_GAME,
MUSIC_MENU,
MUSIC_NETHER_BASALT_DELTAS("MUSIC_NETHER"),
PARTICLE_SOUL_ESCAPE,
MUSIC_NETHER_CRIMSON_FOREST,
MUSIC_NETHER_NETHER_WASTES,
MUSIC_NETHER_SOUL_SAND_VALLEY,
MUSIC_NETHER_WARPED_FOREST,
MUSIC_UNDER_WATER,
UI_BUTTON_CLICK("CLICK"),
UI_CARTOGRAPHY_TABLE_TAKE_RESULT,
UI_LOOM_SELECT_PATTERN,
UI_LOOM_TAKE_RESULT,
UI_STONECUTTER_SELECT_RECIPE,
UI_STONECUTTER_TAKE_RESULT,
UI_TOAST_CHALLENGE_COMPLETE,
UI_TOAST_IN,
UI_TOAST_OUT,
WEATHER_RAIN("AMBIENCE_RAIN"),
WEATHER_RAIN_ABOVE;
/**
* An immutable cached list of {@link XSound#values()} to avoid allocating memory for
* calling the method every time.
*
* @since 2.0.0
*/
public static final EnumSet<Sounds> VALUES = EnumSet.allOf(Sounds.class);
/**
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
* Caches the parsed {@link Sound} objects instead of string. Because it has to go through catching exceptions again
* since {@link Sound} class doesn't have a method like {@link Material#getMaterial(String)}.
* So caching these would be more efficient.
*
* @since 2.0.0
*/
private static final Cache<Sounds, com.google.common.base.Optional<Sound>> CACHE = CacheBuilder.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.softValues()
.build();
/**
* Pre-compiled RegEx pattern.
* Include both replacements to avoid creating string multiple times and multiple RegEx checks.
*
* @since 1.0.0
*/
private static final Pattern FORMAT_PATTERN = Pattern.compile("\\d+|\\W+");
private static final Pattern DOUBLE_SPACE = Pattern.compile(" +");
private final String[] legacy;
Sounds(String... legacy) {
this.legacy = legacy;
}
/**
* Attempts to build the string like an enum name.<br>
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
*
* @param name the sound name to modify.
* @return a Sound enum name.
* @since 1.0.0
*/
@Nonnull
private static String format(@Nonnull String name) {
return FORMAT_PATTERN.matcher(
name.trim().replace('-', '_').replace(' ', '_')).replaceAll("").toUpperCase(Locale.ENGLISH);
}
/**
* Checks if XSound enum and the legacy names contains a sound with this name.
*
* @param sound name of the sound
* @return true if XSound enum has this sound.
* @since 1.0.0
*/
public static boolean contains(@Nonnull String sound) {
Validate.notEmpty(sound, "Cannot check for null or empty sound name");
sound = format(sound);
for (Sounds sounds : VALUES)
if (sounds.name().equals(sound) || sounds.anyMatchLegacy(sound)) return true;
return false;
}
/**
* Parses the XSound with the given name.
*
* @param sound the name of the sound.
* @return a matched XSound.
* @since 1.0.0
*/
@Nonnull
public static Optional<Sounds> matchXSound(@Nonnull String sound) {
Validate.notEmpty(sound, "Cannot match XSound of a null or empty sound name");
sound = format(sound);
for (Sounds sounds : VALUES)
if (sounds.name().equals(sound) || sounds.anyMatchLegacy(sound)) return Optional.of(sounds);
return Optional.empty();
}
/**
* Parses the XSound with the given bukkit sound.
*
* @param sound the Bukkit sound.
* @return a matched sound.
* @throws IllegalArgumentException may be thrown as an unexpected exception.
* @since 2.0.0
*/
@Nonnull
public static Sounds matchXSound(@Nonnull Sound sound) {
Objects.requireNonNull(sound, "Cannot match XSound of a null sound");
return matchXSound(sound.name())
.orElseThrow(() -> new IllegalArgumentException("Unsupported Sound: " + sound.name()));
}
/**
* @see #play(Location, String)
* @since 1.0.0
*/
@Nonnull
public static CompletableFuture<Record> play(@Nullable Player player, @Nullable String sound) {
Objects.requireNonNull(player, "Cannot play sound to null player");
return parse(player, player.getLocation(), sound, true);
}
/**
* @see #play(Location, String)
* @since 3.0.0
*/
@Nonnull
public static CompletableFuture<Record> play(@Nonnull Location location, @Nullable String sound) {
return parse(null, location, sound, true);
}
/**
* Just an extra feature that loads sounds from strings.
* Useful for getting sounds from config files.
* Sounds are thread safe.
* <p>
* It's strongly recommended to use this method while using it inside a loop.
* This can help to avoid parsing the sound properties multiple times.
* A simple usage of using it in a loop is:
* <blockquote><pre>
* Record record = XSound.parse(player, location, sound, false).join();
* // Loop:
* if (record != null) record.play();
* </pre></blockquote>
* <p>
* This will also ignore {@code none} and {@code null} strings.
* <p>
* <b>Format:</b> [LOC:]Sound, [Volume], [Pitch]<br>
* Where {@code LOC:} will play the sound at the location if a player is specified.
* A sound played at a location will be heard by everyone around.
* Comma separators are optional.
* <p>
* <b>Examples:</b>
* <p>
* <pre>
* LOC:ENTITY_PLAYER_BURP, 2.5f, 0.5
* ENTITY_PLAYER_BURP, 0.5, 1f
* BURP 0.5f 1
* MUSIC_END, 10f
* none
* null
* </pre>
*
* @param player the only player to play the sound to if requested to do so.
* @param location the location to play the sound to.
* @param sound the string of the sound with volume and pitch (if needed).
* @param play if the sound should be played right away.
* @since 3.0.0
*/
@Nonnull
public static CompletableFuture<Record> parse(@Nullable Player player, @Nonnull Location location, @Nullable String sound, boolean play) {
Objects.requireNonNull(player, "Cannot play sound to null location");
if (Strings.isNullOrEmpty(sound) || sound.equalsIgnoreCase("none")) return null;
return CompletableFuture.supplyAsync(() -> {
String[] split = StringUtils.contains(sound, ',') ?
StringUtils.split(StringUtils.deleteWhitespace(sound), ',') :
StringUtils.split(DOUBLE_SPACE.matcher(sound).replaceAll(" "), ' ');
String name = split[0];
boolean playForEveryone = player == null;
if (!playForEveryone && StringUtils.startsWithIgnoreCase(name, "loc:")) {
name = name.substring(4);
playForEveryone = true;
}
Optional<Sounds> typeOpt = matchXSound(name);
if (!typeOpt.isPresent()) return null;
Sound type = typeOpt.get().parseSound();
if (type == null) return null;
float volume = 1.0f;
float pitch = 1.0f;
try {
if (split.length > 1) {
volume = Float.parseFloat(split[1]);
if (split.length > 2) pitch = Float.parseFloat(split[2]);
}
} catch (NumberFormatException ignored) {
}
Record record = new Record(type, player, location, volume, pitch, playForEveryone);
if (play) record.play();
return record;
}).exceptionally((ex) -> {
System.err.println("Could not play sound for string: " + sound);
ex.printStackTrace();
return null;
});
}
/**
* Stops all the playing musics (not all the sounds)
* <p>
* Note that this method will only work for the sound
* that are sent from {@link Player#playSound} and
* the sounds played from the client will not be
* affected by this.
*
* @param player the player to stop all the sounds from.
* @see #stopSound(Player)
* @since 2.0.0
*/
public static CompletableFuture<Void> stopMusic(@Nonnull Player player) {
Objects.requireNonNull(player, "Cannot stop playing musics from null player");
// We don't need to cache because it's rarely used.
EnumSet<Sounds> musics = EnumSet.of(MUSIC_CREATIVE, MUSIC_CREDITS,
MUSIC_DISC_11, MUSIC_DISC_13, MUSIC_DISC_BLOCKS, MUSIC_DISC_CAT, MUSIC_DISC_CHIRP,
MUSIC_DISC_FAR, MUSIC_DISC_MALL, MUSIC_DISC_MELLOHI, MUSIC_DISC_STAL,
MUSIC_DISC_STRAD, MUSIC_DISC_WAIT, MUSIC_DISC_WARD,
MUSIC_DRAGON, MUSIC_END, MUSIC_GAME, MUSIC_MENU, MUSIC_NETHER_BASALT_DELTAS, MUSIC_UNDER_WATER);
return CompletableFuture.runAsync(() -> {
for (Sounds music : musics) {
Sound sound = music.parseSound();
if (sound != null) player.stopSound(sound);
}
});
}
/**
* In most cases your should be using {@link #name()} instead.
*
* @return a friendly readable string name.
*/
@Override
public String toString() {
return WordUtils.capitalize(this.name().replace('_', ' ').toLowerCase(Locale.ENGLISH));
}
/**
* Gets all the previous sound names used for this sound.
*
* @return a list of legacy sound names.
* @since 1.0.0
*/
@Nonnull
public String[] getLegacy() {
return legacy;
}
/**
* Parses the XSound as a {@link Sound} based on the server version.
*
* @return the vanilla sound.
* @since 1.0.0
*/
@Nullable
@SuppressWarnings({"Guava", "OptionalAssignedToNull"})
public Sound parseSound() {
com.google.common.base.Optional<Sound> cachedSound = CACHE.getIfPresent(this);
if (cachedSound != null) return cachedSound.orNull();
com.google.common.base.Optional<Sound> sound;
// Since Sound class doesn't have a getSound() method we'll use Guava so
// it can cache it for us.
sound = Enums.getIfPresent(Sound.class, this.name());
if (!sound.isPresent()) {
for (String legacy : this.legacy) {
sound = Enums.getIfPresent(Sound.class, legacy);
if (sound.isPresent()) break;
}
}
// Put nulls too, because there's no point of parsing them again if it's going to give us null again.
CACHE.put(this, sound);
return sound.orNull();
}
/**
* Checks if this sound is supported in the current Minecraft version.
* <p>
* An invocation of this method yields exactly the same result as the expression:
* <p>
* <blockquote>
* {@link #parseSound()} != null
* </blockquote>
*
* @return true if the current version has this sound, otherwise false.
* @since 1.0.0
*/
public boolean isSupported() {
return this.parseSound() != null;
}
/**
* Checks if the given string matches any of this sound's legacy sound names.
*
* @param name the sound name to check
* @return true if it's one of the legacy names.
* @since 1.0.0
*/
public boolean anyMatchLegacy(@Nonnull String name) {
Validate.notEmpty(name, "Cannot check for legacy name for null or empty sound name");
return Arrays.asList(this.legacy).contains(format(name));
}
/**
* Plays a sound repeatedly with the given delay at a moving target's location.
*
* @param plugin the plugin handling schedulers. (You can replace this with a static instance)
* @param entity the entity to play the sound to. We exactly need an entity to keep the track of location changes.
* @param volume the volume of the sound.
* @param pitch the pitch of the sound.
* @param repeat the amount of times to repeat playing.
* @param delay the delay between each repeat.
* @see #play(Location, float, float)
* @since 2.0.0
*/
public void playRepeatedly(JavaPlugin plugin, Entity entity, float volume, float pitch, int repeat, int delay) {
Objects.requireNonNull(plugin, "Cannot play repeating sound from null plugin");
Objects.requireNonNull(entity, "Cannot play repeating sound at null location");
Validate.isTrue(repeat > 0, "Cannot repeat playing sound " + repeat + " times");
Validate.isTrue(delay > 0, "Delay ticks must be at least 1");
new BukkitRunnable() {
int repeating = repeat;
@Override
public void run() {
play(entity.getLocation(), volume, pitch);
if (repeating-- == 0) cancel();
}
}.runTaskTimer(plugin, 0, delay);
}
/**
* Plays an instrument's notes in an ascending form.
* This method is not really relevant to this utility class, but a nice feature.
*
* @param plugin the plugin handling schedulers.
* @param player the player to play the note from.
* @param playTo the entity to play the note to.
* @param instrument the instrument.
* @param ascendLevel the ascend level of notes. Can only be positive and not higher than 7
* @param delay the delay between each play.
* @since 2.0.0
*/
public void playAscendingNote(@Nonnull JavaPlugin plugin, @Nonnull Player player, @Nonnull Entity playTo, Instrument instrument, int ascendLevel, int delay) {
Objects.requireNonNull(player, "Cannot play note from null player");
Objects.requireNonNull(playTo, "Cannot play note to null entity");
Validate.isTrue(ascendLevel > 0, "Note ascend level cannot be lower than 1");
Validate.isTrue(ascendLevel <= 7, "Note ascend level cannot be greater than 7");
Validate.isTrue(delay > 0, "Delay ticks must be at least 1");
new BukkitRunnable() {
int repeating = ascendLevel;
@Override
public void run() {
player.playNote(playTo.getLocation(), instrument, Note.natural(1, Note.Tone.values()[ascendLevel - repeating]));
if (repeating-- == 0) cancel();
}
}.runTaskTimerAsynchronously(plugin, 0, delay);
}
/**
* Stops playing the specified sound from the player.
*
* @param player the player to stop playing the sound to.
* @see #stopMusic(Player)
* @since 2.0.0
*/
public void stopSound(@Nonnull Player player) {
Objects.requireNonNull(player, "Cannot stop playing sound from null player");
Sound sound = this.parseSound();
if (sound != null) player.stopSound(sound);
}
/**
* Plays a normal sound to an entity.
*
* @param entity the entity to play the sound to.
* @since 1.0.0
*/
public void play(@Nonnull Entity entity) {
play(entity, 1.0f, 1.0f);
}
/**
* Plays a sound to an entity with the given volume and pitch.
*
* @param entity the entity to play the sound to.
* @param volume the volume of the sound, 1 is normal.
* @param pitch the pitch of the sound, 0 is normal.
* @since 1.0.0
*/
public void play(@Nonnull Entity entity, float volume, float pitch) {
Objects.requireNonNull(entity, "Cannot play sound to a null entity");
if (entity instanceof Player) {
Sound sound = this.parseSound();
if (sound == null) return;
((Player) entity).playSound(entity.getLocation(), sound, volume, pitch);
} else {
play(entity.getLocation(), volume, pitch);
}
}
/**
* Plays a normal sound in a location.
*
* @param location the location to play the sound in.
* @since 2.0.0
*/
public void play(@Nonnull Location location) {
play(location, 1.0f, 1.0f);
}
/**
* Plays a sound in a location with the given volume and pitch.
*
* @param location the location to play this sound.
* @param volume the volume of the sound, 1 is normal.
* @param pitch the pitch of the sound, 0 is normal.
* @since 2.0.0
*/
public void play(@Nonnull Location location, float volume, float pitch) {
Objects.requireNonNull(location, "Cannot play sound to null location");
Sound sound = this.parseSound();
if (sound == null) return;
location.getWorld().playSound(location, sound, volume, pitch);
}
/**
* A class to help caching sound properties parsed from config.
*
* @since 3.0.0
*/
public static class Record {
public final Sound sound;
public final Player player;
public final Location location;
public final float volume;
public final float pitch;
public final boolean playAtLocation;
public Record(Sound sound, Player player, Location location, float volume, float pitch, boolean playAtLocation) {
this.sound = sound;
this.player = player;
this.location = location;
this.volume = volume;
this.pitch = pitch;
this.playAtLocation = playAtLocation;
}
/**
* Plays the sound with the given options and updating the players location.
*
* @since 3.0.0
*/
public void play() {
play(player == null ? location : player.getLocation());
}
/**
* Plays the sound with the updated location.
*
* @param updatedLocation the upated location.
* @since 3.0.0
*/
public void play(Location updatedLocation) {
if (playAtLocation) location.getWorld().playSound(updatedLocation, sound, volume, pitch);
else if (player.isOnline()) player.playSound(updatedLocation, sound, volume, pitch);
}
}
} | 55,155 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ThrowableRunnable.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ThrowableRunnable.java | package me.patothebest.gamecore.util;
@FunctionalInterface
public interface ThrowableRunnable<T extends Throwable> {
void run() throws T;
} | 145 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
CacheCollection.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/CacheCollection.java | package me.patothebest.gamecore.util;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
public class CacheCollection<E> implements Collection<E> {
private final Cache<E, Byte> cacheMap;
@SuppressWarnings("unchecked")
public CacheCollection(CallableCallback<CacheBuilder> mapper) {
CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
cacheBuilder = mapper.call(cacheBuilder);
this.cacheMap = cacheBuilder.build();
}
/**
* Returns the number of elements in this list. If this list contains
* more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this list
*/
@Override
public int size() {
return (int) cacheMap.size();
}
/**
* Returns <tt>true</tt> if this list contains no elements.
*
* @return <tt>true</tt> if this list contains no elements
*/
@Override
public boolean isEmpty() {
return cacheMap.size() == 0;
}
/**
* Returns <tt>true</tt> if this list contains the specified element.
* More formally, returns <tt>true</tt> if and only if this list contains
* at least one element <tt>e</tt> such that
* <tt>(o==null ? e==null : o.equals(e))</tt>.
*
* @param o element whose presence in this list is to be tested
*
* @return <tt>true</tt> if this list contains the specified element
*
* @throws ClassCastException if the type of the specified element
* is incompatible with this list
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified element is null and this
* list does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>)
*/
@Override
public boolean contains(Object o) {
return cacheMap.asMap().containsKey(o);
}
/**
* Returns an iterator over the elements in this list in proper sequence.
*
* @return an iterator over the elements in this list in proper sequence
*/
@Override
public Iterator<E> iterator() {
return cacheMap.asMap().keySet().iterator();
}
/**
* Returns an array containing all of the elements in this list in proper
* sequence (from first to last element).
* <p>
* <p>The returned array will be "safe" in that no references to it are
* maintained by this list. (In other words, this method must
* allocate a new array even if this list is backed by an array).
* The caller is thus free to modify the returned array.
* <p>
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all of the elements in this list in proper
* sequence
*
* @see Arrays#asList(Object[])
*/
@Override
public Object[] toArray() {
return cacheMap.asMap().keySet().toArray();
}
/**
* Returns an array containing all of the elements in this list in
* proper sequence (from first to last element); the runtime type of
* the returned array is that of the specified array. If the list fits
* in the specified array, it is returned therein. Otherwise, a new
* array is allocated with the runtime type of the specified array and
* the size of this list.
* <p>
* <p>If the list fits in the specified array with room to spare (i.e.,
* the array has more elements than the list), the element in the array
* immediately following the end of the list is set to <tt>null</tt>.
* (This is useful in determining the length of the list <i>only</i> if
* the caller knows that the list does not contain any null elements.)
* <p>
* <p>Like the {@link #toArray()} method, this method acts as bridge between
* array-based and collection-based APIs. Further, this method allows
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
* <p>
* <p>Suppose <tt>x</tt> is a list known to contain only strings.
* The following code can be used to dump the list into a newly
* allocated array of <tt>String</tt>:
* <p>
* <pre>{@code
* String[] y = x.toArray(new String[0]);
* }</pre>
* <p>
* Note that <tt>toArray(new Object[0])</tt> is identical in function to
* <tt>toArray()</tt>.
*
* @param a the array into which the elements of this list are to
* be stored, if it is big enough; otherwise, a new array of the
* same runtime type is allocated for this purpose.
*
* @return an array containing the elements of this list
*
* @throws ArrayStoreException if the runtime type of the specified array
* is not a supertype of the runtime type of every element in
* this list
* @throws NullPointerException if the specified array is null
*/
@Override
public <T> T[] toArray(T[] a) {
return cacheMap.asMap().keySet().toArray(a);
}
/**
* Appends the specified element to the end of this list (optional
* operation).
* <p>
* <p>Lists that support this operation may place limitations on what
* elements may be added to this list. In particular, some
* lists will refuse to add null elements, and others will impose
* restrictions on the type of elements that may be added. List
* classes should clearly specify in their documentation any restrictions
* on what elements may be added.
*
* @param e element to be appended to this list
*
* @return <tt>true</tt> (as specified by {@link Collection#add})
*
* @throws UnsupportedOperationException if the <tt>add</tt> operation
* is not supported by this list
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this list
* @throws NullPointerException if the specified element is null and this
* list does not permit null elements
* @throws IllegalArgumentException if some property of this element
* prevents it from being added to this list
*/
@Override
public boolean add(E e) {
cacheMap.put(e, (byte) 0);
return true;
}
/**
* Removes the first occurrence of the specified element from this list,
* if it is present (optional operation). If this list does not contain
* the element, it is unchanged. More formally, removes the element with
* the lowest index <tt>i</tt> such that
* <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>
* (if such an element exists). Returns <tt>true</tt> if this list
* contained the specified element (or equivalently, if this list changed
* as a result of the call).
*
* @param o element to be removed from this list, if present
*
* @return <tt>true</tt> if this list contained the specified element
*
* @throws ClassCastException if the type of the specified element
* is incompatible with this list
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified element is null and this
* list does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws UnsupportedOperationException if the <tt>remove</tt> operation
* is not supported by this list
*/
@Override
public boolean remove(Object o) {
cacheMap.invalidate(o);
return true;
}
/**
* Returns <tt>true</tt> if this list contains all of the elements of the
* specified collection.
*
* @param c collection to be checked for containment in this list
*
* @return <tt>true</tt> if this list contains all of the elements of the
* specified collection
*
* @throws ClassCastException if the types of one or more elements
* in the specified collection are incompatible with this
* list
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified collection contains one
* or more null elements and this list does not permit null
* elements
* (<a href="Collection.html#optional-restrictions">optional</a>),
* or if the specified collection is null
* @see #contains(Object)
*/
@Override
public boolean containsAll(Collection<?> c) {
for (Object o : c) {
if (!contains(o)) {
return false;
}
}
return true;
}
/**
* Appends all of the elements in the specified collection to the end of
* this list, in the order that they are returned by the specified
* collection's iterator (optional operation). The behavior of this
* operation is undefined if the specified collection is modified while
* the operation is in progress. (Note that this will occur if the
* specified collection is this list, and it's nonempty.)
*
* @param c collection containing elements to be added to this list
*
* @return <tt>true</tt> if this list changed as a result of the call
*
* @throws UnsupportedOperationException if the <tt>addAll</tt> operation
* is not supported by this list
* @throws ClassCastException if the class of an element of the specified
* collection prevents it from being added to this list
* @throws NullPointerException if the specified collection contains one
* or more null elements and this list does not permit null
* elements, or if the specified collection is null
* @throws IllegalArgumentException if some property of an element of the
* specified collection prevents it from being added to this list
* @see #add(Object)
*/
@Override
public boolean addAll(Collection<? extends E> c) {
for (E e : c) {
add(e);
}
return true;
}
/**
* Removes from this list all of its elements that are contained in the
* specified collection (optional operation).
*
* @param c collection containing elements to be removed from this list
*
* @return <tt>true</tt> if this list changed as a result of the call
*
* @throws UnsupportedOperationException if the <tt>removeAll</tt> operation
* is not supported by this list
* @throws ClassCastException if the class of an element of this list
* is incompatible with the specified collection
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if this list contains a null element and the
* specified collection does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>),
* or if the specified collection is null
* @see #remove(Object)
* @see #contains(Object)
*/
@Override
public boolean removeAll(Collection<?> c) {
for (Object o : c) {
remove(o);
}
return true;
}
/**
* Retains only the elements in this list that are contained in the
* specified collection (optional operation). In other words, removes
* from this list all of its elements that are not contained in the
* specified collection.
*
* @param c collection containing elements to be retained in this list
*
* @return <tt>true</tt> if this list changed as a result of the call
*
* @throws UnsupportedOperationException if the <tt>retainAll</tt> operation
* is not supported by this list
* @throws ClassCastException if the class of an element of this list
* is incompatible with the specified collection
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if this list contains a null element and the
* specified collection does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>),
* or if the specified collection is null
* @see #remove(Object)
* @see #contains(Object)
*/
@Override
public boolean retainAll(Collection<?> c) {
removeIf(e -> !c.contains(e));
return true;
}
/**
* Removes all of the elements from this list (optional operation).
* The list will be empty after this call returns.
*
* @throws UnsupportedOperationException if the <tt>clear</tt> operation
* is not supported by this list
*/
@Override
public void clear() {
cacheMap.invalidateAll();
}
}
| 14,420 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
DoubleCallback.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/DoubleCallback.java | package me.patothebest.gamecore.util;
public interface DoubleCallback<T, V> {
void call(T t, V v) ;
} | 108 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
ObservablePlayer.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/ObservablePlayer.java | package me.patothebest.gamecore.util;
import me.patothebest.gamecore.player.modifiers.PlayerModifier;
/**
* This class represents an observable object, or "data"
* in the model-view paradigm. It can be subclassed to represent an
* object that the application wants to have observed.
* <p>
* An observable object can have one or more observers. An observer
* may be any object that implements interface <tt>PlayerObserver</tt>. After an
* observable instance changes, an application calling the
* <code>ObservablePlayer</code>'s <code>notifyObservers</code> method
* causes all of its observers to be notified of the change by a call
* to their <code>update</code> method.
* <p>
* The order in which notifications will be delivered is unspecified.
* The default implementation provided in the ObservablePlayer class will
* notify Observers in the order in which they registered interest, but
* subclasses may change this order, use no guaranteed order, deliver
* notifications on separate threads, or may guarantee that their
* subclass follows this order, as they choose.
* <p>
* Note that this notification mechanism has nothing to do with threads
* and is completely separate from the <tt>wait</tt> and <tt>notify</tt>
* mechanism of class <tt>Object</tt>.
* <p>
* When an observable object is newly created, its set of observers is
* empty. Two observers are considered the same if and only if the
* <tt>equals</tt> method returns true for them.
*
* @author Chris Warth
* @see java.util.Observable#notifyObservers()
* @see java.util.Observable#notifyObservers(java.lang.Object)
* @see java.util.Observer
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
* @since JDK1.0
*/
public interface ObservablePlayer {
/**
* Adds an observer to the set of observers for this object, provided
* that it is not the same as some observer already in the set.
* The order in which notifications will be delivered to multiple
* observers is not specified. See the class comment.
*
* @param o an observer to be added.
*
* @throws NullPointerException if the parameter o is null.
*/
void addObserver(PlayerObserver o);
/**
* Deletes an observer from the set of observers of this object.
* Passing <CODE>null</CODE> to this method will have no effect.
*
* @param o the observer to be deleted.
*/
void deleteObserver(PlayerObserver o);
/**
* If this object has changed, as indicated by the
* <code>hasChanged</code> method, then notify all of its observers
* and then call the <code>clearChanged</code> method to indicate
* that this object has no longer changed.
* <p>
* Each observer has its <code>update</code> method called with two
* arguments: this observable object and the <code>arg</code> argument.
*
* @param modifiedType modified type
* @param args the extra args
*
* @see java.util.Observable#clearChanged()
* @see java.util.Observable#hasChanged()
* @see java.util.Observer#update(java.util.Observable, Object)
*/
void notifyObservers(PlayerModifier modifiedType, Object... args);
/**
* Clears the observer list so that this object no longer has any observers.
*/
void deleteObservers();
/**
* Returns the number of observers of this <tt>ObservablePlayer</tt> object.
*
* @return the number of observers of this object.
*/
int countObservers();
}
| 3,529 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
WrappedBukkitRunnable.java | /FileExtraction/Java_unseen/PatoTheBest_MiniGames/GameCore/src/main/java/me/patothebest/gamecore/util/WrappedBukkitRunnable.java | package me.patothebest.gamecore.util;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
/**
* This class is provided as an easy way to handle scheduling tasks.
*/
public abstract class WrappedBukkitRunnable extends BukkitRunnable {
private int taskId = -1;
/**
* Attempts to cancel this task.
*
* @throws IllegalStateException if task was not scheduled yet
*/
public synchronized void cancel() throws IllegalStateException {
if(!hasBeenScheduled()) {
return;
}
Bukkit.getScheduler().cancelTask(getTaskId());
this.taskId = -1;
}
/**
* Schedules this in the Bukkit scheduler to run on next tick.
*
* @param plugin the reference to the plugin scheduling task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTask(Plugin, Runnable)
*/
public synchronized BukkitTask runTask(Plugin plugin) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTask(plugin, (Runnable) this));
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Schedules this in the Bukkit scheduler to run asynchronously.
*
* @param plugin the reference to the plugin scheduling task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable)
*/
public synchronized BukkitTask runTaskAsynchronously(Plugin plugin) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this));
}
/**
* Schedules this to run after the specified number of server ticks.
*
* @param plugin the reference to the plugin scheduling task
* @param delay the ticks to wait before running the task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTaskLater(Plugin, Runnable, long)
*/
public synchronized BukkitTask runTaskLater(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay));
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Schedules this to run asynchronously after the specified number of
* server ticks.
*
* @param plugin the reference to the plugin scheduling task
* @param delay the ticks to wait before running the task
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long)
*/
public synchronized BukkitTask runTaskLaterAsynchronously(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay));
}
/**
* Schedules this to repeatedly run until cancelled, starting after the
* specified number of server ticks.
*
* @param plugin the reference to the plugin scheduling task
* @param delay the ticks to wait before running the task
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long)
*/
public synchronized BukkitTask runTaskTimer(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period));
}
/**
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
* should be taken to assure the thread-safety of asynchronous tasks.</b>
* <p>
* Schedules this to repeatedly run asynchronously until cancelled,
* starting after the specified number of server ticks.
*
* @param plugin the reference to the plugin scheduling task
* @param delay the ticks to wait before running the task for the first
* time
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @see BukkitScheduler#runTaskTimerAsynchronously(Plugin, Runnable, long,
* long)
*/
public synchronized BukkitTask runTaskTimerAsynchronously(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkState();
return setupId(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period));
}
/**
* Gets the task id for this runnable.
*
* @return the task id that this runnable was scheduled as
* @throws IllegalStateException if task was not scheduled yet
*/
public synchronized int getTaskId() throws IllegalStateException {
final int id = taskId;
if (id == -1) {
throw new IllegalStateException("Not scheduled yet");
}
return id;
}
/**
* Checks if the task has already been scheduled, this is done by
* checking if the task has already a task id assigned
*
* @return true if the task has already been scheduled
*/
public synchronized boolean hasBeenScheduled() {
return taskId != -1;
}
private void checkState() {
// if the task is already running...
if(hasBeenScheduled()) {
// ...display an error message...
System.err.println("Task " + this.getClass().getSimpleName() + " tried to re-schedule without canceling. Canceling previous scheduled task to avoid issues");
// ...and cancel the task to avoid any issues
cancel();
}
}
private BukkitTask setupId(final BukkitTask task) {
this.taskId = task.getTaskId();
return task;
}
}
| 7,104 | Java | .java | PatoTheBest/MiniGames | 13 | 2 | 1 | 2020-08-07T03:43:56Z | 2022-01-23T23:52:46Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.