Skip to content

Commit

Permalink
More lobby options
Browse files Browse the repository at this point in the history
Took 25 minutes
  • Loading branch information
TheNathanSpace committed Sep 2, 2021
1 parent 7396eb3 commit 7c6c4d0
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 25 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

- Names are all white
- Drop sand in spawn area
- can still get over wall barriers
- nullpointer
- Allow you to change the co-ords of lobby
- Add a command to toggle building when in said lobby.
- timer when stuck
- Can you add a config option for the assault command /help to not override normal /help if you have a permission?
- Add more game modifiers like First to 5 (stars) or Most stars in 8 minutes
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.thekingelessar.assault</groupId>
<artifactId>assault</artifactId>
<version>0.11.3</version>
<version>0.11.4</version>
<packaging>jar</packaging>
<name>Assault</name>
<url>https://github.com/thekingelessar/assault</url>
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/thekingelessar/assault/Assault.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import com.thekingelessar.assault.game.map.ItemShopTrait;
import com.thekingelessar.assault.game.map.Map;
import com.thekingelessar.assault.game.world.WorldManager;
import com.thekingelessar.assault.util.Coordinate;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.TraitInfo;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -33,6 +31,9 @@ public class Assault extends JavaPlugin
static public World lobbyWorld;
static public Location lobbySpawn;

static public GameMode lobbyGamemode = GameMode.ADVENTURE;
static public boolean forceLobbyInventory = true;

static public final String ASSAULT_PREFIX = "§5§l[§d§lAssault§5§l] " + ChatColor.RESET;

static public HashMap<String, Map> maps = new HashMap<>();
Expand All @@ -52,7 +53,10 @@ public void onEnable()
this.saveDefaultConfig();
mainConfig = this.getConfig();
lobbyWorld = Bukkit.getWorld(mainConfig.getString("lobby_world"));
lobbySpawn = new Location(lobbyWorld, 0.5, 101.5, 0.5, 90, 0);
lobbySpawn = new Coordinate(mainConfig.getString("lobby_spawn")).toLocation(lobbyWorld);

lobbyGamemode = GameMode.valueOf(mainConfig.getString("lobby_gamemode"));
forceLobbyInventory = mainConfig.getBoolean("force_lobby_inventory");

