Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.5.32 dev #27

Merged
merged 2 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Bingo.iml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.27" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.github.PMFRTT:Core:16.5.32-dev">
<library name="Maven: com.github.PMFRTT:Core:16.5.40-dev">
<CLASSES>
<root url="jar://$MODULE_DIR$/../Core/target/Core-16.5.32-dev.jar!/" />
<root url="jar://$MODULE_DIR$/../Core/target/Core-16.5.40-dev.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
<dependency>
<groupId>com.github.PMFRTT</groupId>
<artifactId>Core</artifactId>
<version>16.5.32-dev</version>
<version>16.5.40-dev</version>
<scope>system</scope>
<systemPath>C:\Code\Java\Bukkit\Core\target\Core-16.5.32-dev.jar</systemPath>
<systemPath>C:\Code\Java\Bukkit\Core\target\Core-16.5.40-dev.jar</systemPath>
</dependency>
</dependencies>
</project>
29 changes: 17 additions & 12 deletions src/main/java/bingo/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
public class Banner {

private static HashMap<String, Timer> playerTimers = new HashMap<String, Timer>();
private static HashMap<String, Integer> playerIndexTimers = new HashMap<String, Integer>();
private static final HashMap<String, Integer> playerIndexTimers = new HashMap<String, Integer>();
private static boolean isRunning = false;

private static Plugin plugin;

Expand All @@ -48,17 +49,20 @@ public void run() {
Timer timer = playerTimers.get(player.getDisplayName());
Random random = new Random();
if (timer.getSeconds() == ((Integer) BingoPlugin.getBingoSettings().banningSettings.getSettingbyName("Erster Timeout").getValue() + playerIndexTimers.get(player.getDisplayName()) * (Integer) BingoPlugin.getBingoSettings().banningSettings.getSettingbyName("Bann Abstand").getValue()) && BingoInventory.bannedItem.get(player.getDisplayName()).size() < core.Utils.getSettingValueInt(BingoPlugin.getBingoSettings().banningSettings, "Anzahl der Items")) {
while (!banItem(player, BingoList.getBingoList().get(random.nextInt(BingoList.getBingoList().size()))));
while (!banItem(player, BingoList.getBingoList().get(random.nextInt(BingoList.getBingoList().size()))))
;
}
}
}
isRunning = !done;
if (done) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.closeInventory();
if (core.Utils.getSettingValueBool(BingoPlugin.getBingoSettings(), "Scatter Players")) {
scatterPlayer(player, scatterSize, true);
scatterPlayer(player, scatterSize, true, false);
}
}
isRunning = false;
cancel();
}
}
Expand All @@ -67,17 +71,18 @@ public void run() {

public static boolean banItem(Player player, Material material) {
if (BingoInventory.bannedItem.get(player.getDisplayName()).size() < core.Utils.getSettingValueInt(BingoPlugin.getBingoSettings().banningSettings, "Anzahl der Items")) {
if (!BingoList.playerCollectedList.get(player.getDisplayName()).contains(material)) {
assert BingoList.getBingoList() != null;
CheckInventory.playerBans.get(player.getDisplayName()).add(BingoList.getBingoList().indexOf(material));
BingoInventory.bannedItem.get(player.getDisplayName()).add(material);
BingoList.addMaterialToCollected(player, material);
SideList.updateScoreboard();
playerIndexTimers.put(player.getDisplayName(), playerIndexTimers.get(player.getDisplayName()) + 1);
return true;
}
assert BingoList.getBingoList() != null;
CheckInventory.playerBans.get(player.getDisplayName()).add(BingoList.getBingoList().indexOf(material));
BingoInventory.bannedItem.get(player.getDisplayName()).add(material);
BingoList.addMaterialToCollected(player, material);
playerIndexTimers.put(player.getDisplayName(), playerIndexTimers.get(player.getDisplayName()) + 1);
return true;
}
return false;
}

public static boolean getRunning(){
return isRunning;
}

}
116 changes: 80 additions & 36 deletions src/main/java/bingo/SideList.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bingo;

import bingo.eventhandler.CheckInventory;
import bingo.main.BingoInventory;
import bingo.main.BingoList;
import bingo.main.BingoPlugin;
Expand All @@ -23,7 +24,7 @@

