├── bin └── .gitignore ├── src └── com │ └── LagBug │ └── ThePit │ ├── GUIs │ ├── HelpGUI.java │ ├── ItemsGUI.java │ ├── UpgradesGUI.java │ └── PerksGUI.java │ ├── Events │ ├── OnDeath.java │ ├── OnInteract.java │ ├── OnLevelUp.java │ ├── OnMobSpawn.java │ ├── OnHunger.java │ ├── OnMove.java │ ├── OnBreak.java │ ├── OnFall.java │ ├── OnChat.java │ ├── OnLeave.java │ ├── OnPlace.java │ ├── OnPickUp.java │ ├── OnRespawn.java │ ├── OnSignChange.java │ ├── OnJoin.java │ └── OnFight.java │ ├── GUIListners │ ├── PerksGUIListener.java │ ├── UpgradesGUIListener.java │ ├── HelpGUIListener.java │ └── ItemsGUIListener.java │ ├── Others │ ├── UpdateResult.java │ ├── StringUtils.java │ ├── TabList.java │ ├── ItemBuilder.java │ ├── TabComplete.java │ ├── UpdateChecker.java │ ├── GiveItems.java │ ├── PlayerManager.java │ ├── FileUtils.java │ └── CustomScoreboard.java │ ├── Commands │ ├── PitCommands │ │ ├── Reload.java │ │ ├── SetLobby.java │ │ ├── Adminmode.java │ │ ├── List.java │ │ ├── Create.java │ │ ├── Discord.java │ │ ├── AddGold.java │ │ ├── Launchpad.java │ │ ├── RemGold.java │ │ ├── SetGold.java │ │ ├── Leave.java │ │ ├── AddLevel.java │ │ ├── SetLevel.java │ │ ├── RemLevel.java │ │ ├── SetSpawn.java │ │ ├── Delete.java │ │ ├── Join.java │ │ ├── SetMax.java │ │ └── GoldLoc.java │ ├── UpgradesCommand.java │ ├── PerksCommand.java │ ├── ItemsCommand.java │ └── PitCommand.java │ ├── Runnables │ └── GoldRunnable.java │ ├── Actiobar │ └── Actionbar.java │ └── Main.java ├── .settings └── org.eclipse.core.resources.prefs ├── plugin.yml ├── .classpath ├── .project ├── guis ├── items.yml └── upgrades.yml ├── README.md ├── messages.yml └── config.yml /bin/.gitignore: -------------------------------------------------------------------------------- 1 | /com/ 2 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIs/HelpGUI.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/GUIs/HelpGUI.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnDeath.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/Events/OnDeath.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnInteract.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/Events/OnInteract.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnLevelUp.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/Events/OnLevelUp.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIListners/PerksGUIListener.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/GUIListners/PerksGUIListener.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIListners/UpgradesGUIListener.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LagBug/ThePit/HEAD/src/com/LagBug/ThePit/GUIListners/UpgradesGUIListener.java -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/UpdateResult.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | public enum UpdateResult { 4 | FOUND, 5 | NOT_FOUND, 6 | DEVELOPMENT, 7 | ERROR 8 | } 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/com/LagBug/ThePit/Events/OnFight.java=UTF-8 3 | encoding//src/com/LagBug/ThePit/GUIs/PerksGUI.java=UTF-8 4 | encoding/config.yml=UTF-8 5 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: ThePit 2 | version: 0.0.3 3 | main: com.LagBug.ThePit.Main 4 | description: An advanced and free ThePit plugin. 5 | commands: 6 | pit: 7 | description: Main command for the plugin. 8 | items: 9 | description: Opens the items gui. 10 | perks: 11 | description: Opens the perks gui. 12 | upgrades: 13 | description: Opens the upgrades gui. -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnMobSpawn.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.Listener; 5 | import org.bukkit.event.entity.CreatureSpawnEvent; 6 | 7 | import com.LagBug.ThePit.Main; 8 | 9 | public class OnMobSpawn implements Listener { 10 | 11 | private Main main = Main.getPlugin(Main.class); 12 | 13 | @EventHandler 14 | public void onMobSpawn(CreatureSpawnEvent e) { 15 | if (main.getConfig().getBoolean("general.spawn-mobs") == false) { 16 | e.setCancelled(true); 17 | } 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | 6 | public class StringUtils { 7 | 8 | public static Location LocFromString(String string) { 9 | String[] loc = string.split(":"); 10 | return new Location(Bukkit.getWorld(loc[0]), Double.parseDouble(loc[1]), Double.parseDouble(loc[2]), 11 | Double.parseDouble(loc[3]), (float) Double.parseDouble(loc[4]), (float) Double.parseDouble(loc[5])); 12 | } 13 | 14 | public static String SringFromLoc(Location loc) { 15 | return loc.getWorld().getName() + ":" + loc.getX() + ":" + loc.getY() + ":" + loc.getZ() + ":" + loc.getYaw() 16 | + ":" + loc.getPitch(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Reload.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.LagBug.ThePit.Main; 8 | 9 | public class Reload { 10 | 11 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 12 | Player player = (Player) sender; 13 | 14 | if (!player.hasPermission("pit.admin.reload") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 15 | player.sendMessage(main.getMessage("general.no-permission")); 16 | return false; 17 | } 18 | 19 | main.saveFiles(); 20 | player.sendMessage(main.getMessage("commands.reload.success")); 21 | 22 | return false; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnHunger.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.entity.FoodLevelChangeEvent; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class OnHunger implements Listener { 11 | 12 | private Main main = Main.getPlugin(Main.class); 13 | 14 | @EventHandler 15 | public void onHunger(FoodLevelChangeEvent e) { 16 | Player player = (Player)e.getEntity(); 17 | if (player == null) return; 18 | if ((main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) || (main.getDataFile().getString("lobby.world") != null && player.getWorld().getName().equals(main.getDataFile().getString("lobby.world")))) { 19 | if (main.getConfig().getBoolean("general.lose-hunger") == false) { 20 | e.setCancelled(true); 21 | e.setFoodLevel(20); 22 | } 23 | } 24 | 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/TabList.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import org.bukkit.ChatColor; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.LagBug.ThePit.Main; 7 | 8 | public class TabList { 9 | 10 | public static String getLevel(Player player) { 11 | int lvl = player.getLevel(); 12 | int min = (int) Math.floor(lvl/10.0) * 10; 13 | int max = (int) Math.ceil(lvl/9.9) * 10 - 1; 14 | if (lvl <= 0) { max = 9; } 15 | if (lvl >= 120) { return "120"; } 16 | 17 | return min+"to"+max; 18 | 19 | } 20 | 21 | public static void setTabName(Player player, Main main) { 22 | int lvl = player.getLevel(); 23 | 24 | player.setPlayerListName(ChatColor.translateAlternateColorCodes('&', 25 | main.getConfig().getString("format.tablist-format") 26 | .replace("%lvl%", ChatColor.translateAlternateColorCodes('&', 27 | main.getConfig().getString("leveling-system." + getLevel(player) + ".color") + lvl)) 28 | .replace("%player%", player.getName()))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnMove.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.block.BlockFace; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.player.PlayerMoveEvent; 9 | import org.bukkit.util.Vector; 10 | 11 | import com.LagBug.ThePit.Main; 12 | 13 | public class OnMove implements Listener { 14 | 15 | private Main main = Main.getPlugin(Main.class); 16 | 17 | @EventHandler 18 | public void onMove(PlayerMoveEvent e) { 19 | Block stand = e.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN); 20 | if (stand.getType() == Material.SLIME_BLOCK) { 21 | double lpPower = main.getConfig().getDouble("general.launchpad-power"); 22 | e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(lpPower)); 23 | e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.0D, e.getPlayer().getVelocity().getZ())); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnBreak.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.block.BlockBreakEvent; 9 | 10 | import com.LagBug.ThePit.Main; 11 | 12 | 13 | public class OnBreak implements Listener { 14 | 15 | private Main main = Main.getPlugin(Main.class); 16 | 17 | @EventHandler 18 | public void onPlace(final BlockBreakEvent e) { 19 | Player player = e.getPlayer(); 20 | 21 | if ((main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) || (main.getDataFile().getString("lobby.world") != null && player.getWorld().getName().equals(main.getDataFile().getString("lobby.world")))) { 22 | if (!(main.adminmode.contains(player))) { 23 | if (!(e.getBlock().getType().equals(Material.COBBLESTONE) || e.getBlock().getType().equals(Material.OBSIDIAN))) { 24 | e.setCancelled(true); 25 | } 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnFall.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.entity.EntityDamageEvent; 7 | import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | public class OnFall implements Listener { 12 | 13 | private Main main = Main.getPlugin(Main.class); 14 | 15 | @EventHandler 16 | public void onFall(EntityDamageEvent e) { 17 | Player player = (Player) e.getEntity(); 18 | if (player == null) return; 19 | if ((main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) || (main.getDataFile().getString("lobby.world") != null && player.getWorld().getName().equals(main.getDataFile().getString("lobby.world")))) { 20 | if (main.getConfig().getBoolean("general.fall-damage") == false) { 21 | if (e.getCause() == DamageCause.FALL) { 22 | e.setCancelled(true); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/SetLobby.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.StringUtils; 10 | 11 | public class SetLobby { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | 15 | Player player = (Player) sender; 16 | FileConfiguration afile = main.getArenaFile(); 17 | 18 | if (!player.hasPermission("pit.admin.setlobby") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | afile.set("lobby", StringUtils.SringFromLoc(player.getLocation())); 24 | main.saveFiles(); 25 | player.sendMessage(main.getMessage("commands.setlobby.set")); 26 | 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Adminmode.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.GameMode; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class Adminmode { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | Player player = (Player) sender; 14 | 15 | if (!player.hasPermission("pit.admin.adminmode") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 16 | player.sendMessage(main.getMessage("general.no-permission")); 17 | return false; 18 | } 19 | if (!main.adminmode.contains(player)) { 20 | main.adminmode.add(player); 21 | player.setGameMode(GameMode.CREATIVE); 22 | player.sendMessage(main.getMessage("commands.adminmode.enabled")); 23 | } else { 24 | main.adminmode.remove(player); 25 | player.setGameMode(GameMode.SURVIVAL); 26 | player.sendMessage(main.getMessage("commands.adminmode.disabled")); 27 | } 28 | 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/ItemBuilder.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.Material; 8 | import org.bukkit.inventory.ItemFlag; 9 | import org.bukkit.inventory.ItemStack; 10 | import org.bukkit.inventory.meta.ItemMeta; 11 | 12 | 13 | public class ItemBuilder { 14 | 15 | ItemStack item; 16 | ItemMeta meta; 17 | 18 | public ItemBuilder(Material material, int amount, int data) { 19 | item = new ItemStack(material, amount, (byte) data); 20 | meta = item.getItemMeta(); 21 | } 22 | 23 | public ItemBuilder setDisplayName(String name) { 24 | meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); 25 | return this; 26 | } 27 | 28 | public ItemBuilder setLore(List lore) { 29 | List loreR = new ArrayList<>(); 30 | for (String s : lore) { 31 | loreR.add(ChatColor.translateAlternateColorCodes('&', s)); 32 | } 33 | meta.setLore(loreR); 34 | return this; 35 | } 36 | 37 | public ItemStack build() { 38 | meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); 39 | item.setItemMeta(meta); 40 | return item; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnChat.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.ChatColor; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.AsyncPlayerChatEvent; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | public class OnChat implements Listener { 12 | 13 | private Main main = Main.getPlugin(Main.class); 14 | 15 | @EventHandler 16 | public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) { 17 | 18 | Player player = e.getPlayer(); 19 | int level = player.getLevel(); 20 | 21 | e.setFormat(ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("format.chat-format") 22 | .replace("%lvl%", main.getConfig().getString("leveling-system." + getLevel(player) + ".color") + level) 23 | .replace("%player%", player.getName()) 24 | .replace("%message%", e.getMessage()))); 25 | 26 | } 27 | 28 | public String getLevel(Player player) { 29 | 30 | int lvl = player.getLevel(); 31 | int min = (int) Math.floor(lvl / 10.0) * 10; 32 | int max = (int) Math.ceil(lvl / 9.9) * 10 - 1; 33 | 34 | if (lvl <= 0) { max = 9; } 35 | if (lvl >= 120) { return "120"; } 36 | 37 | return min + "to" + max; 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /guis/items.yml: -------------------------------------------------------------------------------- 1 | title: 'Non-permanent items' 2 | availabilityColors: '&e:&c' 3 | availabilityMessages: 'Click to purchase:Not enough gold' 4 | slots: 27 5 | items: 6 | '0': 7 | name: '%color%Diamond Sword' 8 | material: 'DIAMOND_SWORD:1:0' 9 | slot: 10 10 | price: 100 11 | lore: 12 | - '&7+6 Attack damage.' 13 | - '' 14 | - '&7&oLost on death' 15 | - '&7Cost: &6%price%g' 16 | - '%color%%message%' 17 | '1': 18 | name: '%color%Obsidian' 19 | material: 'OBSIDIAN:8:0' 20 | slot: 11 21 | price: 40 22 | lore: 23 | - '&7+6 Remains for 120 seconds.' 24 | - '' 25 | - '&7&oLost on death' 26 | - '&7Cost: &6%price%g' 27 | - '%color%%message%' 28 | '2': 29 | name: '%color%Diamond Chestplate' 30 | material: 'DIAMOND_CHESTPLATE:1:0' 31 | slot: 15 32 | price: 250 33 | lore: 34 | - '&7Auto-equips on buy.' 35 | - '' 36 | - '&7&oLost on death' 37 | - '&7Cost: &6%price%g' 38 | - '%color%%message%' 39 | '3': 40 | name: '%color%Diamond Boots' 41 | material: 'DIAMOND_BOOTS:1:0' 42 | slot: 16 43 | price: 150 44 | lore: 45 | - '&7Auto-equips on buy.' 46 | - '' 47 | - '&7&oLost on death' 48 | - '&7Cost: &6%price%' 49 | - '%color%%message%' -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/List.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | public class List { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | Player player = (Player) sender; 15 | java.util.List arenas = new ArrayList<>(); 16 | 17 | if (!player.hasPermission("pit.user.list") || !player.hasPermission("pit.user.*")|| !player.hasPermission("pit.*")) { 18 | player.sendMessage(main.getMessage("general.no-permission")); 19 | return false; 20 | } 21 | 22 | if (main.getArenaFile().getConfigurationSection("arenas") == null) { 23 | player.sendMessage(main.getMessage("commands.arena.not-found")); 24 | return false; 25 | } 26 | 27 | for (String s : main.getArenaFile().getConfigurationSection("arenas").getKeys(false)) { 28 | arenas.add(main.getArenaFile().getString("arenas." + s + ".name")); 29 | } 30 | 31 | player.sendMessage(main.getMessage("commands.arena.list").replace("%arenas%", arenas.toString())); 32 | 33 | return false; 34 | } 35 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/UpgradesCommand.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandExecutor; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import com.LagBug.ThePit.Main; 11 | import com.LagBug.ThePit.GUIs.UpgradesGUI; 12 | 13 | 14 | public class UpgradesCommand implements CommandExecutor { 15 | 16 | private Main main = Main.getPlugin(Main.class); 17 | 18 | @Override 19 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 20 | 21 | if (!(sender instanceof Player)) { 22 | Bukkit.getConsoleSender().sendMessage(main.getMessage("general.no-console")); 23 | } else { 24 | Player player = (Player) sender; 25 | if (!player.hasPermission("pit.user.upgrades") || !player.hasPermission("pit.user.*")) { 26 | player.sendMessage(main.getMessage("general.no-permission")); 27 | } else { 28 | if (main.playerArena.get(player) == null || main.playerArena.get(player).equals("")) { 29 | player.sendMessage(main.getMessage("commands.arena.not-in-arena")); 30 | return false; 31 | } 32 | new UpgradesGUI().OpenGUI(player); 33 | } 34 | } 35 | return false; 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Create.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | 11 | public class Create { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | Player player = (Player) sender; 15 | FileConfiguration afile = main.getArenaFile(); 16 | int counter = afile.getInt("arenasCounter"); 17 | 18 | if (!player.hasPermission("pit.admin.create") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("genral.no-permissions")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 1) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit create ")); 25 | return false; 26 | } 27 | 28 | afile.set("arenas." + (counter + 1) + ".name", args[1]); 29 | afile.set("arenasCounter", counter + 1); 30 | main.saveFiles(); 31 | player.sendMessage(main.getMessage("commands.arena.create").replace("%arena%", args[1])); 32 | 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PerksCommand.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandExecutor; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import com.LagBug.ThePit.Main; 11 | import com.LagBug.ThePit.GUIs.PerksGUI; 12 | 13 | 14 | public class PerksCommand implements CommandExecutor { 15 | private Main main = Main.getPlugin(Main.class); 16 | private PerksGUI pgui; 17 | 18 | public PerksCommand () { 19 | this.pgui = new PerksGUI(main); 20 | } 21 | @Override 22 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 23 | 24 | if (!(sender instanceof Player)) { 25 | if (cmd.getName().equalsIgnoreCase("perks")) { 26 | Bukkit.getConsoleSender().sendMessage(main.getMessage("general.no-console")); 27 | } 28 | } else { 29 | Player player = (Player) sender; 30 | if (!player.hasPermission("pit.user.perks") || !player.hasPermission("pit.user.*")) { 31 | player.sendMessage(main.getMessage("general.no-permission")); 32 | } else { 33 | if (main.playerArena.get(player) == null || main.playerArena.get(player).equals("")) { 34 | player.sendMessage(main.getMessage("commands.arena.not-in-arena")); 35 | return false; 36 | } 37 | pgui.OpenGUI(player); 38 | } 39 | } 40 | return false; 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/ItemsCommand.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandExecutor; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import com.LagBug.ThePit.Main; 11 | import com.LagBug.ThePit.GUIs.ItemsGUI; 12 | 13 | 14 | public class ItemsCommand implements CommandExecutor { 15 | 16 | private Main main = Main.getPlugin(Main.class); 17 | private ItemsGUI itemsgui; 18 | 19 | public ItemsCommand () { 20 | this.itemsgui = new ItemsGUI(); 21 | } 22 | @Override 23 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 24 | 25 | if (!(sender instanceof Player)) { 26 | if (cmd.getName().equalsIgnoreCase("items")) { 27 | Bukkit.getConsoleSender().sendMessage(main.getMessage("general.no-console")); 28 | } 29 | } else { 30 | Player player = (Player) sender; 31 | if (!player.hasPermission("pit.user.items") || !player.hasPermission("pit.user.*")) { 32 | player.sendMessage(main.getMessage("general.no-permission")); 33 | } else { 34 | if (main.playerArena.get(player) == null || main.playerArena.get(player).equals("")) { 35 | player.sendMessage(main.getMessage("commands.arena.not-in-arena")); 36 | return false; 37 | } 38 | itemsgui.OpenGUI(player); 39 | } 40 | } 41 | return false; 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Discord.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.LagBug.ThePit.Main; 8 | 9 | import net.md_5.bungee.api.ChatColor; 10 | import net.md_5.bungee.api.chat.ClickEvent; 11 | import net.md_5.bungee.api.chat.ComponentBuilder; 12 | import net.md_5.bungee.api.chat.HoverEvent; 13 | import net.md_5.bungee.api.chat.TextComponent; 14 | 15 | public class Discord { 16 | 17 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 18 | Player player = (Player) sender; 19 | 20 | if (!player.hasPermission("pit.admin.discord") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 21 | player.sendMessage(main.getMessage("general.no-permission")); 22 | return false; 23 | } 24 | 25 | TextComponent msg = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&8&l > &6Join the support Discord: &ehttps://discord.gg/sJg2J56")); 26 | msg.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, "https://discord.gg/sJg2J56")); 27 | msg.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&6Click this message to join.")).create())); 28 | 29 | player.spigot().sendMessage(msg); 30 | 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnLeave.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Location; 6 | import org.bukkit.World; 7 | import org.bukkit.configuration.file.FileConfiguration; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.player.PlayerQuitEvent; 12 | 13 | import com.LagBug.ThePit.Main; 14 | 15 | 16 | public class OnLeave implements Listener{ 17 | 18 | private Main main = Main.getPlugin(Main.class); 19 | 20 | @EventHandler 21 | public void onLeave(PlayerQuitEvent e) { 22 | FileConfiguration dfile = main.getDataFile(); 23 | Player player = e.getPlayer(); 24 | Location loc = null; 25 | if (dfile.getString("lobby") != null) { 26 | World world = Bukkit.getWorld(dfile.getString("lobby.world")); 27 | double x = dfile.getDouble("lobby.x"); 28 | double y = dfile.getDouble("lobby.y"); 29 | double z = dfile.getDouble("lobby.z"); 30 | float yaw = (float) dfile.getDouble("lobby.yaw"); 31 | float pitch = (float) dfile.getDouble("lobby.pitch"); 32 | 33 | loc = new Location(world, x, y, z, yaw, pitch); 34 | } 35 | if (main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) { 36 | main.arenaCounter.put(main.playerArena.get(player), main.arenaCounter.get(main.playerArena.get(player))-1); 37 | main.playerArena.put(player, ""); 38 | player.getInventory().clear(); 39 | if (loc != null) player.teleport(loc); 40 | 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/AddGold.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.PlayerManager; 10 | 11 | public class AddGold { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | 15 | Player player = (Player) sender; 16 | PlayerManager pm = new PlayerManager(player); 17 | 18 | if (!player.hasPermission("pit.admin.addgold") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | if (args.length <= 2) { 23 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit addgold ")); 24 | } else if (args.length >= 3) { 25 | Player target = Bukkit.getPlayer(args[1]); 26 | 27 | int amount = 0; 28 | try { 29 | amount = Integer.parseInt(args[2]); 30 | } catch (NumberFormatException ex) { 31 | player.sendMessage(main.getMessage("commands.must-be-number")); 32 | return false; 33 | } 34 | if (target == null) { 35 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 36 | } else { 37 | player.sendMessage(main.getMessage("commands.gold.add")); 38 | pm.addGold(amount); 39 | } 40 | } 41 | 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Launchpad.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.Material; 6 | import org.bukkit.command.Command; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import com.LagBug.ThePit.Main; 11 | 12 | public class Launchpad { 13 | 14 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 15 | 16 | Player player = (Player) sender; 17 | Location loc = player.getLocation(); 18 | 19 | if (!player.hasPermission("pit.admin.launchpad") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 20 | player.sendMessage(main.getMessage("general.no-permission")); 21 | return false; 22 | } 23 | 24 | double x = loc.getX(); 25 | double y = loc.getY(); 26 | double z = loc.getZ(); 27 | 28 | loc.getWorld().getBlockAt(loc).getRelative(0, -1, 0).setType(Material.SLIME_BLOCK); 29 | Location newLoc = new Location(player.getWorld(), x, y + 1.5, z); 30 | 31 | if (player.getAllowFlight() == false) { 32 | player.setAllowFlight(true); 33 | player.setFlying(true); 34 | 35 | 36 | Bukkit.getScheduler().runTaskLaterAsynchronously(main, () -> { 37 | player.setAllowFlight(false); 38 | player.setFlying(false); 39 | }, 100); 40 | 41 | newLoc.setYaw(loc.getYaw()); 42 | newLoc.setPitch(loc.getPitch()); 43 | player.teleport(newLoc); 44 | player.sendMessage(main.getMessage("commands.launchpad.add")); 45 | 46 | } 47 | 48 | return false; 49 | } 50 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/RemGold.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.PlayerManager; 10 | 11 | public class RemGold { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | 15 | Player player = (Player) sender; 16 | PlayerManager pm = new PlayerManager(player); 17 | 18 | if (!player.hasPermission("pit.admin.remgold") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permissions")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 2) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit remgold ")); 25 | 26 | } else if (args.length >= 3) { 27 | Player goldPlayer = Bukkit.getPlayer(args[1]); 28 | 29 | int newGold = 0; 30 | try{ 31 | newGold = Integer.parseInt(args[2]); 32 | }catch(NumberFormatException e){ 33 | player.sendMessage(main.getMessage("commands.must-be-number")); 34 | return false; 35 | } 36 | if (goldPlayer == null) { 37 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 38 | } else { 39 | player.sendMessage(main.getMessage("commands.gold.rem")); 40 | pm.removeGold(newGold); 41 | } 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnPlace.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.block.BlockPlaceEvent; 10 | 11 | import com.LagBug.ThePit.Main; 12 | 13 | 14 | public class OnPlace implements Listener { 15 | 16 | private Main main = Main.getPlugin(Main.class); 17 | 18 | @EventHandler 19 | public void onPlace(final BlockPlaceEvent e) { 20 | Player player = e.getPlayer(); 21 | 22 | if ((main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) || (main.getDataFile().getString("lobby.world") != null && player.getWorld().getName().equals(main.getDataFile().getString("lobby.world")))) { 23 | if (!(main.adminmode.contains(player))) { 24 | 25 | if (!(e.getBlock().getType().equals(Material.COBBLESTONE) || e.getBlock().getType().equals(Material.OBSIDIAN))) { 26 | e.setCancelled(true); 27 | } else { 28 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".boughtUpgrades").contains("buildbattler")) { 29 | Bukkit.getScheduler().runTaskLater(main, new Runnable() { 30 | public void run() { 31 | e.getBlock().setType(Material.AIR); 32 | } 33 | }, 20 * (120 + 60)); 34 | } else { 35 | Bukkit.getScheduler().runTaskLater(main, new Runnable() { 36 | public void run() { 37 | e.getBlock().setType(Material.AIR); 38 | } 39 | }, 20 * 120); 40 | } 41 | 42 | } 43 | } 44 | } 45 | 46 | 47 | 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/SetGold.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.PlayerManager; 10 | 11 | public class SetGold { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | 15 | Player player = (Player) sender; 16 | PlayerManager pm = new PlayerManager(player); 17 | 18 | if (!player.hasPermission("pit.admin.setgold") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 2) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit setgold ")); 25 | } else if (args.length >= 3) { 26 | 27 | Player goldPlayer = Bukkit.getPlayer(args[1]); 28 | int newGold = 0; 29 | 30 | try { 31 | newGold = Integer.parseInt(args[2]); 32 | } catch (NumberFormatException e) { 33 | player.sendMessage(main.getMessage("commands.must-be-number")); 34 | return false; 35 | } 36 | 37 | if (goldPlayer == null) { 38 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 39 | } else { 40 | pm.setGold(newGold); 41 | player.sendMessage(main.getMessage("commands.gold.set")); 42 | } 43 | } 44 | 45 | return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/TabComplete.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import org.bukkit.command.Command; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.command.TabCompleter; 11 | import org.bukkit.entity.Player; 12 | 13 | import com.LagBug.ThePit.Main; 14 | 15 | 16 | public class TabComplete implements TabCompleter { 17 | 18 | private Main main = Main.getPlugin(Main.class); 19 | 20 | @Override 21 | public List onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { 22 | List empty = new ArrayList<>(); 23 | if (sender instanceof Player) { 24 | if (cmd.getName().equalsIgnoreCase("pit")) { 25 | if (args.length == 1) { 26 | 27 | List list = new ArrayList<>(); 28 | 29 | for (String s : main.commands()) { 30 | list.add(s.substring(5)); 31 | } 32 | Collections.sort(list); 33 | return list; 34 | } else if (args.length == 2){ 35 | if (args[0].equalsIgnoreCase("launchpad") || args[0].equalsIgnoreCase("spawn") ||args[0].equalsIgnoreCase("respawn") || args[0].equalsIgnoreCase("setspawn")) { 36 | return empty; 37 | } else if (args[0].equalsIgnoreCase("goldloc")) { 38 | List list = new ArrayList<>(); 39 | list.add("add"); 40 | list.add("rem"); 41 | return list; 42 | } 43 | } else if (args.length >= 3){ 44 | return empty; 45 | } 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Leave.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.CustomScoreboard; 10 | import com.LagBug.ThePit.Others.StringUtils; 11 | 12 | public class Leave { 13 | 14 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 15 | Player player = (Player) sender; 16 | FileConfiguration afile = main.getArenaFile(); 17 | 18 | if (!player.hasPermission("pit.user.leave") || !player.hasPermission("pit.user.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | if (afile.getString("lobby") != null) { 24 | 25 | if (main.playerArena.get(player) != null && !main.playerArena.get(player).equals("")) { 26 | main.arenaCounter.put(main.playerArena.get(player), main.arenaCounter.get(main.playerArena.get(player)) - 1); 27 | new CustomScoreboard(main).disableScoreboard(player); 28 | player.teleport(StringUtils.LocFromString(afile.getString("lobby"))); 29 | player.getInventory().clear(); 30 | 31 | player.sendMessage(main.getMessage("commands.arena.leave").replace("%arena%", main.playerArena.get(player))); 32 | main.playerArena.put(player, ""); 33 | } else { 34 | player.sendMessage(main.getMessage("commands.arena.not-in-arena")); 35 | } 36 | 37 | } else { 38 | player.sendMessage(main.getMessage("commands.arena.no-lobby-loc")); 39 | } 40 | 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/AddLevel.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class AddLevel { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | Player player = (Player) sender; 14 | 15 | if (!player.hasPermission("pit.admin.addlevel") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 16 | player.sendMessage(main.getMessage("general.no-permission")); 17 | return false; 18 | } 19 | if (args.length <= 2) { 20 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit addlevel ")); 21 | } else if (args.length >= 3) { 22 | Player leveledupPlayer = Bukkit.getPlayer(args[1]); 23 | int level = 0; 24 | try { 25 | level = Integer.parseInt(args[2]); 26 | } catch (NumberFormatException e) { 27 | player.sendMessage(main.getMessage("commands.must-be-number")); 28 | return false; 29 | } 30 | if (leveledupPlayer == null) { 31 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 32 | } else { 33 | if (level < 0 || level > 120) { 34 | player.sendMessage(main.getMessage("commands.level.between")); 35 | } else { 36 | player.sendMessage(main.getMessage("commands.level.add").replace("%player%", leveledupPlayer.getName()).replace("%amount%", Integer.toString(level))); 37 | leveledupPlayer.setLevel(leveledupPlayer.getLevel() + level); 38 | } 39 | 40 | } 41 | } 42 | 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnPickUp.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerPickupItemEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import com.LagBug.ThePit.Main; 13 | 14 | import net.md_5.bungee.api.ChatColor; 15 | 16 | 17 | public class OnPickUp implements Listener { 18 | 19 | private Main main = Main.getPlugin(Main.class); 20 | 21 | @EventHandler 22 | public void onPickUp(PlayerPickupItemEvent e) { 23 | final Player player = e.getPlayer(); 24 | String uuid = player.getUniqueId().toString(); 25 | double gold = main.getDataFile().getDouble("pdata." + uuid + ".gold"); 26 | double goldOnPickup = main.getConfig().getDouble("general.gold-on-pickup"); 27 | 28 | 29 | if (e.getItem().getItemStack().isSimilar(new ItemStack (Material.GOLD_INGOT))){ 30 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks").contains("trickledown")) { goldOnPickup = goldOnPickup*7; } 31 | player.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("messages.gold-pickup-message").replace("%amount%", Double.toString(goldOnPickup).replace("%player%", player.getName())))); 32 | main.getDataFile().set("pdata." + uuid + ".gold", gold + (goldOnPickup * 7)); 33 | main.saveFiles(); 34 | Bukkit.getScheduler().runTaskLater(main, new Runnable() { 35 | public void run() { 36 | player.getInventory().removeItem(new ItemStack(Material.GOLD_INGOT, 64)); 37 | } 38 | }, 5); 39 | 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIListners/HelpGUIListener.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.GUIListners; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.inventory.InventoryClickEvent; 8 | 9 | import net.md_5.bungee.api.ChatColor; 10 | import net.md_5.bungee.api.chat.ClickEvent; 11 | import net.md_5.bungee.api.chat.ComponentBuilder; 12 | import net.md_5.bungee.api.chat.HoverEvent; 13 | import net.md_5.bungee.api.chat.TextComponent; 14 | 15 | public class HelpGUIListener implements Listener { 16 | 17 | @EventHandler 18 | public void onClick(InventoryClickEvent e) { 19 | Player player = (Player) e.getWhoClicked(); 20 | if (e.getCurrentItem() == null || e.getClickedInventory() == null || e.getInventory() == null || e.getCurrentItem().getType().equals(Material.AIR)) return; 21 | if (e.getClickedInventory().getTitle().contains("ThePit Help Menu")) { 22 | e.setCancelled(true); 23 | player.closeInventory(); 24 | hoverMessage(player, e.getCurrentItem().getItemMeta().getDisplayName().replace(ChatColor.translateAlternateColorCodes('&', "&8&l> &6"), "")); 25 | } 26 | 27 | 28 | } 29 | 30 | public void hoverMessage(Player player, String command) { 31 | TextComponent msg = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&8&l > &6Click &ehere &6to perform the command!")); 32 | msg.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command)); 33 | msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&6Yup, right here!")).create())); 34 | 35 | player.spigot().sendMessage(msg); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/SetLevel.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class SetLevel { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | 14 | Player player = (Player) sender; 15 | 16 | if (!player.hasPermission("pit.admin.setlevel") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 17 | player.sendMessage(main.getMessage("general.no-permission")); 18 | return false; 19 | } 20 | if (args.length <= 2) { 21 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit setlevel ")); 22 | } else if (args.length >= 3) { 23 | Player leveledupPlayer = Bukkit.getPlayer(args[1]); 24 | int level = 0; 25 | try { 26 | level = Integer.parseInt(args[2]); 27 | } catch (NumberFormatException e){ 28 | player.sendMessage(main.getMessage("commands.must-be-number")); 29 | return false; 30 | } 31 | if (leveledupPlayer == null) { 32 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 33 | } else { 34 | if (level < 0 || level > 120) { 35 | player.sendMessage(main.getMessage("commands.level.between")); 36 | } else { 37 | player.sendMessage(main.getMessage("commands.level.set").replace("%player%", leveledupPlayer.getName()).replace("%amount%", Integer.toString(level))); 38 | leveledupPlayer.setLevel(level); 39 | } 40 | 41 | } 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Runnables/GoldRunnable.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Runnables; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.Location; 9 | import org.bukkit.Material; 10 | import org.bukkit.World; 11 | import org.bukkit.configuration.file.FileConfiguration; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import com.LagBug.ThePit.Main; 15 | 16 | public class GoldRunnable implements Runnable { 17 | private Main main; 18 | public GoldRunnable(Main main) { 19 | this.main = main; 20 | } 21 | 22 | @Override 23 | public void run() { 24 | final List possibleLocs = new ArrayList<>(); 25 | Random random = new Random(); 26 | FileConfiguration dfile = main.getDataFile(); 27 | int onlinePlayers = Bukkit.getOnlinePlayers().size(); 28 | if (onlinePlayers >= main.getConfig().getInt("gold-generators.required-players")) { 29 | if (main.getDataFile().getConfigurationSection("goldlocs") != null) { 30 | for (String section : main.getDataFile().getConfigurationSection("goldlocs").getKeys(false)) { 31 | final World newWorld = Bukkit.getWorld(dfile.getString("goldlocs." + section + ".world")); 32 | long newX = Math.round(dfile.getDouble("goldlocs." + section + ".x")) ; 33 | long newY = Math.round(dfile.getDouble("goldlocs." + section + ".y")); 34 | long newZ = Math.round(dfile.getDouble("goldlocs." + section + ".z")); 35 | final Location newLoc = new Location(newWorld, newX, newY, newZ); 36 | possibleLocs.add(newLoc); 37 | } 38 | Location newLoc = possibleLocs.get(random.nextInt(possibleLocs.size())); 39 | World newWorld = newLoc.getWorld(); 40 | newWorld.dropItemNaturally(newLoc, new ItemStack(Material.GOLD_INGOT)); 41 | } 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/RemLevel.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class RemLevel { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | 14 | Player player = (Player) sender; 15 | 16 | if (!player.hasPermission("pit.admin.remlevel") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 17 | player.sendMessage(main.getMessage("general.no-permission")); 18 | return false; 19 | } 20 | 21 | if (args.length <= 2) { 22 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit remlevel ")); 23 | 24 | } else if (args.length >= 3) { 25 | Player leveledupPlayer = Bukkit.getPlayer(args[1]); 26 | int level = 0; 27 | try{ 28 | level = Integer.parseInt(args[2]); 29 | }catch(NumberFormatException e){ 30 | player.sendMessage(main.getMessage("commands.must-be-number")); 31 | return false; 32 | } 33 | if (leveledupPlayer == null) { 34 | player.sendMessage(main.getMessage("commands.player-not-found").replace("%player%", args[1])); 35 | } else { 36 | if (level < 0 || level > 120) { 37 | player.sendMessage(main.getMessage("commands.level.between")); 38 | } else { 39 | player.sendMessage(main.getMessage("commands.level.remove").replace("%player%", leveledupPlayer.getName()).replace("%amount%", Integer.toString(level))); 40 | leveledupPlayer.setLevel(leveledupPlayer.getLevel() - level); 41 | } 42 | 43 | } 44 | } 45 | 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/SetSpawn.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.StringUtils; 10 | 11 | public class SetSpawn { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | boolean found = false; 15 | 16 | Player player = (Player) sender; 17 | FileConfiguration afile = main.getArenaFile(); 18 | 19 | if (!player.hasPermission("pit.admin.setspawn") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 20 | player.sendMessage(main.getMessage("general.no-permission")); 21 | return false; 22 | } 23 | 24 | if (args.length <= 1) { 25 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit setspawn ")); 26 | return false; 27 | } 28 | 29 | if (afile.getConfigurationSection("arenas") == null) { 30 | player.sendMessage(main.getMessage("commands.arena.not-found")); 31 | return false; 32 | } 33 | 34 | for (String s : main.getArenaFile().getConfigurationSection("arenas").getKeys(false)) { 35 | if (args[1].equalsIgnoreCase(afile.getString("arenas." + s + ".name"))) { 36 | afile.set("arenas." + s + ".spawn", StringUtils.SringFromLoc(player.getLocation())); 37 | main.saveFiles(); 38 | player.sendMessage(main.getMessage("commands.arena.setspawn")); 39 | found = true; 40 | break; 41 | } 42 | } 43 | 44 | if (!found) { 45 | player.sendMessage(main.getMessage("commands.arena.not-found")); 46 | } 47 | 48 | return false; 49 | } 50 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/UpdateChecker.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.net.MalformedURLException; 6 | import java.net.URL; 7 | import java.net.URLConnection; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | public class UpdateChecker { 12 | 13 | private Main main; 14 | private int projectID; 15 | private String newVersion; 16 | private String currentVersion; 17 | private URL url; 18 | 19 | public UpdateChecker(Main main, int projectID) { 20 | this.main = main; 21 | this.projectID = projectID; 22 | this.currentVersion = this.main.getDescription().getVersion(); 23 | try { 24 | url = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + projectID); 25 | } catch (MalformedURLException ex) { } 26 | } 27 | 28 | 29 | public UpdateResult getResult() { 30 | try { 31 | URLConnection con = url.openConnection(); 32 | this.newVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine(); 33 | 34 | int currentV = Integer.parseInt(currentVersion.replace(".", "")); 35 | int newV = Integer.parseInt(newVersion.replace(".", "")); 36 | 37 | if (newV > currentV) { 38 | return UpdateResult.FOUND; 39 | } else if (newV < currentV) { 40 | return UpdateResult.DEVELOPMENT; 41 | } 42 | return UpdateResult.NOT_FOUND; 43 | 44 | } catch (Exception ex) { 45 | return UpdateResult.ERROR; 46 | } 47 | } 48 | 49 | public int getProjectID() { 50 | return projectID; 51 | } 52 | 53 | public String getCurrentVersion() { 54 | return currentVersion; 55 | } 56 | 57 | public String getNewVersion() { 58 | return newVersion; 59 | } 60 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnRespawn.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.World; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.player.PlayerRespawnEvent; 11 | 12 | import com.LagBug.ThePit.Main; 13 | import com.LagBug.ThePit.Others.GiveItems; 14 | 15 | public class OnRespawn implements Listener { 16 | 17 | private Main main = Main.getPlugin(Main.class); 18 | private GiveItems gi; 19 | 20 | public OnRespawn() { 21 | this.gi = new GiveItems(); 22 | } 23 | 24 | @EventHandler 25 | public void onRespawn(PlayerRespawnEvent e) { 26 | Player killed = e.getPlayer(); 27 | FileConfiguration afile = main.getArenaFile(); 28 | 29 | 30 | if (afile.getConfigurationSection("arenas") != null && main.playerArena.get(killed) != null && !main.playerArena.get(killed).equals("")) { 31 | gi.setupItems(killed); 32 | for (String s : afile.getConfigurationSection("arenas").getKeys(false)) { 33 | if (afile.getString("arenas." + s + ".spawn..world")!= null && afile.getString("arenas." + s + ".name").equals(main.playerArena.get(killed))) { 34 | String path = "arenas." + s + ".spawn"; 35 | World world = Bukkit.getWorld(afile.getString(path + ".world")); 36 | long pitch = Math.round(afile.getDouble(path + ".pitch")); 37 | long yaw = Math.round(afile.getDouble(path + ".yaw")); 38 | long x = Math.round(afile.getDouble(path + ".x")) ; 39 | long y = Math.round(afile.getDouble(path + ".y")); 40 | long z = Math.round(afile.getDouble(path + ".z")); 41 | 42 | Location loc = new Location(world, x, y, z, yaw, pitch); 43 | e.setRespawnLocation(loc); 44 | } 45 | } 46 | 47 | } 48 | } 49 | 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/GiveItems.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | 12 | public class GiveItems implements Listener { 13 | 14 | private Main main = Main.getPlugin(Main.class); 15 | 16 | public void setupItems(Player player) { 17 | 18 | 19 | player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); 20 | player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); 21 | player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); 22 | player.getInventory().setItem(0, new ItemStack(Material.IRON_SWORD)); 23 | player.getInventory().setItem(1, new ItemStack(Material.BOW)); 24 | player.getInventory().setItem(8, new ItemStack(Material.ARROW, 32, (short) 0)); 25 | 26 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks").contains("safetyfirst")) { player.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); } 27 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks").contains("fishingrod")) { player.getInventory().addItem(new ItemStack(Material.FISHING_ROD)); } 28 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks").contains("lavabucket")) { player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET)); } 29 | 30 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks").contains("mineman")) { 31 | player.getInventory().addItem(new ItemStack(Material.COBBLESTONE, 24)); 32 | player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE)); 33 | } 34 | 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Delete.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class Delete { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | boolean found = false; 14 | Player player = (Player) sender; 15 | FileConfiguration afile = main.getArenaFile(); 16 | int counter = afile.getInt("arenasCounter"); 17 | 18 | if (!player.hasPermission("pit.admin.delete") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 1) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit delete ")); 25 | return false; 26 | } 27 | 28 | if (afile.getConfigurationSection("arenas") == null || counter <= 0 ) { 29 | player.sendMessage(main.getMessage("commands.arena.not-found")); 30 | return false; 31 | } 32 | 33 | for (String s : afile.getConfigurationSection("arenas").getKeys(false)) { 34 | 35 | if (args[1].equalsIgnoreCase(afile.getString("arenas." + s + ".name"))) { 36 | afile.set("arenas." + s, null); 37 | afile.set("arenasCounter", counter - 1); 38 | main.saveFiles(); 39 | player.sendMessage(main.getMessage("commands.arena.delete").replace("%arena%", args[1])); 40 | found = true; 41 | break; 42 | } 43 | } 44 | 45 | if (!found) { 46 | player.sendMessage(main.getMessage("commands.arena.not-found")); 47 | found = false; 48 | } 49 | 50 | 51 | 52 | 53 | return false; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ThePit 2 | A remake of the popular ThePit game from Hypixel. This version is quite outdated and not maintained though. ThePit is an FFA (Free For All) PVP game. Its gameplay is pretty easy as your main goal is to fight and kill as many players as you can. Every time you get a kill, you will be rewarded with XP and gold, depending on your level. With gold, you can purchase items, upgrades, and perks which give you an advantage whilst fighting others. XP is used to level up. Gold can be earned in various ways, the simpler one is by killing others but you can also pick it up from the ground or claim bounties that are randomly getting placed if a player has a high streak. With gold, you can also a purchase diamond armor, sword, arrows, and obsidian which will help you advance faster. Perks are helpful as well as they give you a different feeling when playing, where you can have golden heads instead of golden apples, earn 7x more gold from pick-ups and much more! Finally, upgrades will help you more since your blocks will stay longer, you will earn more XP and gold, or you will deal more damage. 3 | 4 | ## Prerequisites 5 | - Java 8 or above. 6 | - A spigot server 7 | 8 | ## Installation 9 | In order to intall and get this plugin to work in your server, you'll first have to buy it from https://www.spigotmc.org/resources/thepit.61016/. After that is done, simply download it and put it in your plugins folder. Now run your server once and then stop it. Make any neccessary changes in the config or messages file and start your server again. You're now ready to go. 10 | 11 | ## In action 12 | These are a few images demostrating the plugin in action. You can also test it yourself by joining my minecraft server at `lagbug.me` 13 | 14 | ![alt text](https://i.imgur.com/nphmuIv.png) 15 | ![alt text](https://i.imgur.com/fGae3Qb.png) 16 | ![alt text](https://i.imgur.com/KmfOmpK.png) 17 | ![alt text](https://i.imgur.com/MnqU3cj.png) 18 | ![alt text](https://i.imgur.com/0gpG0fT.png) 19 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/Join.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | import com.LagBug.ThePit.Others.PlayerManager; 10 | 11 | public class Join { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | Player player = (Player) sender; 15 | boolean work = false; 16 | boolean works = false; 17 | FileConfiguration afile = main.getArenaFile(); 18 | PlayerManager pm = new PlayerManager(player); 19 | 20 | if (!player.hasPermission("pit.user.join") || !player.hasPermission("pit.user.*") || !player.hasPermission("pit.*")) { 21 | player.sendMessage(main.getMessage("general.no-permission")); 22 | return false; 23 | } 24 | 25 | if (args.length <= 1) { 26 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit join ")); 27 | return false; 28 | } 29 | 30 | if (afile.getConfigurationSection("arenas") == null) { 31 | player.sendMessage(main.getMessage("commands.arena.not-found")); 32 | return false; 33 | } 34 | 35 | for (String s : main.getArenaFile().getConfigurationSection("arenas").getKeys(false)){ 36 | if (args[1].equalsIgnoreCase(afile.getString("arenas." + s + ".name"))) { 37 | work = true; 38 | if (afile.getString("arenas." + s + ".spawn") != null) { 39 | pm.joinArena(s); 40 | works = true; 41 | break; 42 | } 43 | } 44 | } 45 | 46 | if (!work) { 47 | player.sendMessage(main.getMessage("commands.arena.not-found")); 48 | return false; 49 | } 50 | 51 | if (!works) { 52 | player.sendMessage(main.getMessage("commands.arena.no-spawn-loc")); 53 | return false; 54 | } 55 | 56 | 57 | return false; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/SetMax.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class SetMax { 11 | 12 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 13 | 14 | Player player = (Player) sender; 15 | boolean work = false; 16 | FileConfiguration afile = main.getArenaFile(); 17 | 18 | if (!player.hasPermission("pit.admin.setmax") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 2) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit setmax ")); 25 | return false; 26 | } 27 | 28 | if (afile.getConfigurationSection("arenas") == null) { 29 | player.sendMessage(main.getMessage("commands.arena.not-found")); 30 | return false; 31 | } 32 | 33 | for (String s : main.getArenaFile().getConfigurationSection("arenas").getKeys(false)) { 34 | if (args[2].equalsIgnoreCase(afile.getString("arenas." + s + ".name"))) { 35 | int num = 0; 36 | try { 37 | num = Integer.parseInt(args[1]); 38 | } catch(NumberFormatException ex) { 39 | player.sendMessage(main.getMessage("commands.must-be-number")); 40 | return false; 41 | } 42 | 43 | afile.set("arenas." + s + ".maxPlayers", num); 44 | main.saveFiles(); 45 | player.sendMessage(main.getMessage("commands.arena.setmax")); 46 | work = true; 47 | break; 48 | } 49 | } 50 | 51 | if (!work) { 52 | player.sendMessage(main.getMessage("commands.arena.not-found")); 53 | } 54 | 55 | 56 | return false; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnSignChange.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import java.util.List; 5 | 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.Location; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.block.SignChangeEvent; 12 | 13 | import com.LagBug.ThePit.Main; 14 | 15 | 16 | public class OnSignChange implements Listener { 17 | 18 | private Main main = Main.getPlugin(Main.class); 19 | 20 | @EventHandler 21 | public void onSignChange(SignChangeEvent e) { 22 | boolean work = false; 23 | Player player = e.getPlayer(); 24 | 25 | if (!player.hasPermission("pit.admin.sign") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 26 | player.sendMessage(main.getMessage("general.no-permission")); 27 | return; 28 | } 29 | 30 | if (e.getLine(0).equalsIgnoreCase("[thepit]") || e.getLine(0).equalsIgnoreCase("[pit]")) { 31 | if (main.getArenaFile().getConfigurationSection("arenas") == null) { 32 | player.sendMessage(main.getMessage("commands.arena.not-found")); 33 | } else { 34 | for (String s : main.getArenaFile().getConfigurationSection("arenas").getKeys(false)){ 35 | if (e.getLine(1).equalsIgnoreCase(main.getArenaFile().getString("arenas." + s + ".name"))){ 36 | List list = main.getConfig().getStringList("arenas." + s + ".signs"); 37 | list.add(loc2str(e.getBlock().getLocation())); 38 | main.getArenaFile().set("arenas." + s + ".signs", list); 39 | main.saveFiles(); 40 | work = true; 41 | break; 42 | } 43 | } 44 | 45 | if (!work) { 46 | e.setLine(0, ChatColor.translateAlternateColorCodes('&', "&8[&6&lThePit&8]")); 47 | e.setLine(1, ChatColor.translateAlternateColorCodes('&', "&8Arena not found")); 48 | } 49 | 50 | } 51 | } 52 | 53 | } 54 | 55 | 56 | public String loc2str(Location loc){ 57 | return loc.getWorld().getName()+":"+loc.getBlockX()+":"+loc.getBlockY()+":"+loc.getBlockZ(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/PlayerManager.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import org.bukkit.GameMode; 4 | import org.bukkit.configuration.file.FileConfiguration; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.LagBug.ThePit.Main; 8 | 9 | public class PlayerManager { 10 | 11 | private Player player; 12 | private Main main = Main.getPlugin(Main.class); 13 | private FileConfiguration dfile = main.getDataFile(); 14 | 15 | public PlayerManager(Player player) { 16 | this.player = player; 17 | } 18 | 19 | public void setGold(int amount) { 20 | dfile.set("pdata." + player.getUniqueId().toString() + ".gold", amount); 21 | main.saveFiles(); 22 | } 23 | 24 | public void addGold(int amount) { 25 | dfile.set("pdata." + player.getUniqueId().toString() + ".gold", dfile.getDouble("pdata." + player.getUniqueId().toString() + ".gold") + amount); 26 | main.saveFiles(); 27 | } 28 | 29 | public void removeGold(int amount) { 30 | dfile.set("pdata." + player.getUniqueId().toString() + ".gold", dfile.getDouble("pdata." + player.getUniqueId().toString() + ".gold") - amount); 31 | main.saveFiles(); 32 | } 33 | 34 | 35 | public void joinArena(String key) { 36 | FileConfiguration afile = main.getArenaFile(); 37 | 38 | if (main.playerArena.get(player) == null || main.playerArena.get(player).equals("")) { 39 | CustomScoreboard sb = new CustomScoreboard(main); 40 | 41 | sb.enableScoreboard(player); 42 | 43 | player.teleport(StringUtils.LocFromString(afile.getString("arenas." + key + ".spawn"))); 44 | player.setGameMode(GameMode.SURVIVAL); 45 | 46 | main.arenaCounter.put(afile.getString("arenas." + key + ".name"), main.arenaCounter.get(afile.getString("arenas." + key + ".name")) + 1); 47 | main.playerArena.put(player, afile.getString("arenas." + key + ".name")); 48 | new GiveItems().setupItems(player); 49 | 50 | player.sendMessage(main.getMessage("commands.arena.join").replace("%arena%", afile.getString("arenas." + key + ".name"))); 51 | 52 | } else { 53 | player.sendMessage(main.getMessage("commands.arena.already-in-arena")); 54 | } 55 | 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommands/GoldLoc.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands.PitCommands; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.entity.Player; 8 | 9 | import com.LagBug.ThePit.Main; 10 | 11 | public class GoldLoc { 12 | 13 | public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args, Main main) { 14 | Player player = (Player) sender; 15 | FileConfiguration dfile = main.getDataFile(); 16 | Location loc = player.getLocation(); 17 | 18 | if (!player.hasPermission("pit.admin.goldloc") || !player.hasPermission("pit.admin.*") || !player.hasPermission("pit.*")) { 19 | player.sendMessage(main.getMessage("general.no-permission")); 20 | return false; 21 | } 22 | 23 | if (args.length <= 1) { 24 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit goldloc ")); 25 | 26 | } else if (args.length >= 1) { 27 | 28 | if (args[1].equalsIgnoreCase("add")) { 29 | int goldLocsCounter = dfile.getInt("counters.goldLocsCounter"); 30 | dfile.set("goldlocs." + (goldLocsCounter + 1) + ".world", loc.getWorld().getName()); 31 | dfile.set("goldlocs." + (goldLocsCounter + 1) + ".x", loc.getX()); 32 | dfile.set("goldlocs." + (goldLocsCounter + 1) + ".y", loc.getY()); 33 | dfile.set("goldlocs." + (goldLocsCounter + 1) + ".z", loc.getZ()); 34 | dfile.set("counters.goldLocsCounter", goldLocsCounter + 1); 35 | main.saveFiles(); 36 | player.sendMessage(main.getMessage("commands.goldloc.add")); 37 | 38 | } else if (args[1].equalsIgnoreCase("rem") || (args[1].equalsIgnoreCase("remove"))) { 39 | int goldLocsCounter = dfile.getInt("counters.goldLocsCounter"); 40 | dfile.set("goldlocs." + goldLocsCounter, null); 41 | dfile.set("counters.goldLocsCounter", goldLocsCounter - 1); 42 | main.saveFiles(); 43 | player.sendMessage(main.getMessage("commands.goldloc.remove")); 44 | 45 | } else { 46 | player.sendMessage(main.getMessage("commands.right-usage").replace("%usage%", "/pit goldloc ")); 47 | } 48 | } 49 | 50 | return false; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIs/ItemsGUI.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.GUIs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.ChatColor; 8 | import org.bukkit.Material; 9 | import org.bukkit.configuration.file.YamlConfiguration; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.Inventory; 12 | import org.bukkit.inventory.ItemFlag; 13 | import org.bukkit.inventory.ItemStack; 14 | import org.bukkit.inventory.meta.ItemMeta; 15 | 16 | import com.LagBug.ThePit.Main; 17 | 18 | public class ItemsGUI { 19 | 20 | private Main main = Main.getPlugin(Main.class); 21 | private YamlConfiguration ifile = main.getItemsFile(); 22 | 23 | public void OpenGUI(Player player) { 24 | double getGold = main.getDataFile().getDouble("pdata." + player.getUniqueId().toString() + ".gold"); 25 | Inventory gui = Bukkit.createInventory(null, ifile.getInt("slots"), ChatColor.translateAlternateColorCodes('&', ifile.getString("title"))); 26 | String[] colors = ifile.getString("availabilityColors").split(":"); 27 | String[] messages = ifile.getString("availabilityMessages").split(":"); 28 | 29 | for (String key : ifile.getConfigurationSection("items").getKeys(false)) { 30 | String[] mats = ifile.getString("items." + key + ".material").split(":"); 31 | List lore = new ArrayList<>(); 32 | 33 | ItemStack item = new ItemStack(Material.valueOf(mats[0].toUpperCase()), Integer.parseInt(mats[1]), (byte) Integer.parseInt(mats[2])); 34 | ItemMeta meta = item.getItemMeta(); 35 | 36 | meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', ifile.getString("items." + key + ".name").replace("%color%", getGold >= ifile.getInt("items." + key + ".price") ? colors[0] : colors[1]).replace("%price%", Integer.toString(ifile.getInt("items." + key + ".price"))).replace("%message%", getGold >= ifile.getInt("items." + key + ".price") ? messages[0] : messages[1]))); 37 | meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); 38 | for (String loreC : ifile.getStringList("items." + key + ".lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', loreC.replace("%color%", getGold >= ifile.getInt("items." + key + ".price") ? colors[0] : colors[1]).replace("%price%", Integer.toString(ifile.getInt("items." + key + ".price"))).replace("%message%", getGold >= ifile.getInt("items." + key + ".price") ? messages[0] : messages[1]))); } 39 | meta.setLore(lore); 40 | item.setItemMeta(meta); 41 | 42 | gui.setItem(ifile.getInt("items." + key + ".slot"), item); 43 | } 44 | player.openInventory(gui); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnJoin.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.Location; 7 | import org.bukkit.World; 8 | import org.bukkit.configuration.file.FileConfiguration; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.player.PlayerJoinEvent; 13 | 14 | import com.LagBug.ThePit.Main; 15 | import com.LagBug.ThePit.Others.TabList; 16 | import com.LagBug.ThePit.Others.UpdateResult; 17 | 18 | import net.md_5.bungee.api.chat.ClickEvent; 19 | import net.md_5.bungee.api.chat.ComponentBuilder; 20 | import net.md_5.bungee.api.chat.HoverEvent; 21 | import net.md_5.bungee.api.chat.TextComponent; 22 | 23 | 24 | public class OnJoin implements Listener { 25 | 26 | private Main main = Main.getPlugin(Main.class); 27 | 28 | @EventHandler 29 | public void onJoin(PlayerJoinEvent e) { 30 | 31 | FileConfiguration dfile = main.getDataFile(); 32 | final Player player = e.getPlayer(); 33 | 34 | if (main.isFighting.contains(player)) main.isFighting.remove(player); 35 | TabList.setTabName(player, main); 36 | 37 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".boughtUpgrades").contains("gatobattler")) main.ElGato.add(player); 38 | 39 | if (dfile.getString("lobby.world") != null) { 40 | World world = Bukkit.getWorld(dfile.getString("lobby.world")); 41 | long pitch = Math.round(dfile.getDouble("lobby.pitch")); 42 | long yaw = Math.round(dfile.getDouble("lobby.yaw")); 43 | long x = Math.round(dfile.getDouble("lobby.x")); 44 | long y = Math.round(dfile.getDouble("lobby.y")); 45 | long z = Math.round(dfile.getDouble("lobby.z")); 46 | 47 | Location loc = new Location(world, x, y, z, yaw, pitch); 48 | player.teleport(loc); 49 | } 50 | 51 | if (player.isOp() && main.updater.getResult().equals(UpdateResult.FOUND)) { 52 | for (String s : main.getMessagesFile().getStringList("general.update-found")) { 53 | TextComponent msg = new TextComponent(ChatColor.translateAlternateColorCodes('&', s.replace("%link%", "https://www.spigotmc.org/resources/61016/"))); 54 | 55 | if (s.contains("%link%") || s.contains("https://www.spigotmc.org/resources/61016/")) { 56 | msg.setHoverEvent( new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&6Click this message to open the url.")).create())); 57 | msg.setClickEvent( new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org/resources/61016/")); 58 | } 59 | player.spigot().sendMessage(msg); 60 | } 61 | } 62 | 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /messages.yml: -------------------------------------------------------------------------------- 1 | general: 2 | no-permission: '&8&l > &6You do not have &epermission &6to do that' 3 | no-console: '&cOnly players can use that command.' 4 | update-found: 5 | - '&8[&eThePit&8] &6An update was found. Stay updated and download it using the' 6 | - '&8[&eThePit&8] &6following link: https://www.spigotmc.org/resources/61016/' 7 | death-by-player: '&c&lDEATH! &7by %killer%! &e&lTRY NEXT TIME' 8 | death-by-unknown: '&c&lDEATH!' 9 | kill-by-player: '&a&lKILL! &7on %killed%! &6+%gold%g &b+%xp%XP' 10 | level-up-message: '&b&lPIT LEVEL UP! &7[&3%oldlevel%&7] &7-> &7[&b%newlevel%&7]' 11 | gold-pickup-message: '&6&lGOLD PICKUP! &7from the ground &6%amount%g' 12 | killstreak-message: '&c&lSTREAK! &7of &c%kills% &7by %player%' 13 | bountied-message: '&6&lBOUNTY! &7bump &6&l%bounty% &7on %player% for high streak' 14 | bounty-claimed: '&6&lBOUNTY CLAIMED! &7%killer% killed %killed% for &6&l%bounty%g' 15 | 16 | guis: 17 | bought: '&a&lPURCHASE! &6%item%' 18 | not-enough-gold: '&cYou do not have enough gold.' 19 | 20 | commands: 21 | right-usage: '&8&l > &6The right usage is &e%usage%' 22 | player-not-found: '&8&l > &e%player% &6could not be found.' 23 | must-be-number: '&8&l > &6The amount &ehas &6to be a number.' 24 | gold: 25 | set: '&8&l > &6Successfully set &e%amount% &6gold to &e%player%&6.' 26 | add: '&8&l > &6Successfully added &e%amount% &6gold to &e%player%&6.' 27 | rem: '&8&l > &6Successfully removed &e%amount% &6gold to &e%player%&6.' 28 | level: 29 | between: '&8&l > &6The level has to be &ebetween &60 and 120.' 30 | set: '&8&l > &6Successfully set &e%amount% &6level to &e%player%&6.' 31 | add: '&8&l > &6Successfully added &e%amount% &6gold to &e%player%&6.' 32 | remove: '&8&l > &6Successfully removed &e%amount% &6gold to &e%player%&6.' 33 | adminmode: 34 | enabled: '&8&l > &6You are now in the &eadmin &6mode.' 35 | disabled: '&8&l > &6You are no longer in the &eadmin &6mode.' 36 | arena: 37 | already-in-arena: '&8&l > &6You are &ealready &6in an arena.' 38 | not-in-arena: '&8&l > &6You are &enot &6in any arena right now.' 39 | no-spawn-loc: '&8&l > &6The spawn &elocation &6has not been set.' 40 | no-lobby-loc: '&8&l > &6The lobby &elocation &6has not been set.' 41 | not-found: '&8&l > &6An arena with that &ename &6could not be found.' 42 | create: '&8&l > &6Successfully created a &enew &6arena named &e%arena%&6.' 43 | delete: '&8&l > &6Successfully deleted an arena named &e%arena%&6.' 44 | join: '&8&l > &6Successfully joined &e%arena% &6arena. Have fun :)' 45 | leave: '&8&l > &6Successfully left &e%arena% &6arena. Rip :(' 46 | list: '&8&l > &6The current arenas are: &e' 47 | setspawn: '&8&l > &6Successfully set the &espawn &6location.' 48 | setmax: '&8&l > &6Successfully set max players &e%max% &6for arena &e%arena%&6.' 49 | goldloc: 50 | add: '&8&l > &6Successfully added a new &egold &6generator.' 51 | remove: '&8&l > &6Successfully removed the latest &egold &6generator.' 52 | lauchpad: 53 | add: '&8&l > &6Successfully &eadded &6a new launchpad.' 54 | setlobby: 55 | set: '&8&l > &6Successfully set the &elobby &6location.' 56 | reload: 57 | success: '&8&l > &6Successfully &ereloaded &6the configuration files.' -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.bukkit.configuration.file.YamlConfiguration; 7 | 8 | import com.LagBug.ThePit.Main; 9 | 10 | public class FileUtils { 11 | private Main main = Main.getPlugin(Main.class); 12 | private File dataFile, arenaFile, messagesFile, itemsFile, upgradesFile; 13 | private YamlConfiguration modifyData, modifyArena, modifyMessages, modifyItems, modifyUpgrades; 14 | 15 | public FileUtils() { 16 | initializeConfig(); 17 | initializeFiles(); 18 | } 19 | 20 | private void initializeFiles() { 21 | dataFile = new File(main.getDataFolder(), "data.yml"); 22 | if (!dataFile.exists()) { 23 | File directory = new File(dataFile.getParentFile().getAbsolutePath()); 24 | directory.mkdirs(); 25 | try { 26 | dataFile.createNewFile(); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | modifyData = YamlConfiguration.loadConfiguration(dataFile); 32 | 33 | 34 | arenaFile = new File(main.getDataFolder(), "arenas.yml"); 35 | if (!arenaFile.exists()) { 36 | File directory = new File(arenaFile.getParentFile().getAbsolutePath()); 37 | directory.mkdirs(); 38 | try { 39 | arenaFile.createNewFile(); 40 | } catch (IOException e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | modifyArena = YamlConfiguration.loadConfiguration(arenaFile); 45 | 46 | 47 | messagesFile = new File(main.getDataFolder(), "messages.yml"); 48 | if (!messagesFile.exists()) { 49 | main.saveResource("messages.yml", false); 50 | } 51 | modifyMessages = YamlConfiguration.loadConfiguration(messagesFile); 52 | 53 | 54 | itemsFile = new File(main.getDataFolder(), "guis" + File.separator + "items.yml"); 55 | if (!itemsFile.exists()) { 56 | main.saveResource("guis" + File.separator + "items.yml", false); 57 | } 58 | modifyItems = YamlConfiguration.loadConfiguration(itemsFile); 59 | 60 | upgradesFile = new File(main.getDataFolder(), "guis" + File.separator + "upgrades.yml"); 61 | if (!upgradesFile.exists()) { 62 | main.saveResource("guis" + File.separator + "upgrades.yml", false); 63 | } 64 | modifyUpgrades = YamlConfiguration.loadConfiguration(upgradesFile); 65 | 66 | } 67 | 68 | private void initializeConfig() { 69 | main.getConfig().options().copyDefaults(true); 70 | main.getConfig().options().copyHeader(true); 71 | main.saveDefaultConfig(); 72 | main.reloadConfig(); 73 | 74 | File guisFolder = new File(main.getDataFolder(), "guis"); 75 | if (!guisFolder.exists()) { guisFolder.mkdirs(); } 76 | } 77 | 78 | 79 | public YamlConfiguration getDataFile() { return modifyData; } 80 | public File getDataData() { return dataFile; } 81 | 82 | public YamlConfiguration getArenaFile() { return modifyArena; } 83 | public File getArenaData() { return arenaFile; } 84 | 85 | public YamlConfiguration getMessagesFile() { return modifyMessages; } 86 | public File getMessagesData() { return messagesFile; } 87 | 88 | public YamlConfiguration getItemsFile() { return modifyItems; } 89 | public File getItemsData() { return itemsFile; } 90 | 91 | public YamlConfiguration getUpgradesFile() { return modifyUpgrades; } 92 | public File getUpgradesData() { return upgradesFile; } 93 | } 94 | -------------------------------------------------------------------------------- /guis/upgrades.yml: -------------------------------------------------------------------------------- 1 | title: 'Permanent upgrades' 2 | availabilityColors: '&e:&c:&c' 3 | availabilityMessages: 'Click to purchase:Not enough gold:Already owned' 4 | slots: 45 5 | items: 6 | '0': 7 | name: '&aPerk Slot #1' 8 | material: 'DIAMOND_BLOCK:1:0' 9 | reqlevel: 0 10 | slot: 12 11 | lore: 12 | - '&7Select a perk to fill this' 13 | - '&7slot' 14 | - '' 15 | - '&eClick to choose a perk.' 16 | '1': 17 | name: '&aPerk Slot #2' 18 | material: 'DIAMOND_BLOCK:2:0' 19 | reqlevel: 35 20 | slot: 13 21 | lore: 22 | - '&7Select a perk to fill this' 23 | - '&7slot' 24 | - '' 25 | - '&eClick to choose a perk.' 26 | '2': 27 | name: '&aPerk Slot #3' 28 | material: 'DIAMOND_BLOCK:3:0' 29 | reqlevel: 70 30 | slot: 14 31 | lore: 32 | - '&7Select a perk to fill this' 33 | - '&7slot' 34 | - '' 35 | - '&eClick to choose a perk.' 36 | '3': 37 | name: '%color%XP Boost' 38 | material: 'INK_SACK:1:12' 39 | slot: 28 40 | price: 500 41 | lore: 42 | - '&7Each tier:' 43 | - '&7Earn &b+10XP &7from all' 44 | - '&7sources' 45 | - '' 46 | - '&7Cost: &6%price%g' 47 | - '%color%%message%' 48 | '4': 49 | name: '%color%Gold Boost' 50 | material: 'INK_SACK:1:14' 51 | slot: 29 52 | price: 1000 53 | lore: 54 | - '&7Each tier:' 55 | - '&7Earn &6+10XP &7from all' 56 | - '&7sources' 57 | - '' 58 | - '&7Cost: &6%price%g' 59 | - '%color%%message%' 60 | '5': 61 | name: '%color%Melee Damage' 62 | material: 'INK_SACK:1:1' 63 | slot: 30 64 | price: 450 65 | lore: 66 | - '&7Each tier:' 67 | - '&7Deal &c+1 &7melee damage.' 68 | - '' 69 | - '&7Cost: &6%price%g' 70 | - '%color%%message%' 71 | '6': 72 | name: '%color%Bow Damage' 73 | material: 'INK_SACK:1:11' 74 | slot: 31 75 | price: 450 76 | lore: 77 | - '&7Each tier:' 78 | - '&7Deal &c+3 &7bow damage.' 79 | - '' 80 | - '&7Cost: &6%price%g' 81 | - '%color%%message%' 82 | '7': 83 | name: '%color%Damage Reduction' 84 | material: 'INK_SACK:1:6' 85 | slot: 32 86 | price: 450 87 | lore: 88 | - '&7Each tier:' 89 | - '&7Recieve &9-1 &7damage.' 90 | - '' 91 | - '&7Cost: &6%price%g' 92 | - '%color%%message%' 93 | '8': 94 | name: '%color%Build Battler' 95 | material: 'INK_SACK:1:7' 96 | slot: 33 97 | price: 750 98 | lore: 99 | - '&7Each tier:' 100 | - '&7Your blocks stay &e+60' 101 | - '&7seconds.' 102 | - '' 103 | - '&7Cost: &6%price%g' 104 | - '%color%%message%' 105 | '9': 106 | name: '%color%Gato Battler' 107 | material: 'CAKE:1:0' 108 | slot: 34 109 | price: 1000 110 | lore: 111 | - '&7Each tier:' 112 | - '&dFirst kill &7each life' 113 | - '&7rewards &6+5g &b+6XP&7.' 114 | - '' 115 | - '&7Cost: &6%price%g' 116 | - '%color%%message%' 117 | 118 | 119 | not-available: 120 | perks: 121 | name: &cPerk slot not available.' 122 | material: 'BEDROCK:1:0' 123 | lore: 124 | - 'Required level: &7[&c&l%level%&7]' 125 | upgrades: 126 | name: &cUnknown Upgrade' 127 | material: 'BEDROCK:1:0' 128 | lore: 129 | - 'Required level: &7[&c&l%level%&7]' -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIs/UpgradesGUI.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.GUIs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.ChatColor; 8 | import org.bukkit.Material; 9 | import org.bukkit.configuration.file.YamlConfiguration; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.Inventory; 12 | import org.bukkit.inventory.ItemFlag; 13 | import org.bukkit.inventory.ItemStack; 14 | import org.bukkit.inventory.meta.ItemMeta; 15 | 16 | import com.LagBug.ThePit.Main; 17 | import com.LagBug.ThePit.Others.ItemBuilder; 18 | 19 | public class UpgradesGUI { 20 | 21 | private Main main = Main.getPlugin(Main.class); 22 | private YamlConfiguration ufile = main.getUpgradesFile(); 23 | 24 | public void OpenGUI(Player player) { 25 | Inventory gui = Bukkit.createInventory(null, ufile.getInt("slots"), ChatColor.translateAlternateColorCodes('&', ufile.getString("title"))); 26 | 27 | 28 | for (String key : ufile.getConfigurationSection("items").getKeys(false)) { 29 | String[] mats = ufile.getString("items." + key + ".material").split(":"); 30 | List lore = new ArrayList<>(); 31 | 32 | ItemStack item = new ItemStack(Material.valueOf(mats[0].toUpperCase()), Integer.parseInt(mats[1]), (byte) Integer.parseInt(mats[2])); 33 | ItemMeta meta = item.getItemMeta(); 34 | meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', replace(ufile.getString("items." + key + ".name"), key, player))); 35 | meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); 36 | for (String loreC : ufile.getStringList("items." + key + ".lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', replace(loreC, key, player))); } 37 | meta.setLore(lore); 38 | item.setItemMeta(meta); 39 | 40 | String[] perkMats = ufile.getString("not-available.perk.material").split(":"); 41 | @SuppressWarnings("unused") 42 | ItemStack reqLevelPerk = new ItemBuilder(Material.valueOf(perkMats[0]), Integer.parseInt(perkMats[1]), Integer.parseInt(perkMats[2])) 43 | .setDisplayName(ufile.getString("not-available.perks.name")) 44 | .setLore(ufile.getStringList("not-available.perks.lore")).build(); 45 | 46 | 47 | gui.setItem(ufile.getInt("items." + key + ".slot"), item); 48 | } 49 | player.openInventory(gui); 50 | } 51 | 52 | 53 | private String replace(String text, String key, Player player) { 54 | String nameid = ChatColor.stripColor(ufile.getString("items." + key + ".name").replace("%color%", "").replace("%price%", "").replace(" ", "").toLowerCase()); 55 | double getGold = main.getDataFile().getDouble("pdata." + player.getUniqueId().toString() + ".gold"); 56 | List boughtUpg = main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".boughtUpgrades"); 57 | String[] colors = ufile.getString("availabilityColors").split(":"); 58 | String[] messages = ufile.getString("availabilityMessages").split(":"); 59 | 60 | if (!boughtUpg.contains(nameid)) { 61 | if (getGold >= ufile.getInt("items." + key + ".price")) { 62 | text = text.replace("%message%",messages[0]).replace("%color%", colors[0]); 63 | } else { 64 | text = text.replace("%message%",messages[1]).replace("%color%", colors[1]); 65 | } 66 | } else { 67 | text = text.replace("%message%", messages[2]).replace("%color%", colors[2]); 68 | } 69 | 70 | return text.replace("%price%", Integer.toString(ufile.getInt("items." + key + ".price"))); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Others/CustomScoreboard.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Others; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | import java.util.List; 6 | 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.scoreboard.DisplaySlot; 11 | import org.bukkit.scoreboard.Objective; 12 | import org.bukkit.scoreboard.Scoreboard; 13 | import org.bukkit.scoreboard.Team; 14 | 15 | import com.LagBug.ThePit.Main; 16 | 17 | public class CustomScoreboard { 18 | private Main main; 19 | 20 | public CustomScoreboard(Main main) { 21 | this.main = main; 22 | 23 | } 24 | 25 | public void enableScoreboard(Player player) { 26 | Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); 27 | Objective obj = board.registerNewObjective("Scoreboard", "Dummy"); 28 | 29 | obj.setDisplaySlot(DisplaySlot.SIDEBAR); 30 | obj.setDisplayName(replace(main.getConfig().getString("scoreboard.title"), player)); 31 | 32 | int count = main.getConfig().getStringList("scoreboard.rows").size(); 33 | 34 | for (String text : main.getConfig().getStringList("scoreboard.rows")) { 35 | String result = getResult(text, player); 36 | 37 | Team team = board.registerNewTeam(result.substring(0, result.length()/2)); 38 | 39 | team.addEntry(Integer.toString(count)); 40 | 41 | 42 | String prefix = result.substring(0, result.length() / 2); 43 | String suffix = result.substring(result.length() / 2); 44 | 45 | team.setPrefix(prefix); 46 | team.setSuffix(suffix); 47 | obj.getScore(result).setScore(count); 48 | count--; 49 | 50 | } 51 | 52 | player.setScoreboard(board); 53 | 54 | } 55 | 56 | public void updateScoreboard(Player player) { 57 | Scoreboard board = player.getScoreboard(); 58 | int current = 0; 59 | List lines = main.getConfig().getStringList("scoreboard.rows"); 60 | for (Team team : board.getTeams()) { 61 | String text = lines.get(current); 62 | String result = getResult(text, player); 63 | 64 | String prefix = result.substring(0, result.length() / 2); 65 | String suffix = result.substring(result.length() / 2); 66 | 67 | team.setPrefix(prefix); 68 | team.setSuffix(suffix); 69 | 70 | current++; 71 | } 72 | 73 | } 74 | 75 | public void disableScoreboard(Player p) { 76 | Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); 77 | board.clearSlot(DisplaySlot.SIDEBAR); 78 | p.setScoreboard(board); 79 | } 80 | 81 | public String status(Player p) { 82 | if (main.isFighting.contains(p)) { 83 | return ChatColor.translateAlternateColorCodes('&', "&cFighting"); 84 | } 85 | return ChatColor.translateAlternateColorCodes('&', "&aIdling"); 86 | } 87 | 88 | public String getResult(String text, Player p) { 89 | return replace(replace(text.substring(0, text.length() / 2), p) + replace(text.substring(text.length() / 2), p), p); 90 | } 91 | 92 | public String replace(String s, Player p) { 93 | 94 | double gold = main.getDataFile().getDouble("pdata." + p.getUniqueId().toString() + ".gold"); 95 | 96 | return ChatColor.translateAlternateColorCodes('&', 97 | s.replace("%lvl%", Integer.toString(p.getLevel())).replace("%date%", getDate()) 98 | .replace("%xp%", Integer.toString(p.getExpToLevel())).replace("%gold%", Double.toString(gold)) 99 | .replace("%status%", (status(p)))); 100 | } 101 | 102 | public String getDate() { 103 | Calendar cal = Calendar.getInstance(); 104 | SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy"); 105 | return sdf.format(cal.getTime()); 106 | } 107 | 108 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIListners/ItemsGUIListener.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.GUIListners; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.configuration.file.YamlConfiguration; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.inventory.InventoryClickEvent; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import com.LagBug.ThePit.Main; 12 | import com.LagBug.ThePit.GUIs.ItemsGUI; 13 | import com.LagBug.ThePit.Others.PlayerManager; 14 | 15 | import net.md_5.bungee.api.ChatColor; 16 | 17 | public class ItemsGUIListener implements Listener { 18 | 19 | private Main main = Main.getPlugin(Main.class); 20 | private YamlConfiguration ifile = main.getItemsFile(); 21 | 22 | @EventHandler 23 | public void onClick(InventoryClickEvent e) { 24 | Player player = (Player) e.getWhoClicked(); 25 | 26 | if (e.getCurrentItem() == null || e.getClickedInventory() == null || e.getInventory() == null || e.getCurrentItem().getType().equals(Material.AIR)) return; 27 | if (e.getClickedInventory().getTitle().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', ifile.getString("title")))) { 28 | double getGold = main.getDataFile().getDouble("pdata." + player.getUniqueId().toString() + ".gold"); 29 | e.setCancelled(true); 30 | int price = 0; 31 | 32 | String[] colors = ifile.getString("availabilityColors").split(":"); 33 | String[] messages = ifile.getString("availabilityMessages").split(":"); 34 | 35 | for (String key : ifile.getConfigurationSection("items").getKeys(false)) { 36 | if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', ifile.getString("items." + key + ".name").replace("%color%", getGold >= ifile.getInt("items." + key + ".price") ? colors[0] : colors[1]).replace("%price%", Integer.toString(ifile.getInt("items." + key + ".price"))).replace("%message%", getGold >= ifile.getInt("items." + key + ".price") ? messages[0] : messages[1])))) { 37 | price = ifile.getInt("items." + key + ".price"); 38 | } 39 | } 40 | 41 | ItemStack newItem = new ItemStack(e.getCurrentItem().getType(), e.getCurrentItem().getAmount(), e.getCurrentItem().getDurability()); 42 | 43 | if (getGold >= price) { 44 | 45 | switch (getArmorType(e.getCurrentItem())) { 46 | case "helmet": 47 | player.getInventory().addItem(player.getInventory().getHelmet()); 48 | player.getInventory().setHelmet(newItem); 49 | break; 50 | case "chestplate": 51 | player.getInventory().addItem(player.getInventory().getChestplate()); 52 | player.getInventory().setChestplate(newItem); 53 | break; 54 | case "leggings": 55 | player.getInventory().addItem(player.getInventory().getLeggings()); 56 | player.getInventory().setLeggings(newItem); 57 | break; 58 | case "boots": 59 | player.getInventory().addItem(player.getInventory().getBoots()); 60 | player.getInventory().setBoots(newItem); 61 | break; 62 | default: 63 | player.getInventory().addItem(newItem); 64 | break; 65 | } 66 | 67 | new PlayerManager(player).removeGold(price); 68 | player.sendMessage(main.getMessage("guis.bought").replace("%item%", ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()))); 69 | } else { 70 | player.sendMessage(main.getMessage("guis.not-enough-gold")); 71 | } 72 | 73 | player.closeInventory(); 74 | new ItemsGUI().OpenGUI(player); 75 | } 76 | } 77 | 78 | private String getArmorType(ItemStack item) { 79 | String type = item.getType().toString().toLowerCase(); 80 | 81 | if (type.contains("helmet")) { 82 | return "helmet"; 83 | } else if (type.contains("chestplate")) { 84 | return "chestplate"; 85 | } else if (type.contains("leggings")) { 86 | return "leggings"; 87 | } else if (type.contains("boots")) { 88 | return "boots"; 89 | } 90 | return ""; 91 | } 92 | } -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Actiobar/Actionbar.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Actiobar; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.Method; 5 | 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.entity.Player; 8 | 9 | 10 | public class Actionbar { 11 | 12 | private static String nmsver; 13 | private static boolean useOldMethods = false; 14 | 15 | public static void sendActionBar(Player player, String message) { 16 | 17 | nmsver = Bukkit.getServer().getClass().getPackage().getName(); 18 | nmsver = nmsver.substring(nmsver.lastIndexOf(".") + 1); 19 | if ((nmsver.equalsIgnoreCase("v1_8_R1")) || (nmsver.startsWith("v1_7_"))) { 20 | useOldMethods = true; 21 | } 22 | 23 | if (player == null || !player.isOnline()) { 24 | return; 25 | } 26 | 27 | try { 28 | Class craftPlayerClass = Class.forName("org.bukkit.craftbukkit." + nmsver + ".entity.CraftPlayer"); 29 | Object craftPlayer = craftPlayerClass.cast(player); 30 | 31 | Class packetPlayOutChatClass = Class.forName("net.minecraft.server." + nmsver + ".PacketPlayOutChat"); 32 | Class packetClass = Class.forName("net.minecraft.server." + nmsver + ".Packet"); 33 | Object packet; 34 | if (useOldMethods) { 35 | Class chatSerializerClass = Class.forName("net.minecraft.server." + nmsver + ".ChatSerializer"); 36 | Class iChatBaseComponentClass = Class 37 | .forName("net.minecraft.server." + nmsver + ".IChatBaseComponent"); 38 | Method m3 = chatSerializerClass.getDeclaredMethod("a", new Class[] { String.class }); 39 | Object cbc = iChatBaseComponentClass 40 | .cast(m3.invoke(chatSerializerClass, new Object[] { "{\"text\": \"" + message + "\"}" })); 41 | packet = packetPlayOutChatClass.getConstructor(new Class[] { iChatBaseComponentClass, Byte.TYPE }) 42 | .newInstance(new Object[] { cbc, Byte.valueOf((byte) 2) }); 43 | } else { 44 | Class chatComponentTextClass = Class 45 | .forName("net.minecraft.server." + nmsver + ".ChatComponentText"); 46 | Class iChatBaseComponentClass = Class 47 | .forName("net.minecraft.server." + nmsver + ".IChatBaseComponent"); 48 | try { 49 | Class chatMessageTypeClass = Class 50 | .forName("net.minecraft.server." + nmsver + ".ChatMessageType"); 51 | Object[] chatMessageTypes = chatMessageTypeClass.getEnumConstants(); 52 | Object chatMessageType = null; 53 | for (Object obj : chatMessageTypes) { 54 | if (obj.toString().equals("GAME_INFO")) { 55 | chatMessageType = obj; 56 | } 57 | } 58 | Object chatCompontentText = chatComponentTextClass.getConstructor(new Class[] { String.class }) 59 | .newInstance(new Object[] { message }); 60 | packet = packetPlayOutChatClass 61 | .getConstructor(new Class[] { iChatBaseComponentClass, chatMessageTypeClass }) 62 | .newInstance(new Object[] { chatCompontentText, chatMessageType }); 63 | } catch (ClassNotFoundException cnfex) { 64 | Object chatCompontentText = chatComponentTextClass.getConstructor(new Class[] { String.class }) 65 | .newInstance(new Object[] { message }); 66 | packet = packetPlayOutChatClass.getConstructor(new Class[] { iChatBaseComponentClass, Byte.TYPE }) 67 | .newInstance(new Object[] { chatCompontentText, Byte.valueOf((byte) 2) }); 68 | } 69 | } 70 | Method craftPlayerHandleMethod = craftPlayerClass.getDeclaredMethod("getHandle", new Class[0]); 71 | Object craftPlayerHandle = craftPlayerHandleMethod.invoke(craftPlayer, new Object[0]); 72 | Field playerConnectionField = craftPlayerHandle.getClass().getDeclaredField("playerConnection"); 73 | Object playerConnection = playerConnectionField.get(craftPlayerHandle); 74 | Method sendPacketMethod = playerConnection.getClass().getDeclaredMethod("sendPacket", 75 | new Class[] { packetClass }); 76 | sendPacketMethod.invoke(playerConnection, new Object[] { packet }); 77 | } catch (Exception ex) { 78 | ex.printStackTrace(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Events/OnFight.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Events; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Arrow; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.entity.EntityDamageByEntityEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import com.LagBug.ThePit.Main; 13 | import com.LagBug.ThePit.Actiobar.Actionbar; 14 | 15 | import net.md_5.bungee.api.ChatColor; 16 | 17 | public class OnFight implements Listener { 18 | 19 | 20 | private Main main = Main.getPlugin(Main.class); 21 | private Player damager; 22 | 23 | @EventHandler 24 | public void onFight(EntityDamageByEntityEvent e) { 25 | final Player player = (Player) e.getEntity(); 26 | 27 | if (e.getEntity() instanceof Player && e.getDamager() instanceof Player) { 28 | this.damager = (Player) e.getDamager(); 29 | } else if (e.getDamager() instanceof Arrow) { 30 | Arrow oldShooter = (Arrow) e.getDamager(); 31 | this.damager = (Player) oldShooter.getShooter(); 32 | } 33 | 34 | Actionbar.sendActionBar(damager, 35 | ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("actionbar.hearts.format") 36 | .replace("%player%", player.getName()).replace("%hearts%", getHeartLevel(player)))); 37 | 38 | if (!main.isFighting.contains(player)) { 39 | main.isFighting.add(player); 40 | } 41 | if (!main.isFighting.contains(damager)) { 42 | main.isFighting.add(damager); 43 | } 44 | 45 | Bukkit.getScheduler().runTaskLater(main, new Runnable() { 46 | public void run() { 47 | main.isFighting.remove(player); 48 | main.isFighting.remove(damager); 49 | } 50 | }, main.getConfig().getInt("general.fighting-time") * 20); 51 | 52 | } 53 | 54 | private String getHeartLevel(Player player) { 55 | 56 | int currentHealth = (int) player.getHealth() / 2; 57 | int maxHealth = (int) player.getMaxHealth() / 2; 58 | String rHeartColor = ChatColor.translateAlternateColorCodes('&', 59 | main.getConfig().getString("actionbar.hearts.remain-hearts-color")); 60 | String lHeartColor = ChatColor.translateAlternateColorCodes('&', 61 | main.getConfig().getString("actionbar.hearts.lose-hearts-color")); 62 | int lostHealth = maxHealth - currentHealth; 63 | 64 | String rHeart = ""; 65 | String lHeart = ""; 66 | 67 | for (int i = 0; i < currentHealth; i++) { 68 | rHeart = rHeart + rHeartColor + "❤"; 69 | } 70 | for (int i = 0; i < lostHealth; i++) { 71 | lHeart = lHeart + lHeartColor + "❤"; 72 | } 73 | 74 | String heartResult = rHeart + lHeart; 75 | return heartResult; 76 | } 77 | 78 | public void givePerksUpgrds(Player player, Player damager, EntityDamageByEntityEvent e) { 79 | if (main.getDataFile().getStringList("pdata." + damager.getUniqueId().toString() + ".boughtUpgrades") 80 | .contains("damagereduction")) { 81 | e.setDamage(e.getDamage() - 1.0); 82 | } 83 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks") 84 | .contains("gladiator")) { 85 | e.setDamage(e.getDamage() - 3.0); 86 | } 87 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks") 88 | .contains("vampire")) { 89 | if (player.getHealth() <= 18.5) { 90 | player.setHealth(player.getHealth() + 1.5); 91 | } 92 | } 93 | 94 | if (e.getDamager() instanceof Arrow) { 95 | if (main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks") 96 | .contains("endlessquiver")) { 97 | player.getInventory().addItem(new ItemStack(Material.ARROW, 3)); 98 | } 99 | if (main.getDataFile().getStringList("pdata." + damager.getUniqueId().toString() + ".boughtUpgrades") 100 | .contains("bowdamage")) { 101 | e.setDamage(e.getDamage() + 3.0); 102 | } 103 | 104 | } else { 105 | if (main.getDataFile().getStringList("pdata." + damager.getUniqueId().toString() + ".boughtUpgrades") 106 | .contains("meleedamage")) { 107 | e.setDamage(e.getDamage() + 1.0); 108 | } 109 | } 110 | 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Commands/PitCommand.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.Commands; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandExecutor; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | 9 | import com.LagBug.ThePit.Main; 10 | import com.LagBug.ThePit.Commands.PitCommands.AddGold; 11 | import com.LagBug.ThePit.Commands.PitCommands.AddLevel; 12 | import com.LagBug.ThePit.Commands.PitCommands.Adminmode; 13 | import com.LagBug.ThePit.Commands.PitCommands.Create; 14 | import com.LagBug.ThePit.Commands.PitCommands.Delete; 15 | import com.LagBug.ThePit.Commands.PitCommands.Discord; 16 | import com.LagBug.ThePit.Commands.PitCommands.GoldLoc; 17 | import com.LagBug.ThePit.Commands.PitCommands.Join; 18 | import com.LagBug.ThePit.Commands.PitCommands.Launchpad; 19 | import com.LagBug.ThePit.Commands.PitCommands.Leave; 20 | import com.LagBug.ThePit.Commands.PitCommands.List; 21 | import com.LagBug.ThePit.Commands.PitCommands.Reload; 22 | import com.LagBug.ThePit.Commands.PitCommands.RemGold; 23 | import com.LagBug.ThePit.Commands.PitCommands.RemLevel; 24 | import com.LagBug.ThePit.Commands.PitCommands.SetGold; 25 | import com.LagBug.ThePit.Commands.PitCommands.SetLevel; 26 | import com.LagBug.ThePit.Commands.PitCommands.SetLobby; 27 | import com.LagBug.ThePit.Commands.PitCommands.SetMax; 28 | import com.LagBug.ThePit.Commands.PitCommands.SetSpawn; 29 | import com.LagBug.ThePit.GUIs.HelpGUI; 30 | 31 | public class PitCommand implements CommandExecutor { 32 | 33 | private Main main = Main.getPlugin(Main.class); 34 | private HelpGUI helpgui; 35 | 36 | public PitCommand() { 37 | this.helpgui = new HelpGUI(main); 38 | } 39 | 40 | @Override 41 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 42 | 43 | if (!(sender instanceof Player)) { 44 | if (cmd.getName().equalsIgnoreCase("pit")) { 45 | Bukkit.getConsoleSender().sendMessage(main.getMessage("general.no-console")); 46 | } 47 | } else { 48 | 49 | final Player player = (Player) sender; 50 | 51 | if (args.length == 0) { 52 | helpgui.OpenGUI(player); 53 | } else if (args.length >= 1) { 54 | 55 | switch (args[0].toLowerCase()) { 56 | 57 | case "launchpad": 58 | Launchpad.onCommand(sender, cmd, label, args, main); 59 | break; 60 | 61 | case "reload": 62 | Reload.onCommand(sender, cmd, label, args, main); 63 | break; 64 | 65 | case "goldloc": 66 | GoldLoc.onCommand(sender, cmd, label, args, main); 67 | break; 68 | 69 | case "setlobby": 70 | SetLobby.onCommand(sender, cmd, label, args, main); 71 | break; 72 | 73 | case "create": 74 | Create.onCommand(sender, cmd, label, args, main); 75 | break; 76 | 77 | case "delete": 78 | Delete.onCommand(sender, cmd, label, args, main); 79 | break; 80 | 81 | case "list": 82 | List.onCommand(sender, cmd, label, args, main); 83 | break; 84 | 85 | case "join": 86 | Join.onCommand(sender, cmd, label, args, main); 87 | break; 88 | 89 | case "leave": 90 | Leave.onCommand(sender, cmd, label, args, main); 91 | break; 92 | 93 | case "setmax": 94 | SetMax.onCommand(sender, cmd, label, args, main); 95 | break; 96 | 97 | case "setspawn": 98 | SetSpawn.onCommand(sender, cmd, label, args, main); 99 | break; 100 | 101 | case "discord": 102 | Discord.onCommand(sender, cmd, label, args, main); 103 | break; 104 | 105 | case "adminmode": 106 | Adminmode.onCommand(sender, cmd, label, args, main); 107 | break; 108 | 109 | case "addlevel": 110 | AddLevel.onCommand(sender, cmd, label, args, main); 111 | break; 112 | 113 | case "remlevel": 114 | RemLevel.onCommand(sender, cmd, label, args, main); 115 | break; 116 | 117 | case "setlevel": 118 | SetLevel.onCommand(sender, cmd, label, args, main); 119 | break; 120 | 121 | case "addgold": 122 | AddGold.onCommand(sender, cmd, label, args, main); 123 | break; 124 | 125 | case "remgold": 126 | RemGold.onCommand(sender, cmd, label, args, main); 127 | break; 128 | 129 | case "setgold": 130 | SetGold.onCommand(sender, cmd, label, args, main); 131 | break; 132 | 133 | default: 134 | helpgui.OpenGUI(player); 135 | break; 136 | } 137 | } 138 | 139 | } 140 | 141 | return false; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/GUIs/PerksGUI.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit.GUIs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.Material; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.Inventory; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.inventory.meta.ItemMeta; 14 | import org.bukkit.inventory.meta.SkullMeta; 15 | 16 | import com.LagBug.ThePit.Main; 17 | 18 | public class PerksGUI { 19 | private Main main; 20 | 21 | public PerksGUI(Main main) { 22 | this.main = main; 23 | } 24 | 25 | 26 | public ItemStack setItem(String name, Material material, List oldLore, Player player) { 27 | String nameid = name.toLowerCase().replace(" ", "").replace("-", ""); 28 | double getGold = main.getDataFile().getDouble("pdata." + player.getUniqueId().toString() + ".gold"); 29 | List boughtPrk = main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".boughtPerks"); 30 | List activePrk = main.getDataFile().getStringList("pdata." + player.getUniqueId().toString() + ".activePerks"); 31 | ItemStack item = null; 32 | ItemMeta itemMeta; 33 | List lore = new ArrayList<>(); 34 | for (String s : oldLore) { lore.add(s); } 35 | 36 | if (material.equals(Material.SKULL_ITEM)) { 37 | item = new ItemStack(material, 1, (short) 3); 38 | SkullMeta t = (SkullMeta) item.getItemMeta(); 39 | itemMeta = t; 40 | ((SkullMeta) itemMeta).setOwner(main.getConfig().getString("general.goldenheads-head")); 41 | } else { 42 | item = new ItemStack(material); 43 | itemMeta = item.getItemMeta(); 44 | } 45 | 46 | lore.add(""); 47 | if (!activePrk.contains(nameid)) { 48 | if (!boughtPrk.contains(nameid)) { 49 | lore.add("§7Cost: §6" + main.getConfig().getInt("prices.perks." +nameid) + "g"); 50 | if (getGold >= main.getConfig().getInt("prices.perks." + nameid)) { 51 | itemMeta.setDisplayName("§e" +name); 52 | lore.add("§eClick to purchase!"); 53 | } else { 54 | itemMeta.setDisplayName("§c" +name); 55 | lore.add("§cNot enough gold!"); 56 | } 57 | } else { 58 | itemMeta.setDisplayName("§a" +name); 59 | lore.add("§eClick to select!"); 60 | } 61 | } else { 62 | itemMeta.setDisplayName("§a" +name); 63 | lore.add("§aAlready selected!"); 64 | } 65 | 66 | 67 | itemMeta.setLore(lore); 68 | item.setItemMeta(itemMeta); 69 | 70 | return item; 71 | } 72 | 73 | public void OpenGUI(Player player) { 74 | int level = player.getLevel(); 75 | Inventory gui = Bukkit.createInventory(null, 36, "Choose a perk"); 76 | 77 | List backLore = new ArrayList<>(); 78 | ItemStack back = new ItemStack(Material.ARROW); 79 | ItemMeta backMeta = back.getItemMeta(); 80 | backMeta.setDisplayName("§aGo Back"); 81 | backLore.add("§7To permanent upgrades"); 82 | backMeta.setLore(backLore); 83 | back.setItemMeta(backMeta); 84 | 85 | 86 | gui.setItem(31, back); 87 | gui.setItem(10, setItem("Golden Heads", Material.SKULL_ITEM, lores().get("goldenheads"), player)); 88 | gui.setItem(11, setItem("Fishing Rod", Material.FISHING_ROD, lores().get("fishingrod"), player)); 89 | gui.setItem(12, setItem("Lava Bucket", Material.LAVA_BUCKET, lores().get("lavabucket"), player)); 90 | 91 | gui.setItem(13, level >= 20 ? setItem("Strength-Chaining", Material.REDSTONE, lores().get("strength"), player) : reqLevel("§320")); 92 | gui.setItem(14, level >= 20 ? setItem("Endless Quiver", Material.BOW, lores().get("endless"), player) : reqLevel("§320")); 93 | 94 | gui.setItem(15, level >= 20 ? setItem("Mineman", Material.COBBLESTONE, lores().get("mineman"), player) : reqLevel("§230")); 95 | gui.setItem(16, level >= 20 ? setItem("Safety First", Material.CHAINMAIL_HELMET, lores().get("safety"), player) : reqLevel("§230")); 96 | 97 | gui.setItem(19, level >= 40 ? setItem("Trickle-down", Material.GOLD_INGOT, lores().get("trickle"), player) : reqLevel("§a40")); 98 | gui.setItem(20, level >= 40 ? setItem("Lucky Diamond", Material.DIAMOND, lores().get("lucky"), player) : reqLevel("§a40")); 99 | gui.setItem(21, level >= 40 ? setItem("Spammer", Material.STRING, lores().get("spammer"), player) : reqLevel("§a40")); 100 | 101 | gui.setItem(22, level >= 50 ? setItem("Bounty Hunter", Material.GOLD_LEGGINGS, lores().get("bounty"), player) : reqLevel("§e50")); 102 | gui.setItem(23, level >= 50 ? setItem("Streaker", Material.HAY_BLOCK, lores().get("streaker"), player) : reqLevel("§e50")); 103 | 104 | gui.setItem(24, level >= 60 ? setItem("Gladiator", Material.BONE, lores().get("gladiator"), player) : reqLevel("§6§l60")); 105 | gui.setItem(25, level >= 60 ? setItem("Vampire", Material.SPIDER_EYE, lores().get("vampire"), player) : reqLevel("§6§l60")); 106 | 107 | 108 | player.openInventory(gui); 109 | } 110 | 111 | public ItemStack reqLevel(String level) { 112 | List lore = new ArrayList<>(); 113 | ItemStack item = new ItemStack(Material.BEDROCK); 114 | ItemMeta meta = item.getItemMeta(); 115 | meta.setDisplayName("§cUnknown perk"); 116 | lore.add("§7Required level: [" + level + "§r§7]"); 117 | meta.setLore(lore); 118 | item.setItemMeta(meta); 119 | 120 | return item; 121 | } 122 | 123 | public HashMap> lores() { 124 | HashMap> lores = new HashMap<>(); 125 | lores.put("goldenheads", Arrays.asList("§7Golden apples you earn turn", "§7into §6Golden Heads§7.")); 126 | lores.put("fishingrod", Arrays.asList("§7Spawn with a fishing rod.")); 127 | lores.put("lavabucket", Arrays.asList("§7Spawn with a laval bucket.")); 128 | lores.put("strength", Arrays.asList("§c+5% damage", "§7stacking on kill.")); 129 | lores.put("endless", Arrays.asList("§7Get 3 arrows on arrow hit.")); 130 | lores.put("mineman", Arrays.asList("§7Spawn with §f24 Cobblestone", "§7and a diamond pickaxe", "", "§7+§f3 blocks §7on kill.")); 131 | lores.put("safety", Arrays.asList("§7Spawn with a helmet.")); 132 | lores.put("trickle", Arrays.asList("§7Picked up gold ingot", "§7rewards 7x more coins.")); 133 | lores.put("lucky", Arrays.asList("§730% chance to upgrade", "§7dropped armor pieces from", "§7kills to §bdiamond§7.", "", "§7Upgraded pieces warp to", "§7your inventory.")); 134 | lores.put("spammer", Arrays.asList("§7Double base gold reward on", "§7targets you've shot an", "§7arrow in.", "", "§6+2g §7on assists.")); 135 | lores.put("bounty", Arrays.asList("§6+4g §7on all kills.", "§7Earn bounty assists shares.", "", "§c+1% damage§7/100g bounty", "§7on target.")); 136 | lores.put("streaker", Arrays.asList("§7Triple streak kill §bXP", "§7bonus.")); 137 | lores.put("gladiator", Arrays.asList("§7Receive §9-3% §7damage per", "§7nearby player.", "", "§712 blocks range.", "§7Minimum 3, max 10 players.")); 138 | lores.put("vampire", Arrays.asList("§7Don't earn golden apples", "§7Heal §c0.5❤ §7on melee hit.", "§7Heal §c1.5❤ §7on arrow hit.")); 139 | 140 | return lores; 141 | } 142 | 143 | 144 | 145 | } 146 | 147 | 148 | -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | # Thanks for downloading my plugin. Make sure to enjoy it. 2 | # If you have any questions to hesitate to contact me. 3 | # _____ _ ____ _ _ 4 | # |_ _| | |__ ___ | _ \ (_) | |_ 5 | # | | | '_ \ / _ \ | |_) | | | | __| 6 | # | | | | | | | __/ | __/ | | | |_ 7 | # |_| |_| |_| \___| |_| |_| \__| 8 | # 9 | # This is a file to help you configure settings to your likings. It is recommended 10 | # to leave everything as it is, but, if you know what you're doing, feel free to change 11 | # it. If you do not understand what something does, please leave it as it is and ask for help 12 | 13 | general: #General stuff 14 | launchpad-power: 5.0 #How many power should launchpads have? (Slime Blocks turn into launchpads when using this plugin) [number] 15 | gold-on-pickup: 2.0 #When picking-up gold from the gold generators, how many gold should the player be rewarded with? [number] 16 | auto-respawn: true #When a player dies, should he get auto re-spawned? (Could be bugged) [true/false] 17 | fighting-time: 20 #For how many seconds should 'Fighting' appear in scoreboard when someone fights? In seconds [number] 18 | goldenheads-head: 'LegendaryJulien' #The name of the player for the Golden Heads perk. [text] 19 | spawn-mobs: false #Should mobs be spawned in the server? Might not work properly [true/false] 20 | fall-damage: false #Should players take fall damage when they fall? [true/false] 21 | lose-hunger: false #Should players lose hunger when they are on the server? [true/false] 22 | 23 | prices: #Costing 24 | items: #Prices for '/items' 25 | 1diamondsword: 100 #When purchasing a diamond sword, how many gold should the player charged? [number] 26 | 8obsidian: 40 #When purchasing 8 obsidian blocks, how many gold should the player charged? [number] 27 | 32arrows: 16 #When purchasing 32 arrows, how many gold should the player charged? [number] 28 | 1diamondplate: 250 #When purchasing a diamond chestplate, how many gold should the player charged? [number] 29 | 1diamondboots: 150 #When purchasing diamond boots, how many gold should the player charged? [number] 30 | upgrades: #Prices for '/upgrades' 31 | xpboost: 500 #When purchasing the XP Boost upgrade, how many gold should the player charged? [number] 32 | goldboost: 1000 #When purchasing the Gold Boost upgrade, how many gold should the player charged? [number] 33 | meleedamage: 450 #When purchasing the Melee Damage upgrade, how many gold should the player charged? [number] 34 | bowdamage: 450 #When purchasing the Bow Damage upgrade, how many gold should the player charged? [number] 35 | damagereduction: 450 #When purchasing the Damage Reduction upgrade, how many gold should the player charged? [number] 36 | buildbattler: 750 #When purchasing the Build Battler upgrade, how many gold should the player charged? [number] 37 | gatobattler: 1000 #When purchasing the Gato Battler upgrade, how many gold should the player charged? [number] 38 | perks: #Prices for '/perks' 39 | goldenheads: 500 #When purchasing the Golden Heads perk, how many gold should the player charged? [number] 40 | fishingrod: 1000 #When purchasing the Fishing Rod perk, how many gold should the player charged? [number] 41 | lavabucket: 1000 #When purchasing the Lava Bucket perk, how many gold should the player charged? [number] 42 | strengthchaining: 2000 #When purchasing the Strenght Chaining perk, how many gold should the player charged? [number] 43 | endlessquiver: 2000 #When purchasing the Endless Quiver perk, how many gold should the player charged? [number] 44 | spammer: 1000 #When purchasing the Spammer perk, how many gold should the player charged? [number] 45 | bountyhunter: 2000 #When purchasing the Bounty Hunter perk, how many gold should the player charged? [number] 46 | mineman: 3000 #When purchasing the MineMan perk, how many gold should the player charged? [number] 47 | safetyfirst: 3000 #When purchasing the Safety First perk, how many gold should the player charged? [number] 48 | trickledown: 4000 #When purchasing the Trickle Down perk, how many gold should the player charged? [number] 49 | luckydiamond: 4000 #When purchasing the Lucky Diamond perk, how many gold should the player charged? [number] 50 | streaker: 1000 #When purchasing the Streaker perk, how many gold should the player charged? [number] 51 | gladiator: 4000 #When purchasing the Gladiator perk, how many gold should the player charged? [number] 52 | vampire: 4000 #When purchasing the Vampire perk, how many gold should the player charged? [number] 53 | 54 | gold-generators: #Spawning gold 55 | required-players: 2 #How many players to require in order to start spawning gold? (Set to 0 to disable) [number] 56 | spawn-interval: 200 #Every how many seconds should gold randomly be spawned in the locations set? (In seconds) [number] 57 | 58 | signs: #Joining system 59 | lines: #The lines for signs 60 | - '&8[&6&lThePit&8]' #The first line [text] 61 | - 'Map: &8[&6%arena%&8]' #Same as above for the other lines. 62 | - 'Players: &8[&6%current%&7/&6%max%&8]' 63 | - 'Join: &8[&6Click Here&8]' 64 | 65 | actionbar: #Sending a pretty message 66 | hearts: #Hitting each-other 67 | format: '&7%player% %hearts%' #When player hits another player what message should be sent in the actionbar? [text] 68 | remain-hearts-color: '&4' #When replacing %hearts% above what should the color of the remaining hearts be? [text] 69 | lose-hearts-color: '&0' #When replacing %hearts% above what should the color of the lost hearts be? [text] 70 | kill: #Killing each-other 71 | format: '&7%player% &a&lKILL!' #When a player kills another player what message should be sent in the action to the killer? [text] 72 | 73 | titles: #Sending titles 74 | death-title: #Death 75 | title: '&cYOU DIED' #When a player dies, what title should be sent? [text] 76 | subtitle: '' #When a player dies, what subtitle should be sent? [text] 77 | level-up-title: #Level-up 78 | title: '&b&lLEVEL UP!' #When a player level-ups, what title should be sent? [text] 79 | subtitle: '&7[&3%oldlevel%&7] &7-> &7[&b%newlevel%&7]' #When a player level-ups, what subtitle should be sent? [text] 80 | 81 | format: #Formating 82 | chat-format: '&7[%lvl%&7] %player%: %message%' #When someone types in chat, how should the plugin format his message? [text] 83 | tablist-format: '&7[%lvl%&7] &7%player%' #When someone joins the server, how should the plugin format his tablist? [text] 84 | 85 | killstreaks: #Streaks 86 | - 5 #On what killstreak should a message be sent? [text] 87 | - 10 88 | - 15 89 | - 30 90 | 91 | bounties: #Bounties 92 | required-ks-for-bounty: 30 #After a player has reach an amount of killstreak there's an X chance that he will get bountied [number] 93 | bounty-chance: 7 #What should the chance of getting bountied be? [text] 94 | values: 95 | - 250 #Random bounty values [number] 96 | - 300 97 | - 200 98 | - 350 99 | 100 | scoreboard: #That little thing in the right middle of your screen 101 | update: 1 #Every how many half of a second should the scoreboard get updated? Example, putting 1 means it's going to update every half second, and putting 2 will update every second [number] 102 | title: '&e&lTHE PIT' #The title of the scoreboard [text] 103 | rows: #Rows for the scoreboard [text] 104 | - '&7%date%' 105 | - '&2&l' 106 | - 'Level: &7[&3%lvl%&7]' 107 | - 'Needed XP: &b%xp%' 108 | - '&4&l' 109 | - 'Gold: &6%gold%g' 110 | - '&7&l' 111 | - 'Status: %status%' 112 | - '&9&l' 113 | - '&emc.example.net' 114 | 115 | leveling-system: #Color, XP, Gold 116 | 0to9: #When a player is from level 0 to level 9. 117 | color: '&7' #When a player is from level 0 to level 9 what color should he have when formating? [text] 118 | xp-on-kill: 2 #When a player is from level 0 to level 9 how many XP should he earn when killing someone? [number] 119 | gold-on-kill: 10.00 #When a player is from level 0 to level 9 how many GOLD should he earn when killing someone? [number] 120 | 10to19: #Same as above for everything else in 'leveling-system' 121 | color: '&9' 122 | xp-on-kill: 4 123 | gold-on-kill: 10.00 124 | 20to29: 125 | color: '&3' 126 | xp-on-kill: 5 127 | gold-on-kill: 13.00 128 | 30to39: 129 | color: '&2' 130 | xp-on-kill: 5 131 | gold-on-kill: 13.00 132 | 40to49: 133 | color: '&a' 134 | xp-on-kill: 6 135 | gold-on-kill: 15.00 136 | 50to59: 137 | color: '&e' 138 | xp-on-kill: 7 139 | gold-on-kill: 15.00 140 | 60to69: 141 | color: '&6&l' 142 | xp-on-kill: 8 143 | gold-on-kill: 16.00 144 | 70to79: 145 | color: '&c&l' 146 | xp-on-kill: 9 147 | gold-on-kill: 17.00 148 | 80to89: 149 | color: '&4&l' 150 | xp-on-kill: 10 151 | gold-on-kill: 19.00 152 | 90to99: 153 | color: '&5&l' 154 | xp-on-kill: 12 155 | gold-on-kill: 22.00 156 | 100to109: 157 | color: '&d&l' 158 | xp-on-kill: 14 159 | gold-on-kill: 24.00 160 | 110to119: 161 | color: '&f&l' 162 | xp-on-kill: 16 163 | gold-on-kill: 26.00 164 | 120: 165 | color: '&b&l' 166 | xp-on-kill: 0 167 | gold-on-kill: 30.00 -------------------------------------------------------------------------------- /src/com/LagBug/ThePit/Main.java: -------------------------------------------------------------------------------- 1 | package com.LagBug.ThePit; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.ChatColor; 11 | import org.bukkit.Location; 12 | import org.bukkit.block.BlockState; 13 | import org.bukkit.block.Sign; 14 | import org.bukkit.command.ConsoleCommandSender; 15 | import org.bukkit.configuration.file.FileConfiguration; 16 | import org.bukkit.configuration.file.YamlConfiguration; 17 | import org.bukkit.entity.Player; 18 | import org.bukkit.plugin.java.JavaPlugin; 19 | 20 | import com.LagBug.ThePit.Commands.ItemsCommand; 21 | import com.LagBug.ThePit.Commands.PerksCommand; 22 | import com.LagBug.ThePit.Commands.PitCommand; 23 | import com.LagBug.ThePit.Commands.UpgradesCommand; 24 | import com.LagBug.ThePit.Events.OnBreak; 25 | import com.LagBug.ThePit.Events.OnChat; 26 | import com.LagBug.ThePit.Events.OnDeath; 27 | import com.LagBug.ThePit.Events.OnFall; 28 | import com.LagBug.ThePit.Events.OnFight; 29 | import com.LagBug.ThePit.Events.OnHunger; 30 | import com.LagBug.ThePit.Events.OnInteract; 31 | import com.LagBug.ThePit.Events.OnJoin; 32 | import com.LagBug.ThePit.Events.OnLeave; 33 | import com.LagBug.ThePit.Events.OnLevelUp; 34 | import com.LagBug.ThePit.Events.OnMobSpawn; 35 | import com.LagBug.ThePit.Events.OnMove; 36 | import com.LagBug.ThePit.Events.OnPickUp; 37 | import com.LagBug.ThePit.Events.OnPlace; 38 | import com.LagBug.ThePit.Events.OnRespawn; 39 | import com.LagBug.ThePit.Events.OnSignChange; 40 | import com.LagBug.ThePit.GUIListners.HelpGUIListener; 41 | import com.LagBug.ThePit.GUIListners.ItemsGUIListener; 42 | import com.LagBug.ThePit.GUIListners.PerksGUIListener; 43 | import com.LagBug.ThePit.GUIListners.UpgradesGUIListener; 44 | import com.LagBug.ThePit.Others.CustomScoreboard; 45 | import com.LagBug.ThePit.Others.FileUtils; 46 | import com.LagBug.ThePit.Others.StringUtils; 47 | import com.LagBug.ThePit.Others.TabComplete; 48 | import com.LagBug.ThePit.Others.UpdateChecker; 49 | import com.LagBug.ThePit.Runnables.GoldRunnable; 50 | 51 | public class Main extends JavaPlugin { 52 | 53 | public ArrayList adminmode = new ArrayList<>(); 54 | public ArrayList isFighting = new ArrayList<>(); 55 | public ArrayList ElGato = new ArrayList<>(); 56 | 57 | public HashMap ks = new HashMap<>(); 58 | public HashMap bounty = new HashMap<>(); 59 | public HashMap playerArena = new HashMap<>(); 60 | public HashMap arenaCounter = new HashMap<>(); 61 | 62 | private ConsoleCommandSender c = Bukkit.getConsoleSender(); 63 | public UpdateChecker updater = new UpdateChecker(this, 61016); 64 | private FileUtils futils; 65 | 66 | @Override 67 | public void onEnable() { 68 | futils = new FileUtils(); 69 | updateSigns(); 70 | registerCommands(); 71 | registerEvents(); 72 | updateScoreboard(); 73 | c.sendMessage("--------------------------------------------------"); 74 | c.sendMessage(" [ThePit] Successfully enabled ThePit."); 75 | c.sendMessage(" [ThePit] Running version " + updater.getCurrentVersion()); 76 | c.sendMessage("--------------------------------------------------"); 77 | 78 | switch (updater.getResult()) { 79 | case ERROR: 80 | c.sendMessage(" [ThePit] Failed to check for updates."); 81 | break; 82 | case FOUND: 83 | c.sendMessage(" [ThePit] Found a new update! Download it using the following link:"); 84 | c.sendMessage(" [ThePit] https://www.spigotmc.org/resources/ThePit.61016/"); 85 | break; 86 | case NOT_FOUND: 87 | c.sendMessage(" [ThePit] No updates were found, you are using the latest version."); 88 | break; 89 | case DEVELOPMENT: 90 | c.sendMessage(" [ThePit] You are running a development build, this is not stable."); 91 | break; 92 | } 93 | c.sendMessage("--------------------------------------------------"); 94 | 95 | } 96 | 97 | @Override 98 | public void onDisable() { 99 | unregisterPlayers(); 100 | c.sendMessage("--------------------------------------------------"); 101 | c.sendMessage(" [ThePit] Successfully disabled ThePit."); 102 | c.sendMessage("--------------------------------------------------"); 103 | 104 | } 105 | 106 | 107 | public YamlConfiguration getDataFile() { 108 | return futils.getDataFile(); 109 | } 110 | 111 | public YamlConfiguration getArenaFile() { 112 | return futils.getArenaFile(); 113 | } 114 | 115 | public YamlConfiguration getMessagesFile() { 116 | return futils.getMessagesFile(); 117 | } 118 | 119 | public YamlConfiguration getItemsFile() { 120 | return futils.getItemsFile(); 121 | } 122 | 123 | public YamlConfiguration getUpgradesFile() { 124 | return futils.getUpgradesFile(); 125 | } 126 | 127 | public void saveFiles() { 128 | try { 129 | getDataFile().save(futils.getDataData()); 130 | getArenaFile().save(futils.getArenaData()); 131 | getItemsFile().save(futils.getItemsData()); 132 | getMessagesFile().save(futils.getMessagesData()); 133 | getUpgradesFile().save(futils.getUpgradesData()); 134 | reloadConfig(); 135 | 136 | } catch (IOException e) { 137 | e.printStackTrace(); 138 | } 139 | } 140 | 141 | public String getMessage(String path) { 142 | return ChatColor.translateAlternateColorCodes('&', getMessagesFile().getString(path)); 143 | } 144 | 145 | private void unregisterPlayers() { 146 | 147 | FileConfiguration dfile = getDataFile(); 148 | 149 | if (dfile.getString("lobby") != null) { 150 | if (!Bukkit.getOnlinePlayers().isEmpty()) { 151 | for (Player p : Bukkit.getOnlinePlayers()) { 152 | if (playerArena.get(p) != null && !playerArena.get(p).equals("") 153 | && dfile.getString("lobby") != null) { 154 | p.teleport(StringUtils.LocFromString(dfile.getString("lobby"))); 155 | } 156 | if (playerArena.get(p) != null && !playerArena.get(p).equals("")) { 157 | new CustomScoreboard(this).disableScoreboard(p); 158 | p.getInventory().clear(); 159 | } 160 | } 161 | } 162 | } 163 | 164 | } 165 | 166 | private void registerCommands() { 167 | getCommand("pit").setExecutor(new PitCommand()); 168 | getCommand("pit").setTabCompleter(new TabComplete()); 169 | getCommand("items").setExecutor(new ItemsCommand()); 170 | getCommand("upgrades").setExecutor(new UpgradesCommand()); 171 | getCommand("perks").setExecutor(new PerksCommand()); 172 | } 173 | 174 | private void updateScoreboard() { 175 | final CustomScoreboard sb = new CustomScoreboard(this); 176 | Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { 177 | public void run() { 178 | if (!Bukkit.getOnlinePlayers().isEmpty()) { 179 | for (Player p : Bukkit.getOnlinePlayers()) { 180 | if (playerArena.get(p) != null && !playerArena.get(p).equals("")) { 181 | sb.updateScoreboard(p); 182 | } 183 | } 184 | } 185 | } 186 | }, getConfig().getInt("scoreboard.update") * 10, getConfig().getInt("scoreboard.update") * 10); 187 | } 188 | 189 | private void updateSigns() { 190 | Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { 191 | public void run() { 192 | if (getArenaFile().getConfigurationSection("arenas") == null) { return; } 193 | for (String s : getArenaFile().getConfigurationSection("arenas").getKeys(false)) { 194 | if (arenaCounter.get(getArenaFile().getString("arenas." + s + ".name")) == null) { 195 | arenaCounter.put(getArenaFile().getString("arenas." + s + ".name"), 0); 196 | } 197 | if (getArenaFile().getStringList("arenas." + s + ".signs") == null) 198 | return; 199 | for (String l : getArenaFile().getStringList("arenas." + s + ".signs")) { 200 | String str2loc[] = l.split("\\:"); 201 | Location loc = new Location(Bukkit.getWorld(str2loc[0]), 0, 0, 0); 202 | loc.setX(Double.parseDouble(str2loc[1])); 203 | loc.setY(Double.parseDouble(str2loc[2])); 204 | loc.setZ(Double.parseDouble(str2loc[3])); 205 | 206 | BlockState state = null; 207 | Sign sign = null; 208 | 209 | try { 210 | state = loc.getBlock().getState(); 211 | sign = (Sign) state; 212 | } catch (Exception ex) { 213 | return; 214 | } 215 | 216 | for (int i = 0; i < sign.getLines().length; i++) { 217 | sign.setLine(i, replace(getConfig().getStringList("signs.lines").get(i), s, 218 | getArenaFile().getString("arenas." + s + ".name"))); 219 | sign.update(); 220 | } 221 | } 222 | } 223 | } 224 | }, 20, 20); 225 | } 226 | 227 | private String replace(String s, String sec, String arena) { 228 | s = s.replace("%arena%", getArenaFile().getString("arenas." + sec + ".name")); 229 | s = s.replace("%max%", Integer.toString(getArenaFile().getInt("arenas." + sec + ".maxPlayers"))); 230 | 231 | if (arenaCounter.get(arena) != null) { 232 | s = s.replace("%current%", Integer.toString(arenaCounter.get(arena))); 233 | } 234 | return ChatColor.translateAlternateColorCodes('&', s); 235 | } 236 | 237 | private void registerEvents() { 238 | Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new GoldRunnable(this), getConfig().getInt("gold-generators.spawn-interval") * 20, getConfig().getInt("gold-generators.spawn-interval") * 20); 239 | Bukkit.getPluginManager().registerEvents(new HelpGUIListener(), this); 240 | Bukkit.getPluginManager().registerEvents(new ItemsGUIListener(), this); 241 | Bukkit.getPluginManager().registerEvents(new UpgradesGUIListener(), this); 242 | Bukkit.getPluginManager().registerEvents(new PerksGUIListener(), this); 243 | Bukkit.getPluginManager().registerEvents(new OnJoin(), this); 244 | Bukkit.getPluginManager().registerEvents(new OnLeave(), this); 245 | Bukkit.getPluginManager().registerEvents(new OnPlace(), this); 246 | Bukkit.getPluginManager().registerEvents(new OnBreak(), this); 247 | Bukkit.getPluginManager().registerEvents(new OnDeath(), this); 248 | Bukkit.getPluginManager().registerEvents(new OnRespawn(), this); 249 | Bukkit.getPluginManager().registerEvents(new OnMove(), this); 250 | Bukkit.getPluginManager().registerEvents(new OnPickUp(), this); 251 | Bukkit.getPluginManager().registerEvents(new OnFight(), this); 252 | Bukkit.getPluginManager().registerEvents(new OnLevelUp(), this); 253 | Bukkit.getPluginManager().registerEvents(new OnChat(), this); 254 | Bukkit.getPluginManager().registerEvents(new OnFall(), this); 255 | Bukkit.getPluginManager().registerEvents(new OnMobSpawn(), this); 256 | Bukkit.getPluginManager().registerEvents(new OnHunger(), this); 257 | Bukkit.getPluginManager().registerEvents(new OnInteract(), this); 258 | Bukkit.getPluginManager().registerEvents(new OnSignChange(), this); 259 | } 260 | 261 | public List commands() { 262 | 263 | List cmds = new ArrayList<>(); 264 | 265 | cmds.add("/pit setspawn"); 266 | cmds.add("/pit adminmode"); 267 | cmds.add("/pit create"); 268 | cmds.add("/pit delete"); 269 | cmds.add("/pit setmax"); 270 | cmds.add("/pit join"); 271 | cmds.add("/pit leave"); 272 | cmds.add("/pit list"); 273 | cmds.add("/pit setlobby"); 274 | cmds.add("/pit setgold"); 275 | cmds.add("/pit addgold"); 276 | cmds.add("/pit remgold"); 277 | cmds.add("/pit setlevel"); 278 | cmds.add("/pit addlevel"); 279 | cmds.add("/pit remlevel"); 280 | cmds.add("/pit goldloc"); 281 | cmds.add("/pit launchpad"); 282 | cmds.add("/pit discord"); 283 | cmds.add("/pit reload"); 284 | 285 | Collections.sort(cmds); 286 | 287 | return cmds; 288 | } 289 | 290 | } 291 | --------------------------------------------------------------------------------