Skip to content

Commit

Permalink
Added basic team selector setup
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMAVA committed Dec 27, 2019
1 parent 6e00284 commit 67e86a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/me/PauMAVA/TTR/TTRCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class TTRCore extends JavaPlugin {

private static TTRCore instance;
private boolean enabled = false;
private boolean enabled = true;
private TTRMatch match;
private TTRTeamHandler teamHandler;
private TTRConfigManager configManager;
Expand Down Expand Up @@ -64,4 +64,8 @@ public TTRMatch getCurrentMatch() {
public TTRTeamHandler getTeamHandler() {
return this.teamHandler;
}

public TTRConfigManager getConfigManager() {
return this.configManager;
}
}
5 changes: 5 additions & 0 deletions src/me/PauMAVA/TTR/config/TTRConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

public class TTRConfigManager {

Expand Down Expand Up @@ -81,6 +82,10 @@ public int getTeamCount() {
return this.teamsSection.getKeys(false).size();
}

public Set<String> getTeamNames() {
return this.teamsSection.getKeys(false);
}

private ConfigurationSection getTeam(String teamName) {
for(String key: this.teamsSection.getKeys(false)) {
if(key.equalsIgnoreCase(teamName)) {
Expand Down
14 changes: 14 additions & 0 deletions src/me/PauMAVA/TTR/ui/TeamSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@

package me.PauMAVA.TTR.ui;

import me.PauMAVA.TTR.TTRCore;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class TeamSelector extends CustomUI {

private Player owner;
private int selected = -1;

public TeamSelector(Player player) {
super(27, "Team Selection");
this.owner = player;
setUp();
}

public void openSelector() {
Expand All @@ -37,4 +43,12 @@ public void closeSelector() {
super.closeUI(this.owner);
}

public void setUp() {
int i = 0;
for(String teamName: TTRCore.getInstance().getConfigManager().getTeamNames()) {
setSlot(i, new ItemStack(Material.valueOf(TTRCore.getInstance().getConfigManager().getTeamColor(teamName).name() + "_WOOL"), 1), TTRCore.getInstance().getConfigManager().getTeamColor(teamName) + teamName, null);
i++;
}
}

}

0 comments on commit 67e86a3

Please sign in to comment.