List<String> mapList = (List<String>) mainConfig.getList("map_list");
for (String mapName : mapList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ public void onInventoryClick(InventoryClickEvent inventoryClickEvent)
{
if (player.getWorld().equals(Assault.lobbyWorld))
{
if (itemStack != null)
if (Assault.forceLobbyInventory)
{
if (itemStack.equals(LobbyUtil.joinGameStar))
if (itemStack != null)
{
LobbyUtil.joinQueue(player);
if (itemStack.equals(LobbyUtil.joinGameStar))
{
LobbyUtil.joinQueue(player);
}

if (itemStack.getType().equals(Material.BARRIER))
{
LobbyUtil.leaveQueue(player);
}
}

if (itemStack.getType().equals(Material.BARRIER))
{
LobbyUtil.leaveQueue(player);
}
inventoryClickEvent.setCancelled(true);
}

inventoryClickEvent.setCancelled(true);
}

return;
Expand Down Expand Up @@ -107,7 +110,7 @@ else if (inventoryOpen.equals(gamePlayer.shopAttacking.inventory))
{
player.playSound(player.getLocation(), Sound.valueOf("BLOCK_CHEST_OPEN"), 0.5F, 1.3F);
}

player.openInventory(playerTeam.secretStorage);
inventoryClickEvent.setCancelled(true);
return;
Expand All @@ -128,7 +131,7 @@ else if (inventoryClickEvent.getInventory().equals(playerTeam.secretStorage))
{
player.playSound(player.getLocation(), Sound.valueOf("BLOCK_CHEST_CLOSE"), 0.5F, 1.3F);
}

player.openInventory(gamePlayer.shopAttacking.inventory);
inventoryClickEvent.setCancelled(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public void onInventoryClick(InventoryDragEvent inventoryDragEvent)
}

inventoryDragEvent.setCancelled(true);
// handlePlacingTop(inventoryDragEvent);
// handlePlacingTop(inventoryDragEvent);
}

// Couldn't get working satisfactorily. Wanted to protect shop inventories while allowing dragging in player inventories.
private void handlePlacingTop(InventoryDragEvent inventoryDragEvent)
{
Inventory destInvent = inventoryDragEvent.getInventory();
Expand Down Expand Up @@ -73,7 +74,7 @@ private void handlePlacingTop(InventoryDragEvent inventoryDragEvent)
itemStack.setAmount(inventoryDragEvent.getOldCursor().getAmount() - payment);
inventoryDragEvent.setCursor(itemStack);
}

System.out.println("This inventory has " + inventoryDragEvent.getInventory().getSize() + " slots!");
for (Map.Entry<Integer, ItemStack> entry : newItems.entrySet())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public void onItemDrop(PlayerDropItemEvent playerDropItemEvent)

if (itemStack != null)
{
List<ItemStack> undroppable = Arrays.asList(LobbyUtil.joinGameStar, LobbyUtil.rulesBook, LobbyUtil.inQueueStar, LobbyUtil.leaveBarrier, GameInstance.gameModifierItemStack);
if (undroppable.contains(itemStack))
if (LobbyUtil.undroppable.contains(itemStack))
{
playerDropItemEvent.setCancelled(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public void openShop(Player player)
inventoryView = player.openInventory(gameTeam.shopBuilding.inventory);
break;
case ATTACKING:
System.out.println("--- OPENING ATTACK SHOP ---");
System.out.println("Player name: " + gamePlayer.player.getName());
System.out.println("Player team: " + gamePlayer.gameTeam.color);
inventoryView = player.openInventory(gamePlayer.shopAttacking.inventory); // todo: nullpointer
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public void finishTimer()
title.clearTitle(player);

GamePlayer gamePlayer = gameInstance.getGamePlayer(player);

System.out.println("--- RESPAWNING ---");
System.out.println("Player name: " + gamePlayer.player.getName());
System.out.println("Player team: " + gamePlayer.gameTeam.color);
gamePlayer.spawn(PlayerMode.ATTACKING); // todo: nullpointer

gamePlayer.taskCountdownRespawn = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

Expand All @@ -22,6 +23,8 @@ public class LobbyUtil
public static ItemStack leaveBarrier = ItemInit.initBarrier();
public static ItemStack rulesBook = ItemInit.initBook();

public static List<ItemStack> undroppable = Arrays.asList(LobbyUtil.joinGameStar, LobbyUtil.rulesBook, LobbyUtil.inQueueStar, LobbyUtil.leaveBarrier, GameInstance.gameModifierItemStack);

public static List<Player> queueList = new ArrayList<>();

public static void joinQueue(Player player)
Expand Down Expand Up @@ -170,7 +173,7 @@ public static void joinLobby(Player player)
player.setDisplayName(player.getName());
player.setPlayerListName(player.getName());
player.setCustomName(player.getName());
player.setGameMode(GameMode.ADVENTURE);
player.setGameMode(Assault.lobbyGamemode);
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
LobbyUtil.giveStar(player);
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
lobby_world: lobby_world
lobby_spawn: 0.5 101.5 0.5 90 0
lobby_gamemode: ADVENTURE

# Allow players to rearrange their inventory while in the lobby
force_lobby_inventory: true

# References maps in the maps/ directory.
# Map files should be in the form map_[name].yml.
# Here, they can be either saloon, map_saloon, saloon.yml, or map_saloon.yml.
# They can take these forms: saloon, map_saloon, saloon.yml, or map_saloon.yml.
map_list:
- map_saloon

0 comments on commit 7c6c4d0

Please sign in to comment.