public class SideList {

Plugin plugin;
private static Plugin plugin;
private static final HashMap<String, Scoreboard> playerScoreboards = new HashMap<String, Scoreboard>();
private static final HashMap<String, ScoreboardDisplay> playerScoreboardsDisplay = new HashMap<String, ScoreboardDisplay>();

Expand All @@ -41,10 +42,14 @@ public void init() {
public void createPlayerScoreBoards() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (!playerScoreboards.containsKey(player.getDisplayName())) {
Scoreboard scoreboard = new Scoreboard(ScoreboardType.STATIC_TITLE, new ArrayList<String>() {{
add("Bingo");
Scoreboard scoreboard = new Scoreboard(ScoreboardType.MULTI_TITLE, new ArrayList<String>() {{
add(core.Utils.colorize(core.Utils.getRainbowString("Bingo") + "&f - by PMFRTT"));
add(core.Utils.colorize("Gefundene Items: &6" + BingoList.playerCollectedList.get(player.getDisplayName()).size() + "&7/&a" + BingoList.bingoList.size()));
}}, 0);
ScoreboardDisplay scoreboardDisplay = new ScoreboardDisplay(this.plugin, player);
scoreboard.addScore(new Score("", 2));
ScoreboardDisplay scoreboardDisplay = new ScoreboardDisplay(plugin, player);
scoreboardDisplay.setScoreboard(scoreboard);
scoreboardDisplay.enableTitlesList(300);
playerScoreboards.put(core.Utils.getDisplayName(player), scoreboard);
playerScoreboardsDisplay.put(core.Utils.getDisplayName(player), scoreboardDisplay);
} else {
Expand All @@ -56,55 +61,94 @@ public void createPlayerScoreBoards() {
}

public static void updateScoreboard() {
for (String name : playerScoreboards.keySet()) {
Player player = Bukkit.getPlayer(name);
Scoreboard scoreboard = playerScoreboards.get(name);
List<String> scores = new ArrayList<String>();
for (Score score : scoreboard.getScores()) {
scores.add(score.getContent());
}
for (Material material : BingoList.getBingoList(Objects.requireNonNull(player))) {
if (BingoList.playerCollectedList.get(name).contains(material)) {
removeScore(player, material);
Objects.requireNonNull(SummarizerCore.getSummarization(player)).lockedItem(material);
scoreboard.addScore(new Score(core.Utils.colorize("&a" + Utils.formatMaterialName(material)), -1));
} else if (player.getInventory().contains(material)) {
removeScore(player, material);
Objects.requireNonNull(SummarizerCore.getSummarization(player)).collectedItem(material);
scoreboard.addScore(new Score(core.Utils.colorize("&b" + Utils.formatMaterialName(material)), 0));
} else {
removeScore(player, material);
scoreboard.addScore(new Score(core.Utils.colorize("&c" + Utils.formatMaterialName(material)), 1));
if (!BingoPlugin.getTimer().isPaused()) {
CheckInventory.checkInventory(BingoList.bingoList.size());
for (String name : playerScoreboards.keySet()) {
Player player = Bukkit.getPlayer(name);
Scoreboard scoreboard = playerScoreboards.get(name);
List<String> scores = new ArrayList<String>();
for (Score score : scoreboard.getScores()) {
scores.add(score.getContent());
}
BingoInventory.updateInventory(player);
}
int i = 0;
for (Score score : scoreboard.getScores()) {
if (scores.contains(score.getContent())) {
i++;
for (Material material : BingoList.getBingoList(Objects.requireNonNull(player))) {
if (BingoList.playerCollectedList.get(name).contains(material)) {
removeScore(player, material);
Objects.requireNonNull(SummarizerCore.getSummarization(player)).lockedItem(material);
Score score = new Score(core.Utils.colorize("&a" + Utils.formatMaterialName(material)), -3);
score.setSuffix("&7 gefunden!");
scoreboard.addScore(score);
} else if (player.getInventory().contains(material)) {
removeScore(player, material);
Objects.requireNonNull(SummarizerCore.getSummarization(player)).collectedItem(material);
Score score = new Score(core.Utils.colorize("&b" + Utils.formatMaterialName(material)), 1);
score.setPrefix("&7Sperre ");
score.setSuffix("&7!");
scoreboard.addScore(score);
} else {
removeScore(player, material);
Score score = new Score(core.Utils.colorize("&c" + Utils.formatMaterialName(material)), 0);
if (BingoList.contains(material) == 0) {
score.setValue(0);
score.setPrefix("(&aX&f) &7Finde ");
} else if (BingoList.contains(material) == 1) {
score.setValue(-1);
score.setPrefix("(&6X&f) &7Finde ");
} else if (BingoList.contains(material) == 2) {
score.setValue(-2);
score.setPrefix("(&cX&f) &7Finde ");
}
score.setSuffix("&7!");
scoreboard.addScore(score);
}

scoreboard.getTitles().set(1, core.Utils.colorize("Gefundene Items: &6" + BingoList.playerCollectedList.get(player.getDisplayName()).size() + "&7/&a" + BingoList.bingoList.size()));
BingoInventory.updateInventory(player);
}
int i = 0;
for (Score score : scoreboard.getScores()) {
if (scores.contains(score.getContent())) {
i++;
}
}
if (i != BingoList.bingoList.size()) {
startRender(player);
}
}
if (i != core.Utils.getSettingValueInt(BingoPlugin.getBingoSettings(), "Items")) {
startRender(player);
}
}
}

private static void removeScore(Player player, Material material) {
Scoreboard scoreboard = playerScoreboards.get(player.getDisplayName());

Scoreboard scoreboard = getScoreboard(player);

scoreboard.removeScoreByName(core.Utils.colorize("&a" + Utils.formatMaterialName(material)));
scoreboard.removeScoreByName(core.Utils.colorize("&b" + Utils.formatMaterialName(material)));
scoreboard.removeScoreByName(core.Utils.colorize("&c" + Utils.formatMaterialName(material)));
}

private static void startRender(Player player) {
playerScoreboardsDisplay.get(player.getDisplayName()).renderScoreboard(playerScoreboards.get(player.getDisplayName()));
DebugSender.sendDebug(DebugType.GUI, "rendered sidelist", "Sidelist");

Scoreboard scoreboard = getScoreboard(player);
ScoreboardDisplay display = getScoreboardDisplay(player);

if (scoreboard.getType().equals(ScoreboardType.STATIC_TITLE) || scoreboard.getType().equals(ScoreboardType.MULTI_TITLE)) {
display.renderScoreboard();
DebugSender.sendDebug(DebugType.GUI, "rendered sidelist", "Sidelist");
} else {
System.err.println("could not start render of scoreboard because the ScoreBoardType is not STATIC_TITLE (bingo.SideList:126)");
}
}

public static void removePlayer(Player player) {
playerScoreboards.remove(player.getDisplayName());
playerScoreboardsDisplay.remove(player.getDisplayName());
}

}
private static Scoreboard getScoreboard(Player player) {
return playerScoreboards.get(player.getDisplayName());
}

private static ScoreboardDisplay getScoreboardDisplay(Player player) {
return playerScoreboardsDisplay.get(player.getDisplayName());
}
}
Loading